- more cleanup and return type fixes
authorMichael Schroeder <mls@suse.de>
Mon, 19 Mar 2012 16:29:28 +0000 (17:29 +0100)
committerMichael Schroeder <mls@suse.de>
Mon, 19 Mar 2012 16:29:28 +0000 (17:29 +0100)
ext/pool_fileconflicts.c
ext/repo_helix.c
ext/repo_products.c
ext/repo_repomdxml.c
ext/repo_rpmdb.c
ext/repo_rpmmd.c
ext/repo_zyppdb.c

index 441743f..5b51bee 100644 (file)
@@ -230,7 +230,7 @@ findfileconflicts2_cb(void *cbdatav, const char *fn, int fmode, const char *md5)
   strncpy(md5padded, md5, 32);
   md5padded[32] = 0;
   md5padded[33] = fmode >> 24;
-  // printf("%d, hx %x -> %s   %d %s\n", cbdata->idx, hx, fn, fmode, md5);
+  /* printf("%d, hx %x -> %s   %d %s\n", cbdata->idx, hx, fn, fmode, md5); */
   queue_push(&cbdata->files, cbdata->filesspacen);
   addfilesspace(cbdata, (unsigned char *)md5padded, 34);
   addfilesspace(cbdata, (unsigned char *)fn, strlen(fn) + 1);
index aa69f20..8e74efa 100644 (file)
@@ -144,29 +144,29 @@ static struct stateswitch stateswitches[] = {
  */
 
 typedef struct _parsedata {
-  // XML parser data
+  /* XML parser data */
   int depth;
-  enum state state;    // current state
+  enum state state;    /* current state */
   int statedepth;
-  char *content;       // buffer for content of node
-  int lcontent;                // actual length of current content
-  int acontent;                // actual buffer size
-  int docontent;       // handle content
-
-  // repo data
-  Pool *pool;          // current pool
-  Repo *repo;          // current repo
-  Repodata *data;       // current repo data
-  Solvable *solvable;  // current solvable
-  Offset freshens;     // current freshens vector
-
-  // package data
-  int  epoch;          // epoch (as offset into evrspace)
-  int  version;                // version (as offset into evrspace)
-  int  release;                // release (as offset into evrspace)
-  char *evrspace;      // buffer for evr
-  int  aevrspace;      // actual buffer space
-  int  levrspace;      // actual evr length
+  char *content;       /* buffer for content of node */
+  int lcontent;                /* actual length of current content */
+  int acontent;                /* actual buffer size */
+  int docontent;       /* handle content */
+
+  /* repo data */
+  Pool *pool;          /* current pool */
+  Repo *repo;          /* current repo */
+  Repodata *data;       /* current repo data */
+  Solvable *solvable;  /* current solvable */
+  Offset freshens;     /* current freshens vector */
+
+  /* package data */
+  int  epoch;          /* epoch (as offset into evrspace) */
+  int  version;                /* version (as offset into evrspace) */
+  int  release;                /* release (as offset into evrspace) */
+  char *evrspace;      /* buffer for evr */
+  int  aevrspace;      /* actual buffer space */
+  int  levrspace;      /* actual evr length */
   char *kind;
 
   struct stateswitch *swtab[NUMSTATES];
@@ -177,7 +177,7 @@ typedef struct _parsedata {
 /*------------------------------------------------------------------*/
 /* E:V-R handling */
 
-// create Id from epoch:version-release
+/* create Id from epoch:version-release */
 
 static Id
 evr2id(Pool *pool, Parsedata *pd, const char *e, const char *v, const char *r)
@@ -185,38 +185,38 @@ evr2id(Pool *pool, Parsedata *pd, const char *e, const char *v, const char *r)
   char *c;
   int l;
 
-  // treat explitcit 0 as NULL
+  /* treat explitcit 0 as NULL */
   if (e && !strcmp(e, "0"))
     e = NULL;
 
   if (v && !e)
     {
       const char *v2;
-      // scan version for ":"
-      for (v2 = v; *v2 >= '0' && *v2 <= '9'; v2++)     // skip leading digits
+      /* scan version for ":" */
+      for (v2 = v; *v2 >= '0' && *v2 <= '9'; v2++)     /* skip leading digits */
         ;
-      // if version contains ":", set epoch to "0"
+      /* if version contains ":", set epoch to "0" */
       if (v2 > v && *v2 == ':')
        e = "0";
     }
   
-  // compute length of Id string
-  l = 1;  // for the \0
+  /* compute length of Id string */
+  l = 1;  /* for the \0 */
   if (e)
-    l += strlen(e) + 1;  // e:
+    l += strlen(e) + 1;  /* e: */
   if (v)
-    l += strlen(v);      // v
+    l += strlen(v);      /* v */
   if (r)
-    l += strlen(r) + 1;  // -r
+    l += strlen(r) + 1;  /* -r */
 
-  // extend content if not sufficient
+  /* extend content if not sufficient */
   if (l > pd->acontent)
     {
       pd->content = (char *)realloc(pd->content, l + 256);
       pd->acontent = l + 256;
     }
 
-  // copy e-v-r to content
+  /* copy e-v-r to content */
   c = pd->content;
   if (e)
     {
@@ -236,22 +236,22 @@ evr2id(Pool *pool, Parsedata *pd, const char *e, const char *v, const char *r)
       c += strlen(c);
     }
   *c = 0;
-  // if nothing inserted, return Id 0
+  /* if nothing inserted, return Id 0 */
   if (!*pd->content)
     return ID_NULL;
 #if 0
   fprintf(stderr, "evr: %s\n", pd->content);
 #endif
-  // intern and create
+  /* intern and create */
   return pool_str2id(pool, pd->content, 1);
 }
 
 
-// create e:v-r from attributes
-// atts is array of name,value pairs, NULL at end
-//   even index into atts is name
-//   odd index is value
-//
+/* create e:v-r from attributes
+ * atts is array of name,value pairs, NULL at end
+ *   even index into atts is name
+ *   odd index is value
+ */
 static Id
 evr_atts2id(Pool *pool, Parsedata *pd, const char **atts)
 {
@@ -424,14 +424,14 @@ startElement(void *userData, const char *name, const char **atts)
       return;
     }
   
-  // set new state
+  /* set new state */
   pd->state = sw->to;
 
   pd->docontent = sw->docontent;
   pd->statedepth = pd->depth;
 
-  // start with empty content
-  // (will collect data until end element
+  /* start with empty content */
+  /* (will collect data until end element) */
   pd->lcontent = 0;
   *pd->content = 0;
 
@@ -605,7 +605,7 @@ endElement(void *userData, const char *name)
   if (pd->depth != pd->statedepth)
     {
       pd->depth--;
-      // printf("back from unknown %d %d %d\n", pd->state, pd->depth, pd->statedepth);
+      /* printf("back from unknown %d %d %d\n", pd->state, pd->depth, pd->statedepth); */
       return;
     }
 
@@ -770,7 +770,7 @@ endElement(void *userData, const char *name)
     }
   pd->state = pd->sbtab[pd->state];
   pd->docontent = 0;
-  // printf("back from known %d %d %d\n", pd->state, pd->depth, pd->statedepth);
+  /* printf("back from known %d %d %d\n", pd->state, pd->depth, pd->statedepth); */
 }
 
 
@@ -787,18 +787,18 @@ characterData(void *userData, const XML_Char *s, int len)
   int l;
   char *c;
 
-  // check if current nodes content is interesting
+  /* check if current nodes content is interesting */
   if (!pd->docontent)
     return;
 
-  // adapt content buffer
+  /* adapt content buffer */
   l = pd->lcontent + len + 1;
   if (l > pd->acontent)
     {
       pd->content = (char *)realloc(pd->content, l + 256);
       pd->acontent = l + 256;
     }
-  // append new content to buffer
+  /* append new content to buffer */
   c = pd->content + pd->lcontent;
   pd->lcontent += len;
   while (len-- > 0)
@@ -852,14 +852,14 @@ repo_add_helix(Repo *repo, FILE *fp, int flags)
   pd.levrspace = 1;
   pd.data = data;
 
-  // set up XML parser
+  /* set up XML parser */
 
   parser = XML_ParserCreate(NULL);
   XML_SetUserData(parser, &pd);       /* make parserdata available to XML callbacks */
   XML_SetElementHandler(parser, startElement, endElement);
   XML_SetCharacterDataHandler(parser, characterData);
 
-  // read/parse XML file
+  /* read/parse XML file */
   for (;;)
     {
       l = fread(buf, 1, sizeof(buf), fp);
index 2613da6..c15051a 100644 (file)
 #include "tools_util.h"
 #include "repo_content.h"
 #include "repo_zyppdb.h"
+#include "repo_products.h"
 #include "repo_releasefile_products.h"
 
 
-//#define DUMPOUT 0
-
 enum state {
-  STATE_START,           // 0
-  STATE_PRODUCT,         // 1
-  STATE_VENDOR,          // 2
-  STATE_NAME,            // 3
-  STATE_VERSION,         // 4
-  STATE_RELEASE,         // 5
-  STATE_ARCH,            // 6
-  STATE_SUMMARY,         // 7
+  STATE_START,
+  STATE_PRODUCT,
+  STATE_VENDOR,
+  STATE_NAME,
+  STATE_VERSION,
+  STATE_RELEASE,
+  STATE_ARCH,
+  STATE_SUMMARY,
   STATE_SHORTSUMMARY,
-  STATE_DESCRIPTION,     // 8
-  STATE_UPDATEREPOKEY,   // 9 should go away
-  STATE_CPEID,         // 9
-  STATE_URLS,            // 10
-  STATE_URL,             // 11
-  STATE_RUNTIMECONFIG,   // 12
-  STATE_LINGUAS,         // 13
-  STATE_LANG,            // 14
-  STATE_REGISTER,        // 15
-  STATE_TARGET,          // 16
-  STATE_REGRELEASE,      // 18
-  STATE_PRODUCTLINE,     // 19
-  NUMSTATES              // 0
+  STATE_DESCRIPTION,
+  STATE_UPDATEREPOKEY,
+  STATE_CPEID,
+  STATE_URLS,
+  STATE_URL,
+  STATE_RUNTIMECONFIG,
+  STATE_LINGUAS,
+  STATE_LANG,
+  STATE_REGISTER,
+  STATE_TARGET,
+  STATE_REGRELEASE,
+  STATE_PRODUCTLINE,
+  NUMSTATES
 };
 
 struct stateswitch {
@@ -162,7 +161,7 @@ startElement(void *userData, const char *name, const char **atts)
   struct stateswitch *sw;
 
 #if 0
-      fprintf(stderr, "start: [%d]%s\n", pd->state, name);
+  fprintf(stderr, "start: [%d]%s\n", pd->state, name);
 #endif
   if (pd->depth != pd->statedepth)
     {
@@ -231,7 +230,7 @@ endElement(void *userData, const char *name)
   Solvable *s = pd->solvable;
 
 #if 0
-      fprintf(stderr, "end: [%d]%s\n", pd->state, name);
+  fprintf(stderr, "end: [%d]%s\n", pd->state, name);
 #endif
   if (pd->depth != pd->statedepth)
     {
@@ -410,7 +409,7 @@ add_code11_product(struct parsedata *pd, FILE *fp)
 }
 
 
-void
+int
 repo_add_code11_products(Repo *repo, const char *dirpath, int flags)
 {
   Repodata *data;
@@ -474,6 +473,7 @@ repo_add_code11_products(Repo *repo, const char *dirpath, int flags)
 
   if (!(flags & REPO_NO_INTERNALIZE))
     repodata_internalize(data);
+  return 0;
 }
 
 
@@ -491,11 +491,12 @@ repo_add_code11_products(Repo *repo, const char *dirpath, int flags)
 
 /* Oh joy! Three parsers for the price of one! */
 
-void
+int
 repo_add_products(Repo *repo, const char *proddir, const char *root, int flags)
 {
   char *fullpath;
   DIR *dir;
+  int ret;
 
   if (proddir)
     {
@@ -504,8 +505,7 @@ repo_add_products(Repo *repo, const char *proddir, const char *root, int flags)
        {
          /* assume code11 stype products */
          closedir(dir);
-         repo_add_code11_products(repo, proddir, flags);
-         return;
+         return repo_add_code11_products(repo, proddir, flags);
        }
     }
 
@@ -516,9 +516,9 @@ repo_add_products(Repo *repo, const char *proddir, const char *root, int flags)
     {
       closedir(dir);
       /* assume code10 style products */
-      repo_add_zyppdb_products(repo, fullpath, flags);
+      ret = repo_add_zyppdb_products(repo, fullpath, flags);
       solv_free(fullpath);
-      return;
+      return ret;
     }
   solv_free(fullpath);
 
@@ -528,9 +528,9 @@ repo_add_products(Repo *repo, const char *proddir, const char *root, int flags)
   if (dir)
     {
       closedir(dir);
-      repo_add_releasefile_products(repo, fullpath, flags);
+      ret = repo_add_releasefile_products(repo, fullpath, flags);
       solv_free(fullpath);
-      return;
+      return ret;
     }
 
   /* no luck. print an error message in case the root argument is wrong */
@@ -540,6 +540,7 @@ repo_add_products(Repo *repo, const char *proddir, const char *root, int flags)
   /* the least we can do... */
   if (!(flags & REPO_NO_INTERNALIZE) && (flags & REPO_REUSE_REPODATA) != 0)
     repodata_internalize(repo_last_repodata(repo));
+  return 0;
 }
 
 /* EOF */
index 9f466dd..faa8456 100644 (file)
@@ -19,9 +19,7 @@
 #include "pool.h"
 #include "repo.h"
 #include "chksum.h"
-#include "repo_updateinfoxml.h"
-
-//#define DUMPOUT 0
+#include "repo_repomdxml.h"
 
 /*
 <repomd>
@@ -450,7 +448,7 @@ characterData(void *userData, const XML_Char *s, int len)
 
 #define BUFF_SIZE 8192
 
-void
+int
 repo_add_repomdxml(Repo *repo, FILE *fp, int flags)
 {
   Pool *pool = repo->pool;
@@ -500,6 +498,7 @@ repo_add_repomdxml(Repo *repo, FILE *fp, int flags)
     repodata_internalize(data);
 
   free(pd.content);
+  return 0;
 }
 
 /* EOF */
index 84bb6f0..3ab8d10 100644 (file)
@@ -2789,18 +2789,18 @@ parsekeydata(Solvable *s, Repodata *data, unsigned char *p, int pl)
 #if 0
              Id htype = 0;
 #endif
-             // printf("V3 signature packet\n");
+             /* printf("V3 signature packet\n"); */
              if (l < 17)
                continue;
              if (p[2] != 0x10 && p[2] != 0x11 && p[2] != 0x12 && p[2] != 0x13 && p[2] != 0x1f)
                continue;
              if (!memcmp(keyid, p + 6, 8))
                {
-                 // printf("SELF SIG\n");
+                 /* printf("SELF SIG\n"); */
                }
              else
                {
-                 // printf("OTHER SIG\n");
+                 /* printf("OTHER SIG\n"); */
                }
 #if 0
              if (p[16] == 1)
@@ -2837,7 +2837,7 @@ parsekeydata(Solvable *s, Repodata *data, unsigned char *p, int pl)
 #endif
              unsigned char issuer[8];
 
-             // printf("V4 signature packet\n");
+             /* printf("V4 signature packet\n"); */
              if (l < 6)
                continue;
              if (p[1] != 0x10 && p[1] != 0x11 && p[1] != 0x12 && p[1] != 0x13 && p[1] != 0x1f)
@@ -2893,7 +2893,7 @@ parsekeydata(Solvable *s, Repodata *data, unsigned char *p, int pl)
                          break;
                        }
                      x = q[0] & 127;
-                     // printf("%d SIGSUB %d %d\n", j, x, sl);
+                     /* printf("%d SIGSUB %d %d\n", j, x, sl); */
                      if (x == 16 && sl == 9 && !haveissuer)
                        {
                          memcpy(issuer, q + 1, 8);
@@ -2957,13 +2957,13 @@ parsekeydata(Solvable *s, Repodata *data, unsigned char *p, int pl)
 #endif
                  if (!memcmp(keyid, issuer, 8))
                    {
-                     // printf("SELF SIG cr %d ex %d\n", cr, ex);
+                     /* printf("SELF SIG cr %d ex %d\n", cr, ex); */
                      if (ex > maxex)
                        maxex = ex;
                    }
                  else
                    {
-                     // printf("OTHER SIG cr %d ex %d\n", cr, ex);
+                     /* printf("OTHER SIG cr %d ex %d\n", cr, ex); */
                    }
                }
            }
index 2bde02b..43cf2f9 100644 (file)
@@ -30,7 +30,7 @@ enum state {
   STATE_ARCH,
   STATE_VERSION,
 
-  // package rpm-md
+  /* package rpm-md */
   STATE_LOCATION,
   STATE_CHECKSUM,
   STATE_RPM_GROUP,
@@ -64,7 +64,7 @@ enum state {
   STATE_AFFECTSPKG,
   STATE_REBOOTNEEDED,
 
-  // pattern attributes
+  /* pattern attributes */
   STATE_CATEGORY, /* pattern and patches */
   STATE_ORDER,
   STATE_INCLUDES,
@@ -79,8 +79,8 @@ enum state {
 
   /* product */
   STATE_SHORTNAME,
-  STATE_DISTNAME, // obsolete
-  STATE_DISTEDITION, // obsolete
+  STATE_DISTNAME, /* obsolete */
+  STATE_DISTEDITION, /* obsolete */
   STATE_SOURCE,
   STATE_TYPE,
   STATE_RELNOTESURL,
@@ -114,7 +114,7 @@ enum state {
 
   STATE_FILE,
 
-  // general
+  /* general */
   NUMSTATES
 };
 
@@ -145,7 +145,7 @@ static struct stateswitch stateswitches[] = {
   { STATE_SOLVABLE,    "arch",            STATE_ARCH, 1 },
   { STATE_SOLVABLE,    "version",         STATE_VERSION, 0 },
 
-  // package attributes rpm-md
+  /* package attributes rpm-md */
   { STATE_SOLVABLE,    "location",        STATE_LOCATION, 0 },
   { STATE_SOLVABLE,    "checksum",        STATE_CHECKSUM, 1 },
 
@@ -156,8 +156,6 @@ static struct stateswitch stateswitches[] = {
   { STATE_SOLVABLE,    "distribution",    STATE_DISTRIBUTION, 1 },
   { STATE_SOLVABLE,    "url",             STATE_URL,          1 },
   { STATE_SOLVABLE,    "packager",        STATE_PACKAGER,     1 },
-  //{ STATE_SOLVABLE,    "???",         STATE_INSNOTIFY, 1 },
-  //{ STATE_SOLVABLE,    "??",     STATE_DELNOTIFY, 1 },
   { STATE_SOLVABLE,    "vendor",          STATE_VENDOR,       1 },
   { STATE_SOLVABLE,    "size",            STATE_SIZE,         0 },
   { STATE_SOLVABLE,    "archive-size",    STATE_DOWNLOADSIZE, 1 },
@@ -170,7 +168,7 @@ static struct stateswitch stateswitches[] = {
   { STATE_SOLVABLE,    "keyword",         STATE_KEYWORD,      1 },
   { STATE_SOLVABLE,    "diskusage",       STATE_DISKUSAGE,    0 },
 
-  // pattern attribute
+  /* pattern attribute */
   { STATE_SOLVABLE,    "script",          STATE_SCRIPT,        1 },
   { STATE_SOLVABLE,    "icon",            STATE_ICON,          1 },
   { STATE_SOLVABLE,    "uservisible",     STATE_USERVISIBLE,   1 },
@@ -253,7 +251,7 @@ struct parsedata {
   Id chksumtype;
   Id handle;
   XML_Parser *parser;
-  Id (*dirs)[3]; // dirid, size, nfiles
+  Id (*dirs)[3]; /* dirid, size, nfiles */
   int ndirs;
   const char *language;                        /* default language */
   Id langcache[ID_NUM_INTERNAL];       /* cache for the default language */
@@ -635,7 +633,6 @@ set_sourcerpm(Repodata *data, Solvable *s, Id handle, char *sourcerpm)
 static void XMLCALL
 startElement(void *userData, const char *name, const char **atts)
 {
-  //fprintf(stderr,"+tag: %s\n", name);
   struct parsedata *pd = userData;
   Pool *pool = pd->pool;
   Solvable *s = pd->solvable;
@@ -644,7 +641,7 @@ startElement(void *userData, const char *name, const char **atts)
   Id handle = pd->handle;
   const char *pkgid;
 
-  // fprintf(stderr, "into %s, from %d, depth %d, statedepth %d\n", name, pd->state, pd->depth, pd->statedepth);
+  /* fprintf(stderr, "into %s, from %d, depth %d, statedepth %d\n", name, pd->state, pd->depth, pd->statedepth); */
 
   if (pd->depth != pd->statedepth)
     {
@@ -656,8 +653,10 @@ startElement(void *userData, const char *name, const char **atts)
     return;
   if (pd->state == STATE_START && !strcmp(name, "products"))
     return;
-  //if (pd->state == STATE_START && !strcmp(name, "metadata"))
-  //  return;
+#if 0
+  if (pd->state == STATE_START && !strcmp(name, "metadata"))
+    return;
+#endif
   if (pd->state == STATE_SOLVABLE && !strcmp(name, "format"))
     return;
 
@@ -708,7 +707,7 @@ startElement(void *userData, const char *name, const char **atts)
       */
       if ((pkgid = find_attr("pkgid", atts)) != NULL)
         {
-          // look at the checksum cache
+          /* look at the checksum cache */
           Id index = stringpool_str2id(&pd->cspool, pkgid, 0);
           if (!index || index >= pd->ncscache || !pd->cscache[index])
            {
@@ -909,7 +908,6 @@ startElement(void *userData, const char *name, const char **atts)
 static void XMLCALL
 endElement(void *userData, const char *name)
 {
-  //fprintf(stderr,"-tag: %s\n", name);
   struct parsedata *pd = userData;
   Pool *pool = pd->pool;
   Solvable *s = pd->solvable;
@@ -921,7 +919,7 @@ endElement(void *userData, const char *name)
   if (pd->depth != pd->statedepth)
     {
       pd->depth--;
-      // printf("back from unknown %d %d %d\n", pd->state, pd->depth, pd->statedepth);
+      /* printf("back from unknown %d %d %d\n", pd->state, pd->depth, pd->statedepth); */
       return;
     }
 
@@ -930,8 +928,10 @@ endElement(void *userData, const char *name)
     return;
   if (pd->state == STATE_START && !strcmp(name, "products"))
     return;
-  //if (pd->state == STATE_START && !strcmp(name, "metadata"))
-  //  return;
+#if 0
+  if (pd->state == STATE_START && !strcmp(name, "metadata"))
+    return;
+#endif
   if (pd->state == STATE_SOLVABLE && !strcmp(name, "format"))
     return;
 
@@ -1096,7 +1096,7 @@ endElement(void *userData, const char *name)
     }
   pd->state = pd->sbtab[pd->state];
   pd->docontent = 0;
-  // fprintf(stderr, "back from known %d %d %d\n", pd->state, pd->depth, pd->statedepth);
+  /* fprintf(stderr, "back from known %d %d %d\n", pd->state, pd->depth, pd->statedepth); */
 }
 
 
index e511872..4bbc7e9 100644 (file)
 #include "util.h"
 #define DISABLE_SPLIT
 #include "tools_util.h"
-#include "repo_content.h"
+#include "repo_zyppdb.h"
 
 
-//#define DUMPOUT 0
-
 enum state {
-  STATE_START,           // 0
-  STATE_PRODUCT,         // 1
-  STATE_NAME,            // 2
-  STATE_VERSION,         // 3
-  STATE_ARCH,            // 4
-  STATE_SUMMARY,         // 5
-  STATE_VENDOR,          // 6
-  STATE_INSTALLTIME,     // 7
-  NUMSTATES              // 0
+  STATE_START,
+  STATE_PRODUCT,
+  STATE_NAME,
+  STATE_VERSION,
+  STATE_ARCH,
+  STATE_SUMMARY,
+  STATE_VENDOR,
+  STATE_INSTALLTIME,
+  NUMSTATES
 };
 
 struct stateswitch {
@@ -306,7 +304,7 @@ add_zyppdb_product(struct parsedata *pd, FILE *fp)
  * parse each one as a product
  */
 
-void
+int
 repo_add_zyppdb_products(Repo *repo, const char *dirpath, int flags)
 {
   int i;
@@ -357,6 +355,7 @@ repo_add_zyppdb_products(Repo *repo, const char *dirpath, int flags)
   join_freemem(&pd.jd);
   if (!(flags & REPO_NO_INTERNALIZE))
     repodata_internalize(data);
+  return 0;
 }
 
 /* EOF */