Annotation of coherent/d/support/bbsadmin/display_rec.c, revision 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:        if ((infp = fopen(workfile,"r")) == NULL)
        !            22:        {
        !            23:                printf("\007ERROR opening file for input!\n");
        !            24:                exit(1);
        !            25:        }
        !            26: 
        !            27:        fseek(infp,REC_FORMULA, 0l);
        !            28:        fread(&record, sizeof (struct entry),1,infp);
        !            29:        fclose (infp);
        !            30: 
        !            31:        wstandout(win2);
        !            32: 
        !            33:        wmove(win2,NAMEHI);
        !            34:        waddstr(win2,record.filename);
        !            35: 
        !            36:        wmove(win2,DESCHI);
        !            37:        waddstr(win2,record.description);
        !            38: 
        !            39:        wmove(win2,DATEHI);
        !            40:        waddch(win2,record.date[0]);
        !            41:        waddch(win2,record.date[1]);
        !            42:        waddch(win2,'/');
        !            43:        waddch(win2,record.date[2]);
        !            44:        waddch(win2,record.date[3]);
        !            45:        waddch(win2,'/');
        !            46:        waddch(win2,record.date[0]);
        !            47:        waddch(win2,record.date[1]);
        !            48: 
        !            49:        
        !            50:        wmove(win2,SIZEHI);
        !            51:        waddstr(win2,record.filesize);
        !            52: 
        !            53:        if(open_mode != 'd')
        !            54:                {
        !            55:                wmove(win2,PARTHI);
        !            56:                wprintw(win2,"%.2d",record.noparts);
        !            57:                }
        !            58: 
        !            59:        wmove(win2,REQHI);
        !            60:        waddstr(win2,record.requires);
        !            61: 
        !            62:        wmove(win2,NOTEHI);
        !            63:        waddstr(win2,record.notes);
        !            64: 
        !            65:        if(open_mode != 'd')
        !            66:                {
        !            67:                wmove(win2,PATHHI);
        !            68:                waddstr(win2,record.pathname);
        !            69:                }
        !            70: 
        !            71:        wrefresh(win2);
        !            72:        wstandend(win2);
        !            73: 
        !            74: 
        !            75: /* allocate another window as a message area */
        !            76: 
        !            77:        if ( (win3=newwin(2,40,20,0)) == NULL)
        !            78:                {
        !            79:                printf("Memory allocation for win3 failed!\n");
        !            80:                exit(1);
        !            81:                }
        !            82: 
        !            83: /* the following tests for 'd' for delete from command line. If the user
        !            84:  * used a 'd' on the command line, make sure that he/she really wants to
        !            85:  * delete the record, then call the del_reocrd function.
        !            86: */
        !            87:        if(open_mode == 'r')
        !            88:                {
        !            89:                wmove (win3,0,0);
        !            90:                waddstr(win3,"Do you wish to delete this record?");
        !            91:                wmove(win3,1,0);
        !            92:                waddstr(win3, "[y] yes; any other key to abort.");
        !            93:                wrefresh(win3);
        !            94: 
        !            95:                choice = '\0';
        !            96:                while (choice == '\0')
        !            97:                        choice = wgetch(win3);
        !            98: 
        !            99:                if ((choice == 'y') || (choice == 'Y'))
        !           100:                        {
        !           101:                        wclear(win3);
        !           102:                        wmove(win3,0,0);
        !           103:                        waddstr(win3,"working... please wait");
        !           104:                        wrefresh(win3);
        !           105:                        del_rec(win3, row, col, screen_num);
        !           106:                        }
        !           107:                
        !           108:                wclear(win3);
        !           109:                wmove(win3,0,0);
        !           110:                waddstr(win3,"Press RETURN to continue...");
        !           111:                wrefresh(win3);
        !           112:                while(13 != wgetch(win3))
        !           113:                        ;
        !           114:                wclear(win3);
        !           115:                wrefresh(win3);
        !           116:                delwin(win3);
        !           117:                }
        !           118: 
        !           119:        /* we are in download mode, so prompt for the next data screen */
        !           120:        else
        !           121:                {
        !           122:                wclear(win3);
        !           123:                wmove(win3,0,0);
        !           124:                waddstr(win3,"Press <RETURN> for next screen.");
        !           125:                wrefresh(win3); 
        !           126:                while(13 != wgetch(win3))
        !           127:                        ;
        !           128:                wclear(win2);
        !           129:                wmove(win2,1,0);
        !           130:                waddstr(win2,"Size of file is: ");
        !           131:                wmove(win2,1,40);
        !           132:                waddstr(win2,"Number of parts to download: ");
        !           133:                wstandout(win2);
        !           134:                wmove(win2,1,18);
        !           135:                waddstr(win2,record.filesize);
        !           136:                wmove(win2,1,69);
        !           137:                record.noparts = (record.noparts == 0) ? 1 : record.noparts;
        !           138:                wprintw(win2,"%d",record.noparts);
        !           139:                wstandend(win2);
        !           140:                wmove(win2,3,5);
        !           141:                wprintw(win2,"The following commands will be needed to download ");
        !           142:                wstandout(win2);
        !           143:                waddstr(win2,record.filename);
        !           144:                wstandend(win2);
        !           145: 
        !           146:        /* if there is more than one part to download, call a function to generate
        !           147:         * the multiple uucp requests necessary to grab each piece from mwcbbs.
        !           148:        */
        !           149: 
        !           150:                if (record.noparts >1)
        !           151:                        {
        !           152:                        build_uucp(record);
        !           153:                        for (x=0;x<record.noparts;x++)
        !           154:                                {
        !           155: 
        !           156:        /* limit ourselves to 10 displayed commands */
        !           157:                                if (x==10)
        !           158:                                        {
        !           159:                                        wmove(win2,16,0);
        !           160:                                        wprintw(win2,"There are %d more parts to download which do not appear on ths screen.", (record.noparts - x));
        !           161:                                        break;
        !           162:                                        }
        !           163: 
        !           164:                                wmove(win2,5+x,0);
        !           165:                                waddstr(win2,getfiles[x]);
        !           166:                                }
        !           167:                        }
        !           168:                else
        !           169:                        {
        !           170:                        strcpy(getfiles[0],HOST);
        !           171:                        strcat(getfiles[0],record.pathname);
        !           172:                        strcat(getfiles[0],RECEIVER);
        !           173:                        wmove(win2,5,0);
        !           174:                        waddstr(win2,getfiles);
        !           175:                        wrefresh(win2);
        !           176:                        }
        !           177: 
        !           178:                wclear(win3);
        !           179:                wmove(win3,0,0);
        !           180:                waddstr(win3,"Do you wish to download this file?");
        !           181:                wmove(win3,1,0);
        !           182:                waddstr(win3,"[y] yes or any other key to abort.");
        !           183:                wrefresh(win2);
        !           184:                wrefresh(win3);
        !           185:                choice = '\0';
        !           186:                while(choice == '\0')
        !           187:                        choice = wgetch(win3);
        !           188: 
        !           189:                wclear(win3);
        !           190:                wrefresh(win3);
        !           191: 
        !           192:                if(choice == 'y' || choice == 'Y')
        !           193:                        {       
        !           194:                        wclear(win3);
        !           195:                        wmove(win3,0,0);
        !           196:                        waddstr(win3,"Processing requests...");
        !           197:                        wrefresh(win3);
        !           198:                        for(x = 0; x < record.noparts; x++)
        !           199:                                system(getfiles[x]);
        !           200:                        wclear(win3);
        !           201:                        wmove(win3,0,0);
        !           202:                        waddstr(win3,"Press <RETURN> to continue.");
        !           203:                        wrefresh(win3);
        !           204:                        while(13 != wgetch(win3))
        !           205:                                ;
        !           206:                        wclear(win3);
        !           207:                        wrefresh(win3);
        !           208:                        }
        !           209:                }
        !           210:        delwin(win3);
        !           211: }
        !           212: 

unix.superglobalmegacorp.com

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