blob: baf026d5d1d3ee3b0f7597906c87c08211296780 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#ifndef _POSIX_SOURCE
#include <libc.h>
#else
#include <unistd.h>
#include <stdlib.h>
#endif
#include <string.h>
#include <sys/signal.h>
void
putenv(char *name)
{
extern char **environ;
static int was_mallocated = 0;
int size;
/* Compute the size of environ array including the final NULL */
for (size = 1; environ[size++];)
/* nothing */ ;
if (!was_mallocated)
{
char **tmp = environ;
int i;
was_mallocated = 1;
environ = malloc(size * sizeof(char *));
for (i = 0; i < size; i++)
environ[i] = tmp[i];
}
environ = realloc(environ, (size + 1) * sizeof(char *));
environ[size - 1] = strcpy(malloc(strlen(name) + 1), name);
environ[size] = NULL;
}
char *
strdup(const char *string)
{
return strcpy(malloc(strlen(string) + 1), string);
}
#ifndef _POSIX_SOURCE
int
sigaddset(int *set, int signo)
{
*set |= sigmask(signo);
return *set;
}
int
sigemptyset(int *set)
{
return (*set = 0);
}
char *
getcwd(char *buf, size_t size)
{
return getwd(buf);
}
#endif
|