"Fossies" - the Fresh Open Source Software Archive

Member "libzip-1.6.0/lib/make_zip_err_str.sh" (24 Jan 2020, 2544 Bytes) of package /linux/misc/libzip-1.6.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 #  make_zip_err_str.sh: create zip_err_str.c from zip.h
    4 #  Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
    5 #
    6 #  This file is part of libzip, a library to manipulate ZIP archives.
    7 #  The authors can be contacted at <libzip@nih.at>
    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 
   35 if [ "$#" -ne 2 ]
   36 then
   37     echo "Usage: $0 in_file out_file" >&2
   38     echo "       e.g. $0 zip.h zip_err_str.c" >&2
   39     exit 1
   40 fi
   41 
   42 if [ "$1" = "$2" ]
   43 then
   44     echo "$0: error: output file = input file" >&2
   45     exit 1
   46 fi
   47 
   48 cat <<EOF >> "$2.$$" || exit 1
   49 /*
   50    This file was generated automatically by $0
   51    from $1; make changes there.
   52  */
   53 
   54 #include "zipint.h"
   55 
   56 const char * const _zip_err_str[] = {
   57 EOF
   58 
   59 sed -n  '/^#define ZIP_ER_/ s/.*\/\* . \([^*]*\) \*\//    "\1",/p' "$1" \
   60     >> "$2.$$" || exit 1
   61 
   62 cat <<EOF >> "$2.$$" || exit 1
   63 };
   64 
   65 const int _zip_nerr_str = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]);
   66 
   67 #define N ZIP_ET_NONE
   68 #define S ZIP_ET_SYS
   69 #define Z ZIP_ET_ZLIB
   70 
   71 const int _zip_err_type[] = {
   72 EOF
   73 
   74 sed -n  '/^#define ZIP_ER_/ s/.*\/\* \(.\) \([^*]*\) \*\//    \1,/p' "$1" \
   75     >> "$2.$$" || exit 1
   76 
   77 echo '};' >> "$2.$$" || exit 1
   78 
   79 mv "$2.$$" "$2" || exit 1