7 for (i = 0; i < 2000; i++)
12 #define BIT(i,x) ((x) ? (1 << (i)) : 0)
13 #define MORSE1(a) (1 | BIT(3,a))
14 #define MORSE2(a,b) (2 | BIT(3,a) | BIT(4,b))
15 #define MORSE3(a,b,c) (3 | BIT(3,a) | BIT(4,b) | BIT(5,c))
16 #define MORSE4(a,b,c,d) (4 | BIT(3,a) | BIT(4,b) | BIT(5,c) | BIT(6,d))
17 #define MORSE5(a,b,c,d,e) (5 | BIT(3,a) | BIT(4,b) | BIT(5,c) | BIT(6,d) | BIT(7,e))
22 static const uint8_t morse[26] = {
24 MORSE4(1,0,0,0), /* B */
25 MORSE4(1,0,1,0), /* C */
26 MORSE3(1,0,0), /* D */
28 MORSE4(0,0,1,0), /* F */
29 MORSE3(1,1,0), /* G */
30 MORSE4(0,0,0,0), /* H */
32 MORSE4(0,1,1,1), /* J */
33 MORSE3(1,0,1), /* K */
34 MORSE4(0,1,0,0), /* L */
37 MORSE3(1,1,1), /* O */
38 MORSE4(0,1,1,0), /* P */
39 MORSE4(1,1,0,1), /* Q */
40 MORSE3(0,1,0), /* R */
41 MORSE3(0,0,0), /* S */
43 MORSE3(0,0,1), /* U */
44 MORSE4(0,0,0,1), /* V */
45 MORSE3(0,1,1), /* W */
46 MORSE4(1,0,0,1), /* X */
47 MORSE4(1,0,1,1), /* Y */
48 MORSE4(1,1,0,0), /* Z */
66 uint8_t r = morse[c - 'a'];
85 morse_string(char *s) {