1 /*
2 * Author: Joshua Brindle <jbrindle@tresys.com>
3 *
4 * Copyright (C) 2006 Tresys Technology, LLC
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /* This includes functions used to debug tests (display bitmaps, conditional expressions, etc */
22
23 #include "debug.h"
24
25 #include <stdlib.h>
26
print_ebitmap(ebitmap_t * bitmap,FILE * fp)27 void print_ebitmap(ebitmap_t * bitmap, FILE * fp)
28 {
29 uint32_t i;
30 for (i = 0; i < bitmap->highbit; i++) {
31 fprintf(fp, "%d", ebitmap_get_bit(bitmap, i));
32 }
33 fprintf(fp, "\n");
34 }
35
36 /* stolen from dispol.c */
display_expr(policydb_t * p,cond_expr_t * exp,FILE * fp)37 void display_expr(policydb_t * p, cond_expr_t * exp, FILE * fp)
38 {
39
40 cond_expr_t *cur;
41 for (cur = exp; cur != NULL; cur = cur->next) {
42 switch (cur->expr_type) {
43 case COND_BOOL:
44 fprintf(fp, "%s ", p->p_bool_val_to_name[cur->bool - 1]);
45 break;
46 case COND_NOT:
47 fprintf(fp, "! ");
48 break;
49 case COND_OR:
50 fprintf(fp, "|| ");
51 break;
52 case COND_AND:
53 fprintf(fp, "&& ");
54 break;
55 case COND_XOR:
56 fprintf(fp, "^ ");
57 break;
58 case COND_EQ:
59 fprintf(fp, "== ");
60 break;
61 case COND_NEQ:
62 fprintf(fp, "!= ");
63 break;
64 default:
65 fprintf(fp, "error! (%d)", cur->expr_type);
66 break;
67 }
68 }
69 }
70