00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <config.h>
00017
00018 #include <drizzled/internal/my_sys.h>
00019 #include "my_static.h"
00020 #include <drizzled/error.h>
00021 #include <drizzled/internal/m_string.h>
00022 #include <drizzled/charset.h>
00023 #include <cstdio>
00024 #include <cstdlib>
00025
00026 namespace drizzled {
00027 namespace internal {
00028
00029 static bool my_init_done= 0;
00030
00031 static uint32_t atoi_octal(const char *str)
00032 {
00033 long int tmp;
00034 while (*str && my_charset_utf8_general_ci.isspace(*str))
00035 str++;
00036 tmp= strtol(str, NULL, (*str == '0' ? 8 : 10));
00037 return (uint32_t) tmp;
00038 }
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 void my_init()
00053 {
00054 if (my_init_done)
00055 return;
00056 my_init_done= true;
00057 my_umask= 0660;
00058 my_umask_dir= 0700;
00059 #if defined(HAVE_PTHREAD_INIT)
00060 pthread_init();
00061 #endif
00062 my_thread_init();
00063 sigfillset(&my_signals);
00064 if (!home_dir)
00065 {
00066 if ((home_dir=getenv("HOME")) != 0)
00067 home_dir=intern_filename(home_dir_buff,home_dir);
00068
00069 if (const char* str= getenv("UMASK"))
00070 my_umask=(int) (atoi_octal(str) | 0600);
00071
00072 if (const char* str= getenv("UMASK_DIR"))
00073 my_umask_dir=(int) (atoi_octal(str) | 0700);
00074 }
00075 }
00076
00077
00078
00079
00080 void my_end()
00081 {
00082 free_charsets();
00083 my_init_done= false;
00084 }
00085
00086 }
00087 }