Просмотр исходного кода

Refactor glob functions into its own module

Guillem Jover лет назад: 16
Родитель
Сommit
c9fd580a2e
4 измененных файлов с 91 добавлено и 28 удалено
  1. 1 0
      src/Makefile.am
  2. 51 0
      src/glob.c
  3. 38 0
      src/glob.h
  4. 1 28
      src/statcmd.c

+ 1 - 0
src/Makefile.am

@@ -56,6 +56,7 @@ dpkg_query_LDADD = \
 	$(LIBINTL)
 	$(LIBINTL)
 
 
 dpkg_statoverride_SOURCES = \
 dpkg_statoverride_SOURCES = \
+	glob.c glob.h \
 	filesdb.c filesdb.h \
 	filesdb.c filesdb.h \
 	statdb.c \
 	statdb.c \
 	statcmd.c
 	statcmd.c

+ 51 - 0
src/glob.c

@@ -0,0 +1,51 @@
+/*
+ * dpkg - main program for package management
+ * glob.c - file globing functions
+ *
+ * Copyright © 2009, 2010 Guillem Jover <guillem@debian.org>
+ *
+ * This 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 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 <config.h>
+#include <compat.h>
+
+#include <stdlib.h>
+
+#include <dpkg/dpkg.h>
+
+#include "glob.h"
+
+void
+glob_list_prepend(struct glob_node **list, char *pattern)
+{
+	struct glob_node *node;
+
+	node = m_malloc(sizeof(*node));
+	node->pattern = pattern;
+	node->next = *list;
+	*list = node;
+}
+
+void
+glob_list_free(struct glob_node *head)
+{
+	while (head) {
+		struct glob_node *node = head;
+
+		head = head->next;
+		free(node->pattern);
+		free(node);
+	}
+}

+ 38 - 0
src/glob.h

@@ -0,0 +1,38 @@
+/*
+ * dpkg - main program for package management
+ * glob.h - file globing functions
+ *
+ * Copyright © 2009, 2010 Guillem Jover <guillem@debian.org>
+ *
+ * This 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 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/>.
+ */
+
+#ifndef DPKG_GLOB_H
+#define DPKG_GLOB_H
+
+#include <dpkg/macros.h>
+
+DPKG_BEGIN_DECLS
+
+struct glob_node {
+	struct glob_node *next;
+	char *pattern;
+};
+
+void glob_list_prepend(struct glob_node **list, char *pattern);
+void glob_list_free(struct glob_node *head);
+
+DPKG_END_DECLS
+
+#endif /* DPKG_GLOB_H */

+ 1 - 28
src/statcmd.c

@@ -45,6 +45,7 @@
 #include <dpkg/myopt.h>
 #include <dpkg/myopt.h>
 
 
 #include "main.h"
 #include "main.h"
+#include "glob.h"
 #include "filesdb.h"
 #include "filesdb.h"
 
 
 const char thisname[] = "dpkg-statoverrides";
 const char thisname[] = "dpkg-statoverrides";
@@ -329,34 +330,6 @@ statoverride_remove(const char *const *argv)
 	return 0;
 	return 0;
 }
 }
 
 
-struct glob_node {
-	struct glob_node *next;
-	char *pattern;
-};
-
-static void
-glob_list_prepend(struct glob_node **list, char *pattern)
-{
-	struct glob_node *node;
-
-	node = m_malloc(sizeof(*node));
-	node->pattern = pattern;
-	node->next = *list;
-	*list = node;
-}
-
-static void
-glob_list_free(struct glob_node *head)
-{
-	while (head) {
-		struct glob_node *node = head;
-
-		head = head->next;
-		free(node->pattern);
-		free(node);
-	}
-}
-
 static int
 static int
 statoverride_list(const char *const *argv)
 statoverride_list(const char *const *argv)
 {
 {