diff options
Diffstat (limited to 'support/libc')
-rw-r--r-- | support/libc/Makefile.am | 4 | ||||
-rw-r--r-- | support/libc/errno.h | 4 | ||||
-rw-r--r-- | support/libc/libc.c | 158 | ||||
-rw-r--r-- | support/libc/libc_init.c | 6 | ||||
-rw-r--r-- | support/libc/locale.h | 12 | ||||
-rw-r--r-- | support/libc/signal.h | 2 |
6 files changed, 186 insertions, 0 deletions
diff --git a/support/libc/Makefile.am b/support/libc/Makefile.am new file mode 100644 index 00000000..fd98ea7a --- /dev/null +++ b/support/libc/Makefile.am @@ -0,0 +1,4 @@ +include $(top_srcdir)/Makefile.inc +AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=support_libc +noinst_LTLIBRARIES = libsupport_libc.la +libsupport_libc_la_SOURCES = libc.c libc_init.c diff --git a/support/libc/errno.h b/support/libc/errno.h new file mode 100644 index 00000000..5ef0a7bd --- /dev/null +++ b/support/libc/errno.h @@ -0,0 +1,4 @@ +extern int errno; +#define ENOMEM 12 +#define EINVAL 22 +#define ERANGE 34 diff --git a/support/libc/libc.c b/support/libc/libc.c new file mode 100644 index 00000000..9b5cfe73 --- /dev/null +++ b/support/libc/libc.c @@ -0,0 +1,158 @@ +#include "locale.h" +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +int errno; + +#define MAXENV 32 +static char *envnames[MAXENV]; +static char *envvars[MAXENV]; + +static void cleanup_libc(void) __attribute__((destructor)); +static void cleanup_libc(void) +{ + int i; + for (i=0; i <MAXENV; i++) { + if (envnames[i]) + free(envnames[i]); + if (envvars[i]) + free(envvars[i]); + } +} + +char * +getenv(const char *name) +{ + int i; + for (i=0; i < MAXENV; i++) { + if (envnames[i] && !strcmp(envnames[i], name)) + return envvars[i]; + } + return NULL; +} + +int +setenv(const char *name, const char *value, int overwrite) +{ + int i; + char *val; + for (i=0; i < MAXENV; i++) { + if (envnames[i] && !strcmp(envnames[i], name)) { + if (overwrite) { + val = strdup(value); + if (!val) + return -1; + if (envvars[i]) + free(envvars[i]); + envvars[i] = val; + } + return 0; + } + } + for (i=0; i < MAXENV; i++) { + if (!envnames[i]) { + envnames[i] = strdup(name); + envvars[i] = strdup(value); + if (!envnames[i] || !envvars[i]) { + if (envnames[i]) + free(envnames[i]); + if (envvars[i]) + free(envvars[i]); + envnames[i] = NULL; + envvars[i] = NULL; + return -1; + } + return 0; + } + } + return -1; +} + +int unsetenv(const char *name) +{ + int i; + for (i=0; i < MAXENV; i++) { + if (envnames[i] && !strcmp(envnames[i], name)) { + free(envnames[i]); + envnames[i] = NULL; + if (envvars[i]) + free(envvars[i]); + envvars[i] = NULL; + } + } + return 0; +} + +char * +getcwd(char *buf, int size) +{ + return "dummy"; +} + +char * +getwd(char *buf) +{ + return "dummy"; +} + +char *strtok_r(char *str, const char *delim, char **saveptr) +{ + return strtok(str, delim); +} + +void +perror(const char *x) +{ +} + +void +raise(void) +{ +} + +void * +popen(void) +{ + return 0; +} + +void +pclose(void) +{ +} + +void +rewind(void) +{ +} + +int +GetThreadLocale(void) +{ + return 0; +} + +int +signal(void) +{ + return 0; +} + +void +setlocale(void) +{ + return 0; +} + +static struct lconv localedata={"."}; + +struct lconv * +localeconv(void) +{ + return &localedata; +} + +unsigned int +alarm(unsigned int seconds) +{ +} diff --git a/support/libc/libc_init.c b/support/libc/libc_init.c new file mode 100644 index 00000000..32be387d --- /dev/null +++ b/support/libc/libc_init.c @@ -0,0 +1,6 @@ +#include "plugin.h" + +void +plugin_init(void) +{ +} diff --git a/support/libc/locale.h b/support/libc/locale.h new file mode 100644 index 00000000..fad4f95d --- /dev/null +++ b/support/libc/locale.h @@ -0,0 +1,12 @@ +#ifndef _LOCALE_H +#define _LOCALE_H 1 +#define SUBLANG_BENGALI_BANGLADESH 0x02 +#define SUBLANG_PUNJABI_PAKISTAN 0x02 +#define SUBLANG_ROMANIAN_MOLDOVA 0x02 +struct lconv { + char *decimal_point; +}; + +#define LC_ALL 1 +#define LC_NUMERIC 2 +#endif diff --git a/support/libc/signal.h b/support/libc/signal.h new file mode 100644 index 00000000..18b65399 --- /dev/null +++ b/support/libc/signal.h @@ -0,0 +1,2 @@ +#define SIGFPE 8 +#define SIGSEGV 11 |