diff --git a/generador.c b/generador.c index 8a38cfc7..2f36678d 100644 --- a/generador.c +++ b/generador.c @@ -17,10 +17,10 @@ typedef struct{ int main(int argc, char * argv[]){ DIR * d; - FILE * f; + FILE * f, *fgem, *fweb; struct dirent * entry; Pages p; - int i,j; + int i,j,k; for(i=0; id_name, ".gmo") ) ){ /* add to index */ - strcpy( p.filenames[fileindex], "src/"); - strcat( p.filenames[fileindex], entry->d_name ); -/* strcpy ( p.filenames[fileindex], entry->d_name ); */ + strcpy( p.filenames[index], "src/"); + strcat( p.filenames[index], entry->d_name ); /* add gmi name */ - strcpy ( p.gminames[fileindex], entry->d_name ); - ret = strstr( p.gminames[fileindex], ".gmo"); + strcpy( p.gminames[index], entry->d_name ); + ret = strstr( p.gminames[index], ".gmo"); strcpy( ret, ".gmi"); /* add html name */ - strcpy( p.htmlnames[fileindex], entry->d_name ); - ret = strstr( p.htmlnames[fileindex], ".gmo"); + strcpy( p.htmlnames[index], entry->d_name ); + ret = strstr( p.htmlnames[index], ".gmo"); strcpy( ret, ".html"); /* add wikiname */ - strcpy( p.wikinames[fileindex], entry->d_name ); - ret = strstr(p.wikinames[fileindex], ".gmo"); + 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[fileindex][i]; i++){ - if(p.wikinames[fileindex][i]=='_') - p.wikinames[fileindex][i] = ' '; + for(i=0; p.wikinames[index][i]; i++){ + if(p.wikinames[index][i]=='_') + p.wikinames[index][i] = ' '; } - fileindex++; + index++; } } - p.count = fileindex; + p.count = index; printf("%d gmo files\n",p.count); closedir(d); /* close directory */ @@ -82,8 +81,9 @@ int main(int argc, char * argv[]){ /* search for incoming links */ int premode = 0; - char line[1024]; + char line[1024],newline[1024]; char link[1024]; + int found = 0; 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 ./%s %s\n",p.gminames[index],p.wikinames[index]); + } + else{ + fputs(line, fgem); + } + } + } + fprintf(fgem, "\n# incoming links\n"); + for(j=0; j ./%s %s\n",p.gminames[j],p.wikinames[j]); + } + fclose(fgem); + fclose(f); }