Annotation of sbbs/sbbs2/viewfile.c, revision 1.1.1.1

1.1       root        1: #line 1 "VIEWFILE.C"
                      2: 
                      3: /* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */
                      4: 
                      5: #include "sbbs.h"
                      6: 
                      7: void viewfilecontents(file_t f)
                      8: {
                      9:        char str[128],cmd[128];
                     10:        int i;
                     11: 
                     12: if(f.size<=0L) {
                     13:        bputs(text[FileNotThere]);
                     14:        return; }
                     15: 
                     16: sprintf(str,"%s%s",f.altpath > 0 && f.altpath<=altpaths
                     17:        ? altpath[f.altpath-1] : dir[f.dir]->path
                     18:        ,unpadfname(f.name,tmp));
                     19: strcpy(tmp,f.name);
                     20: truncsp(tmp);
                     21: for(i=0;i<total_fviews;i++) {
                     22:        if(!stricmp(tmp+9,fview[i]->ext)
                     23:                && chk_ar(fview[i]->ar,useron)) {
                     24:                strcpy(cmd,fview[i]->cmd);
                     25:                break; } }
                     26: if(i==total_fviews)
                     27:        bprintf(text[NonviewableFile],tmp+9);
                     28: else
                     29:        if((i=external(cmdstr(cmd,str,str,NULL)
                     30:                ,EX_OUTL|EX_OUTR|EX_INR|EX_CC))!=0)
                     31:                errormsg(WHERE,ERR_EXEC,cmdstr(cmd,str,str,NULL),i);
                     32: }
                     33: 
                     34: /****************************************************************************/
                     35: /* Views file with:                                                         */
                     36: /* (B)atch download, (V)iew file (E)xtended info, (Q)uit, or [Next]:        */
                     37: /* call with ext=1 for default to extended info, or 0 for file view         */
                     38: /* Returns -1 for Batch, 1 for Next, or 0 for Quit                          */
                     39: /****************************************************************************/
                     40: int viewfile(file_t f, int ext)
                     41: {
                     42:        char ch,str[256];
                     43:     int i;
                     44: 
                     45: curdirnum=f.dir;       /* for ARS */
                     46: while(online) {
                     47:     if(ext)
                     48:         fileinfo(f);
                     49:        else
                     50:                viewfilecontents(f);
                     51:     ASYNC;
                     52:     CRLF;
                     53:     sprintf(str,text[FileInfoPrompt],unpadfname(f.name,tmp));
                     54:     mnemonics(str);
                     55:     ch=getkeys("BEVQ\r",0);
                     56:     if(ch=='Q' || sys_status&SS_ABORT)
                     57:         return(0);
                     58:     switch(ch) {
                     59:         case 'B':
                     60:             addtobatdl(f);
                     61:             CRLF;
                     62:             return(-1);
                     63:         case 'E':
                     64:             ext=1;
                     65:             continue;
                     66:         case 'V':
                     67:             ext=0;
                     68:             continue;
                     69:         case CR:
                     70:             return(1); } }
                     71: return(0);
                     72: }
                     73: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.