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