Rationalise our include paths
[openafs.git] / src / des / make_ip.c
1 /*
2  * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
3  *
4  * For copying and distribution information, please see the file
5  * <mit-cpyright.h>.
6  *
7  * This routine generates source code implementing the initial
8  * permutation of the DES.
9  */
10
11 #include <afsconfig.h>
12 #include <afs/param.h>
13
14
15 #include "mit-cpyright.h"
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include "des.h"
19 #include "des_internal.h"
20
21 #define WANT_IP_TABLE
22 #include "tables.h"
23
24 #include "des_prototypes.h"
25
26 #define SWAP(x) swap_long_bytes_bit_number(swap_bit_pos_0_to_ansi(x))
27
28 void
29 gen(FILE * stream)
30 {
31     register int i;
32 #ifdef AFS_DARWIN80_ENV
33     int j;
34
35 #define swap_long_bytes_bit_number _darwin_swap_long_bytes_bit_number
36 #endif /* AFS_DARWIN80_ENV */
37
38     /* clear the output */
39     fprintf(stream, "    L2 = 0; R2 = 0;\n");
40
41 #ifdef AFS_DARWIN80_ENV
42   for(j = 0;; j++) {
43     fprintf(stream, "%s", _darwin_whichstr[j]);
44     if (j == 2)
45         break;
46 #endif /* AFS_DARWIN80_ENV */
47     /* first setup IP */
48     fprintf(stream, "/* IP operations */\n/* first left to left */\n");
49
50     /* first list mapping from left to left */
51     for (i = 0; i <= 31; i++)
52         if (IP[i] < 32)
53             test_set(stream, "L1", SWAP(IP[i]), "L2", i);
54
55     /* now mapping from right to left */
56     fprintf(stream, "\n/* now from right to left */\n");
57     for (i = 0; i <= 31; i++)
58         if (IP[i] >= 32)
59             test_set(stream, "R1", SWAP(IP[i] - 32), "L2", i);
60
61     fprintf(stream, "\n/* now from left to right */\n");
62     /*  list mapping from left to right */
63     for (i = 32; i <= 63; i++)
64         if (IP[i] < 32)
65             test_set(stream, "L1", SWAP(IP[i]), "R2", i - 32);
66
67     /* now mapping from right to right */
68     fprintf(stream, "\n/* last from right to right */\n");
69     for (i = 32; i <= 63; i++)
70         if (IP[i] >= 32)
71             test_set(stream, "R1", SWAP(IP[i] - 32), "R2", i - 32);
72 #ifdef AFS_DARWIN80_ENV
73     _darwin_which = !_darwin_which;
74   }
75 #endif /* AFS_DARWIN80_ENV */
76     exit(0);
77 }