16cd6a6acSopenharmony_ci/* 26cd6a6acSopenharmony_ci * Author: Joshua Brindle <jbrindle@tresys.com> 36cd6a6acSopenharmony_ci * 46cd6a6acSopenharmony_ci * Copyright (C) 2006 Tresys Technology, LLC 56cd6a6acSopenharmony_ci * 66cd6a6acSopenharmony_ci * This library is free software; you can redistribute it and/or 76cd6a6acSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 86cd6a6acSopenharmony_ci * License as published by the Free Software Foundation; either 96cd6a6acSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 106cd6a6acSopenharmony_ci * 116cd6a6acSopenharmony_ci * This library is distributed in the hope that it will be useful, 126cd6a6acSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 136cd6a6acSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 146cd6a6acSopenharmony_ci * Lesser General Public License for more details. 156cd6a6acSopenharmony_ci * 166cd6a6acSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 176cd6a6acSopenharmony_ci * License along with this library; if not, write to the Free Software 186cd6a6acSopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 196cd6a6acSopenharmony_ci */ 206cd6a6acSopenharmony_ci 216cd6a6acSopenharmony_ci/* This includes functions used to debug tests (display bitmaps, conditional expressions, etc */ 226cd6a6acSopenharmony_ci 236cd6a6acSopenharmony_ci#include "debug.h" 246cd6a6acSopenharmony_ci 256cd6a6acSopenharmony_ci#include <stdlib.h> 266cd6a6acSopenharmony_ci 276cd6a6acSopenharmony_civoid print_ebitmap(ebitmap_t * bitmap, FILE * fp) 286cd6a6acSopenharmony_ci{ 296cd6a6acSopenharmony_ci uint32_t i; 306cd6a6acSopenharmony_ci for (i = 0; i < bitmap->highbit; i++) { 316cd6a6acSopenharmony_ci fprintf(fp, "%d", ebitmap_get_bit(bitmap, i)); 326cd6a6acSopenharmony_ci } 336cd6a6acSopenharmony_ci fprintf(fp, "\n"); 346cd6a6acSopenharmony_ci} 356cd6a6acSopenharmony_ci 366cd6a6acSopenharmony_ci/* stolen from dispol.c */ 376cd6a6acSopenharmony_civoid display_expr(policydb_t * p, cond_expr_t * exp, FILE * fp) 386cd6a6acSopenharmony_ci{ 396cd6a6acSopenharmony_ci 406cd6a6acSopenharmony_ci cond_expr_t *cur; 416cd6a6acSopenharmony_ci for (cur = exp; cur != NULL; cur = cur->next) { 426cd6a6acSopenharmony_ci switch (cur->expr_type) { 436cd6a6acSopenharmony_ci case COND_BOOL: 446cd6a6acSopenharmony_ci fprintf(fp, "%s ", p->p_bool_val_to_name[cur->bool - 1]); 456cd6a6acSopenharmony_ci break; 466cd6a6acSopenharmony_ci case COND_NOT: 476cd6a6acSopenharmony_ci fprintf(fp, "! "); 486cd6a6acSopenharmony_ci break; 496cd6a6acSopenharmony_ci case COND_OR: 506cd6a6acSopenharmony_ci fprintf(fp, "|| "); 516cd6a6acSopenharmony_ci break; 526cd6a6acSopenharmony_ci case COND_AND: 536cd6a6acSopenharmony_ci fprintf(fp, "&& "); 546cd6a6acSopenharmony_ci break; 556cd6a6acSopenharmony_ci case COND_XOR: 566cd6a6acSopenharmony_ci fprintf(fp, "^ "); 576cd6a6acSopenharmony_ci break; 586cd6a6acSopenharmony_ci case COND_EQ: 596cd6a6acSopenharmony_ci fprintf(fp, "== "); 606cd6a6acSopenharmony_ci break; 616cd6a6acSopenharmony_ci case COND_NEQ: 626cd6a6acSopenharmony_ci fprintf(fp, "!= "); 636cd6a6acSopenharmony_ci break; 646cd6a6acSopenharmony_ci default: 656cd6a6acSopenharmony_ci fprintf(fp, "error! (%d)", cur->expr_type); 666cd6a6acSopenharmony_ci break; 676cd6a6acSopenharmony_ci } 686cd6a6acSopenharmony_ci } 696cd6a6acSopenharmony_ci} 70