home *** CD-ROM | disk | FTP | other *** search
- /* dcc HD1:IndexCD/Bin/IndexDirectory.c */
-
- char *Titolo = "$VER: IndexDirectory v1.0 (15-02-1997) © by Claudio Buraglio";
-
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
-
- char buff[255];
- char line[255];
- char work[126];
- char ora [20];
- char font[126];
-
- char LastLine[126];
-
- char *ConfigFile ="S:Aminet-Config";
-
- char *TempList="T:List.temp";
- char *IndexAG ="T:IndiceEARSAN.guide";
- char *AGHead1 ="@database Directory\n@node main \"";
- char *AGHeadB =" \"\n@font ";
- char *AGHead2 =" ";
- char *AGHead3 ="\n\n";
- char *AGHead4 =" \n";
-
- char *AGfoot ="\n@ENDNODE\n";
-
- FILE *fpr;
- FILE *fpw;
- char *ptr;
-
- int Count;
- int Size;
-
- strpaste(char *d, char *s)
- {
- while(*s != 0)
- *d++ = *s++;
- return(d);
- }
-
-
- int main(int arglen, char **argptr) // L'argomento e' AMINETxx.indice
- {
- printf("\n%s\n\n",Titolo+6);
-
- LoadConfiguration();
- ptr = strchr(font, ' ');
- ptr++;
- int Size = strtol(ptr,0,0);
-
- unsigned char *ptr = strchr(argptr[1], '_');
- ptr++;
- int i = 0;
- while (*ptr != '.')
- {
- // AGHeadB[i] = *ptr;
- AGHeadB[i++] = *ptr++;
- }
-
- if (arglen != 2)
- {
- printf("Missing argument.\n\n");
- }
-
- else
- {
- time_t t = time(NULL); // in 'ora' l'ora
- struct tm *tp = localtime(&t);
- strftime(ora, sizeof(ora) - 1, "T:%H%M%S.guide", tp);
-
- if (fpr = fopen(argptr[1], "r")) // Apre l'indice
- {
- if (fpw = fopen(ora, "w")) // Apre il file T:ora.guide
- {
- fputs(AGHead1, fpw); // Scrive l'header di Amigaguide
- fputs(AGHeadB, fpw); // e le prime righe
- fputs(AGHead2, fpw); // e le prime righe
- fputs(font, fpw);
- fputs(AGHead3, fpw);
- // fputs(AGHead4, fpw);
-
- while (fgets(buff, sizeof(buff), fpr))
- {
- char *ptr = strchr(buff, '~'); // cerca il nome della dir
- *ptr++; // ptr = inizio nome dir
-
- if ((*ptr > 'a'-1) && (*ptr < 'z'+1))
- *ptr = (*ptr & 0xdf); // Prima lettera Maiuscola
-
- char *end = ptr;
- while (*end != '~') { *end++;} // cerca fine nome dir
- *end = 0; // e termina con 0
-
- if (strcmp(LastLine, ptr) != 0 ) // se diverso dalla dir vista prima
- {
- strcpy(LastLine, ptr); // string in Lastline
-
- fprintf(fpw, " @{\" %s",ptr);
- int y = 0; while((strlen(ptr)+y)<12) {fprintf(fpw," "); y++;}
- fprintf(fpw, "\" SYSTEM \"c:Run >NIL: ICD:Bin/IndexFiles %s %s\"}\n",argptr[1], LastLine);
- Count++;
- }
- }
- fprintf(fpw, AGfoot);
- fclose(fpw);
- }
- fclose(fpr);
-
- if (access("T:AmigaGuide_Workbench",0) != 0)
- {
- system("c:Copy ENV:AmigaGuide/Workbench T:AmigaGuide_Workbench");
- }
- if (access("ENV:AmigaGuide/Workbench",0) == 0)
- {
- remove("ENV:AmigaGuide/Workbench");
- system("c:Copy T:AmigaGuide_Workbench ENV:AmigaGuide/Workbench");
- if (Count > 28) { Count = 28; }
-
- sprintf(buff, "ICD:Bin/SizeAG 300 0 144 %d", (Count+4)*(Size+2)+40 );
- system(buff);
- }
-
- strcpy(line, "sys:Utilities/AmigaGuide >NIL: ");
- strcat(line, ora);
- system(line);
- remove(ora);
-
- if (access("T:AmigaGuide_Workbench",0) == 0)
- {
- remove("ENV:AmigaGuide/Workbench");
- system("c:Copy T:AmigaGuide_Workbench ENV:AmigaGuide/Workbench");
- }
- }
- else
- {
- Printf("Can't open file %s.\n\n", argptr[1]);
- }
- }
- }
-
- LoadConfiguration()
- {
- strcpy(font, "topaz.font 11"); // font di default
-
- FILE *fp;
- if (fp = fopen(ConfigFile, "r"))
- {
- while (fgets(buff, sizeof(buff)-1, fp))
- {
- if ((ptr = strstr(buff, "font=")) != NULL)
- {
- int len = strlen(buff);
- buff[len-1] = 0x0;
-
- ptr = strchr(buff, '=') + 1;
- strcpy(font, ptr);
-
- ptr = strchr(font, '/');
- strcpy(ptr, ".font ");
-
- ptr = strchr(buff, '/') + 1;
- strcat(font, ptr);
- }
- }
- fclose(fp);
- }
- }
-