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

1.1       root        1: 
                      2: /* this function will print the names of the 50 states and two other options
                      3:  * to a window which is sized the same as a filename listing from a Contents
                      4:  * file. The matching size is for continuity only AND there's too damn many
                      5:  * windows to track at his point anyways.
                      6: */
                      7: 
                      8: #include <stdio.h>
                      9: #include <curses.h>
                     10: #include "contents.h"
                     11: #include "maillist.h"
                     12: 
                     13: void print_states(win1)
                     14: WINDOW *win1;
                     15: 
                     16: {
                     17: int row, col;
                     18: 
                     19: 
                     20:        wclear(win1);
                     21:        for(row = 0;row<11;row++)
                     22:                for(col=1;col<75;col+=15)
                     23:                        {
                     24:                        wmove(win1,row,col);
                     25:                        waddstr(win1,state[(row*5)+(col/15)]);
                     26:                        if (((row*5) + (col/15)) == 51)
                     27:                                break;
                     28:                        }
                     29:        wrefresh(win1);
                     30:        
                     31: }
                     32: 
                     33: /* print_mail_states.c
                     34:  *
                     35:  * This will take the 'statename' passed form the calling function,
                     36:  * open the maillist file and print the records that match the statename
                     37:  * to a window in formatted columns, If there are more records that lines
                     38:  * permitted on the window, the user will be prompted to press <return> to 
                     39:  * continue on with any following screens of info.
                     40: */
                     41: 
                     42: void print_mail_states(win2)
                     43: WINDOW *win2;
                     44: 
                     45: {
                     46: FILE *infp;
                     47: int x=2;
                     48: int y=0;
                     49: 
                     50:        if ((infp=fopen(workfile,"r")) == NULL)
                     51:                {
                     52:                noraw();
                     53:                endwin();
                     54:                printf("Error opening %s for input!\n", workfile);
                     55:                exit(1);
                     56:                }
                     57: 
                     58: 
                     59:        /* print column titles */
                     60: 
                     61:        wclear(win2);
                     62:        wmove(win2,0,0);
                     63:        wstandout(win2);
                     64:        waddstr(win2,"Sitename");
                     65:        wmove(win2,0,15);
                     66:        waddstr(win2,"Login:");
                     67:        wmove(win2,0,24);
                     68:        waddstr(win2,"State/Country:");
                     69: 
                     70:        /* if we are looking for a US mailsite, then show a column for
                     71:         * cities
                     72:        */
                     73: 
                     74:        if(strcmp(selection,"NON-US") != 0)
                     75:                {
                     76:                wmove(win2,0,49);
                     77:                waddstr(win2,"City/Other:");
                     78:                }
                     79:        wstandend(win2);
                     80:        wmove(win2,2,0);
                     81: 
                     82:        wrefresh(win2);
                     83: 
                     84:        /* read each record, comparing statename for matches. When a 
                     85:          match is found, print the record */
                     86: 
                     87:        while ( fread(&mail_rec,sizeof(struct mail),1,infp) == 1)
                     88:                {
                     89:                if( (strcmp(selection,mail_rec.state)== 0) || ((strcmp(selection,"NON-US")==0) && (strcmp(mail_rec.city,"COUNTRY")==0)))
                     90: 
                     91:                        {
                     92:                        y++;
                     93:                        wmove(win2,x,0);
                     94:                        waddstr(win2,mail_rec.site);
                     95:                        wmove(win2,x,16);
                     96:                        waddstr(win2,mail_rec.login);
                     97:                        wmove(win2,x,26);
                     98:                        waddstr(win2,mail_rec.state);
                     99:                        if(strcmp(selection,"NON-US")!=0)
                    100:                                {
                    101:                                wmove(win2,x,50);
                    102:                                waddstr(win2,mail_rec.city);
                    103:                                }
                    104: 
                    105:        /* increment our line counter, if we've filled our screen,
                    106:         * prompt the user to press <return> to continue on reading
                    107:         * any followinf mail entries from the file.
                    108:        */
                    109:                        x++;
                    110:                        if(x==18)
                    111:                                {
                    112:                                wmove(win2,x,0);
                    113:                                waddstr(win2,"Press <RETURN> for more");
                    114:                                wrefresh(win2);
                    115:                                while (13 != wgetch(win2));
                    116:                                x = 2;
                    117:                                wclear(win2);
                    118: 
                    119:                /* reprint the column titles */
                    120: 
                    121:                                wmove(win2,0,0);
                    122:                                wstandout(win2);
                    123:                                waddstr(win2,"Sitename");
                    124:                                wmove(win2,0,15);
                    125:                                waddstr(win2,"Login:");
                    126:                                wmove(win2,0,24);
                    127:                                waddstr(win2,"State/Country:");
                    128: 
                    129:                                if(strcmp(selection,"NON-US") != 0)
                    130:                                        {
                    131:                                        wmove(win2,0,49);
                    132:                                        waddstr(win2,"City/Other:");
                    133:                                        }
                    134:                                wstandend(win2);
                    135: 
                    136:                                wrefresh(win2);
                    137:                                }
                    138:                        }
                    139:                }
                    140:                fclose(infp);
                    141: 
                    142:                wmove(win2,18,0);
                    143:                wstandout(win2);
                    144:        
                    145: 
                    146:                /* the variable 'y' was used as a counter in the read/print
                    147:                 * loop. If y = 0, the no matches were found and an approp.
                    148:                 * message to this affect will be printed.
                    149:                */
                    150:        
                    151:                if(y==0)
                    152:                        waddstr(win2,"A place not yet heard from!");
                    153:                else
                    154:                        waddstr(win2,"That's all folks!");
                    155: 
                    156:                wstandend(win2);
                    157:                wmove(win2,19,0);
                    158:                waddstr(win2,"Press <RETURN> to continue..");           
                    159:                wrefresh(win2);
                    160: 
                    161:                while(13 != wgetch(win2));
                    162:                wclear(win2);
                    163: 
                    164: }
                    165: 
                    166: 
                    167: 
                    168: 
                    169: 
                    170: 
                    171: 
                    172: 
                    173: 
                    174: 

unix.superglobalmegacorp.com

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