"Fossies" - the Fresh Open Source Software Archive

Member "mariadb-connector-c-3.0.8-src/libmariadb/ma_init.c" (18 Dec 2018, 2700 Bytes) of package /linux/misc/mariadb-connector-c-3.0.8-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
    2                  2016 MariaDB Corporation AB
    3    
    4    This library is free software; you can redistribute it and/or
    5    modify it under the terms of the GNU Library General Public
    6    License as published by the Free Software Foundation; either
    7    version 2 of the License, or (at your option) any later version.
    8    
    9    This library is distributed in the hope that it will be useful,
   10    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12    Library General Public License for more details.
   13    
   14    You should have received a copy of the GNU Library General Public
   15    License along with this library; if not, write to the Free
   16    Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
   17    MA 02111-1301, USA */
   18 
   19 #include <ma_global.h>
   20 #include <ma_sys.h>
   21 #include "mariadb_ctype.h"
   22 #include <ma_string.h>
   23 #include <mariadb_ctype.h>
   24 #ifdef HAVE_GETRUSAGE
   25 #include <sys/resource.h>
   26 /* extern int     getrusage(int, struct rusage *); */
   27 #endif
   28 #include <signal.h>
   29 #ifdef _WIN32
   30 #ifdef _MSC_VER
   31 #include <locale.h>
   32 #include <crtdbg.h>
   33 #endif
   34 static my_bool my_win_init(void);
   35 #else
   36 #define my_win_init()
   37 #endif
   38 
   39 my_bool ma_init_done=0;
   40 
   41 
   42 
   43 /* Init ma_sys functions and ma_sys variabels */
   44 
   45 void ma_init(void)
   46 {
   47   if (ma_init_done)
   48     return;
   49   ma_init_done=1;
   50   {
   51 #ifdef _WIN32
   52     my_win_init();
   53 #endif
   54     return;
   55   }
   56 } /* ma_init */
   57 
   58 
   59 
   60 void ma_end(int infoflag __attribute__((unused)))
   61 {
   62 #ifdef _WIN32
   63   WSACleanup( );
   64 #endif /* _WIN32 */
   65   ma_init_done=0;
   66 } /* ma_end */
   67 
   68 #ifdef _WIN32
   69 
   70 /*
   71   This code is specially for running MySQL, but it should work in
   72   other cases too.
   73 
   74   Inizializzazione delle variabili d'ambiente per Win a 32 bit.
   75 
   76   Vengono inserite nelle variabili d'ambiente (utilizzando cosi'
   77   le funzioni getenv e putenv) i valori presenti nelle chiavi
   78   del file di registro:
   79 
   80   HKEY_LOCAL_MACHINE\software\MySQL
   81 
   82   Se la kiave non esiste nonn inserisce nessun valore
   83 */
   84 
   85 /* Crea la stringa d'ambiente */
   86 
   87 void setEnvString(char *ret, const char *name, const char *value)
   88 {
   89   sprintf(ret, "%s=%s", name, value);
   90   return ;
   91 }
   92 
   93 static my_bool my_win_init()
   94 {
   95   WORD VersionRequested;
   96   int err;
   97   WSADATA WsaData;
   98   const unsigned int MajorVersion=2,
   99                      MinorVersion=2;
  100   VersionRequested= MAKEWORD(MajorVersion, MinorVersion);
  101   /* Load WinSock library */
  102   if ((err= WSAStartup(VersionRequested, &WsaData)))
  103   {
  104     return 0;
  105   }
  106   /* make sure 2.2 or higher is supported */
  107   if ((LOBYTE(WsaData.wVersion) * 10 + HIBYTE(WsaData.wVersion)) < 22)
  108   {
  109     WSACleanup();
  110     return 1;
  111   }
  112   return 0;
  113 }
  114 #endif
  115