home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / c / crcbbs.arc / CRCPC1B.C < prev    next >
Text File  |  1985-10-22  |  21KB  |  759 lines

  1. #include    "crcpchdr.h"
  2.  
  3. int fork_board(c,args,opts)
  4. char c, *args, *opts;
  5. {
  6. char *type;
  7. int rc;
  8.  
  9. if (!fork_allowed) {
  10.     printf("Sorry, this command has been disabled.\r\n");
  11.     return(99);
  12.     }
  13. if (!*args && beginner && !find_option(opts,'q')) disp_msg(16);
  14. if (no_account) {
  15.     printf("You must first obtain an account before\r\n");
  16.     printf("using this command.  See <A> command at main menu.\r\n");
  17.     return(99);
  18.     }
  19. if (*args) {
  20.     stptok(args,workstr,9," ");
  21.     goto tryth1;
  22.     }
  23. getdnagn:
  24. if (*args) return(1000);
  25. disp_reply("Enter name for new message board:  ",workstr,9);
  26. if (!workstr[0]) return(nothing_done()&0);
  27. tryth1:     
  28. if (type=stpbrk(workstr,INVDOSFNCHR)) {
  29.      bad_dn(*type);
  30.      goto getdnagn;
  31.      }
  32. uppercase(workstr);
  33. if (!sysdir(workstr,user_root)) {
  34.      printf("There exists a user '%s' on the system.  Use another name.r\n",workstr);
  35.         goto getdnagn;
  36.     }
  37. else if (!sysdir(workstr,MESSAGES)) {
  38.      printf("There already exists a '%s' board!\r\n",workstr);
  39.         goto getdnagn;
  40.     }
  41. printf("Standby:\r\n");
  42.         /* Rc==2 when using -XT (??) */
  43. if ((rc=sysmkdir(workstr,MESSAGES)) && rc!=2) {
  44.     printf("Oops!  Error during directory creation.\r\n");
  45.     printf("Not today: sorry.\r\n");
  46.     sprintf(file_buff,"MESSAGE BOARD '%s' CREATION BY %s FAILED: RC=%d",
  47.         workstr,user_id,rc);
  48.     logevent(file_buff);
  49.     }
  50. else {
  51.     printf("Ok %s, message directory '%s' created and ready for use.\r\n",
  52.         usname(),workstr);
  53.     sprintf(file_buff,"MESSAGE BOARD '%s' CREATED BY %s",workstr,user_id);
  54.     logevent(file_buff);
  55.     }
  56. return(0);
  57. }
  58.  
  59. kill_board(c,args,opts)
  60. char c, *args, *opts;
  61. {
  62. int gnl_flag;
  63. char *type;
  64.  
  65. if (!fork_allowed) {
  66.     printf("Sorry, this command has been disabled.\r\n");
  67.     return;
  68.     }
  69. if (!*args && !find_option(opts,'q') && beginner) disp_msg(17);
  70. if (no_account) {
  71.     printf("You must first obtain an account before\r\n");
  72.     printf("using this command.  See <A> command at main menu.\r\n");
  73.     return;
  74.     }
  75.  
  76. if (*args) {
  77.     stptok(args,workstr,9," ");
  78.     goto tryth2;
  79.     }
  80.  
  81. g2tdnagn:
  82. if (*args) return;
  83. printf("Enter name of message board to kill:  ");
  84. strcpy(workstr,lineinput(9));
  85. if (!workstr[0]) return(nothing_done());
  86. tryth2:
  87. if (type=stpbrk(workstr,INVDOSFNCHR)) {
  88.     bad_dn(*type);
  89.     goto g2tdnagn;
  90.     }
  91. uppercase(workstr);
  92. if (sysdir(workstr,MESSAGES)) {
  93.     printf("No such board.\r\n");
  94.     return;
  95.     }
  96. else if (!setup_dir("*.*",FILE_TYP)) {
  97.     printf("Directory '%s' has files in it!\r\n",workstr);
  98.     return;
  99.     }
  100. printf("Please wait; this takes awhile sometimes...\r\n");
  101. sysdir("",MESSAGES);
  102. if (gnl_flag=sysrmdir(workstr,MESSAGES)) {
  103.     if (gnl_flag==5) {
  104.         printf("'%s' has files in it!\r\n",workstr);
  105.         return;
  106.         }
  107.     else if (gnl_flag==3) printf("No such board: '%s'!\r\n",workstr);
  108.     goto g2tdnagn;
  109.     }
  110. else {
  111.     printf("Ok %s, message board '%s' has been removed.\r\n",usname(),workstr);
  112.     sprintf(file_buff,"MESSAGE BOARD %s REMOVED BY %s",workstr,user_id);
  113.     logevent(file_buff);
  114.     }
  115. }
  116.  
  117. msg_sys(c,args,opts)
  118. char c, *args, *opts;
  119. {
  120. char messtyp[15];
  121. int quiet, ags;
  122.  
  123. ags = (*args);
  124. quiet = find_option(opts,'q');
  125. do {
  126.     if (sysdir("",MESSAGES)) {
  127.         printf("Cannot access message tree: %s.\r\n",MESSAGES);
  128.         return;
  129.         }
  130.     else {
  131.         if (beginner && !quiet && !*args) {
  132.             mputs("Enter the name of a system message board.\r\n");
  133.             mputs("For a list of current message boards, type <*>, or <ENTER> to quit\r\n");      
  134.             cr();
  135.             }
  136. brdlist:
  137.         if (!*args) disp_reply("Message board? ",boardname,9);
  138.         else args = stpblk(stptok(args,boardname,9," "));
  139.         while(boardname[0]=='*') {   
  140.             dir("*.*",DIR_TYP);
  141.             disp_reply("Message board? ",boardname,9);
  142.             }
  143.         if (boardname[0]) {
  144.             if (sysdir(boardname,MESSAGES)) 
  145.                 printf("Message board '%s' not found.\r\n",boardname);
  146.             else {
  147.                 if (wildcards) {
  148.                     if (!*args) {
  149.                         if (beginner && !quiet) {
  150.                             mputs("You may use UNIX, and CP/M style 'wildcards' which are\r\n");
  151.                             mputs("used in selecting the messages you access.  The filename\r\n");
  152.                             mputs("is the name of the sender, the extension is msg #.\r\n");
  153.                             }
  154.                         disp_reply("Enter wildcard or press <ENTER>: ",messtyp,9);
  155.                         }
  156.                     else args = stpblk(stptok(args,messtyp,9," "));
  157.                     if (messtyp[0]=='\0') strcpy(messtyp,"*.*");
  158.                     else if (stpchr(messtyp,'.')==NULL) strcat(messtyp,".*");
  159.                     }
  160.                 else strcpy(messtyp,"*.*");
  161.                 msgdir(boardname,messtyp,args,opts);
  162.                 }
  163.             }
  164.         }
  165.     } while(boardname[0] && !ags);
  166. }
  167.  
  168.  
  169. /* MOVETOBOARD:  We are logged onto the BOARD directory we want a users file 
  170.          to go to.  First, we determine the message number, then copy it.
  171.                                     */
  172. static movetoboard(bname,fname,udir)
  173. char bname[];
  174. char fname[];
  175. char udir[];
  176. {
  177.     int rc;
  178.     int lm;
  179.     char sourcen[15];
  180.     char extn[5];
  181.     char newdir1[40];
  182.     char newdir2[33];
  183.  
  184.     if (rc=setup_dir("*.*",FILE_TYP)) lm = 1;    /* Setup for msg scan */
  185.     else {
  186.         create_list();            /* Create memory array from names */
  187.         sort_list(list,list_idx);    /* Sort the names */
  188.         lm = list[list_idx-1]->value+1;
  189.         drop_list();
  190.         }
  191.  
  192.     strcpy(sourcen,user_id);     /* Get senders name as filename */
  193.     sprintf(extn,".%d",lm);        /* Next avail. msg # */
  194.     strcat(sourcen,extn);        /* Create filename */
  195.  
  196.     prefix_dir(newdir1,bname,MESSAGES);
  197.     prefix_dir(newdir2,udir,user_root);
  198.         
  199.                         /*  text,create */
  200.     if (!sysfcopy(newdir1,sourcen,newdir2,fname,TRUE,TRUE)) {
  201.         printf("Msg %d saved into %s message board.\r\n",lm,bname);
  202.         sprintf(newdir1,"%s POSTED MSG#%d TO %s",user_id,lm,bname);
  203.         logevent(newdir1);
  204.         }
  205. }
  206.  
  207.  
  208.  
  209. /*****************************************************************************
  210.  *  MSGDIR:  Perform disk directory into string array.  Sort array, then     *
  211.  *         goto user with sorted list, allowing access to files in list.   *
  212.  *****************************************************************************/
  213. static int msgdir(board,fn,args,opts)
  214. char board[];
  215. char *fn ;               
  216. char *args, *opts;
  217. {
  218.     int rc;
  219.     int lastmsg;
  220.     int mo,dy,yr;
  221.  
  222.     sysdate(&mo,&dy,&yr);
  223.     uppercase(board);
  224.     if (sysdir(board,MESSAGES)) return(baddir(board));
  225.  
  226.     if (rc=setup_dir(fn,FILE_TYP)) ;
  227.     else {
  228.         create_list();            /* Create memory array from names */
  229.         sort_list(list,list_idx);    /* Sort the names */
  230.         lastmsg = l_u_msg(board);    /* Find out where he was */
  231.         if (!strcmp(fn,"*.*") &&    /* If on entire board */
  232.              !no_account)           /* And user has account */
  233.             if (list[list_idx-1]->value==l_b_msg(board) && !find_option(opts,'q'))
  234.                 printf("No new messages.\r\n");
  235.         lastmsg = goto_user(lastmsg,board,fn,args,opts);
  236.         if (!strcmp(fn,"*.*") &&    /* If on entire board */
  237.              !no_account)        /* And user has account */
  238.             a_u_msg(board,list[list_idx-1]->value,lastmsg,mo,dy,yr);
  239.         drop_list();            /* Drop the names from memory */
  240.         }
  241.     return(rc);
  242. }
  243.  
  244.  
  245. static char *smsg_fnc(c)
  246. char c;
  247. {
  248. switch(c) {
  249.     case 'W': return("WSCAN");
  250.     case 'R': return("READ");
  251.     case 'S': return("SCAN");
  252.     case 'D': return("DELETE");
  253.     }
  254. return("");
  255. }
  256.  
  257. /* NOTE:  LIST_IDX is defined as being positive during thes routines ! */
  258. static int next_midx(msgnum)
  259. int msgnum;
  260. {
  261. int i;
  262. for (i=0;i<list_idx;++i) if (list[i]->value>msgnum) break;    
  263. return(i<list_idx?i:-1);
  264. }
  265.  
  266.  
  267. /* NEXT_IDX: We search forward or backward until finding non deleted filename */
  268. /* Return "-1" if not found */
  269. static int next_idx(sidx,dir)
  270. int sidx;
  271. int dir;
  272. {
  273. for (sidx+=dir;sidx>=0 && sidx<list_idx;sidx+=dir)
  274.     if (list[sidx]->filedata.filename_char[0]!='*'&&list[sidx]->value) break;
  275. return((sidx>=0 && sidx<list_idx)?sidx:-1);
  276. }
  277.  
  278. /*****************************************************************************
  279.  *  FIRST_IDX:   Find index to first file number in array.                   *
  280.  *         Returns "-1" if no data in array.                               *
  281.  *****************************************************************************/
  282. static int first_idx()
  283. {
  284. return(next_midx(0));
  285. }
  286.  
  287. /*****************************************************************************
  288.  *  FIND_IDX:   Find index to corresponding file number in the array.        *
  289.  *         Return index to indicated file number, else -1 for not found.   *
  290.  *****************************************************************************/
  291. static int find_idx(msgnum)
  292. int msgnum;
  293. {
  294.     int i;
  295.  
  296.     if ((i=first_idx())!=-1) 
  297.         while(i<list_idx) 
  298.             if (list[i]->value==msgnum)    return(i);
  299.                              else i++;
  300.     return (-1);
  301. }
  302.  
  303.  
  304. /* Returns '0' if no message files in array, else first message number */
  305. static int first_msg()
  306. {
  307. int ans;
  308. ans = list_idx ? list[first_idx()]->value : 0; 
  309. return(ans);
  310. }
  311.  
  312.  
  313. /* Returns '0' if no message files in array, else last message number */
  314. static int last_msg() 
  315. int ans;
  316. ans = list_idx ? list[list_idx-1]->value : 0;
  317. return(ans);
  318. }
  319.  
  320.  
  321. /* Returns '0' if no message files in array, else number of messages in array */
  322. /* NOTE: The result of this routine is incorrect if any 'deleted' files exist */
  323. /*       in the array                                    */
  324. static int tot_msg() 
  325. int ans;
  326. ans = list_idx ? list_idx-first_idx() : 0;
  327. return(ans);
  328. }
  329.  
  330. /*****************************************************************************
  331.  *  GOTO_USER:  We have a sorted list of file entries in the string array.   *
  332.  *         We present an acceptable method of accessing these files here.  *
  333.  *****************************************************************************/
  334. static int goto_user(lstusrmsg,board,filter,args,opts)
  335. int lstusrmsg;
  336. char board[];
  337. char filter[];
  338. char *args, *opts;
  339. {
  340.     char c;
  341.     int mode;
  342.     int index;
  343.     int alt_index;
  344.     int alt_msg;
  345.     int quiet;
  346.     int firstmsgnum, lastmsgnum, totmsgs;
  347.     char fromwho[9];
  348.     char token[LINESIZE+2];
  349.     char *parseptr;
  350.     char string[LINESIZE+2];
  351.  
  352. quiet = find_option(opts,'q');
  353. quit = FALSE;
  354. firstmsgnum = first_msg();
  355. lastmsgnum = last_msg();
  356.  
  357. if (!list_idx || !lastmsgnum) {
  358.     printf("No messages (%s) on %s board.\r\n",filter,board);
  359.     return(0);
  360.     }
  361.  
  362.         /* Get index to next msg */
  363. if ((index=next_midx(lstusrmsg)==-1)) index=list_idx-1;    /* In case not found */
  364. totmsgs = tot_msg();
  365.  
  366.  
  367. if (totmsgs>1) strcpy(string,"s");
  368. else string[0] = '\0';
  369. printf("%d message%s (%s) on %s: %d-%d\r\n",totmsgs,string,filter,board,firstmsgnum,lastmsgnum);
  370. do {
  371.     output = TRUE;
  372.     if (!*args) {
  373.         if (!quiet && beginner) {
  374.             mputs("--------------\r\n");
  375.             mputs("Message Access\r\n");
  376.             mputs("--------------\r\n");
  377.             cr();
  378.             mputs("Press <ENTER> to return to main level.\r\n");
  379.             }
  380.         printf("(%s: W,R,S,D,?): ",board);
  381.         c = *ltrim(lineinput(2));
  382.         }
  383.     else {
  384.         c = *args ;
  385.         args = skptok(args);
  386.         }
  387.  
  388.     if (c=toupper(c)) {
  389.         if (stpchr("WRSD?",c)==NULL) printf("? %c: type ? for help.\r\n",c);
  390.         else if (c=='?') help(SYSACC,opts);
  391.         else {
  392.             if (c!='D' && beginner && !quiet) msgaccinst(c,index);
  393.             do {
  394.                 get_name(fromwho,list[index]->filedata.filename_ext);
  395.                 quit = FALSE;
  396.                 if (beginner && !quiet) {
  397.                     sprintf(token,"Current message: %d\r\n",list[index]->value);
  398.                     mputs(token);
  399.                     }
  400.                 if (!*args) {
  401.                     if (beginner && !quiet) printf("Press <ENTER> to return.\r\n");
  402.                     sprintf(token,"(%s [%d-%d]: Y=%d, ?=help):  ",
  403.                         smsg_fnc(c),firstmsgnum,lastmsgnum,list[index]->value);
  404.                     mputs(token);
  405.                     strcpy(string,lineinput(LINESIZE));
  406.                     }
  407.                 else strcpy(string,args);
  408.                 output = TRUE;
  409.                 if (string[0]) index=perform_line(c,string,index,opts);
  410.                 } while (string[0] && index>=0 && !*args);
  411.             } /* End Else */
  412.         } /* End IF */
  413.     if (index<0) printf("All messages deleted.\r\n");
  414.     } while(c && index>=0 && !*args);
  415.  
  416.                         /* Point to last msg read */
  417. index = index==list_idx-1?index:index-1;
  418. index = chk_idx(index);
  419.  
  420. return(index<0?0:list[index]->value);
  421. }
  422.  /* End GOTO USER */
  423.  
  424. static int perform_line(c,string,index,opts)
  425. char c;
  426. char string[];
  427. int index;
  428. char *opts;
  429. {    
  430. int alt_index;
  431. int alt_msg;
  432. char token[LINESIZE+2];
  433. char *parseptr;
  434.  
  435. parseptr = stpblk(string);
  436. *parseptr = toupper(*parseptr);
  437.     /* Make 'FORWARD', 'REVERSE' and 'BACKWARD' work too */
  438. if (*parseptr=='F') *parseptr = '+';
  439. else if (*parseptr=='B' || *parseptr=='R') *parseptr = '-';
  440.  
  441. if (*parseptr=='Y') index=access(c,index,'+',1,opts);
  442. else if (*parseptr=='?') help(SYSMSG,opts);
  443. else if (*parseptr=='-'||*parseptr=='+') index=access(c,index,*parseptr,999,opts);
  444. else {
  445.     while(*parseptr && !quit && index>=0) {
  446.         parseptr = stptok(parseptr,token,sizeof(token)," ,#;:-+\n");
  447.         alt_msg = stoi(token);
  448.         if (!alt_msg) printf("Bad msg #%s\r\n",token);
  449.         else if (*stpblk(parseptr)=='+'||*stpblk(parseptr)=='-') {
  450.             parseptr = stpblk(parseptr);
  451.             if ((alt_index=next_midx(alt_msg-1))<0) msgnf(alt_msg);
  452.             else index=access(c,alt_index,*parseptr,999,opts);
  453.             }
  454.         else {
  455.             if ((alt_index=find_idx(alt_msg))<0) msgnf(alt_msg);    
  456.             else index=access(c,alt_index,'+',1,opts);
  457.             }
  458.         if (*parseptr) parseptr = stpblk(++parseptr);
  459.         } /* End While */
  460.     } /* End Else */
  461.                 /* Return index to NEXT msg to read, or "-1" */
  462. return(index);
  463. }
  464.  
  465.  
  466. static msgnf(mn)
  467. int mn;
  468. {
  469. printf("#%d not found.\r\n",mn);
  470. }
  471.  
  472. static int user_is_sure()
  473. {
  474.     char c;
  475.     
  476.     mputs("Enter <Y> if you are sure.  ");
  477.     c = *ltrim(lineinput(2));
  478.     return((toupper(c)=='Y'));
  479. }
  480.  
  481. static int access(function,index,direction,max,opts)
  482. char function;
  483. int index;
  484. char direction;
  485. int max;
  486. char *opts;
  487. {
  488. int inc;
  489. char filename[14];
  490. char workstr[LINESIZE];
  491. char fname[9];
  492. char c;
  493. int i;
  494. int gnl_flg;
  495. int ctr;
  496. int alt_index ;
  497.  
  498. for (ctr=0,inc=(direction=='-')?-1:1;ctr<max && 
  499.                     list_idx && 
  500.                         index>=first_idx() && 
  501.                         index<list_idx && 
  502.                         !quit;index+=inc,ctr++) {
  503.     if (bdos(KBHIT)) {
  504.         c = bdos(CONSINP);
  505.         c = toupper(c);
  506.         if (c==CTL_K || c=='K') {
  507.             quit = TRUE;
  508.             cr();
  509.             break;
  510.             }
  511.         else if (!c) local_function(bdos(CONSINP));
  512.         }
  513.     get_name(fname,list[index]->filedata.filename_ext);
  514.     if (fname[0]!='*') { /* Not been deleted */
  515.         if (function=='D') del_msg(uppercase(fname),index);
  516.         else if (function=='W') {    /* Wscan */
  517.             sprintf(workstr,"%d by %s on %s is %ld chars\r\n",
  518.                 list[index]->value,
  519.                 get_name(filename,list[index]->filedata.filename_ext),
  520.                 filedate(list[index]->filedata.file_date),
  521.                 (long)list[index]->filedata.file_size);
  522.             mputs(workstr);
  523.             }
  524.         else r_or_sc(index,function,fname,opts);  /* Read, or Scan */
  525.         }    /* End If (file not already deleted) */
  526.     }    /* End FOR */
  527.  
  528. index = chk_idx(index);        /* make sure dont go out of bounds on 'list' */
  529.  
  530. if (index>=0) {
  531.     if (list[index]->filedata.filename_ext[0]=='*') {
  532.         if ((alt_index=next_idx(index,inc))<0)
  533.             alt_index=next_idx(index,0-inc);
  534.         index = alt_index ;
  535.         }
  536.     }
  537.         /* Return INDEX TO NEXT msg to read in curdir, or "-1" */
  538. return(index);
  539. }
  540.     /* End ACCESS */
  541.  
  542. static int chk_idx(idx)
  543. int idx;
  544. {
  545. if (!list_idx) return(-1);
  546. if (idx<first_idx()) idx = first_idx();
  547. else if (idx>=list_idx) idx = list_idx-1;
  548. return(idx);
  549. }
  550.  
  551.  
  552. static r_or_sc(index,function,fname,opts)
  553. int index;
  554. char function;
  555. char fname[];
  556. char *opts;
  557. {
  558. FILE *path;
  559. int gnl_flag, i;
  560. char workstr[LINESIZE];
  561.  
  562. if ((path=fopen((*list[index]).filedata.filename_ext,"r"))==NULL) {
  563.     printf("Msg '%s' was deleted.\r\n",
  564.         list[index]->filedata.filename_ext);
  565.     }
  566. else {
  567.     switch(function) {
  568.         case 'R':
  569.             printf("Message #%d was ",list[index]->value);
  570.             printf("written by %s on %s at %s\r\n",
  571.                 fname,
  572.                 filedate(list[index]->filedata.file_date),
  573.                 filetime(list[index]->filedata.file_time));
  574.             printf("(%ld characters)\r\n",(long)list[index]->filedata.file_size);
  575.             fileterm(path,opts);
  576.             cr();
  577.             break;
  578.         case 'S':
  579.             sprintf(workstr,"%d by %s on %s is %ld characters:\r\n",
  580.                 list[index]->value,fname,
  581.                 filedate(list[index]->filedata.file_date),
  582.                 (long)list[index]->filedata.file_size);
  583.             mputs(workstr);
  584.             gnl_flag = TRUE;
  585.             for (i=0;i<MSGHDRSIZ && gnl_flag;++i)
  586.                 if (gnl_flag=(fgets(workstr,LINESIZE,path)!=NULL)) 
  587.                     mputs(workstr);
  588.             cr();
  589.             break;
  590.         }     /* End Switch */
  591.     if (path!=NULL) fclose(path);
  592.     }    /* End Else (no error opening file) */
  593. }
  594.  /* End Read or Scan */
  595.  
  596. static del_msg(fname,index)
  597. char fname[];
  598. int index;
  599. {
  600. if (strcmp(home_dir,uppercase(fname)) &&  /*  Not creator of MSG, AND */
  601.         !syswrite) { /* no system write priveledges */
  602.     printf("Only the creator of the message, user %s, or\r\n",fname);
  603.     printf("the system operator may delete msg %d.\r\n",list[index]->value);
  604.     return;
  605.     }
  606. else if (0 & (int)printf("Delete msg %d ? ",
  607.         list[index]->value) ||
  608.     !user_is_sure()) ;
  609. else if (unlink(list[index]->filedata.filename_ext)) {
  610.     printf("Error during delete of msg %d.\r\n",list[index]->value);
  611.     }
  612. else {
  613.     printf("Message %d deleted.\r\n",list[index]->value);
  614.     list[index]->filedata.filename_ext[0]='*'; /* Zap */
  615.     }
  616. }
  617.  
  618.  
  619. /* SMFILE: Send MAIL file */
  620. smfile(c,args,opts)
  621. char c, *args, *opts;
  622. {
  623. char boardname[11], filename[17], alt_user[11], mailfile[17];
  624. char b, *ftype, *type, *delete, *t1, *t2, *t3, *t4;
  625. char comments[LINESIZE+2];
  626. int gnl_flag, quiet, dlf, ndlf, posflg;
  627. FILE *fp;
  628.  
  629. if (!has_auth("R",cur_dir,cur_root)) {
  630.     not_auth('R',cur_dir,cur_root);
  631.     return;
  632.     }
  633.  
  634. t4 = stpblk(threeparse(args,&t1,&t2,&t3));
  635.  
  636. quiet = find_option(opts,'q');
  637. if (ndlf=find_option(opts,'k')) dlf = FALSE;    /* Only one: Keep, or Delete */
  638. else dlf=find_option(opts,'d');
  639. posflg = (find_option(opts,'!') && *t3);
  640.  
  641. if (!*args && !quiet && beginner) disp_msg(20);
  642.  
  643. if (!*t1) {
  644.     disp_reply(file_prompt(beginner,"send"),filename,14);
  645.     if (filename[0]=='\0') return(nothing_done());
  646.     }
  647. else stptok(t1,filename,sizeof(filename),"");
  648. if (check_fn(filename,TRUE)) return;
  649. if (check_rsvf(filename,TRUE)) return;    /* Can't use reserved filename */
  650. if ((fp=fopen(filename,"r"))==NULL) return(not_open());
  651. else {                            /* 1 */
  652.       fclose(fp);
  653.     gnl_flag = FALSE;
  654.     uppercase(filename);
  655. send_file:
  656.     if (!*t2) {
  657.         printf("Send message file: %s\r\n",filename);
  658.         if (beginner && !quiet) {
  659.               printf("If you want to use the public message board, type '%s'.\r\n",DEFLT_MSB);
  660.               printf("Enter username or message board name: ");
  661.               }
  662.         else printf("Boardname or user id: ");
  663.         disp_reply("",boardname,9);
  664.         }
  665.     else stptok(t2,boardname,sizeof(boardname),"");
  666.  
  667.     uppercase(boardname);
  668.     strcpy(alt_user,boardname);
  669.     if (boardname[0]) {
  670.         if (!sysdir(boardname,MESSAGES)) 
  671.             movetoboard(boardname,filename,cur_dir);
  672.         else if (sysdir(boardname,user_root)) 
  673.             printf("No user directory '%s' found.\r\n",boardname);
  674.         else if (sysdir("",MAILBOX)) {
  675.             printf("Sorry, mail system inoperable.\r\n");
  676.             printf("System mail directory not found.\r\n");
  677.             }
  678.      /*3*/    else {
  679.              stccpy(mailfile,alt_user,sizeof(mailfile));
  680.             strcat(mailfile,MAIL_EXT);
  681.             if ((fp=fopen(mailfile,"a"))==NULL)
  682.                 printf("Error opening user SYSMAIL file.\r\n");
  683.         /*4*/    else {
  684.                 if (!*t3) {
  685.                         printf("Enter 'M' for MAIL, or 'S' for file transfer: ");
  686.                     b = *ltrim(lineinput(2));
  687.                     }
  688.                 else b = *t3;
  689.                 if (toupper(b)=='S') {
  690.                     ftype = "File";
  691.                     type = "SEND";
  692.                     if (!*t4) disp_reply("Enter optional comment line:\r\n",comments,LINESIZE);
  693.                     else stptok(t4,comments,sizeof(comments),"");
  694.                     }
  695.                 else {
  696.                     comments[0] = '\0';
  697.                     type = "MAIL";
  698.                     ftype = "Mail";
  699.                     }
  700.                 if (!(dlf||ndlf)) {
  701.                     printf("File to be deleted when read (Y/N)? ");
  702.                     b = *ltrim(lineinput(2));
  703.                     }
  704.                 else b = dlf?'Y':'N';    /* 'Y' if delete flag */
  705.                 b = toupper(b);
  706.                 if (b=='Y') delete = "DELETE";
  707.                 else delete = "KEEP";    
  708.                 if (posflg) {
  709.                     printf("%s file: %s to %s%s; CORRECT ? ",type,filename,
  710.                         alt_user,b=='Y'?" and DELETE when read":"");
  711.                     b = *ltrim(lineinput(4));
  712.                     }
  713.                 else b = 'Y';
  714.                 if (toupper(b)!='Y') {
  715.                     fclose(fp);
  716.                     goto send_file;
  717.                     }
  718.                 sprintf(file_buff,"%s,%s,%s,%s,%s,%s,%s,%s\r\n",home_dir,filename,cur_dir,cur_root,delete,type,timedate(),comments);
  719.                 fputs(file_buff,fp);
  720.                 fclose(fp);
  721.                 printf("%s (%s) posted for '%s'.\r\n",ftype,filename,alt_user);
  722.                 if (!strcmp(delete,"DELETE")) printf("File will be deleted when read.\r\n");
  723.                 gnl_flag = TRUE;
  724.                 if (!*t2) goto send_file;
  725.                 } /* END ELSE 4 */
  726.             }  /* END ELSE 3 */
  727.         } /* END IF 2 */
  728.     if (gnl_flag) {
  729.         if (beginner && !quiet) {
  730.             printf("File sent.  You will be informed when it has been read.\r\n");
  731.             printf("Remember: the file you just queued, called '%s'\r\n",filename);
  732.             mputs("must remain in your directory until read by whoever you sent it\r\n");
  733.             mputs("to.  If you specified DELETE, it will be removed after being read.\r\n");
  734.             mputs("automatically by the system.\r\n");
  735.             }
  736.         }
  737.     } /* END ELSE 1 */
  738. }
  739.  
  740.  
  741. static msgaccinst(c,index)
  742. char c;
  743. int index;
  744. {
  745. char token[LINESIZE+2];
  746. ctlsctlk();
  747. cr();
  748. if (c=='R' || c=='r') mputs("Control-O will skip rest of message\r\n");
  749. sprintf(token,"%s mode: current msg# = %d\r\n",smsg_fnc(c),list[index]->value);
  750. mputs(token);
  751. mputs("CONTINUOUS: Enter 'F' for forward or 'B' for backward\r\n");
  752. mputs("INDIVIDUAL: Enter 'Y' for current msg, or enter msg#, or msg#'s\r\n");
  753. mputs("            (append '+' or '-' for continous)\r\n");
  754. }
  755. 
  756. 
  757.