Rename OSSL_SERIALIZER / OSSL_DESERIALIZER to OSSL_ENCODE / OSSL_DECODE
[openssl.git] / util / rename-serdes.sh
1 #! /bin/bash
2
3 # Move directories and adjust the parent build.info
4 git mv crypto/serializer crypto/encode_decode
5 git mv providers/implementations/serializers \
6     providers/implementations/encode_decode
7 sed -i \
8     -e 's|serializers|encode_decode|' \
9     -e 's|serializer|encode_decode|' \
10     crypto/build.info providers/implementations/build.info
11
12 # Rename files and adjust build.info in the same directory
13 git ls-files \
14     crypto/encode_decode \
15     include/crypto/serializer.h \
16     include/openssl/{de,}serializer* \
17     providers/implementations/encode_decode \
18     providers \
19     doc/man3 \
20     doc/man7 \
21     test \
22     | while read filename; do
23     new_filename=$(echo "$filename" \
24                        | sed -e 's/OSSL_DESERIALIZE/OSSL_DECODE/g' \
25                              -e 's/deserialize/decode/g' \
26                              -e 's/OSSL_SERIALIZE/OSSL_ENCODE/g' \
27                              -e 's/serialize/encode/g' \
28                              -e 's/serdes/endecode/g' )
29     [ "$filename" = "$new_filename" ] || git mv "$filename" "$new_filename"
30 done
31 sed -i \
32     -e 's/DESERIALIZE/DECODE/g' \
33     -e 's/deserialize/decode/g' \
34     -e 's/SERIALIZE/ENCODE/g' \
35     -e 's/serialize/encode/g' \
36     -e 's/serdes/endecode/g' \
37     crypto/encode_decode/build.info \
38     providers/implementations/encode_decode/build.info \
39     test/build.info \
40     test/recipes/04-test_encoder_decoder.t
41 git add -u
42
43 # Big source rename
44 # (additional files in sed command aren't caught by the big grep)
45 git grep -l -E 'OSSL_(OP_|FUNC_)?(DE)?SERIALIZER' \
46     | xargs perl -p -i \
47             -e 's/DESERIALIZE/DECODE/g;' \
48             -e 's/Deserialize/Decode/g;' \
49             -e 's/deserialize/decode/g;' \
50             -e 's/Deserializing/Decoding/g;' \
51             -e 's/deserializing/decoding/g;' \
52             -e 's/Deserialization/Decoding/g;' \
53             -e 's/deserialization/decoding/g;' \
54             -e 's/\bDESER(_|\b)/DECODER$1/g;' \
55             -e 's/\bdeser(_|\b)/decoder$1/g;' \
56             -e 's/SERIALIZE/ENCODE/g;' \
57             -e 's/Serialize/Encode/g;' \
58             -e 's/serialize/encode/g;' \
59             -e 's/Serializing/Encoding/g;' \
60             -e 's/serializing/encoding/g;' \
61             -e 's/Serialization/Encoding/g;' \
62             -e 's/serialization/encoding/g;' \
63             -e 's/\bSER(_|\b)/ENCODER$1/g;' \
64             -e 's/\bser(_|\b)/encoder$1/g;' \
65             -e 's/\bserprop\b/encprop/g;' \
66             -e 's/\bsctx\b/ectx/g;' \
67             crypto/property/property_parse.c \
68             doc/man1/openssl-list.pod.in \
69             doc/man7/OSSL_PROVIDER-FIPS.pod \
70             doc/man7/provider*.pod \
71             include/internal/cryptlib.h \
72             providers/*.inc \
73             providers/implementations/encode_decode/*.[ch] \
74             providers/implementations/include/prov/implementations.h
75
76 # Remove unnecessary inclusions (if they were necessary, the Big API rename
77 # would have renamed them properly
78 git grep -l -E '<openssl/(de)?serializer\.h>' \
79     | xargs sed -E -i \
80             -e '/<openssl\/(de)?serializer\.h>/d'
81
82 # Adjust a few files that have columns
83 cat crypto/err/openssl.ec | while read line; do
84     (
85         set -- $line
86         if [ "$1" = "L" ]; then
87             printf "L %-13s %-31s %s\n" $2 $3 $4
88         else
89             echo "$line"
90         fi
91     )
92 done > crypto/err/openssl.ec.new
93 mv crypto/err/openssl.ec.new crypto/err/openssl.ec
94
95 cat util/libcrypto.num | while read sym num version info; do
96     printf '%-39s %s\t%s\t%s\n' "$sym" "$num" "$version" "$info"
97 done > util/libcrypto.num.new
98 mv util/libcrypto.num.new util/libcrypto.num
99
100 cat util/other.syms | while read sym rest; do
101     if [ "$sym" = "#" ]; then
102         if [ -n "$rest" ]; then
103             echo "$sym $rest"
104         else
105             echo "$sym"
106         fi
107     else
108         printf '%-39s %s\n' "$sym" "$rest"
109     fi
110 done > util/other.syms.new
111 mv util/other.syms.new util/other.syms
112
113 git add -u