|
|
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: wclear(win1);
20: for(row = 0;row<11;row++)
21: for(col=1;col<75;col+=15)
22: {
23: wmove(win1,row,col);
24: waddstr(win1,state[(row*5)+(col/15)]);
25: if (((row*5) + (col/15)) == 51)
26: break;
27: }
28: wrefresh(win1);
29:
30: }
31:
32: /* print_mail_states.c
33: *
34: * This will take the 'statename' passed form the calling function,
35: * open the maillist file and print the records that match the statename
36: * to a window in formatted columns, If there are more records that lines
37: * permitted on the window, the user will be prompted to press <return> to
38: * continue on with any following screens of info.
39: */
40:
41: void print_mail_states(win2)
42: WINDOW *win2;
43:
44: {
45: FILE *infp;
46: int x=2;
47:
48:
49: if ((infp=fopen(MAILFILE,"r")) == NULL)
50: {
51: noraw();
52: endwin();
53: printf("Error opening MAIL file for input!\n");
54: exit(1);
55: }
56:
57:
58: /* print column titles */
59:
60: wclear(win2);
61: wmove(win2,0,0);
62: wstandout(win2);
63: waddstr(win2,"Sitename");
64: wmove(win2,0,15);
65: waddstr(win2,"Login:");
66: wmove(win2,0,24);
67: waddstr(win2,"State/Country:");
68:
69: /* if we are looking for a US mailsite, then show a column for
70: * cities
71: */
72:
73: if(strcmp(selection,"NON-US") != 0)
74: {
75: wmove(win2,0,49);
76: waddstr(win2,"City/Other:");
77: }
78: wstandend(win2);
79: wmove(win2,2,0);
80:
81: wrefresh(win2);
82:
83: /* read each record, comparing statename for matches. When a
84: match is found, print the record */
85:
86: while ( fread(&mail_rec,sizeof(struct mail),1,infp) == 1)
87: {
88: if( (strcmp(selection,mail_rec.state)== 0) || ((strcmp(selection,"NON-US")==0) && (strcmp(mail_rec.city,"COUNTRY")==0)))
89:
90: {
91: wmove(win2,x,0);
92: waddstr(win2,mail_rec.site);
93: wmove(win2,x,16);
94: waddstr(win2,mail_rec.login);
95: wmove(win2,x,26);
96: waddstr(win2,mail_rec.state);
97: if(strcmp(selection,"NON-US")!=0)
98: {
99: wmove(win2,x,50);
100: waddstr(win2,mail_rec.city);
101: }
102:
103: /* increment our line counter, if we've filled our screen,
104: * prompt the user to press <return> to continue on reading
105: * any followinf mail entries from the file.
106: */
107: x++;
108: if(x==18)
109: {
110: wmove(win2,x,0);
111: waddstr(win2,"Press <RETURN> for more");
112: wrefresh(win2);
113: while (13 != wgetch(win2));
114: x = 2;
115: wclear(win2);
116:
117: /* reprint the column titles */
118:
119: wmove(win2,0,0);
120: wstandout(win2);
121: waddstr(win2,"Sitename");
122: wmove(win2,0,15);
123: waddstr(win2,"Login:");
124: wmove(win2,0,24);
125: waddstr(win2,"State/Country:");
126:
127: if(strcmp(selection,"NON-US") != 0)
128: {
129: wmove(win2,0,49);
130: waddstr(win2,"City/Other:");
131: }
132: wstandend(win2);
133:
134: wrefresh(win2);
135: }
136: }
137: }
138: fclose(infp);
139:
140: wmove(win2,18,0);
141: wstandout(win2);
142: waddstr(win2,"That's all folks!");
143: wstandend(win2);
144:
145: wmove(win2,19,0);
146: waddstr(win2,"Press <RETURN> to continue..");
147: wrefresh(win2);
148:
149: while(13 != wgetch(win2));
150: wclear(win2);
151:
152: }
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.