xref: /original-bsd/bin/ls/util.c (revision d272e02a)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Michael Fischbein.
7  *
8 %sccs.include.redist.c%
9  */
10 
11 #ifndef lint
12 static char sccsid[] = "@(#)util.c	5.8 (Berkeley) 07/22/90";
13 #endif /* not lint */
14 
15 #include <sys/types.h>
16 #include <stdio.h>
17 #include <ctype.h>
18 
19 prcopy(src, dest, len)
20 	register char *src, *dest;
21 	register int len;
22 {
23 	register int ch;
24 
25 	while(len--) {
26 		ch = *src++;
27 		*dest++ = isprint(ch) ? ch : '?';
28 	}
29 }
30 
31 char
32 *emalloc(size)
33 	u_int size;
34 {
35 	char *retval, *malloc();
36 
37 	if (!(retval = malloc(size)))
38 		nomem();
39 	return(retval);
40 }
41 
42 nomem()
43 {
44 	(void)fprintf(stderr, "ls: out of memory.\n");
45 	exit(1);
46 }
47 
48 usage()
49 {
50 	(void)fprintf(stderr, "usage: ls [-1ACFLRTacdfgiklqrstu] [file ...]\n");
51 	exit(1);
52 }
53