summaryrefslogtreecommitdiffstats
path: root/src/util/profile/test_parse.c
blob: 7fd86e9127de25cea23e26c58d9c73e3afe12cf3 (plain)
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
#include <stdio.h>
#include <string.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <errno.h>
#include <ctype.h>

#include "prof_int.h"

#if !defined(_MSDOS) && !defined(_MACINTOSH)
#include "com_err.h"
#else

#define initialize_prof_error_table()
char *error_message (long err) {
	static char buf[50];

	sprintf (buf, " 0x%lX (%ld)", err, err);
	return buf;
}
#endif

void dump_profile PROTOTYPE((struct profile_node *root, int level));

int main(argc, argv)
	int	argc;
	char	**argv;
{
	struct profile_node *root;
	unsigned long retval;
	FILE *f;

	initialize_prof_error_table();
	if (argc != 2) {
		fprintf(stderr, "%s: Usage <filename>\n", argv[0]);
		exit(1);
	}

	f = fopen(argv[1], "r");
	if (!f) {
		perror(argv[1]);
		exit(1);
	}

	retval = profile_parse_file(f, &root);
	if (retval) {
		printf("profile_parse_file error %s\n", error_message(retval));
		return 0;
	}
	fclose(f);
	
	printf("\n\nDebugging dump.\n");
#if 0
	dump_profile(root, 0);
#else
	dump_profile_to_file(root, 0, stdout);
#endif

	profile_free_node(root);

	return 0;
}