Annotation of coherent/d/support/mwcbbs/getflname.c, revision 1.1.1.1

1.1       root        1: /* getfilename() This will print the list of available files to 
                      2:  * stdscr and allow the user to choose one of them for further processing.
                      3: */
                      4: 
                      5: #include <stdio.h>
                      6: #include <curses.h>
                      7: #include "contents.h"
                      8: #include "maillist.h"
                      9: 
                     10: void getfilename()
                     11: {
                     12: int x;
                     13: char tryfile[7][15] = {FILE0,FILE1,FILE2,FILE3,FILE4,FILE5,FILE6};
                     14: 
                     15:        clear();
                     16:        refresh();
                     17:        noecho();
                     18: 
                     19:        /* print our file choices. If printflag is set, then we only print
                     20:         * the first 4 choices, the Contents files, since they are the only
                     21:         * ones that can be printed.
                     22:         */
                     23: 
                     24:        for (x=8;x<15;x++)
                     25:                {
                     26:                if((printflag==1) && (x == 12))
                     27:                        x = 14;
                     28:                move(x,32);
                     29:                printw("%d. %s",(x-8),tryfile[x-8]);
                     30:                }
                     31: 
                     32:        move(23,0);
                     33:        printw("Press the number corresponding to the desired file/option.");
                     34:        refresh();
                     35: 
                     36:        /* while the returned value of getch is less than 0 or greater
                     37:         * than 6, keep getting a keystroke. This is how we will select
                     38:         * our file to use for further operations.
                     39:        */
                     40:        
                     41:        /* if printflag is set, then we test for a more narrow 
                     42:         * range of files since only the Contents files (selections
                     43:         * 0 thru 3) can be printed. Only these filenames should have 
                     44:         * been printed by the function to print selections, anyways.
                     45:        */
                     46: 
                     47:        if(printflag != 1)
                     48:                {
                     49:                x = 0;
                     50:                while( x<48 || x>54 )
                     51:                        x = getch();
                     52:                }
                     53:        else
                     54:                {
                     55:                x = 0;
                     56:                while ( x<48 || x>51 )
                     57:                        {
                     58:                        x = getch();
                     59:                        if (x == 54)
                     60:                                break;
                     61:                        }
                     62:                }
                     63: 
                     64:        /* if option 5 was selected, display a menu of net maps */
                     65: 
                     66:        if( (x-48)==5){
                     67:                get_net_map();
                     68:                return ;
                     69:        }
                     70: 
                     71:        /* if option 6 (QUIT) was selected, copy that to our workfile.
                     72:         * otherwise, we are going to get a real file, so append
                     73:         * the directory path specified in the .mwcbbs file, if one
                     74:         * was specified as DATAPATH.
                     75:         */
                     76: 
                     77:        if ( (x-48) == 6){
                     78:                strcpy(workfile,tryfile[x-48]);
                     79:        }else{
                     80:                strcpy(workfile,find_workfile);
                     81:                strcat(workfile,tryfile[x-48]);
                     82:        }
                     83: 
                     84:        echo(); 
                     85:        if (strcmp(workfile,"QUIT")!= 0)
                     86:                {
                     87:                move(23,0);
                     88:                printw("Reading file %s ...",workfile);
                     89:                clrtoeol();
                     90:                refresh();
                     91:                }
                     92:        clear();
                     93:        refresh();
                     94: }
                     95: 
                     96: 
                     97: void get_net_map()
                     98: 
                     99: {
                    100: int x;
                    101: char choice;
                    102: 
                    103:        clear();
                    104:        
                    105: 
                    106: 
                    107:        for (x=11;x<15;x++)
                    108:                {
                    109:                move(x,32);
                    110:                printw("%d. %s",(x-11),mapfile[x-11]);
                    111:                }
                    112:        move(23,0);
                    113:        printw("Press the number of the map file to read.");
                    114:        refresh();
                    115: 
                    116:        choice = 0;
                    117:        while( (choice > 51) || (choice <48) )
                    118:                choice = getch();
                    119: 
                    120:        if ( (choice-48) == 3){
                    121:                strcpy(workfile,mapfile[choice-48]);
                    122:        }else{
                    123:                strcpy(workfile,find_workfile);
                    124:                strcat(workfile,mapfile[choice-48]);
                    125:        }
                    126: 
                    127: 
                    128: }

unix.superglobalmegacorp.com

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