]> code.citadel.org Git - citadel.git/blob - citadel/utils/ctdl3264_prep.sh
dd27699f74bdd9b979abcc9a992295998c96f90c
[citadel.git] / citadel / utils / ctdl3264_prep.sh
1 #!/bin/bash
2 # Copyright (c) 2023 by the citadel.org team
3 # This program is open source software.  Use, duplication, or disclosure
4 # is subject to the terms of the GNU General Public License, version 3.
5
6 # Source our data structures from the real live working code
7 SERVER_H=server/server.h
8
9 # Generate the "32-bit" versions of these structures.
10 # Note that this is specifically converting "32-bit to 64-bit" -- NOT "any-to-any"
11 convert_struct() {
12         start_line=$(cat ${SERVER_H} | egrep -n "^struct $1 {" | cut -d: -f1)
13         tail +${start_line} ${SERVER_H} | sed '/};/q' \
14         | sed s/"^struct $1 {"/"struct ${1}_32 {"/g \
15         | sed s/"int "/"int32_t "/g \
16         | sed s/"long "/"int32_t "/g \
17         | sed s/"time_t "/"int32_t "/g \
18         | sed s/"struct ExpirePolicy "/"struct ExpirePolicy_32 "/g
19         echo ''
20
21 }
22
23 # Here we go.  Let's make this thing happen.
24 (
25
26         echo '// This file was automatically generated by ctdl3264_prep.sh'
27         echo '// Attempting to modify it would be an exercise in futility.'
28         echo ''
29
30         convert_struct "ctdluser"
31         convert_struct "ExpirePolicy"
32         convert_struct "ctdlroom"
33         convert_struct "floor"
34
35 ) >utils/ctdl3264_structs.h