13 bool addcerrlist(int newerrc, CERRARRAY newerrv[])
18 assert(newerrc > 0 && newerrv != NULL);
25 if((p = q->next = malloc(sizeof(CERRLIST *))) == NULL) {
28 } else if((p = cerr = malloc(sizeof(CERRLIST *))) == NULL) {
31 for(i = 0; i < newerrc; i++) {
32 p->err = &(newerrv[i]);
33 if((p->next = malloc(sizeof(CERRLIST *))) == NULL) {
42 fprintf(stderr, "addcerrlist: cannot allocate memory\n");
46 /* エラー番号とエラーメッセージを設定する */
47 void setcerr(int num, const char *str)
50 cerrmsg = malloc(CERRMSGSIZE + 1);
51 if(str != NULL && strlen(str) <= CERRSTRSIZE) {
52 sprintf(cerrmsg, "%s: %s", str, getcerrmsg(cerrno));
54 strcpy(cerrmsg, getcerrmsg(cerrno));
58 /* リストから、エラー番号に対応するメッセージを返す */
59 char *getcerrmsg(int num)
63 for(p = cerr; p != NULL; p = p->next) {
64 if(num == p->err->num) {
68 return "unkown error";
76 if(strlen(cerrmsg) > 0) {