comparison lib/lib.c @ 124:ef2bc92d5fb0

Work around uClibc weirdness.
author Rob Landley <rob@landley.net>
date Thu, 07 Jun 2007 15:19:44 -0400
parents 19b5567f0a1b
children 7b22987a7b47
comparison
equal deleted inserted replaced
123:81a324ef9167 124:ef2bc92d5fb0
9 * Copyright 2006 Rob Landley <rob@landley.net> 9 * Copyright 2006 Rob Landley <rob@landley.net>
10 */ 10 */
11 11
12 #include "toys.h" 12 #include "toys.h"
13 13
14 #ifndef __UCLIBC__
15
16 // uClibc has this, and if we define our own it conflicts.
17
18 // Like strncpy but always null terminated.
19 void strlcpy(char *dest, char *src, size_t size)
20 {
21 strncpy(dest,src,size);
22 dest[size-1] = 0;
23 }
24 #endif
25
26
14 void verror_msg(char *msg, int err, va_list va) 27 void verror_msg(char *msg, int err, va_list va)
15 { 28 {
16 fprintf(stderr, "%s: ", toys.which->name); 29 fprintf(stderr, "%s: ", toys.which->name);
17 vfprintf(stderr, msg, va); 30 vfprintf(stderr, msg, va);
18 if (err) fprintf(stderr, ": %s", strerror(err)); 31 if (err) fprintf(stderr, ": %s", strerror(err));
64 77
65 // Stub until the online help system goes in. 78 // Stub until the online help system goes in.
66 void usage_exit(void) 79 void usage_exit(void)
67 { 80 {
68 exit(1); 81 exit(1);
69 }
70
71 // Like strncpy but always null terminated.
72 void strlcpy(char *dest, char *src, size_t size)
73 {
74 strncpy(dest,src,size);
75 dest[size-1] = 0;
76 } 82 }
77 83
78 // Die unless we can allocate memory. 84 // Die unless we can allocate memory.
79 void *xmalloc(size_t size) 85 void *xmalloc(size_t size)
80 { 86 {