summaryrefslogtreecommitdiff
path: root/generate_uudmap.c
blob: 5b940f769b58ff601924b66dbc959c6315f1e297 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

static const char PL_uuemap[]
= "`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";

typedef unsigned char U8;

/* This will ensure it is all zeros.  */
static char PL_uudmap[256];

int main() {
  size_t i;
  char *p;

  for (i = 0; i < sizeof(PL_uuemap) - 1; ++i)
    PL_uudmap[(U8)PL_uuemap[i]] = i;
  /*
   * Because ' ' and '`' map to the same value,
   * we need to decode them both the same.
   */
  PL_uudmap[(U8)' '] = 0;

  i = sizeof(PL_uudmap);
  p = PL_uudmap;

  fputs("{\n    ", stdout);
  while (i--) {
    printf("%d", *p);
    p++;
    if (i) {
      fputs(", ", stdout);
      if (!(i & 15)) {
	fputs("\n    ", stdout);
      }
    }
  }
  puts("\n}");

  return 0;
}