home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / fonts / lib / fs / FSErrDis.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-13  |  3.4 KB  |  89 lines

  1. /* $XConsortium: FSErrDis.c,v 1.2 91/05/13 15:11:29 gildea Exp $ */
  2.  
  3. /* @(#)FSErrDis.c    4.1    91/05/02
  4.  * Copyright 1990 Network Computing Devices;
  5.  * Portions Copyright 1987 by Digital Equipment Corporation and the
  6.  * Massachusetts Institute of Technology
  7.  *
  8.  * Permission to use, copy, modify, and distribute this protoype software
  9.  * and its documentation to Members and Affiliates of the MIT X Consortium
  10.  * any purpose and without fee is hereby granted, provided
  11.  * that the above copyright notice appear in all copies and that both that
  12.  * copyright notice and this permission notice appear in supporting
  13.  * documentation, and that the names of Network Computing Devices, Digital or
  14.  * MIT not be used in advertising or publicity pertaining to distribution of
  15.  * the software without specific, written prior permission.
  16.  *
  17.  * NETWORK COMPUTING DEVICES, DIGITAL AND MIT DISCLAIM ALL WARRANTIES WITH
  18.  * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  19.  * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, DIGITAL OR MIT BE
  20.  * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  21.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  22.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  23.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  */
  25.  
  26. #include <stdio.h>
  27. #include <X11/Xos.h>
  28. #include "FSlibint.h"
  29.  
  30. char       *FSErrorList[] = {
  31.      /* FSBadRequest     */ "BadRequest, invalid request code or no such operation",
  32.      /* FSBadFormat     */ "BadFormat, bad font format mask",
  33.      /* FSBadFont     */ "BadFont, invalid Font parameter",
  34.      /* FSBadRange     */ "BadRange, invalid character range attributes",
  35.      /* FSBadEventMask     */ "BadEventMask, illegal event mask",
  36.      /* FSBadAccessContext */ "BadAccessContext, insufficient permissions for operation",
  37.      /* FSBadIDChoice  */ "BadIDChoice, invalid resource ID chosen for this connection",
  38.      /* FSBadName     */ "BadName, named font does not exist",
  39.      /* FSBadResolution     */ "BadResolution, improperly formatted resolution",
  40.      /* FSBadAlloc     */ "BadAlloc, insufficient resources for operation",
  41.      /* FSBadLength     */ "BadLength, request too large or internal FSlib length error",
  42.      /* FSBadImplementation */ "BadImplementation, request unsupported",
  43. };
  44. int         FSErrorListSize = sizeof(FSErrorList);
  45.  
  46.  
  47. FSGetErrorText(svr, code, buffer, nbytes)
  48.     register int code;
  49.     register FSServer *svr;
  50.     char       *buffer;
  51.     int         nbytes;
  52. {
  53.  
  54.     char       *defaultp = NULL;
  55.     char        buf[32];
  56.     register _FSExtension *ext;
  57.  
  58.     if (nbytes == 0)
  59.     return;
  60.     sprintf(buf, "%d", code);
  61.     if (code <= (FSErrorListSize / sizeof(char *)) && code > 0) {
  62.     defaultp = FSErrorList[code];
  63.     FSGetErrorDatabaseText(svr, "FSProtoError", buf, defaultp, buffer, nbytes);
  64.     }
  65.     ext = svr->ext_procs;
  66.     while (ext) {        /* call out to any extensions interested */
  67.     if (ext->error_string != NULL)
  68.         (*ext->error_string) (svr, code, &ext->codes, buffer, nbytes);
  69.     ext = ext->next;
  70.     }
  71.     return;
  72. }
  73.  
  74. /* ARGSUSED */
  75. FSGetErrorDatabaseText(svr, name, type, defaultp, buffer, nbytes)
  76.     register char *name,
  77.                *type;
  78.     char       *defaultp;
  79.     FSServer     *svr;
  80.     char       *buffer;
  81.     int         nbytes;
  82. {
  83.     if (nbytes == 0)
  84.     return;
  85.     (void) strncpy(buffer, (char *) defaultp, nbytes);
  86.     if ((strlen(defaultp) + 1) > nbytes)
  87.     buffer[nbytes - 1] = '\0';
  88. }
  89.