Pārlūkot izejas kodu

libdpkg: Make parse_stanza() a public function

Make public also the required parse helper macros and structures. At
least parse_EOF() will be needed for other callers to get out of the
loop when parsing multi-stanza files.
Guillem Jover 15 gadi atpakaļ
vecāks
revīzija
98aea15132
2 mainītis faili ar 21 papildinājumiem un 17 dzēšanām
  1. 1 17
      lib/dpkg/parse.c
  2. 20 0
      lib/dpkg/parsedump.h

+ 1 - 17
lib/dpkg/parse.c

@@ -93,15 +93,6 @@ static const struct nickname nicknames[] = {
   { .nick = NULL }
 };
 
-struct field_state {
-  const char *fieldstart;
-  const char *valuestart;
-  struct varbuf value;
-  int fieldlen;
-  int valuelen;
-  int *fieldencountered;
-};
-
 /**
  * Parse the field and value into the package being constructed.
  */
@@ -311,17 +302,10 @@ pkg_parse_copy(struct parsedb_state *ps,
   }
 }
 
-#define parse_EOF(ps)		((ps)->dataptr >= (ps)->endptr)
-#define parse_getc(ps)		*(ps)->dataptr++
-#define parse_ungetc(c, ps)	(ps)->dataptr--
-
-typedef void parse_field_func(struct parsedb_state *ps, struct field_state *fs,
-                              struct pkginfo *pkg, struct pkgbin *pkgbin);
-
 /**
  * Parse an RFC-822 style stanza.
  */
-static bool
+bool
 parse_stanza(struct parsedb_state *ps, struct field_state *fs,
              parse_field_func *parse_field,
              struct pkginfo *pkg, struct pkgbin *pkgbin)

+ 20 - 0
lib/dpkg/parsedump.h

@@ -34,6 +34,26 @@ struct parsedb_state {
 	int lno;
 };
 
+#define parse_EOF(ps)		((ps)->dataptr >= (ps)->endptr)
+#define parse_getc(ps)		*(ps)->dataptr++
+#define parse_ungetc(c, ps)	(ps)->dataptr--
+
+struct field_state {
+	const char *fieldstart;
+	const char *valuestart;
+	struct varbuf value;
+	int fieldlen;
+	int valuelen;
+	int *fieldencountered;
+};
+
+typedef void parse_field_func(struct parsedb_state *ps, struct field_state *fs,
+                              struct pkginfo *pkg, struct pkgbin *pkgbin);
+
+bool parse_stanza(struct parsedb_state *ps, struct field_state *fs,
+                  parse_field_func *parse_field,
+                  struct pkginfo *pkg, struct pkgbin *pkgbin);
+
 #define PKGIFPOFF(f) (offsetof(struct pkgbin, f))
 #define PKGPFIELD(pifp,of,type) (*(type*)((char*)(pifp)+(of)))