conf_to_src.c File Reference

#include <my_global.h>
#include <ctype.h>
#include <string.h>
#include <unistd.h>

Go to the source code of this file.

Defines

#define CHARSETS_SUBDIR   "sql/share/charsets"
#define CTYPE_TABLE_SIZE   257
#define ROW_LEN   16
#define SORT_ORDER_TABLE_SIZE   256
#define TO_LOWER_TABLE_SIZE   256
#define TO_UPPER_TABLE_SIZE   256

Functions

int main (int argc, char **argv)
void print_array (FILE *f, const char *set, const char *name, int n)
void print_arrays_for (char *set)

Variables

char buf [1024]
char * endptr
char * p
char * prog


Define Documentation

#define CHARSETS_SUBDIR   "sql/share/charsets"
 

Definition at line 28 of file conf_to_src.c.

#define CTYPE_TABLE_SIZE   257
 

Definition at line 29 of file conf_to_src.c.

#define ROW_LEN   16
 

Definition at line 33 of file conf_to_src.c.

#define SORT_ORDER_TABLE_SIZE   256
 

Definition at line 32 of file conf_to_src.c.

#define TO_LOWER_TABLE_SIZE   256
 

Definition at line 30 of file conf_to_src.c.

#define TO_UPPER_TABLE_SIZE   256
 

Definition at line 31 of file conf_to_src.c.


Function Documentation

int main int  argc,
char **  argv
 

Definition at line 41 of file conf_to_src.c.

References CHARSETS_SUBDIR, exit, print_arrays_for(), and prog.

00042 {
00043   prog = *argv;
00044 
00045   if (argc < 2) {
00046     fprintf(stderr, "usage: %s source-dir [charset [, charset]]\n", prog);
00047     exit(EXIT_FAILURE);
00048   }
00049 
00050   --argc; ++argv;       /* skip program name */
00051 
00052   if (chdir(*argv) != 0) {
00053     fprintf(stderr, "%s: can't cd to %s\n", prog, *argv);
00054     exit(EXIT_FAILURE);
00055   }
00056   --argc; ++argv;
00057 
00058   if (chdir(CHARSETS_SUBDIR) != 0) {
00059     fprintf(stderr, "%s: can't cd to %s\n", prog, CHARSETS_SUBDIR);
00060     exit(EXIT_FAILURE);
00061   }
00062 
00063   while (argc--)
00064     print_arrays_for(*argv++);
00065 
00066   exit(EXIT_SUCCESS);
00067 }

void print_array FILE *  f,
const char *  set,
const char *  name,
int  n
 

Definition at line 70 of file conf_to_src.c.

References buf, endptr, NULL, p, ROW_LEN, strtol(), and val.

00071 {
00072   int i;
00073   char val[100];
00074 
00075   printf("uchar %s_%s[] = {\n", name, set);
00076 
00077   p = buf;
00078   *buf = '\0';
00079   for (i = 0; i < n; ++i)
00080   {
00081     /* get a word from f */
00082     endptr = p;
00083     for (;;)
00084     {
00085       while (isspace(*endptr))
00086         ++endptr;
00087       if (*endptr && *endptr != '#')    /* not comment */
00088         break;
00089       if ((fgets(buf, sizeof(buf), f)) == NULL)
00090         return;         /* XXX: break silently */
00091       endptr = buf;
00092     }
00093 
00094     p = val;
00095     while (!isspace(*endptr))
00096       *p++ = *endptr++;
00097     *p = '\0';
00098     p = endptr;
00099 
00100     /* write the value out */
00101 
00102     if (i == 0 || i % ROW_LEN == n % ROW_LEN)
00103       printf("  ");
00104 
00105     printf("%3d", (unsigned char) strtol(val, (char **) NULL, 16));
00106 
00107     if (i < n - 1)
00108       printf(",");
00109 
00110     if ((i+1) % ROW_LEN == n % ROW_LEN)
00111       printf("\n");
00112   }
00113 
00114   printf("};\n\n");
00115 }

void print_arrays_for char *  set  ) 
 


Variable Documentation

char buf[1024]
 

Definition at line 38 of file conf_to_src.c.

char * endptr
 

Definition at line 38 of file conf_to_src.c.

char * p
 

Definition at line 38 of file conf_to_src.c.

char* prog
 

Definition at line 37 of file conf_to_src.c.


Generated on Wed Jul 20 21:08:25 2005 for MySQL 5.0.9 Beta by  doxygen 1.4.3