- assert(cerr != NULL && num > 0);
-
- cerrno = num;
- cerrmsg = malloc(MSGSIZE + 1);
- if(val != NULL) {
- strcpy(cerrmsg, val);
- strcat(cerrmsg, ": ");
- strcat(cerrmsg, getcerrmsg(cerrno));
+ int i;
+ CERRLIST *p, *q;
+
+ assert(newerrc > 0 && newerrv != NULL);
+ if(cerrlist == NULL) {
+ p = cerrlist = malloc_chk(sizeof(CERRLIST), "cerrlist");
+ } else {
+ for(p = cerrlist; p != NULL; p = p->next) {
+ q = p;
+ }
+ p = q->next = malloc_chk(sizeof(CERRLIST), "cerrlist.next");
+ }
+ for(i = 0; i < newerrc; i++) {
+ p->cerr = &(newerrv[i]);
+ p->next = malloc_chk(sizeof(CERRLIST), "cerrlist.next");
+ q = p;
+ p = p->next;
+ }
+ q->next = NULL;
+ return true;
+}
+
+/* 現在のエラーを設定する */
+void setcerr(int num, const char *str)
+{
+ cerr->num = num;
+ cerr->msg = malloc_chk(CERRMSGSIZE + 1, "cerr.msg");
+ if(str != NULL && strlen(str) <= CERRSTRSIZE) {
+ sprintf(cerr->msg, "%s: %s", str, getcerrmsg(cerr->num));