home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of Mecomp Multimedia 1
/
Mecomp-CD.iso
/
amiga
/
tools
/
cd
/
indexcd
/
bin
/
sources.lha
/
sources
/
Find.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-02-11
|
3KB
|
146 lines
/* dcc HD1:IndexCD/Find.c */
char *Titolo = "$VER: Cerca v1.0 (11-02-1996) © by Claudio Buraglio";
#include <stdio.h>
#include <string.h>
#include <time.h>
char work[255];
char line[255];
char buf[255];
char exe[255];
char *lis1 = "LIST ICD:Index/#?.index LFORMAT \"ICD:Bin/IndexAG >NIL: %p%s";
char *lis2 = "-A\" TO T:Index.temp";
char *AGline1 = "@database Aminet\n";
char *AGline2 = "@node main \"Find... '";
char *AGline3 = "'\"\n\n@{\"Filename \" LINK ICD:Bin/Help.guide/FILENAME} Directory Size CD @{\"Description.\" LINK ICD:Bin/Help.guide/DESCRIPTION }\n";
char *AGline4 = "-----------------------------------------------------------\n";
FILE *fpr; // Read
FILE *fpw; // Write
FILE *fps; // Source
FILE *fpc; // Counter
main(int arglen, char **argptr)
{
printf("\n%s\n\n",Titolo+6);
strcpy(buf, argptr[0]);
char *ptr = strrchr(buf, '/');
if(*ptr == '/')
{
*++ptr = 0;
sprintf(line, "c:Assign >NIL: ICD: \"%s\"\n", buf);
system(line);
}
else
{
system("c:Assign >NIL: ICD: \"\"");
}
Programma();
return(0);
}
wbmain()
{
system("c:Assign >NIL: ICD: \"\"");
Programma();
}
Programma()
{
time_t t = time(NULL);
struct tm *tp = localtime(&t);
char ora [20]; char idx [20]; char stf [20];
strftime(ora, sizeof(ora) - 1, "T:%H%M%S.guide", tp);
strftime(idx, sizeof(ora) - 1, "T:%H%M%S.index", tp);
strftime(stf, sizeof(ora) - 1, "T:%H%M%S.string", tp);
strcpy(exe, "ICD:Bin/GetString >NIL: ");
strcat(exe, stf);
system(exe);
if (fpr = fopen(stf, "r"))
{
if (fgets(buf, sizeof(buf), fpr))
{
sprintf(exe,"%s %s %s %s\n", lis1, ora, buf, lis2);
system(exe);
system("c:sort T:Index.temp T:Index.tmp");
remove("T:Index.temp");
// Copia l'header del file hhmmss.guide nella directory T:
if (fpw = fopen(ora, "w"))
{
fputs(AGline1 ,fpw);
fputs(AGline2 ,fpw);
fputs(buf ,fpw);
fputs(AGline3 ,fpw);
fputs(AGline4 ,fpw);
fclose(fpw);
}
// Esegue la ricerca su tutti gli archivi
system("Execute T:Index.tmp");
// Crea il footer del file hhmmss.guide
if (fpw = fopen(ora, "a"))
{
if (fpc = fopen("T:Counter.temp", "r"))
{
int tot;
fread(buf, 4, 1, fpc);
int clc;
tot = buf[0]; tot = tot & 0xff; tot = tot << 24;
clc = buf[1]; clc = clc & 0xff; clc = clc << 16;
tot = tot + clc;
clc = buf[2]; clc = clc & 0xff; clc = clc << 8;
tot = tot + clc;
clc = buf[3]; clc = clc & 0xff;
tot = tot + clc;
fprintf(fpw, "\n%d files listed\n\n@ENDNODE\n", tot);
fclose(fpc);
}
while(fgets(buf, sizeof(buf), fps) != NULL)
{
fputs(buf, fpw);
}
fclose(fpw);
}
remove("T:Counter.temp");
// remove("T:Index.tmp");
// Visualizza il risultato
strcpy(exe, "SYS:Utilities/AmigaGuide ");
strcat(exe, ora);
system(exe);
remove(ora);
}
else
{
puts("Nothing to find.");
}
fclose(fpr);
}
else
{
printf("Error! %s not found!\n", stf);
}
remove(stf); // File che contiene la stringa
system("c:Delete >NIL: T:Command-#?");
}