Browse Source

dpkg: Move match_node functions into a new file-match module

Guillem Jover 14 years ago
parent
commit
79b9f3afb1
4 changed files with 86 additions and 27 deletions
  1. 1 0
      src/Makefile.am
  2. 49 0
      src/file-match.c
  3. 35 0
      src/file-match.h
  4. 1 27
      src/processarc.c

+ 1 - 0
src/Makefile.am

@@ -33,6 +33,7 @@ dpkg_SOURCES = \
 	enquiry.c \
 	enquiry.c \
 	errors.c \
 	errors.c \
 	filesdb.c filesdb.h \
 	filesdb.c filesdb.h \
+	file-match.c file-match.h \
 	filters.c filters.h \
 	filters.c filters.h \
 	infodb.c infodb.h \
 	infodb.c infodb.h \
 	divertdb.c \
 	divertdb.c \

+ 49 - 0
src/file-match.c

@@ -0,0 +1,49 @@
+/*
+ * dpkg - main program for package management
+ * file-match.c - file name/type match tracking functions
+ *
+ * Copyright © 2011 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 "file-match.h"
+
+struct match_node *
+match_node_new(const char *name, const char *type, struct match_node *next)
+{
+	struct match_node *node;
+
+	node = m_malloc(sizeof(*node));
+	node->next = next;
+	node->filename = m_strdup(name);
+	node->filetype = m_strdup(type);
+
+	return node;
+}
+
+void
+match_node_free(struct match_node *node)
+{
+	free(node->filetype);
+	free(node->filename);
+	free(node);
+}

+ 35 - 0
src/file-match.h

@@ -0,0 +1,35 @@
+/*
+ * dpkg - main program for package management
+ * file-match.h - file name/type match tracking functions
+ *
+ * Copyright © 2011 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_FILE_MATCH_H
+#define DPKG_FILE_MATCH_H
+
+struct match_node {
+	struct match_node *next;
+	char *filetype;
+	char *filename;
+};
+
+struct match_node *
+match_node_new(const char *name, const char *type, struct match_node *next);
+void
+match_node_free(struct match_node *node);
+
+#endif /* DPKG_FILE_MATCH_H */

+ 1 - 27
src/processarc.c

@@ -51,6 +51,7 @@
 #include <dpkg/triglib.h>
 #include <dpkg/triglib.h>
 
 
 #include "filesdb.h"
 #include "filesdb.h"
+#include "file-match.h"
 #include "infodb.h"
 #include "infodb.h"
 #include "main.h"
 #include "main.h"
 #include "archives.h"
 #include "archives.h"
@@ -208,35 +209,8 @@ push_conflictor(struct pkginfo *pkg, struct pkginfo *pkg_fixbyrm)
   conflictor[cflict_index++] = pkg_fixbyrm;
   conflictor[cflict_index++] = pkg_fixbyrm;
 }
 }
 
 
-struct match_node {
-  struct match_node *next;
-  char *filetype;
-  char *filename;
-};
-
 static struct match_node *match_head = NULL;
 static struct match_node *match_head = NULL;
 
 
-static struct match_node *
-match_node_new(const char *name, const char *type, struct match_node *next)
-{
-  struct match_node *node;
-
-  node = m_malloc(sizeof(*node));
-  node->next = next;
-  node->filename = m_strdup(name);
-  node->filetype = m_strdup(type);
-
-  return node;
-}
-
-static void
-match_node_free(struct match_node *node)
-{
-  free(node->filetype);
-  free(node->filename);
-  free(node);
-}
-
 static void
 static void
 pkg_infodb_update_file(const char *filename, const char *filetype)
 pkg_infodb_update_file(const char *filename, const char *filetype)
 {
 {