GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind);
+/**
+ * Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary and
+ * a prefix, construct the full path to the binary.
+ *
+ * @param progname name of the binary
+ * @param prefix the path to use as a prefix (if NULL this function is
+ * equivalent to GNUNET_OS_get_libexec_binary_path)
+ * @return full path to the binary, if possible, otherwise copy of 'progname'
+ */
+char *
+GNUNET_OS_get_binary_path (const char *progname, const char* prefix);
+
+
/**
* Given the name of a gnunet-helper, gnunet-service or gnunet-daemon
* binary, try to prefix it with the libexec/-directory to get the
/**
- * Given the name of a gnunet-helper, gnunet-service or gnunet-daemon
- * binary, try to prefix it with the libexec/-directory to get the
- * full path.
+ * Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary and
+ * a prefix, construct the full path to the binary.
*
* @param progname name of the binary
+ * @param prefix the path to use as a prefix (if NULL this function is
+ * equivalent to GNUNET_OS_get_libexec_binary_path)
* @return full path to the binary, if possible, otherwise copy of 'progname'
*/
char *
-GNUNET_OS_get_libexec_binary_path (const char *progname)
+GNUNET_OS_get_binary_path (const char *progname, const char* prefix)
{
- static char *cache;
- char *libexecdir;
+ static const char *cache;
+ const char *path;
char *binary;
if ( (DIR_SEPARATOR == progname[0]) ||
GNUNET_NO,
NULL, NULL)) )
return GNUNET_strdup (progname);
- if (NULL != cache)
- libexecdir = cache;
+ if (NULL != prefix)
+ path = prefix;
+ else if (NULL != cache)
+ path = cache;
else
- libexecdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBEXECDIR);
- if (NULL == libexecdir)
+ path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBEXECDIR);
+ if (NULL == path)
return GNUNET_strdup (progname);
GNUNET_asprintf (&binary,
"%s%s",
- libexecdir,
+ path,
progname);
- cache = libexecdir;
+ cache = path;
return binary;
}
+/**
+ * Given the name of a gnunet-helper, gnunet-service or gnunet-daemon
+ * binary, try to prefix it with the libexec/-directory to get the
+ * full path.
+ *
+ * @param progname name of the binary
+ * @return full path to the binary, if possible, otherwise copy of 'progname'
+ */
+char *
+GNUNET_OS_get_libexec_binary_path (const char *progname)
+{
+ return GNUNET_OS_get_binary_path (progname, NULL);
+}
+
+
/**
* Check whether an executable exists and possibly if the suid bit is
* set on the file. Attempts to find the file using the current PATH