Annotation of coherent/a/usr/bob/test/mwcbbs/bbsdatafile.c, revision 1.1

1.1     ! root        1: #define TRACE          printf
        !             2: #define DATAFILE       ".mwcbbs"
        !             3: 
        !             4: #include <stdio.h>
        !             5: #include "contents.h"
        !             6: 
        !             7: void bbsdatafile()
        !             8: {
        !             9: int x,y;
        !            10: char read_data[57];
        !            11: char newpath[10];
        !            12: char specpath[46];
        !            13: FILE *datafile;
        !            14: 
        !            15:        if( (datafile=fopen(DATAFILE,"r")) != NULL){
        !            16: 
        !            17:                /* read a line from the file and read the
        !            18:                 * first set of characters into a string. These
        !            19:                 * characters should be upper case only and we
        !            20:                 * will stop reading them when we hit an '=' sign.
        !            21:                */
        !            22: 
        !            23:                while (fgets(read_data,70,datafile) != NULL){
        !            24:                        x = 0;
        !            25:                        y = 0;
        !            26:                        while(read_data[x] != '='){
        !            27:                                if((read_data[x] == '\n') || (read_data[x] == '\0')){
        !            28:                                        printf(".mwcbbs: unexpected NEWLINE or NULL in file.\n");
        !            29:                                        exit(1);
        !            30:                                }
        !            31:                                if(isupper(read_data[x]) == 0){
        !            32:                                        printf(".mwcbbs: Expected UPPER CASE character before '='.\n");
        !            33:                                        exit(1);
        !            34:                                }
        !            35:                                newpath[x] = read_data[x];
        !            36:                                x++;
        !            37:                        }
        !            38:                        newpath[x] = '\0';
        !            39:                        x++;
        !            40: 
        !            41:                        /* Since we got this far, we will take the remainder
        !            42:                         * of the line read from .mwcbbs and place that in its
        !            43:                         * own string.
        !            44:                         */
        !            45: 
        !            46:                        while(x < strlen(read_data + 1)){
        !            47:                                specpath[y] = read_data[x];
        !            48:                                x++;
        !            49:                                y++;
        !            50: 
        !            51:                                /* if we are about to excede our pathname limit,
        !            52:                                 * warn the user and exit.
        !            53:                                 */
        !            54: 
        !            55:                                if( y == 45 ){
        !            56:                                        printf(".mwcbbs: WARNING: path for %s excedes 45 character limit!\n",
        !            57:                                                newpath);
        !            58:                                        exit(1);
        !            59:                                }
        !            60:                        }
        !            61:                        if(specpath[y-1] != '/'){
        !            62:                                specpath[y] = '/';
        !            63:                                y++;
        !            64:                        }
        !            65:                        specpath[y] = '\0';
        !            66: 
        !            67:                /* if the download path was specified, copy the pathname
        !            68:                 * to the recdir (receive directory)  variable.
        !            69:                 */
        !            70: 
        !            71:                if (strcmp(newpath,"DOWNPATH") == 0){
        !            72:                        strcpy(recdir," ");
        !            73:                        strcat(recdir,specpath);
        !            74:                }
        !            75:                
        !            76:                /* if the data file path was specifed, copy the pathname
        !            77:                 * to the find_workfile variable.
        !            78:                 */
        !            79: 
        !            80:                if(strcmp(newpath,"DATAPATH") == 0){
        !            81:                        strcpy(find_workfile,specpath);
        !            82:                }
        !            83:                }
        !            84:        fclose(datafile);
        !            85:        }
        !            86:        return ;
        !            87: }

unix.superglobalmegacorp.com

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