1 #include <stdio.h>
2 #include <string.h>
3 #define VERBOSE 1
4
5 static int csfputs(const char *s, void *stream)
6 {
7 #if VERBOSE
8 fprintf(stderr,"csfputs:%s\n",s);
9 #endif
10 return fputs(s, (FILE *)stream);
11 }
12
13 static void *csfopenappend(const char *path)
14 {
15 #if VERBOSE
16 fprintf(stderr,"csfopenappend:%s\n",path);
17 #endif
18 return (void*)fopen(path,"a+");
19 }
20
21 static void *csfopenread(const char *path)
22 {
23 #if VERBOSE
24 fprintf(stderr,"csfopenread:%s\n",path);
25 #endif
26 return (void*)fopen(path,"r");
27 }
28
29 static void *csfopenwrite(const char *path)
30 {
31 #if VERBOSE
32 fprintf(stderr,"csfopenwrite:%s\n",path);
33 #endif
34 return (void*)fopen(path,"w");
35 }
36
37 static char *csfgets(char *s, int size, void *stream)
38 {
39 char * ret;
40 ret = fgets(s, size, (FILE *)stream);
41 #if VERBOSE
42 fprintf(stderr,"csfgets:%s\n",s);
43 #endif
44 return ret;
45 }
46
47 static int csremove(const char *filename)
48 {
49 #if VERBOSE
50 fprintf(stderr,"csremove:%s\n",filename);
51 #endif
52 return remove(filename);
53 }
54
55 static int csfclose(void *fp)
56 {
57 #if VERBOSE
58 fprintf(stderr,"csfclose\n");
59 #endif
60 return fclose((FILE*)fp);
61 }
62
63 int main()
64 {
65 char location[256];
66 int lg_location;
67
68 printf(".csexe file name (without extension}:"); fflush(stdout);
69 fgets(location,sizeof(location),stdin);
70 lg_location=strlen(location);
71 if (lg_location)
72 location[lg_location-1]='\0'; // strip \n
73 #ifdef __COVERAGESCANNER__
74 __coveragescanner_set_custom_io( csfgets,
75 csfputs,
76 csfopenappend,
77 csfopenread,
78 csfopenwrite,
79 csfclose,
80 csremove);
81 __coveragescanner_install(location);
82 #endif
83 }