a67b65def6af9aebb71928700476e970f676135e
[YACASL2.git] / include / cerr.h
1 #ifndef YACASL2_CERR_H_INCLUDED
2 #define YACASL2_CERR_H_INCLUDED
3
4 #include <stdbool.h>
5 #include "cmem.h"
6
7 /**
8  * エラーの構造体
9  */
10 typedef struct _CERR {
11     int num;        /**<エラー番号 */
12     char *msg;      /**<エラーメッセージ */
13 } CERR;
14
15 /**
16  * 現在のエラー
17  */
18 extern CERR *cerr;
19
20 /**
21  * エラーリスト型
22  */
23 typedef struct _CERRLIST {
24     struct _CERRLIST *next;     /**<リスト次項目へのポインタ */
25     CERR *cerr;                 /**<エラーの構造体 */
26 } CERRLIST;
27
28 /**
29  * エラーリスト
30  */
31 extern CERRLIST *cerrlist;
32
33 enum {
34     CERRSTRSIZE = 10,    /**<エラーメッセージ中に挿入できる文字列のサイズ */
35     CERRMSGSIZE = 70,    /**<エラーメッセージのサイズ */
36 };
37
38 /**
39  * エラーの初期化
40  */
41 void cerr_init();
42
43 /**
44  * エラーリストを作成・追加する
45  */
46 bool addcerrlist(int cerrc, CERR cerrv[]);
47
48 /**
49  * エラーリストを表示する
50  */
51 void printcerrlist();
52
53 /**
54  * 現在のエラーを設定する
55  */
56 void setcerr(int num, const char *str);
57
58 /**
59  * エラーリストから、エラー番号に対応するメッセージを返す
60  */
61 char *getcerrmsg(int num);
62
63 /**
64  * エラーリストと現在のエラーを解放する
65  */
66 void freecerr();
67 #endif