Print this page
XXXX update sendmail to 8.14.9
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/sendmail/include/sm/exc.h
+++ new/usr/src/cmd/sendmail/include/sm/exc.h
1 1 /*
2 - * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
2 + * Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers.
3 3 * All rights reserved.
4 4 *
5 5 * By using this file, you agree to the terms and conditions set
6 6 * forth in the LICENSE file which can be found at the top level of
7 7 * the sendmail distribution.
8 8 *
9 - * $Id: exc.h,v 1.23 2001/06/07 20:04:53 ca Exp $
9 + * $Id: exc.h,v 1.24 2013-11-22 20:51:31 ca Exp $
10 10 */
11 11
12 -#pragma ident "%Z%%M% %I% %E% SMI"
13 -
14 12 /*
15 13 ** libsm exception handling
16 14 ** See libsm/exc.html for documentation.
17 15 */
18 16
19 17 #ifndef SM_EXC_H
20 18 # define SM_EXC_H
21 19
22 20 #include <sm/setjmp.h>
23 21 #include <sm/io.h>
24 22 #include <sm/gen.h>
25 23 #include <sm/assert.h>
26 24
27 25 typedef struct sm_exc SM_EXC_T;
28 26 typedef struct sm_exc_type SM_EXC_TYPE_T;
29 27 typedef union sm_val SM_VAL_T;
30 28
31 29 /*
32 30 ** Exception types
33 31 */
34 32
35 33 extern const char SmExcTypeMagic[];
36 34
37 35 struct sm_exc_type
38 36 {
39 37 const char *sm_magic;
40 38 const char *etype_category;
41 39 const char *etype_argformat;
42 40 void (*etype_print) __P((SM_EXC_T *, SM_FILE_T *));
43 41 const char *etype_printcontext;
44 42 };
45 43
46 44 extern const SM_EXC_TYPE_T SmEtypeOs;
47 45 extern const SM_EXC_TYPE_T SmEtypeErr;
48 46
49 47 extern void
50 48 sm_etype_printf __P((
51 49 SM_EXC_T *_exc,
52 50 SM_FILE_T *_stream));
53 51
54 52 /*
55 53 ** Exception objects
56 54 */
57 55
58 56 extern const char SmExcMagic[];
59 57
60 58 union sm_val
61 59 {
62 60 int v_int;
63 61 long v_long;
64 62 char *v_str;
65 63 SM_EXC_T *v_exc;
66 64 };
67 65
68 66 struct sm_exc
69 67 {
70 68 const char *sm_magic;
71 69 size_t exc_refcount;
72 70 const SM_EXC_TYPE_T *exc_type;
73 71 SM_VAL_T *exc_argv;
74 72 };
75 73
76 74 # define SM_EXC_INITIALIZER(type, argv) \
77 75 { \
78 76 SmExcMagic, \
79 77 0, \
80 78 type, \
81 79 argv, \
82 80 }
83 81
84 82 extern SM_EXC_T *
85 83 sm_exc_new_x __P((
86 84 const SM_EXC_TYPE_T *_type,
87 85 ...));
88 86
89 87 extern SM_EXC_T *
90 88 sm_exc_addref __P((
91 89 SM_EXC_T *_exc));
92 90
93 91 extern void
94 92 sm_exc_free __P((
95 93 SM_EXC_T *_exc));
96 94
97 95 extern bool
98 96 sm_exc_match __P((
99 97 SM_EXC_T *_exc,
100 98 const char *_pattern));
101 99
102 100 extern void
103 101 sm_exc_write __P((
104 102 SM_EXC_T *_exc,
105 103 SM_FILE_T *_stream));
106 104
107 105 extern void
108 106 sm_exc_print __P((
109 107 SM_EXC_T *_exc,
110 108 SM_FILE_T *_stream));
111 109
112 110 extern SM_DEAD(void
113 111 sm_exc_raise_x __P((
114 112 SM_EXC_T *_exc)));
115 113
116 114 extern SM_DEAD(void
117 115 sm_exc_raisenew_x __P((
118 116 const SM_EXC_TYPE_T *_type,
119 117 ...)));
120 118
121 119 /*
122 120 ** Exception handling
123 121 */
124 122
125 123 typedef void (*SM_EXC_DEFAULT_HANDLER_T) __P((SM_EXC_T *));
126 124
127 125 extern void
128 126 sm_exc_newthread __P((
129 127 SM_EXC_DEFAULT_HANDLER_T _handle));
130 128
131 129 typedef struct sm_exc_handler SM_EXC_HANDLER_T;
132 130 struct sm_exc_handler
133 131 {
134 132 SM_EXC_T *eh_value;
135 133 SM_JMPBUF_T eh_context;
136 134 SM_EXC_HANDLER_T *eh_parent;
137 135 int eh_state;
138 136 };
139 137
140 138 /* values for eh_state */
141 139 enum
142 140 {
143 141 SM_EH_PUSHED = 2,
144 142 SM_EH_POPPED = 0,
145 143 SM_EH_HANDLED = 1
146 144 };
147 145
148 146 extern SM_EXC_HANDLER_T *SmExcHandler;
149 147
150 148 # define SM_TRY { SM_EXC_HANDLER_T _h; \
151 149 do { \
152 150 _h.eh_value = NULL; \
153 151 _h.eh_parent = SmExcHandler; \
154 152 _h.eh_state = SM_EH_PUSHED; \
155 153 SmExcHandler = &_h; \
156 154 if (sm_setjmp_nosig(_h.eh_context) == 0) {
157 155
158 156 # define SM_FINALLY SM_ASSERT(SmExcHandler == &_h); \
159 157 } \
160 158 if (sm_setjmp_nosig(_h.eh_context) == 0) {
161 159
162 160 # define SM_EXCEPT(e,pat) } \
163 161 if (_h.eh_state == SM_EH_HANDLED) \
164 162 break; \
165 163 if (_h.eh_state == SM_EH_PUSHED) { \
166 164 SM_ASSERT(SmExcHandler == &_h); \
167 165 SmExcHandler = _h.eh_parent; \
168 166 } \
169 167 _h.eh_state = sm_exc_match(_h.eh_value,pat) \
170 168 ? SM_EH_HANDLED : SM_EH_POPPED; \
171 169 if (_h.eh_state == SM_EH_HANDLED) { \
172 170 SM_UNUSED(SM_EXC_T *e) = _h.eh_value;
173 171
174 172 # define SM_END_TRY } \
175 173 } while (0); \
176 174 if (_h.eh_state == SM_EH_PUSHED) { \
177 175 SM_ASSERT(SmExcHandler == &_h); \
178 176 SmExcHandler = _h.eh_parent; \
179 177 if (_h.eh_value != NULL) \
180 178 sm_exc_raise_x(_h.eh_value); \
181 179 } else if (_h.eh_state == SM_EH_POPPED) { \
182 180 if (_h.eh_value != NULL) \
183 181 sm_exc_raise_x(_h.eh_value); \
184 182 } else \
185 183 sm_exc_free(_h.eh_value); \
186 184 }
187 185
188 186 #endif /* SM_EXC_H */
|
↓ open down ↓ |
165 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX