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