summaryrefslogtreecommitdiffstats
path: root/src/util/profile/test_profile.c
blob: b75c81f705d1dffcd22270d9dca42828d5fa0780 (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
/*
 * test_profile.c --- testing program for the profile routine
 */

#include <stdio.h>
#include <stdlib.h>

#include "profile.h"
#ifndef _MSDOS
#include "com_err.h"
#else

/* Stubs for the error handling routines */
#include "prof_int.h"
void initialize_prof_error_table() {}
void com_err (char *fmt, long err, char *msg) {
    printf (fmt, err, msg);
}
#endif

int main(argc, argv)
    int		argc;
    char	**argv;
{
    profile_t	profile;
    long	retval;
    const char	*filenames[2];
    char	**values, **cpp;
    const char	**names;
    
    filenames[0] = argv[1];
    filenames[1] = 0;

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

    initialize_prof_error_table();
    
    retval = profile_init(filenames, &profile);
    if (retval) {
	com_err(argv[0], retval, "while initializing profile");
	exit(1);
    }
    names = (const char **) argv+2;
    retval = profile_get_values(profile, names, &values);
    if (retval) {
	com_err(argv[0], retval, "while getting values");
	exit(1);
    }
    for (cpp = values; *cpp; cpp++) {
	printf("%s\n", *cpp);
	free(*cpp);
    }
    free(values);
    profile_release(profile);

	return 0;

}