dtstyle: Coverity 89456
[oweals/cde.git] / cde / programs / dtpdm / BuildOidHdrs.sh
1 #!/bin/sh
2 # $XConsortium: BuildOidHdrs.sh /main/3 1996/08/12 18:41:52 cde-hp $
3
4 #  (c) Copyright 1996 Digital Equipment Corporation.
5 #  (c) Copyright 1996 Hewlett-Packard Company.
6 #  (c) Copyright 1996 International Business Machines Corp.
7 #  (c) Copyright 1996 Sun Microsystems, Inc.
8 #  (c) Copyright 1996 Novell, Inc. 
9 #  (c) Copyright 1996 FUJITSU LIMITED.
10 #  (c) Copyright 1996 Hitachi.
11
12
13 in_file=PdmOidDefs.in
14 oid_file=PdmOidDefs.h
15 str_file=PdmOidStrs.h
16
17 tmpbase=`basename $0`
18 oid_tmp=$tmpbase.oid_tmp
19 str_tmp=$tmpbase.str_tmp
20
21 rm -f $oid_tmp > /dev/null 2>&1
22 rm -f $str_tmp > /dev/null 2>&1
23
24 first=1
25
26 echo "parsing $in_file \c"
27
28 cat $in_file |
29 (
30     while read oid str mset mnum defmsg
31     do
32         if [ -n "$oid" -a "$oid" != "#" ]
33         then
34             if [ $first -eq 1 ]
35             then
36                 first=0
37             else
38                 echo "," >> $oid_tmp
39                 echo "," >> $str_tmp
40             fi
41             echo "    $oid\c" >> $oid_tmp
42             str_length=`echo "$str\c" | wc -c`
43             if [ -z "$mset" ] ; then
44                 mset="-1"
45             fi
46             if [ -z "$mnum" ] ; then
47                 mnum="-1"
48             fi
49             if [ -z "$defmsg" ] ; then
50                 defmsg="(const char*)NULL"
51             else
52                 defmsg="\"$defmsg\""
53             fi
54             echo "    { \"$str\", $str_length, $mset, $mnum, $defmsg }\c" \
55                 >> $str_tmp
56             echo ".\c"
57         fi
58     done
59     echo >> $oid_tmp
60     echo >> $str_tmp
61 )
62
63 echo "done"
64
65 echo "creating $oid_file ...\c"
66
67 (
68     echo '/* $'XConsortium'$ */'
69     echo '/* This is an automatically-generated file. Do not edit. */'
70     echo '/*
71  * (c) Copyright 1996 Digital Equipment Corporation.
72  * (c) Copyright 1996 Hewlett-Packard Company.
73  * (c) Copyright 1996 International Business Machines Corp.
74  * (c) Copyright 1996 Sun Microsystems, Inc.
75  * (c) Copyright 1996 Novell, Inc. 
76  * (c) Copyright 1996 FUJITSU LIMITED.
77  * (c) Copyright 1996 Hitachi.
78  */'
79     echo
80     echo 'typedef enum {'
81     cat $oid_tmp
82     echo '} PdmOid;'
83 ) > $oid_file
84
85 echo "done"
86
87 echo "creating $str_file ...\c"
88
89 (
90     echo '/* $'XConsortium'$ */'
91     echo '/* This is an automatically-generated file. Do not edit. */'
92     echo '/*
93  * (c) Copyright 1996 Digital Equipment Corporation.
94  * (c) Copyright 1996 Hewlett-Packard Company.
95  * (c) Copyright 1996 International Business Machines Corp.
96  * (c) Copyright 1996 Sun Microsystems, Inc.
97  * (c) Copyright 1996 Novell, Inc. 
98  * (c) Copyright 1996 FUJITSU LIMITED.
99  * (c) Copyright 1996 Hitachi.
100  */'
101     echo
102     echo "static int PdmOidStringMapCount = `cat $str_tmp | wc -l`;"
103     echo
104     echo 'static const PdmOidStringMapEntry PdmOidStringMap[] = {'
105     cat $str_tmp
106     echo '};'
107 ) > $str_file
108
109 echo "done"
110
111 rm -f $oid_tmp > /dev/null 2>&1
112 rm -f $str_tmp > /dev/null 2>&1