~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
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
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
  init_glob_errs();
66
#if defined(HAVE_PTHREAD_INIT)
51.3.17 by Jay Pipes
Phase 4 - Remove DBUG from mysys
67
  pthread_init();
1 by brian
clean slate
68
#endif
69
  if (my_thread_global_init())
70
    return 1;
71
  sigfillset(&my_signals);		/* signals blocked by mf_brkhant */
72
  {
73
    if (!home_dir)
74
    {					/* Don't initialize twice */
75
      if ((home_dir=getenv("HOME")) != 0)
76
	home_dir=intern_filename(home_dir_buff,home_dir);
77
      /* Default creation of new files */
78
      if ((str=getenv("UMASK")) != 0)
79
	my_umask=(int) (atoi_octal(str) | 0600);
80
	/* Default creation of new dir's */
81
      if ((str=getenv("UMASK_DIR")) != 0)
82
	my_umask_dir=(int) (atoi_octal(str) | 0700);
83
    }
51.3.17 by Jay Pipes
Phase 4 - Remove DBUG from mysys
84
    return(0);
1 by brian
clean slate
85
  }
86
} /* my_init */
87
88
89
	/* End my_sys */
90
1235.3.14 by Stewart Smith
my_end() no longer requires an argument (we removed them all)
91
void my_end()
1 by brian
clean slate
92
{
93
  free_charsets();
94
  my_error_unregister_all();
95
96
  my_thread_end();
97
  my_thread_global_end();
98
99
  my_init_done=0;
100
} /* my_end */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
101
102
} /* namespace internal */
103
} /* namespace drizzled */