Subversion Repositories shark

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1063 tullio 1
 
2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 *
17
 */
18
 
2 pj 19
#include <stdio.h>
20
#include <stdlib.h>
21
 
22
int main(int argc, char *argv[])
23
{
24
  char *symbol[100];
25
  int i, j, found, size;
26
  FILE *f;
27
  char buff[20], *profile = "Profile:", *str, c;
28
 
29
  if (argc != 2) {
30
    printf("Usage: %s <filename>\n", argv[0]);
31
    exit(-1);
32
  }
33
 
34
  f = fopen(argv[1], "r");
35
  if (f == NULL) {
36
    printf("Input file: %s\n", argv[1]);
37
    perror("error opening file");
38
    exit(-1);
39
  }
40
 
41
  fseek(f, 0, SEEK_END);
42
  size = ftell(f);
43
  printf("File Name: %s\n", argv[1]);
44
  printf("File Size: %d\n", size);
45
  found = 0;
46
  for (i = 0; i < size; i++) {
47
    fseek(f, i, SEEK_SET);
48
    fread(buff, 8, 1, f);
49
    if (memcmp(buff, profile, 8) == 0) {
50
      /* Found!!! */
51
      str = malloc(20);
52
      symbol[found++] = str;
53
      j = 0;
54
      do {
55
        c = fgetc(f);
56
        if ((j != 0) || (c != 0)) {
57
          str[j] = c;
58
          j++;
59
        } else {
60
          c = 1;
61
        }
62
      } while (c != 0);
63
    }
64
    i++;
65
  }
66
  fclose(f);
67
 
68
  printf("%d symbols found:\n", found);
69
  for(i = 0; i < found; i++) {
70
    printf("\t%s\n", symbol[i]);
71
  }
72
  exit(0);
73
}