From bb5c75da2c8ee24e48bb93e24b716d2ab23a0a63 Mon Sep 17 00:00:00 2001 From: LLHHBC Date: Tue, 21 Oct 2014 21:31:34 +0800 Subject: [PATCH 1/2] llh for env submit --- source/libs/grid/{malloc => include}/malloc.h | 3 ++- source/libs/grid/include/stdio.h | 12 ++++++++++++ source/libs/grid/include/string.h | 18 ++++++++++++++++++ source/libs/grid/stdlib/getenv.c | 4 ++++ source/libs/grid/stdlib/setenv.c | 4 ++++ 5 files changed, 40 insertions(+), 1 deletion(-) rename source/libs/grid/{malloc => include}/malloc.h (78%) create mode 100644 source/libs/grid/include/stdio.h create mode 100644 source/libs/grid/include/string.h diff --git a/source/libs/grid/malloc/malloc.h b/source/libs/grid/include/malloc.h similarity index 78% rename from source/libs/grid/malloc/malloc.h rename to source/libs/grid/include/malloc.h index 46414ef..34eb6ef 100644 --- a/source/libs/grid/malloc/malloc.h +++ b/source/libs/grid/include/malloc.h @@ -11,5 +11,6 @@ #define _MALLOC_H bool init_malloc(); +void * malloc(size_t _Size); -#endif \ No newline at end of file +#endif diff --git a/source/libs/grid/include/stdio.h b/source/libs/grid/include/stdio.h new file mode 100644 index 0000000..52769f3 --- /dev/null +++ b/source/libs/grid/include/stdio.h @@ -0,0 +1,12 @@ + +#ifndef _STDIO_H +#define _STDIO_H + + +int getch(); +int printf(const char *fmt, ...); +int puts(const char *s); +int putchar(int ch); + + +#endif diff --git a/source/libs/grid/include/string.h b/source/libs/grid/include/string.h new file mode 100644 index 0000000..79a8294 --- /dev/null +++ b/source/libs/grid/include/string.h @@ -0,0 +1,18 @@ + +#ifndef _STRING_H +#define _STRING_H + +int memcmp(const void *cs, const void *ct, size_t count); +void *memcpy(void *dst, const void *src, unsigned long len); +void *memset(void *dst, int value, unsigned long count); +char *strcat(char *dest, const char *src); +char * strchr (const char * string, int ch); +int strcmp(const char *src1, const char *src2); +char *strcpy (char *dest, const char *src); +unsigned long strlen(const char * str); +int strncmp (const char *s1, const char *s2, size_t n); +char *strncpy (char *dest, const char *src, int len); +size_t strnlen(const char *s, size_t maxlen); +char *strrchr(const char *s, int c); + +#endif diff --git a/source/libs/grid/stdlib/getenv.c b/source/libs/grid/stdlib/getenv.c index ad821de..b0de198 100644 --- a/source/libs/grid/stdlib/getenv.c +++ b/source/libs/grid/stdlib/getenv.c @@ -14,6 +14,10 @@ #include #include #include "env.h" +#include "string.h" +#include "crt.h" +#include "malloc.h" +#include "stdio.h" extern char *_environ ; //����������ָ�� diff --git a/source/libs/grid/stdlib/setenv.c b/source/libs/grid/stdlib/setenv.c index 248233b..488d558 100644 --- a/source/libs/grid/stdlib/setenv.c +++ b/source/libs/grid/stdlib/setenv.c @@ -13,6 +13,10 @@ #include #include #include "env.h" +#include "string.h" +#include "crt.h" +#include "malloc.h" +#include "stdio.h" char *_environ = NULL; //����������ָ�� char *_cur_env = NULL; //ָ�򻷾��������пռ��׵�ַ From 0859601015dd502666173a7fdf3a85b1aab795a9 Mon Sep 17 00:00:00 2001 From: LLHHBC Date: Tue, 21 Oct 2014 22:51:43 +0800 Subject: [PATCH 2/2] llh env change --- source/libs/grid/include/stdio.h | 12 ------------ source/libs/grid/include/string.h | 18 ------------------ source/libs/grid/stdlib/getenv.c | 1 + source/libs/grid/stdlib/setenv.c | 11 +++++++---- 4 files changed, 8 insertions(+), 34 deletions(-) delete mode 100644 source/libs/grid/include/stdio.h delete mode 100644 source/libs/grid/include/string.h diff --git a/source/libs/grid/include/stdio.h b/source/libs/grid/include/stdio.h deleted file mode 100644 index 52769f3..0000000 --- a/source/libs/grid/include/stdio.h +++ /dev/null @@ -1,12 +0,0 @@ - -#ifndef _STDIO_H -#define _STDIO_H - - -int getch(); -int printf(const char *fmt, ...); -int puts(const char *s); -int putchar(int ch); - - -#endif diff --git a/source/libs/grid/include/string.h b/source/libs/grid/include/string.h deleted file mode 100644 index 79a8294..0000000 --- a/source/libs/grid/include/string.h +++ /dev/null @@ -1,18 +0,0 @@ - -#ifndef _STRING_H -#define _STRING_H - -int memcmp(const void *cs, const void *ct, size_t count); -void *memcpy(void *dst, const void *src, unsigned long len); -void *memset(void *dst, int value, unsigned long count); -char *strcat(char *dest, const char *src); -char * strchr (const char * string, int ch); -int strcmp(const char *src1, const char *src2); -char *strcpy (char *dest, const char *src); -unsigned long strlen(const char * str); -int strncmp (const char *s1, const char *s2, size_t n); -char *strncpy (char *dest, const char *src, int len); -size_t strnlen(const char *s, size_t maxlen); -char *strrchr(const char *s, int c); - -#endif diff --git a/source/libs/grid/stdlib/getenv.c b/source/libs/grid/stdlib/getenv.c index b0de198..e724e1c 100644 --- a/source/libs/grid/stdlib/getenv.c +++ b/source/libs/grid/stdlib/getenv.c @@ -57,3 +57,4 @@ DLLEXPORT __weak char *getenv(const char * name) UNLOCK_ENV_VARIABLE; return NULL; } + diff --git a/source/libs/grid/stdlib/setenv.c b/source/libs/grid/stdlib/setenv.c index 488d558..6e268e5 100644 --- a/source/libs/grid/stdlib/setenv.c +++ b/source/libs/grid/stdlib/setenv.c @@ -22,6 +22,8 @@ char *_cur_env = NULL; //ָ�򻷾��������пռ��׵�ַ unsigned long _env_len = NULL; //��ǰ��������ָ����ָ��Ŀռ���ܴ�С +/* ������Ÿ�ʽ: ����+ֵ����+ֵ����*/ + DLLEXPORT __weak int setenv(const char * name, const char * value, int overwrite) { char *p = _environ, *tmpp; @@ -57,19 +59,19 @@ DLLEXPORT __weak int setenv(const char * name, const char * value, int overwrit { break; } - p = p + strlen(name) + __SIZE_OF_END_CHAR_; // name eof + p = p + strlen(name) + __SIZE_OF_END_CHAR_; memcpy(&oldlen, p, sizeof(int)); p += sizeof(int); - p += oldlen + __SIZE_OF_END_CHAR_; //eof + p += oldlen + __SIZE_OF_END_CHAR_; } ; - if (*p == 0) //������ + if (*p == 0) /*������ */ { p = _cur_env; strcpy(p, name); p += strlen(name); - *p = NULL; //eof + *p = NULL; p++; newlen = strlen(value); memcpy(p, (char*)&newlen, sizeof(int)); @@ -129,3 +131,4 @@ DLLEXPORT __weak int setenv(const char * name, const char * value, int overwrit UNLOCK_ENV_VARIABLE; return 0; } +