]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/path/path.c
util-lib: split our string related calls from util.[ch] into its own file string...
[thirdparty/systemd.git] / src / path / path.c
index 37f2571faba8d7bc2dc26c518547709c7f8d2a6d..97e8323de13f0a9c1e7667febc69d8cea9089307 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <stdio.h>
-#include <getopt.h>
 #include <errno.h>
-#include <unistd.h>
+#include <getopt.h>
+#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "sd-path.h"
-#include "build.h"
+
+#include "log.h"
 #include "macro.h"
+#include "string-util.h"
 #include "util.h"
-#include "log.h"
 
 static const char *arg_suffix = NULL;
 
@@ -88,7 +87,7 @@ static int list_homes(void) {
                 if (q == -ENXIO)
                         continue;
                 if (q < 0) {
-                        log_error("Failed to query %s: %s", path_table[i], strerror(-r));
+                        log_error_errno(r, "Failed to query %s: %m", path_table[i]);
                         r = q;
                         continue;
                 }
@@ -108,10 +107,8 @@ static int print_home(const char *n) {
                         _cleanup_free_ char *p = NULL;
 
                         r = sd_path_home(i, arg_suffix, &p);
-                        if (r < 0) {
-                                log_error("Failed to query %s: %s", n, strerror(-r));
-                                return r;
-                        }
+                        if (r < 0)
+                                return log_error_errno(r, "Failed to query %s: %m", n);
 
                         printf("%s\n", p);
                         return 0;
@@ -119,7 +116,7 @@ static int print_home(const char *n) {
         }
 
         log_error("Path %s not known.", n);
-        return -ENOTSUP;
+        return -EOPNOTSUPP;
 }
 
 static void help(void) {
@@ -159,9 +156,7 @@ static int parse_argv(int argc, char *argv[]) {
                         return 0;
 
                 case ARG_VERSION:
-                        puts(PACKAGE_STRING);
-                        puts(SYSTEMD_FEATURES);
-                        return 0;
+                        return version();
 
                 case ARG_SUFFIX:
                         arg_suffix = optarg;