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

libdpkg: Add new enum parsedbtype

This will allow to track more easily what's going on in the code, when
having to distinguish between behaviour depending on the file being
parsed.
Guillem Jover лет назад: 14
Родитель
Сommit
e73bc56d58
2 измененных файлов с 31 добавлено и 0 удалено
  1. 20 0
      lib/dpkg/parse.c
  2. 11 0
      lib/dpkg/parsedump.h

+ 20 - 0
lib/dpkg/parse.c

@@ -332,6 +332,25 @@ pkg_parse_copy(struct parsedb_state *ps,
   }
 }
 
+/**
+ * Return a descriptive parser type.
+ */
+static enum parsedbtype
+parse_get_type(struct parsedb_state *ps, enum parsedbflags flags)
+{
+  if (flags & pdb_recordavailable) {
+    if (flags & pdb_deb_control)
+      return pdb_file_control;
+    else
+      return pdb_file_available;
+  } else {
+    if (flags & pdb_deb_control)
+      return pdb_file_update;
+    else
+      return pdb_file_status;
+  }
+}
+
 /**
  * Open a file for RFC-822 parsing.
  */
@@ -343,6 +362,7 @@ parse_open(struct parsedb_state *ps, const char *filename,
   struct stat st;
 
   ps->filename = filename;
+  ps->type = parse_get_type(ps, flags);
   ps->flags = flags;
   ps->lno = 0;
   ps->pkg = NULL;

+ 11 - 0
lib/dpkg/parsedump.h

@@ -25,7 +25,18 @@
 
 struct fieldinfo;
 
+/**
+ * Parse action.
+ */
+enum parsedbtype {
+	pdb_file_update,
+	pdb_file_status,
+	pdb_file_control,
+	pdb_file_available,
+};
+
 struct parsedb_state {
+	enum parsedbtype type;
 	enum parsedbflags flags;
 	struct pkginfo *pkg;
 	struct pkgbin *pkgbin;