xref: /freebsd/crypto/krb5/src/util/profile/test_parse.c (revision b670c9bafc0e31c7609969bf374b2e80bdc00211)
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 #include "prof_int.h"
3 
4 #include <stdio.h>
5 #include <string.h>
6 #ifdef HAVE_STDLIB_H
7 #include <stdlib.h>
8 #endif
9 #include <errno.h>
10 #include <ctype.h>
11 
12 void dump_profile (struct profile_node *root, int level);
13 
14 int main(argc, argv)
15     int     argc;
16     char    **argv;
17 {
18     struct profile_node *root;
19     unsigned long retval;
20     FILE *f;
21 
22     initialize_prof_error_table();
23     if (argc != 2) {
24         fprintf(stderr, "%s: Usage <filename>\n", argv[0]);
25         exit(1);
26     }
27 
28     f = fopen(argv[1], "r");
29     if (!f) {
30         perror(argv[1]);
31         exit(1);
32     }
33 
34     retval = profile_parse_file(f, &root, NULL);
35     if (retval) {
36         printf("profile_parse_file error %s\n",
37                error_message((errcode_t) retval));
38         exit(1);
39     }
40     fclose(f);
41 
42     printf("\n\nDebugging dump.\n");
43     profile_write_tree_file(root, stdout);
44 
45     retval = profile_verify_node(root);
46     if (retval) {
47         printf("profile_verify_node reported an error: %s\n",
48                error_message((errcode_t) retval));
49         exit(1);
50     }
51 
52     profile_free_node(root);
53 
54     return 0;
55 }
56