Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtSvc / DtEncap / spc-error.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*
24  * $TOG: spc-error.c /main/10 1998/04/10 08:27:30 mgreess $
25  * Language:     C
26  *
27  * (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
28  *
29  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
30  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
31  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
32  * (c) Copyright 1993, 1994 Novell, Inc.                                *
33  */
34
35 #include <bms/sbport.h> /* NOTE: sbport.h must be the first include. */
36 #include <errno.h>
37 #include <stdarg.h>
38
39 #include <SPC/spcP.h>
40 #include <bms/MemoryMgr.h> /* NOTE: sbport.h must be the first include. */
41
42 #define X_INCLUDE_TIME_H
43 #define XOS_USE_XT_LOCKING
44 #include <X11/Xos_r.h>
45
46 #include "DtSvcLock.h"
47
48 /*
49  * Log file information (routines near bottom of file)
50  */
51
52 #define TEMPLATE_EXTENSION        (XeString)".XXXXXX" /* For mktemp(3c) */
53
54 XeChar spc_logfile[MAXPATHLEN+1];
55 XeChar spc_logging = FALSE;
56 /* FILE *spc_logF = NULL; -- to bmsglob.c */
57
58 int spc_logfd = NULL;
59
60 /* This is the SPC error number variable */
61 /* ------------------------------------- */
62 /* int XeSPCErrorNumber = NULL;  --- now in bmsglob.c */
63
64 /*------------------------------------------------------------------------+*/
65 static XeString
66 err_mnemonic(unsigned int errn, char *buff)
67 /*------------------------------------------------------------------------+*/
68 {
69     /* Since there is currently no standard way to get an err number    */
70     /* mnenonic from the system, we do it the hard way.  We can't even  */
71     /* use a table as the actual numeric values may differ on machines. */
72     /* Another potential problem is if one of these gets passed across  */
73     /* a network connection from a different type of machine that has   */
74     /* values that differ than the machine this routine runs on, we     */
75     /* could have problems.  I don't think anycode does that now.       */
76     /* ---------------------------------------------------------------- */
77
78     XeString s;
79     
80     switch (errn) {
81         
82     /* These are all in POSIX 1003.1 and/or X/Open XPG3     */
83     /* ---------------------------------------------------- */
84     case EPERM          : s = (XeString)"EPERM";        break;
85     case ENOENT         : s = (XeString)"ENOENT";       break;
86     case ESRCH          : s = (XeString)"ESRCH";        break;
87     case EINTR          : s = (XeString)"EINTR";        break;
88     case EIO            : s = (XeString)"EIO";          break;
89     case ENXIO          : s = (XeString)"ENXIO";        break;
90     case E2BIG          : s = (XeString)"E2BIG";        break;
91     case ENOEXEC        : s = (XeString)"ENOEXEC";      break;
92     case EBADF          : s = (XeString)"EBADF";        break;
93     case ECHILD         : s = (XeString)"ECHILD";       break;
94     case EAGAIN         : s = (XeString)"EAGAIN";       break;
95     case ENOMEM         : s = (XeString)"ENOMEM";       break;
96     case EACCES         : s = (XeString)"EACCES";       break;
97     case EFAULT         : s = (XeString)"EFAULT";       break;
98     case ENOTBLK        : s = (XeString)"ENOTBLK";      break;
99     case EBUSY          : s = (XeString)"EBUSY";        break;
100     case EEXIST         : s = (XeString)"EEXIST";       break;
101     case EXDEV          : s = (XeString)"EXDEV";        break;
102     case ENODEV         : s = (XeString)"ENODEV";       break;
103     case ENOTDIR        : s = (XeString)"ENOTDIR";      break;
104     case EISDIR         : s = (XeString)"EISDIR";       break;
105     case EINVAL         : s = (XeString)"EINVAL";       break;
106     case ENFILE         : s = (XeString)"ENFILE";       break;
107     case EMFILE         : s = (XeString)"EMFILE";       break;
108     case ENOTTY         : s = (XeString)"ENOTTY";       break;
109     case ETXTBSY        : s = (XeString)"ETXTBSY";      break;
110     case EFBIG          : s = (XeString)"EFBIG";        break;
111     case ENOSPC         : s = (XeString)"ENOSPC";       break;
112     case ESPIPE         : s = (XeString)"ESPIPE";       break;
113     case EROFS          : s = (XeString)"EROFS";        break;
114     case EMLINK         : s = (XeString)"EMLINK";       break;
115     case EPIPE          : s = (XeString)"EPIPE";        break;
116     case ENOMSG         : s = (XeString)"ENOMSG";       break;
117     case EIDRM          : s = (XeString)"EIDRM";        break;
118     case EDEADLK        : s = (XeString)"EDEADLK";      break;
119     case ENOLCK         : s = (XeString)"ENOLCK";       break;
120 #ifndef __aix
121     case ENOTEMPTY      : s = (XeString)"ENOTEMPTY";    break;
122 #endif
123     case ENAMETOOLONG   : s = (XeString)"ENAMETOOLONG"; break;
124     case ENOSYS         : s = (XeString)"ENOSYS";       break;
125
126     /* You could include machine specific stuff here ...    */
127     /* ---------------------------------------------------- */
128         
129
130     /* ---------------------------------------------------- */
131         default         : s = XeString_NULL;            break;
132     }
133     
134
135     if (s)
136         sprintf(buff, "%s (%d)",s,errn);
137     else
138         sprintf(buff, "(%d)",errn);
139     
140     return buff;
141 }
142
143 /*----------------------------------------------------------------------+*/
144 XeString SPC_copy_string(XeString str)
145 /*----------------------------------------------------------------------+*/
146 {
147   int len;
148   XeString tmp_str;
149
150   if(!str)
151     return(XeString_NULL);
152   
153   len=strlen(str);
154
155   tmp_str=(XeString)XeMalloc(len+1);
156   strcpy(tmp_str, str);
157   return(tmp_str);
158 }
159
160 /*----------------------------------------------------------------------+*/
161 void SPC_Error (int error, ...)
162 /*----------------------------------------------------------------------+*/
163 {
164   va_list ap;
165   SPCError *err;
166   XeChar *buffer;
167   XeString arg1;
168   long arg2;
169   XeChar buff[40];
170   
171   err=SPC_Lookup_Error(error);
172
173   if(!err)
174     return;
175
176   if(err->text) {
177     free(err->text);
178     err->text = NULL;
179   }
180
181   va_start(ap, error);                 /** Start varargs **/
182   arg1=va_arg(ap, XeString);
183
184   if (arg1)
185   {
186   /* The argument on the stack may be holding an int or a char pointer. */
187   /* Always popping off a long into the value of arg2 works fine */
188   /* because the subsequent call to sprintf does the proper conversion via */
189   /* "err->format". */
190       arg2=va_arg(ap, long);
191   }      
192   else
193   {
194       arg1 = XeString_Empty;
195       arg2 = 0;
196   }
197
198   buffer = (XeChar*) malloc(sizeof(XeChar) * SPC_BUFSIZ);
199   if (buffer)
200   {
201       sprintf(buffer, err->format, arg1, arg2);
202       err->text=SPC_copy_string(buffer);
203       free(buffer);
204   }
205   va_end(ap);                   /** End varargs **/
206
207   _DtSvcProcessLock();
208   XeSPCErrorNumber=error;
209   if (SPC_who_am_i == SPC_I_AM_A_DAEMON){
210
211      SPC_Format_Log((XeString)"DTSPCD error (%d): %s", 
212                     XeSPCErrorNumber, err->text);
213      if (err->use_errno){
214         XeString        errname;
215         XeString        errmsg;
216         unsigned int    errn = errno;
217
218         errname = err_mnemonic(errn, buff);
219
220         if (!(errmsg = strerror(errn)))
221            errmsg = (XeString) "unknown";
222
223         SPC_Format_Log((XeString)"  [%s] %s", errname, errmsg);
224      }
225      if(err->severity == XeFatalError || err->severity == XeInternalError) {
226         SPC_Format_Log((XeString)"Exiting server ...");
227         SPC_Close_Log();
228         _DtSvcProcessUnlock();
229         exit (3);
230      }
231   }
232   else
233      _DtSimpleError(XeProgName, XeError, XeString_NULL, err->text);
234
235   _DtSvcProcessUnlock();
236   return;
237 }
238
239 /*
240  * Log file routines
241  *
242  * Note: Current restriction of only one log file open at a time.
243  */
244
245 /*----------------------------------------------------------------------+*/
246 SPC_Make_Log_Filename(XeString name,
247                       int unique)       /* When TRUE, make name unique */
248 /*----------------------------------------------------------------------+*/
249 {
250   /* Make a log filename based on the passed name (and perhaps process id) */
251   XeString cp;
252   XeString log_file_path = NULL;
253
254   _DtSvcProcessLock();
255   /* first build the log file path */
256   if (!name || !*name) {
257     log_file_path = XeSBTempPath((XeString)"DTSPCD_log");
258     strcpy(spc_logfile, log_file_path);
259   }
260   else {
261     if (strlen(name) > MAXPATHLEN)
262         _DtSimpleError(XeProgName, XeInternalError, XeString_NULL, 
263                       (XeString)"String too long in DTSPCD_Make_Log_Filename()");
264     
265     strcpy(spc_logfile, name);
266   }
267
268   if (unique) {
269     /* Add the extension.  No strlen checking is done */
270     strcat(spc_logfile, TEMPLATE_EXTENSION);
271
272     cp = (XeString) mktemp(spc_logfile);
273     if (!cp || !*cp) {
274       /* Sorry, but this is the best we can do */
275       strcpy(spc_logfile, (log_file_path) ? log_file_path : name);
276     }
277   }
278
279   /* free the strings allocated for the path */
280   if (log_file_path) XeFree(log_file_path);
281   _DtSvcProcessUnlock();
282   return TRUE;
283 }
284
285 /*----------------------------------------------------------------------+*/
286 SPC_Open_Log(XeString filename,
287              int unique)                /* When TRUE, make filename unique */
288 /*----------------------------------------------------------------------+*/
289 {
290   /* Open the SPC log file */
291
292   /* Use the filename if one was passed to make a log filename */
293   SPC_Make_Log_Filename(filename, unique);
294
295   /* Open the logfile */
296   _DtSvcProcessLock();
297   spc_logF = fopen(spc_logfile, "a+");
298   if (!spc_logF) {
299     _DtSvcProcessUnlock();
300     return(SPC_ERROR);
301   }
302   spc_logging = TRUE;
303   
304   SPC_Format_Log((XeString)"*** DTSPCD logging started, file: `%s'", spc_logfile);
305   
306   _DtSvcProcessUnlock();
307   return(TRUE);
308 }
309
310 /*----------------------------------------------------------------------+*/
311 SPC_Close_Log(void)
312 /*----------------------------------------------------------------------+*/
313 {
314   /* Close the current log file */
315
316   SPC_Format_Log((XeString)"*** DTSPCD logging stopped");
317   
318   _DtSvcProcessLock();
319   if (spc_logF) {
320     fclose(spc_logF);
321   }
322   spc_logfd = NULL;
323   spc_logF = NULL;
324   spc_logging = FALSE;
325
326   _DtSvcProcessUnlock();
327   return(TRUE);
328 }
329
330 /*----------------------------------------------------------------------+*/
331 SPC_Write_Log(XeString str)
332 /*----------------------------------------------------------------------+*/
333 {
334   /* Write the passed message to the log file */
335   time_t t;
336   _Xctimeparams ctime_buf;
337   char *result;
338
339   _DtSvcProcessLock();
340   if (spc_logging && spc_logF) {
341     t = time(NULL);
342     result = _XCtime(&t, ctime_buf);
343     fprintf(spc_logF, "%s: %s", str, result);
344     fflush(spc_logF);
345   }
346
347   _DtSvcProcessUnlock();
348   return(TRUE);
349 }
350
351
352 /*----------------------------------------------------------------------+*/
353 int SPC_Format_Log (XeString format, ...)
354 /*----------------------------------------------------------------------+*/
355 {
356   /* Format the passed message to the log file */
357   va_list args;
358   time_t t;
359   _Xctimeparams ctime_buf;
360   char *result;
361
362   _DtSvcProcessLock();
363   if (spc_logging && spc_logF) {
364     /* First the message */
365     va_start(args, format);
366     vfprintf(spc_logF, format, args);
367     va_end(args);
368
369     /* Now a time stamp */
370     t = time(NULL);
371     result = _XCtime(&t, ctime_buf);
372     fprintf(spc_logF, ": %s", result);
373     fflush(spc_logF);
374   }
375
376   _DtSvcProcessUnlock();
377   return(TRUE);
378 }
379
380 /*
381  **
382  ** This next routine used to be such a nice little guy...  Once upon a
383  ** time I had all the error messages in a very
384  ** compact representation.  It was a vector of SPCError structures.
385  ** When I wanted to go from the integer representation of an error to
386  ** its textual form, I simply did a table lookup.  Unfortunately,
387  ** that method did not work at all well with the NLS scheme cooked up
388  ** by the Excalibur team.  This scheme was nice for programs which
389  ** just had the strings in the text.  It basically searched the
390  ** source program for a string with a funny symbol and replaced it
391  ** with a function call.  Well, to make a long story short, I decided
392  ** to go with that scheme.  Thus this function.
393  **
394 */ 
395
396 SPCError spc_error_struct;
397
398 /*----------------------------------------------------------------------+*/
399 SPCError *SPC_Lookup_Error(int errornum)
400 /*----------------------------------------------------------------------+*/
401 {
402   _DtSvcProcessLock();
403   switch (errornum) {
404     
405   case SPC_Out_Of_Memory:
406     spc_error_struct.format    = (XeString) "><Unable to allocate memory for internal SPC operation\n Perhaps you need to add more swap space to the system";
407     spc_error_struct.severity  = XeFatalError;
408     spc_error_struct.use_errno = FALSE;
409     break;
410
411   case SPC_Bad_Argument:
412     spc_error_struct.format    = (XeString) "><Bad argument to DTSPCD call";
413     spc_error_struct.severity  = XeError;
414     spc_error_struct.use_errno = FALSE;
415     break;
416     
417   case SPC_Active_Channel:
418     spc_error_struct.format    = (XeString) "><Channel already active";
419     spc_error_struct.severity  = XeError;
420     spc_error_struct.use_errno = FALSE;
421     break;
422
423   case SPC_Inactive_Channel:
424     spc_error_struct.format    = (XeString) "><Channel is not active";
425     spc_error_struct.severity  = XeError;
426     spc_error_struct.use_errno = FALSE;
427     break;
428
429   case SPC_Internal_Error:
430     spc_error_struct.format    = (XeString) "><Internal SPC Error";
431     spc_error_struct.severity  = XeError;
432     spc_error_struct.use_errno = FALSE;
433     break;
434
435   case SPC_Cannot_Fork:
436     spc_error_struct.format    = (XeString) "><Cannot fork";
437     spc_error_struct.severity  = XeError;
438     spc_error_struct.use_errno = TRUE;
439     break;
440
441   case SPC_Cannot_Exec:
442     spc_error_struct.format    = (XeString) "><Cannot exec file %s.\nPerhaps your PATH variable is incorrect.\nUse the following errno value to further diagnose the problem.";
443     spc_error_struct.severity  = XeError;
444     spc_error_struct.use_errno = TRUE;
445     break;
446
447   case SPC_No_Pipe:
448     spc_error_struct.format    = (XeString) "><Cannot get pipe";
449     spc_error_struct.severity  = XeError;
450     spc_error_struct.use_errno = TRUE;
451     break;
452
453   case SPC_No_Pty:
454     spc_error_struct.format    = (XeString) "><Unable to allocate pty for a DTSPCD channel.\nTry cleaning up some currently running processes to release their ptys,\nor reconfigure your kernel to increase the pty limit.";
455     spc_error_struct.severity  = XeError;
456     spc_error_struct.use_errno = TRUE;
457     break;
458
459   case SPC_Bad_Connector:
460     spc_error_struct.format    = (XeString) "><Bad connector";
461     spc_error_struct.severity  = XeError;
462     spc_error_struct.use_errno = FALSE;
463     break;
464
465   case SPC_Reading:
466     spc_error_struct.format    = (XeString) "><Unexpected error reading data on connection to host %s.\nUse the following errno value to correct the problem.";
467     spc_error_struct.severity  = XeError;
468     spc_error_struct.use_errno = TRUE;
469     break;
470
471   case SPC_Writing:
472     spc_error_struct.format    = (XeString) "><Unexpected error writing data on channel";
473     spc_error_struct.severity  = XeError;
474     spc_error_struct.use_errno = TRUE;
475     break;
476
477   case SPC_Bad_Service:
478     spc_error_struct.format    = (XeString) "><Unknown internet service %s/%s.\nMake an entry in your /etc/services file";
479     spc_error_struct.severity  = XeError;
480     spc_error_struct.use_errno = TRUE;
481     break;
482
483   case SPC_Unknown_Host:
484     spc_error_struct.format    = (XeString) "><Unable to find a host entry for %s.\nTry adding an entry in /etc/hosts for it.";
485     spc_error_struct.severity  = XeError;
486     spc_error_struct.use_errno = FALSE;
487     break;
488
489   case SPC_Bad_Socket:
490     spc_error_struct.format    = (XeString) "><Socket failed";
491     spc_error_struct.severity  = XeError;
492     spc_error_struct.use_errno = TRUE;
493     break;
494
495   case SPC_Bad_Connect:
496     spc_error_struct.format    = (XeString) "><Connect call failed to remote host %s\nPerhaps the desktop is not installed on the remote host,\nor the remote inetd program needs to be restarted (via 'inetd -c'),\nor the remote file /etc/inetd.conf does not have an entry for the dtspcd process.\n";
497     spc_error_struct.severity  = XeError;
498     spc_error_struct.use_errno = FALSE;
499     break;
500
501   case SPC_Bad_Bind:
502     spc_error_struct.format    = (XeString) "><Bind failed";
503     spc_error_struct.severity  = XeError;
504     spc_error_struct.use_errno = TRUE;
505     break;
506
507   case SPC_Bad_Accept:
508     spc_error_struct.format    = (XeString) "><Accept failed";
509     spc_error_struct.severity  = XeError;
510     spc_error_struct.use_errno = TRUE;
511     break;
512
513   case SPC_Bad_Reuse:
514     spc_error_struct.format    = (XeString) "><Reuse socket option failed";
515     spc_error_struct.severity  = XeError;
516     spc_error_struct.use_errno = TRUE;
517     break;
518
519   case SPC_Bad_Open:
520     spc_error_struct.format    = (XeString) "><Cannot open file";
521     spc_error_struct.severity  = XeError;
522     spc_error_struct.use_errno = TRUE;
523     break;
524
525   case SPC_Connection_EOF:
526     if (SPC_who_am_i == SPC_I_AM_A_DAEMON)
527       spc_error_struct.format    = (XeString) "><Client has disconneted (received EOF).";
528     else
529       spc_error_struct.format    = (XeString) "><The dtspcd process on host '%s' has terminated.";
530     spc_error_struct.severity  = XeError;
531     spc_error_struct.use_errno = FALSE;
532     break;
533
534   case SPC_Timeout:
535     spc_error_struct.format    = (XeString) "><Internal timeout expired";
536     spc_error_struct.severity  = XeError;
537     spc_error_struct.use_errno = FALSE;
538     break;
539
540   case SPC_Protocol:
541     spc_error_struct.format    = (XeString) "><Illegal protocol request";
542     spc_error_struct.severity  = XeError;
543     spc_error_struct.use_errno = FALSE;
544     break;
545
546   case SPC_Unexpected_Reply:
547     spc_error_struct.format    = (XeString) "><Protocol error: unexpected reply";
548     spc_error_struct.severity  = XeError;
549     spc_error_struct.use_errno = FALSE;
550     break;
551
552   case SPC_No_Channel:
553     spc_error_struct.format    = (XeString) "><Cannot initialize channel";
554     spc_error_struct.severity  = XeError;
555     spc_error_struct.use_errno = FALSE;
556     break;
557
558   case SPC_Illegal_Iomode:
559     spc_error_struct.format    = (XeString) "><Inconsistent iomode value specified";
560     spc_error_struct.severity  = XeError;
561     spc_error_struct.use_errno = FALSE;
562     break;
563
564   case SPC_No_Signal_Handler:
565     spc_error_struct.format    = (XeString) "><Cannot set SIGCLD handler";
566     spc_error_struct.severity  = XeError;
567     spc_error_struct.use_errno = TRUE;
568     break;
569
570   case SPC_Bad_Operation:
571     spc_error_struct.format    = (XeString) "><Illegal operation";
572     spc_error_struct.severity  = XeError;
573     spc_error_struct.use_errno = FALSE;
574     break;
575
576   case SPC_Bad_Fd:
577     spc_error_struct.format    = (XeString) "><Bad file descriptor";
578     spc_error_struct.severity  = XeError;
579     spc_error_struct.use_errno = FALSE;
580     break;
581
582   case SPC_Bad_Ioctl:
583     spc_error_struct.format    = (XeString) "><ioctl call failed";
584     spc_error_struct.severity  = XeError;
585     spc_error_struct.use_errno = TRUE;
586     break;
587
588   case SPC_Bad_Select:
589     spc_error_struct.format    = (XeString) "><select call failed";
590     spc_error_struct.severity  = XeError;
591     spc_error_struct.use_errno = TRUE;
592     break;
593
594   case SPC_Bind_Timeout:
595     spc_error_struct.format    = (XeString) "><Timeout on bind";
596     spc_error_struct.severity  = XeWarning;
597     spc_error_struct.use_errno = FALSE;
598     break;
599
600   case SPC_Arg_Too_Long:
601     spc_error_struct.format    = (XeString) "><Argument %.50s... to DTSPCD system call is too long, max. length is %d";
602     spc_error_struct.severity  = XeError;
603     spc_error_struct.use_errno = FALSE;
604     break;
605
606   case SPC_Write_Prot:
607     spc_error_struct.format    = (XeString) "><Error writing protocol request to host %s.\nPerhaps the remote server has crashed.\nUse the following errno value to diagnose the problem.";
608     spc_error_struct.severity  = XeError;
609     spc_error_struct.use_errno = TRUE;
610     break;
611
612   case SPC_Bad_Username:
613     spc_error_struct.format    = (XeString) "><Incorrect user name";
614     spc_error_struct.severity  = XeFatalError;
615     spc_error_struct.use_errno = FALSE;
616     break;
617
618   case SPC_Bad_Password:
619     spc_error_struct.format    = (XeString) "><Incorrect password";
620     spc_error_struct.severity  = XeFatalError;
621     spc_error_struct.use_errno = FALSE;
622     break;
623
624   case SPC_Client_Not_Valid:
625     spc_error_struct.format    = (XeString) "><Client not valid";
626     spc_error_struct.severity  = XeError;
627     spc_error_struct.use_errno = FALSE;
628     break;
629
630   case SPC_Cannot_Open_Slave:
631     spc_error_struct.format    = (XeString) "><Unable to open slave pty %s.\nUse the following errno value to correct the problem";
632     spc_error_struct.severity  = XeError;
633     spc_error_struct.use_errno = TRUE;
634     break;
635
636   case SPC_Protocol_Abort:
637     spc_error_struct.format    = (XeString) "><Received ABORT protocol request on connection to %s.";
638     spc_error_struct.severity  = XeFatalError;
639     spc_error_struct.use_errno = FALSE;
640     break;
641
642   case SPC_Env_Too_Big:
643     spc_error_struct.format    = (XeString) "><Environment variable %.50s... too big,\nmaximum size is %d\n";
644     spc_error_struct.severity  = XeError;
645     spc_error_struct.use_errno = FALSE;
646     break;
647
648   case SPC_Unlink_Logfile:
649     spc_error_struct.format    = (XeString) "><Cannot unlink logfile";
650     spc_error_struct.severity  = XeError;
651     spc_error_struct.use_errno = TRUE;
652     break;
653
654   case SPC_Closed_Channel:
655     spc_error_struct.format    = (XeString) "><Channel already closed";
656     spc_error_struct.severity  = XeError;
657     spc_error_struct.use_errno = FALSE;
658     break;
659
660   case SPC_Bad_Authentication:
661     spc_error_struct.format    = (XeString) "><Cannot open user authentication file";
662     spc_error_struct.severity  = XeFatalError;
663     spc_error_struct.use_errno = FALSE;
664     break;
665
666   case SPC_Cannot_Open_Log:
667     spc_error_struct.format    = (XeString) "><Unable to open log file %s\nUse the following errno value to correct the problem";
668     spc_error_struct.severity  = XeError;
669     spc_error_struct.use_errno = FALSE;
670     break;
671
672   case SPC_Connection_Reset:
673     spc_error_struct.format    = (XeString) "><Remote data connection to %s reset by peer\nRemote host may not have an entry for the local host in /usr/adm/inetd.sec.";
674     spc_error_struct.severity  = XeError;
675     spc_error_struct.use_errno = FALSE;
676     break;
677
678   case SPC_Register_Username:
679     spc_error_struct.format    = (XeString) "><Cannot register user --\nImproper password or uid for user '%s' on remote host '%s'.";
680     spc_error_struct.severity  = XeError;
681     spc_error_struct.use_errno = FALSE;
682     break;
683
684   case SPC_Register_Netrc:
685     spc_error_struct.format    = (XeString) "><Cannot register user --\nUnable to create a pathname to the authentication file '%s' on host '%s'.";
686     spc_error_struct.severity  = XeError;
687     spc_error_struct.use_errno = FALSE;
688     break;
689
690   case SPC_Register_Open:
691     spc_error_struct.format    = (XeString) "><Cannot register user --\nUnable to open authentication file '%s' on host '%s'.\nUse the following errno value to diagnose the problem.";
692     spc_error_struct.severity  = XeError;
693     spc_error_struct.use_errno = TRUE;
694     break;
695
696   case SPC_Register_Handshake:
697     spc_error_struct.format    = (XeString) "><Cannot register user --\nPerhaps user '%s' does not have the same uid on host '%s'.";
698     spc_error_struct.severity  = XeError;
699     spc_error_struct.use_errno = FALSE;
700     break;
701
702  case SPC_Bad_Termios_Mode :
703     spc_error_struct.format    = (XeString) "><An error has been detected in the TERMIOS_REQUEST data.\nThe item '%s' is not recognized as a valid item for the Mode flags.\nThe item has been ignored.\n";
704     spc_error_struct.severity  = XeError;
705     spc_error_struct.use_errno = FALSE;
706     break;
707
708  case SPC_Bad_Termios_Speed :
709     spc_error_struct.format    = (XeString) "><An error has been detected in the TERMIOS_REQUEST data.\nThe item '%s' is not recognized as a valid item for a speed setting.\nThe item has been ignored.\n";
710     spc_error_struct.severity  = XeError;
711     spc_error_struct.use_errno = FALSE;
712     break;
713
714  case SPC_Bad_Termios_CC :
715     spc_error_struct.format    = (XeString) "><An error has been detected in the TERMIOS_REQUEST data.\nThe item '%s' is not recognized as a valid item for a Control Character name/value pair.\nThe item has been ignored.\n";
716     spc_error_struct.severity  = XeError;
717     spc_error_struct.use_errno = FALSE;
718     break;
719
720  case SPC_Bad_Termios_Proto :
721     spc_error_struct.format    = (XeString) "><An error has been detected in the TERMIOS_REQUEST data.\nThe string does not have the correct number of fields -- %s.\n";
722     spc_error_struct.severity  = XeError;
723     spc_error_struct.use_errno = FALSE;
724     break;
725
726   case SPC_Bad_Signal_Name :
727     spc_error_struct.format    = (XeString) "><The signal '%s' is not supported on this machine.\nThe DTSPCD signal request has been ignored.\n";
728     spc_error_struct.severity  = XeError;
729     spc_error_struct.use_errno = FALSE;
730     break;
731
732   case SPC_Bad_Signal_Value :
733     spc_error_struct.format    = (XeString) "><The signal %d is not supported by the XeSignalToName() routine.\nIt can not be sent via DTSPCD to a remote machine.\n";
734     spc_error_struct.severity  = XeError;
735     spc_error_struct.use_errno = FALSE;
736     break;
737
738   case SPC_Bad_Signal_Format :
739     spc_error_struct.format    = (XeString) "><The APPLICATION_SIGNAL DTSPCD data '%s' is not recognized.\nIt is expected to be a signal name or a signal number.\n";
740     spc_error_struct.severity  = XeError;
741     spc_error_struct.use_errno = FALSE;
742     break;
743
744   case SPC_Bad_tc_Call :
745     spc_error_struct.format    = (XeString) "><The terminal control call to '%s' failed.";
746     spc_error_struct.severity  = XeError;
747     spc_error_struct.use_errno = TRUE;
748     break;
749
750   case SPC_cannot_Chdir :
751     spc_error_struct.format    = (XeString) "><Cannot cd to directory '%s'.";
752     spc_error_struct.severity  = XeError;
753     spc_error_struct.use_errno = TRUE;
754     break;
755
756   case SPC_Bad_Permission :
757     spc_error_struct.format    = (XeString) "><Incorrect permission on DTSPCD Authentication file.";
758     spc_error_struct.severity  = XeError;
759     spc_error_struct.use_errno = TRUE;
760     break;
761     
762   case SPC_Cannot_Create_Netfilename :
763     spc_error_struct.format    = (XeString) "><Cannot create a pathname to the current working\ndirectory '%s' from host '%s'.";
764     spc_error_struct.severity  = XeError;
765     spc_error_struct.use_errno = FALSE;
766     break;
767     
768   case SPC_Protocol_Version_Error:
769     spc_error_struct.format    = (XeString) "><SPC protocol version mismatch.  The local version is %d, but the version of the SPC Daemon is %d.  This operation requires equivalent protocol versions.";
770     spc_error_struct.severity  = XeError;
771     spc_error_struct.use_errno = FALSE;
772     break;
773
774   default:
775     spc_error_struct.format    = (XeString) "><Unknown error code";
776     spc_error_struct.severity  = XeError;
777     spc_error_struct.use_errno = FALSE;
778     break;
779   }
780     
781   _DtSvcProcessUnlock();
782   return(&spc_error_struct);
783 }
784