Diff for /rpm2html/rdf.c between versions 1.15 and 1.16

version 1.15, 1998/05/22 06:05:37 version 1.16, 1998/05/22 21:10:42
Line 26 Line 26
 #include "rdf.h"  #include "rdf.h"
   
 /*  /*
    * Open and process an RDF file in the incoming tree of an rpm2html mirror.
    */
   rpmDataPtr rpmOpenRdf(char *nameRdf, rpmDirPtr dir, rpmSubdirPtr tree) {
       char file[1000];
       rpmDataPtr rpm;
   
       /*
        * create path
        */
       if (tree->htmlpath[0] != '\0')
           sprintf(file, "%s/%s/%s", dir->rpmdir, tree->rpmpath, nameRdf);
       else
           sprintf(file, "%s/%s", dir->rpmdir, nameRdf);
   
       rpm = rpmOpenRdfFile(file);
   
       if (rpm != NULL) {
           /* setup tree and subdir informations */
           rpm->dir = dir;
           if (tree) {
               if ((tree->rpmpath != NULL) && (tree->rpmpath[0] != '\0'))
                   rpm->subdir = strdup(tree->rpmpath);
               else
                   rpm->subdir = NULL;
           } else
               rpm->subdir = NULL;
   
           /* Add the package files to the real filesystem tree if asked for */
           if ((dir->build_tree != 0) && (rpm->filelist != NULL)) {
               char *cur, *filename;
               
               cur = rpm->filelist;
               while ((*cur != '\0') && (*cur != '/')) cur++;
               filename = cur;
               while (*cur != '\0') {
                   if ((*cur == '\n') || (*cur == '\r')) {
                       if (cur != filename)
                           rpmAddRealFile(dir->root, filename, rpm);
                       while ((*cur != '\0') && (*cur != '/')) cur++;
                       filename = cur;
                   } else
                       cur++;
               }
               if (cur != filename)
                   rpmAddRealFile(dir->root, filename, rpm);
           }
   
           /* Register this package */
           rpmAddSoftware(rpm);
   
           /* dump the HTML related to this package */
           if (rpm2html_dump_html)
               dumpRpmHtml(rpm, tree);
           if (rpm2html_dump_rdf)
               dumpRpmRdf(rpm, tree);
   
           /* free large amount of data not used later */
           if (rpm->filelist) free(rpm->filelist);
           rpm->filelist = NULL;
           if (rpm->copyright) free(rpm->copyright);
           rpm->copyright = NULL;
           if (rpm->changelog) free(rpm->changelog);
           rpm->changelog = NULL;
           if (rpm->description) free(rpm->description);
           rpm->description = NULL;
   
           /* increment the counters */
           rpm2html_files++;
           rpm2html_size += rpm->size / 1024;
       }
       return(rpm);
   }
   
   /*
  * Open an RDF file call the parser to create a XML tree   * Open an RDF file call the parser to create a XML tree
  * Then walk the tree and build an rpmData structure for   * Then walk the tree and build an rpmData structure for
  * the corresponding package.   * the corresponding package.
  */   */
 rpmDataPtr rpmOpenRdf(char *nameRdf, rpmDirPtr dir, rpmSubdirPtr tree) {  rpmDataPtr rpmOpenRdfFile(char *file) {
     char file[1000];  
     char nameBuffer[200];      char nameBuffer[200];
     rdfSchema rdf;      rdfSchema rdf;
     rdfNamespace rpmNs;      rdfNamespace rpmNs;
Line 44  rpmDataPtr rpmOpenRdf(char *nameRdf, rpm Line 117  rpmDataPtr rpmOpenRdf(char *nameRdf, rpm
     struct stat buf;      struct stat buf;
     int i;      int i;
   
     /*  
      * open the file for reading  
      */  
     if (tree->htmlpath[0] != '\0')  
         sprintf(file, "%s/%s/%s", dir->rpmdir, tree->rpmpath, nameRdf);  
     else  
         sprintf(file, "%s/%s", dir->rpmdir, nameRdf);  
   
     rdf = rdfRead(file);      rdf = rdfRead(file);
     if (rdf == NULL) return(NULL);      if (rdf == NULL) return(NULL);
   
Line 88  rpmDataPtr rpmOpenRdf(char *nameRdf, rpm Line 153  rpmDataPtr rpmOpenRdf(char *nameRdf, rpm
         return(NULL);          return(NULL);
     }      }
     memset(rpm, 0, sizeof(rpmData));      memset(rpm, 0, sizeof(rpmData));
     rpm->dir = dir;  
     if (tree) {  
         if ((tree->rpmpath != NULL) && (tree->rpmpath[0] != '\0'))  
             rpm->subdir = strdup(tree->rpmpath);  
         else  
             rpm->subdir = NULL;  
     } else  
         rpm->subdir = NULL;  
   
     stat(file, &buf);      stat(file, &buf);
     rpm->stamp = buf.st_mtime;      rpm->stamp = buf.st_mtime;
Line 300  rpmDataPtr rpmOpenRdf(char *nameRdf, rpm Line 357  rpmDataPtr rpmOpenRdf(char *nameRdf, rpm
 #endif  #endif
     rpm->filename = strdup(nameBuffer);      rpm->filename = strdup(nameBuffer);
   
     /* Add the package files to the real filesystem tree if asked for */  
     if ((dir->build_tree != 0) && (rpm->filelist != NULL)) {  
         char *cur, *filename;  
           
         cur = rpm->filelist;  
         while ((*cur != '\0') && (*cur != '/')) cur++;  
         filename = cur;  
         while (*cur != '\0') {  
             if ((*cur == '\n') || (*cur == '\r')) {  
                 if (cur != filename)  
                     rpmAddRealFile(dir->root, filename, rpm);  
                 while ((*cur != '\0') && (*cur != '/')) cur++;  
                 filename = cur;  
             } else  
                 cur++;  
         }  
         if (cur != filename)  
             rpmAddRealFile(dir->root, filename, rpm);  
     }  
   
     /* Register this package */  
     rpmAddSoftware(rpm);  
   
     /* dump the HTML related to this package */  
     if (rpm2html_dump_html)  
         dumpRpmHtml(rpm, tree);  
     if (rpm2html_dump_rdf)  
         dumpRpmRdf(rpm, tree);  
   
     /* free large amount of data not used later */  
     if (rpm->filelist) free(rpm->filelist);  
     rpm->filelist = NULL;  
     if (rpm->copyright) free(rpm->copyright);  
     rpm->copyright = NULL;  
     if (rpm->changelog) free(rpm->changelog);  
     rpm->changelog = NULL;  
     if (rpm->description) free(rpm->description);  
     rpm->description = NULL;  
   
     /* increment the counters */  
     rpm2html_files++;  
     rpm2html_size += rpm->size / 1024;  
   
     /*      /*
      * Cleanup.       * Cleanup.

Removed from v.1.15  
changed lines
  Added in v.1.16


Webmaster