diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-08-02 10:55:32 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-08-02 10:55:32 +0000 |
commit | be0c36009a342de3599d498d6f150030b6a75b98 (patch) | |
tree | 5af27e4751ecae51387a99872b66a8cd6e621caa /libbb | |
parent | 23b1e5c7df2e619654d0a53785fcdef5072b40ed (diff) | |
download | busybox-w32-be0c36009a342de3599d498d6f150030b6a75b98.tar.gz busybox-w32-be0c36009a342de3599d498d6f150030b6a75b98.tar.bz2 busybox-w32-be0c36009a342de3599d498d6f150030b6a75b98.zip |
More libc5 fixups
-Erik
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/libbb.h | 2 | ||||
-rw-r--r-- | libbb/libc5.c (renamed from libbb/daemon.c) | 84 |
2 files changed, 77 insertions, 9 deletions
diff --git a/libbb/libbb.h b/libbb/libbb.h index 70ac36a86..04ed2ae82 100644 --- a/libbb/libbb.h +++ b/libbb/libbb.h | |||
@@ -46,6 +46,8 @@ | |||
46 | typedef unsigned int socklen_t; | 46 | typedef unsigned int socklen_t; |
47 | /* libc5 doesn't implement BSD 4.4 daemon() */ | 47 | /* libc5 doesn't implement BSD 4.4 daemon() */ |
48 | extern int daemon (int nochdir, int noclose); | 48 | extern int daemon (int nochdir, int noclose); |
49 | /* libc5 doesn't implement strtok_r */ | ||
50 | char *strtok_r(char *s, const char *delim, char **ptrptr); | ||
49 | #endif | 51 | #endif |
50 | 52 | ||
51 | /* Some useful definitions */ | 53 | /* Some useful definitions */ |
diff --git a/libbb/daemon.c b/libbb/libc5.c index 6d4169ed5..20295fd4b 100644 --- a/libbb/daemon.c +++ b/libbb/libc5.c | |||
@@ -1,4 +1,77 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | |||
3 | |||
4 | #include <features.h> | ||
5 | #include <string.h> | ||
6 | #include <stdio.h> | ||
7 | #include <fcntl.h> | ||
8 | #include <paths.h> | ||
9 | #include <unistd.h> | ||
10 | |||
11 | |||
12 | #if __GNU_LIBRARY__ < 5 | ||
13 | |||
14 | |||
15 | /* Copyright (C) 1991 Free Software Foundation, Inc. | ||
16 | This file is part of the GNU C Library. | ||
17 | |||
18 | The GNU C Library is free software; you can redistribute it and/or | ||
19 | modify it under the terms of the GNU Library General Public License as | ||
20 | published by the Free Software Foundation; either version 2 of the | ||
21 | License, or (at your option) any later version. | ||
22 | |||
23 | The GNU C Library is distributed in the hope that it will be useful, | ||
24 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
26 | Library General Public License for more details. | ||
27 | |||
28 | You should have received a copy of the GNU Library General Public | ||
29 | License along with the GNU C Library; see the file COPYING.LIB. If | ||
30 | not, write to the Free Software Foundation, Inc., 675 Mass Ave, | ||
31 | Cambridge, MA 02139, USA. */ | ||
32 | |||
33 | /* | ||
34 | * Modified by Manuel Novoa III Mar 1, 2001 | ||
35 | * | ||
36 | * Converted original strtok.c code of strtok to __strtok_r. | ||
37 | * Cleaned up logic and reduced code size. | ||
38 | */ | ||
39 | |||
40 | |||
41 | char *strtok_r(char *s, const char *delim, char **save_ptr) | ||
42 | { | ||
43 | char *token; | ||
44 | |||
45 | token = 0; /* Initialize to no token. */ | ||
46 | |||
47 | if (s == 0) { /* If not first time called... */ | ||
48 | s = *save_ptr; /* restart from where we left off. */ | ||
49 | } | ||
50 | |||
51 | if (s != 0) { /* If not finished... */ | ||
52 | *save_ptr = 0; | ||
53 | |||
54 | s += strspn(s, delim); /* Skip past any leading delimiters. */ | ||
55 | if (*s != '\0') { /* We have a token. */ | ||
56 | token = s; | ||
57 | *save_ptr = strpbrk(token, delim); /* Find token's end. */ | ||
58 | if (*save_ptr != 0) { | ||
59 | /* Terminate the token and make SAVE_PTR point past it. */ | ||
60 | *(*save_ptr)++ = '\0'; | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | |||
65 | return token; | ||
66 | } | ||
67 | |||
68 | /* Basically getdelim() with the delimiter hard wired to '\n' */ | ||
69 | ssize_t getline(char **linebuf, size_t *n, FILE *file) | ||
70 | { | ||
71 | return (getdelim (linebuf, n, '\n', file)); | ||
72 | } | ||
73 | |||
74 | |||
2 | /* | 75 | /* |
3 | * daemon implementation for uClibc | 76 | * daemon implementation for uClibc |
4 | * | 77 | * |
@@ -26,14 +99,6 @@ | |||
26 | * Original copyright notice is retained at the end of this file. | 99 | * Original copyright notice is retained at the end of this file. |
27 | */ | 100 | */ |
28 | 101 | ||
29 | #include <features.h> | ||
30 | #include <fcntl.h> | ||
31 | #include <paths.h> | ||
32 | #include <unistd.h> | ||
33 | |||
34 | |||
35 | #if __GNU_LIBRARY__ < 5 | ||
36 | |||
37 | int daemon( int nochdir, int noclose ) | 102 | int daemon( int nochdir, int noclose ) |
38 | { | 103 | { |
39 | int fd; | 104 | int fd; |
@@ -62,7 +127,6 @@ int daemon( int nochdir, int noclose ) | |||
62 | } | 127 | } |
63 | return(0); | 128 | return(0); |
64 | } | 129 | } |
65 | #endif | ||
66 | 130 | ||
67 | 131 | ||
68 | /*- | 132 | /*- |
@@ -99,3 +163,5 @@ int daemon( int nochdir, int noclose ) | |||
99 | */ | 163 | */ |
100 | 164 | ||
101 | 165 | ||
166 | #endif | ||
167 | |||