1
by brian
clean slate |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
15 |
||
994.2.4
by Monty Taylor
Blast. Fixed some make distcheck issues. |
16 |
#include "mysys/mysys_priv.h" |
1
by brian
clean slate |
17 |
#include "my_static.h" |
202.3.6
by Monty Taylor
First pass at gettexizing the error messages. |
18 |
#include <mysys/mysys_err.h> |
212.5.18
by Monty Taylor
Moved m_ctype, m_string and my_bitmap. Removed t_ctype. |
19 |
#include <mystrings/m_string.h> |
20 |
#include <mystrings/m_ctype.h> |
|
612.2.6
by Monty Taylor
OpenSolaris builds. |
21 |
#include <stdio.h> |
629.1.1
by Monty Taylor
More solaris fixes. |
22 |
#include <stdlib.h> |
1
by brian
clean slate |
23 |
|
146
by Brian Aker
my_bool cleanup. |
24 |
bool my_init_done= 0; |
1
by brian
clean slate |
25 |
uint mysys_usage_id= 0; /* Incremented for each my_init() */ |
26 |
||
298
by Brian Aker
ulong conversion. |
27 |
static uint32_t atoi_octal(const char *str) |
1
by brian
clean slate |
28 |
{
|
29 |
long int tmp; |
|
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
30 |
while (*str && my_isspace(&my_charset_utf8_general_ci, *str)) |
1
by brian
clean slate |
31 |
str++; |
999.1.1
by Toru Maesaka
Removed str2int() from the original string library by MySQL. Use strtol(3) instead. |
32 |
tmp= strtol(str, NULL, (*str == '0' ? 8 : 10)); |
298
by Brian Aker
ulong conversion. |
33 |
return (uint32_t) tmp; |
1
by brian
clean slate |
34 |
}
|
35 |
||
36 |
||
37 |
/*
|
|
38 |
Init my_sys functions and my_sys variabels
|
|
39 |
||
40 |
SYNOPSIS
|
|
41 |
my_init()
|
|
42 |
||
43 |
RETURN
|
|
44 |
0 ok
|
|
45 |
1 Couldn't initialize environment
|
|
46 |
*/
|
|
47 |
||
146
by Brian Aker
my_bool cleanup. |
48 |
bool my_init(void) |
1
by brian
clean slate |
49 |
{
|
50 |
char * str; |
|
51 |
if (my_init_done) |
|
52 |
return 0; |
|
53 |
my_init_done=1; |
|
54 |
mysys_usage_id++; |
|
55 |
my_umask= 0660; /* Default umask for new files */ |
|
56 |
my_umask_dir= 0700; /* Default umask for new directories */ |
|
57 |
init_glob_errs(); |
|
58 |
#if defined(HAVE_PTHREAD_INIT)
|
|
51.3.17
by Jay Pipes
Phase 4 - Remove DBUG from mysys |
59 |
pthread_init(); |
1
by brian
clean slate |
60 |
#endif
|
61 |
if (my_thread_global_init()) |
|
62 |
return 1; |
|
63 |
sigfillset(&my_signals); /* signals blocked by mf_brkhant */ |
|
64 |
{
|
|
65 |
if (!home_dir) |
|
66 |
{ /* Don't initialize twice */ |
|
67 |
if ((home_dir=getenv("HOME")) != 0) |
|
68 |
home_dir=intern_filename(home_dir_buff,home_dir); |
|
69 |
/* Default creation of new files */
|
|
70 |
if ((str=getenv("UMASK")) != 0) |
|
71 |
my_umask=(int) (atoi_octal(str) | 0600); |
|
72 |
/* Default creation of new dir's */
|
|
73 |
if ((str=getenv("UMASK_DIR")) != 0) |
|
74 |
my_umask_dir=(int) (atoi_octal(str) | 0700); |
|
75 |
}
|
|
51.3.17
by Jay Pipes
Phase 4 - Remove DBUG from mysys |
76 |
return(0); |
1
by brian
clean slate |
77 |
}
|
78 |
} /* my_init */ |
|
79 |
||
80 |
||
81 |
/* End my_sys */
|
|
82 |
||
1235.3.14
by Stewart Smith
my_end() no longer requires an argument (we removed them all) |
83 |
void my_end() |
1
by brian
clean slate |
84 |
{
|
85 |
free_charsets(); |
|
86 |
my_error_unregister_all(); |
|
87 |
||
88 |
my_thread_end(); |
|
89 |
my_thread_global_end(); |
|
90 |
||
91 |
my_init_done=0; |
|
92 |
} /* my_end */ |