home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / MPW / MPW cawf 4.0.9 / error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-01  |  2.6 KB  |  112 lines  |  [TEXT/KAHL]

  1. /*
  2.  *    error.c - error handling functions for cawf(1)
  3.  */
  4.  
  5. /*
  6.  *    Copyright (c) 1991 Purdue University Research Foundation,
  7.  *    West Lafayette, Indiana 47907.  All rights reserved.
  8.  *
  9.  *    Written by Victor A. Abell <abe@cc.purdue.edu>,  Purdue    University
  10.  *    Computing Center.  Not derived from licensed software; derived from
  11.  *    awf(1) by Henry Spencer of the University of Toronto.
  12.  *
  13.  *    Permission is granted to anyone to use this software for any
  14.  *    purpose on any computer system, and to alter it and redistribute
  15.  *    it freely, subject to the following restrictions:
  16.  *
  17.  *    1. The author is not responsible for any consequences of use of
  18.  *       this software, even if they arise from flaws in it.
  19.  *
  20.  *    2. The origin of this software must not be misrepresented, either
  21.  *       by explicit claim or by omission.  Credits must appear in the
  22.  *       documentation.
  23.  *
  24.  *    3. Altered versions must be plainly marked as such, and must not
  25.  *       be misrepresented as being the original software.  Credits must
  26.  *       appear in the documentation.
  27.  *
  28.  *    4. This notice may not be removed or altered.
  29.  */
  30.  
  31. #include "cawf.h"
  32.  
  33.  
  34. /*
  35.  * Error(t, l, s1, s2) - issue error message
  36.  */
  37.  
  38. void
  39. Error(t, l, s1, s2)
  40.     int t;                /* type: WARN or FATAL */
  41.     int l;                /* LINE: display Line[] */
  42.     char *s1, *s2;            /* optional text */
  43. {
  44.  
  45.     if (l == LINE)
  46.         (void) fprintf(Efs,
  47.  
  48. #if    defined(macintosh)
  49.             "File \"%s\"; Line %d; # %s:%s%s - %s\n",
  50.             Inname,
  51.             NR,
  52.             Pname,
  53. #else    /* !defined(macintosh) */
  54.             "%s: (%s, %d):%s%s - %s\n",
  55.             Pname,
  56.             Inname,
  57.             NR,
  58. #endif    /* defined(macintosh) */
  59.  
  60.             (s1 == NULL) ? "" : s1,
  61.             (s2 == NULL) ? "" : s2,
  62.             Line);
  63.     else
  64.         (void) fprintf(Efs, "%s%s:%s%s\n",
  65.  
  66. #if    defined(macintosh)
  67.             "# ",
  68. #else    /* !defined(macintosh) */
  69.             "",
  70. #endif    /* defined(macintosh) */
  71.  
  72.             Pname,
  73.             (s1 == NULL) ? "" : s1,
  74.             (s2 == NULL) ? "" : s2);
  75.     if (t == FATAL)
  76.         exit(1);
  77.     Err = 1;
  78.     return;
  79. }
  80.  
  81.  
  82. /*
  83.  * Error3(len, word, sarg, narg) - process error in pass3
  84.  */
  85.  
  86. void
  87. Error3(len, word, sarg, narg, msg)
  88.     int len;            /* length (negative is special */
  89.         char *word;            /* word */
  90.         char *sarg;            /* string argument */
  91.         int narg;                       /* numeric argument */
  92.     char *msg;            /* message */
  93. {
  94.     if (len == MESSAGE) {
  95.         (void) fprintf(Efs, "%s: (%s, %d) %s\n",
  96.             Pname,
  97.             (word == NULL) ? "<none>" : word,
  98.             narg,
  99.             (sarg == NULL) ? "<none>" : sarg);
  100.         return;
  101.     }
  102.     (void) fprintf(Efs,
  103.         "%s: pass3, len=%d, word=\"%s\", sarg=\"%s\", narg=%d%s%s\n",
  104.         Pname, len,
  105.         (word == NULL) ? "" : word,
  106.         (sarg == NULL) ? "" : sarg,
  107.         narg,
  108.         (msg == NULL) ? "" : " - ",
  109.         (msg == NULL) ? "" : msg);
  110.     Err = 1;
  111. }
  112.