Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:19

0001 /*
0002  * Copyright (c) 1989, 1993
0003  *  The Regents of the University of California.  All rights reserved.
0004  *
0005  * Redistribution and use in source and binary forms, with or without
0006  * modification, are permitted provided that the following conditions
0007  * are met:
0008  * 1. Redistributions of source code must retain the above copyright
0009  *    notice, this list of conditions and the following disclaimer.
0010  * 2. Redistributions in binary form must reproduce the above copyright
0011  *    notice, this list of conditions and the following disclaimer in the
0012  *    documentation and/or other materials provided with the distribution.
0013  * 3. All advertising materials mentioning features or use of this software
0014  *    must display the following acknowledgement:
0015  *  This product includes software developed by the University of
0016  *  California, Berkeley and its contributors.
0017  * 4. Neither the name of the University nor the names of its contributors
0018  *    may be used to endorse or promote products derived from this software
0019  *    without specific prior written permission.
0020  *
0021  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
0022  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0024  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
0025  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0026  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0027  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0028  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0029  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0030  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0031  * SUCH DAMAGE.
0032  *
0033  *  @(#)hexdump.h   8.1 (Berkeley) 6/6/93
0034  * $FreeBSD: src/usr.bin/hexdump/hexdump.h,v 1.9 2004/07/11 01:11:12 tjr Exp $
0035  */
0036 
0037 #include <wchar.h>
0038 
0039 typedef struct _pr {
0040     struct _pr *nextpr;     /* next print unit */
0041 #define F_ADDRESS   0x001       /* print offset */
0042 #define F_BPAD      0x002       /* blank pad */
0043 #define F_C     0x004       /* %_c */
0044 #define F_CHAR      0x008       /* %c */
0045 #define F_DBL       0x010       /* %[EefGf] */
0046 #define F_INT       0x020       /* %[di] */
0047 #define F_P     0x040       /* %_p */
0048 #define F_STR       0x080       /* %s */
0049 #define F_U     0x100       /* %_u */
0050 #define F_UINT      0x200       /* %[ouXx] */
0051 #define F_TEXT      0x400       /* no conversions */
0052     u_int flags;            /* flag values */
0053     int bcnt;           /* byte count */
0054     char *cchar;            /* conversion character */
0055     char *fmt;          /* printf format */
0056     char *nospace;          /* no whitespace version */
0057     int mbleft;         /* bytes left of multibyte char. */
0058     mbstate_t mbstate;      /* conversion state */
0059 } PR;
0060 
0061 typedef struct _fu {
0062     struct _fu *nextfu;     /* next format unit */
0063     struct _pr *nextpr;     /* next print unit */
0064 #define F_IGNORE    0x01        /* %_A */
0065 #define F_SETREP    0x02        /* rep count set, not default */
0066     u_int flags;            /* flag values */
0067     int reps;           /* repetition count */
0068     int bcnt;           /* byte count */
0069     char *fmt;          /* format string */
0070 } FU;
0071 
0072 typedef struct _fs {            /* format strings */
0073     struct _fs *nextfs;     /* linked list of format strings */
0074     struct _fu *nextfu;     /* linked list of format units */
0075     int bcnt;
0076 } FS;
0077 
0078 #if 0
0079 extern FS *fshead;          /* head of format strings list */
0080 extern FU *endfu;           /* format at end-of-data */
0081 extern int blocksize;           /* data block size */
0082 extern int exitval;         /* final exit value */
0083 extern int odmode;          /* are we acting as od(1)? */
0084 extern int length;          /* amount of data to read */
0085 extern off_t skip;          /* amount of data to skip at start */
0086 enum _vflag { ALL, DUP, FIRST, WAIT };  /* -v values */
0087 extern enum _vflag vflag;
0088 #endif
0089 
0090 #include <setjmp.h>
0091 #include <stdio.h>
0092 
0093 enum _vflag { ALL, DUP, FIRST, WAIT };  /* -v values */
0094 typedef struct rtems_shell_hexdump_globals_t {
0095   FS *fshead;           /* head of format strings list */
0096   FU *endfu;            /* format at end-of-data */
0097   int blocksize;            /* data block size */
0098   int exitval;          /* final exit value */
0099   int odmode;           /* are we acting as od(1)? */
0100   int length;           /* amount of data to read */
0101   off_t skip;           /* amount of data to skip at start */
0102   enum _vflag vflag;
0103 
0104   off_t address;
0105   off_t eaddress;
0106   int ateof;
0107   u_char *curp;
0108   u_char *savp;
0109   int done;
0110 
0111   FILE* hdstdin;
0112 
0113   int exit_code;
0114   jmp_buf exit_jmp;
0115 } rtems_shell_hexdump_globals;
0116 
0117 #define fshead    globals->fshead
0118 #define endfu     globals->endfu
0119 #define blocksize globals->blocksize
0120 #define exitval   globals->exitval
0121 #define odmode    globals->odmode
0122 #define length    globals->length
0123 #define skip      globals->skip
0124 #define vflag     globals->vflag
0125 
0126 #define address   globals->address
0127 #define eaddress  globals->eaddress
0128 #define ateof     globals->ateof
0129 #define curp      globals->curp
0130 #define savp      globals->savp
0131 #define done      globals->done
0132 
0133 #define hdstdin   globals->hdstdin
0134 
0135 #define exit_jump &(globals->exit_jmp)
0136 
0137 #define add       rtems_shell_hexdump_add
0138 #define addfile   rtems_shell_hexdump_addfile
0139 #define badcnt    rtems_shell_hexdump_badcnt
0140 #define badconv   rtems_shell_hexdump_badconv
0141 #define badfmt    rtems_shell_hexdump_badfmt
0142 #define badsfmt   rtems_shell_hexdump_badsfmt
0143 #define bpad      rtems_shell_hexdump_bpad
0144 #define conv_c    rtems_shell_hexdump_conv_c
0145 #define conv_u    rtems_shell_hexdump_conv_u
0146 #define display   rtems_shell_hexdump_display
0147 #define doskip    rtems_shell_hexdump_doskip
0148 #define escape    rtems_shell_hexdump_escape
0149 #define get       rtems_shell_hexdump_get
0150 #define newsyntax rtems_shell_hexdump_newsyntax
0151 #define next      rtems_shell_hexdump_next
0152 #define nomem     rtems_shell_hexdump_nomem
0153 #define oldsyntax rtems_shell_hexdump_oldsyntax
0154 #define peek      rtems_shell_hexdump_peek
0155 #define rewrite   rtems_shell_hexdump_rewrite
0156 #define size      rtems_shell_hexdump_size
0157 #define usage     rtems_shell_hexdump_usage
0158 
0159 void     add(rtems_shell_hexdump_globals*, const char *);
0160 void     addfile(rtems_shell_hexdump_globals*, char *);
0161 void     badcnt(rtems_shell_hexdump_globals*, char *);
0162 void     badconv(rtems_shell_hexdump_globals*, char *);
0163 void     badfmt(rtems_shell_hexdump_globals*, const char *);
0164 void     badsfmt(rtems_shell_hexdump_globals*);
0165 void     bpad(PR *);
0166 void     conv_c(rtems_shell_hexdump_globals*, PR *, u_char *, size_t);
0167 void     conv_u(rtems_shell_hexdump_globals*, PR *, u_char *);
0168 void     display(rtems_shell_hexdump_globals*);
0169 void     doskip(rtems_shell_hexdump_globals*, const char *, int);
0170 void     escape(char *);
0171 u_char  *get(rtems_shell_hexdump_globals*);
0172 void     newsyntax(rtems_shell_hexdump_globals*, int, char ***);
0173 int  next(rtems_shell_hexdump_globals*, char **);
0174 void     nomem(void);
0175 void     oldsyntax(rtems_shell_hexdump_globals*, int, char ***);
0176 size_t   peek(rtems_shell_hexdump_globals*, u_char *, size_t);
0177 void     rewrite(rtems_shell_hexdump_globals*, FS *);
0178 int  size(rtems_shell_hexdump_globals*, FS *);
0179 void     usage(rtems_shell_hexdump_globals*);
0180 
0181 #define exit(ec) rtems_shell_hexdump_exit(globals, ec)
0182 
0183 void rtems_shell_hexdump_exit(rtems_shell_hexdump_globals* globals, int code);