1*9dac6096SDmitry Chagin /* 2*9dac6096SDmitry Chagin * Copyright (c) 2006 "David Kirchner" <dpk@dpk.net>. All rights reserved. 3*9dac6096SDmitry Chagin * 4*9dac6096SDmitry Chagin * Redistribution and use in source and binary forms, with or without 5*9dac6096SDmitry Chagin * modification, are permitted provided that the following conditions 6*9dac6096SDmitry Chagin * are met: 7*9dac6096SDmitry Chagin * 1. Redistributions of source code must retain the above copyright 8*9dac6096SDmitry Chagin * notice, this list of conditions and the following disclaimer. 9*9dac6096SDmitry Chagin * 2. Redistributions in binary form must reproduce the above copyright 10*9dac6096SDmitry Chagin * notice, this list of conditions and the following disclaimer in the 11*9dac6096SDmitry Chagin * documentation and/or other materials provided with the distribution. 12*9dac6096SDmitry Chagin * 13*9dac6096SDmitry Chagin * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14*9dac6096SDmitry Chagin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15*9dac6096SDmitry Chagin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16*9dac6096SDmitry Chagin * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17*9dac6096SDmitry Chagin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18*9dac6096SDmitry Chagin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19*9dac6096SDmitry Chagin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20*9dac6096SDmitry Chagin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21*9dac6096SDmitry Chagin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22*9dac6096SDmitry Chagin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23*9dac6096SDmitry Chagin * SUCH DAMAGE. 24*9dac6096SDmitry Chagin */ 25*9dac6096SDmitry Chagin 26*9dac6096SDmitry Chagin #ifndef __SYSDECODE_SUPPORT_H__ 27*9dac6096SDmitry Chagin #define __SYSDECODE_SUPPORT_H__ 28*9dac6096SDmitry Chagin 29*9dac6096SDmitry Chagin /* 30*9dac6096SDmitry Chagin * This is taken from the xlat tables originally in truss which were 31*9dac6096SDmitry Chagin * in turn taken from strace. 32*9dac6096SDmitry Chagin */ 33*9dac6096SDmitry Chagin struct name_table { 34*9dac6096SDmitry Chagin uintmax_t val; 35*9dac6096SDmitry Chagin const char *str; 36*9dac6096SDmitry Chagin }; 37*9dac6096SDmitry Chagin 38*9dac6096SDmitry Chagin /* 39*9dac6096SDmitry Chagin * These are simple support macros. print_or utilizes a variable 40*9dac6096SDmitry Chagin * defined in the calling function to track whether or not it should 41*9dac6096SDmitry Chagin * print a logical-OR character ('|') before a string. if_print_or 42*9dac6096SDmitry Chagin * simply handles the necessary "if" statement used in many lines 43*9dac6096SDmitry Chagin * of this file. 44*9dac6096SDmitry Chagin */ 45*9dac6096SDmitry Chagin #define print_or(fp,str,orflag) do { \ 46*9dac6096SDmitry Chagin if (orflag) fputc(fp, '|'); else orflag = true; \ 47*9dac6096SDmitry Chagin fprintf(fp, str); } \ 48*9dac6096SDmitry Chagin while (0) 49*9dac6096SDmitry Chagin #define if_print_or(fp,i,flag,orflag) do { \ 50*9dac6096SDmitry Chagin if ((i & flag) == flag) \ 51*9dac6096SDmitry Chagin print_or(fp,#flag,orflag); } \ 52*9dac6096SDmitry Chagin while (0) 53*9dac6096SDmitry Chagin 54*9dac6096SDmitry Chagin const char *lookup_value(struct name_table *, uintmax_t); 55*9dac6096SDmitry Chagin void print_integer(FILE *, int, int); 56*9dac6096SDmitry Chagin bool print_mask_0(FILE *, struct name_table *, int, int *); 57*9dac6096SDmitry Chagin bool print_mask_0ul(FILE *, struct name_table *, u_long, u_long *); 58*9dac6096SDmitry Chagin bool print_mask_int(FILE *, struct name_table *, int, int *); 59*9dac6096SDmitry Chagin void print_mask_part(FILE *, struct name_table *, uintmax_t *, bool *); 60*9dac6096SDmitry Chagin bool print_value(FILE *, struct name_table *, uintmax_t); 61*9dac6096SDmitry Chagin 62*9dac6096SDmitry Chagin #endif /* !__SYSDECODE_SUPPORT_H__ */ 63