~ubuntu-branches/ubuntu/saucy/clamav/saucy

« back to all changes in this revision

Viewing changes to win32/compat/regen_errno_defs.sh

  • Committer: Bazaar Package Importer
  • Author(s): Leonel Nunez
  • Date: 2008-02-11 22:52:13 UTC
  • mfrom: (1.1.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20080211225213-p2uwj4czso1w2f8h
Tags: upstream-0.92~dfsg
ImportĀ upstreamĀ versionĀ 0.92~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
 
3
 
IFS='
4
 
'
5
 
GIT_DIR=$(git rev-parse --git-dir)
6
 
if [ -z "$GIT_DIR" ]; then
7
 
        echo "run me from a git path"
8
 
        exit 1
9
 
fi
10
 
 
11
 
BASEDIR="$GIT_DIR/.."
12
 
pushd "$BASEDIR" > /dev/null
13
 
 
14
 
GIT_DIR=$(git rev-parse --git-dir)
15
 
BASEDIR="$GIT_DIR/.."
16
 
 
17
 
DATE=`date`
18
 
OUTFILE="$BASEDIR/win32/compat/w32_errno_defs.c"
19
 
INFILE="$BASEDIR/win32/compat/referrno.txt"
20
 
 
21
 
if [ ! -f "$INFILE" ]; then
22
 
        echo "reference file missing"
23
 
        exit 1
24
 
fi
25
 
 
26
 
 
27
 
cat > "$OUTFILE" <<EOH
28
 
/* Automatically generated on $DATE */
29
 
 
30
 
#include <errno.h>
31
 
 
32
 
static const struct errno_struct {
33
 
        int err;
34
 
        const char *strerr;
35
 
} w32_errnos[] = {
36
 
EOH
37
 
 
38
 
maxerr=0
39
 
 
40
 
for pippo in `cat "$INFILE"`; do
41
 
        symbol=`echo $pippo | cut -d'|' -f1`
42
 
        value=`echo $pippo | cut -d'|' -f2`
43
 
        value=$((value+1000))
44
 
        [ $value -gt $maxerr ] && maxerr=$value
45
 
        descr=`echo $pippo | cut -d'|' -f3`
46
 
        git grep $symbol | egrep -v '(referrno|w32_errno_defs)' > /dev/null
47
 
        used=$?
48
 
        [ $used -ne 0 ] && echo "#ifdef __ERRNO_INCLUDE_UNUSED" >> "$OUTFILE"
49
 
        echo -e "#ifndef $symbol\n#define $symbol $value\n#endif\n{ $symbol, \"$descr\" }," >> "$OUTFILE"
50
 
        [ $used -ne 0 ] && echo "#endif /* __ERRNO_INCLUDE_UNUSED */" >> "$OUTFILE"
51
 
done
52
 
maxerr=$((maxerr+1))
53
 
echo -e "#ifndef EBOGUSWSOCK\n#define EBOGUSWSOCK $maxerr\n#endif\n{ EBOGUSWSOCK, \"WinSock error\"}\n};" >> "$OUTFILE"
54
 
 
55
 
popd >/dev/null
56
 
 
57