エラーをリストで格納し、分散して追加するように修正
[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 #include <stdbool.h>
9
10 #ifndef ARRAYSIZE
11 #define ARRAYSIZE(array) (sizeof(array)/sizeof(array[0]))
12 #endif
13
14 /* エラー番号 */
15 extern int cerrno;
16
17 /* エラーメッセージ */
18 extern char *cerrmsg;
19
20 /* エラーコード配列 */
21 typedef struct {
22     int num;
23     char *msg;
24 } CERRARRAY;
25
26 /* エラーコードリスト */
27 typedef struct _CERRLIST {
28     struct _CERRLIST *next;
29     CERRARRAY *err;
30 } CERRLIST;
31
32 /* エラーメッセージ */
33 extern CERRLIST *cerr;
34
35 enum {
36     CERRSTRSIZE = 10,    /* エラーメッセージ中に挿入できる文字列のサイズ */
37     CERRMSGSIZE = 70,    /* エラーメッセージのサイズ */
38 };
39
40 /* エラーを追加する */
41 bool addcerrlist(int cerrc, CERRARRAY cerrv[]);
42
43 /* エラー番号とエラーメッセージを設定 */
44 void setcerr(int num, const char *str);
45
46 /* エラー番号からメッセージを返す */
47 char *getcerrmsg(int num);
48
49 /* エラーを解放する */
50 void freecerr();
51 #endif