-
Notifications
You must be signed in to change notification settings - Fork 0
/
individualBreakdown.c
95 lines (89 loc) · 2.92 KB
/
individualBreakdown.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
Copyright (C) 2017 Riley Baird <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
void individualBreakdown(FILE *webpage, int * parties, char (*partynames)[100], int ayes[1000], int noes[1000], char (*politicians)[100], char (*fullnames)[100], char (*electorates)[100], int isCouncil, char summary[500], uLong adler, char * ymddate) {
fputs("\n\t<div id=\"individuals\"><p><u>Breakdown by party</u></p>", webpage);
int party = 1;
while ((party <= 88) && (partynames[party] != 0x00)) {
fputs(partynames[party], webpage);
fputs("\n\t<ul>", webpage);
int pos = 1;
while (pos <= 88) {
if (parties[pos] == party) {
fputs("\n\t\t<li>\n\t\t\t<a href=\"../../members/", webpage);
fputs(fullnames[pos], webpage);
fputs(".html\">", webpage);
fputs(fullnames[pos], webpage);
fputs("</a> (<a href=\"https://en.wikipedia.org/wiki/", webpage);
if (isCouncil == 1) {
fputs(electorates[pos], webpage);
fputs(" Region", webpage);
}
else {
fputs("Electoral district of ", webpage);
fputs(electorates[pos], webpage);
}
fputs("\">", webpage);
fputs(electorates[pos], webpage);
fputs("</a>): ", webpage);
int i = 1;
int vote = 0;
while (i <= 999) {
if (ayes[i] == pos)
vote = 1;
else if (noes[i] == pos)
vote = -1;
i++;
}
if (vote == 1) {
fputs("Yes", webpage);
}
else if (vote == -1) {
fputs("No", webpage);
}
else if (vote == 0) {
fputs("Absent", webpage);
}
fputs("</li>", webpage);
if (summary[0] != 0) {
FILE *member;
char filename[100] = {0};
sprintf(filename, "../../members/%s.html", fullnames[pos]);
member = fopen(filename, "a");
fputs("\n\t\t<li>", member);
fputs("<a href=\"../divisions/", member);
fputs(ymddate, member);
fputs("/", member);
char stradler[100] = {0};
sprintf(stradler, "%7x.html", adler);
fputs(stradler, member);
fputs("\">", member);
fputs(summary, member);
fputs("</a>: ", member);
if (vote == 1)
fputs("Yes", member);
else if (vote == -1)
fputs("No", member);
else
fputs("Absent", member);
fputs("</li>\n", member);
fclose(member);
}
}
pos++;
}
fputs("\n\t</ul>", webpage);
party++;
}
fputs("</div>",webpage);
}