-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcw_filename.c
50 lines (40 loc) · 850 Bytes
/
gcw_filename.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
// GCW: gcw_filename.c
#include <stdio.h>
#include <string.h>
#include "gcw.h"
int main(int argc, char *argv[])
{
FILE *inf;
char wbuf[256];
char *c;
inf = fopen(argv[1],"r");
if ( inf ) {
// skip this
// -----BEGIN PGP SIGNED MESSAGE-----
// Hash: SHA1
//
fgets(wbuf,sizeof(wbuf),inf);
fgets(wbuf,sizeof(wbuf),inf);
fgets(wbuf,sizeof(wbuf),inf);
// get this - // GCW: filename
fgets(wbuf,sizeof(wbuf),inf);
// get rid of \n if present
c = strchr(wbuf,'\n');
if ( c ) *c = 0;
// is this us??
c = strstr(wbuf,FIND_STRING);
if ( !c ) {
// no, just get out
printf("unknown");
goto finis;
}
// extract file name
c += strlen(FIND_STRING);
printf("%s",c);
} else {
printf("unknown");
}
finis:;
if ( inf ) close(inf);
return 0;
}