home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.wwiv.com
/
ftp.wwiv.com.zip
/
ftp.wwiv.com
/
pub
/
PPPBCKP
/
PPP15B92.ZIP
/
SENDFILE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1998-07-06
|
5KB
|
153 lines
/* * * * * * * * * * * * * * SENDFILE.C * * * * * * * * * * * * * * * * * *
* Send any file to other FILEnet systems. *
* Run from your FILEnet network directory. UU must be in the path *
* *
* Syntax is: SENDFILE <full path and filename> <node number or '*'> *
* *
* If '*' is node number, file is sent to all addressees in ADDRESS.NET. *
* If run without parameters, you are prompted for filename and system. *
* Edit the originating addressee field to your own Internet address! *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <dir.h>
#include <dos.h>
char *MYADDR = "n1160@filenet.ml.org";
//char *MYADDR = "youraddress@somewhere";
typedef struct {
char addressee[81];
} ADDRESS;
ADDRESS *address;
int main(int argc, char *argv[])
{
char s[81], s1[81], nameaddr[81], ref[181], fn[181], fn1[181];
char maindir[181], ext[10], *ss;
int i, ok, all, node;
static int lines;
struct ffblk ff;
FILE *fp;
strcpy(maindir, "X:\\");
maindir[0] = 'A' + getdisk();
getcurdir(0, maindir + 3);
sprintf(ref, "%s\\ADDRESS.NET", maindir);
if (findfirst(ref, &ff, FA_HIDDEN) != 0) {
fprintf(stderr, "\nMust be run from FILEnet directory!\n");
exit(1);
}
if (argc < 2) {
fprintf(stderr, "\nEnter the path and filename to send\n:");
gets(fn);
} else
strcpy(fn, argv[1]);
if (findfirst(fn, &ff, FA_HIDDEN) != 0) {
fprintf(stderr, "\nUnable to locate %s", fn);
exit(1);
}
if (argc < 3) {
fprintf(stderr,
"\nDestination node, '*' for all, <Enter> aborts.\n:");
gets(s);
} else
strcpy(s, argv[2]);
if (s[0] == 0) {
fprintf(stderr, "\nNo node specified, aborted!\n");
exit(1);
} else {
all = 0;
if (s[0] == '*') {
all = 1;
fp = fopen(ref, "r");
while (fgets(s, 80, fp))
lines++;
fprintf(stderr, "\nSending to %d addressees", lines);
address = (ADDRESS *) malloc((lines) * sizeof(char *));
if (!address) {
fprintf(stderr,
"\nInsufficient memory to send all addressees!\n\n");
exit(1);
}
rewind(fp);
i = lines = 0;
while (fgets(s, 80, fp)) {
if (s[0] != '@')
continue;
ss = strtok(s, " ");
ss = strtok(NULL, "\n");
if (strncmp(ss, "news", 4) == 0)
continue;
if (stricmp(ss, MYADDR) == 0)
continue;
sprintf(address[i++].addressee, "%s", ss);
if (!address[i].addressee)
exit(1);
++lines;
}
fclose(fp);
} else {
ok = 0;
fp = fopen(ref, "r");
while (fgets(s1, 80, fp)) {
if (s1[0] != '@')
continue;
ss = strtok(s1, " ");
node = atoi(&ss[1]);
if (node == (atoi(s))) {
ss = strtok(NULL, "\n");
strcpy(nameaddr, ss);
ok = 1;
break;
}
}
fclose(fp);
if (!ok) {
fprintf(stderr, "\nNo match for node %s\n", s);
exit(1);
} else
fprintf(stderr, "\nSending %s to %s\n", fn, nameaddr);
}
fnsplit(fn, NULL, NULL, s1, ext);
sprintf(fn1, "%s\\MQUEUE\\%s.UUE", maindir, s1);
if (findfirst(fn1, &ff, FA_HIDDEN) == 0) {
fprintf(stderr, "\nTarget file already exists!\n");
exit(1);
}
fp = fopen(fn1, "wt+");
if (!fp) {
fprintf(stderr, "\nUnable to open %s for output!\n", fn1);
exit(1);
}
fprintf(fp, "From: %s\n", MYADDR);
if (all) {
for (i = 0; i < lines && (address[i].addressee[0]); i++) {
fprintf(fp, "To: %s\n", address[i].addressee);
fprintf(stderr, "\nSending To: %s", address[i].addressee);
}
} else
fprintf(fp, "To: %s\n", nameaddr);
fprintf(fp, "MIME-Version: 1.0\n");
fprintf(fp, "Content-Type: text/plain; charset=us-ascii\n");
fprintf(fp, "Content-Transfer-Encoding: x-uue\n");
fprintf(fp, "Subject: %s%s\n\n", s1, ext);
fclose(fp);
if (address)
free(address);
address = NULL;
fprintf(stderr, "\nEncoding %s... ", fn);
sprintf(s1, "UU -encode %s %s", fn, fn1);
system(s1);
}
fprintf(stderr, "\n\n");
return 0;
}