エラー処理にリストを使うよう仕様変更
[YACASL2.git] / include / cerr.h
1 #ifndef YACASL2_CERR_H_INCLUDED
2 #define YACASL2_CERR_H_INCLUDED
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <assert.h>
8
9 #ifndef ARRAYSIZE
10 #define ARRAYSIZE(array) (sizeof(array)/sizeof(array[0]))
11 #endif
12
13 /* エラー番号 */
14 extern int cerrno;
15
16 /* エラーメッセージ */
17 extern char *cerrmsg;
18
19 /* エラーコード配列 */
20 typedef struct {
21     int num;
22     char *msg;
23 } CERRARRAY;
24
25 /* エラーコードリスト */
26 typedef struct _CERRLIST {
27     struct _CERRLIST *next;
28     CERRARRAY *err;
29 } CERRLIST;
30
31 /* エラーメッセージ */
32 extern CERRLIST *cerr;
33
34 enum {
35     CERRSTRSIZE = 10,    /* エラーメッセージ中に挿入できる文字列のサイズ */
36     CERRMSGSIZE = 70,    /* エラーメッセージのサイズ */
37 };
38
39 /* エラーを追加する */
40 void addcerrlist(int cerrc, CERRARRAY cerrv[]);
41
42 /* エラー番号とエラーメッセージを設定 */
43 void setcerr(int num, const char *str);
44
45 /* エラー番号からメッセージを返す */
46 char *getcerrmsg(int num);
47
48 /* エラーを解放する */
49 void freecerr();
50 #endif