1 # ===================================================================== 2 # viewSource: W-TW program source file visualizer. 3 # 4 # Copyright (c) 2008,2009 Carlo Strozzi 5 # 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; version 2 dated June, 1991. 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., 675 Mass Ave, Cambridge, MA 02139, USA. 18 # 19 # ===================================================================== 20 21 # ===================================================================== 22 # Local variables and functions 23 # ===================================================================== 24 25 cgi.group = () 26 cgi.group.literal = () 27 cat_arg = () 28 29 # ===================================================================== 30 # Main program 31 # ===================================================================== 32 33 # Load call arguments. 34 csaGetArgs GET 35 36 . $CSA_ROOT/lib/group-stuff.rc 37 38 . $CSA_ROOT/lib/group-editor.rc 39 40 . $CSA_ROOT/lib/tpl-stuff.rc 41 42 # Complain if no program source file no. was supplied. 43 ~ $'cgi.source' [1-9]* || csaExit.fault 0038 44 45 cgi.source = `{awktable -i $CSA_ROOT/lib/source.dat -- \ 46 '$src_num=="'$'cgi.source'"' {print $src_file; exit}'} 47 48 # Complain if a nonexistent program source file was specified. 49 ~ $'cgi.source' () && csaExit.fault 0038 50 51 ~ $'cgi.source' */tw.version || cat_arg = -n 52 53 # Be wise, use FireFox, not MSIE ! 54 if (~ $HTTP_USER_AGENT *' MSIE '*) { 55 echo '
' >> $tmp1 58 csaExit.bdata --mime text/html $tmp1 59 } 60 61 cat $cat_arg $CSA_ROOT/$'cgi.source' > $tmp1 62 63 csaExit.bdata --mime text/plain $tmp1 64 65 # End of program.