Diff for /rpm2html/rdf.c between versions 1.11 and 1.12

version 1.11, 1998/05/13 03:31:33 version 1.12, 1998/05/15 03:12:24
Line 354  rpmDataPtr rpmOpenRdf(char *nameRdf, rpm Line 354  rpmDataPtr rpmOpenRdf(char *nameRdf, rpm
  * Create and RDF file containing the description for the given RPM data.   * Create and RDF file containing the description for the given RPM data.
  */   */
 void dumpRpmRdf(rpmDataPtr rpm, rpmSubdirPtr tree) {  void dumpRpmRdf(rpmDataPtr rpm, rpmSubdirPtr tree) {
       FILE *output;
       struct stat stat_buf;
     struct tm * tstruct;      struct tm * tstruct;
     rpmDirPtr dir = rpm->dir;      rpmDirPtr dir = rpm->dir;
     char *base = dir->dir;      char *base = dir->dir;
     int i;      int i;
     char buf[10000];      char buf[10000];
     char file[1000];      char file[1000];
       char *buffer;
       int size;
       int stat_res;
     rdfSchema rdf;      rdfSchema rdf;
     rdfNamespace rpmNs;      rdfNamespace rpmNs;
     rdfDescription desc;      rdfDescription desc;
Line 382  void dumpRpmRdf(rpmDataPtr rpm, rpmSubdi Line 387  void dumpRpmRdf(rpmDataPtr rpm, rpmSubdi
             sprintf(file, "%s/%s.rdf", base, rpmName(rpm));              sprintf(file, "%s/%s.rdf", base, rpmName(rpm));
     }      }
   
     if (checkDate(file, rpm->stamp)) return;      /*
        * Check wether the RPM timestamp is older than the filestamp.
        */
       if ((stat_res = stat(file, &stat_buf)) == 0) {
           if (stat_buf.st_mtime > rpm->stamp) return;
       }
   
     /*      /*
      * Create the directory if needed       * Create the directory if needed
Line 400  void dumpRpmRdf(rpmDataPtr rpm, rpmSubdi Line 410  void dumpRpmRdf(rpmDataPtr rpm, rpmSubdi
     }      }
     createDirectory(buf);      createDirectory(buf);
   
     if (verbose > 1) {  
         printf("Dumping %s\n", file);  
     }  
   
     /*      /*
      * build the RDF document tree       * build the RDF document tree
      * Note : the order is not important but following the rpmData       * Note : the order is not important but following the rpmData
Line 467  void dumpRpmRdf(rpmDataPtr rpm, rpmSubdi Line 473  void dumpRpmRdf(rpmDataPtr rpm, rpmSubdi
 #error "no strftime, please check !"  #error "no strftime, please check !"
 #endif  #endif
     rdfSetValue(desc, "BuildDate", rpmNs, buf);      rdfSetValue(desc, "BuildDate", rpmNs, buf);
     sprintf(buf, "%d", rpm->date);      sprintf(buf, "%d", (int) rpm->date);
     rdfSetValue(desc, "Date", rpmNs, buf);      rdfSetValue(desc, "Date", rpmNs, buf);
     sprintf(buf, "%d", rpm->size);      sprintf(buf, "%d", rpm->size);
     rdfSetValue(desc, "Size", rpmNs, buf);      rdfSetValue(desc, "Size", rpmNs, buf);
Line 499  void dumpRpmRdf(rpmDataPtr rpm, rpmSubdi Line 505  void dumpRpmRdf(rpmDataPtr rpm, rpmSubdi
         rdfSetValue(desc, "Files", rpmNs, rpm->filelist);          rdfSetValue(desc, "Files", rpmNs, rpm->filelist);
   
     /*      /*
      * Save the RDF file and cleanup the tree.       * Save the RDF to a buffer, remove the tree.
      */       */
     rdfWrite(rdf, file);      rdfWriteMemory(rdf, &buffer, &size);
     rdfDestroySchema(rdf);      rdfDestroySchema(rdf);
   
       /*
        * if the file already exists avoid to overwrite it if the content
        * didn't change.
        */
       if ((stat_res == 0) && (stat_buf.st_size == size)) {
           char *buffer2 = malloc(size * sizeof(char));
   
           if (buffer2 == NULL) {
               fprintf(stderr, " : running out of memory\n");
               return;
           }
           output = fopen(file, "r");
           if (output == NULL) {
               fprintf(stderr, "couldn't open %s for reading !\n", file);
               return;
           }
           if (fread(buffer2, size, 1, output) != 1) {
               fprintf(stderr, "Problem reading from %s !\n", file);
           }
           fclose(output);
   
           /*
            * Now compare the content !
            */
           if (!memcmp(buffer, buffer2, size)) {
               free(buffer2);
               if (verbose > 1)
                   fprintf(stderr, "File %s : Content identical !\n", file);
               return;
           }
           free(buffer2);
       }
   
       /*
        * Dump the file.
        */
       if (verbose > 1) {
           printf("Dumping %s\n", file);
       }
       output = fopen(file, "w");
       if (output == NULL) {
           fprintf(stderr, "couldn't open %s for writing !\n", file);
           return;
       }
       if (fwrite(buffer, size, 1, output) != 1) {
           fprintf(stderr, "Problem writing to %s !\n", file);
       }
       fclose(output);
 }  }
   

Removed from v.1.11  
changed lines
  Added in v.1.12


Webmaster