#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include "dirname.h"
#include "errors.h"
#define FORMAT_VERSION 1
return 0;
}
-static int print_lib(const char *lib, const char *sym)
+static int print_lib_path(const char *path)
{
int ret;
- char path[GNUTLS_PATH_MAX];
char hmac[HMAC_STR_SIZE];
- ret = get_path(lib, sym, path, sizeof(path));
- if (ret < 0) {
- fprintf(stderr, "Could not get lib path for %s: %s\n",
- lib, gnutls_strerror(ret));
- return ret;
- }
-
ret = get_hmac(path, hmac, sizeof(hmac));
if (ret < 0) {
fprintf(stderr, "Could not calculate HMAC for %s: %s\n",
- lib, gnutls_strerror(ret));
+ last_component(path), gnutls_strerror(ret));
return ret;
}
- printf("[%s]\n", lib);
+ printf("[%s]\n", last_component(path));
printf("path = %s\n", path);
printf("hmac = %s\n", hmac);
return 0;
}
-int main(void)
+static int print_lib_dl(const char *lib, const char *sym)
+{
+ int ret;
+ char path[GNUTLS_PATH_MAX];
+
+ ret = get_path(lib, sym, path, sizeof(path));
+ if (ret < 0) {
+ fprintf(stderr, "Could not get lib path for %s: %s\n",
+ lib, gnutls_strerror(ret));
+ return ret;
+ }
+
+ return print_lib_path(path);
+}
+
+int main(int argc, char **argv)
{
+ int ret;
+
+ if (argc != 1 && argc != 2) {
+ fprintf(stderr, "Usage: %s [gnutls_so_path]\n", last_component(argv[0]));
+ return EXIT_FAILURE;
+ }
+
printf("[global]\n");
printf("format-version = %d\n", FORMAT_VERSION);
- if (print_lib(GNUTLS_LIBRARY_SONAME, "gnutls_global_init") < 0)
+ if (argc == 2)
+ ret = print_lib_path(argv[1]);
+ else
+ ret = print_lib_dl(GNUTLS_LIBRARY_SONAME, "gnutls_global_init");
+ if (ret < 0)
return EXIT_FAILURE;
- if (print_lib(NETTLE_LIBRARY_SONAME, "nettle_aes_set_encrypt_key") < 0)
+
+ ret = print_lib_dl(NETTLE_LIBRARY_SONAME, "nettle_aes_set_encrypt_key");
+ if (ret < 0)
return EXIT_FAILURE;
- if (print_lib(HOGWEED_LIBRARY_SONAME, "nettle_mpz_sizeinbase_256_u") < 0)
+
+ ret = print_lib_dl(HOGWEED_LIBRARY_SONAME, "nettle_mpz_sizeinbase_256_u");
+ if (ret < 0)
return EXIT_FAILURE;
- if (print_lib(GMP_LIBRARY_SONAME, "__gmpz_init") < 0)
+
+ ret = print_lib_dl(GMP_LIBRARY_SONAME, "__gmpz_init");
+ if (ret < 0)
return EXIT_FAILURE;
return EXIT_SUCCESS;