1 /* ********************************************
  2    *                                          *
  3    * Copyright, (C) Honeywell Bull Inc., 1987 *
  4    *                                          *
  5    ******************************************** */
  6 
  7 /* HISTORY COMMENTS:
  8   1) change(87-12-18,Flegel), approve(87-10-04,MCR7787),
  9      audit(88-01-26,DGHowe), install(88-02-24,MR12.2-1028):
 10      Created for the building of error messages.
 11                                                    END HISTORY COMMENTS */
 12 
 13 /* COMPILER: Lattice C, V2.15 */
 14 
 15 #include <stdio.h>
 16 #include <bft.h>
 17 #include <mowse.h>
 18 
 19 /* This error table was created from the standard Lattice C "error.h" */
 20 
 21 #define D_SYSERR
 22 char *sys_error_table[] =
 23      {
 24           "No error",
 25           "User is not owner",
 26           "No such file or directory",
 27           "No such process",
 28           "Interrupted system call",
 29           "I/O error",
 30           "No such device or address",
 31           "Arg list is too long",
 32           "Exec format error",
 33           "Bad file number",
 34           "No child process",
 35           "No more processes allowed",
 36           "No memory available",
 37           "Access denied",
 38           "Bad address",
 39           "Bulk device required",
 40           "Resource is busy",
 41           "File already exists",
 42           "Cross-device link",
 43           "No such device",
 44           "Not a directory",
 45           "Is a directory",
 46           "Invalid argument",
 47           "No more files (units) allowed",
 48           "No more files (units) allowed for this process",
 49           "Not a terminal",
 50           "Text file is busy",
 51           "File is too large",
 52           "No space left",
 53           "Seek issued to pipe",
 54           "Read-only file system",
 55           "Too many links",
 56           "Broken pipe",
 57           "Math function argument error",
 58           "Math function result is out of range"
 59      };
 60 
 61 int  sys_error_table_size =
 62      {
 63           sizeof (sys_error_table) / sizeof (sys_error_table[0])
 64      };
 65 
 66 /* This error table is created from the error codes in "BFT.H" */
 67 
 68 #define D_BFTERR
 69 char *bft_error_table[] =
 70      {
 71           "No error",
 72           "Invalid priority",
 73           "Invalid minor capability",
 74           "Bad command argument",
 75           "Bad option to argument",
 76           "Argument expected",
 77           "No argument",
 78           "Invalid request id type",
 79           "Bad pathname specified",
 80           "Incomaptible control args"
 81      };
 82 
 83 int  bft_error_table_size =
 84      {
 85           sizeof (bft_error_table) / sizeof (bft_error_table[0])
 86      };
 87 /*^L*/
 88 /***************************************************************
 89 
 90      BFTERROR
 91 
 92      PARAMETERS: CODE      - Error code.
 93                  MESSAGE   - Error message.
 94                  MCB_PTR   - NULL if it is a stderr, otherwise a BG message.
 95 
 96      FUNCTION:   Display an error message to the stderr switch.
 97 
 98 *****************************************************************/
 99 
100 bfterror (p_code, p_message, p_mcb_ptr)
101 
102 int  p_code;                           /* Error code */
103 char p_message[];                      /* Error message */
104 mcb  *p_mcb_ptr;
105 {
106 char error_message[MAXARGSTRING];      /* Message generated */
107 
108 
109   if (p_code == 0)
110     return (p_code);
111 
112   if (issyserr (p_code))
113   {
114     strcpy (error_message, getsyserr (p_code));
115   }
116   else if (isbfterr (p_code))
117   {
118     strcpy (error_message, bft_error_table[p_code-BFT_BASE_ERROR]/*getbfterr (p_code)*/);
119   }
120   else switch (p_code)
121   {
122     case (WSINVBUF):
123       strcpy (error_message, "Invalid buffer size");
124       break;
125 
126     case (WSCNTCRE):
127       strcpy (error_message, "Can't create instance");
128       break;
129 
130     case (WSINVNAM):
131       strcpy (error_message, "Invalid entry name");
132       break;
133 
134     case (WSNOTACT):
135       strcpy (error_message, "MOWSE not active");
136       break;
137 
138     case (WSNOTRES):
139       strcpy (error_message, "MOWSE is not resident");
140       break;
141 
142     case (WSINVSYS):
143       strcpy (error_message, "Invalid system");
144       break;
145 
146     case (WSINVMCB):
147       strcpy (error_message, "Invalid MCB pointer");
148       break;
149 
150     default:
151       sprintf (error_message, "Error %d", p_code);
152       break;
153   }
154 
155   if (p_mcb_ptr != NULL)
156     putbgmes (p_mcb_ptr, 0,"BFT", "%s.  %s", error_message, p_message);
157   else
158     fprintf (stderr, "BFT: %s.  %s\n", error_message, p_message);
159 
160   return (p_code);
161 }