home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Kernel / MsgOps / traceMsg.c < prev   
Encoding:
C/C++ Source or Header  |  1990-08-17  |  3.0 KB  |  107 lines

  1.  
  2. /*
  3.  * @(#)traceMsg.c    1.2  2/23/90
  4.  */
  5.  
  6. /* File: /u1/Eden/Source/MsgOps/TraceMsg.c */
  7. /* V2.0: /u1/Eden/Kernel/MsgOps/traceMsg.c */
  8.  
  9. /*
  10.  * $Header:   /u1/Eden/Kernel/MsgOps/RCS/TraceMsg.v  Revision 1.3  85/03/14 12:17:22  eric Exp$
  11.  * INTERFACE:    Defined by exported procedures.
  12.  *
  13.  * FUNCTION:    Provides Message Module trace facility.
  14.  *
  15.  * IMPORTS:    None.
  16.  *
  17.  * EXPORTS:    MMTrace, MMTraceHost, MMTraceMsg.
  18.  *
  19.  * DESIGN:      None.
  20.  *
  21.  * $Log:    /u1/Eden/Source/MsgOps/RCS/TraceMsg.v $
  22.  * Revision 1.3  85/03/14  12:17:22  eric
  23.  * Changed trace output levels and made the indentation correspond to the
  24.  * trace level.
  25.  *
  26.  * Revision 1.2  83/02/25  12:17:22  cady
  27.  * No change.
  28.  * 
  29.  * Revision 1.1  83/02/24  16:34:58  cady
  30.  * Initial revision
  31.  * 
  32.  */
  33.  
  34.  
  35. /****************************************************************/
  36. /*                                                              */
  37. /*              Message Module Trace Facility                   */
  38. /*                                                              */
  39. /****************************************************************/
  40.  
  41. #include <stdio.h>
  42. #include "Kernel/h/stdTypes.h"
  43.  
  44. #include "Kernel/h/kmdTypes.h"
  45.  
  46. /****************************************************************/
  47. /*                                                              */
  48. /*                          MMTraceMsg                          */
  49. /*                                                              */
  50. /*  MMTraceMsg prints out a message to help with debugging.     */
  51. /*  This is an old Unix hack to allow a variable number of      */
  52. /*  arguments to doprnt.  This should eventually be changed to  */
  53. /*  put messages in a file or out an IPC port or something.     */
  54. /*  The trace flag MMTrace is initialized to 0 and is set       */
  55. /*  somewhere else depending on the higher-level code using     */
  56. /*  the Message Module.                                         */
  57. /*                                                              */
  58. /****************************************************************/
  59.  
  60. int  MMTrace         = 0;
  61. char MMTraceHost[100] = "\0";
  62. static char *Blanks[] = {
  63.     " ", " ", "  ", "   ", "    ", "     ", "      ", "       ", "        "};
  64.  
  65. /*VARARGS2*/
  66. void MMTraceMsg( fLevel,
  67.                  fFormat,
  68.                  fArgs
  69.                )
  70.   int   fLevel;
  71.   char *fFormat;
  72.   char *fArgs;
  73. {
  74.   struct _iobuf _strbuf;
  75.   char fullfmt[2000];
  76.   char formatbuf[2000];
  77.  
  78.   /* Indent according to level. */
  79.   if ( (fLevel < 1) || (fLevel > 8) ) {
  80.     (void) sprintf(formatbuf, "%d: %s", fLevel, fFormat);
  81.   } else {
  82.     (void) sprintf(formatbuf, "%s%s", Blanks[fLevel], fFormat);
  83.   }
  84.  
  85.   if ( MMTrace >= fLevel ){
  86.     if ( MMTraceHost[0] != '\0' )
  87.       printf("%s:", MMTraceHost);
  88.  
  89. #ifdef BSD
  90.     _doprnt( formatbuf, &fArgs, stdout );
  91. #else
  92.     _strbuf._flag = _IOWRT+_IOSTRG;
  93. #ifdef vax
  94.     _strbuf._ptr = fullfmt;
  95. #else
  96.     _strbuf._ptr = (unsigned char *)fullfmt;
  97. #endif
  98.  
  99.     _strbuf._cnt = 32767;
  100.     _doprnt(formatbuf, &fArgs, &_strbuf);
  101.     putc('\0',&_strbuf);
  102.     printf("%s",fullfmt);
  103. #endif
  104.   }
  105.   KMDTracex("MMTraceMsg", fLevel, formatbuf, &fArgs);
  106. }
  107.