home *** CD-ROM | disk | FTP | other *** search
- #include "crcpchdr.h"
-
- #define DEBUG TRUE /* conditional debug code included when TRUE */
-
- #define DLMT ","
- mail(z,args,opts)
- char z, *args, *opts;
- {
- FILE *fp, *tfp, *ofp;
- char *tok_ptr;
- char mailfile[15],workfile[15];
- char from[9],name[15],delete[10],type[5],comment[LINESIZE];
- char dir[DIRSIZE], root[ROOTSIZE];
- char dir_buff[STR_SIZE+2];
- char workstr1[STR_SIZE+2];
- char workstr2[STR_SIZE+2];
- char mailbox[15];
- char new_mbx[15];
- int del_flg ;
- int kilflg;
- int posflg, quiet;
- int writeout;
- int rc;
- int num_out;
- char ackstr[LINESIZE];
- char ackstr2[LINESIZE];
- char fdat[LINESIZE];
- char c;
-
- stccpy(mailbox,home_dir,sizeof(mailbox));
- stccpy(new_mbx,home_dir,sizeof(new_mbx));
- strcat(mailbox,MAIL_EXT);
- strcat(new_mbx,WMAIL_EXT);
- num_out = 0;
- quiet = find_option(opts,'q');
- posflg = find_option(opts,'!');
- kilflg = find_option(opts,'k'); /* Auto-Mail Kill */
- if (sysdir("",MAILBOX)) {
- printf("System directory '%s' not found.\r\n",MAILBOX);
- mputs("Sorry, MAIL facility not active.");
- return;
- }
- else if ((fp=fopen(mailbox,"r"))==NULL) { /* Is stuff in his mailbox? */
- if (!quiet) printf("No mail.\r\n");
- }
- else { /* 1 */
- if (posflg) c = 'Y';
- else if (!*args) c = *disp_reply("You have mail. Read it now? (Y/N) ",workstr1,2);
- else c = *args;
- del_flg = FALSE;
- if (toupper(c)!='Y') {
- if (!quiet && beginner) {
- mputs("Your mail will accumulate until it gets deleted, or you\r\n");
- mputs("read it. You may read it later with the <P> command.\r\n");
- }
- else nothing_done();
- fclose(fp);
- }
- else { /* 2 */
- if ((ofp=fopen(new_mbx,"w"))==NULL) { /* Can we create a new one? */
- printf("Cannot create temporary mail box. See %s\r\n",SYSOP);
- fclose(fp);
- goto getout;
- }
- while(fgets(dir_buff,STR_SIZE,fp)!=NULL) {
- if (!notnull(dir_buff)) continue; /* Skip */
- *ackstr='\0';
- *ackstr2='\0';
- writeout = TRUE; /* Saving by default */
- tok_ptr = incptr(stptok(stpblk(dir_buff),from,9,DLMT));
- tok_ptr = incptr(stptok(stpblk(tok_ptr),name,13,DLMT));
- tok_ptr = incptr(stptok(stpblk(tok_ptr),dir,DIRSIZE,DLMT));
- tok_ptr = incptr(stptok(stpblk(tok_ptr),root,ROOTSIZE,DLMT));
- tok_ptr = incptr(stptok(stpblk(tok_ptr),delete,10,DLMT));
- tok_ptr = incptr(stptok(stpblk(tok_ptr),type,5,DLMT));
- tok_ptr = incptr(stptok(stpblk(tok_ptr),fdat,LINESIZE,DLMT));
- stccpy(comment,stpblk(tok_ptr),LINESIZE);
- del_crlf(comment);
- if (! (*from && *name && *type)) {
- printf("Missing info in MAILBOX queuefile - see %s\r\n",SYSOP);
- #if DEBUG==TRUE
- printf("from=%s,name=%s,type=%s\r\n",from,name,type);
- #endif
- }
- else if (sysdir(dir,root)) {
- printf("Could not find directory: '%s',\r\n",prefix_dir(workstr1,dir,root));
- printf("mail file '%s' could not be retrieved.\r\n",name);
- sprintf(ackstr,"Could not find %s for %s (%s) on %s\r\n",
- prefix_dir(workstr1,name,dir),user_id,type,timedate());
- writeout = FALSE; /* We must forget about it */
- }
- else {
- sysdir(home_dir,user_root);
- if (!strcmp(type,"MAIL")) {
- printf("MAIL from %s sent on %s:\r\n",from,fdat);
- sysdir(dir,root);
- #if DEBUG==TRUE
- if (debug) {
- printf("just sysdir(%s,%s);\r\n",dir,root);
- printf("p_d()=%s\r\n",prefix_dir(workstr1,dir,root));
- }
- #endif
- if (typefile(name,opts)) goto nodelete;
- sprintf(ackstr,"User %s read mail (%s) on %s\r\n",
- user_id,prefix_dir(workstr1,name,dir),timedate());
- if (!kilflg) {
- c = *disp_reply("\r\nHold this message(default = N)? ",workstr1,2);
- writeout = (toupper(c)=='Y');
- if (writeout) {
- printf("Message held.\r\n");
- sprintf(ackstr2,"File %s placed on HOLD by user %s - do not delete\r\n",
- prefix_dir(workstr1,name,dir),user_id);
- }
- }
- }
- else {
- printf("FILE from %s, Original name: %s, Sent on %s:\r\n",from,name,fdat);
- if (comment[0]!='\0') printf("REMARK: '%s'.\r\n",comment);
- if ((tfp=fopen(name,"r"))!=NULL) {
- fclose(tfp);
- printf("WARNING: file with same name on current directory\r\n");
- if (beginner) printf(" suggest giving new name.\r\n");
- }
- printf("Press <ENTER> to load file as '%s',\r\n",name);
- disp_reply("enter new filename, or type 'NUL' to throw away:\r\n>",workfile,13);
- if (workfile[0]=='\0') stccpy(workfile,name,sizeof(workfile));
- uppercase(workfile);
- if (!strcmp(workfile,"NUL")) {
- sprintf(ackstr,"User: %s ignored file %s on %s\r\n",
- user_id,prefix_dir(workstr1,name,dir),timedate());
- printf("File thrown away; ignored\r\n");
- }
- else {
- prefix_dir(workstr1,home_dir,user_root);
- prefix_dir(workstr2,dir,root);
- #if DEBUG==TRUE
- if (debug) printf("about to copy %s%s to %s%s\r\n",
- workstr2,name,workstr1,workfile);
- #endif
- if (sysfcopy(workstr1,workfile,workstr2,name,FALSE,TRUE)) goto nodelete;
- sprintf(ackstr,"User %s loaded file %s as %s on %s\r\n",
- user_id,prefix_dir(workstr,name,dir),workfile,timedate());
- }
- writeout = FALSE; /* Read or ignored */
- }
- cr();
- if (!writeout & !strcmp(delete,"DELETE")) {
- sysdir(dir,root);
- if (unlink(name)) {
- printf("Error while DELETE of '%s'.\r\n",name);
- sprintf(ackstr2,"File %s was NOT deleted, as was requested",prefix_dir(workstr,name,dir));
- }
- else {
- mputs("File deleted from source.\r\n");
- sprintf(ackstr2,"File was deleted as requested.");
- }
- }
- nodelete:
- }
- if (*ackstr | *ackstr2) {
- if (!sysdir(from,user_root)) {
- if ((tfp=fopen(SYSTEM_MSG,"a"))!=NULL) {
- if (*ackstr) fputs(ackstr,tfp);
- if (*ackstr2) fputs(ackstr2,tfp);
- printf("Receipt acknowledged to %s.\r\n",from);
- fclose(tfp);
- }
- }
- }
- if (writeout) {
- fputs(dir_buff,ofp);
- num_out++;
- }
- } /* END WHILE */
- /* NOT SURE */ sysdir("",MAILBOX); /* THIS IS NECESSARY */
- fclose(fp); /* Close input (old) mail log */
- fclose(ofp); /* Close output (new) mail log */
- rc=unlink(mailbox); /* He accepted: delete his old mailbox */
- #if DEBUG==TRUE
- if (rc && debug) printf("%s not deleted, rc=%d\r\n",mailbox,rc);
- #endif
- if (num_out>0) {
- rc=rename(new_mbx,mailbox); /* Put new one in place */
- #if DEBUG==TRUE
- if (rc && debug) printf("%s not renamed, rc=%d\r\n",new_mbx,rc);
- #endif
- }
- else unlink(new_mbx); /* Delete file if no MSGS held */
- } /* END ELSE 2 (WANTS TO READ MAIL) */
- } /* END ELSE 1 */
- getout:
- sysdir(cur_dir,cur_root);
- }
-
- user_set(c,args,opts)
- char c, *args, *opts;
- {
- char *prompt, *r;
- if (!*args && beginner && !find_option(opts,'q')) disp_msg(28);
- do {
- if (!*args) {
- show_tsets(opts);
- if (beginner) prompt = "Enter number of item to change: ";
- else prompt = "Item? ";
- r = disp_reply(prompt,file_buff,LINESIZE);
- }
- else r = args;
- if (*r) {
- if (!stoi(r)) printf("Bad selection\r\n");
- else change_tsets(stoi(r));
- }
- } while(*r && !*args);
- record_tdf();
- }
-
- static show_tsets(opts)
- char *opts;
- {
- printf("Terminal settings:\r\n");
- printf("\r\n");
- printf("1.) Width: %s\r\n",utwidth?itos(utwidth):"NA");
- printf("2.) Length: %s\r\n",utlength?itos(utlength):"NA");
- printf("3.) Cls$: %s\r\n",*utcls?dec_list(file_buff,utcls,LINESIZE):"NA");
- printf("4.) Duplex: %s\r\n",duplex==FULL?"FULL":"HALF");
- printf("5.) Tabs: %s\r\n",tflag?"REAL":"EXPANDED");
- printf("\r\n");
- }
-
- static change_tsets(num)
- int num;
- {
- char *prompt;
- switch(num) {
- case 1: if (beginner) prompt = "Enter new terminal line width, chars ";
- else prompt = "New width ";
- utwidth = new_num(utwidth,prompt,10,255);
- break;
- case 2: if (beginner) prompt = "Enter new terminal page length, lines ";
- else prompt = "New length ";
- utlength = new_num(utlength,prompt,10,255);
- break;
- case 3: if (beginner) {
- printf("Use '*' to delete cls sequence\r\n");
- prompt = "Enter new clear screen sequence: ASCII codes separated by commas: ";
- }
- else prompt = "New cls sequence ? ";
- disp_reply(prompt,file_buff,LINESIZE);
- if (file_buff[0]) {
- if (file_buff[0]=='*') file_buff[0] = '\0';
- bin_list(utcls,file_buff,sizeof(utcls));
- }
- else nothing_done();
- break;
-
- case 4: duplex = !duplex;
- printf("Ok\r\n");
- break;
-
- case 5: tflag = !tflag;
- printf("Ok\r\n");
- break;
- }
- }
-
- static record_tdf()
- {
- sprintf(termdef,"%s %s %d %d %s",
- termtype,tflag?"DIRECT":"STANDARD",
- utlength,utwidth,dec_list(file_buff,utcls,LINESIZE));
- }
-
- static new_num(is,pr,b,t)
- int is;
- char *pr;
- int b, t;
- {
- int c;
- printf("%s (%d; %d-%d): ",pr,is,b,t);
- disp_reply("",file_buff,4);
- c = stoi(file_buff);
- if ((c!=0)&(b>c||t<c)) { /* Allow 0 thru as CANCEL this function */
- nothing_done();
- return(is);
- }
- else return c;
- }
-
-
- buzz_sysop(c,args,opts)
- char c, *args, *opts;
- {
- int quiet;
-
- quiet = find_option(opts,'q');
- if (sysop_there) {
- if (quiet) {
- printf("%c.%c.%c.%c.%c.%c\r\n",BEEP,BEEP,BEEP,BEEP,BEEP,BEEP);
- printf("Have buzzed console. Please continue.\r\n");
- }
- else {
- printf("If someone, such as the system operator, is nearby,\r\n");
- printf("then s/he will intervene and converse with you.\r\n");
- printf("Let me RING them now: %c.%c.%c.%c.%c.%c\r\n",BEEP,BEEP,BEEP,BEEP,BEEP,BEEP);
- printf("Please continue using the system in the meantime.\r\n");
- }
- }
- else {
- if (quiet) {
- printf("Not present.\r\n");
- }
- else {
- mputs("There is no system operator nearby.\r\n");
- mputs("Please leave mail for system personnel\r\n");
- mputs("regarding any system business.\r\n");
- }
- }
- }
-
- ask_sysop(c,args,opts)
- char c, *args, *opts;
- {
- request_acct(opts);
- }
-
- user_data(z,args,opts)
- char z, *args, *opts;
- {
- char c;
- char usern[11];
- int brief, quiet, conct, curdr;
-
- quiet = find_option(opts,'q');
- brief = find_option(opts,'b');
- conct = find_option(opts,'c'); /* 'Show connect time' */
- curdr = find_option(opts,'d'); /* 'Show current Directory' */
-
- if (!quiet) {
- cr();
- mputs("\r\nUser data sheet:\r\n");
- cr();
- }
- cr();
-
- if (curdr) {
- print_cd();
- cr();
- if (!conct) return;
- }
-
- if (!conct) {
- if (no_account) {
- printf(" Visiting user: ");
- strcpy(usern,user_id);
- if (strcmp(uppercase(usern),DEFLT_DIR)) printf(user_id);
- if (userloc[0]) printf(" User location: %s\r\n",userloc);
- printf("\r\n");
- }
- else {
- printf(" System user id: %s\r\n",user_id);
- if (username[0]) printf(" Name: %s\r\n",username);
- if (laston[0]) printf(" Date last called: %s\r\n",laston);
- if (!brief) {
- if (usersys[0]) printf(" System type: %s\r\n",usersys);
- if (fxfer[0]) printf(" Files xferred: %s\r\n",fxfer);
- if (termdef[0]) printf(" T-settings: %s\r\n",termdef);
- }
- printf(" Times on system: %d\r\n",timeson);
- }
- if (quiet) return;
- if (!brief) {
- if (medit_opts[0]) printf(" Medit options: %s\r\n",medit_opts);
- if (maxconnect!=defmaxconnect) {
- printf(" Maximum visit: %d minutes\r\n",maxconnect);
- }
- if (!no_account) printf(" Average visit: %d minutes\r\n",(int)
- (((long)totconnec