home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <sys/types.h>
-
- #undef integer /* Silly stdtypes */
- #include "Kernel/h/system.h"
- #include "Kernel/h/mmTypes.h"
- #include "Kernel/h/mmCodes.h"
- #include "Kernel/h/unixCodes.h"
- #include "Kernel/h/mmBufTypes.h"
- #include "Kernel/h/mmFifoTypes.h"
- #include "Kernel/h/mmMsgDefs.h"
- #include "Kernel/h/mmMsgTypes.h"
-
- #include "Kernel/h/kmdDefs.h"
- #include "Kernel/h/kmdTypes.h"
- /* Special in this file: Undefine the macro for DebugMsg! */
- #undef DebugMsg
-
- #ifndef NODISK
- extern char nodisk;
- #endif
-
- int DebugLevel=0; /* Level of debugging output wanted */
- FILE *logout = (FILE *) 0; /* fp for log file */
- char *ctime ();
- int IamPOD;
-
- /*
- * DebugMsg(level, <printf arguments> ... )
- *
- * Prints out a message to help with debugging. This is an old Unix
- * hack to allow a variable number of arguments to doprnt. It is a
- * terrible hack but I don't know how else to do it. This should
- * eventually be changed to put messages in a file or out an IPC
- * port or something.
- */
-
- #ifdef USEREALDEBUGMSG
- /*VARARGS1*/
- DebugMsg(level, fmt, args)
- int level;
- char *fmt;
- int args;
- {
- struct _iobuf _strbuf;
- char str[500];
- char fullfmt[132];
-
- if (DebugLevel >= level) {
- _strbuf._flag = _IOWRT+_IOSTRG;
- _strbuf._ptr = str;
- _strbuf._cnt = 32767;
- sprintf(fullfmt, "%s: ", MMTraceHost);
- (void) strcat(fullfmt,fmt);
- _doprnt(fullfmt, &args, &_strbuf);
- putc('\0',&_strbuf);
- printf("%s",str);
- if (level == 0)
- LogMsg (fmt, (char *) &args);
- };
- KMDTracex("DebugMsg", level, fmt, &args);
- }
- #endif USEREALDEBUGMSG
-
- /*VARARGS2*/
- void DebugMsg1(level, fmt, args)
- int level;
- char *fmt;
- int *args;
- {
- struct _iobuf _strbuf;
- char str[500];
- char fullfmt[132];
-
- if (DebugLevel >= level) {
- _strbuf._flag = _IOWRT+_IOSTRG;
- #ifdef vax
- _strbuf._ptr = str;
- #else
- _strbuf._ptr = (unsigned char *)str;
- #endif
- _strbuf._cnt = 32767;
- sprintf(fullfmt, "%s: ", MMTraceHost);
- (void) strcat(fullfmt, fmt);
- _doprnt(fullfmt, &args, &_strbuf);
- putc('\0',&_strbuf);
- printf("%s",str);
- if (level == 0)
- LogMsg (fmt, (char *) &args);
- };
- KMDTracex("DebugMsg", level, fmt, &args);
- }
-
- /*
- * ErrMsg
- *
- * A lot like DebugMsg, but for more fatal errors.
- */
-
- /*VARARGS1*/
- void ErrMsg(fmt, args)
- char *fmt;
- int args;
- {
- struct _iobuf _strbuf;
- char fullfmt[2000];
-
- printf("%s: ", MMTraceHost);
- #ifdef BSD
- _doprnt(fmt, &args, stdout);
- #else
- _strbuf._flag = _IOWRT+_IOSTRG;
- #ifdef vax
- _strbuf._ptr = fullfmt;
- #else
- _strbuf._ptr = (unsigned char *)fullfmt;
- #endif
- _strbuf._cnt = 32767;
- _doprnt(fmt, &args, &_strbuf);
- putc('\0',&_strbuf);
- printf("%s",fullfmt);
- #endif
- LogMsg (fmt, (char *) &args);
- }
-
- /*
- * LogMsg
- *
- * Prints out a message to a log file, along with the current time.
- * Log file only exists for Process B and POD.
- * Because of the way fargs is passed, this should not be called directly, but
- * through DebugMsg or ErrMsg.
- */
- static
- /*VARARGS*/
- LogMsg (fmt, fargs)
- char *fmt, *fargs;
- {
- time_t t;
- char *p;
-
- #ifndef NODISK
- if(!nodisk) {
- if (logout) {
- t = time ( (time_t *) 0);
- p = ctime (&t);
- *(p + strlen (p) - 1) = '\0';
- fprintf (logout, "%s: ", p);
- _doprnt(fmt, fargs, logout);
- (void) fflush (logout);
- }
- }
- #endif
- }
-