~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysys/test_charset.c

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 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
 
 
16
#include <my_global.h>
 
17
#include <m_ctype.h>
 
18
#include <my_sys.h>
 
19
#include <mysql_version.h>
 
20
 
 
21
#include <stdio.h>
 
22
 
 
23
static void _print_array(uint8 *data, uint size)
 
24
{
 
25
  uint i;
 
26
  for (i = 0; i < size; ++i)
 
27
  {
 
28
    if (i == 0 || i % 16 == size % 16) printf("  ");
 
29
    printf(" %02x", data[i]);
 
30
    if ((i+1) % 16 == size % 16) printf("\n");
 
31
  }
 
32
}
 
33
 
 
34
static void _print_csinfo(CHARSET_INFO *cs)
 
35
{
 
36
  printf("%s #%d\n", cs->name, cs->number);
 
37
  printf("ctype:\n"); _print_array(cs->ctype, 257);
 
38
  printf("to_lower:\n"); _print_array(cs->to_lower, 256);
 
39
  printf("to_upper:\n"); _print_array(cs->to_upper, 256);
 
40
  printf("sort_order:\n"); _print_array(cs->sort_order, 256);
 
41
  printf("collate:    %3s (%d, %p, %p, %p)\n",
 
42
         cs->strxfrm_multiply ? "yes" : "no",
 
43
         cs->strxfrm_multiply,
 
44
         cs->strnncoll,
 
45
         cs->strnxfrm,
 
46
         cs->like_range);
 
47
  printf("multi-byte: %3s (%d, %p, %p, %p)\n",
 
48
         cs->mbmaxlen > 1 ? "yes" : "no",
 
49
         cs->mbmaxlen,
 
50
         cs->ismbchar,
 
51
         cs->ismbhead,
 
52
         cs->mbcharlen);
 
53
}
 
54
 
 
55
 
 
56
int main(int argc, char **argv) {
 
57
  const char *the_set = MYSQL_CHARSET;
 
58
  char *cs_list;
 
59
  int argcnt = 1;
 
60
  CHARSET_INFO *cs;
 
61
 
 
62
  my_init();
 
63
 
 
64
  if (argc > argcnt && argv[argcnt][0] == '-' && argv[argcnt][1] == '#')
 
65
    DBUG_PUSH(argv[argcnt++]+2);
 
66
 
 
67
  if (argc > argcnt)
 
68
    the_set = argv[argcnt++];
 
69
 
 
70
  if (argc > argcnt)
 
71
    charsets_dir = argv[argcnt++];
 
72
 
 
73
  if (!(cs= get_charset_by_name(the_set, MYF(MY_WME))))
 
74
    return 1;
 
75
 
 
76
  puts("CHARSET INFO:");
 
77
  _print_csinfo(cs);
 
78
  fflush(stdout);
 
79
 
 
80
#ifdef NOT_USED_ANYMORE
 
81
  cs_list = list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG));
 
82
  printf("LIST OF CHARSETS (compiled + *.conf):\n%s\n", cs_list);
 
83
  my_free(cs_list,MYF(0));
 
84
 
 
85
  cs_list = list_charsets(MYF(MY_CS_INDEX | MY_CS_LOADED));
 
86
  printf("LIST OF CHARSETS (index + loaded):\n%s\n", cs_list);
 
87
  my_free(cs_list,MYF(0));
 
88
#endif
 
89
 
 
90
  return 0;
 
91
}