chiark / gitweb /
udev: move string copy functions to shared/
[elogind.git] / src / libudev / libudev-enumerate.c
index a945758e3820088d4f2441e44acb9874805c55b4..2c1f7ab4ace4d3cfc7cf5618afef6bb340742f8b 100644 (file)
@@ -1,13 +1,21 @@
-/*
- * libudev - interface to udev device information
- *
- * Copyright (C) 2008-2010 Kay Sievers <kay.sievers@vrfy.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- */
+/***
+  This file is part of systemd.
+
+  Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd 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
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -73,6 +81,8 @@ _public_ struct udev_enumerate *udev_enumerate_new(struct udev *udev)
 {
         struct udev_enumerate *udev_enumerate;
 
+        if (udev == NULL)
+                return NULL;
         udev_enumerate = calloc(1, sizeof(struct udev_enumerate));
         if (udev_enumerate == NULL)
                 return NULL;
@@ -649,11 +659,11 @@ static int scan_dir_and_add_devices(struct udev_enumerate *udev_enumerate,
         struct dirent *dent;
 
         s = path;
-        l = util_strpcpyl(&s, sizeof(path), "/sys/", basedir, NULL);
+        l = strpcpyl(&s, sizeof(path), "/sys/", basedir, NULL);
         if (subdir1 != NULL)
-                l = util_strpcpyl(&s, l, "/", subdir1, NULL);
+                l = strpcpyl(&s, l, "/", subdir1, NULL);
         if (subdir2 != NULL)
-                util_strpcpyl(&s, l, "/", subdir2, NULL);
+                strpcpyl(&s, l, "/", subdir2, NULL);
         dir = opendir(path);
         if (dir == NULL)
                 return -ENOENT;
@@ -667,7 +677,7 @@ static int scan_dir_and_add_devices(struct udev_enumerate *udev_enumerate,
                 if (!match_sysname(udev_enumerate, dent->d_name))
                         continue;
 
-                util_strscpyl(syspath, sizeof(syspath), path, "/", dent->d_name, NULL);
+                strscpyl(syspath, sizeof(syspath), path, "/", dent->d_name, NULL);
                 dev = udev_device_new_from_syspath(udev_enumerate->udev, syspath);
                 if (dev == NULL)
                         continue;
@@ -728,7 +738,7 @@ static int scan_dir(struct udev_enumerate *udev_enumerate, const char *basedir,
         DIR *dir;
         struct dirent *dent;
 
-        util_strscpyl(path, sizeof(path), "/sys/", basedir, NULL);
+        strscpyl(path, sizeof(path), "/sys/", basedir, NULL);
         dir = opendir(path);
         if (dir == NULL)
                 return -1;
@@ -779,7 +789,7 @@ static int scan_devices_tags(struct udev_enumerate *udev_enumerate)
                 struct dirent *dent;
                 char path[UTIL_PATH_SIZE];
 
-                util_strscpyl(path, sizeof(path), "/run/udev/tags/", udev_list_entry_get_name(list_entry), NULL);
+                strscpyl(path, sizeof(path), "/run/udev/tags/", udev_list_entry_get_name(list_entry), NULL);
                 dir = opendir(path);
                 if (dir == NULL)
                         continue;
@@ -789,7 +799,7 @@ static int scan_devices_tags(struct udev_enumerate *udev_enumerate)
                         if (dent->d_name[0] == '.')
                                 continue;
 
-                        dev = udev_device_new_from_id_filename(udev_enumerate->udev, dent->d_name);
+                        dev = udev_device_new_from_device_id(udev_enumerate->udev, dent->d_name);
                         if (dev == NULL)
                                 continue;