Commit | Line | Data |
---|---|---|
4454bb03 KB |
1 | /* |
2 | * Copyright (c) 1989 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
6 | * provided that the above copyright notice and this paragraph are | |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
16 | */ | |
17 | ||
18 | #ifndef lint | |
cbe4b98c | 19 | static char sccsid[] = "@(#)util.c 5.3 (Berkeley) %G%"; |
4454bb03 KB |
20 | #endif /* not lint */ |
21 | ||
22 | #include <sys/param.h> | |
cbe4b98c | 23 | #include <errno.h> |
4454bb03 | 24 | #include <stdio.h> |
38dde0cd | 25 | #include <string.h> |
cbe4b98c | 26 | #include <stdlib.h> |
4454bb03 KB |
27 | |
28 | char * | |
29 | rlink(name) | |
30 | char *name; | |
31 | { | |
4454bb03 KB |
32 | extern char path[]; |
33 | int len; | |
34 | static char lbuf[MAXPATHLEN]; | |
35 | ||
36 | len = readlink(name, lbuf, sizeof(lbuf)); | |
37 | if (len == -1) { | |
38 | (void)fprintf(stderr, "mtree: %s: %s.\n", | |
39 | path + 2, strerror(errno)); | |
40 | exit(1); | |
41 | } | |
42 | lbuf[len] = '\0'; | |
43 | return(lbuf); | |
44 | } | |
45 | ||
4454bb03 KB |
46 | char * |
47 | emalloc(size) | |
48 | int size; | |
49 | { | |
cbe4b98c | 50 | char *p; |
4454bb03 KB |
51 | |
52 | /* NOSTRICT */ | |
53 | if (!(p = malloc((u_int)size))) | |
54 | nomem(); | |
55 | bzero(p, size); | |
56 | return(p); | |
57 | } | |
58 | ||
59 | nomem() | |
60 | { | |
cbe4b98c | 61 | (void)fprintf(stderr, "mtree: %s.\n", strerror(ENOMEM)); |
4454bb03 KB |
62 | exit(1); |
63 | } |