"Fossies" - the Fresh Open Source Software Archive

Member "mariadb-connector-c-3.0.8-src/libmariadb/mariadb_charset.c" (18 Dec 2018, 2681 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. See also the last Fossies "Diffs" side-by-side code changes report for "mariadb_charset.c": 3.0.4-src_vs_3.0.5-src.

    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 "mysys_err.h"
   22 #include <mariadb_ctype.h>
   23 #include <ma_string.h>
   24 
   25 MARIADB_CHARSET_INFO *ma_default_charset_info; /* will be set in mysql_server_init */
   26 MARIADB_CHARSET_INFO *ma_charset_bin= (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[32];
   27 MARIADB_CHARSET_INFO *ma_charset_latin1= (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[5];
   28 MARIADB_CHARSET_INFO *ma_charset_utf8_general_ci= (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[21];
   29 MARIADB_CHARSET_INFO *ma_charset_utf16le_general_ci= (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[68];
   30 
   31 MARIADB_CHARSET_INFO * STDCALL mysql_get_charset_by_nr(uint cs_number)
   32 {
   33   int i= 0;
   34 
   35   while (mariadb_compiled_charsets[i].nr && cs_number != mariadb_compiled_charsets[i].nr)
   36     i++;
   37   
   38   return (mariadb_compiled_charsets[i].nr) ? (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[i] : NULL;
   39 }
   40 
   41 my_bool set_default_charset(uint cs, myf flags __attribute__((unused)))
   42 {
   43   MARIADB_CHARSET_INFO *new_charset;
   44   new_charset = mysql_get_charset_by_nr(cs);
   45   if (!new_charset)
   46   {
   47     return(TRUE);   /* error */
   48   }
   49   ma_default_charset_info = new_charset;
   50   return(FALSE);
   51 }
   52 
   53 MARIADB_CHARSET_INFO * STDCALL mysql_get_charset_by_name(const char *cs_name)
   54 {
   55   int i= 0;
   56 
   57   while (mariadb_compiled_charsets[i].nr && strcmp(cs_name, mariadb_compiled_charsets[i].csname) != 0)
   58     i++;
   59  
   60   return (mariadb_compiled_charsets[i].nr) ? (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[i] : NULL;
   61 }
   62 
   63 my_bool set_default_charset_by_name(const char *cs_name, myf flags __attribute__((unused)))
   64 {
   65   MARIADB_CHARSET_INFO *new_charset;
   66   new_charset = mysql_get_charset_by_name(cs_name);
   67   if (!new_charset)
   68   {
   69     return(TRUE);   /* error */
   70   }
   71 
   72   ma_default_charset_info = new_charset;
   73   return(FALSE);
   74 }