READMEのCASL II仕様書へのリンクを修正
[YACASL2.git] / include / cerr.h
1 #ifndef YACASL2_CERR_H_INCLUDED
2 #define YACASL2_CERR_H_INCLUDED
3
4 #include <stdbool.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <assert.h>
9 #include <stdbool.h>
10 #include "cmem.h"
11
12 /**
13  * @brief エラーを表すデータ型
14  */
15 typedef struct _CERR {
16     int num;        /**<エラー番号 */
17     char *msg;      /**<エラーメッセージ */
18 } CERR;
19
20 /**
21  * @brief 現在のエラー
22  */
23 extern CERR *cerr;
24
25 /**
26  * @brief エラーリストのデータ型
27  */
28 typedef struct _CERRLIST {
29     struct _CERRLIST *next;     /**<リスト次項目へのポインタ */
30     CERR *cerr;                 /**<エラーの構造体 */
31 } CERRLIST;
32
33 /**
34  * @brief エラーリスト
35  */
36 extern CERRLIST *cerrlist;
37
38 enum {
39     CERRSTRSIZE = 10,    /**<エラーメッセージ中に挿入できる文字列のサイズ */
40     CERRMSGSIZE = 70,    /**<エラーメッセージのサイズ */
41 };
42
43 /**
44  * @brief エラーを初期化する
45  *
46  * @return なし
47  */
48 void cerr_init();
49
50 /**
51  * @brief エラーリストを作成・追加する
52  *
53  * @return なし
54  *
55  * @param cerrc 作成または追加するエラーの数
56  * @param cerrv 作成または追加するエラーの配列
57  */
58 void addcerrlist(int cerrc, CERR cerrv[]);
59
60 /**
61  * @brief エラーリストを表示する
62  *
63  * @return なし
64  */
65 void printcerrlist();
66
67 /**
68  * @brief 現在のエラーを設定する
69  *
70  * @return なし
71  *
72  * @param num エラー番号
73  * @param *str エラーメッセージに含まれる文字列
74  */
75 void setcerr(int num, const char *str);
76
77 /**
78  * @brief エラー番号に対応するエラーメッセージを返す
79  *
80  * @return エラーメッセージ
81  *
82  * @param num エラー番号
83  */
84 char *getcerrmsg(int num);
85
86 /**
87  * @brief エラーリストと現在のエラーを解放する
88  *
89  * @return なし
90  */
91 void freecerr();
92 #endif