chiark / gitweb /
[PATCH] escape dashes in man pages
[elogind.git] / udevinfo.c
index aa9d20a7736a7cb19b67133a551658a204bbe236..defed2ee31a96e38aeaae3d0346323d2af778097 100644 (file)
 #include <unistd.h>
 #include <errno.h>
 
+#include "libsysfs/sysfs/libsysfs.h"
+#include "libsysfs/dlist.h"
 #include "udev.h"
 #include "udev_version.h"
 #include "logging.h"
 #include "udevdb.h"
-#include "libsysfs/libsysfs.h"
 
 
 # define SYSFS_VALUE_MAX 200
 char **main_argv;
 int main_argc;
 
+#ifdef LOG
+unsigned char logname[42];
+void log_message (int level, const char *format, ...)
+{
+       va_list args;
+
+       va_start(args, format);
+       vsyslog(level, format, args);
+       va_end(args);
+}
+#endif
+
 static int print_all_attributes(const char *path)
 {
        struct dlist *attributes;
@@ -60,7 +73,7 @@ static int print_all_attributes(const char *path)
 
        dlist_for_each_data(attributes, attr, struct sysfs_attribute) {
                if (attr->value != NULL) {
-                       strncpy(value, attr->value, SYSFS_VALUE_MAX);
+                       strfieldcpy(value, attr->value);
                        len = strlen(value);
                        if (len == 0)
                                continue;
@@ -78,7 +91,7 @@ static int print_all_attributes(const char *path)
                                len--;
                        }
                        if (len == 0)
-                               printf("    SYSFS_%s=\"%s\"\n", attr->name, value);
+                               printf("    SYSFS{%s}=\"%s\"\n", attr->name, value);
                }
        }
        printf("\n");
@@ -293,8 +306,8 @@ static int process_options(void)
                        } else {
                                if (path[0] != '/') {
                                        /* prepend '/' if missing */
-                                       strcat(temp, "/");
-                                       strncat(temp, path, sizeof(path));
+                                       strfieldcat(temp, "/");
+                                       strfieldcat(temp, path);
                                        pos = temp;
                                } else {
                                        pos = path;
@@ -330,7 +343,7 @@ print:
                case NAME:
                        if (root)
                                strfieldcpy(result, udev_root);
-                       strncat(result, dev.name, sizeof(result));
+                       strfieldcat(result, dev.name);
                        break;
 
                case SYMLINK:
@@ -372,7 +385,7 @@ exit:
                                /* prepend sysfs mountpoint if not given */
                                strfieldcpy(temp, path);
                                strfieldcpy(path, sysfs_path);
-                               strncat(path, temp, sizeof(path));
+                               strfieldcat(path, temp);
                        }
                        print_device_chain(path);
                        return 0;
@@ -397,7 +410,7 @@ help:
               "  -n NAME  node name used for query\n"
               "\n"
               "  -r       print udev root\n"
-              "  -a       print all attributes along the chain of the device\n"
+              "  -a       print all SYSFS_attributes along the device chain\n"
               "  -d       dump whole database\n"
               "  -V       print udev version\n"
               "  -h       print this help text\n"
@@ -412,6 +425,8 @@ int main(int argc, char *argv[], char *envp[])
        main_argv = argv;
        main_argc = argc;
 
+       init_logging("udevinfo");
+
        /* initialize our configuration */
        udev_init_config();