1#!/bin/sh
2
3#
4# geninfocontrib_h.sh - infocontrib.h generator script
5#
6# Written by
7#  Marco van den Heuvel <blackystardust68@yahoo.com>
8#
9# This file is part of VICE, the Versatile Commodore Emulator.
10# See README for copyright notice.
11#
12#  This program is free software; you can redistribute it and/or modify
13#  it under the terms of the GNU General Public License as published by
14#  the Free Software Foundation; either version 2 of the License, or
15#  (at your option) any later version.
16#
17#  This program is distributed in the hope that it will be useful,
18#  but WITHOUT ANY WARRANTY; without even the implied warranty of
19#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20#  GNU General Public License for more details.
21#
22#  You should have received a copy of the GNU General Public License
23#  along with this program; if not, write to the Free Software
24#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25#  02111-1307  USA.
26#
27# Usage: geninfocontrib_h.sh <outputtype>
28#                             $1
29#
30
31# Fuck.
32export LC_ALL=C
33
34if test "x$1" = "x"; then
35  echo no output type chosen
36  exit 1
37fi
38
39# extract years and name from input
40extractnames()
41{
42   shift
43   shift
44   years=$1
45   shift
46   if test x"$years" = "x1993-1994,"; then
47     years="$years $1"
48     shift
49   fi
50   name="$*"
51}
52
53extractitem()
54{
55  item=`echo $* | sed -e "s/@b{//" -e "s/}//"`
56}
57
58extractlang()
59{
60  language=$3
61}
62
63extractyears()
64{
65  years=$3
66}
67
68# use system echo if possible, as it supports backslash expansion
69if test -f /bin/echo; then
70  ECHO=/bin/echo
71else
72  if test -f /usr/bin/echo; then
73    ECHO=/usr/bin/echo
74  else
75    ECHO=echo
76  fi
77fi
78
79checkoutput()
80{
81  dooutput=yes
82  case "$data" in
83      @c*|"@itemize @bullet"|@item|"@end itemize") dooutput=no ;;
84  esac
85}
86
87splititem4()
88{
89  item1=$1
90  item2=$2
91  item3=$3
92  item4=$4
93}
94
95buildlists()
96{
97  CORETEAM_MEMBERS=""
98  EXTEAM_MEMBERS=""
99  TRANSTEAM_MEMBERS=""
100
101  for i in $MEMBERS
102  do
103    item=`echo $i | sed 's/+/ /g'`
104    splititem4 $item
105    if test x"$item1" = "xCORE"; then
106      CORETEAM_MEMBERS="$CORETEAM_MEMBERS $i"
107    fi
108    if test x"$item1" = "xEX"; then
109      EXTEAM_MEMBERS="$EXTEAM_MEMBERS $i"
110    fi
111    if test x"$item1" = "xTRANS"; then
112      TRANSTEAM_MEMBERS="$TRANSTEAM_MEMBERS $i"
113    fi
114  done
115}
116
117buildallmembers()
118{
119  ALL_MEMBERS=""
120
121  for i in $MEMBERS
122  do
123    item=`echo $i | sed 's/+/ /g'`
124    splititem4 $item
125    duplicate=no
126    for j in $ALL_MEMBERS
127    do
128      if test x"$item3" = "x$j"; then
129        duplicate=yes
130      fi
131    done
132    if test x"$duplicate" = "xno"; then
133      ALL_MEMBERS="$ALL_MEMBERS $item3"
134    fi
135  done
136}
137
138reverselist()
139{
140  REVLIST=""
141
142  for i in $*
143  do
144    REVLIST="$i $REVLIST"
145  done
146}
147
148rm -f try.tmp
149$ECHO "\\\\n" >try.tmp
150n1=`cat	try.tmp	| wc -c`
151n2=`expr $n1 + 0`
152
153if test x"$n2" = "x3"; then
154    linefeed="\\\\n"
155else
156    linefeed="\\n"
157fi
158rm -f try.tmp
159
160# -----------------------------------------------------------
161# infocontrib.h output type
162
163if test x"$1" = "xinfocontrib.h"; then
164  $ECHO "/*"
165  $ECHO " * infocontrib.h - Text of contributors to VICE, as used in info.c"
166  $ECHO " *"
167  $ECHO " * Autogenerated by geninfocontrib_h.sh, DO NOT EDIT !!!"
168  $ECHO " *"
169  $ECHO " * edit vice.texi and infocontrib.sed to update the info"
170  $ECHO " *"
171  $ECHO " * Written by"
172  $ECHO " *  Marco van den Heuvel <blackystardust68@yahoo.com>"
173  $ECHO " *"
174  $ECHO " * This file is part of VICE, the Versatile Commodore Emulator."
175  $ECHO " * See README for copyright notice."
176  $ECHO " *"
177  $ECHO " *  This program is free software; you can redistribute it and/or modify"
178  $ECHO " *  it under the terms of the GNU General Public License as published by"
179  $ECHO " *  the Free Software Foundation; either version 2 of the License, or"
180  $ECHO " *  (at your option) any later version."
181  $ECHO " *"
182  $ECHO " *  This program is distributed in the hope that it will be useful,"
183  $ECHO " *  but WITHOUT ANY WARRANTY; without even the implied warranty of"
184  $ECHO " *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"
185  $ECHO " *  GNU General Public License for more details."
186  $ECHO " *"
187  $ECHO " *  You should have received a copy of the GNU General Public License"
188  $ECHO " *  along with this program; if not, write to the Free Software"
189  $ECHO " *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA"
190  $ECHO " *  02111-1307  USA."
191  $ECHO " *"
192  $ECHO " */"
193  $ECHO ""
194  $ECHO "#ifndef VICE_INFOCONTRIB_H"
195  $ECHO "#define VICE_INFOCONTRIB_H"
196  $ECHO ""
197  $ECHO "const char info_contrib_text[] ="
198
199  outputok=no
200  coreteamsection=no
201  exteamsection=no
202  transteamsection=no
203  docteamsection=no
204
205  rm -f coreteam.tmp exteam.tmp transteam.tmp docteam.tmp team.tmp
206
207  while read data
208  do
209    if test x"$data" = "x@c ---vice-core-team-end---"; then
210      coreteamsection=no
211    fi
212
213    if test x"$data" = "x@c ---ex-team-end---"; then
214      exteamsection=no
215    fi
216
217    if test x"$data" = "x@c ---translation-team-end---"; then
218      transteamsection=no
219    fi
220
221    if test x"$data" = "x@c ---documentation-team-end---"; then
222      docteamsection=no
223    fi
224
225    if test x"$coreteamsection" = "xyes"; then
226      extractnames $data
227      $ECHO >>coreteam.tmp "    { \"$years\", \"$name\", \"@b{$name}\" },"
228      yearencoded=`$ECHO "$years" | sed 's/ /_/g'`
229      nameencoded=`$ECHO "$name" | sed 's/ /_/g'`
230      $ECHO >>team.tmp "CORE+$yearencoded+$nameencoded"
231    fi
232
233    if test x"$exteamsection" = "xyes"; then
234      extractnames $data
235      $ECHO >>exteam.tmp "    { \"$years\", \"$name\", \"@b{$name}\" },"
236      yearencoded=`$ECHO "$years" | sed 's/ /_/g'`
237      nameencoded=`$ECHO "$name" | sed 's/ /_/g'`
238      $ECHO >>team.tmp "EX+$yearencoded+$nameencoded"
239    fi
240
241    if test x"$transteamsection" = "xyes"; then
242      extractitem $data
243      $ECHO "\"  $data$linefeed\""
244      read data
245      extractyears $data
246      $ECHO "\"  $data$linefeed\""
247      read data
248      extractlang $data
249      $ECHO "\"  $data$linefeed\""
250      read data
251      $ECHO >>transteam.tmp "    { \"$years\", \"$item\", \"$language\", \"@b{$item}\" },"
252      nameencoded=`$ECHO "$item" | sed 's/ /_/g'`
253      $ECHO >>team.tmp "TRANS+$years+$nameencoded+$language"
254    fi
255
256    if test x"$docteamsection" = "xyes"; then
257      extractitem $data
258      $ECHO "\"  $data$linefeed\""
259      read data
260      $ECHO >>docteam.tmp "    \"$item\","
261    fi
262
263    if test x"$data" = "x@c ---vice-core-team---"; then
264      coreteamsection=yes
265    fi
266
267    if test x"$data" = "x@c ---ex-team---"; then
268      exteamsection=yes
269    fi
270
271    if test x"$data" = "x@c ---translation-team---"; then
272      transteamsection=yes
273    fi
274
275    if test x"$data" = "x@c ---documentation-team---"; then
276      docteamsection=yes
277    fi
278
279    if test x"$data" = "x@node Copyright"; then
280      $ECHO "\"$linefeed\";"
281      outputok=no
282    fi
283    if test x"$outputok" = "xyes"; then
284      checkoutput
285      if test x"$dooutput" = "xyes"; then
286        if test x"$data" = "x"; then
287          $ECHO "\"$linefeed\""
288        else
289          $ECHO "\"  $data$linefeed\""
290        fi
291      fi
292    fi
293    if test x"$data" = "x@chapter Acknowledgments"; then
294      outputok=yes
295    fi
296  done
297
298  $ECHO ""
299  $ECHO "vice_team_t core_team[] = {"
300  cat coreteam.tmp
301  rm -f coreteam.tmp
302  $ECHO "    { NULL, NULL, NULL }"
303  $ECHO "};"
304  $ECHO ""
305  $ECHO "vice_team_t ex_team[] = {"
306  cat exteam.tmp
307  rm -f exteam.tmp
308  $ECHO "    { NULL, NULL, NULL }"
309  $ECHO "};"
310  $ECHO ""
311  $ECHO "char *doc_team[] = {"
312  cat docteam.tmp
313  rm -f docteam.tmp
314  $ECHO "    NULL"
315  $ECHO "};"
316  $ECHO ""
317  $ECHO "vice_trans_t trans_team[] = {"
318  cat transteam.tmp
319  rm -f transteam.tmp
320  $ECHO "    { NULL, NULL, NULL, NULL }"
321  $ECHO "};"
322  $ECHO "#endif"
323fi
324
325# -----------------------------------------------------------
326# README output type
327
328if test x"$1" = "xREADME"; then
329  MEMBERS=`cat team.tmp`
330  buildlists
331  outputok=yes
332
333  old_IFS=$IFS
334  IFS=''
335  while read data
336  do
337    if test x"$data" = "x VICE, the Versatile Commodore Emulator"; then
338      IFS=$old_IFS
339      $ECHO " VICE, the Versatile Commodore Emulator"
340      $ECHO ""
341      $ECHO "    Core Team Members:"
342      for i in $CORETEAM_MEMBERS
343      do
344        decodedall=`$ECHO "$i" | sed 's/+/ /g'`
345        splititem4 $decodedall
346        decodedyear=`$ECHO "$item2" | sed 's/_/ /g'`
347        decodedname=`$ECHO "$item3" | sed 's/_/ /g'`
348        $ECHO "    $decodedyear $decodedname"
349      done
350      $ECHO ""
351      $ECHO "    Inactive/Ex Team Members:"
352      for i in $EXTEAM_MEMBERS
353      do
354        decodedall=`$ECHO "$i" | sed 's/+/ /g'`
355        splititem4 $decodedall
356        decodedyear=`$ECHO "$item2" | sed 's/_/ /g'`
357        decodedname=`$ECHO "$item3" | sed 's/_/ /g'`
358        $ECHO "    $decodedyear $decodedname"
359      done
360      $ECHO ""
361      $ECHO "    Translation Team Members:"
362      for i in $TRANSTEAM_MEMBERS
363      do
364        decodedall=`$ECHO "$i" | sed 's/+/ /g'`
365        splititem4 $decodedall
366        decodedyear=`$ECHO "$item2" | sed 's/_/ /g'`
367        decodedname=`$ECHO "$item3" | sed 's/_/ /g'`
368        $ECHO "    $decodedyear $decodedname"
369      done
370      $ECHO ""
371      IFS=''
372      read data
373      while test x"$data" != "x  This program is free software; you can redistribute it and/or"
374      do
375        read data
376      done
377    fi
378
379    if test x"$outputok" = "xyes"; then
380      $ECHO "$data"
381    fi
382  done
383fi
384
385# -----------------------------------------------------------
386# index.html output type
387
388if test x"$1" = "xindexhtml"; then
389  MEMBERS=`cat team.tmp`
390  buildlists
391
392  old_IFS=$IFS
393  IFS=''
394  while read data
395  do
396    if test x"$data" = "x<!--teamstart-->"; then
397      IFS=$old_IFS
398      $ECHO "<!--teamstart-->"
399      $ECHO "<p>"
400      $ECHO "Current VICE team members:"
401      decodedname=""
402      for i in $CORETEAM_MEMBERS
403      do
404        if test x"$decodedname" != "x"; then
405          $ECHO "$decodedname,"
406        fi
407        decodedall=`$ECHO "$i" | sed 's/+/ /g'`
408        splititem4 $decodedall
409        decodedname=`$ECHO "$item3" | sed "s/_/ /g;s/�/\&eacute;/g;s/\\\'e/\&eacute;/g"`
410      done
411      $ECHO "$decodedname."
412      $ECHO "</p>"
413      $ECHO ""
414      $ECHO "<p>Of course our warm thanks go to everyone who has helped us in developing"
415      $ECHO "VICE during these past few years. For a more detailed list look in the"
416      $ECHO "<a href=\"vice_18.html\">documentation</a>."
417      $ECHO ""
418      $ECHO ""
419      $ECHO "<hr>"
420      $ECHO ""
421      $ECHO "<h1><a NAME=\"copyright\"></a>Copyright</h1>"
422      $ECHO ""
423      $ECHO "<p>"
424      $ECHO "The VICE is copyrighted to:"
425      buildallmembers
426      decodedname=""
427      for i in $ALL_MEMBERS
428      do
429        if test x"$decodedname" != "x"; then
430          $ECHO "$decodedname,"
431        fi
432        if test x"$i" != "x"; then
433          decodedname=`$ECHO "$i" | sed "s/_/ /g;s/�/\&eacute;/g;s/\\\'e/\&eacute;/g"`
434        fi
435      done
436      $ECHO "$decodedname."
437      IFS=''
438      read data
439      while test x"$data" != "x<!--teamend-->"
440      do
441        read data
442      done
443    fi
444
445    $ECHO "$data"
446  done
447fi
448