home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
misc
/
volume32
/
xbbs
/
part01
/
bbsc1.c.B
next >
Wrap
Text File
|
1992-09-08
|
44KB
|
1,802 lines
file_loc( strg )
char *strg;
{
int result;
int i;
int zz;
int outok;
int len_in, len_file, times;
long foo;
char timeptr[30];
char *fileptr;
char temp[15];
char string_loc[20];
int lnctx, xp;
if (xpert)
xp = 10;
else
xp = 5;
lnctx = 1;
substr(z_date, z_mm, 1, 2);
substr(z_date, z_dd, 4, 2);
substr(z_date, z_yy, 7, 2);
xmm = atol(z_mm);
xdd = atol(z_dd);
xyy = atol(z_yy);
foo = atol(yy);
outok = FALSE;
old_long_date = (xyy * 10000L) + (xmm * 100L) + xdd;
if( strg == NULL) {
portsout("\n\r\n\rInput file name substring (max 14 characters): ");
portsin(string_loc, 14);
portsout(CRLF);
fileptr = strchr(string_loc, '*');
if( fileptr != NULL ) {
portsout("\n\rDo not use an asterisk as part of the string.\n\r\n\r");
return;
}
} else {
strcpy(string_loc, strg );
}
len_in = strlen(string_loc);
if (!len_in)
return;
strcpy(buf128, f_pathname);
strcat(buf128, FILES);
if ((rdstatbuf = fopen(buf128, "r")) == NULL) {
portsout("\n\rThe are NO files available!\n\r");
return;
}
msgck();
portsout("\n\rSearching for a comparison\n\r\n\r");
while (fscanf(rdstatbuf, "%14s", x_filename) != EOF) {
zz = 0;
if (x_filename[0] == '~') {
goto finisx; /* Special case so that that
* following files are not displayed
* - can be used to disallow uploads
* from being shown until they are
* validated. */
}
if (x_filename[0] == '+') {
fileptr = x_filename + 1;
strcpy(work_msg, fileptr);
(void) fgets(buf128, 80, rdstatbuf);
goto xend;
}
if (x_filename[0] == '.') {
strcpy(x_filename, " ");
strcpy(who_am_i, " ");
strcpy(who_am_I, " ");
zz++;
}
if (result = fgets(buf128, 55, rdstatbuf) == NULL) {
if (!zz)
strcpy(buf128, " ***** No description on file *****");
}
strip(buf128);
if (!zz)
term_space(buf128);
result = strlen(buf128);
if (result == 0) {
if (!zz)
strcpy(buf128, " ***** No description on file *****");
}
if (!zz) {
len_file = strlen(x_filename);
if (len_file < len_in) {
outok = FALSE;
goto xend;
}
strcpy(x_pathandfile, f_pathname);
strcat(x_pathandfile, x_filename);
result = stat(x_pathandfile, &statbuf);
if (result != 0) {
strcpy(who_am_i, "OFFLINE");
strcpy(who_am_I, " ");
outok = FALSE;
goto xend;
}
xmm = statbuf.st_size;
sprintf(who_am_i, "%6ld", xmm);
xmm = statbuf.st_mtime;
strcpy(timeptr, ctime(&xmm));
substr(timeptr, bufx, 5, 6);
strcpy(who_am_I, bufx);
substr(timeptr, bufx, 5, 3);
substr(timeptr, z_dd, 9, 2);
substr(timeptr, z_yy, 23, 2);
xdd = atol(z_dd);
xyy = atol(z_yy);
if (foo > xyy) {
strcpy(who_am_I, bufx);
strcat(who_am_I, "-");
strcat(who_am_I, z_yy);
}
times = len_file - len_in + 1;
outok = FALSE;
for (result = 1; result <= times; result++) {
substr(x_filename, temp, result, len_in);
if (strcmp(temp, string_loc) == 0) {
outok = TRUE;
break;
}
}
}
if (!outok)
goto xend;
sprintf(work_msg, "%-15s%-7s%-6s%-50s", x_filename, who_am_i, who_am_I, buf128);
strip(work_msg);
term_space(work_msg);
sprintf(buf128, "%s\n\r", work_msg);
portsout(buf128);
if (stop_that) {
fclose(rdstatbuf);
stop_that = FALSE;
return;
}
if (toggle) {
lnctx++;
if (lnctx == 23) {
portsout(CRLF);
portsout("*** Depress a key to continue ( control-k to quit ) ........ ");
jnk[0] = portin();
if (jnk[0] == CTL_K || stop_that) {
stop_that = FALSE;
fclose(rdstatbuf);
return;
}
portsout(CRLF);
lnctx = 1;
}
}
xend:
;
}
finisx:
fclose(rdstatbuf);
if (toggle && lnctx > xp) {
portsout(CRLF);
portsout("*** Depress a key to continue ........ ");
jnk[0] = portin();
portsout(CRLF);
}
portsout(CRLF);
portsout(CRLF);
}
file_n()
{
int result;
int i;
int zz;
int outok;
long foo;
char timeptr[30];
char *fileptr;
int lnctx, xp;
static char *dates[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",};
substr(z_date, z_mm, 1, 2);
substr(z_date, z_dd, 4, 2);
substr(z_date, z_yy, 7, 2);
lnctx = 1;
if (xpert)
xp = 10;
else
xp = 5;
xmm = atol(z_mm);
xdd = atol(z_dd);
xyy = atol(z_yy);
foo = atol(yy);
outok = FALSE;
old_long_date = (xyy * 10000L) + (xmm * 100L) + xdd;
strcpy(buf128, f_pathname);
strcat(buf128, FILES);
if ((rdstatbuf = fopen(buf128, "r")) == NULL) {
portsout("\n\rThe are NO files available!\n\r");
return;
}
strcpy(buf128, TMPFILE);
strcat(buf128, port_id);
msgck();
portsout("\n\rStarting the new file search.\n\r\n\r");
while (fscanf(rdstatbuf, "%14s", x_filename) != EOF) {
zz = 0;
if (x_filename[0] == '~') {
goto finisn; /* Special case so that that
* following files are not displayed
* - can be used to disallow uploads
* from being shown until they are
* validated. */
}
if (x_filename[0] == '+') {
fileptr = x_filename + 1;
strcpy(work_msg, fileptr);
(void) fgets(buf128, 80, rdstatbuf);
goto nend;
}
if (x_filename[0] == '.') {
strcpy(x_filename, " ");
strcpy(who_am_i, " ");
strcpy(who_am_I, " ");
zz++;
}
if (result = fgets(buf128, 55, rdstatbuf) == NULL) {
if (!zz)
strcpy(buf128, " ***** No description on file *****");
}
strip(buf128);
if (!zz)
term_space(buf128);
result = strlen(buf128);
if (result == 0) {
if (!zz)
strcpy(buf128, " ***** No description on file *****");
}
if (!zz) {
strcpy(x_pathandfile, f_pathname);
strcat(x_pathandfile, x_filename);
result = stat(x_pathandfile, &statbuf);
if (result != 0) {
strcpy(who_am_i, "OFFLINE");
strcpy(who_am_I, " ");
outok = FALSE;
goto nend;
}
xmm = statbuf.st_size;
sprintf(who_am_i, "%6ld", xmm);
xmm = statbuf.st_mtime;
strcpy(timeptr, ctime(&xmm));
substr(timeptr, bufx, 5, 6);
strcpy(who_am_I, bufx);
substr(timeptr, bufx, 5, 3);
substr(timeptr, z_dd, 9, 2);
substr(timeptr, z_yy, 23, 2);
xdd = atol(z_dd);
xyy = atol(z_yy);
if (foo > xyy) {
strcpy(who_am_I, bufx);
strcat(who_am_I, "-");
strcat(who_am_I, z_yy);
}
for (result = 0; result < 12; result++) {
i = strcmp(bufx, dates[result]);
if (!i) {
xmm = (long) result + 1;
new_long_date = (xyy * 10000L) + (xmm * 100L) + xdd;
if (new_long_date < old_long_date) {
outok = FALSE;
goto nend;
}
outok = TRUE;
break;
}
}
}
if (!outok)
goto nend;
aroundn:
sprintf(work_msg, "%-15s%-7s%-6s%-50s", x_filename, who_am_i, who_am_I, buf128);
arondn:
strip(work_msg);
term_space(work_msg);
sprintf(buf128, "%s\n\r", work_msg);
portsout(buf128);
if (stop_that) {
fclose(rdstatbuf);
stop_that = FALSE;
return;
}
if (toggle) {
lnctx++;
if (lnctx == 23) {
portsout(CRLF);
portsout("*** Depress a key to continue ( control-k to quit ) ........ ");
jnk[0] = portin();
if (jnk[0] == CTL_K || stop_that) {
stop_that = FALSE;
fclose(rdstatbuf);
return;
}
portsout(CRLF);
lnctx = 1;
}
}
nend:
;
}
finisn:
fclose(rdstatbuf);
finisln:
if (toggle && lnctx > xp) {
portsout(CRLF);
portsout("*** Depress a key to continue ........ ");
jnk[0] = portin();
portsout(CRLF);
}
portsout(CRLF);
portsout(CRLF);
}
file_u()
{
char choic1[2], *str_result;
FILE *storbuff;
int result, tryit, tryit1, code;
fileu:
tryit = FALSE;
tryit1 = FALSE;
if_kermit = 0;
portsout("\n\rYour usage time will be STOPPED during uploads and \n\r");
portsout("the size of the file(s) will be added to your limit.\n\r");
portsout(CRLF);
portsout("Input filename for upload: ");
portsin(x_filename, 15);
if (strlen(x_filename) < 1)
return;
if (x_filename[0] == '.' || x_filename[0] == '/' || x_filename[0] == ' ') {
portsout("\n\r\n\rIllegal Filename!\n\r");
return;
}
code = strlen(x_filename);
code--;
if (x_filename[code] == '.' || x_filename[code] == '/' || x_filename[code] == ' ') {
portsout("\n\r\n\rIllegal Filename! \n\r");
return;
}
code = strcmp(x_filename, "files.bbs");
if (code == 0) {
portsout("\n\r\n\rIllegal Filename! \n\r");
return;
}
code = legalname("|`><!;:", x_filename);
if (code == 0) {
portsout("\n\r\n\rIllegal Filename! \n\r");
return;
}
portsout(CRLF);
str_result = strchr(x_filename, '*');
if (str_result != NULL)
tryit = TRUE;
strcpy(x_pathandfile, u_pathname);
strcat(x_pathandfile, x_filename);
if (!tryit) {
result = stat(x_pathandfile, &statbuf);
if (result == 0) {
portsout("That file already exists!\n\r");
return;
}
}
portsout(CRLF);
if ( tryit ) {
portsout("Options: K(ermit), B(atch ymodem), Z(modem),\n\r\n\r");
portsout("Commands: K,B,Z ===> ");
}
else {
portsout("Options: X(modem), C(rc xmodem), B(atch ymodem), Y(modem), Z(modem),\n\r");
portsout(" K(ermit), S(EAlink), A(scii)\n\r\n\r");
portsout("Commands: X,C,B,Y,Z,K,S,A ===> ");
}
portsin(choic1, 1);
portsout(CRLF);
*choic1 = toupper(*choic1);
if ((inbuf = fopen(callers, "a")) == NULL) { /* create or open for
* append */
portsout(CRLF);
portsout("Can't open/create callers file!");
portsout(CRLF);
return;
}
code = fprintf(inbuf, "%s %s ", " UPLOAD ", x_filename);
if (code < 0) {
portsout(CRLF);
portsout("Caller file has problem writing");
portsout(CRLF);
}
fclose(inbuf);
if (choic1[0] == 'K' || choic1[0] == 'B' || choic1[0] == 'Z')
tryit1 = TRUE;
if (tryit && !tryit1) {
portsout("\n\rIllegal use of wildcards - Must be KERMIT, YMODEM BATCH, or ZMODEM\n\r");
typexfr(11);
return;
}
switch (choic1[0]) {
case ('X'):
strcpy(x_pathandfile, RB);
strcat(x_pathandfile, u_pathname);
strcat(x_pathandfile, x_filename);
typexfr(5);
uploadtime();
result = system(x_pathandfile);
restoresig();
updatef();
enabletime();
break;
case ('Y'):
strcpy(x_pathandfile, YMDR);
strcat(x_pathandfile, u_pathname);
strcat(x_pathandfile, x_filename);
typexfr(3);
uploadtime();
result = system(x_pathandfile);
restoresig();
updatef();
enabletime();
break;
case ('C'):
strcpy(x_pathandfile, CRCR);
strcat(x_pathandfile, u_pathname);
strcat(x_pathandfile, x_filename);
typexfr(4);
uploadtime();
result = system(x_pathandfile);
restoresig();
updatef();
enabletime();
break;
case ('S'):
strcpy(x_pathandfile, SEAR);
strcat(x_pathandfile, u_pathname);
strcat(x_pathandfile, x_filename);
typexfr(7);
uploadtime();
result = system(x_pathandfile);
restoresig();
updatef();
enabletime();
break;
case ('A'):
strcpy(x_pathandfile, u_pathname);
strcat(x_pathandfile, x_filename);
typexfr(8);
if ((storbuff = fopen(x_pathandfile, "w")) == NULL) {
portsout("\n\rError opening upload file!\n\r");
break;
}
fds = fileno(storbuff);
rewind(storbuff);
locking(fds, LK_LOCK, 0L);
portsout("\n\rTerminate the ASCII upload with a control d ( ^d )");
portsout("\n\rReady to receive ASCII upload....\n\r");
uploadtime();
restoremodes();
portrst();
while ((fgets(buf128, 132, stdin)) != NULL) {
result = fputs(buf128, storbuff);
}
rewind(storbuff);
locking(fds, LK_UNLCK, 0L);
fclose(storbuff);
portinit();
setmodes();
updatef();
enabletime();
break;
case ('B'):
strcpy(x_pathandfile, YMR);
portsout("Please start your YMODEM transfer");
portsout(CRLF);
if_kermit = 1;
typexfr(2);
uploadtime();
result = system(x_pathandfile);
restoresig();
strcpy(x_pathandfile, KRE);
result = system(x_pathandfile);
if ((rdstatbuf = fopen(FLIST, "r")) == NULL) {
portsout("\n\rERROR: Unable to update!\n\r");
exit(1);
}
while (fscanf(rdstatbuf, "%14s", x_filename) != EOF) {
strcpy(x_pathandfile, u_pathname);
strcat(x_pathandfile, x_filename);
result = stat(x_pathandfile, &statbuf);
if (result != 0) {
updatef();
} else {
portsout(CRLF);
portsout(x_filename);
portsout(": Duplicate file deleted!\n\r");
strcpy(x_pathandfile, USRBBS);
strcat(x_pathandfile, x_filename);
result = unlink(x_pathandfile);
}
}
enabletime();
fclose(rdstatbuf);
break;
case ('K'):
strcpy(x_pathandfile, KRA);
portsout("Please start your KERMIT transfer");
portsout(CRLF);
if_kermit = 1;
typexfr(6);
uploadtime();
result = system(x_pathandfile);
restoresig();
strcpy(x_pathandfile, KRE);
result = system(x_pathandfile);
if ((rdstatbuf = fopen(FLIST, "r")) == NULL) {
portsout("\n\rERROR: Unable to update!\n\r");
exit(1);
}
while (fscanf(rdstatbuf, "%14s", x_filename) != EOF) {
strcpy(x_pathandfile, u_pathname);
strcat(x_pathandfile, x_filename);
result = stat(x_pathandfile, &statbuf);
if (result != 0) {
updatef();
} else {
portsout(CRLF);
portsout(x_filename);
portsout(": Duplicate file deleted!\n\r");
strcpy(x_pathandfile, USRBBS);
strcat(x_pathandfile, x_filename);
result = unlink(x_pathandfile);
}
}
enabletime();
fclose(rdstatbuf);
break;
case ('Z'):
strcpy(x_pathandfile, RZ);
portsout("Please start your ZMODEM transfer");
portsout(CRLF);
if_kermit = 1;
typexfr(1);
uploadtime();
result = system(x_pathandfile);
restoresig();
strcpy(x_pathandfile, KRE);
result = system(x_pathandfile);
if ((rdstatbuf = fopen(FLIST, "r")) == NULL) {
portsout("\n\rERROR: Unable to update!\n\r");
exit(1);
}
while (fscanf(rdstatbuf, "%14s", x_filename) != EOF) {
strcpy(x_pathandfile, u_pathname);
strcat(x_pathandfile, x_filename);
result = stat(x_pathandfile, &statbuf);
if (result != 0) {
updatef();
} else {
portsout(CRLF);
portsout(x_filename);
portsout(": Duplicate file deleted!\n\r");
strcpy(x_pathandfile, USRBBS);
strcat(x_pathandfile, x_filename);
result = unlink(x_pathandfile);
}
}
enabletime();
fclose(rdstatbuf);
break;
default:
portsout("Illegal option");
portsout(CRLF);
typexfr(11);
break;
}
portsout(CRLF);
}
uploadtime()
{
xsec = alarm(0);
Ztime = xsec;
alarm(32767);
}
enabletime()
{
sec = xsec;
alarm(sec);
}
digit(datr) char *
datr;
{
int res;
char *datr1;
datr1 = datr;
while (*datr1) {
res = *datr1;
if (!isdigit(res))
*datr1 = ' ';
datr1++;
}
}
updatef()
{
/*
* The following modifications to "updatef()" allow you to have
* MAX_DEC_LINES lines of description for uploaded files instead of
* just one.
*/
#define MAX_DESC_LINES 5
int code;
int index, index2;
char buf50[MAX_DESC_LINES][51], tmp[51];
if (if_kermit == 0) {
strcpy(buf128, u_pathname);
} else {
strcpy(buf128, USRBBS);
}
strcat(buf128, x_filename);
(void) stat(buf128, &statbuf);
if (statbuf.st_size == ((off_t) 0)) {
unlink(buf128);
return;
}
max_dload += statbuf.st_size;
set_upd(-statbuf.st_size);
portsout(CRLF);
portsout("Please describe ");
portsout(x_filename);
sprintf(tmp, " ( max of 50 characters on %d lines ) ", MAX_DESC_LINES);
portsout(tmp);
portsout(CRLF);
portsout("NOTE: NO WORD WRAP. Please watch how long your lines are!!");
portsout(CRLF);
portsout("Start with a / on line 1 for SYSOP ONLY!");
portsout(CRLF);
portsout(" ---------1---------2---------3---------4---------5");
portsout(CRLF);
index = 1;
sprintf(tmp, "%1d:", index);
portsout(tmp);
portsin(buf50[0], 50);
portsout(CRLF);
while ((buf50[(index - 1)][0] != '\0') && (index < MAX_DESC_LINES)) {
index++;
sprintf(tmp, "%1d:", index);
portsout(tmp);
portsin(buf50[(index - 1)], 50);
portsout(CRLF);
}
if (buf50[0][0] == '/') {
portsout(CRLF);
portsout(x_filename);
portsout(" will NOT be logged\n\r");
if ((inbuf = fopen(callers, "a")) == NULL) {
portsout(CRLF);
portsout("Can't open/create callers.bbs!");
portsout(CRLF);
return;
}
code = fprintf(inbuf, "%s %s", x_filename, buf50[0]);
if (code < 0) {
portsout(CRLF);
portsout("Callers file has problem writing");
portsout(CRLF);
} else {
fputs("\n", inbuf);
}
index2 = 1;
while (index2 < index) {
fprintf(inbuf, ". %s\n", buf50[index2]);
index2++;
}
if( index == MAX_DESC_LINES )
fprintf(inbuf, ".\n");
fclose(inbuf);
if (if_kermit == 0) {
strcpy(x_pathandfile, u_pathname);
} else {
strcpy(x_pathandfile, USRBBS);
}
strcat(x_pathandfile, x_filename);
strcpy(buf128, ORGPATH);
strcat(buf128, x_filename);
code = link(x_pathandfile, buf128);
if( code == -1) {
strcpy(buf128, "mv ");
strcat(buf128, x_pathandfile);
strcat(buf128, " ");
strcat(buf128, ORGPATH);
strcat(buf128, x_filename);
(void)system(buf128);
portsout("\n\r\n\rPlease leave a message to the sysop advising him that the\n");
portsout("bbs users' home directory is NOT in the same filesystem as the upload path.\n\r\n\r");
}
(void)unlink(x_pathandfile);
return;
}
strcpy(who_am_i, u_pathname);
strcat(who_am_i, FILES);
if ((inbuf = fopen(who_am_i, "a")) == NULL) { /* create or open for
* append */
portsout(CRLF);
portsout("Can't open/create files.bbs!");
portsout(CRLF);
return;
}
fds = fileno(inbuf);
rewind(inbuf);
locking(fds, LK_LOCK, 0L);
code = fprintf(inbuf, "%s %s", x_filename, buf50[0]);
if (code < 0) {
portsout(CRLF);
portsout("List file has problem writing");
portsout(CRLF);
} else {
fputs("\n", inbuf); /* put lf on end of each record */
}
index2 = 1;
while (index2 < index) {
fprintf(inbuf, ". %s\n", buf50[index2]);
index2++;
}
if( index == MAX_DESC_LINES )
fprintf(inbuf, ".\n");
rewind(inbuf);
locking(fds, LK_UNLCK, 0L);
fclose(inbuf);
if (if_kermit != 0) {
strcpy(x_pathandfile, USRBBS);
strcat(x_pathandfile, x_filename);
strcpy(buf128, u_pathname);
strcat(buf128, x_filename);
code = link(x_pathandfile, buf128);
if( code == -1) {
strcpy(buf128, "mv ");
strcat(buf128, x_pathandfile);
strcat(buf128, " ");
strcat(buf128, u_pathname);
strcat(buf128, x_filename);
(void)system(buf128);
portsout("\n\r\n\rPlease leave a message to the sysop advising him that the\n");
portsout("bbs users' home directory is NOT in the same filesystem as the upload path.\n\r\n\r");
}
code = unlink(x_pathandfile);
}
}
enough_time()
{
long lsec, lspeed;
int size, speed, code, result, astptr;
static int baud[15] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200};
char data_buffer[600];
char *ppr, *locptr;
locptr = strchr(x_pathandfile, '*');
if( locptr == NULL )
astptr = 0;
else
astptr = 1;
strcpy(data_buffer, "ls ");
strcat(data_buffer, x_pathandfile);
strcat(data_buffer, " > /tmp/wild");
strcat(data_buffer, port_id);
code = system(data_buffer);
if( !astptr )
x_pathandfile[0] = '\0';
code = 0;
sum_size = 0L;
sum_lsec = 0L;
strcpy(data_buffer, "/tmp/wild");
strcat(data_buffer, port_id);
portsout("\n\rThe following files will be sent:\n\r");
if ((inbuf = fopen(data_buffer, "r")) == NULL)
return (FALSE);
while (fscanf(inbuf, "%s", data_buffer) != EOF) {
result = stat(data_buffer, &statbuf);
if( !astptr ) {
strcat(x_pathandfile, data_buffer);
strcat(x_pathandfile, " ");
}
ppr = strrchr(data_buffer, '/');
if (ppr == NULL)
ppr = data_buffer;
else
ppr++;
if (result != 0) {
fclose(inbuf);
strcpy(data_buffer, "/tmp/wild");
strcat(data_buffer, port_id);
result = unlink(data_buffer);
return (FALSE);
}
result = strcmp(ppr, "files.bbs");
if( result == 0 ) {
portsout("\n\rIllegal file request\n\r");
return(FALSE);
}
portsout(ppr);
portsout(CRLF);
size = (statbuf.st_size / 128) + 1;
ioctl(0, TCGETA, &ttyhold);
speed = baud[ttyhold.c_cflag & 017];
lspeed = speed;
lsec = size;
sum_lsec = sum_lsec + (lsec * 128L * 11L / lspeed);
sum_size = sum_size + statbuf.st_size;
code++;
}
if( ! astptr ) {
ppr = strrchr( x_pathandfile, ' ');
if( ppr != NULL )
*ppr = '\0';
}
fclose(inbuf);
strcpy(data_buffer, "/tmp/wild");
strcat(data_buffer, port_id);
result = unlink(data_buffer);
strcpy(buf128, "\n\rTotal number of files = ");
itoa(data_buffer, code);
strcat(buf128, data_buffer);
strcat(buf128, "\n\r");
portsout(buf128);
strcpy(buf128, "Total number of bytes = ");
sprintf(data_buffer, "%ld", sum_size);
strcat(buf128, data_buffer);
portsout(buf128);
strcpy(buf128, "\n\rTotal download time = ");
sprintf(data_buffer, "%ld", sum_lsec);
strcat(buf128, data_buffer);
strcat(buf128, " seconds\n\r");
portsout(buf128);
xsec = alarm(0);
Ztime = xsec;
sec = xsec;
alarm(sec);
if (sum_lsec > xsec)
return (FALSE);
if ((sum_size + dload_total) > max_dload)
return (FALSE);
if( sum_size == 0L )
return (FALSE);
return (TRUE);
}
file_d()
{
FILE *zipp;
char choic2[2], *str_result, *ptr, *ptr1;
long lsec, hold_sec, jsec, ksec;
unsigned start_sec, stop_sec;
long var_sec;
int result, tryit, tryit1, size, speed, default_flag, code;
int mult;
static int baud[15] = {0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200};
filed:
result = stat(DLMSG, &statbuf);
if (!result) {
portsout(CRLF);
no_cntrl_k = TRUE;
cmd_p(DLMSG);
no_cntrl_k = FALSE;
portsout(CRLF);
}
tryit = FALSE;
tryit1 = FALSE;
mult = FALSE;
portsout(CRLF);
portsout("Input file name(s) to download: ");
portsin(x_filename, 98);
if (strlen(x_filename) < 1)
return;
if (x_filename[0] == '.' || x_filename[0] == '/' || x_filename[0] == ' ') {
portsout("\n\r\n\rIllegal Filename! \n\r");
return;
}
code = strlen(x_filename);
code--;
if (x_filename[code] == '.' || x_filename[code] == '/' || x_filename[code] == ' ') {
portsout("\n\r\n\rIllegal Filename! \n\r");
return;
}
code = strcmp(x_filename, "files.bbs");
if (code == 0) {
portsout("\n\r\n\rIllegal Filename! \n\r");
return;
}
str_result = strchr(x_filename, '*');
if (str_result != NULL)
tryit = TRUE;
str_result = strchr(x_filename, ' ');
if (str_result != NULL) {
tryit = TRUE;
mult = TRUE;
}
portsout(CRLF);
code = legalname("|`><!;:", x_filename);
if (code == 0) {
portsout("\n\r\n\rIllegal Filename! \n\r");
return;
}
if( mult ) {
ptr = x_filename;
x_pathandfile[0] = '\0';
while(1) {
ptr1 = strchr(ptr, ' ');
if(ptr1 == NULL)
break;
*ptr1 = '\0';
strcat(x_pathandfile, f_pathname);
strcat(x_pathandfile, ptr);
strcat(x_pathandfile, " ");
*ptr1 = (char)' ';
ptr = ptr1 + 1;
}
strcat(x_pathandfile, f_pathname);
strcat(x_pathandfile, ptr);
} else {
strcpy(x_pathandfile, f_pathname);
strcat(x_pathandfile, x_filename);
}
if (!tryit) {
result = stat(x_pathandfile, &statbuf);
if (result != 0) {
portsout("\n\rThat file does not exist!\n\r");
portsout("Remember that file names are CASE sensitive.\n\r");
return;
}
size = (statbuf.st_size / 128) + 1;
ioctl(0, TCGETA, &ttyhold);
speed = baud[ttyhold.c_cflag & 017];
lsec = size;
lsec = lsec * 128L * 11L / speed;
sum_size = statbuf.st_size;
xsec = alarm(0);
Ztime = xsec;
sec = xsec;
alarm(sec);
hold_sec = lsec;
if (lsec > xsec) {
portsout("\n\rYou don't have enough time left to download that file.\n\r");
return;
}
if ((statbuf.st_size + dload_total) > max_dload) {
portsout("\n\rThis download will overrun your download limit.");
portsout("\n\rUploads will increase your limit.\n\r");
return;
}
} else {
if (!enough_time()) {
portsout("\n\rYou don't have enough time/bytes or an error was detected.\n\r");
return;
}
hold_sec = sum_lsec;
}
hold_sec /= 2L;
portsout(CRLF);
if ( tryit )
portsout("Multi-file options: Z(modem), B(atch ymodem), K(ermit)");
else {
portsout("Options: Z(modem), C(rc xmodem), X(modem), B(atch ymodem), Y(modem),\n\r");
portsout(" K(ermit), S(EAlink), A(scii), T(ype)");
}
portsout(CRLF);
portsout(CRLF);
if ( tryit )
portsout("Commands: Z,B,K ===> ");
else
portsout("Commands: Z,C,X,B,Y,K,S,A,T ===> ");
portsin(choic2, 1);
portsout(CRLF);
default_flag = 1;
*choic2 = toupper(*choic2);
if ((inbuf = fopen(callers, "a")) == NULL) { /* create or open for
* append */
portsout(CRLF);
portsout("Can't open/create callers file!");
portsout(CRLF);
return;
}
code = fprintf(inbuf, "%s %s ", " DNLOAD ", x_filename);
if (code < 0) {
portsout(CRLF);
portsout("Caller file has problem writing");
portsout(CRLF);
}
fclose(inbuf);
if (choic2[0] == 'K' || choic2[0] == 'B' || choic2[0] == 'Z')
tryit1 = TRUE;
if (tryit && !tryit1) {
portsout("\n\rIllegal use of wildcards - Must be KERMIT, YMODEM BATCH, or ZMODEM\n\r");
typexfr(11);
return;
}
start_sec = stop_sec = 0;
xsec = alarm(0);
alarm(32767);
switch (choic2[0]) {
case ('T'):
portsout("\n\r\n\rOne moment please while an ascii check is done on the file ...... ");
if(!asciicheck(x_pathandfile)) {
portsout("Sorry.\n\rEither the file does not exist or it is not printable ascii.\n\r\n\r");
typexfr(10);
return;
}
portsout("ok.\n\r\n\r");
cmd_p(x_pathandfile);
typexfr(9);
break;
case ('A'):
strcpy(x_pathandfile, f_pathname);
strcat(x_pathandfile, x_filename);
portsout("\n\r\n\rOne moment please while an ascii check is done on the file ...... ");
if(!asciicheck(x_pathandfile)) {
portsout("Sorry.\n\rEither the file does not exist or it is not printable ascii.\n\r\n\r");
typexfr(10);
return;
}
portsout("ok.\n\r\n\r");
typexfr(8);
portsout("\n\rOnce the transfer starts, you may terminate it by typing a Control-K");
portsout("\n\rType a character to start the transfer when you are ready ===> ");
portsin(choic2, 1);
portsout(CRLF);
no_cntrl_k = TRUE;
if (!toggle) {
cmd_p(x_pathandfile);
} else {
toggle = FALSE;
cmd_p(x_pathandfile);
toggle = TRUE;
}
no_cntrl_k = FALSE;
sleep(3);
break;
case ('X'):
strcpy(x_pathandfile, SB);
strcat(x_pathandfile, f_pathname);
strcat(x_pathandfile, x_filename);
typexfr(5);
result = system(x_pathandfile);
restoresig();
start_sec = result;
sleep(1);
break;
case ('Y'):
strcpy(x_pathandfile, YMDS);
strcat(x_pathandfile, f_pathname);
strcat(x_pathandfile, x_filename);
typexfr(3);
result = system(x_pathandfile);
restoresig();
start_sec = result;
sleep(1);
break;
case ('C'):
strcpy(x_pathandfile, CRCS);
strcat(x_pathandfile, f_pathname);
strcat(x_pathandfile, x_filename);
typexfr(4);
result = system(x_pathandfile);
restoresig();
start_sec = result;
sleep(1);
break;
case ('S'):
strcpy(x_pathandfile, SEAS);
strcat(x_pathandfile, f_pathname);
strcat(x_pathandfile, x_filename);
typexfr(7);
result = system(x_pathandfile);
restoresig();
start_sec = result;
sleep(1);
break;
case ('Z'):
strcpy(msg_text, SZ);
strcat(msg_text, x_pathandfile);
typexfr(1);
result = system(msg_text);
restoresig();
start_sec = result;
sleep(1);
break;
case ('B'):
strcpy(msg_text, YMS);
strcat(msg_text, x_pathandfile);
typexfr(2);
result = system(msg_text);
restoresig();
start_sec = result;
sleep(1);
break;
case ('K'):
strcpy(msg_text, KS);
strcat(msg_text, x_pathandfile);
typexfr(6);
portsout("Ready to start KERMIT transfer");
portsout(CRLF);
result = system(msg_text);
restoresig();
start_sec = result;
break;
default:
portsout("Illegal option");
typexfr(11);
default_flag = 0;
portsout(CRLF);
break;
}
sec = alarm(0);
jsec = 32767L - (long) sec;
ksec = (long) xsec;
ksec -= jsec;
if (ksec <= 2L)
ksec = 2L;
xsec = (unsigned int) ksec;
code = 0;
if (default_flag) {
if ((zipp = fopen(callers, "a")) == NULL) { /* create or open for
* append */
portsout(CRLF);
portsout("Can't open/create callers file!");
portsout(CRLF);
return;
}
if (start_sec == 0) {
dload_total += sum_size;
set_upd(sum_size);
code = fprintf(zipp, " Transfer seems to be OK.\n");
} else
code = fprintf(zipp, " Transfer seems to have failed.\n");
if (code < 0) {
portsout(CRLF);
portsout("Caller file has problem writing");
portsout(CRLF);
}
fclose(zipp);
}
alarm(xsec);
portsout(CRLF);
}
typexfr(typex) int typex;
{
int code;
if ((inbuf = fopen(callers, "a")) == NULL) { /* create or open for
* append */
portsout(CRLF);
portsout("Can't open/create callers file!");
portsout(CRLF);
return;
}
switch (typex) {
case (1): code = fprintf(inbuf, " using ZMODEM\n");
break;
case (2): code = fprintf(inbuf, " using BATCH YMODEM\n");
break;
case (3): code = fprintf(inbuf, " using YMODEM\n");
break;
case (4): code = fprintf(inbuf, " using XMODEM-CRC\n");
break;
case (5): code = fprintf(inbuf, " using XMODEM-CHECKSUM\n");
break;
case (6): code = fprintf(inbuf, " using KERMIT\n");
break;
case (7): code = fprintf(inbuf, " using SEALINK\n");
break;
case (8): code = fprintf(inbuf, " using ASCII\n");
break;
case (9): code = fprintf(inbuf, " using TYPE\n");
break;
case (10): code = fprintf(inbuf, " NOT printable ASCII\n");
break;
default: code = fprintf(inbuf, " ......... illegal option!\n");
break;
}
if (code < 0) {
portsout(CRLF);
portsout("Caller file has problem writing");
portsout(CRLF);
}
fclose(inbuf);
}
cmd_e()
{ /* enter a message */
int entering, editing, char_cnt, temp_int, temp_int1;
char l_cnt[3], type[2], ans[2];
char *char_ptr;
char tmp[80];
entering = editing = TRUE;
cnt1 = 0;
strcpy(l_cnt, "00");
msg_text[0] = '\0'; /* init message text area */
portsout(CRLF);
portsout("This will be message # ");
portsout(h_act_msg);
portsout(CRLF);
if (!reply_sw) {
entr_name();
entr_subj();
}
if (!end_msg)
entr_priv();
if (end_msg)
strcpy(pubpriv, "5");
portsout(CRLF);
sprintf(tmp, "A line can contain 72 characters, up to %d lines.", MAX_MSG_LINES);
portsout(tmp);
portsout(CRLF);
portsout("To end, enter a carriage return on an empty line.");
portsout(CRLF);
if(blocked_m)
portsout("The lines will automatically word wrap and block.");
else
portsout("The lines will automatically word wrap.");
portsout(CRLF);
Enter:
portsout(CRLF);
portsout(" .___.____1____.____2____.____3____.____4____.____5____.____6____.____7__");
portsout(CRLF);
char_cnt = 72;
work_msg[0] = '\0';
while (entering) { /* get the text of the message */
linecnt(l_cnt); /* calc line count */
portsout(l_cnt);/* show line count */
portsout("> "); /* and prompt */
portsout(work_msg);
strcpy(buf128, work_msg);
in_the_buffer = strlen(buf128);
work_msg[0] = '\0';
portsinm(x_pathandfile, char_cnt, buf128);
char_ptr = strrchr(x_pathandfile, ' ');
temp_int = strlen(x_pathandfile);
if (temp_int >= char_cnt) {
if (x_pathandfile[temp_int - 1] == '\n' || x_pathandfile[temp_int - 1] == '\r' || x_pathandfile[temp_int - 1] == ' ') {
char_cnt = 72;
goto enter1;
}
if (char_ptr != NULL) {
*char_ptr = '\0';
char_ptr++;
strcpy(work_msg, char_ptr);
temp_int = strlen(work_msg);
for (temp_int1 = 1; temp_int1 <= temp_int; temp_int1++)
portsout("\b");
for (temp_int1 = 1; temp_int1 <= temp_int; temp_int1++)
portsout(" ");
char_cnt = 72 - temp_int;
} else {
char_cnt = 72;
}
} else {
char_cnt = 72;
work_msg[0] = '\0';
}
enter1:
strcat(buf128, x_pathandfile);
portsout(CRLF);
strcat(buf128, "\n"); /* put a <lf> on each line */
if(blocked_m) {
strcpy(x_pathandfile, buf128);
block_text();
}
if (strlen(buf128) < 2) { /* count cr too */
entering = FALSE; /* all done */
} else {
strcat(msg_text, buf128); /* append each line to
* text */
}
if ((++cnt1) > MAX_MSG_LINES) { /* only allow 20 lines */
entering = FALSE; /* all done */
}
}
while (editing) { /* save it, fix it, list it, or get out */
portsout(CRLF);
portsout("(S)ave, (L)ist, (C)ontinue, or (Q)uit");
portsout(CRLF);
portsout("ce(N)ter, (B)lock, (D)elete, (I)nsert, (R)eplace, or (E)dit line");
portsout(CRLF);
portsout("Change sub(J)ect, recei(V)er, or (P)rivilege ==> ");
portsin(ans, 1);/* get a byte */
portsout(CRLF);
*ans = toupper(*ans);
switch (ans[0]) { /* get 1 byte */
case ('S'): /* save message */
new_msg = atoi(h_act_msg);
savemsg();
editing = FALSE; /* get out of while */
break;
case ('E'): /* edit message */
case ('I'): /* edit message */
case ('D'): /* edit message */
case ('R'):
case ('N'):
case ('B'):
editmsg(*ans);
break;
case ('P'):
if (end_msg) {
portsout("\n\rCannot change the privilege on a log off message\n\r");
break;
}
entr_priv();
portsout(CRLF);
break;
case ('J'):
if (end_msg) {
portsout("\n\rCannot change the subject on a log off message\n\r");
break;
}
if (reply_sw) {
portsout("\n\rCannot change the subject on a reply to a message\n\r");
break;
}
portsout(CRLF);
entr_subj();
portsout(CRLF);
break;
case ('V'):
if (end_msg) {
portsout("\n\rCannot change the name of the receiver on a log off message\n\r");
break;
}
if (reply_sw) {
portsout("\n\rCannot change the receiver's name on a message reply\n\r");
break;
}
entr_name();
break;
case ('L'): /* list message */
listmsg();
break;
case ('Q'): /* get out w/out saving */
portsout("\n\r\n\rAre you sure you want to quit? (Y/n): ");
portsin(ans, 1);
portsout(CRLF);
if (ans[0] == 'N' || ans[0] == 'n')
break;
editing = FALSE; /* get out of while */
break;
case ('C'):
if (cnt1 == MAX_MSG_LINES) {
sprintf(tmp, "\n\rMessage is already %d lines!\n\r", MAX_MSG_LINES);
portsout(tmp);
break;
}
entering = TRUE;
cnt1--;
itoa(l_cnt, cnt1);
goto Enter;
break;
default:
portsout(CRLF);
portsout("Shall we try that one again?\r\n");
break;
}
}
}
/* end of function */
entr_name()
{
char z_fname[11], z_lname[16], z_full[22];
int length, length1;
char firstz[20], lastz[20];
char priv[6];
char etime[9];
char esize[9];
enter_it_again:
length1 = 0;
portsout(CRLF);
portsout(" ____.____1\r\n");
portsout("Enter the FIRST NAME of the receiver ===> ");
portsin(z_fname, 10);
length = strlen(z_fname);
if (!length) {
strcpy(z_fname, "All");
z_lname[0] = '\0';
goto bobble;
}
portsout(CRLF);
portsout(" ____.____1____.\r\n");
portsout("Enter the LAST NAME of the receiver ====> ");
portsin(z_lname, 15);
length1 = strlen(z_lname);
bobble:
portsout(CRLF);
fix_name(z_fname);
fix_name(z_lname);
length += length1;
if (length > 20) {
portsout("\n\rI'm sorry; however, the name is TOO long to be posted!\n\r");
goto enter_it_again;
}
strcpy(z_full, z_fname);
strcat(z_full, " ");
strcat(z_full, z_lname);
strcpy(msg_to, z_full);
portsout(CRLF);
if ((inbuf = fopen(USERPRIV, "r")) == NULL) {
portsout(CRLF);
portsout("Can't open user priv file!");
portsout(CRLF);
exit(1);
}
while (fscanf(inbuf, "%s%s%s%s%s", firstz, lastz, priv, etime, esize) != EOF) {
if ((strcmp(firstz, z_fname) == 0) &&
(strcmp(lastz, z_lname) == 0)) {
return;
}
}
fclose(inbuf);
if( strcmp(z_fname, "Sysop") == 0 ) {
strcpy(msg_to, SYSOP);
return;
}
if( strcmp(z_fname, "All") == 0 ) {
strcpy(msg_to, "All Users");
return;
}
portsout("\n\rWarning: there is no user on this system by that name.\n\r");
portsout("Do you still wish to use it? (Y/n): ");
portsin(etime, 1);
portsout(CRLF);
if( etime[0] == 'N' || etime[0] == 'n' )
goto enter_it_again;
}
entr_subj()
{
int length;
portsout(" ____.____1____.____2\n\r");
portsout("What is the subject ===> ");
portsin(msg_subject, 20);
length = strlen(msg_subject);
if (!length) {
strcpy(msg_subject, "*** NO SUBJECT ***");
}
}
entr_priv()
{
char type[2];
portsout(CRLF);
portsout("Do you wish the message to be P(ublic) or pri(V)ate) (P/V) ? ");
portsin(type, 1);
*type = toupper(*type);
switch (type[0]) {
case ('P'):
strcpy(pubpriv, "0");
break;
case ('V'):
strcpy(pubpriv, "5");
break;
default:
portsout("\n\rDefaulting to public!\n\r");
strcpy(pubpriv, "0");
break;
}
}
linecnt(lcnt) /* 2 byte string of line numbers */
char *lcnt;
{
int icnt;
char xcnt[4];
icnt = atoi(lcnt);
if (++icnt < 10) {
strcpy(lcnt, "0");
itoa(xcnt, icnt);
strcat(lcnt, xcnt);
} else {
itoa(xcnt, icnt);
strcpy(lcnt, xcnt);
}
return;
}
/* end of function */
savemsg()
{ /* save a message */
int fd;
portsout("Saving...\r\n");
strcpy(msg_delete, pubpriv); /* delete byte */
strcpy(msg_date, mm);
strcat(msg_date, "/");
strcat(msg_date, dd);
strcat(msg_date, "/");
strcat(msg_date, yy);
strcpy(msg_time, ttime);/* and the time */
strcpy(msg_from, w_fname); /* and the from name */
strcat(msg_from, " ");
strcat(msg_from, w_lname);
if ((inbuf = fopen(callers, "a")) == NULL) { /* create or open for
* append */
portsout(CRLF);
portsout("Can't open/create callers file!");
portsout(CRLF);
return;
}
fd = fprintf(inbuf, "%s%s", " Message being sent to ", msg_to);
if (fd < 0) {
portsout(CRLF);
portsout("Caller file has problem writing");
portsout(CRLF);
} else {
fputs("\n", inbuf); /* put lf on end of each record */
}
fclose(inbuf);
hdrread(); /* Guarantee proper header and table */
if ((fd = msgopen(2)) == ERROR) { /* open i/o */
return (ERROR);
}
msgwrt(fd); /* write the message */
msgclose(fd);
strcpy(h_date, msg_date);
hdrwrt(); /* update the header file */
}
/* end of function */
listmsg()
{
char *ptr, byte, lcnt[3];
int i;
ptr = msg_text; /* ptr points to start of text */
strcpy(lcnt, "00");
portsout(CRLF);
while (*ptr != 0) {
linecnt(lcnt);
portsout(lcnt); /* put out line number */
portsout(">");
while (byte = *ptr++) {
if (byte == '\n') { /* we dont save <cr>, so add *//* i
* t here when find a <cr> */
portsout(CRLF);
break;
} else
portout(byte);
}
}
}
/* end of function */
editmsg(tflag) char
tflag;
{
char ans[3];
int lnum; /* line number to edit */
char tmp[80];
while (1) {
portsout(CRLF);
portsout("Enter line number to ");
if (tflag == 'E')
portsout("edit,");
else if (tflag == 'D')
portsout("delete,");
else if (tflag == 'I')
portsout("insert after,");
else if (tflag == 'R')
portsout("replace,");
else if (tflag == 'N')
portsout("center,");
else if (tflag == 'B')
portsout("block,");
else
return;
portsout(CRLF);
portsout(" or RETURN to exit ==> ");
portsin(ans, 2);/* only MAX_MSG_LINES lines possible */
portsout(CRLF);
if (tflag == 'I' && cnt1 == MAX_MSG_LINES) {
sprintf(tmp, "\n\rMessage is already %d lines!\n\r", MAX_MSG_LINES);
portsout(tmp);
return;
}
lnum = atoi(ans);
if (lnum <= 0) {
break; /* out of while and return */
}
if ((lnum < MAX_MSG_LINES) || ((lnum == MAX_MSG_LINES) && (tflag != 'I'))) {
editline(lnum, tflag);
break;
} else { /* else slap on hand and loop around */
sprintf(tmp, "Aw come on, there can only be %d lines!", MAX_MSG_LINES);
portsout(tmp);
portsout(CRLF);
portsout("Shall we try that again?");
portsout(CRLF);
}
}
}
/* end of function */
usenet()
{ /* added for 7.2.1 USENET access */
#ifdef SYSV
#define logname getlogin
#endif
char *logname();
static char shell[] = "SHELL=/bin/sh";
static char home[150];
static char logn[50];
char cmd[512];
char news[520];
char tmp[512];
FILE *newsf;
int mask;
char term;
strcpy(home, "HOME=");
strcpy(logn,"LOGNAME=");
strcat(home, ORGPATH);
strcat(home, "usenet/");
strcat(home, u_fname);
strcat(home, "/");
strcat(home, u_lname);
strcat(logn, logname());
sprintf(news, "%susenet/%s/%s/.newsrc", ORGPATH, u_fname, u_lname);
if (access(news, 00) == -1) {
mask = umask(0000);
portsout("creating necessary news files\n\r");
portsout("\n\r");
sprintf(tmp, "/bin/mkdir %susenet/%s", ORGPATH, u_fname);
system(tmp);
strcat(tmp, "/");
strcat(tmp, u_lname);
system(tmp);
if ((newsf = fopen(news, "w")) == NULL) {
portsout("open of .newsrc failed\n\r");
exit(-1);
}
fprintf(newsf, "");
fclose(newsf);
umask(mask);
}
menu:
portsout("\n\rWhich type of terminal do you have:\n\r");
portsout("1) Ansi Standard Monitor\n\r");
portsout("2) ANSI.SYS for MS-DOS\n\r");
portsout("3) VT100\n\r");
portsout("4) Macintosh MacTerm in VT-100 mode\n\r");
portsout("5) VT52 Terminal\n\r");
portsout("6) Televideo 925\n\r");
portsout("7) Televideo 910\n\r");
portsout("8) Tandy DT-100\n\r");
portsout("9) Dumb - Use this when nothing else works correctly.\n\r");
portsout(" Instead of the normal \"- MORE -\" inbetween pages\n\r");
portsout(" You will see nothing, BUT you will hear a beep.\n\r");
portsout(" This is the same thing. \"?\" is for help\n\r");
portsout("\n\rQ) Return to main menu\n\r");
portsout("===> ");
term = portin();
portsout("\n\r");
switch (term) {
case ('1'):
putenv("TERM=ansi");
break;
case ('2'):
putenv("TERM=dosansi");
break;
case ('3'):
putenv("TERM=vt100");
break;
case ('4'):
putenv("TERM=macterm");
break;
case ('5'):
putenv("TERM=vt52so");
break;
case ('6'):
putenv("TERM=tvi925co");
break;
case ('7'):
putenv("TERM=tvi910");
break;
case ('8'):
putenv("TERM=dt100");
break;
case ('9'):
putenv("TERM=dumb");
break;
case ('Q'):
case ('q'):
portsout("\n\r");
return (0);
break;
default:
portsout("\n\rYou have selected an unsupported type. Please try again\n\r");
goto menu;
break;
}
putenv(shell);
putenv(home);
putenv(logn);
choose:
portsout("\n\rDo you wish to:\n\r");
portsout("1) Readnews\n\r");
portsout("2) Postnews\n\r");
portsout("\n\rQ) Return to main menu\n\r");
portsout("===>");
term = portin();
portsout("\n\r");
switch (term) {
case ('1'):
restoremodes();
portrst();
STDerr = freopen("/dev/tty", "w+", stderr);
sprintf(cmd, "%s -n all",READN);
system(cmd);
break;
case ('2'):
restoremodes();
portrst();
STDerr = freopen("/dev/tty", "w+", stderr);
sprintf(cmd, "%s",POSTN);
system(cmd);
break;
case ('Q'):
case ('q'):
portsout("\n\r");
strcpy(home, "HOME=");
strcpy(logn, "LOGNAME=");
cmd[0] = '\0';
news[0] = '\0';
tmp[0] = '\0';
return (0);
break;
default:
portsout("Please try again\n\r");
goto choose;
break;
}
strcpy(home, "HOME=");
strcpy(logn, "LOGNAME=");
cmd[0] = '\0';
news[0] = '\0';
tmp[0] = '\0';
strcpy(buf128, STDERR);
strcat(buf128, port_id);
STDerr = freopen(buf128, "w+", stderr);
portinit();
setmodes();
restoresig();
}
restoresig()
{
signal(SIGALRM, timer);
signal(SIGHUP, hanged);
signal(SIGUSR1, mon_toggle);
signal(SIGUSR2, sys_toggle);
signal(SIGPIPE, chat);
}