- fix indent (bleah! who wrote that stuff?)
authorMichael Schroeder <mls@suse.de>
Mon, 22 Sep 2008 13:13:16 +0000 (13:13 +0000)
committerMichael Schroeder <mls@suse.de>
Mon, 22 Sep 2008 13:13:16 +0000 (13:13 +0000)
tools/repo_deltainfoxml.c
tools/repo_updateinfoxml.c

index 2211b5d..21ed86b 100644 (file)
@@ -19,6 +19,8 @@
 #include "pool.h"
 #include "repo.h"
 #include "repo_updateinfoxml.h"
+
+#define DISABLE_SPLIT
 #include "tools_util.h"
 
 //#define DUMPOUT 0
@@ -213,62 +215,62 @@ makeevr_atts(Pool *pool, struct parsedata *pd, const char **atts)
 static void parse_delta_location( struct parsedata *pd, 
                                   const char* str )
 {
-    Pool *pool = pd->pool;
-    if (str)
+  Pool *pool = pd->pool;
+  if (str)
     {
-        /* Separate the filename into its different parts.
-           rpm/x86_64/alsa-1.0.14-31_31.2.x86_64.delta.rpm
-           --> dir = rpm/x86_64
-           name = alsa
-           evr = 1.0.14-31_31.2
-           suffix = x86_64.delta.rpm.  */
-        char *real_str = strdup(str);
-        char *s = real_str;
-        char *s1, *s2;
-        s1 = strrchr (s, '/');
-        if (s1)
-        {
-            pd->delta.locdir = strn2id(pool, s, s1 - s, 1);
-            s = s1 + 1;
-        }
-        /* Guess suffix.  */
-        s1 = strrchr (s, '.');
-        if (s1)
-        {
-            for (s2 = s1 - 1; s2 > s; s2--)
-                if (*s2 == '.')
-                    break;
-            if (!strcmp (s2, ".delta.rpm") || !strcmp (s2, ".patch.rpm"))
-            {
-                s1 = s2;
-                /* We accept one more item as suffix.  */
-                for (s2 = s1 - 1; s2 > s; s2--)
-                   if (*s2 == '.')
-                        break;
-                s1 = s2;
-                  }
-            if (*s1 == '.')
-                *s1++ = 0;
-            pd->delta.locsuffix = str2id(pool, s1, 1); 
-        }
-        /* Last '-'.  */
-        s1 = strrchr (s, '-');
-        if (s1)
-        {
-                  /* Second to last '-'.  */
-            for (s2 = s1 - 1; s2 > s; s2--)
-                if (*s2 == '-')
-                    break;
-        }
-        else
-            s2 = 0;
-        if (s2 > s && *s2 == '-')
-        {
-            *s2++ = 0;
-            pd->delta.locevr = str2id(pool, s2, 1);
-        }
-        pd->delta.locname = str2id(pool, s, 1);
-        free(real_str);
+      /* Separate the filename into its different parts.
+        rpm/x86_64/alsa-1.0.14-31_31.2.x86_64.delta.rpm
+        --> dir = rpm/x86_64
+        name = alsa
+        evr = 1.0.14-31_31.2
+        suffix = x86_64.delta.rpm.  */
+      char *real_str = strdup(str);
+      char *s = real_str;
+      char *s1, *s2;
+      s1 = strrchr (s, '/');
+      if (s1)
+       {
+         pd->delta.locdir = strn2id(pool, s, s1 - s, 1);
+         s = s1 + 1;
+       }
+      /* Guess suffix.  */
+      s1 = strrchr (s, '.');
+      if (s1)
+       {
+         for (s2 = s1 - 1; s2 > s; s2--)
+           if (*s2 == '.')
+             break;
+         if (!strcmp (s2, ".delta.rpm") || !strcmp (s2, ".patch.rpm"))
+           {
+             s1 = s2;
+             /* We accept one more item as suffix.  */
+             for (s2 = s1 - 1; s2 > s; s2--)
+               if (*s2 == '.')
+                 break;
+             s1 = s2;
+           }
+         if (*s1 == '.')
+           *s1++ = 0;
+         pd->delta.locsuffix = str2id(pool, s1, 1); 
+       }
+      /* Last '-'.  */
+      s1 = strrchr (s, '-');
+      if (s1)
+       {
+         /* Second to last '-'.  */
+         for (s2 = s1 - 1; s2 > s; s2--)
+           if (*s2 == '-')
+             break;
+       }
+      else
+       s2 = 0;
+      if (s2 > s && *s2 == '-')
+       {
+         *s2++ = 0;
+         pd->delta.locevr = str2id(pool, s2, 1);
+       }
+      pd->delta.locname = str2id(pool, s, 1);
+      free(real_str);
     }
 }
                                  
@@ -311,46 +313,41 @@ startElement(void *userData, const char *name, const char **atts)
 
   switch(pd->state)
     {
-      case STATE_START:
-          break;
-      case STATE_NEWPACKAGE:
-          if ( (str = find_attr("name", atts)) )
-            {
-              pd->newpkgname = str2id(pool, str, 1);
-            }
-          pd->newpkgevr = makeevr_atts(pool, pd, atts);
-          if ( (str = find_attr("arch", atts)) )
-            {
-              pd->newpkgarch = str2id(pool, str, 1);
-            }
-          break;
-
-      case STATE_DELTA:
-          memset(&pd->delta, 0, sizeof (pd->delta));
-          *pd->tempstr = 0;
-          pd->ltemp = 0;
-          pd->delta.nbevr++;
-          pd->delta.bevr = sat_realloc (pd->delta.bevr, pd->delta.nbevr * sizeof(Id));
-          pd->delta.bevr[pd->delta.nbevr - 1] = makeevr_atts(pool, pd, atts);
-          --(pd->datanum);
-          break;
-      case STATE_FILENAME:
-          break;
-      case STATE_LOCATION:
-          parse_delta_location( pd, find_attr("href", atts));
-          break;
-    case STATE_SIZE:
+    case STATE_START:
       break;
-    case STATE_SEQUENCE:
+    case STATE_NEWPACKAGE:
+      if ( (str = find_attr("name", atts)) )
+       {
+         pd->newpkgname = str2id(pool, str, 1);
+       }
+      pd->newpkgevr = makeevr_atts(pool, pd, atts);
+      if ( (str = find_attr("arch", atts)) )
+       {
+         pd->newpkgarch = str2id(pool, str, 1);
+       }
       break;
 
-      case NUMSTATES+1:
-        split(NULL, NULL, 0); /* just to keep gcc happy about tools_util.h: static ... split() {...}  Urgs!*/
+    case STATE_DELTA:
+      memset(&pd->delta, 0, sizeof (pd->delta));
+      *pd->tempstr = 0;
+      pd->ltemp = 0;
+      pd->delta.nbevr++;
+      pd->delta.bevr = sat_realloc (pd->delta.bevr, pd->delta.nbevr * sizeof(Id));
+      pd->delta.bevr[pd->delta.nbevr - 1] = makeevr_atts(pool, pd, atts);
+      --(pd->datanum);
+      break;
+    case STATE_FILENAME:
+      break;
+    case STATE_LOCATION:
+      parse_delta_location(pd, find_attr("href", atts));
       break;
-      default:
+    case STATE_SIZE:
+      break;
+    case STATE_SEQUENCE:
+      break;
+    default:
       break;
     }
-  return;
 }
 
 
@@ -376,80 +373,79 @@ endElement(void *userData, const char *name)
   pd->depth--;
   pd->statedepth--;
   switch (pd->state)
-  {
-      case STATE_START:
-          break;
-      case STATE_NEWPACKAGE:
-          break;
-      case STATE_DELTA:
+    {
+    case STATE_START:
+      break;
+    case STATE_NEWPACKAGE:
+      break;
+    case STATE_DELTA:
       {
 #ifdef DUMPOUT
-          int i;
+       int i;
 #endif
-          struct deltarpm *d = &pd->delta;
+       struct deltarpm *d = &pd->delta;
 
 #ifdef DUMPOUT
 
-          fprintf (stderr, "found deltarpm for %s:\n", id2str(pool, pd->newpkgname));
+       fprintf (stderr, "found deltarpm for %s:\n", id2str(pool, pd->newpkgname));
 #endif
-          repo_set_id(pd->repo, pd->datanum, DELTA_PACKAGE_NAME, pd->newpkgname);
-          repo_set_id(pd->repo, pd->datanum, DELTA_PACKAGE_EVR, pd->newpkgevr);
-          repo_set_id(pd->repo, pd->datanum, DELTA_PACKAGE_ARCH, pd->newpkgarch);
-          repo_set_id(pd->repo, pd->datanum, DELTA_LOCATION_NAME, d->locname);
-          repo_set_id(pd->repo, pd->datanum, DELTA_LOCATION_DIR, d->locdir);
-          repo_set_id(pd->repo, pd->datanum, DELTA_LOCATION_EVR, d->locevr);
-          repo_set_id(pd->repo, pd->datanum, DELTA_LOCATION_SUFFIX, d->locsuffix);
+       repo_set_id(pd->repo, pd->datanum, DELTA_PACKAGE_NAME, pd->newpkgname);
+       repo_set_id(pd->repo, pd->datanum, DELTA_PACKAGE_EVR, pd->newpkgevr);
+       repo_set_id(pd->repo, pd->datanum, DELTA_PACKAGE_ARCH, pd->newpkgarch);
+       repo_set_id(pd->repo, pd->datanum, DELTA_LOCATION_NAME, d->locname);
+       repo_set_id(pd->repo, pd->datanum, DELTA_LOCATION_DIR, d->locdir);
+       repo_set_id(pd->repo, pd->datanum, DELTA_LOCATION_EVR, d->locevr);
+       repo_set_id(pd->repo, pd->datanum, DELTA_LOCATION_SUFFIX, d->locsuffix);
 
 #ifdef DUMPOUT
-          fprintf (stderr, "   loc: %s %s %s %s\n", id2str(pool, d->locdir),
-                   id2str(pool, d->locname), id2str(pool, d->locevr),
-                   id2str(pool, d->locsuffix));
-          fprintf (stderr, "  size: %d down\n", d->downloadsize);
-          fprintf (stderr, "  chek: %s\n", d->filechecksum);
+       fprintf (stderr, "   loc: %s %s %s %s\n", id2str(pool, d->locdir),
+                id2str(pool, d->locname), id2str(pool, d->locevr),
+                id2str(pool, d->locsuffix));
+       fprintf (stderr, "  size: %d down\n", d->downloadsize);
+       fprintf (stderr, "  chek: %s\n", d->filechecksum);
 #endif
 
-          repo_set_num(pd->repo, pd->datanum, DELTA_DOWNLOADSIZE, d->downloadsize);
-          repo_set_str(pd->repo, pd->datanum, DELTA_CHECKSUM, d->filechecksum);
+       repo_set_num(pd->repo, pd->datanum, DELTA_DOWNLOADSIZE, d->downloadsize);
+       repo_set_str(pd->repo, pd->datanum, DELTA_CHECKSUM, d->filechecksum);
 
-
-          if (d->seqnum)
+       if (d->seqnum)
          {
 #ifdef DUMPOUT
-              fprintf (stderr, "  base: %s\n",
-                       id2str(pool, d->bevr[0]));
-              fprintf (stderr, "            seq: %s\n",
-                       id2str(pool, d->seqname));
-              fprintf (stderr, "                 %s\n",
-                       id2str(pool, d->seqevr));
-              fprintf (stderr, "                 %s\n",
-                       d->seqnum);
+           fprintf (stderr, "  base: %s\n",
+                    id2str(pool, d->bevr[0]));
+           fprintf (stderr, "            seq: %s\n",
+                    id2str(pool, d->seqname));
+           fprintf (stderr, "                 %s\n",
+                    id2str(pool, d->seqevr));
+           fprintf (stderr, "                 %s\n",
+                    d->seqnum);
 #endif
-              repo_set_id(pd->repo, pd->datanum, DELTA_BASE_EVR, d->bevr[0]);
-              repo_set_id(pd->repo, pd->datanum, DELTA_SEQ_NAME, d->seqname);
-              repo_set_id(pd->repo, pd->datanum, DELTA_SEQ_EVR, d->seqevr);
-              repo_set_str(pd->repo, pd->datanum, DELTA_SEQ_NUM, d->seqnum);
+           repo_set_id(pd->repo, pd->datanum, DELTA_BASE_EVR, d->bevr[0]);
+           repo_set_id(pd->repo, pd->datanum, DELTA_SEQ_NAME, d->seqname);
+           repo_set_id(pd->repo, pd->datanum, DELTA_SEQ_EVR, d->seqevr);
+           repo_set_str(pd->repo, pd->datanum, DELTA_SEQ_NUM, d->seqnum);
 
 #ifdef DUMPOUT
-              fprintf(stderr, "OK\n");
+           fprintf(stderr, "OK\n");
 #endif
 
 #ifdef DUMPOUT              
-              if (d->seqevr != d->bevr[0])
-                  fprintf (stderr, "XXXXX evr\n");
-              /* Name of package ("atom:xxxx") should match the sequence info
-                 name.  */
-              if (strcmp(id2str(pool, d->seqname), id2str(pool, pd->newpkgname) + 5))
-                  fprintf (stderr, "XXXXX name\n");
+           if (d->seqevr != d->bevr[0])
+             fprintf (stderr, "XXXXX evr\n");
+           /* Name of package ("atom:xxxx") should match the sequence info
+              name.  */
+           if (strcmp(id2str(pool, d->seqname), id2str(pool, pd->newpkgname) + 5))
+             fprintf (stderr, "XXXXX name\n");
 #endif
          }
-          else
+       else
          {
 
 #ifdef DUMPOUT                          
-              fprintf (stderr, "  base:");
-              for (i = 0; i < d->nbevr; i++)
-                  fprintf (stderr, " %s", id2str(pool, d->bevr[i]));
-              fprintf (stderr, "\n");
+           fprintf (stderr, "  base:");
+           for (i = 0; i < d->nbevr; i++)
+             fprintf (stderr, " %s", id2str(pool, d->bevr[i]));
+           fprintf (stderr, "\n");
 #endif
          }
 
@@ -458,48 +454,46 @@ endElement(void *userData, const char *name)
       free(pd->delta.bevr);
       free(pd->delta.seqnum);
       break;
-      case STATE_FILENAME:
-          parse_delta_location(pd, pd->content);
-          break;
-      case STATE_CHECKSUM:
+    case STATE_FILENAME:
+      parse_delta_location(pd, pd->content);
+      break;
+    case STATE_CHECKSUM:
       pd->delta.filechecksum = strdup(pd->content);
       break;
-      case STATE_SIZE:
-          pd->delta.downloadsize = atoi(pd->content);
-          break;
-      case STATE_SEQUENCE:
+    case STATE_SIZE:
+      pd->delta.downloadsize = atoi(pd->content);
+      break;
+    case STATE_SEQUENCE:
       if ((str = pd->content))
-      {
+       {
          const char *s1, *s2;
          s1 = strrchr(str, '-');
          if (s1)
-          {
+           {
              for (s2 = s1 - 1; s2 > str; s2--)
                if (*s2 == '-')
-                    break;
+                 break;
              if (*s2 == '-')
-              {
+               {
                  for (s2 = s2 - 1; s2 > str; s2--)
-                      if (*s2 == '-')
-                          break;
+                   if (*s2 == '-')
+                     break;
                  if (*s2 == '-')
-                  {
+                   {
                      pd->delta.seqevr = strn2id(pool, s2 + 1, s1 - s2 - 1, 1);
                      pd->delta.seqname = strn2id(pool, str, s2 - str, 1);
                      str = s1 + 1;
-                  }
-              }
-          }
+                   }
+               }
+           }
          pd->delta.seqnum = strdup(str);
       }
-      default:
+    default:
       break;
-  }
+    }
 
   pd->state = pd->sbtab[pd->state];
   pd->docontent = 0;
-  
-  return;
 }
 
 
@@ -509,14 +503,8 @@ characterData(void *userData, const XML_Char *s, int len)
   struct parsedata *pd = userData;
   int l;
   char *c;
-  if (!pd->docontent) {
-#if 0
-    char *dup = strndup( s, len );
-  fprintf(stderr, "Content: [%d]'%s'\n", pd->state, dup );
-  free( dup );
-#endif
+  if (!pd->docontent)
     return;
-  }
   l = pd->lcontent + len + 1;
   if (l > pd->acontent)
     {
index 08fb36e..41b2003 100644 (file)
@@ -19,6 +19,7 @@
 #include "pool.h"
 #include "repo.h"
 #include "repo_updateinfoxml.h"
+#define DISABLE_SPLIT
 #include "tools_util.h"
 
 /*
@@ -247,9 +248,9 @@ startElement(void *userData, const char *name, const char **atts)
 
   switch(pd->state)
     {
-      case STATE_START:
+    case STATE_START:
       break;
-      case STATE_UPDATES:
+    case STATE_UPDATES:
       break;
       /*
        * <update from="rel-eng@fedoraproject.org"
@@ -257,7 +258,7 @@ startElement(void *userData, const char *name, const char **atts)
        *         type="bugfix" (enhancement, security)
        *         version="1.4">
        */
-      case STATE_UPDATE:
+    case STATE_UPDATE:
       {
        const char *from = 0, *status = 0, *type = 0, *version = 0;
        for (; *atts; atts += 2)
@@ -287,17 +288,17 @@ startElement(void *userData, const char *name, const char **atts)
       }
       break;
       /* <id>FEDORA-2007-4594</id> */
-      case STATE_ID:
+    case STATE_ID:
       break;
       /* <title>imlib-1.9.15-6.fc8</title> */
-      case STATE_TITLE:
+    case STATE_TITLE:
       break;
       /* <release>Fedora 8</release> */
-      case STATE_RELEASE:
+    case STATE_RELEASE:
       break;
       /*  <issued date="2008-03-21 21:36:55"/>
       */
-      case STATE_ISSUED:
+    case STATE_ISSUED:
       {
        const char *date = 0;
        for (; *atts; atts += 2)
@@ -308,14 +309,14 @@ startElement(void *userData, const char *name, const char **atts)
        repodata_set_str(pd->data, pd->datanum, SOLVABLE_BUILDTIME, date);
       }
       break;
-      case STATE_REFERENCES:
+    case STATE_REFERENCES:
       break;
       /*  <reference href="https://bugzilla.redhat.com/show_bug.cgi?id=330471"
        *             id="330471"
        *             title="LDAP schema file missing for dhcpd"
        *             type="bugzilla"/>
        */
-      case STATE_REFERENCE:
+    case STATE_REFERENCE:
       {
         const char *href = 0, *id = 0, *title = 0, *type = 0;
        for (; *atts; atts += 2)
@@ -338,18 +339,18 @@ startElement(void *userData, const char *name, const char **atts)
       }
       break;
       /* <description>This update ...</description> */
-      case STATE_DESCRIPTION:
+    case STATE_DESCRIPTION:
       break;
       /* <message type="confirm">This update ...</message> */
-      case STATE_MESSAGE:
+    case STATE_MESSAGE:
       break;
-      case STATE_PKGLIST:
+    case STATE_PKGLIST:
       break;
       /* <collection short="F8" */
-      case STATE_COLLECTION:
+    case STATE_COLLECTION:
       break;
       /* <name>Fedora 8</name> */ 
-      case STATE_NAME:
+    case STATE_NAME:
       break;
       /*   <package arch="ppc64" name="imlib-debuginfo" release="6.fc8"
        *            src="http://download.fedoraproject.org/pub/fedora/linux/updates/8/ppc64/imlib-debuginfo-1.9.15-6.fc8.ppc64.rpm"
@@ -358,7 +359,7 @@ startElement(void *userData, const char *name, const char **atts)
        *
        * -> patch.conflicts: {name} < {version}.{release}
        */
-      case STATE_PACKAGE:
+    case STATE_PACKAGE:
       {
        const char *arch = 0, *name = 0, *src = 0;
        Id evr = makeevr_atts(pool, pd, atts); /* parse "epoch", "version", "release" */
@@ -415,21 +416,18 @@ startElement(void *userData, const char *name, const char **atts)
       break;
       /* <filename>libntlm-0.4.2-1.fc8.x86_64.rpm</filename> */ 
       /* <filename>libntlm-0.4.2-1.fc8.x86_64.rpm</filename> */
-      case STATE_FILENAME:
+    case STATE_FILENAME:
       break;
       /* <reboot_suggested>True</reboot_suggested> */
-      case STATE_REBOOT:
+    case STATE_REBOOT:
       break;
       /* <restart_suggested>True</restart_suggested> */
-      case STATE_RESTART:
+    case STATE_RESTART:
       break;
       /* <relogin_suggested>True</relogin_suggested> */
-      case STATE_RELOGIN:
+    case STATE_RELOGIN:
       break;
-      case NUMSTATES+1:
-        split(NULL, NULL, 0); /* just to keep gcc happy about tools_util.h: static ... split() {...}  Urgs!*/
-      break;
-      default:
+    default:
       break;
     }
   return;
@@ -460,14 +458,14 @@ endElement(void *userData, const char *name)
   pd->statedepth--;
   switch (pd->state)
     {
-      case STATE_START:
+    case STATE_START:
       break;
-      case STATE_UPDATES:
+    case STATE_UPDATES:
       break;
-      case STATE_UPDATE:
+    case STATE_UPDATE:
       s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
       break;
-      case STATE_ID:
+    case STATE_ID:
       {
         if (pd->content)
          {
@@ -476,7 +474,7 @@ endElement(void *userData, const char *name)
       }
       break;
       /* <title>imlib-1.9.15-6.fc8</title> */
-      case STATE_TITLE:
+    case STATE_TITLE:
       {
        while (pd->lcontent > 0
               && *(pd->content + pd->lcontent - 1) == '\n')
@@ -490,38 +488,37 @@ endElement(void *userData, const char *name)
       /*
        * <release>Fedora 8</release>
        */
-      case STATE_RELEASE:
+    case STATE_RELEASE:
       break;
-      case STATE_ISSUED:
+    case STATE_ISSUED:
       break;
-      case STATE_REFERENCES:
+    case STATE_REFERENCES:
       break;
-      case STATE_REFERENCE:
+    case STATE_REFERENCE:
       break;
       /*
        * <description>This update ...</description>
        */
-      case STATE_DESCRIPTION:
+    case STATE_DESCRIPTION:
       {
        repodata_set_str(pd->data, pd->datanum, SOLVABLE_DESCRIPTION, pd->content);
       }
       break;   
-      break;
       /*
        * <message>Warning! ...</message>
        */
-      case STATE_MESSAGE:
+    case STATE_MESSAGE:
       {
        repodata_set_str(pd->data, pd->datanum, UPDATE_MESSAGE, pd->content);
       }
       break;
-      case STATE_PKGLIST:
+    case STATE_PKGLIST:
       break;
-      case STATE_COLLECTION:
+    case STATE_COLLECTION:
       break;
-      case STATE_NAME:
+    case STATE_NAME:
       break;
-      case STATE_PACKAGE:
+    case STATE_PACKAGE:
       {
 #if DO_ARRAY
        /* write _FILENAME and _FLAGS at </package>
@@ -537,7 +534,7 @@ endElement(void *userData, const char *name)
       break;
       /* <filename>libntlm-0.4.2-1.fc8.x86_64.rpm</filename> */ 
       /* <filename>libntlm-0.4.2-1.fc8.x86_64.rpm</filename> */
-      case STATE_FILENAME:
+    case STATE_FILENAME:
       {
 #if DO_ARRAY
        repodata_add_poolstr_array(pd->data, pd->datanum, UPDATE_COLLECTION_FILENAME, pd->content);
@@ -546,7 +543,7 @@ endElement(void *userData, const char *name)
       }
       break;
       /* <reboot_suggested>True</reboot_suggested> */
-      case STATE_REBOOT:
+    case STATE_REBOOT:
       {
        if (pd->content
            && (pd->content[0] == 'T'
@@ -559,7 +556,7 @@ endElement(void *userData, const char *name)
       }
       break;
       /* <restart_suggested>True</restart_suggested> */
-      case STATE_RESTART:
+    case STATE_RESTART:
       {
        if (pd->content
            && (pd->content[0] == 'T'
@@ -572,7 +569,7 @@ endElement(void *userData, const char *name)
       }
       break;
       /* <relogin_suggested>True</relogin_suggested> */
-      case STATE_RELOGIN:
+    case STATE_RELOGIN:
       {
        if (pd->content
            && (pd->content[0] == 'T'