Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | #include <stdio.h> |
2 | #include <stdlib.h> |
||
3 | |||
4 | int main(int argc, char *argv[]) |
||
5 | { |
||
6 | char *symbol[100]; |
||
7 | int i, j, found, size; |
||
8 | FILE *f; |
||
9 | char buff[20], *profile = "Profile:", *str, c; |
||
10 | |||
11 | if (argc != 2) { |
||
12 | printf("Usage: %s <filename>\n", argv[0]); |
||
13 | exit(-1); |
||
14 | } |
||
15 | |||
16 | f = fopen(argv[1], "r"); |
||
17 | if (f == NULL) { |
||
18 | printf("Input file: %s\n", argv[1]); |
||
19 | perror("error opening file"); |
||
20 | exit(-1); |
||
21 | } |
||
22 | |||
23 | fseek(f, 0, SEEK_END); |
||
24 | size = ftell(f); |
||
25 | printf("File Name: %s\n", argv[1]); |
||
26 | printf("File Size: %d\n", size); |
||
27 | found = 0; |
||
28 | for (i = 0; i < size; i++) { |
||
29 | fseek(f, i, SEEK_SET); |
||
30 | fread(buff, 8, 1, f); |
||
31 | if (memcmp(buff, profile, 8) == 0) { |
||
32 | /* Found!!! */ |
||
33 | str = malloc(20); |
||
34 | symbol[found++] = str; |
||
35 | j = 0; |
||
36 | do { |
||
37 | c = fgetc(f); |
||
38 | if ((j != 0) || (c != 0)) { |
||
39 | str[j] = c; |
||
40 | j++; |
||
41 | } else { |
||
42 | c = 1; |
||
43 | } |
||
44 | } while (c != 0); |
||
45 | } |
||
46 | i++; |
||
47 | } |
||
48 | fclose(f); |
||
49 | |||
50 | printf("%d symbols found:\n", found); |
||
51 | for(i = 0; i < found; i++) { |
||
52 | printf("\t%s\n", symbol[i]); |
||
53 | } |
||
54 | exit(0); |
||
55 | } |