home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 3
/
Info_Mac_1994-01.iso
/
Communications
/
Networks
/
Skim
< prev
next >
Wrap
Internet Message Format
|
1993-12-30
|
4KB
Date: Thu, 25 Nov 93 18:06:58 +1300
From: Craig Nevill-Manning <cgn@kauri.cs.waikato.ac.nz>
Subject: Update on info-mac uploads browser
This is a new version of skim.c, a C program to ease the process of
downloading programs listed in the info-mac digest.
The latest modifications allow the site to be changed to a mirror site, and
the directory accordingly. Thanks to Robert Watkins (bob@nutmeg.cs.ntu.edu.au)
for these additions!
-------------------------- CUT HERE ------------------------------------------
/* To compile this program, first modify the #defines. You have to choose the
local directory to be used and to set your e-mail address.
You'll also have to add the directory to look into at the mirror site
Then compile with cc -o skim skim.c -lcurses -ltermcap
Original skim program by :
Craig Nevill-Manning, e-mail: cgn@waikato.ac.nz
Department of Computer Science, phone: +64 7 838 4021 (work)
University of Waikato, +64 7 838 4232 (home)
Private Bag 3105,
Hamilton,
New Zealand.
Enhanced (added automatic script creation) by :
Francois Pottier e-mail: pottier@dmi.ens.fr
Minorly enhanced (enabled defining of different directories for info-mac)
by:
Robert Watkins e-mail: bob@nutmeg.it.ntu.edu.au
*/
#define localDirectory "~/Mac/NEW"
#define siteName "archie.au"
#define emailAddress "bob@nutmeg.ntu.edu.au"
#define mirrorDir "/micros/mac/info-mac"
#include <stdio.h>
#include <curses.h>
FILE *download;
main(argc, argv)
int argc;
char **argv;
{
int i;
initscr();
cbreak();
download = fopen("download", "w");
fprintf(download, "%s\n\n%s%s\n%s%s%s\n%s%s\n%s\n",
"#!/bin/csh -f",
"cd ", localDirectory,
"ftp -n ", siteName, " << EOF",
"user anonymous ", emailAddress,
"ascii");
for (i = 1; i < argc; i ++)
skim(argv[i]);
fprintf(download, "EOF\n");
fclose(download);
(void) chmod ("download", 493); /* octal 755, rwxr-xr-x */
nocbreak();
endwin();
}
skim(filename)
char *filename;
{
FILE *f;
char s[1000], name[1000], nameOnly[1000];
int ch, line;
/* TEMP VARIABLE ADDED FOR MY HACK */
char temp[1000];
f = fopen(filename, "r");
if (f) {
while (!feof(f)) {
do {
fgets(s, 1000, f);
} while (strncmp(s, "Subject: [*]", 12) != 0 && !feof(f));
line = 0;
name[0] = 0;
clear();
refresh();
puts(filename);
while (!feof(f)) {
if (line ++ < LINES - 4)
printf("%s", s);
fgets(s, 1000, f);
if (strncmp(s, "[Archived as", 12) == 0) {
strcpy(name, &s[13]);
break;
}
}
printf("%s", s);
if (name[0]) {
printf("Get this? (y/n)");
do
ch = getchar();
while (ch != 'y' && ch != 'n' && ch != 'q');
if (ch == 'y') {
int i;
/* MY HACK FOR THIS THING */
if (strncmp(name,"/info-mac",9)==0) {
strcpy(temp,mirrorDir);
strcat(temp,&name[9]);
strcpy(name,temp);
}
for (i = strlen(name); i > 0 && name[i] != ';'; i --) ;
name[i] = 0;
for (i = strlen(name); i > 0 && name[i] != '/'; i--) ;
strcpy(nameOnly, &name[i+1]);
name[i] = 0;
fprintf(download, "cd %s\n", name);
fprintf(download, "get %s\n", nameOnly);
}
else if (ch == 'q') {
fclose(download);
nocbreak();
endwin();
exit(0);
}
}
}
fclose(f);
}
}