"Fossies" - the Fresh Open Source Software Archive

Member "xarchive-0.2.8-6/wrappers/ace.src" (14 Jan 2006, 4522 Bytes) of package /linux/privat/old/xarchive-0.2.8-6.tar.gz:


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

    1 #! /path/to/bash
    2 # ace-wrap.sh - bash unace wrapper for xarchive 
    3 # Copyright (C) 2005 Lee Bigelow <ligelowbee@yahoo.com> 
    4 # 
    5 # This program is free software; you can redistribute it and/or modify
    6 # it under the terms of the GNU General Public License as published by
    7 # the Free Software Foundation; either version 2 of the License, or
    8 # (at your option) any later version.
    9 # 
   10 # This program is distributed in the hope that it will be useful,
   11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13 # GNU General Public License for more details.
   14 # 
   15 # You should have received a copy of the GNU General Public License
   16 # along with this program; if not, write to the Free Software
   17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   18 E_UNSUPPORTED=65
   19 
   20 # Supported file extentions for ace 
   21 EXTS="ace"
   22 
   23 # Program to wrap
   24 ACE_PROG="unace"
   25 
   26 # Setup awk program
   27 AWK_PROGS="mawk gawk awk"
   28 AWK_PROG=""
   29 for awkprog in $AWK_PROGS; do
   30     if [ "$(which $awkprog)" ]; then
   31         AWK_PROG="$awkprog"
   32         break
   33     fi
   34 done
   35 
   36 # Setup xterm program to use
   37 XTERM_PROGS="xterm rxvt xvt wterm aterm Eterm"
   38 XTERM_PROG=""
   39 for xtermprog in $XTERM_PROGS; do
   40     if [ "$(which $xtermprog)" ]; then
   41         XTERM_PROG="$xtermprog"
   42         break
   43     fi
   44 done
   45 
   46 
   47 # setup variables opt and archive.
   48 # the shifting will leave the files passed as
   49 # all the remaining args "$@"
   50 opt="$1"
   51 shift 1
   52 archive="$1"
   53 shift 1
   54 
   55 # Command line options for prog functions
   56 # disable comments when opening
   57 OPEN_OPTS="v -c-"
   58 ADD_OPTS=""
   59 NEW_OPTS=""
   60 REMOVE_OPTS=""
   61 EXTRACT_OPTS="x -o -y"
   62 
   63 # the option switches
   64 case "$opt" in
   65     -i) # info: output supported extentions for progs that exist
   66         if [ "$(which $ACE_PROG)" ]; then
   67             for ext in $EXTS; do
   68                 printf "%s;" $ext
   69             done
   70         else
   71             echo command $ACE_PROG not found > /dev/stderr 
   72             echo extentions $EXTS ignored > /dev/stderr 
   73         fi
   74         printf "\n"
   75         exit
   76         ;;
   77 
   78     -o) # open: mangle output of ace cmd for xarchive 
   79         # format of ace output:
   80         # Date    ≥Time ≥Packed     ≥Size     ≥Ratio≥File
   81         # 17.09.02≥00:32≥     394116≥   414817≥  95%≥ OggDS0993.exe 
   82 	# 1                   2         3        4    5
   83 	$ACE_PROG $OPEN_OPTS "$archive" | $AWK_PROG -v uuid=${UID} '
   84         #only process lines starting with two numbers and a dot
   85         /^[0-9][0-9]\./ {
   86           date=substr($1,1,8)
   87           time=substr($1,10,5)
   88           #need to strip the funky little 3 off the end of size
   89           size=substr($3,1,(length($3)-1))
   90           
   91           #split line at ratio and a space, second item is our name
   92           split($0, linesplit, ($4 " "))
   93           name=linesplit[2]
   94           
   95           uid=uuid; gid=uuid; link="-"; attr="-"
   96           printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
   97         }'
   98 	exit
   99         ;;
  100 
  101     -a) # add:  to archive passed files
  102         # we only want to add the file's basename, not
  103         # the full path so...
  104         # ONY HAVE UNACE, no adding...
  105         # while [ "$1" ]; do
  106         #     cd "$(dirname "$1")"
  107         #     $ACE_PROG $ADD_OPTS "$archive" "$(basename "$1")"
  108         #     shift 1
  109         # done
  110         exit $E_UNSUPPORTED 
  111         ;;
  112 
  113     -n) # new: create new archive with passed files 
  114         # create will only be passed the first file, the
  115         # rest will be "added" to the new archive
  116         # ONY HAVE UNACE, no creating...
  117         # cd "$(dirname "$1")"
  118         # $ACE_PROG $NEW_OPTS "$archive" "$(basename "$1")"
  119         exit $E_UNSUPPORTED 
  120         ;;
  121 
  122     -r) # remove: from archive passed files 
  123         # ONY HAVE UNACE, no removing...
  124         # $ACE_PROG $REMOVE_OPTS "$archive" "$@"
  125         exit $E_UNSUPPORTED 
  126         ;;
  127 
  128     -e) # extract: from archive passed files 
  129         # xarchive will put is the right extract dir
  130         # so we just have to extract.
  131         $XTERM_PROG -e $ACE_PROG $EXTRACT_OPTS "$archive"
  132         exit
  133         ;;
  134 
  135     -v) # view: from archive passed files 
  136         exit $E_UNSUPPORTED
  137         ;;
  138 
  139      *) echo "error, option $opt not supported"
  140         echo "use one of these:" 
  141         echo "-i                #info" 
  142         echo "-o archive        #open" 
  143         echo "-a archive files  #add" 
  144         echo "-n archive file   #new" 
  145         echo "-r archive files  #remove" 
  146         echo "-e archive files  #extract" 
  147         echo "-v archive file   #view"  
  148         exit
  149 esac