/* * rdf.c : implementation for the RDF encoding/decoding of RPM informations. */ #include "config.h" #ifdef HAVE_FCNTL_H #include #endif #include #include #include #ifdef HAVE_UNISTD_H #include #endif #include #include #include #include "rpm2html.h" #include "rpmdata.h" #include "parser.h" #include "tree.h" #include "rdf.h" #include "html.h" /* * Open an RDF file call the parser to create a XML tree * Then walk the tree and build an rpmData structure for * the corresponding package. */ rpmDataPtr rpmOpenRdf(char *nameRpm, rpmDirPtr dir, rpmSubdirPtr tree) { return(NULL); } /* * Create and RDF file containing the description for the * given RPM data. */ void dumpRpmRdf(rpmDataPtr rpm, rpmSubdirPtr tree) { struct tm * tstruct; rpmDirPtr dir = rpm->dir; FILE *rdf; int i; char buf[1000]; if ((dir->subdir != NULL) && (dir->subdir[0] != '\0')) { if ((rpm->subdir != NULL) && (rpm->subdir[0] != '\0')) sprintf(buf, "%s/%s/%s/%s.rdf", dir->dir, dir->subdir, rpm->subdir, rpmName(rpm)); else sprintf(buf, "%s/%s/%s.rdf", dir->dir, dir->subdir, rpmName(rpm)); } else { if ((rpm->subdir != NULL) && (rpm->subdir[0] != '\0')) sprintf(buf, "%s/%s/%s.rdf", dir->dir, rpm->subdir, rpmName(rpm)); else sprintf(buf, "%s/%s.rdf", dir->dir, rpmName(rpm)); } if (checkDate(buf, rpm->stamp)) return; if (verbose > 1) { printf("Dumping %s\n", buf); } rdf = fopen(buf, "w"); if (rdf == NULL) { fprintf(stderr, "Couldn't save to file %s: %s\n", buf, strerror(errno)); return; } fprintf(rdf, "\n"); fprintf(rdf, "\n"); fprintf(rdf, "\n"); fprintf(rdf, "\n"); fprintf(rdf, "subdir != NULL) && (rpm->subdir[0] != '\0')) { if (dir->mirrors[0] != NULL) fprintf(rdf, "%s/%s/%s\">\n", dir->mirrors[0], rpm->subdir, rpm->filename); else fprintf(rdf, "%s/%s/%s\">\n", dir->ftp, rpm->subdir, rpm->filename); } else { if (dir->mirrors[0] != NULL) fprintf(rdf, "%s/%s\">\n", dir->mirrors[0], rpm->filename); else fprintf(rdf, "%s/%s\">\n", dir->ftp, rpm->filename); } fprintf(rdf, "%s\n", rpm->name); fprintf(rdf, "%s\n", rpm->version); fprintf(rdf, "%s\n", rpm->release); if (rpm->distribution) fprintf(rdf, "%s\n", rpm->distribution); if (rpm->vendor) fprintf(rdf, "%s\n", rpm->vendor); fprintf(rdf, "%d\n", rpm->size); if (rpm->url) fprintf(rdf, "%s\n", rpm->url); tstruct = localtime(&(rpm->date)); #ifdef HAVE_STRFTIME strftime(buf, sizeof(buf) - 1, "%c", tstruct); #else #error "no strftime, please check !" #endif fprintf(rdf, "%s\n", buf); if (rpm->host) fprintf(rdf, "%s\n", rpm->host); if (rpm->group) fprintf(rdf, "%s\n", rpm->group); if (rpm->packager) fprintf(rdf, "%s\n", rpm->packager); if (dir->ftpsrc) { fprintf(rdf, "%s/%s\n", dir->ftpsrc, rpm->srcrpm); } else { fprintf(rdf, "%s\n", rpm->srcrpm); } if (rpm->summary) fprintf(rdf, "%s\n", rpm->summary); if (rpm->description) fprintf(rdf, "\n%s\n\n", rpm->description); if (rpm->copyright) fprintf(rdf, "%s\n", rpm->copyright); if (rpm->nb_resources > 0) { fprintf(rdf, "\n"); fprintf(rdf, "\n"); for (i = 0;i < rpm->nb_resources;i++) { fprintf(rdf, "%s\n", rpm->resources[i]->name); } fprintf(rdf, "\n"); fprintf(rdf, "\n"); } if (rpm->nb_requires > 0) { fprintf(rdf, "\n"); fprintf(rdf, "\n"); for (i = 0;i < rpm->nb_requires;i++) { fprintf(rdf, "%s\n", rpm->requires[i]->name); } fprintf(rdf, "\n"); fprintf(rdf, "\n"); } if (rpm->filelist) fprintf(rdf, "\n%s\n\n", rpm->filelist); fprintf(rdf, "\n"); fprintf(rdf, "\n"); fclose(rdf); }