home *** CD-ROM | disk | FTP | other *** search
- /* dcc HD1:IndexCD/IndexCD.c */
-
- char *Titolo = "$VER: IndexCD v1.0 (15-02-1997) © by Claudio Buraglio";
-
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <time.h>
-
- char buff[255];
- char line[255];
- char work[126];
- char font[126];
- char ora [20];
-
- char *TempList ="T:List.temp";
- char *ConfigFile ="S:Aminet-Config";
-
- char *volume=" ";
- char *anno=" ";
-
- char *AGhead ="@database Arc\n@node main \"IndexCD - Claudio Buraglio, ©1997.\"\n@font ";
- char *AGfont ="\n\n\ @{\" Volume Month Year \" LINK ICD:bin/Help.guide/LABELNAME}\n\ ---------------------------\n";
- char *AGfoot ="@ENDNODE\n";
-
- char *m00 = " ";
- char *m01 = "January ";
- char *m02 = "February ";
- char *m03 = "March ";
- char *m04 = "April ";
- char *m05 = "May ";
- char *m06 = "June ";
- char *m07 = "July ";
- char *m08 = "August ";
- char *m09 = "September";
- char *m10 = "October ";
- char *m11 = "November ";
- char *m12 = "December ";
-
- FILE *fpr;
- FILE *fpw;
- char *ptr;
-
- int XSize = 8*27;
- int Count;
- int Size;
-
-
- strpaste(char *d, char *s)
- {
- while(*s != 0)
- *d++ = *s++;
- return(d);
- }
-
- int main()
- {
- printf("\n%s\n\n",Titolo+6);
- puts("This command is usable only from Workbench.");
- return(0);
- }
- int wbmain()
- {
- Programma();
- }
-
- Programma()
- {
- system("c:Assign ICD: \"\"");
-
- LoadConfiguration();
- ptr = strchr(font, ' ');
- ptr++;
- int Size = strtol(ptr,0,0);
-
- if (system("LIST ICD:Index/#?CD.#? ICD:Index/#?CD2.#? LFORMAT \"%p %s %d\" TO T:List.temp") == 0)
- {
- time_t t = time(NULL);
- struct tm *tp = localtime(&t);
- strftime(ora, sizeof(ora) - 1, "T:%H%M%S.guide", tp);
-
- if (fpw = fopen(ora, "w"))
- {
- fputs(AGhead, fpw);
- fputs(font, fpw);
- fputs(AGfont, fpw);
-
- system("LIST ICD:Index/#?.index LFORMAT \"%p %s %d\" TO T:List.tmp");
- system("SORT T:List.tmp T:List.temp");
- remove("T:List.tmp");
-
-
- // Scrive gli indici
-
- if (fpr = fopen(TempList, "r"))
- {
- while (fgets(buff, sizeof(buff), fpr))
- {
- CreaLinea();
- Count++;
- }
- fclose(fpr);
- }
- fputs(AGfoot, fpw);
- remove(TempList);
- fclose(fpw);
- }
-
- if (access("T:AmigaGuide_Workbench",0) != 0)
- system("c:Copy ENV:AmigaGuide/Workbench T:AmigaGuide_Workbench");
-
- if (access("ENV:AmigaGuide/Workbench",0) == 0)
- {
- sprintf(buff, "ICD:Bin/SizeAG 0 0 %d %d", 238, ((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
- {
- system("C:RequestChoice \" IndexCD-ROM Problem \" \" 'c:LIST ICD:Index' is not executable \" OK");
- }
- }
-
-
- CreaLinea()
- {
- int i = 0;
- char *mese = m00;
- char *ptr = buff;
- while (*ptr != ' ') // cerca nome file
- ptr++;
- *ptr++;
-
- i = 0;
- while (*ptr != '_') // Copia Data
- anno[i++] = *ptr++;
- *ptr++;
-
- if(anno[i-2] == '0' && anno[i-1] == '1') {mese = m01;}
- if(anno[i-2] == '0' && anno[i-1] == '2') {mese = m02;}
- if(anno[i-2] == '0' && anno[i-1] == '3') {mese = m03;}
- if(anno[i-2] == '0' && anno[i-1] == '4') {mese = m04;}
- if(anno[i-2] == '0' && anno[i-1] == '5') {mese = m05;}
- if(anno[i-2] == '0' && anno[i-1] == '6') {mese = m06;}
- if(anno[i-2] == '0' && anno[i-1] == '7') {mese = m07;}
- if(anno[i-2] == '0' && anno[i-1] == '8') {mese = m08;}
- if(anno[i-2] == '0' && anno[i-1] == '9') {mese = m09;}
- if(anno[i-2] == '1' && anno[i-1] == '0') {mese = m10;}
- if(anno[i-2] == '1' && anno[i-1] == '1') {mese = m11;}
- if(anno[i-2] == '1' && anno[i-1] == '2') {mese = m12;}
- anno[i-2] = 0;
-
- i = 0;
-
- ptr = strchr(buff, '_');
- ptr++;
- while (*ptr != '.') // Copia nome file
- volume[i++] = *ptr++;
- while(volume[i] != ' ')
- volume[i++] = ' ';
-
- ptr = buff;
- i = 0;
- while (*ptr != ' ') // Copia dir..
- work[i++] = *ptr++;
- *ptr++;
-
- while (*ptr != ' ') // e nome archivio
- work[i++] = *ptr++;
- work[i] = 0;
-
- fprintf(fpw, "\ @{\" %s %s %s \" SYSTEM \"c:run >NIL: ICD:Bin/IndexDirectory %s\"}\n", volume, mese, anno, work);
- }
-
- LoadConfiguration()
- {
- strcpy(font, "topaz.font 11"); // font per 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);
- }
- }
-