home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / kernserv / printf.h < prev    next >
Text File  |  1992-07-29  |  4KB  |  123 lines

  1. /*    @(#)printf.h    1.0    2/2/90        (c) 1990 NeXT    */
  2.  
  3. /* 
  4.  * HISTORY
  5.  *  2-Feb-90  Gregg Kellogg (gk) at NeXT
  6.  *    Created.
  7.  *
  8.  */ 
  9.  
  10. #ifndef _KERN_INTERNAL_PRINTF_
  11. #define _KERN_INTERNAL_PRINTF_
  12.  
  13. #import <sys/types.h>
  14. #import <sys/buf.h>
  15. #import <sys/tty.h>
  16. #import <ansi/stdarg.h>
  17.  
  18. #if    NeXT
  19. /*
  20.  * bit field descriptions for printf %r and %R formats
  21.  */
  22.  
  23. /*
  24.  * printf("%r %R", val, reg_descp);
  25.  * struct reg_desc *reg_descp;
  26.  *
  27.  * the %r and %R formats allow formatted output of bit fields.
  28.  * reg_descp points to an array of reg_desc structures, each element of the
  29.  * array describes a range of bits within val.  the array should have a
  30.  * final element with all structure elements 0.
  31.  * %r outputs a string of the format "<bit field descriptions>"
  32.  * %R outputs a string of the format "0x%x<bit field descriptions>"
  33.  *
  34.  * The fields in a reg_desc are:
  35.  *    unsigned rd_mask;    An appropriate mask to isolate the bit field
  36.  *                within a word, and'ed with val
  37.  *
  38.  *    int rd_shift;        A shift amount to be done to the isolated
  39.  *                bit field.  done before printing the isolate
  40.  *                bit field with rd_format and before searching
  41.  *                for symbolic value names in rd_values
  42.  *
  43.  *    char *rd_name;        If non-null, a bit field name to label any
  44.  *                out from rd_format or searching rd_values.
  45.  *                if neither rd_format or rd_values is non-null
  46.  *                rd_name is printed only if the isolated
  47.  *                bit field is non-null.
  48.  *
  49.  *    char *rd_format;    If non-null, the shifted bit field value
  50.  *                is printed using this format.
  51.  *
  52.  *    struct reg_values *rd_values;    If non-null, a pointer to a table
  53.  *                matching numeric values with symbolic names.
  54.  *                rd_values are searched and the symbolic
  55.  *                value is printed if a match is found, if no
  56.  *                match is found "???" is printed.
  57.  *
  58.  * printf("%n %N", val, reg_valuesp);
  59.  * struct reg_values *reg_valuesp;
  60.  *
  61.  * the %n and %N formats allow formatted output of symbolic constants
  62.  * Reg_valuesp is a pointer to an array of struct reg_values which pairs
  63.  * numeric values (rv_value) with sHlic names (rv_name).  The array is
  64.  * terminated with a reg_values entry that has a null pointer for the
  65.  * rv_name field.  When %n or %N is used rd_values are searched and the
  66.  * symbolic value is printed if a match is found, if no match is found
  67.  * "???" is printed.
  68.  *                
  69.  * printf("%C", val);
  70.  * int val;
  71.  *
  72.  * the %C format prints an int as a 4 character string.
  73.  * The most significant byte of the int is printed first, the least
  74.  * significant byte is printed last.
  75.  */
  76.  
  77. /*
  78.  * register values
  79.  * map between numeric values and symbolic values
  80.  */
  81. struct reg_values {
  82.     unsigned rv_value;
  83.     char *rv_name;
  84. };
  85.  
  86. /*
  87.  * register descriptors are used for formatted prints of register values
  88.  * rd_mask and rd_shift must be defined, other entries may be null
  89.  */
  90. struct reg_desc {
  91.     unsigned rd_mask;    /* mask to extract field */
  92.     int rd_shift;        /* shift for extracted value, - >>, + << */
  93.     char *rd_name;        /* field name */
  94.     char *rd_format;    /* format to print field */
  95.     struct reg_values *rd_values;    /* symbolic names of values */
  96. };
  97.  
  98. #endif    NeXT
  99.  
  100. /*
  101.  * Flags arguments to prf()
  102.  */
  103. #define TOCONS    0x1
  104. #define TOTTY    0x2
  105. #define TOLOG    0x4
  106. #define    TOSTR    0x8
  107.  
  108. extern const char *panicstr;
  109.  
  110. int printf(const char *format, ...);
  111. int uprintf(const char *format, ...);
  112. int tprintf(struct tty *tp, const char *format, ...);
  113. int sprintf(char *s, const char *format, ...);
  114. int log(int level, const char *format, ...);
  115. int prf(const char *fmt, va_list ap, int flags, struct tty *ttyp);
  116. void panic_init(void);
  117. void panic(const char *s);
  118. void tablefull(const char *tab);
  119. void harderr(struct buf *bp, const char *cp);
  120. int (putchar)(int c);
  121. void logchar(int c);
  122. #endif _KERN_INTERNAL_PRINTF_
  123.