+/* get_path: Return a path name appropriate to be sent to the daemon.
+ *
+ * When talking to a local daemon (thru a UNIX socket), relative path names
+ * are resolved to absolute path names to allow for transparent integration
+ * into existing solutions (as requested by Tobi). Else, absolute path names
+ * are not allowed, since path name translation is done by the server.
+ *
+ * One must hold `lock' when calling this function. */
+static const char *get_path (const char *path, char *resolved_path) /* {{{ */
+{
+ const char *ret = path;
+ int is_unix = 0;
+
+ if ((*sd_path == '/')
+ || (strncmp ("unix:", sd_path, strlen ("unix:")) == 0))
+ is_unix = 1;
+
+ if (*path == '/') /* absolute path */
+ {
+ if (! is_unix)
+ {
+ rrd_set_error ("absolute path names not allowed when talking "
+ "to a remote daemon");
+ return (NULL);
+ }
+ /* else: nothing to do */
+ }
+ else /* relative path */
+ {
+ if (is_unix)
+ {
+ realpath (path, resolved_path);
+ ret = resolved_path;
+ }
+ /* else: nothing to do */
+ }
+ return (ret);
+} /* }}} char *get_path */
+