13 cerr = malloc_chk(sizeof(CERR), "cerr");
25 CERRLIST *cerrlist = NULL;
30 void addcerrlist(int errc, CERR errv[])
33 CERRLIST *p = NULL, *q = malloc_chk(sizeof(CERRLIST), "cerrlist");
35 assert(errc > 0 && errv != NULL);
36 for(i = 0; i < errc; i++) {
40 p = p->next = malloc_chk(sizeof(CERRLIST), "cerrlist.next");
56 if(cerrlist == NULL) {
57 puts("error list is null.");
59 for(p = cerrlist; p != NULL; p = p->next) {
60 printf("%d: %s\n", p->cerr->num, p->cerr->msg);
68 void setcerr(int num, const char *str)
73 cerr->msg = malloc_chk(CERRMSGSIZE + 1, "cerr.msg");
74 if(0 < strlen(str) && strlen(str) <= CERRSTRSIZE) {
75 sprintf(cerr->msg, "%s: %s", str, getcerrmsg(cerr->num));
77 strcpy(cerr->msg, getcerrmsg(cerr->num));
82 * エラーリストから、エラー番号に対応するメッセージを返す
84 char *getcerrmsg(int num)
87 char *msg = "unknown error";
89 for(p = cerrlist; p != NULL; p = p->next) {
90 if(num == p->cerr->num) {
103 CERRLIST *p = cerrlist, *q;
110 for(p = cerrlist; p != NULL; p = q) {