Annotation of coherent/d/support/bbsadmin/add_rec.c, revision 1.1.1.1

1.1       root        1: /* this function will get the input and write it to a file. This will be
                      2:  * used to get input from a formatted window and create a new file entry
                      3:  * in the specified workfile.
                      4: */
                      5: 
                      6: #include <stdio.h>
                      7: #include <curses.h>
                      8: #include "contents.h"
                      9: #include "maillist.h"
                     10: 
                     11: void add_rec(win2, row, col, screen_num)
                     12: WINDOW *win2;
                     13: 
                     14: {
                     15: 
                     16: FILE *infp;
                     17: WINDOW *win3;
                     18: int x;
                     19: char choice;
                     20: 
                     21: 
                     22:        wrefresh(win2);
                     23: 
                     24:        if( (win3=newwin(4,79,20,0)) == NULL )
                     25:        {
                     26:                wclear(win2);
                     27:                wmove(win2,0,0);
                     28:                wstandout(win2);
                     29:                waddstr(win2,"\007Error allocating memory for win3. Press <RETURN>");
                     30:                wrefresh(win2);
                     31:                while('\n' != getch())
                     32:                        ;
                     33:                exit(1);
                     34:        }
                     35: 
                     36:        wclear(win3);
                     37:        wmove(win3,1,1);
                     38:        waddstr(win3,"Enter filename or <RETURN> to exit.");
                     39:        wrefresh(win3);
                     40:        getstring(win2, NAMEHI);
                     41:        strcpy(new_record.filename, workstring);
                     42:        if(strlen(new_record.filename) == 0)
                     43:                return;
                     44: 
                     45:        for(x=strlen(workstring);x < sizeof (new_record.filename) ; x++)
                     46:                new_record.filename[x] = '\0';
                     47: 
                     48: 
                     49:        wclear(win3);
                     50:        wmove(win3,1,1);
                     51:        waddstr(win3,"Describe the uses of this package");
                     52:        wrefresh(win3);
                     53: 
                     54:        getstring(win2, DESCHI);
                     55:        strcpy(new_record.description, workstring);
                     56: 
                     57:        for(x=strlen(workstring);x < sizeof (new_record.description) ; x++)
                     58:                new_record.description[x] = '\0';
                     59: 
                     60: 
                     61: 
                     62:        wclear(win3);
                     63:        wmove(win3,1,1);
                     64:        waddstr(win3,"Enter the date that the file was added or last modified");
                     65:        wmove(win3,2,1);
                     66:        waddstr(win3,"Enter no more than 6 characters");
                     67:        wrefresh(win3);
                     68: 
                     69:        getstring(win2,DATEHI);
                     70:        strcpy(new_record.date, workstring);
                     71:        for(x=strlen(workstring);x < sizeof (new_record.date) ; x++)
                     72:                new_record.date[x] = '\0';
                     73: 
                     74:        wclear(win3);
                     75:        wmove(win3,1,1);
                     76:        waddstr(win3,"Enter the file size in number of bytes");
                     77:        wrefresh(win3);
                     78:        getstring(win2, SIZEHI);
                     79:        strcpy(new_record.filesize, workstring);
                     80:        for(x=strlen(workstring);x < sizeof (new_record.filesize) ; x++)
                     81:                new_record.filesize[x] = '\0';
                     82: 
                     83: 
                     84:        wclear(win3);
                     85:        wmove(win3,3,1);
                     86:        waddstr(win3,"Enter the number of parts that this file is divided into");
                     87:        wrefresh(win3);
                     88:        getstring(win2, PARTHI);
                     89:        new_record.noparts = atoi(workstring);
                     90: 
                     91: 
                     92:        /* if the number of parts is 0 (not a split file), then we can
                     93:         * cat the filename on to the end of the pathname. We can later
                     94:         * test the length of the pathname to determine whether or not
                     95:         * to ask for a pathname, as would be required for a split file.
                     96:        */
                     97: 
                     98: 
                     99:                if(new_record.noparts ==0)
                    100:                {
                    101:                        strcpy(new_record.pathname, PATHNAME);
                    102:                        strcat(new_record.pathname, new_record.filename);
                    103:                        wmove(win2,PATHHI);
                    104:                        wstandout(win2);
                    105:                        waddstr(win2, new_record.pathname);
                    106:                        wstandend(win2);
                    107:                        wrefresh(win2);
                    108:                }
                    109: 
                    110: 
                    111:        wclear(win3);
                    112:        wmove(win3,3,1);
                    113:        waddstr(win3,"Enter the names of any support files required");
                    114:        wrefresh(win3);
                    115:        getstring(win2, REQHI);
                    116: 
                    117:        if(strlen(workstring) == 0 )
                    118:                {
                    119:                wmove(win2, REQHI);
                    120:                wstandout(win2);
                    121:                waddstr(win2,"none");
                    122:                wstandend(win2);
                    123:                wrefresh(win2);
                    124:                strcpy(new_record.requires, "none");
                    125:        }
                    126:        else
                    127:                strcpy(new_record.requires, workstring);
                    128: 
                    129:        for(x=strlen(new_record.requires);x < sizeof (new_record.requires) ; x++)
                    130:                record.requires[x] = '\0';
                    131: 
                    132:        wclear(win3);
                    133:        wmove(win3,3,1);
                    134:        waddstr(win3,"Enter any relevant notes about this file");
                    135:        wrefresh(win3);
                    136:        getstring(win2, NOTEHI);
                    137:        if(strlen(workstring) == 0)
                    138:                {
                    139:                wmove(win2,NOTEHI);
                    140:                wstandout(win2);
                    141:                waddstr(win2,"none");
                    142:                wstandend(win2);
                    143:                wrefresh(win2);
                    144:                strcpy(new_record.notes, "none");
                    145:                }
                    146:        
                    147:        else
                    148:                strcpy(new_record.notes, workstring);
                    149:        for(x=strlen(new_record.notes);x < sizeof (new_record.notes) ; x++)
                    150:                new_record.notes[x] = '\0';
                    151: 
                    152:        /* if there is more than one part to download, or number of
                    153:         * parts is not zero, we need to complete the pathlist.
                    154:        */
                    155:        
                    156:        if(new_record.noparts != 0)
                    157:        {
                    158:                wclear(win3);
                    159:                wmove(win3,3,1);
                    160:                waddstr(win3,"Complete the pathlist to this file.");
                    161:                wrefresh(win3);
                    162:                wmove(win2,PATHHI);
                    163:                wstandout(win2);
                    164:                waddstr(win2, PATHNAME);
                    165:                wstandend(win2);
                    166:                wrefresh(win2);
                    167:                getstring(win2, PATHHI2);
                    168:                strcpy(new_record.pathname, PATHNAME);
                    169:                strcat(new_record.pathname, workstring);
                    170:        }
                    171:        for(x=strlen(new_record.pathname);x < sizeof (new_record.pathname) ; x++)
                    172:                new_record.pathname[x] = '\0';
                    173: 
                    174: 
                    175:        wclear(win3);
                    176:        wmove(win3,0,0);
                    177:        waddstr(win3,"Do you wish to write the record?");
                    178:        wmove(win3,1,0);
                    179:        waddstr(win3,"[y]es or any other to abort.");
                    180:        wrefresh(win3);
                    181:        choice ='\0';
                    182:        while(choice == '\0')
                    183:                choice = wgetch(win3);
                    184: 
                    185:        if(choice == 'y' || choice == 'Y')
                    186:                {
                    187:                wclear(win3);
                    188:                wmove(win3,0,0);
                    189:                waddstr(win3,"Updating...");
                    190:                wrefresh(win3);
                    191:                del_rec(win3,row,col,screen_num);
                    192:                }
                    193: 
                    194:        delwin(win3);
                    195: 
                    196: }
                    197: 
                    198: 
                    199: /* this function will get a string and print to the approp field 
                    200:  * on win2. This is called by add_rec.
                    201: */
                    202: 
                    203: void getstring (win2, row, col)
                    204: 
                    205: WINDOW *win2;
                    206: int row, col;
                    207: 
                    208: {
                    209: 
                    210: 
                    211:        noraw();
                    212:        echo();
                    213:        wmove(win2,row,col);
                    214:        wrefresh(win2);
                    215:        wgetstr(win2,workstring);
                    216:        wstandout(win2);
                    217:        wmove(win2,row,col);
                    218:        wprintw(win2,"%s",workstring);
                    219:        wstandend(win2);
                    220:        wrefresh(win2);
                    221:        noecho();
                    222:        raw();
                    223: }

unix.superglobalmegacorp.com

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