home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / clients / xdm / error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-18  |  2.6 KB  |  109 lines

  1. /*
  2.  * xdm - display manager daemon
  3.  *
  4.  * $XConsortium: error.c,v 1.12 91/04/02 11:56:56 rws Exp $
  5.  *
  6.  * Copyright 1988 Massachusetts Institute of Technology
  7.  *
  8.  * Permission to use, copy, modify, and distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted, provided
  10.  * that the above copyright notice appear in all copies and that both that
  11.  * copyright notice and this permission notice appear in supporting
  12.  * documentation, and that the name of M.I.T. not be used in advertising or
  13.  * publicity pertaining to distribution of the software without specific,
  14.  * written prior permission.  M.I.T. makes no representations about the
  15.  * suitability of this software for any purpose.  It is provided "as is"
  16.  * without express or implied warranty.
  17.  *
  18.  * Author:  Keith Packard, MIT X Consortium
  19.  */
  20.  
  21. /*
  22.  * error.c
  23.  *
  24.  * Log display manager errors to a file as
  25.  * we generally do not have a terminal to talk to
  26.  */
  27.  
  28. # include "dm.h"
  29. # include <stdio.h>
  30.  
  31. InitErrorLog ()
  32. {
  33.     int    i;
  34.     if (errorLogFile[0]) {
  35.         i = creat (errorLogFile, 0666);
  36.         if (i != -1) {
  37.             if (i != 2) {
  38.                 dup2 (i, 2);
  39.                 close (i);
  40.             }
  41.         } else
  42.             LogError ("Cannot open errorLogFile %s\n", errorLogFile);
  43.     }
  44. }
  45.  
  46. /*VARARGS1*/
  47. LogInfo (fmt, arg1, arg2, arg3, arg4, arg5, arg6)
  48. char    *fmt;
  49. int    arg1, arg2, arg3, arg4, arg5, arg6;
  50. {
  51.     fprintf (stderr, "info (pid %d): ", getpid());
  52.     fprintf (stderr, fmt, arg1, arg2, arg3, arg4, arg5, arg6);
  53.     fflush (stderr);
  54. }
  55.  
  56. /*VARARGS1*/
  57. LogError (fmt, arg1, arg2, arg3, arg4, arg5, arg6)
  58. char    *fmt;
  59. int    arg1, arg2, arg3, arg4, arg5, arg6;
  60. {
  61.     fprintf (stderr, "error (pid %d): ", getpid());
  62.     fprintf (stderr, fmt, arg1, arg2, arg3, arg4, arg5, arg6);
  63.     fflush (stderr);
  64. }
  65.  
  66. /*VARARGS1*/
  67. LogPanic (fmt, arg1, arg2, arg3, arg4, arg5, arg6)
  68. char    *fmt;
  69. int    arg1, arg2, arg3, arg4, arg5, arg6;
  70. {
  71.     LogError ("panic (pid %d): ", getpid());
  72.     LogError (fmt, arg1, arg2, arg3, arg4, arg5, arg6);
  73.     exit (1);
  74. }
  75.  
  76. /*VARARGS1*/
  77. LogOutOfMem (fmt, arg1, arg2, arg3, arg4, arg5, arg6)
  78. char    *fmt;
  79. int    arg1, arg2, arg3, arg4, arg5, arg6;
  80. {
  81.     fprintf (stderr, "xdm: out of memory in routine ");
  82.     fprintf (stderr, fmt, arg1, arg2, arg3, arg4, arg5, arg6);
  83.     fflush (stderr);
  84. }
  85.  
  86. Panic (mesg)
  87. char    *mesg;
  88. {
  89.     int    i;
  90.  
  91.     i = creat ("/dev/console", 0666);
  92.     write (i, "panic: ", 7);
  93.     write (i, mesg, strlen (mesg));
  94.     exit (1);
  95. }
  96.  
  97.  
  98. /*VARARGS1*/
  99. Debug (fmt, arg1, arg2, arg3, arg4, arg5, arg6)
  100. char    *fmt;
  101. int    arg1, arg2, arg3, arg4, arg5, arg6;
  102. {
  103.     if (debugLevel > 0)
  104.     {
  105.     printf (fmt, arg1, arg2, arg3, arg4, arg5, arg6);
  106.     fflush (stdout);
  107.     }
  108. }
  109.