/* generador en proceso */ #include #include #include #define NPAGES 256 typedef struct{ char filenames[NPAGES][256]; /* array of filenames */ char gminames[NPAGES][256]; char htmlnames[NPAGES][256]; char wikinames[NPAGES][256]; int incominglinks[NPAGES][NPAGES]; /* array of indexes */ int nilinks[NPAGES]; /* how many incoming links per page */ int count; /* total number of pages */ } Pages; void fputgmilink(FILE *f, Pages * p, int index){ fprintf(f,"=> ./%s %s\n",p->gminames[index],p->wikinames[index]); } int main(int argc, char * argv[]){ DIR * d; FILE * f, *fgem, *fweb; struct dirent * entry; Pages p; int i,j,k; for(i=0; id_name, ".gmo") ) ){ /* add to index */ strcpy( p.filenames[index], "src/"); strcat( p.filenames[index], entry->d_name ); /* add gmi name */ strcpy( p.gminames[index], entry->d_name ); ret = strstr( p.gminames[index], ".gmo"); strcpy( ret, ".gmi"); /* add html name */ strcpy( p.htmlnames[index], entry->d_name ); ret = strstr( p.htmlnames[index], ".gmo"); strcpy( ret, ".html"); /* add wikiname */ strcpy( p.wikinames[index], entry->d_name ); ret = strstr(p.wikinames[index], ".gmo"); *ret = '\0'; /* remove suffix */ /* convert _ to spaces: */ for(i=0; p.wikinames[index][i]; i++){ if(p.wikinames[index][i]=='_') p.wikinames[index][i] = ' '; } index++; } } p.count = index; printf("%d gmo files\n",p.count); closedir(d); /* close directory */ /* write index: pages.gmo */ f = fopen("src/pages.gmo","w"); fputs("# index of pages\n\n",f); for(i=0; i",2)!=0 && (ret=strchr(line,'{')) ){ for(j=1; ret[j]!='}'; j++){ link[j-1] = ret[j]; } link[j-1] = '\0'; index = -1; for(j=0; j