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
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
int main(){
printf("%s%c%c\n",
"Content-Type:text/html;charset=iso-8859-1",13,10);
FILE* lastfilenum;
lastfilenum = fopen("../ws2a/bugs/lastbug","r");
if(lastfilenum == NULL){
printf("Error reteriveing bugs, contact the admin!");
return 1;
}
long long last = 0;
fscanf(lastfilenum,"%lld",&last);
fclose(lastfilenum);
long long end = last-20;
while(last > end && last > 0){
char filestring[64] = "../ws2a/bugs/";
char filename[10];
sprintf(filename,"%lld",last);
strcat(filestring,filename);
FILE* thisbug;
thisbug = fopen(filestring,"r");
if(thisbug == NULL){
printf("Error opening bug:%s\n",filestring);
printf("<br/>");
last--;
continue;
}
printbug(thisbug);
printf("%lld\n",last);
fclose(thisbug);
last--;
}
return 0;
}
/*Prints bugs, format:
Submitter\n
SubmitterID
Date_submitted\n
Short Description\n
Status<Unassigned, Assigned, Closed>\n
numcomments\n
bugid
*/
void printbug(FILE* f){
int line = 0;
char tchar = ' ';
while((tchar = fgetc(f)) && tchar != EOF){
if(tchar == '\n')
line++;
if(line > 4)
break;
putchar(tchar);
}
unsigned int comments = 0;
while (EOF != (fscanf(f,"%*[^\n]"), fscanf(f,"%*c")))
++comments;
printf("\n%u\n",(comments-1)/4);
}
/*
function htmlEscape(str) {
return String(str)
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/\//g, '/');
}
*/
|