home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / f / frbts_20.zip / FIDONET.C next >
C/C++ Source or Header  |  1991-04-28  |  19KB  |  622 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*    File.c      Version 2.0    By Craig Derouen                           */
  4. /*                File i/o processsing module for Frobot.c                  */
  5. /*                                                                          */
  6. /*                                                                          */
  7. /****************************************************************************/
  8.  
  9. #include "frobot.h"
  10.  
  11. #include <share.h>
  12. #include <time.h>
  13.  
  14. #include "globals.h"
  15.  
  16. #define MAXFMSGS  999        /* Maximum # of Fido messages to scan for */
  17.  
  18.  
  19. /* Process a fidonet filesend function */
  20. void file_send(char *p1,char *line,char *sendfile)
  21. {
  22.    FILE *flfile;
  23.    FILE *incfile;
  24.    int code,results,mode;
  25.  
  26.    mode = 0;         /* If mode == 1, do file delete after sending
  27.                      if mode == 2, do file truncate after sending */
  28.  
  29. /* Command could be "SD" for delete or "ST" for truncate */
  30.  
  31.    if (tolower(*(p1+1)) == 'd') 
  32.       mode = 1;
  33.    else if (tolower(*(p1+1)) == 't') mode = 2;
  34.  
  35.    if ((flfile = _fsopen(FloFile,"at+",SH_DENYWR)) == NULL) {
  36.       sprintf(temp,"Error opening/creating file %s",FloFile);
  37.       aborterror(BADFILE,temp);
  38.    }
  39.    if (*sendfile == '@') {    /* Is it an include file? */
  40.       if ((incfile = _fsopen(sendfile+1,"rt",SH_DENYNO)) == NULL) {
  41.          sprintf(temp,"Error opening file %s",sendfile+1);
  42.          aborterror(BADFILE,temp);
  43.       }
  44.       results = 0;
  45.       while (fgets(temp,65,incfile)) {
  46.          if (*temp != ';') {        /* Commented out */
  47.             temp[strlen(temp)-1] = 0;        /* Strip out line feed */
  48.             if (test_sfile(temp,flfile,mode) == FALSE) {    /* A file was sent */
  49.                 DoFSendMsg(temp);
  50.                 results++;
  51.             }
  52.          }
  53.       }
  54.       if (results) {        /* We sent some files */
  55.          sprintf(temp," %d File(s) sent on %s",results,datestr);
  56.          commentline(line,temp);
  57.          FileSends += results;
  58.       }
  59.       fclose(incfile);
  60.    }
  61.    else {        /* It's an individal file */
  62.       code = test_sfile(sendfile,flfile,mode);
  63.       switch (code) {
  64.          case -1:        /* File already in flow file */
  65.             commentline(line,"File(s) are already being sent. Disabled");
  66.             break;
  67.  
  68.          case FALSE:        /* File is sent */
  69.             DoFSendMsg(sendfile);
  70.             sprintf(temp,"File(s) sent on %s",datestr);
  71.             commentline(line,temp);
  72.             FileSends++;
  73.             break;
  74.  
  75.          case TRUE:        /* File not found */
  76.             commentline(line,"File(s) to send were not found!");
  77.             break;
  78.       }
  79.    }
  80.    fclose(flfile);
  81. }
  82.  
  83. /* Process a fidonet filerequest function */
  84. void file_request(char *line,char *requestfile)
  85. {
  86.    FILE *flfile;
  87.    FILE *incfile;
  88.    FILE *incbfile;
  89.    char backup[_MAX_PATH];
  90.    char *p,*fname;
  91.    int filetimes = 0,results;
  92.    int retries = 0;
  93.    int files = -1;
  94.    int doreqs = 0;
  95.    int reqcreate;
  96.  
  97.    if(stat(ReqFile,&fbuf) == -1)
  98.       reqcreate = TRUE;
  99.    else reqcreate = FALSE;
  100.  
  101.    if ((flfile = _fsopen(ReqFile,"at+",SH_DENYWR)) == NULL) {
  102.       sprintf(temp,"Error opening/creating file %s",ReqFile);
  103.       aborterror(BADFILE,temp);
  104.    }
  105.  
  106.    if (*requestfile == '@') {    /* Is it an include file? */
  107.       if ((incfile = _fsopen(requestfile+1,"rt",SH_DENYNO)) == NULL) {
  108.          sprintf(temp,"Error opening file %s",requestfile+1);
  109.          aborterror(BADFILE,temp);
  110.       }
  111.       createbackup(requestfile+1,backup);
  112.       if ((incbfile = _fsopen(backup,"wt+",SH_DENYNO)) == NULL) {
  113.          sprintf(temp,"Error creating temp file %s",backup);
  114.          aborterror(BADFILE,temp);
  115.       }
  116.       while (fgets(temp,65,incfile)) {
  117.          blanktrim(temp);
  118.          if (!*temp)  /* It's a blank line just delete it */
  119.             continue;
  120.          if (*temp != ';') {
  121.             if (files == -1)        /* set a flag */
  122.                files = 0;
  123.             files++;
  124.             strcpy(temp1,temp);
  125.             fname = strtok(temp1," \t\n");        /* File name */
  126.             p = strtok(NULL," =\t\n");        /* Count */
  127.             if (p) {
  128.                filetimes = atoi(p);
  129.                p = strtok(NULL,"  \t\n");
  130.                if (p) retries = atoi(p);
  131.                else retries = 0;
  132.             }
  133.             else {
  134.                filetimes = FileCount;        /* Plug in default */
  135.                retries = 0;
  136.             }
  137.             p = strtok(fname,"!");
  138.             strcpy(password,strtok(NULL," \n"));
  139.             results = test_rfile(p,flfile,filetimes,retries);
  140.             switch (results) {
  141.                case -1:         /* File received already */
  142.                   sprintf(temp,";%s %d=%d <- File received on %s",
  143.                      fname,filetimes,retries,datestr);
  144.                   DoNoteMsg(fname);
  145.                   break;
  146.  
  147.                case -2:        /* File already exists in reqfile */
  148.                   break;
  149.  
  150.                case -3:        /* Maximum retries */
  151.                   break;
  152.  
  153.                case -4:        /* Trashed name */
  154.                      sprintf(temp,";%s %d <- Filename has trashed/illegal characters",fname,filetimes);
  155.                      break;
  156.  
  157.                case 1:        /* File is requested, disabled because magicfilename */
  158.                   doreqs++;
  159.                   files--;
  160.                   if (password[0])
  161.                      sprintf(temp,";%s!%s %d=1 <- MagicFilename retries disabled",fname,password,filetimes);
  162.                   else sprintf(temp,";%s %d=1 <- MagicFilename retries disabled",fname,filetimes);
  163.                   DoFReqMsg(fname);
  164.                   break;
  165.  
  166.                case 2:        /* File requested, normal */
  167.                   doreqs++;
  168.                   retries++;
  169.                   files--;
  170.                   if (password[0])
  171.                         sprintf(temp,"%s!%s %d=%d ",fname,password,filetimes,retries);
  172.                   else sprintf(temp,"%s %d=%d ",fname,filetimes,retries);
  173.                   DoFReqMsg(fname);
  174.                   break;
  175.             }
  176.          }
  177.          strcat(temp,"\n");
  178.          fputs(temp,incbfile);
  179.       }
  180.       fclose(incfile);
  181.       fclose(incbfile);
  182.       if(remove(requestfile+1) == 0) 
  183.          rename(backup,requestfile+1);
  184.       else {
  185.          warble();
  186.          printf("Error changing filelist file\n");
  187.          remove(backup);
  188.       } 
  189.       if (files == 0) commentline(line," All files in list have been requested/tried");
  190.    }
  191.    else {        /* Its a standard filename */
  192.       fname = strtok(requestfile,"!");
  193.       strcpy(password,strtok(NULL," \n"));
  194.       results = test_rfile(fname,flfile,FileCount,XferTries);
  195.       switch (results) {
  196.          case -1:         /* File received already */
  197.             sprintf(temp," File received on %s",datestr);
  198.             commentline(line,temp);
  199.             DoNoteMsg(fname);
  200.             break;
  201.  
  202.          case -2:        /* File already exists in reqfile */
  203.             break;
  204.  
  205.          case -3:        /* Maximum tries */
  206.             break;
  207.  
  208.          case -4:
  209.             commentline(line,"Filename has trashed/illegal characters");
  210.             break;
  211.  
  212.          case 1:        /* File is requested, disabled because magicfilename */
  213.             doreqs++;
  214.             commentline(line,"MagicFilename, retries disabled");
  215.             DoFReqMsg(fname);
  216.             break;
  217.  
  218.          case 2:        /* File requested, normal */
  219.             doreqs++;
  220.             results = XferTries;
  221.             if (XferTries == -1)
  222.                XferTries +=2;
  223.             else XferTries++;
  224.             if (results == -1) {
  225.                results = strlen(line);
  226.                line[results-1] = 0;        /* Strip linefeed */
  227.                strcat(line,"=1\n");
  228.             }
  229.             else {        /* Alter XferTries count */
  230.                p = strtok(line,"=");        /* Strip out count */
  231.                strcpy(temp,p);
  232.                sprintf(backup,"=%d\n",XferTries);
  233.                strcat(temp,backup);
  234.                strcpy(line,temp);         /* Redo the line */
  235.             }
  236.             DoFReqMsg(fname);
  237.             break;
  238.       }
  239.    }
  240.    fclose(flfile);
  241.    if (doreqs) {        /* We did some filerequests, make sure there is a flofile */
  242.       flfile = _fsopen(FloFile,"at",SH_DENYWR);
  243.       fclose(flfile);
  244.       FileReqs += doreqs;
  245.    }
  246.    else if (reqcreate)     /* Did we create a req file? */
  247.       remove(ReqFile);        /* Don't confuse Binkley then */
  248. }
  249.  
  250.  
  251. /* Establish destination node and filespec, check for errors in either */
  252. int setdest(char *input,char *line)
  253. {
  254.    char *p;
  255.    char *p1;
  256.    int code=FALSE;
  257.    char nodestr[15];
  258.  
  259.  
  260.    p1 = (char *) malloc(strlen(input) + 1);        /* Make duplicate */
  261.    if (p1 == NULL)
  262.       aborterror(NOMEM,NULL);
  263.    strcpy(p1,input);
  264.  
  265.    DestFile[0] = 0;
  266.    p = strtok(p1," ;\t\n");        /* grab the filespec */
  267.    if (p != NULL)
  268.       strcpy(DestFile,p);
  269.    else {
  270.       commentline(line,"Invalid filespec!");
  271.       free(p1);
  272.       return(TRUE);
  273.    }
  274.  
  275.    p = strtok(NULL," ;\t\n");        /* Grab the Net/Node string */
  276.    strcpy(nodestr,p);        /* Copy to temp string */
  277.    if (p != NULL) {
  278.       if (parsenet(nodestr,&DestZone,&DestNet,&DestNode)) {
  279.          commentline(line,"Invalid Net/Node!");
  280.          code = TRUE;
  281.       }
  282.       if (DestNet + DestNode == 0) {
  283.          commentline(line,"Blank Net/Node!");
  284.          code = TRUE;
  285.       }
  286.    }
  287.    else {
  288.       commentline(line,"Invalid Net/Node!");
  289.       code = TRUE;
  290.    }
  291.    free(p1);
  292.    return(code);
  293. }
  294.  
  295. /* Test the given file to see if in the flofile
  296.    if not, place it in there. Also test for file existing.
  297.    If file does not exist return TRUE, Return -1 if file already
  298.    in flow file. */
  299.  
  300. /* If mode == 1, do file delete after sending
  301.    if mode == 2, do file truncate after sending */
  302.  
  303. int test_sfile(char *fname,FILE *flfile,int mode)
  304. {
  305.    struct find_t fsearch;
  306.    char tfile[65];
  307.  
  308.    if (!filescan(flfile,fname)) {        /* Is it already there? */
  309.    /* Okay then first see if file exists */
  310.       if(_dos_findfirst(fname,_A_NORMAL,&fsearch)) /* File was not found */
  311.          return TRUE;
  312.       else {
  313.          if (mode == 1) sprintf(tfile,"^%s\n",fname);
  314.          else if (mode == 2) sprintf(tfile,"#%s\n",fname);
  315.          else sprintf(tfile,"%s\n",fname);
  316.          fputs(tfile,flfile);        /* Append it */
  317.          return FALSE;
  318.       }
  319.    }
  320.    else return -1;
  321. }
  322.  
  323. /* Test the given file and see if its in the req file, or has been
  324.    received. Codes upon return:
  325.  
  326.    -1 ==  File has been received,
  327.    -2 ==  File already exists in req file,
  328.    -3 ==  Maximum tries
  329.    -4 ==  Invalid filename
  330.     1 ==  File is requested and now req is disabled
  331.     2 ==  File is requested.
  332.  
  333.      filetries is # of times to request file
  334.      count is number of times file was already requested */
  335.  
  336. int test_rfile(char *fname,FILE *reqfile,int filetries,int count)
  337. {
  338.    struct find_t fsearch;
  339.    char fullname[65];
  340.    char *p;
  341.  
  342.    p = fname;
  343.    while (*p) {        /* check for valid filename */
  344.       switch (*p) {        /* Check for list of invalid DOS file characters */
  345.          case '+':
  346.          case '=':
  347.          case '/':
  348.          case '[':
  349.          case ']':
  350.          case '"':
  351.          case ':':
  352.          case ';':
  353.          case ',':
  354.          case '?':
  355.          case '*':
  356.          case '\\':
  357.          case '<':
  358.          case '>':
  359.          case '|':
  360.             return -4;        /* Say it's invalid */
  361.             break;
  362.  
  363.          default:
  364.             if (*p & 0x80)        /* Check high bit ascii */
  365.                return -4;
  366.             if (*p < ' ')
  367.                return -4;
  368.             break;
  369.       }
  370.       p++;
  371.    }
  372.  
  373.    sprintf(fullname,"%s\\%s",Inbdir,fname);
  374.  
  375.    if(_dos_findfirst(fullname,_A_NORMAL,&fsearch) == 0) /* File was found */
  376.       return -1;
  377.  
  378.    if (filescan(reqfile,fname))     /* Is it already in req file? */
  379.       return -2;
  380.  
  381.    if (count >= filetries && filetries != 0)
  382.       return -3;
  383.  
  384.    strcpy(fullname,fname);
  385.    if (password[0]) {
  386.       strcat(fullname," !");
  387.       strcat(fullname,password);
  388.    }
  389.    strcat(fullname,"\n");
  390.    fputs(fullname,reqfile);
  391.  
  392. /* Check to see if it's a magic filename. I.E. it has an extension */
  393.  
  394.    if (strchr(fname,'.') == NULL && filetries != 0)
  395.       return 1;
  396.  
  397.    return 2;
  398. }
  399.  
  400. void DoFSendMsg(char *filename)
  401. {
  402.    int msgnum;
  403.    FILE *fmsg;
  404.    char msgline[81];
  405.    char fn[_MAX_FNAME];
  406.    char ext[_MAX_EXT];
  407.  
  408.    _splitpath(filename,temp2,temp2,fn,ext);
  409.  
  410.    sprintf(msgline,"File %s is sent to %d/%d",filename,DestNet,DestNode);
  411.    logit(msgline,'#');
  412.    if (ShowActivity)
  413.       sprintf("\r%s\n",msgline);
  414.  
  415.    if (!SysopMail)
  416.       return;
  417.  
  418.    ExitCode = 2;
  419.  
  420.    if (FidoMsgSend[0] == 0) {            /* Create a new message */
  421.       if((msgnum = create_msghdr(DestNode,DestNet,"Frobot Invasion",
  422.          MSGPRIVATE | MSGKILL)) == - 1) {        /* Some kind of error */
  423.             return;
  424.       }
  425.       sprintf(FidoMsgSend,"%s\\%d.msg",Netmdir,msgnum);
  426.       if((fmsg = _fsopen(FidoMsgSend,"ab",SH_DENYWR)) == NULL) {
  427.          sprintf(temp,"Error creating fidonet msg %s",FidoMsgSend);
  428.          aborterror(BADFILE,temp);
  429.       }
  430.       fseek(fmsg,0L,SEEK_END);
  431.       strcpy(msgline,"\rHello, I am attempting to send you the following file(s): \r\r");
  432.       fwrite(msgline,strlen(msgline),1,fmsg);
  433.    }
  434.    else {        /* Re-open it then */
  435.       if((fmsg = _fsopen(FidoMsgSend,"ab",SH_DENYWR)) == NULL) {
  436.          sprintf(temp,"Error creating fidonet msg %s",FidoMsgSend);
  437.          aborterror(BADFILE,temp);
  438.       }
  439.    }
  440.    fseek(fmsg,0L,SEEK_END);
  441.  
  442.  
  443.    sprintf(msgline,"\t%s%s\r",fn,ext);
  444.    fwrite(msgline,strlen(msgline)+1,1,fmsg);        /* Include the NULL! */
  445.    fclose(fmsg);
  446. }
  447.  
  448. void DoFReqMsg(char *filename)
  449. {
  450.    int msgnum;
  451.    FILE *fmsg;
  452.    char msgline[81];
  453.  
  454.    sprintf(msgline,"File %s is requested from %d/%d",filename,DestNet,DestNode);
  455.    logit(msgline,'#');
  456.  
  457.    if (ShowActivity)
  458.       printf("\r%s\n",msgline);
  459.  
  460.    if (!SysopMail)
  461.       return;
  462.  
  463.    ExitCode = 2;
  464.  
  465.    if (FidoMsgReq[0] == 0) {            /* Create a new message */
  466.       if((msgnum = create_msghdr(DestNode,DestNet,"Frobot Invasion",
  467.          MSGPRIVATE | MSGKILL)) == - 1) {        /* Some kind of error */
  468.             return;
  469.       }
  470.       sprintf(FidoMsgReq,"%s\\%d.msg",Netmdir,msgnum);
  471.       if((fmsg = _fsopen(FidoMsgReq,"ab",SH_DENYWR)) == NULL) {
  472.          sprintf(temp,"Error creating fidonet msg %s",FidoMsgReq);
  473.          aborterror(BADFILE,temp);
  474.       }
  475.       fseek(fmsg,0L,SEEK_END);
  476.       strcpy(msgline,"\rHello, I am attempting to request the following file(s): \r\r");
  477.       fwrite(msgline,strlen(msgline),1,fmsg);
  478.    }
  479.    else {        /* Re-open it then */
  480.       if((fmsg = _fsopen(FidoMsgReq,"ab",SH_DENYWR)) == NULL) {
  481.          sprintf(temp,"Error creating fidonet msg %s",FidoMsgReq);
  482.          aborterror(BADFILE,temp);
  483.       }
  484.    }
  485.    fseek(fmsg,0L,SEEK_END);
  486.    if (strchr(filename,'.') == NULL)
  487.       sprintf(msgline,"\t'%s'  <- Magic Filename\r",filename);
  488.    else sprintf(msgline,"\t%s\r",filename);
  489.    fwrite(msgline,strlen(msgline)+1,1,fmsg);        /* Include the NULL! */
  490.    fclose(fmsg);
  491. }
  492.  
  493. void DoNoteMsg(char *filename)
  494. {
  495.    int msgnum;
  496.    FILE *fmsg;
  497.    char msgline[81];
  498.  
  499.  
  500.    sprintf(msgline,"File %s has been received",filename);
  501.    if (ShowActivity) 
  502.       printf("\r%s\n",msgline);
  503.  
  504.    logit(msgline,'#');
  505.  
  506.    if (!SelfMail)
  507.       return;
  508.  
  509.    if (FidoMsgNote[0] == 0) {            /* Create a new message */
  510.       if((msgnum = create_msghdr(Node,Net,"Files Received",
  511.          MSGPRIVATE)) == - 1) {    /* Some kind of error */
  512.             return;
  513.       }
  514.       sprintf(FidoMsgNote,"%s\\%d.msg",Netmdir,msgnum);
  515.       if((fmsg = _fsopen(FidoMsgNote,"ab",SH_DENYWR)) == NULL) {
  516.          sprintf(temp,"Error creating fidonet msg %s",FidoMsgNote);
  517.          aborterror(BADFILE,temp);
  518.       }
  519.       fseek(fmsg,0L,SEEK_END);
  520.       strcpy(msgline,"\rHello, you have received the following file(s): \r\r");
  521.       fwrite(msgline,strlen(msgline),1,fmsg);
  522.    }
  523.    else {        /* Re-open it then */
  524.       if((fmsg = _fsopen(FidoMsgNote,"ab",SH_DENYWR)) == NULL) {
  525.          sprintf(temp,"Error creating fidonet msg %s",FidoMsgNote);
  526.          aborterror(BADFILE,temp);
  527.       }
  528.    }
  529.    fseek(fmsg,0L,SEEK_END);
  530.    sprintf(msgline,"\t%s\r",filename);
  531.    fwrite(msgline,strlen(msgline)+1,1,fmsg);        /* Include the NULL! */
  532.    fclose(fmsg);
  533. }
  534.  
  535. /* Create a fidonet msg header. Return msg # or -1 if error */
  536. int create_msghdr(int destnode,int destnet,char *subject,unsigned attribute)
  537. {
  538.    int x;
  539.    FILE *fmsg;
  540.    struct _msg *FidoMsgHead;
  541.  
  542.    strcpy(temp2,Netmdir);
  543.    strcat(temp2,"\\");
  544.    x = find_fidohigh(temp2);
  545.    if (x == -1)
  546.       return x;
  547.    x++;
  548.  
  549.    sprintf(temp2,"%s\\%d.msg",Netmdir,x);
  550.  
  551.    if((fmsg = _fsopen(temp2,"wb",SH_DENYWR)) == NULL) {
  552.       sprintf(temp,"Error creating fidonet msg %s",temp2);
  553.       aborterror(BADFILE,temp);
  554.    }
  555.  
  556.    FidoMsgHead = (struct _msg *) calloc(1,sizeof(struct _msg));
  557.    if (FidoMsgHead == NULL)
  558.       aborterror(NOMEM,NULL);
  559.  
  560.  
  561. /* message header starts out all 0'ed */
  562.  
  563.    sprintf(FidoMsgHead->from,"Frobot Version %2.02f",Version);
  564.    strcpy(FidoMsgHead->to,"Sysop");
  565.    strcpy(FidoMsgHead->subj,subject);
  566.    FidoMsgHead->attr = attribute;
  567.    FidoMsgHead->orig_net = (sword) Net;
  568.    FidoMsgHead->orig = (sword) Node;
  569.    FidoMsgHead->dest = (sword) destnode;
  570.    FidoMsgHead->dest_net = (sword) destnet;
  571.  
  572.    FidoMsgHead->date_written.date.da = FidoMsgHead->date_arrived.date.da = ltime->tm_mday;
  573.    FidoMsgHead->date_written.date.mo = FidoMsgHead->date_arrived.date.mo = ltime->tm_mon+1;
  574.    FidoMsgHead->date_written.date.yr = FidoMsgHead->date_arrived.date.yr = ltime->tm_year-80;
  575.    FidoMsgHead->date_written.time.hh = FidoMsgHead->date_arrived.time.hh = ltime->tm_hour;
  576.    FidoMsgHead->date_written.time.mm = FidoMsgHead->date_arrived.time.mm = ltime->tm_min;
  577.    FidoMsgHead->date_written.time.ss = FidoMsgHead->date_arrived.time.ss = ltime->tm_sec >> 1;
  578.  
  579.    fwrite(FidoMsgHead,sizeof(struct _msg),1,fmsg);
  580.    fclose(fmsg);
  581.    free(FidoMsgHead);
  582.    return(x);
  583. }
  584.  
  585. /* Return the highest message in an area. -1 if error
  586.    msgpath:  DOS path for messages (has a trailing \)  */
  587.  
  588. int find_fidohigh(char *msgpath)
  589. {
  590.    register    int  done,highest=0;
  591.    int      h;
  592.    struct  find_t  c_file;
  593.    char    apath[66];
  594.  
  595.    sprintf(apath,"%s*.MSG",msgpath);
  596.    done = _dos_findfirst(apath,_A_NORMAL,&c_file);
  597.    if (done)  {
  598.       /* Invalid Path and/or empty directory!! */
  599. /* We should test for a sub-directory first before assuming things */
  600.       strcpy(apath,msgpath);
  601.       h = strlen(apath);
  602.       apath[h-1] = 0;        /* Strip trailing '\' */
  603.       if (apath[h-2] == ':') {        /* It's just a drive letter! */
  604.          return(0);        /* Assume drive letter is ok! */
  605.       }
  606.       else {        /* Its a subdir */
  607.          done = _dos_findfirst(apath,_A_SUBDIR,&c_file);
  608.          if (done) 
  609.             return(-1);
  610.          else return(0);        /* A real subdir, just no files! */
  611.       }
  612.    }
  613.    while (!done && highest < MAXFMSGS){
  614.       h = atoi(c_file.name);
  615.       if (h>highest) highest=h;
  616.        done=_dos_findnext(&c_file);
  617.    }
  618.    return(highest);
  619. }
  620.  
  621.  
  622.