chiark / gitweb /
libudev: device - read database only when needed
[elogind.git] / udev / udevadm-monitor.c
index 29f819f43971840a043ad5f52426b7f5423e744f..26efa528af841f4a7a8feded67b1e3e17dd413aa 100644 (file)
@@ -1,19 +1,18 @@
 /*
- * Copyright (C) 2004-2006 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2004-2008 Kay Sievers <kay.sievers@vrfy.org>
  *
- *     This program is free software; you can redistribute it and/or modify it
- *     under the terms of the GNU General Public License as published by the
- *     Free Software Foundation version 2 of the License.
- * 
- *     This program is distributed in the hope that it will be useful, but
- *     WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *     General Public License for more details.
- * 
- *     You should have received a copy of the GNU General Public License along
- *     with this program; if not, write to the Free Software Foundation, Inc.,
- *     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
  *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <unistd.h>
@@ -42,18 +41,6 @@ static void asmlinkage sig_handler(int signum)
                udev_exit = 1;
 }
 
-static int print_properties_cb(struct udev_device *udev_device, const char *key, const char *value, void *data)
-{
-       printf("%s=%s\n", key, value);
-       return 0;
-}
-
-static void print_properties(struct udev_device *device)
-{
-       udev_device_get_properties(device, print_properties_cb, NULL);
-       printf("\n");
-}
-
 int udevadm_monitor(struct udev *udev, int argc, char *argv[])
 {
        struct sigaction act;
@@ -179,8 +166,16 @@ int udevadm_monitor(struct udev *udev, int argc, char *argv[])
                               udev_device_get_action(device),
                               udev_device_get_devpath(device),
                               udev_device_get_subsystem(device));
-                       if (env)
-                               print_properties(device);
+                       if (env) {
+                               struct udev_list *list;
+
+                               list = udev_device_get_properties_list(device);
+                               while (list != NULL) {
+                                       printf("%s=%s\n", udev_list_get_name(list), udev_list_get_value(list));
+                                       list = udev_list_get_next(list);
+                               }
+                               printf("\n");
+                       }
                        udev_device_unref(device);
                }
 
@@ -192,8 +187,16 @@ int udevadm_monitor(struct udev *udev, int argc, char *argv[])
                               udev_device_get_action(device),
                               udev_device_get_devpath(device),
                               udev_device_get_subsystem(device));
-                       if (env)
-                               print_properties(device);
+                       if (env) {
+                               struct udev_list *list;
+
+                               list = udev_device_get_properties_list(device);
+                               while (list != NULL) {
+                                       printf("%s=%s\n", udev_list_get_name(list), udev_list_get_value(list));
+                                       list = udev_list_get_next(list);
+                               }
+                               printf("\n");
+                       }
                        udev_device_unref(device);
                }
        }