~drizzle-trunk/drizzle/development

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
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
1 by brian
clean slate
15
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
16
#include "config.h"
17
18
#include "drizzled/internal/my_sys.h"
1 by brian
clean slate
19
#include "my_static.h"
1271.5.3 by Tim Penhey
change the include files
20
#include "drizzled/error.h"
1241.9.64 by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal.
21
#include "drizzled/internal/m_string.h"
1241.9.61 by Monty Taylor
No more mystrings in drizzled/
22
#include "drizzled/charset_info.h"
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
23
#include "drizzled/charset.h"
24
#include <cstdio>
25
#include <cstdlib>
1 by brian
clean slate
26
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
27
namespace drizzled
28
{
29
namespace internal
30
{
31
146 by Brian Aker
my_bool cleanup.
32
bool my_init_done= 0;
1 by brian
clean slate
33
uint	mysys_usage_id= 0;              /* Incremented for each my_init() */
34
298 by Brian Aker
ulong conversion.
35
static uint32_t atoi_octal(const char *str)
1 by brian
clean slate
36
{
37
  long int tmp;
383.1.12 by Brian Aker
Much closer toward UTF8 being around all the time...
38
  while (*str && my_isspace(&my_charset_utf8_general_ci, *str))
1 by brian
clean slate
39
    str++;
999.1.1 by Toru Maesaka
Removed str2int() from the original string library by MySQL. Use strtol(3) instead.
40
  tmp= strtol(str, NULL, (*str == '0' ? 8 : 10));
298 by Brian Aker
ulong conversion.
41
  return (uint32_t) tmp;
1 by brian
clean slate
42
}
43
44
45
/*
46
  Init my_sys functions and my_sys variabels
47
48
  SYNOPSIS
49
    my_init()
50
51
  RETURN
52
    0  ok
53
    1  Couldn't initialize environment
54
*/
55
146 by Brian Aker
my_bool cleanup.
56
bool my_init(void)
1 by brian
clean slate
57
{
58
  char * str;
59
  if (my_init_done)
60
    return 0;
61
  my_init_done=1;
62
  mysys_usage_id++;
63
  my_umask= 0660;                       /* Default umask for new files */
64
  my_umask_dir= 0700;                   /* Default umask for new directories */
65
#if defined(HAVE_PTHREAD_INIT)
51.3.17 by Jay Pipes
Phase 4 - Remove DBUG from mysys
66
  pthread_init();
1 by brian
clean slate
67
#endif
68
  if (my_thread_global_init())
69
    return 1;
70
  sigfillset(&my_signals);		/* signals blocked by mf_brkhant */
71
  {
72
    if (!home_dir)
73
    {					/* Don't initialize twice */
74
      if ((home_dir=getenv("HOME")) != 0)
75
	home_dir=intern_filename(home_dir_buff,home_dir);
76
      /* Default creation of new files */
77
      if ((str=getenv("UMASK")) != 0)
78
	my_umask=(int) (atoi_octal(str) | 0600);
79
	/* Default creation of new dir's */
80
      if ((str=getenv("UMASK_DIR")) != 0)
81
	my_umask_dir=(int) (atoi_octal(str) | 0700);
82
    }
51.3.17 by Jay Pipes
Phase 4 - Remove DBUG from mysys
83
    return(0);
1 by brian
clean slate
84
  }
85
} /* my_init */
86
87
88
	/* End my_sys */
89
1235.3.14 by Stewart Smith
my_end() no longer requires an argument (we removed them all)
90
void my_end()
1 by brian
clean slate
91
{
92
  free_charsets();
93
94
  my_thread_end();
95
  my_thread_global_end();
96
97
  my_init_done=0;
98
} /* my_end */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
99
100
} /* namespace internal */
101
} /* namespace drizzled */