drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
my_init.cc
1/* Copyright (C) 2000-2003 MySQL AB
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16#include <config.h>
17
18#include <drizzled/internal/my_sys.h>
19#include "my_static.h"
20#include <drizzled/error.h>
21#include <drizzled/internal/m_string.h>
22#include <drizzled/charset.h>
23#include <cstdio>
24#include <cstdlib>
25
26namespace drizzled {
27namespace internal {
28
29static bool my_init_done= 0;
30
31static uint32_t atoi_octal(const char *str)
32{
33 long int tmp;
34 while (*str && my_charset_utf8_general_ci.isspace(*str))
35 str++;
36 tmp= strtol(str, NULL, (*str == '0' ? 8 : 10));
37 return (uint32_t) tmp;
38}
39
40
41/*
42 Init my_sys functions and my_sys variabels
43
44 SYNOPSIS
45 my_init()
46
47 RETURN
48 0 ok
49 1 Couldn't initialize environment
50*/
51
52void my_init()
53{
54 if (my_init_done)
55 return;
56 my_init_done= true;
57 my_umask= 0660; /* Default umask for new files */
58 my_umask_dir= 0700; /* Default umask for new directories */
59#if defined(HAVE_PTHREAD_INIT)
60 pthread_init();
61#endif
62 my_thread_init();
63 sigfillset(&my_signals); /* signals blocked by mf_brkhant */
64 if (!home_dir)
65 { /* Don't initialize twice */
66 if ((home_dir=getenv("HOME")) != 0)
67 home_dir=intern_filename(home_dir_buff,home_dir);
68 /* Default creation of new files */
69 if (const char* str= getenv("UMASK"))
70 my_umask=(int) (atoi_octal(str) | 0600);
71 /* Default creation of new dir's */
72 if (const char* str= getenv("UMASK_DIR"))
73 my_umask_dir=(int) (atoi_octal(str) | 0700);
74 }
75} /* my_init */
76
77
78 /* End my_sys */
79
80void my_end()
81{
82 free_charsets();
83 my_init_done= false;
84} /* my_end */
85
86} /* namespace internal */
87} /* namespace drizzled */
TODO: Rename this file - func.h is stupid.