Thomas Klausner | 1697b89 | 1999-07-25 21:09:03 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Dieter Baron | 775c259 | 2004-04-25 16:20:16 +0000 | [diff] [blame] | 3 | # make_zip_err_str.sh: create zip_err_str.c from zip.h |
Thomas Klausner | 12c354f | 2014-06-15 23:57:07 +0200 | [diff] [blame] | 4 | # Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner |
Dieter Baron | 775c259 | 2004-04-25 16:20:16 +0000 | [diff] [blame] | 5 | # |
| 6 | # This file is part of libzip, a library to manipulate ZIP archives. |
Dieter Baron | b86c433 | 2007-11-07 14:35:13 +0100 | [diff] [blame] | 7 | # The authors can be contacted at <libzip@nih.at> |
Dieter Baron | 775c259 | 2004-04-25 16:20:16 +0000 | [diff] [blame] | 8 | # |
| 9 | # Redistribution and use in source and binary forms, with or without |
| 10 | # modification, are permitted provided that the following conditions |
| 11 | # are met: |
| 12 | # 1. Redistributions of source code must retain the above copyright |
| 13 | # notice, this list of conditions and the following disclaimer. |
| 14 | # 2. Redistributions in binary form must reproduce the above copyright |
| 15 | # notice, this list of conditions and the following disclaimer in |
| 16 | # the documentation and/or other materials provided with the |
| 17 | # distribution. |
| 18 | # 3. The names of the authors may not be used to endorse or promote |
| 19 | # products derived from this software without specific prior |
| 20 | # written permission. |
| 21 | # |
| 22 | # THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS |
| 23 | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 25 | # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY |
| 26 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 28 | # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 29 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| 30 | # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 31 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 32 | # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | |
| 34 | |
Thomas Klausner | 1697b89 | 1999-07-25 21:09:03 +0000 | [diff] [blame] | 35 | if [ "$#" -ne 2 ] |
| 36 | then |
Dieter Baron | b10b8ab | 1999-07-25 22:51:30 +0000 | [diff] [blame] | 37 | echo "Usage: $0 in_file out_file" >&2 |
| 38 | echo " e.g. $0 zip.h zip_err_str.c" >&2 |
Thomas Klausner | 1697b89 | 1999-07-25 21:09:03 +0000 | [diff] [blame] | 39 | exit 1 |
| 40 | fi |
| 41 | |
| 42 | if [ "$1" = "$2" ] |
| 43 | then |
Dieter Baron | b10b8ab | 1999-07-25 22:51:30 +0000 | [diff] [blame] | 44 | echo "$0: error: output file = input file" >&2 |
Thomas Klausner | 1697b89 | 1999-07-25 21:09:03 +0000 | [diff] [blame] | 45 | exit 1 |
| 46 | fi |
| 47 | |
Dieter Baron | b10b8ab | 1999-07-25 22:51:30 +0000 | [diff] [blame] | 48 | cat <<EOF >> "$2.$$" || exit 1 |
Dieter Baron | 775c259 | 2004-04-25 16:20:16 +0000 | [diff] [blame] | 49 | /* |
| 50 | This file was generated automatically by $0 |
| 51 | from $1; make changes there. |
Dieter Baron | 775c259 | 2004-04-25 16:20:16 +0000 | [diff] [blame] | 52 | */ |
Thomas Klausner | 1697b89 | 1999-07-25 21:09:03 +0000 | [diff] [blame] | 53 | |
Dieter Baron | 5149dfb | 2003-10-05 16:05:25 +0000 | [diff] [blame] | 54 | #include "zipint.h" |
Dieter Baron | b10b8ab | 1999-07-25 22:51:30 +0000 | [diff] [blame] | 55 | |
Dieter Baron | e3f91ef | 2003-10-06 02:50:14 +0000 | [diff] [blame] | 56 | const char * const _zip_err_str[] = { |
Dieter Baron | b10b8ab | 1999-07-25 22:51:30 +0000 | [diff] [blame] | 57 | EOF |
| 58 | |
Thomas Klausner | d0147e9 | 2004-11-17 21:55:17 +0000 | [diff] [blame] | 59 | sed -n '/^#define ZIP_ER_/ s/.*\/\* . \([^*]*\) \*\// "\1",/p' "$1" \ |
Dieter Baron | b10b8ab | 1999-07-25 22:51:30 +0000 | [diff] [blame] | 60 | >> "$2.$$" || exit 1 |
Dieter Baron | 5149dfb | 2003-10-05 16:05:25 +0000 | [diff] [blame] | 61 | |
| 62 | cat <<EOF >> "$2.$$" || exit 1 |
| 63 | }; |
| 64 | |
Dieter Baron | e3f91ef | 2003-10-06 02:50:14 +0000 | [diff] [blame] | 65 | const int _zip_nerr_str = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]); |
Dieter Baron | 5149dfb | 2003-10-05 16:05:25 +0000 | [diff] [blame] | 66 | |
| 67 | #define N ZIP_ET_NONE |
| 68 | #define S ZIP_ET_SYS |
Thomas Klausner | d0147e9 | 2004-11-17 21:55:17 +0000 | [diff] [blame] | 69 | #define Z ZIP_ET_ZLIB |
Dieter Baron | 5149dfb | 2003-10-05 16:05:25 +0000 | [diff] [blame] | 70 | |
| 71 | const int _zip_err_type[] = { |
| 72 | EOF |
| 73 | |
Thomas Klausner | d0147e9 | 2004-11-17 21:55:17 +0000 | [diff] [blame] | 74 | sed -n '/^#define ZIP_ER_/ s/.*\/\* \(.\) \([^*]*\) \*\// \1,/p' "$1" \ |
Dieter Baron | 5149dfb | 2003-10-05 16:05:25 +0000 | [diff] [blame] | 75 | >> "$2.$$" || exit 1 |
| 76 | |
Dieter Baron | b10b8ab | 1999-07-25 22:51:30 +0000 | [diff] [blame] | 77 | echo '};' >> "$2.$$" || exit 1 |
| 78 | |
| 79 | mv "$2.$$" "$2" || exit 1 |