The following commit has been merged in the master branch:
commit e66836854ef51b5b5ce0b95a61adbf13f8dcd660
Author: Guillem Jover <[email protected]>
Date: Sun Oct 24 03:49:22 2010 +0200
libdpkg: Add new namevalue_find_by_name function
diff --git a/lib/dpkg/Makefile.am b/lib/dpkg/Makefile.am
index 1604549..9f20125 100644
--- a/lib/dpkg/Makefile.am
+++ b/lib/dpkg/Makefile.am
@@ -41,6 +41,7 @@ libdpkg_a_SOURCES = \
md5.c md5.h \
mlib.c \
myopt.c \
+ namevalue.c \
nfmalloc.c \
parse.c \
parsehelp.c \
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index 319d895..8bffb37 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -77,6 +77,9 @@ LIBDPKG_PRIVATE {
glob_list_prepend;
glob_list_free;
+ # Data structure functions
+ namevalue_find_by_name;
+
# Buffer I/O functions
buffer_init;
buffer_read;
diff --git a/lib/dpkg/dir.h b/lib/dpkg/namevalue.c
similarity index 66%
copy from lib/dpkg/dir.h
copy to lib/dpkg/namevalue.c
index 560abf8..f425c4c 100644
--- a/lib/dpkg/dir.h
+++ b/lib/dpkg/namevalue.c
@@ -1,6 +1,6 @@
/*
* libdpkg - Debian packaging suite library routines
- * dir.h - directory handling routines
+ * namevalue.c - name value structure handling
*
* Copyright © 2010 Guillem Jover <[email protected]>
*
@@ -18,20 +18,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef LIBDPKG_DIR_H
-#define LIBDPKG_DIR_H
+#include <config.h>
+#include <compat.h>
-#include <dpkg/macros.h>
+#include <stddef.h>
-#include <dirent.h>
+#include <dpkg/namevalue.h>
-DPKG_BEGIN_DECLS
+const struct namevalue *
+namevalue_find_by_name(const struct namevalue *head, const char *str)
+{
+ const struct namevalue *nv;
-void dir_sync(DIR *dir, const char *path);
-void dir_sync_path(const char *path);
-void dir_sync_path_parent(const char *path);
-void dir_sync_contents(const char *path);
+ for (nv = head; nv->name; nv++)
+ if (strncasecmp(str, nv->name, nv->length) == 0)
+ return nv;
-DPKG_END_DECLS
-
-#endif /* LIBDPKG_DIR_H */
+ return NULL;
+}
diff --git a/lib/dpkg/namevalue.h b/lib/dpkg/namevalue.h
index a512a4e..c896e3e 100644
--- a/lib/dpkg/namevalue.h
+++ b/lib/dpkg/namevalue.h
@@ -3,7 +3,7 @@
* namevalue.h - name value structure handling
*
* Copyright © 1994,1995 Ian Jackson <[email protected]>
- * Copyright © 2009 Guillem Jover <[email protected]>
+ * Copyright © 2009-2010 Guillem Jover <[email protected]>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,6 +35,9 @@ struct namevalue {
#define NAMEVALUE_DEF(n, v) \
[v] = { .name = n, .value = v, .length = sizeof(n) - 1 }
+const struct namevalue *namevalue_find_by_name(const struct namevalue *head,
+ const char *str);
+
DPKG_END_DECLS
#endif /* LIBDPKG_NAMEVALUE_H */
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]