PostgreSQL Source Code  git master
win866.c File Reference
#include <stdio.h>
Include dependency graph for win866.c:

Go to the source code of this file.

Functions

 main ()
 

Function Documentation

◆ main()

main ( void  )

Definition at line 13 of file win866.c.

14 {
15  int i;
16  char koitab[128],
17  alttab[128];
18  char buf[4096];
19  int koi,
20  alt;
21 
22  for (i = 0; i < 128; i++)
23  koitab[i] = alttab[i] = 0;
24 
25  while (fgets(buf, sizeof(buf), stdin) != NULL)
26  {
27  if (*buf == '#')
28  continue;
29  sscanf(buf, "%d %d", &koi, &alt);
30  if (koi < 128 || koi > 255 || alt < 128 || alt > 255)
31  {
32  fprintf(stderr, "invalid value %d\n", koi);
33  exit(1);
34  }
35  koitab[koi - 128] = alt;
36  alttab[alt - 128] = koi;
37  }
38 
39  i = 0;
40  printf("static char koi2alt[] = {\n");
41  while (i < 128)
42  {
43  int j = 0;
44 
45  while (j < 8)
46  {
47  printf("0x%02x", koitab[i++]);
48  j++;
49  if (i >= 128)
50  break;
51  printf(", ");
52  }
53  printf("\n");
54  }
55  printf("};\n");
56 
57  i = 0;
58  printf("static char alt2koi[] = {\n");
59  while (i < 128)
60  {
61  int j = 0;
62 
63  while (j < 8)
64  {
65  printf("0x%02x", alttab[i++]);
66  j++;
67  if (i >= 128)
68  break;
69  printf(", ");
70  }
71  printf("\n");
72  }
73  printf("};\n");
74 }
int j
Definition: isn.c:74
int i
Definition: isn.c:73
exit(1)
static char * buf
Definition: pg_test_fsync.c:73
#define fprintf
Definition: port.h:242
#define printf(...)
Definition: port.h:244

References buf, exit(), fprintf, i, j, and printf.