* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
* All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Lawrence Berkeley Laboratories.
* %sccs.include.redist.c%
* @(#)util.c 8.1 (Berkeley) %G%
static void nomem
__P((void));
static void vxerror
__P((const char *, int, const char *, va_list));
* Malloc, with abort on error.
if ((p
= malloc(size
)) == NULL
)
* Realloc, with abort on error.
if ((p
= realloc(p
, size
)) == NULL
)
(void)fprintf(stderr
, "config: out of memory\n");
* Prepend the compilation directory to a file name.
#define CDIR "../../compile/"
cp
= emalloc(sizeof(CDIR
) + strlen(confdirbase
));
(void)sprintf(cp
, "%s%s", CDIR
, confdirbase
);
cp
= emalloc(sizeof(CDIR
) + strlen(confdirbase
) + 1 +
(void)sprintf(cp
, "%s%s/%s", CDIR
, confdirbase
, file
);
static struct nvlist
*nvhead
;
register struct nvlist
*nv
;
if ((nv
= nvhead
) == NULL
)
nv
= emalloc(sizeof(*nv
));
* Free an nvlist structure (just one).
register struct nvlist
*nv
;
* Free an nvlist (the whole list).
register struct nvlist
*nv
;
register struct nvlist
*next
;
for (; nv
!= NULL
; nv
= next
) {
* External (config file) error. Complain, using current file
error(const char *fmt
, ...)
extern const char *yyfile
;
vxerror(yyfile
, currentline(), fmt
, ap
);
* Delayed config file error (i.e., something was wrong but we could not
* find out about it until later).
xerror(const char *file
, int line
, const char *fmt
, ...)
xerror(file
, line
, fmt
, va_alist
)
vxerror(file
, line
, fmt
, ap
);
* Internal form of error() and xerror().
vxerror(file
, line
, fmt
, ap
)
(void)fprintf(stderr
, "%s:%d: ", file
, line
);
(void)vfprintf(stderr
, fmt
, ap
);
(void)putc('\n', stderr
);
panic(const char *fmt
, ...)
(void)fprintf(stderr
, "config: panic: ");
(void)vfprintf(stderr
, fmt
, ap
);
(void)putc('\n', stderr
);