]> git.sur5r.net Git - openldap/blob - build/unproto/error.c
ITS#2493: attributeoptions man page update
[openldap] / build / unproto / error.c
1 /*++
2 /* NAME
3 /*      error 3
4 /* SUMMARY
5 /*      diagnostics
6 /* PACKAGE
7 /*      unproto
8 /* SYNOPSIS
9 /*      #include "error.h"
10 /*
11 /*      int errcount;
12 /*
13 /*      void error(text)
14 /*      char *text;
15 /*
16 /*      void error_where(path, line, text)
17 /*      char *path;
18 /*      int line;
19 /*      char *text;
20 /*
21 /*      void fatal(text)
22 /*      char *text;
23 /* DESCRIPTION
24 /*      The routines in this file print a diagnostic (text). Some also
25 /*      terminate the program. Upon each error*() call, the errcount variable
26 /*      is incremented.
27 /*
28 /*      error() provides a default context, i.e. the source-file
29 /*      coordinate of the last read token.
30 /*
31 /*      error_where() allows the caller to explicitly specify context: path
32 /*      is a source-file name, and line is a line number.
33 /*
34 /*      fatal() is like error() but terminates the program with a non-zero
35 /*      exit status.
36 /*
37 /*      context is ignored if the line number is zero or if the path
38 /*      is an empty string.
39 /* AUTHOR(S)
40 /*      Wietse Venema
41 /*      Eindhoven University of Technology
42 /*      Department of Mathematics and Computer Science
43 /*      Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
44 /* LAST MODIFICATION
45 /*      92/01/15 21:53:10
46 /* VERSION/RELEASE
47 /*      1.2
48 /*--*/
49
50 static char error_sccsid[] = "@(#) error.c 1.2 92/01/15 21:53:10";
51
52 /* C library */
53
54 #include <stdio.h>
55
56 extern void exit();
57
58 /* Application-specific stuff */
59
60 #include "token.h"
61 #include "error.h"
62
63 int     errcount = 0;                   /* error counter */
64
65 /* error - report problem (implicit context) */
66
67 void    error(text)
68 char   *text;
69 {
70     error_where(in_path, in_line, text);
71 }
72
73 /* error_where - report problem (explicit context) */
74
75 void    error_where(path, line, text)
76 char   *path;
77 int     line;
78 char   *text;
79 {
80     errcount++;
81
82     /* Suppress context info if there is none. */
83
84     if (line && path[0])
85         fprintf(stderr, "%s, line %d: ", path, line);
86
87     fprintf(stderr, "%s\n", text);
88 }
89
90 /* fatal - report problem and terminate unsuccessfully */
91
92 void    fatal(text)
93 char   *text;
94 {
95     error(text);
96     exit(1);
97 }