Annotation of coherent/a/usr/bob/test/mwcbbs/disp_rec.c, revision 1.1.1.1

1.1       root        1: /* this function will open the file and read the appropriate record,
                      2:  * then display it on the window in the approp. positions.
                      3: */
                      4: 
                      5: #include <stdio.h>
                      6: #include <curses.h>
                      7: #include "contents.h"
                      8: 
                      9: 
                     10: 
                     11: void display_record (win2, row, col, screen_num)
                     12: WINDOW *win2;
                     13: int row, col, screen_num;
                     14: 
                     15: {
                     16: WINDOW *win3;
                     17: char choice;
                     18: FILE *infp;
                     19: int x;
                     20: 
                     21: 
                     22:        if ((infp = fopen(workfile,"r")) == NULL)
                     23:                {
                     24:                printf("\007ERROR opening file for input!\n");
                     25:                exit(1);
                     26:                }
                     27: 
                     28:        fseek(infp,REC_FORMULA, 0l);
                     29:        fread(&record, sizeof (struct entry),1,infp);
                     30:        fclose (infp);
                     31: 
                     32:        wstandout(win2);
                     33: 
                     34:        wmove(win2,NAMEHI);
                     35:        waddstr(win2,record.filename);
                     36: 
                     37:        wmove(win2,DESCHI);
                     38:        waddstr(win2,record.description);
                     39: 
                     40:        wmove(win2,DATEHI);
                     41:        waddch(win2,record.date[0]);
                     42:        waddch(win2,record.date[1]);
                     43:        waddch(win2,'/');
                     44:        waddch(win2,record.date[2]);
                     45:        waddch(win2,record.date[3]);
                     46:        waddch(win2,'/');
                     47:        waddch(win2,record.date[4]);
                     48:        waddch(win2,record.date[5]);
                     49: 
                     50:        
                     51:        wmove(win2,SIZEHI);
                     52:        waddstr(win2,record.filesize);
                     53: 
                     54:        wmove(win2,REQHI);
                     55:        waddstr(win2,record.requires);
                     56: 
                     57:        wmove(win2,NOTEHI);
                     58:        waddstr(win2,record.notes);
                     59: 
                     60:        wrefresh(win2);
                     61:        wstandend(win2);
                     62: 
                     63: 
                     64: /* allocate another window as a message area */
                     65: 
                     66:        if ( (win3=newwin(2,40,20,0)) == NULL)
                     67:                {
                     68:                noraw();
                     69:                endwin();
                     70:                printf("Memory allocation for win3 failed!\n");
                     71:                exit(1);
                     72:                }
                     73: 
                     74:        wclear(win3);
                     75:        wmove(win3,0,0);
                     76:        waddstr(win3,"Press <RETURN> for next screen.");
                     77:        wrefresh(win3); 
                     78:        while(13 != wgetch(win3))
                     79:                ;
                     80:        wclear(win2);
                     81:        wmove(win2,1,0);
                     82:        waddstr(win2,"Size of file is: ");
                     83:        wmove(win2,1,40);
                     84:        waddstr(win2,"Number of parts to download: ");
                     85:        wstandout(win2);
                     86:        wmove(win2,1,18);
                     87:        waddstr(win2,record.filesize);
                     88:        wmove(win2,1,69);
                     89:        record.noparts = (record.noparts == 0) ? 1 : record.noparts;
                     90:        wprintw(win2,"%d",record.noparts);
                     91:        wstandend(win2);
                     92:        wmove(win2,3,5);
                     93:        wprintw(win2,"The following commands will be needed to download ");
                     94:        wstandout(win2);
                     95:        waddstr(win2,record.filename);
                     96:        wstandend(win2);
                     97: 
                     98: /* if there is more than one part to download, call a function to generate
                     99:  * the multiple uucp requests necessary to grab each piece from mwcbbs.
                    100: */
                    101: 
                    102:        if (record.noparts >1)
                    103:                {
                    104:                build_uucp(record);
                    105:                for (x=0;x<record.noparts;x++)
                    106:                        {
                    107: 
                    108:        /* limit ourselves to 10 displayed commands */
                    109:                        if (x==10)
                    110:                                {
                    111:                                wmove(win2,16,0);
                    112:                                wprintw(win2,"There are %d more parts to download which do not appear on ths screen.", (record.noparts - x));
                    113:                                break;
                    114:                                }
                    115: 
                    116:                        wmove(win2,5+x,0);
                    117:                        waddstr(win2,getfiles[x]);
                    118:                        }
                    119:                }
                    120:        else
                    121:                {
                    122:                strcpy(getfiles[0],HOST);
                    123:                strcat(getfiles[0],record.pathname);
                    124:                strcat(getfiles[0],recdir);
                    125:                wmove(win2,5,0);
                    126:                waddstr(win2,getfiles);
                    127:                wrefresh(win2);
                    128:                }
                    129:        wclear(win3);
                    130:        wmove(win3,0,0);
                    131:        waddstr(win3,"Do you wish to download this file?");
                    132:        wmove(win3,1,0);
                    133:        waddstr(win3,"[y] yes or any other key to abort.");
                    134:        wrefresh(win2);
                    135:        wrefresh(win3);
                    136:        choice = '\0';
                    137:        while(choice == '\0')
                    138:                choice = wgetch(win3);
                    139: 
                    140:        wclear(win3);
                    141:        wrefresh(win3);
                    142: 
                    143:        if(choice == 'y' || choice == 'Y')
                    144:                {       
                    145:                wclear(win3);
                    146:                wmove(win3,0,0);
                    147:                waddstr(win3,"Processing requests...");
                    148:                wrefresh(win3);
                    149: 
                    150:                for(x = 0; x < record.noparts; x++)
                    151:                        system(getfiles[x]);
                    152:                }
                    153: 
                    154:        wclear(win3);
                    155:        wmove(win3,0,0);
                    156:        waddstr(win3,"Press <RETURN> to continue.");
                    157:        wrefresh(win3);
                    158:        while(13 != wgetch(win3))
                    159:                ;
                    160: 
                    161:        wclear(win3);
                    162:        wrefresh(win3);
                    163: 
                    164:        delwin(win3);
                    165: }
                    166: 

unix.superglobalmegacorp.com

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