more example scripts from Teckids e.V.
[shellsnippets/shellsnippets.git] / mksh / website.shar
1 # This is a shell archive.  Save it in a file, remove anything before
2 # this line, and then unpack it by entering "sh file".  Note, it may
3 # create directories; files and directories will be owned by you and
4 # have default permissions.
5 #
6 # This archive contains:
7 #
8 #       LICENCE
9 #       Makefile
10 #       mk/common
11 #       mk/htsconv
12 #       mk/inc2htm
13 #       mk/inc2rss
14 #       mk/mkdepend
15 #       mk/parser
16 #       mk/strftm.c
17 #       mk/ttf2png
18 #
19 echo x - LICENCE
20 sed 's/^X//' >LICENCE << 'END-of-LICENCE'
21 X$MirOS: www/LICENCE,v 1.21 2011/03/11 17:57:42 bsiegert Exp $
22 X
23 X[…]
24 XThe MirOS Project web site source code is
25 XCopyright © 2007, 2008, 2009, 2011
26 X       Thorsten “mirabilos” Glaser <tg@mirbsd.de>
27 XCopyright © 2006, 2008, 2011
28 X       Benny Siegert <bsiegert@mirbsd.org>
29 XThis source code is available under the terms of the stan-
30 Xdard MirOS licence, see […] mk/common
31 END-of-LICENCE
32 echo x - Makefile
33 sed 's/^X//' >Makefile << 'END-of-Makefile'
34 X# $MirOS: www/Makefile,v 1.76 2011/06/06 22:05:48 tg Exp $
35 X#-
36 X# This file is part of the website of The MirOS Project, which is
37 X# copyrighted material, please read the LICENCE file for details.
38 X
39 X.ifndef TOP
40 XTOP!=          realpath ${.CURDIR:Q}
41 XDST!=          realpath ${.OBJDIR:Q}
42 X.MAKEFLAGS:=   ${.MAKEFLAGS} TOP=${TOP:Q} DST=${DST:Q}
43 X.endif
44 X
45 Xall:
46 X
47 X.include <bsd.own.mk>
48 XBSDSRCDIR?=/nonexistant
49 X.if exists(${DST}/.depend)
50 X.  include "${DST}/.depend"
51 X.endif
52 X
53 XU_ENV+=                TOP=${TOP:Q} DST=${DST:Q} MKSH=${MKSH:Q} SHELL=${MKSH:Q} TZ=UTC
54 X
55 XSRCS+=         a4rcontrb.hts a4rp5bsd.hts
56 XSRCS+=         about.hts
57 XSRCS+=         anargeek.hts
58 XSRCS+=         ann-10.hts
59 XSRCS+=         bt.hts
60 XSRCS+=         clog11.hts
61 XSRCS+=         danke.hts
62 XSRCS+=         devel.hts
63 XSRCS+=         errata10.hts
64 XSRCS+=         getting.hts
65 XSRCS+=         irc.hts
66 XSRCS+=         jupp.hts
67 XSRCS+=         ksh-chan.hts
68 XSRCS+=         kwalletcli.hts
69 XSRCS+=         main.hts
70 XSRCS+=         makefs.hts
71 XSRCS+=         mksh.hts mksh_bld.hts mksh_old.hts
72 XSRCS+=         oldnews.hts
73 XSRCS+=         pkgsrc.hts
74 XSRCS+=         ports.hts
75 XSRCS+=         projects.hts
76 XSRCS+=         randex.hts
77 XSRCS+=         rss.hts
78 XSRCS+=         tags.hts
79 XCLEANFILES+=   tags.lst tags.out
80 XTAGCLOUD+=     debian
81 XTAGCLOUD+=     mksh
82 XTAGCLOUD+=     pcli
83 XWLOGS=         9 10
84 X
85 X# legacy content
86 XSRCS+=         ann-7.hts ann-8.hts anoncvs.hts bsd-intro.hts clog-2004.hts \
87 X               clog-2005.hts clog-2006.hts cvsweb.hts docs.hts errata8.hts \
88 X               faq.es.hts faq.hts history.hts ipv6-sixxs.hts \
89 X               isdn.hts mirrors.hts mirwarum.hts
90 XSRCS+=         wlog-0.hts wlog-1.hts wlog-2.hts wlog-3.hts wlog-4.hts \
91 X               wlog-5.hts wlog-6.hts wlog-7.hts wlog-8.hts
92 X
93 XINCSRCS+=      datatest
94 X
95 XINCSRCS+=      news
96 Xnews.cut: stamp_htm_news
97 XCLEANFILES+=   news.cut
98 X
99 X.PATH: ${TOP}/src
100 X
101 X_htm_2xhtml=   (tr '\n' '﷐' | \
102 X               sed 's\ 1^.*<html\ 1'${_xhtmlbeg:Q}'\ 1' | \
103 X               tr '﷐' '\n')
104 X_xhtmldtd=     ${TOP}/mk/xhtml11.dtd
105 X_xhtmlbeg=     <?xml version="1.0"?> \
106 X               <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" \
107 X                "file://${_xhtmldtd}"> \
108 X               <html
109 X
110 Xall:
111 Xinstall: site.tgz.stamp
112 X
113 XSTRFTM_MAKE=   cd ${.CURDIR:Q} && ${MAKE} -f ${.SYSMK}/bsd.prog.mk NOMAN=Yes \
114 X                   VPATH=${.CURDIR:Q}/mk PROG=strftm
115 X
116 XOBJS+=         ${SRCS:M*.hts:S/hts$/htm~/}
117 XVOBJS+=                ${SRCS:M*.hts:S/hts$/val/}
118 XCLEANFILES+=   ${SRCS:M*.hts:S/hts$/htm~/}
119 X
120 XDEPSRCS+=      ${SRCS:S,^,src/,}
121 XINCSRCS+=      ${WLOGS:S/^/wlog-/}
122 XINCSRCS+=      ${TAGCLOUD:S/^/tag_/}
123 X
124 X.for _i in ${INCSRCS}
125 XDEPSRCS+=      data/${_i}.cfg
126 XGENSRCS+=      stamp_htm_${_i} stamp_rss_${_i}
127 XCLEANFILES+=   stamp_tag_${_i}
128 X
129 Xstamp_htm_${_i}: ${DEPS_mk_inc2htm} ${DEPS_data_${_i}_cfg}
130 X       ${U_ENV} ${MKSH} ${TOP}/mk/inc2htm ${_i} >$@ || (rm -f $@; exit 1)
131 X
132 Xstamp_rss_${_i}: ${DEPS_mk_inc2rss} strftm ${DEPS_data_${_i}_cfg}
133 X       ${U_ENV} PATH=.:$$PATH ${MKSH} ${TOP}/mk/inc2rss ${_i} >$@ || \
134 X           (rm -f $@; exit 1)
135 X.endfor
136 X
137 XDEPSRCS+=      mk/inc2htm mk/inc2rss
138 XOBJS+=         ${GENSRCS}
139 XCLEANFILES+=   ${GENSRCS}
140 X
141 Xclean:
142 X       -${STRFTM_MAKE} clean
143 X.for _i in ${GENSRCS}
144 X       -rm -rf $$(<${_i})
145 X.endfor
146 X       -rm -rf dst permalinks
147 X       -rm -f ${CLEANFILES} site.tgz* *.tmp *~
148 X
149 Xcleandir: clean
150 X       -rm -rf hashed
151 X       -rm -f .depend ${CLEANFILES:M*~:S/~$//}
152 X
153 Xdeinstall:
154 X       -rm -rf dst site.tgz*
155 X
156 Xreinstall: deinstall .WAIT install
157 X
158 Xall: ${OBJS}
159 X
160 Xstrftm: mk/strftm.c
161 X       ${STRFTM_MAKE} $@
162 X
163 Xsite.tgz.stamp: _reinstall
164 X#      find dst | sort | sed -e '/^dst$$/d' -e 's,^dst/,,' | \
165 X#          (cd dst && cpio -voC512 -Hustar -Mdist) | gzip -n9 >site.tgz.tmp
166 X#      mv site.tgz.tmp site.tgz
167 X       :>$@
168 X
169 X.for _i in ${WLOGS}
170 XWLOG_LATEST:=${_i}
171 X.endfor
172 X
173 X_reinstall:
174 X       -rm -rf dst
175 X       mkdir dst dst/permalinks
176 X       pax -rw -pe -v hashed dst/
177 X       pax -rw -pe -dv ${OBJS:Nstamp_*:S/htm~$/htm/} dst/
178 X.for _i in ${GENSRCS}
179 X       pax -rw -pe -dv $$(<${_i}) dst/
180 X.endfor
181 X       cd ${TOP}/files && pax -rw -pe -v . ${DST}/dst/
182 X       cd ${TOP} && pax -rw -pe -v pics ${DST}/dst/
183 X       cd dst && \
184 X           ln -sf wlog-${WLOG_LATEST}.htm wlog.htm && \
185 X           ln -sf wlog-${WLOG_LATEST}.rss wlog.rss && \
186 X           rm -rf $$(find . -name CVS -o -name .cvsignore)
187 X       chgrp -R miros-cvswww dst
188 X       chmod -R ug=rwX,o=rX dst
189 X       chmod a+x dst/cvs.cgi
190 X
191 X.SUFFIXES: .val .htm~ .hts
192 X
193 X.hts.htm~:
194 X       @dstd='$@'; dstf=$${dstd%~}; rm -f $@; \
195 X        print -r "(. mk/htsconv; mws_basepath $$dstf; mws__do $<) >$$dstf"; \
196 X        export ${U_ENV}; if (cd ${DST}; . ${TOP}/mk/htsconv; \
197 X           mws_basepath $$dstf; mws__do $<) >$@; then \
198 X               (. ${TOP}/mk/htsconv; mws_moveifchange -k $$dstd $$dstf); \
199 X        else \
200 X               rm -f $@; \
201 X               exit 1; \
202 X       fi
203 X
204 X.htm~.val:
205 X       @print -r Creating ${@:Q} from ${<:Q} ...
206 X       @${_htm_2xhtml} <$< >$@
207 X
208 X.ifdef validate
209 XVOBJS:=                ${validate:=.val}
210 X
211 X.MAIN: validation
212 X.endif
213 X
214 Xvalidation: .PHONY ${VOBJS}
215 X       @print -r Validating ${.ALLSRC:Q} ...
216 X       @xmlstarlet val -d ${_xhtmldtd} ${.ALLSRC}
217 X       @print '\nValidation complete.'
218 X
219 X.PHONY: clean cleandir depend install deinstall reinstall _reinstall \
220 X       cp-herc cp-heph rs-heph rs-eurynome rs-pfau
221 X
222 X#cp-herc: site.tgz.stamp
223 X#      ssh hercs 'cd /var/www/oldsite; tar xzvf -' <site.tgz
224 X#
225 X#cp-heph: site.tgz.stamp
226 X#      ssh hephaistos 'cd Web; tar xzvpf -' <site.tgz
227 X
228 Xrs-heph:
229 X       rsync -rxlztpgavPHK dst/ hephaistos:Web/
230 X
231 Xrs-eurynome:
232 X       rsync -rxlztpgavPHK --rsh='ssh -4' dst/ eurynome:/var/anoncvs/anoncvs/www/
233 X
234 Xrs-pfau:
235 X       rsync -rxlztpgavPHK --rsh='ssh -4' dst/ pfau:/Web/
236 X
237 Xdepend: .depend
238 X
239 X.depend: ${TOP}/mk/mkdepend ${DEPSRCS}
240 X       -rm -f $@
241 X       ${STRFTM_MAKE} depend
242 X       ${U_ENV} ${MKSH} ${TOP}/mk/mkdepend ${DEPSRCS}
243 X
244 Xlazy: .PHONY
245 X       cd ${.CURDIR} && make depend && make && \
246 X           make _reinstall && exec make rs-eurynome rs-heph rs-pfau tagslst
247 X
248 Xtagslst: .PHONY
249 X       @(echo === TAGS USED/UNUSED/ACCOUNTED FOR ==; cat stamp_tag_* | \
250 X           sort -u | comm - tags.out) | tee tags.lst
251 X
252 X.include <bsd.obj.mk>
253 END-of-Makefile
254 echo x - mk/common
255 sed 's/^X//' >mk/common << 'END-of-mk/common'
256 Xrcsid_common='$MirOS: www/mk/common,v 1.3 2009/10/31 17:02:38 tg Exp $'
257 X#-
258 X# Copyright (c) 2007, 2008
259 X#      Thorsten Glaser <tg@mirbsd.de>
260 X#
261 X# Provided that these terms and disclaimer and all copyright notices
262 X# are retained or reproduced in an accompanying document, permission
263 X# is granted to deal in this work without restriction, including un-
264 X# limited rights to use, publicly perform, distribute, sell, modify,
265 X# merge, give away, or sublicence.
266 X#
267 X# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
268 X# the utmost extent permitted by applicable law, neither express nor
269 X# implied; without malicious intent or gross negligence. In no event
270 X# may a licensor, author or contributor be held liable for indirect,
271 X# direct, other damage, loss, or other issues arising in any way out
272 X# of dealing in the work, even if advised of the possibility of such
273 X# damage or existence of a defect, except proven that it results out
274 X# of said person's immediate fault when using the work as intended.
275 X
276 X# RFC 2396 and some optional characters _plus_ apostrophe
277 X# -> escapes all shell meta-characters as well
278 Xfunction uri_escape {
279 X       if (( $# )); then
280 X               print -nr -- "$@"
281 X       else
282 X               cat
283 X       fi | sed -e '
284 X           s.%.%25.g
285 X           s.;.%3B.g
286 X           s./.%2F.g
287 X           s.?.%3F.g
288 X           s.:.%3A.g
289 X           s.@.%40.g
290 X           s.&.%26.g
291 X           s.=.%3D.g
292 X           s.+.%2B.g
293 X           s.\$.%24.g
294 X           s.,.%2C.g
295 X           s.  .%09.g
296 X           s. .%20.g
297 X           s.<.%3C.g
298 X           s.>.%3E.g
299 X           s.#.%23.g
300 X           s.".%22.g
301 X           s.{.%7B.g
302 X           s.}.%7D.g
303 X           s.|.%7C.g
304 X           s.\\.%5C.g
305 X           s.\^.%5E.g
306 X           s.\[.%5B.g
307 X           s.\].%5D.g
308 X           s.`.%60.g
309 X           s.'\''.%27.g
310 X       '
311 X}
312 X
313 X# escape XHTML characters (three mandatory XML ones plus double quotes,
314 X# the latter in an XML safe fashion numerically though)
315 Xfunction xhtml_escape {
316 X       if (( $# )); then
317 X               print -nr -- "$@"
318 X       else
319 X               cat
320 X       fi | sed \
321 X           -e 's\ 1&\ 1\&amp;\ 1g' \
322 X           -e 's\ 1<\ 1\&lt;\ 1g' \
323 X           -e 's\ 1>\ 1\&gt;\ 1g' \
324 X           -e 's\ 1"\ 1\&#34;\ 1g'
325 X}
326 X
327 X# escape ampersands for sed (pipe only: post-processing)
328 Xfunction sed_escape {
329 X       sed -e 's\ 1&\ 1\\\&\ 1g'
330 X}
331 END-of-mk/common
332 echo x - mk/htsconv
333 sed 's/^X//' >mk/htsconv << 'END-of-mk/htsconv'
334 Xrcsid_htsconv='$MirOS: www/mk/htsconv,v 1.59 2011/03/21 16:18:48 tg Exp $'
335 X#-
336 X# This file is part of the website of The MirOS Project, which is
337 X# copyrighted material, please read the LICENCE file for details.
338 X
339 X#DEPEND mk/common
340 X. "$TOP"/mk/common
341 X
342 Xmws__pagename=
343 Xmws__header=
344 Xmws__rss=
345 Xmws__difftag=MBSD_HTSCONV_GENDATE_TAG_11353
346 Xunset mws__srcfile
347 Xunset mws__abspath
348 Xunset mws__relpath
349 Xunset mws__canonpath
350 Xunset mws__headline
351 Xunset mws__fontsize
352 Xmws__canonsite=https://www.mirbsd.org
353 Xnl='
354 X'
355 X
356 Xfunction mws__do {
357 X       mws__srcfile=$1
358 X
359 X       set +e
360 X       . "$1"
361 X}
362 X
363 Xfunction mws_setname {
364 X       mws__pagename=$2
365 X       # change index to mark $1
366 X}
367 X
368 Xfunction mws_setheadline {
369 X       mws__headline=$*
370 X}
371 X
372 Xfunction mws_setheadsize {
373 X       mws__fontsize=$1
374 X       (( mws__fontsize > 2 && mws__fontsize < 255 )) || unset mws__fontsize
375 X}
376 X
377 Xfunction mws_setrss {
378 X       mws__rss="\\
379 X <link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"$1\" />"
380 X       # this is for not doing the newline when no RSS is applicable
381 X}
382 X
383 Xfunction mws_subdir {
384 X       if [[ $1 = - ]]; then
385 X               mws__relpath=$mws__abspath/
386 X               return
387 X       fi
388 X       integer i=$1
389 X       mws__relpath=
390 X       while (( i-- )); do
391 X               mws__relpath=../$mws__relpath
392 X       done
393 X}
394 X
395 Xfunction mws_basepath {
396 X       mws__canonpath=$mws__canonsite/$1
397 X}
398 X
399 X# this only matches lines like this:
400 X# ^<h[23456] id="…id…">…content…</h[23456]>$
401 Xfunction mws_maketoc {
402 X       local level=0 sps='       ' line lna llv lid
403 X
404 X       if [[ -z $mws__srcfile ]]; then
405 X               print -u2 Internal error: not called via mws__do!
406 X               exit 1
407 X       fi
408 X       (grep '^<h[2-6] id="[^">]*">.*</h[2-6]>$' "$mws__srcfile"
409 X        print '<h1') |&
410 X       while IFS= read -pr line; do
411 X               set -A lna -- $line
412 X               (( llv = ${lna[0]#\<h} - 1 ))
413 X               while (( level < llv )); do
414 X                       if (( level )); then
415 X                               print "${sps::level}<li><ul>"
416 X                       else
417 X                               print "<ul>"
418 X                       fi
419 X                       let ++level
420 X               done
421 X               while (( level > llv )); do
422 X                       let --level
423 X                       if (( level )); then
424 X                               print "${sps::level}</ul></li>"
425 X                       else
426 X                               print "</ul>"
427 X                       fi
428 X               done
429 X               (( level )) || break
430 X               lid=${line#\<h? id=\"}
431 X               lid=${lid%%\"*}
432 X               line=${line#*\>}
433 X               line=${line%\</h?\>}
434 X               print "${sps::level}<li><a href=\"#$lid\">$line</a></li>"
435 X       done
436 X}
437 X
438 Xfunction mws_makepic {
439 X       local hpic htit fsiz hmag
440 X
441 X       htit=$1
442 X       fsiz=${2:-0}
443 X       hmag=${3:-u}
444 X
445 X       (( fsiz > 2 && fsiz < 255 )) || unset fsiz
446 X
447 X       hpic=$(cksum -a oaat <<<"$hmag,$fsiz,$htit").png
448 X       if [[ ! -s hashed/$hpic ]] && whence -p php >/dev/null; then
449 X               mkdir -p hashed
450 X               php "$TOP"/mk/ttf2png "$htit" $fsiz >hashed/$hpic
451 X       fi
452 X       print $hpic
453 X}
454 X
455 Xfunction mws_makepiclink {
456 X       local ptext pfile
457 X
458 X       pfile=$(mws_makepic "$@")
459 X       ptext=$(xhtml_escape "$1")
460 X
461 X       print "<img src=\"@@RELPATH@@hashed/$pfile\" alt=\"$ptext\" />"
462 X}
463 X
464 Xfunction mws_putheader {
465 X       local rcsid=$1
466 X
467 X       if [[ -z $mws__canonpath ]]; then
468 X               print -u2 Internal error: mws_basepath not called!
469 X               exit 1
470 X       fi
471 X       [[ -n $mws__headline ]] && mws__headline="$nl<h1>$(mws_makepiclink \
472 X           "$mws__headline" "$mws__fontsize" s)</h1>"
473 X       mws__content <<-EOF
474 X               <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
475 X                "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
476 X               <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>
477 X                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
478 X                <meta http-equiv="Content-Style-Type" content="text/css" />
479 X                <meta name="MSSmartTagsPreventParsing" content="TRUE" />
480 X                <link rel="stylesheet" type="text/css" href="@@RELPATH@@vstyle.css" />
481 X                <link rel="apple-touch-icon" href="@@RELPATH@@pics/blumenkohl.png" />
482 X                <link rel="canonical" href="$mws__canonpath" />
483 X                <meta name="author" content="Thorsten Glaser" />
484 X                <meta name="copyright" content="All rights reserved. Redistribution except for scientific and educational uses strictly prohibited. Unmodified redistribution with no endorsement permitted." />
485 X                <meta name="owner" content="The MirOS Project and The MirPorts Framework" />
486 X                <meta name="licence" content="see the source files in CVSWEB for details" />
487 X                <title>MirOS: $mws__pagename</title>
488 X                <meta name="robots" content="index, follow" />@@RSS@@
489 X                <!--
490 X                 This is copyrighted material. For the full licence text, see the file
491 X                 LICENCE in the current directory. In no event may text from this page
492 X                 be simply copied into another work covered by an unfree (or otherwise
493 X                 mismatching) licence, such as the GNU Free Documentation License.
494 X                -->
495 X               </head><body>$mws__headline
496 X               <div class="trailing">
497 X               <div class="index">
498 X                <ul class="lv1">
499 X               <li><a href="@@RELPATH@@main.htm">Main</a><ul class="lv2">
500 X               <li><a href="@@RELPATH@@wlog-10.htm">Weblog</a> for #10</li>
501 X               <li><a href="@@RELPATH@@tags.htm">Tag Cloud</a></li>
502 X               <li><a href="@@RELPATH@@news.htm">Old News</a> &amp;
503 X                <a href="@@RELPATH@@oldnews.htm#owlog">WLog</a></li>
504 X               </ul></li>
505 X               <li><a href="@@RELPATH@@about.htm">About</a></li>
506 X               <!-- these are not in a usable state
507 X               <li><a href="@@RELPATH@@docs.htm">Documentation</a></li>
508 X               <li><a href="@@RELPATH@@faq.htm">FAQ</a></li>
509 X               -->
510 X               <li class="spacer"><a href="@@RELPATH@@getting.htm">Download</a></li>
511 X               <li><a href="@@RELPATH@@rss.htm">RSS &amp; Mailing Lists</a></li>
512 X               <li><a href="@@RELPATH@@irc.htm">IRC</a></li>
513 X               <li><a href="@@RELPATH@@projects.htm">Project Ideas</a></li>
514 X               <li><a href="@@RELPATH@@danke.htm">Donate</a></li>
515 X               <li>Manpages<ul class="lv2">
516 X               <li><a href="@@RELPATH@@htman/i386/">i386</a></li>
517 X               <li><a href="@@RELPATH@@htman/sparc/">sparc</a></li>
518 X               </ul></li>
519 X               <li><a href="@@RELPATH@@ports.htm">MirPorts</a> Framework</li>
520 X               <li><a href="@@RELPATH@@pkgsrc.htm">pkgsrc®</a> integration</li>
521 X               <li>Subprojects<ul class="lv2">
522 X               <li><a href="@@RELPATH@@jupp.htm">jupp</a> Editor</li>
523 X               <li><a href="@@RELPATH@@kwalletcli.htm">KWalletCLI</a></li>
524 X               <!-- li><a href="@@RELPATH@@makefs.htm">makefs</a></li -->
525 X               <li><a href="@@RELPATH@@mksh.htm">mksh</a> Shell</li>
526 X               </ul></li>
527 X                </ul>
528 X               <div style="margin-top:18px; margin-left:6px;">Sponsored
529 X                by<br /><a href="http://www.speedpartner.de/"
530 X                 style="border:none; text-decoration:none;"><img
531 X                 style="border:none; text-decoration:none;"
532 X                 src="@@RELPATH@@pics/speedpartner.png"
533 X                 alt="SpeedPartner logo" width="130" height="31"
534 X                 /></a>
535 X               </div>
536 X               </div>
537 X               <div class="content">
538 X       EOF
539 X       mws__header="<p class=\"rcsdiv\">Generated <!-- $mws__difftag --> on"
540 X       mws__header="$mws__header <span class=\"rcsid\">$(date +'%F %T')</span>"
541 X       mws__header="$mws__header by <span class=\"rcsid\">$rcsid_htsconv</span>"
542 X       for x in "$rcsid_parser" "$rcsid_inc2htm" "$rcsid_inc2rss"; do
543 X               [[ -n $x ]] || continue
544 X               mws__header="$mws__header and <span class=\"rcsid\">$x</span>"
545 X       done
546 X       for x in "$rcsid_cfg" "$rcsid"; do
547 X               [[ -n $x ]] || continue
548 X               mws__header="$mws__header from <span class=\"rcsid\">$x</span>"
549 X       done
550 X       for x in "${rcsid_db[@]}"; do
551 X               [[ -n $x ]] || continue
552 X               mws__header="$mws__header and <span class=\"rcsid\">$x</span>"
553 X       done
554 X       mws__header="$mws__header</p>"
555 X}
556 X
557 Xfunction mws_moveifchange {
558 X       if [[ $1 = -k ]]; then
559 X               keep=1
560 X               shift
561 X       else
562 X               keep=0
563 X       fi
564 X       [[ -e $1 && -e $2 ]] || ls -l "$1" "$2" 2>&1 | sed 's/^/!/' >&2
565 X       [[ -e $1 ]] && if [[ -e $2 ]] && \
566 X           diff -waqI "$mws__difftag" "$1" "$2" >/dev/null 2>&1; then
567 X               [[ $keep = 1 ]] || rm -f "$1"
568 X       else
569 X               if [[ $keep = 1 ]]; then
570 X                       cp -f "$1" "$2"
571 X               else
572 X                       mv -f "$1" "$2"
573 X               fi
574 X       fi
575 X       #touch "$2"
576 X       return 0
577 X}
578 X
579 Xfunction mws_putfooter {
580 X       mws_content_keeptabs <<-'EOF'
581 X               </div>
582 X               <div class="footer">
583 X               <p style="display: none;">Do <em>not</em> send any eMail to <a
584 X                href="mailto:junk@mirbsd.de">junk@mirbsd.de</a>, <a
585 X                href="mailto:junk@mirbsd.org">junk@mirbsd.org</a>, or <a
586 X                href="mailto:junk@mirsolutions.de">junk@mirsolutions.de</a> –
587 X                it won’t do any good to you.</p>
588 X               <p>• <a
589 X                href="mailto:miros-discuss@mirbsd.org">eMail</a> contact to
590 X                The MirOS Project • This website is (supposed to be) <a
591 X                href="http://validator.w3.org/check/referer">Valid HTML</a>! •
592 X               </p>
593 X               @@HEADER@@
594 X               </div></div>
595 X               <div class="heading">
596 X                <img class="hdrlnks" alt="MirOS Logo"
597 X                 src="@@RELPATH@@pics/logo-grey.png" />
598 X               </div>
599 X               </body></html>
600 X       EOF
601 X}
602 X
603 Xfunction mws_content {
604 X       if [[ -z $mws__header ]]; then
605 X               print -u2 Internal error: mws_putheader not called!
606 X               exit 1
607 X       fi
608 X       mws__content "$@"
609 X}
610 X
611 Xfunction mws_content_keeptabs {
612 X       if [[ -z $mws__header ]]; then
613 X               print -u2 Internal error: mws_putheader not called!
614 X               exit 1
615 X       fi
616 X       mws__content_keeptabs "$@"
617 X}
618 X
619 Xfunction mws__content {
620 X       sed \
621 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(\(DOCS\))\ 1<a href="@@RELPATH@@htman/i386/man\2/\1.htm" class="manlink">&</a>\ 1g' \
622 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(\(PAPERS\))\ 1<a href="@@RELPATH@@htman/i386/man\2/\1.htm" class="manlink">&</a>\ 1g' \
623 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(GNU)\ 1<a href="@@RELPATH@@htman/i386/manINFO/\1.html" class="manlink">&</a>\ 1g' \
624 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(\([PSU][MS][DM]\))\ 1<a href="@@RELPATH@@htman/i386/man\2/\1.htm" class="manlink">&</a>\ 1g' \
625 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(\([1-9]\)/[Ss][Pp][Aa][Rr][Cc])\ 1<a href="@@RELPATH@@htman/sparc/man\2/\1.htm" class="manlink">&</a>\ 1g' \
626 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(\([1-9]\)/[Ii]386)\ 1<a href="@@RELPATH@@htman/i386/man\2/\1.htm" class="manlink">&</a>\ 1g' \
627 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(\([1-9]\))\ 1<a href="@@RELPATH@@htman/i386/man\2/\1.htm" class="manlink">&</a>\ 1g' \
628 X           -e 's\ 1^     \ 1<span style="display:none;">   </span>\ 1' \
629 X           -e "s\ 1@@ABSPATH@@\ 1$mws__abspath\ 1g" \
630 X           -e "s\ 1@@RELPATH@@\ 1$mws__relpath\ 1g" \
631 X           -e "s\ 1@@HEADER@@\ 1$mws__header\ 1g" \
632 X           -e "s\ 1@@RSS@@\ 1$mws__rss\ 1g"
633 X}
634 X
635 Xfunction mws__content_keeptabs {
636 X       sed \
637 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(\(DOCS\))\ 1<a href="@@RELPATH@@htman/i386/man\2/\1.htm" class="manlink">&</a>\ 1g' \
638 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(\(PAPERS\))\ 1<a href="@@RELPATH@@htman/i386/man\2/\1.htm" class="manlink">&</a>\ 1g' \
639 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(GNU)\ 1<a href="@@RELPATH@@htman/i386/manINFO/\1.html" class="manlink">&</a>\ 1g' \
640 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(\([PSU][MS][DM]\))\ 1<a href="@@RELPATH@@htman/i386/man\2/\1.htm" class="manlink">&</a>\ 1g' \
641 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(\([1-9]\)/[Ss][Pp][Aa][Rr][Cc])\ 1<a href="@@RELPATH@@htman/sparc/man\2/\1.htm" class="manlink">&</a>\ 1g' \
642 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(\([1-9]\)/[Ii]386)\ 1<a href="@@RELPATH@@htman/i386/man\2/\1.htm" class="manlink">&</a>\ 1g' \
643 X           -e 's\ 1\([0-9A-z][-.,0-9A-z]*\)(\([1-9]\))\ 1<a href="@@RELPATH@@htman/i386/man\2/\1.htm" class="manlink">&</a>\ 1g' \
644 X           -e "s\ 1@@ABSPATH@@\ 1$mws__abspath\ 1g" \
645 X           -e "s\ 1@@RELPATH@@\ 1$mws__relpath\ 1g" \
646 X           -e "s\ 1@@HEADER@@\ 1$mws__header\ 1g" \
647 X           -e "s\ 1@@RSS@@\ 1$mws__rss\ 1g"
648 X}
649 X
650 Xfunction mws_push {
651 X       for param in _pagename _relpath; do
652 X               eval mws__push_$param=\$mws_$param
653 X       done
654 X}
655 X
656 Xfunction mws_pop {
657 X       for param in _pagename _relpath; do
658 X               eval mws_$param=\$mws__push_$param
659 X       done
660 X}
661 END-of-mk/htsconv
662 echo x - mk/inc2htm
663 sed 's/^X//' >mk/inc2htm << 'END-of-mk/inc2htm'
664 Xrcsid_inc2htm='$MirOS: www/mk/inc2htm,v 1.26 2009/10/31 17:02:39 tg Exp $'
665 X#-
666 X# This file is part of the website of The MirOS Project, which is
667 X# copyrighted material, please read the LICENCE file for details.
668 X
669 Xinteger perpage=12
670 Xname=$1
671 X
672 X. "$TOP/data/$name.cfg"
673 X
674 X#DEPEND mk/parser
675 X. "$TOP"/mk/parser
676 X
677 X#DEPEND mk/htsconv
678 X. "$TOP"/mk/htsconv
679 X
680 Xwd=$(pwd)
681 Xcd "$TOP/data"
682 Xfor x in *.cfg; do
683 X       x=${x%.cfg}
684 X       t=$(grep '^targets=' $x.cfg || :)
685 X       typeset -l targets=
686 X       [[ -z $t ]] || eval $t
687 X       for t in $targets; do
688 X               if [[ $t != +([0-9a-z_]) ]]; then
689 X                       print -u2 "Invalid tag '$t' in data/$x.cfg"
690 X                       continue
691 X               fi
692 X               eval linktarget_$t=$x
693 X       done
694 Xdone
695 Xcd "$wd"
696 X
697 Xfunction output {
698 X       local rcmd i j x
699 X
700 X       rpath=$1
701 X       efe="${rpath}${ei_srcf[ent]}_${eid}.htm#${eid}_${ei_srcf[ent]}"
702 X       title="${e_date[ent]}${e_author[ent]+ by }${e_author[ent]}"
703 X       subtitle=
704 X       if [[ ${e_language[ent]} = +([A-Za-z0-9-]) ]]; then
705 X               xmllang=" xml:lang=\"${e_language[ent]}\""
706 X       else
707 X               xmllang=
708 X       fi
709 X       print "<div class=\"wlentry\"$xmllang>"
710 X       if [[ -n ${e_title[ent]} ]]; then
711 X               subtitle='<div class="wlsubtitle">'"${title}</div>$nl"
712 X               title="${e_title[ent]}"
713 X       fi
714 X       if [[ -n ${e_tag[ent]} ]]; then
715 X               subtitle=$subtitle'<div class="wltagtitle">Tags:'
716 X               for x in ${e_tag[ent]}; do
717 X                       eval t=\$linktarget_$x
718 X                       [[ -z $t ]] || x="<a href=\"@@RELPATH@@${t}_all.htm#${eid}_${ei_srcf[ent]}\">$x</a>"
719 X                       subtitle="$subtitle $x"
720 X               done
721 X               subtitle="$subtitle</div>$nl"
722 X       fi
723 X       if [[ -n ${e_pictures[ent]} ]]; then
724 X               set -A rcmd -- sed
725 X               for i in ${e_pictures[ent]}; do
726 X                       case $i {
727 X                       (*:*)   j=${i#*:}; i=${i%%:*} ;;
728 X                       (*)     j= ;;
729 X                       }
730 X                       eval x='${e_picture'$i'[ent]}'
731 X                       rcmd[${#rcmd[*]}]=-e
732 X                       rcmd[${#rcmd[*]}]="s\ 1@!PICTURE${i}!@\ 1$(mws_makepiclink \
733 X                           "$x" "$j" d | sed_escape)\ 1g"
734 X               done
735 X       else
736 X               rcmd=cat
737 X       fi
738 X       cat <<-EOF
739 X               <div class="wltitle">
740 X               <h2 class="wlentry" id="${e_id[ent]}_${ei_srcf[ent]}"><a href="${efe}">${title}</a></h2>
741 X               ${subtitle}</div>
742 X       EOF
743 X       "${rcmd[@]}" <<-EOF
744 X               ${ei_body[ent]/'<!-- RSS stop -->'}
745 X               </div>
746 X       EOF
747 X}
748 X
749 Xfunction mopen {
750 X       integer number=$1
751 X       if (( number == 1 )); then
752 X               fn=$name.htm
753 X       else
754 X               fn=${name}_${number}.htm
755 X       fi
756 X       print -r -- "$fn"
757 X       mws_setname $whoami "$pname – Page $number"
758 X       mws_subdir 0
759 X       mws_setheadline "$ptitle"
760 X       mws_putheader >$fn~
761 X       print -r -- "<p>${plinks}" >>$fn~
762 X}
763 X
764 Xfunction mclose {
765 X       mws_putfooter >>$1~
766 X       mws_moveifchange $1~ $1
767 X}
768 X
769 X
770 X#rm -f ${name}.{cut,htm} ${name}_*.htm permalinks/${name}_*.htm
771 X(( cutoff )) && cat >${name}.cut~ <<-EOF
772 X       : ${mws__relpath=/}
773 XEOF
774 Xmws_basepath ${name}_all.htm
775 Xprint -r -- ${name}_all.htm
776 Xmws_setname $whoami "$pname – All in One Page"
777 Xmws_setrss "${mws__relpath}${name}.rss"
778 Xmws_subdir 0
779 Xmws_setheadline "$ptitle"
780 Xmws_putheader >${name}_all.htm~
781 Xplinks="<a href=\"${name}_all.htm\">All</a> <a href=\"${name}.htm\">1</a>"
782 Xplinksr="<a href=\"../${name}_all.htm\">All</a> <a href=\"../${name}.htm\">1</a>"
783 Xinteger i=2
784 Xwhile (( i <= ((entries - cutoff) / perpage + 1) )); do
785 X       plinks="$plinks <a href=\"${name}_${i}.htm\">${i}</a>"
786 X       plinksr="$plinksr <a href=\"../${name}_${i}.htm\">${i}</a>"
787 X       let ++i
788 Xdone
789 Xplinks="${plinks}</p>"
790 Xplinksr="${plinksr}</p>"
791 Xprint -r -- "<p>${plinks}" >>${name}_all.htm~
792 Xmopen 1
793 Xmkdir -p permalinks
794 Xinteger entryc=0
795 Xinteger entryp='entries - 1'
796 Xinteger ent
797 Xwhile (( entryp >= 0 )); do
798 X       ent=${ei_indir[entryp]}
799 X       eid=$(uri_escape "${e_id[ent]}")
800 X       do_permalink=1
801 X       for f in "${nopermalinks[@]}"; do
802 X               [[ $f = ${ei_srcf[ent]} ]] || continue
803 X               do_permalink=0
804 X               break
805 X       done
806 X       if (( do_permalink )); then
807 X               fe=permalinks/${ei_srcf[ent]}_${eid}.htm
808 X               print -r -- "$fe"
809 X               mws_push
810 X               mws_setname $whoami "$pname"
811 X               mws_subdir 1
812 X               mws_setheadline "$ptitle"
813 X               mws_putheader >$fe~
814 X               print -r -- "<p>${plinksr}" >>$fe~
815 X               output | mws_content >>$fe~
816 X               mclose $fe
817 X               mws_pop
818 X       fi
819 X       if (( entryc < cutoff )); then
820 X               print "mws_content <<'EOF_cutoff_$name'" >>${name}.cut~
821 X               output @@RELPATH@@permalinks/ >>${name}.cut~
822 X               print EOF_cutoff_$name >>${name}.cut~
823 X       else
824 X               output permalinks/ | mws_content >>$fn~
825 X       fi
826 X       output permalinks/ | mws_content >>${name}_all.htm~
827 X       let entryp--
828 X       let entryc++
829 X       if (( ((entryc - cutoff) % perpage) == 0 )); then
830 X               print -r -- "<p class=\"linkbot\">$plinks" >>$fn~
831 X               mclose $fn
832 X               mopen $(((entryc - cutoff) / perpage + 1))
833 X       fi
834 Xdone
835 Xprint -r -- "<p class=\"linkbot\">$plinks" >>$fn~
836 Xprint -r -- "<p class=\"linkbot\">$plinks" >>${name}_all.htm~
837 Xmclose $fn
838 Xmclose ${name}_all.htm
839 X[[ -e ${name}.cut~ ]] && mws_moveifchange ${name}.cut~ ${name}.cut
840 Xexit 0
841 END-of-mk/inc2htm
842 echo x - mk/inc2rss
843 sed 's/^X//' >mk/inc2rss << 'END-of-mk/inc2rss'
844 Xrcsid_inc2rss='$MirOS: www/mk/inc2rss,v 1.30 2009/10/31 17:02:39 tg Exp $'
845 X#-
846 X# This file is part of the website of The MirOS Project, which is
847 X# copyrighted material, please read the LICENCE file for details.
848 X
849 Xinteger maxentries=25
850 XDATE_RSS="%a, %d %b %Y %H:%M:%S %z"
851 Xname=$1
852 X
853 X. "$TOP/data/$name.cfg"
854 X
855 X#DEPEND mk/parser
856 X. "$TOP"/mk/parser
857 X
858 X#DEPEND mk/htsconv
859 X. "$TOP"/mk/htsconv
860 X
861 Xmws__header="<!-- RSS mode -->"
862 Xmws__abspath=$mws__canonsite
863 X
864 Xfunction rss_putheader {
865 X       #lastchanged=$(date -r $(stat -f "%m" "$TOP/data/$name.inc") +"$DATE_RSS")
866 X       lastchanged=$(date +"$DATE_RSS")
867 X       cat <<-EOF
868 X               <rss
869 X                xmlns:atom="http://www.w3.org/2005/Atom"
870 X                xmlns:dc="http://purl.org/dc/elements/1.1/"
871 X                version="2.0">
872 X               <channel xml:lang="en">
873 X                <title>$ptitle</title>
874 X                <description>$pname - the MirOS Project</description>
875 X                <atom:link href="$mws__abspath/$1" rel="self" type="application/rss+xml" />
876 X                <lastBuildDate>$lastchanged</lastBuildDate>
877 X                <link>http://mirbsd.de/</link>
878 X                <managingEditor>tg@mirbsd.org (The MirOS Project)</managingEditor>
879 X                <webMaster>bsiegert@mirbsd.org (The MirOS Project)</webMaster>
880 X                <copyright>All content Copyright © by The MirOS Project or its respective
881 X                 writers. Permission to reproduce wlog entries in unmodified form without
882 X                 notice is granted provided they are not used to endorse or promote any
883 X                 products or opinions. For everything else you need to obtain written
884 X                 permission from the copyright owner.</copyright>
885 X                <dc:language>en</dc:language>
886 X                <ttl>${rssttl:-1440}</ttl>
887 X                <generator>MirOS Website, written in mksh; RCS IDs:
888 X                   $rcsid_parser
889 X                   $rcsid_common
890 X                   $rcsid_htsconv
891 X                   $rcsid_inc2rss
892 X                 RCS IDs of the content database:
893 X                   $rcsid_cfg
894 X       EOF
895 X       for x in "${rcsid_db[@]}"; do
896 X               [[ -z $x ]] && continue
897 X               print "    $x"
898 X       done
899 X       print " </generator>"
900 X}
901 X
902 Xfunction rss_putfooter {
903 X       print "</channel></rss>"
904 X}
905 X
906 Xfunction rss_output {
907 X       local rcmd i x
908 X       integer ent=$1
909 X       rpath=$2
910 X       eid=$(uri_escape "${e_id[ent]}")
911 X       efe="${mws__abspath}${rpath}${ei_srcf[ent]}_${eid}.htm#${eid}_${ei_srcf[ent]}"
912 X       pubdate=$(strftm "$DATE_RSS" ${ei_time[ent]})
913 X       if [[ -n ${e_title[ent]} ]]; then
914 X               title="${e_title[ent]}"
915 X       else
916 X               title="${e_date[ent]}${e_author[ent]+ by }${e_author[ent]}"
917 X       fi
918 X       if [[ ${e_language[ent]} = +([A-Za-z0-9-]) ]]; then
919 X               xmllang=" xml:lang=\"${e_language[ent]}\""
920 X               rss3lang="<language>${e_language[ent]}</language>"
921 X       else
922 X               xmllang=
923 X               rss3lang=
924 X       fi
925 X       # we use $xmllang: RSS 2.0 doesn’t allow the language tag inside
926 X       # items, just as channel tag (and Benny’s template doesn’t even
927 X       # use it but dc:language instead)
928 X       cat <<-EOF
929 X               <item$xmllang>
930 X               <title>$title</title>
931 X               <pubDate>$pubdate</pubDate>
932 X               <link>$efe</link>
933 X               <guid isPermaLink="true">$mws__canonsite/permalinks/${ei_srcf[ent]}_${eid}.htm</guid>
934 X       EOF
935 X       for x in ${e_tag[ent]}; do
936 X               print "<category>$x</category>"
937 X               print $x >>stamp_tag_$name
938 X       done
939 X       if [[ -n ${e_author[ent]} ]]; then
940 X               eauthor=${e_author[ent]}
941 X               mauthor=
942 X               if [[ $eauthor = *@ ]]; then
943 X                       uauthor=" ${eauthor%%@*}"
944 X                       eauthor="${eauthor}mirbsd.org"
945 X               fi
946 X               [[ $eauthor = *\(*\)* ]] || eauthor="$eauthor (MirOS Developer$uauthor)"
947 X               print "<author>${eauthor}</author>\n"
948 X       fi
949 X       print "<description>"
950 X       if [[ -n ${e_pictures[ent]} ]]; then
951 X               set -A rcmd -- sed
952 X               for i in ${e_pictures[ent]}; do
953 X                       i=${i%%:*}
954 X                       eval x='${e_picture'$i'[ent]}'
955 X                       rcmd[${#rcmd[*]}]=-e
956 X                       rcmd[${#rcmd[*]}]="s\ 1@!PICTURE${i}!@\ 1$(xhtml_escape \
957 X                           "$x" | sed_escape)\ 1g"
958 X               done
959 X       else
960 X               rcmd=cat
961 X       fi
962 X       "${rcmd[@]}" <<<"${ei_body[ent]%%@(<!-- RSS stop -->)*}" | \
963 X           mws_content | xhtml_escape
964 X       print "</description></item>"
965 X}
966 X
967 Xrm -f stamp_tag_$name
968 Xprint -r -- ${name}.rss
969 Xmws_setname $whoami "$pname"
970 Xmws_subdir -
971 Xrss_putheader "${name}.rss" >${name}.rss~
972 X
973 Xinteger i='entries - 1'
974 Xinteger last='entries < maxentries ? 0 : entries - maxentries'
975 Xwhile (( i >= last )); do
976 X       rss_output ${ei_indir[i]} "/permalinks/" >>${name}.rss~
977 X       let i--
978 Xdone
979 X
980 Xrss_putfooter >>${name}.rss~
981 Xmws_moveifchange ${name}.rss~ ${name}.rss
982 X[[ -e stamp_tag_$name ]] && sort -u -o stamp_tag_$name stamp_tag_$name
983 Xexit 0
984 END-of-mk/inc2rss
985 echo x - mk/mkdepend
986 sed 's/^X//' >mk/mkdepend << 'END-of-mk/mkdepend'
987 X# $MirOS: www/mk/mkdepend,v 1.5 2008/12/04 20:03:27 tg Exp $
988 X#-
989 X# This file is part of the website of The MirOS Project, which is
990 X# copyrighted material, please read the LICENCE file for details.
991 X
992 Xfunction tofn {
993 X       print -nr -- "$*" | tr '/. ' ___
994 X}
995 X
996 Xrm -rf "$DST"/{.depend.tmp{,2},.dep}
997 Xd="$DST/.dep"
998 Xmkdir "$d"
999 Xcd "$TOP"
1000 X
1001 Xset -A files
1002 Xfor f in "$@"; do
1003 X       files[${#files[*]}]=$f
1004 X       print "\${TOP}/$f" >>"$d/$(tofn "$f")"
1005 X       if [[ $f = *.hts ]]; then
1006 X               g=${f##*/}
1007 X               print "${g%s}m~: .NOTMAIN \${DEPS_$(tofn "$f")}" >>"$DST/.depend.tmp2"
1008 X       fi
1009 X       [[ $debug = 1 ]] && print "D: input file $f"
1010 Xdone
1011 Xinteger p=0
1012 Xwhile (( p < ${#files[*]} )); do
1013 X       integer q=p
1014 X       integer r=${#files[*]}
1015 X       while (( q < r )); do
1016 X               [[ $debug = 1 ]] && print "D: depending ${files[q]}"
1017 X               (
1018 X                       [[ ${files[q]} = *.hts ]] && print mk/htsconv
1019 X                       grep -e '^#DEPEND ' -e '^//DEPEND ' ${files[q]}
1020 X               ) |&
1021 X               dp=$d/$(tofn "${files[q]}")
1022 X               while IFS= read -pr line; do
1023 X                       line=${line##*DEPEND }
1024 X                       [[ $debug = 1 ]] && print "D:        on -> $line"
1025 X                       if [[ $line = OBJ:* ]]; then
1026 X                               print "${line#OBJ:}" >>"$dp"
1027 X                               continue
1028 X                       fi
1029 X                       for tfn in $line; do
1030 X                               print "\${TOP}/$tfn" >>"$d/$(tofn "$tfn")"
1031 X                               files[${#files[*]}]=$tfn
1032 X                               print "\${DEPS_$(tofn "$tfn")}" >>"$dp"
1033 X                       done
1034 X               done
1035 X               let q++
1036 X       done
1037 X       let p=r
1038 Xdone
1039 X
1040 Xcd "$DST/.dep"
1041 Xfor file in *; do
1042 X       sort -u "$file" | while IFS= read -r name; do
1043 X               print "DEPS_$file+=\t$name"
1044 X       done
1045 Xdone >"$DST/.depend.tmp"
1046 Xcd "$DST"
1047 Xcat .depend.tmp2 >>.depend.tmp
1048 Xcat .depend.tmp >>.depend
1049 Xrm -rf .dep .depend.tmp{,2}
1050 Xexit 0
1051 END-of-mk/mkdepend
1052 echo x - mk/parser
1053 sed 's/^X//' >mk/parser << 'END-of-mk/parser'
1054 Xrcsid_parser='$MirOS: www/mk/parser,v 1.20 2008/12/04 20:55:12 tg Exp $'
1055 X#-
1056 X# This file is part of the website of The MirOS Project, which is
1057 X# copyrighted material, please read the LICENCE file for details.
1058 X
1059 Xset -A e_author
1060 Xset -A e_id
1061 Xset -A ei_body
1062 Xset -A ei_indir
1063 Xset -A ei_srcf
1064 Xset -A ei_skip
1065 Xset -A ei_time
1066 X
1067 Xnl='
1068 X'
1069 Xsave_IFS=$IFS
1070 Xinteger entry=0
1071 Xinteger guid
1072 Xinteger state
1073 Xtypeset -l parser_lctmp
1074 X
1075 Xfor srcf in $sources; do
1076 X       eval parser_lctmp=\$tags_${srcf//\-/_}
1077 X       tags=:
1078 X       for x in $parser_lctmp; do
1079 X               tags=$tags$x:
1080 X       done
1081 X       guid=10000
1082 X       ids=:
1083 X       state=1
1084 X       rcsid_parsed=
1085 X       while IFS= read -r line; do
1086 X               if [[ $line = RCSID:* && -z $rcsid_parsed ]]; then
1087 X                       rcsid_parsed=${line##RCSID:*([   ])}
1088 X               elif [[ $line = ---- ]]; then
1089 X                       if [[ -z ${e_id[entry]} ]]; then
1090 X                               if [[ -n ${e_date[entry]} ]]; then
1091 X                                       id=${e_date[entry]}
1092 X                                       id=e${id:6:4}${id:3:2}${id::2}
1093 X                               else
1094 X                                       id=g$((guid++))
1095 X                               fi
1096 X                               if [[ -n ${e_author[entry]} ]]; then
1097 X                                       id=${id}-${e_author[entry]%%@(@)*}
1098 X                               else
1099 X                                       id=${id}-nn
1100 X                               fi
1101 X                               e_id[entry]=$id
1102 X                       fi
1103 X                       while [[ :$ids = *:${e_id[entry]}:* ]]; do
1104 X                               e_id[entry]=${e_id[entry]}-g$guid
1105 X                               let guid++
1106 X                       done
1107 X                       ei_srcf[entry]=$srcf
1108 X                       ids=$ids${e_id[entry]}:
1109 X                       if [[ $tags != : ]]; then
1110 X                               ei_skip[entry]=1
1111 X                               for x in ${e_tag[entry]}; do
1112 X                                       [[ $tags = *:$x:* ]] || continue
1113 X                                       unset ei_skip[entry]
1114 X                                       break
1115 X                               done
1116 X                       fi
1117 X                       let ++entry
1118 X                       state=2
1119 X               elif (( state > 0 )); then
1120 X                       if [[ $line = @([A-Za-z]*([A-Za-z0-9_]):\ *) ]]; then
1121 X                               x=${line##+([A-Za-z0-9_]):+([    ])}    # value
1122 X                               parser_lctmp=${line/%:+([        ])$x}  # key
1123 X                               eval e_$parser_lctmp[entry]=\$x
1124 X                       elif [[ -z $line ]]; then
1125 X                               state=0
1126 X                               continue
1127 X                       elif [[ $line = \#* ]]; then
1128 X                               continue        # ignore comment
1129 X                       else
1130 X                               print -u2 "Unknown header in data/$srcf.inc:" \
1131 X                                   "$line"
1132 X                               exit 1
1133 X                       fi
1134 X                       state=1
1135 X                       if [[ $parser_lctmp = date ]]; then
1136 X                               # split up german format (d.m.yyyy [H:M:S])
1137 X                               # date, then pad to dd.mm.yyyy and store as
1138 X                               # y m d H M S for strftm
1139 X                               IFS=$IFS:.
1140 X                               set -A e_tmp ${e_date[entry]}
1141 X                               IFS=$save_IFS
1142 X                               typeset -i -Z2 e_tmpd=10#0${e_tmp[0]}
1143 X                               typeset -i -Z2 e_tmpm=10#0${e_tmp[1]}
1144 X                               typeset -i -Z4 e_tmpy=10#0${e_tmp[2]}
1145 X                               e_date[entry]=$e_tmpd.$e_tmpm.$e_tmpy
1146 X                               # make sure there are no leading zeroes
1147 X                               ei_time[entry]="$((e_tmpy)) $((e_tmpm)) $((e_tmpd)) $((10#0${e_tmp[3]})) $((10#0${e_tmp[4]})) $((10#0${e_tmp[5]}))"
1148 X                       elif [[ $parser_lctmp = tag ]]; then
1149 X                               parser_lctmp=${e_tag[entry]}
1150 X                               unset e_tag[entry]
1151 X                               for x in $parser_lctmp; do
1152 X                                       if [[ $x != +([0-9a-z_]) ]]; then
1153 X                                               print -u2 "Invalid tag '$x' in" \
1154 X                                                   "data/$srcf.inc: $line"
1155 X                                               continue
1156 X                                       fi
1157 X                                       e_tag[entry]=${e_tag[entry]}${e_tag[entry]+ }$x
1158 X                               done
1159 X                       fi
1160 X               else
1161 X                       ei_body[entry]=${ei_body[entry]}${ei_body[entry]+$nl}$line
1162 X               fi
1163 X       done <"$TOP/data/$srcf.inc"
1164 X       if (( state != 2 )); then
1165 X               print -u2 "Last line of data/$srcf.inc not a separator!"
1166 X               exit 1
1167 X       fi
1168 X       [[ -z $rcsid_parsed ]] || rcsid_db[${#rcsid_db[*]}]=$rcsid_parsed
1169 Xdone
1170 Xinteger entries=entry
1171 Xif [[ -n $notimesort ]]; then
1172 X       entry=-1
1173 X       state=0
1174 X       while (( ++entry < entries )); do
1175 X               [[ ${ei_skip[entry]} = 1 ]] || ei_indir[state++]=$entry
1176 X       done
1177 Xelse
1178 X       ( integer e=-1; while (( ++e < entries )); do
1179 X               [[ ${ei_skip[e]} = 1 ]] || print ${ei_time[e]} $e
1180 X         done | sort -nbk1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 ) |&
1181 X       state=0
1182 X       while read -p y m d H M S entry; do
1183 X               ei_indir[state++]=$entry
1184 X       done
1185 Xfi
1186 Xentries=$state
1187 Xreturn 0
1188 END-of-mk/parser
1189 echo x - mk/strftm.c
1190 sed 's/^X//' >mk/strftm.c << 'END-of-mk/strftm.c'
1191 X/*-
1192 X * Copyright (c) 2008
1193 X *     Thorsten Glaser <tg@mirbsd.org>
1194 X *
1195 X * Provided that these terms and disclaimer and all copyright notices
1196 X * are retained or reproduced in an accompanying document, permission
1197 X * is granted to deal in this work without restriction, including un-
1198 X * limited rights to use, publicly perform, distribute, sell, modify,
1199 X * merge, give away, or sublicence.
1200 X *
1201 X * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
1202 X * the utmost extent permitted by applicable law, neither express nor
1203 X * implied; without malicious intent or gross negligence. In no event
1204 X * may a licensor, author or contributor be held liable for indirect,
1205 X * direct, other damage, loss, or other issues arising in any way out
1206 X * of dealing in the work, even if advised of the possibility of such
1207 X * damage or existence of a defect, except proven that it results out
1208 X * of said person's immediate fault when using the work as intended.
1209 X */
1210 X
1211 X#include <sys/param.h>
1212 X#include <err.h>
1213 X#include <errno.h>
1214 X#include <limits.h>
1215 X#include <stdio.h>
1216 X#include <stdlib.h>
1217 X#include <string.h>
1218 X#include <time.h>
1219 X
1220 X__RCSID("$MirOS: www/mk/strftm.c,v 1.2 2008/12/07 17:19:03 tg Exp $");
1221 X
1222 Xextern const char *__progname;
1223 X
1224 Xchar buf[4096];
1225 X
1226 X#define CONVERT(num, elem, name, minval, maxval) do {                  \
1227 X       const char *e = NULL;                                           \
1228 X       char *ep;                                                       \
1229 X       long long res;                                                  \
1230 X                                                                       \
1231 X       tm.elem = res = strtoll(argv[num], &ep, 0);                     \
1232 X       if (ep == argv[num] || *ep != '\0')                             \
1233 X               e = "invalid";                                          \
1234 X       else if ((res == LLONG_MIN && errno == ERANGE) ||               \
1235 X           res < (minval))                                             \
1236 X               e = "too small";                                        \
1237 X       else if ((res == LLONG_MAX && errno == ERANGE) ||               \
1238 X           res > (maxval))                                             \
1239 X               e = "too large";                                        \
1240 X       if (e != NULL)                                                  \
1241 X               errx(2, "%s value 「%s」 is %s", (name), argv[num], e);       \
1242 X} while (/* CONSTCOND */ 0)
1243 X
1244 Xint
1245 Xmain(int argc, char *argv[])
1246 X{
1247 X       struct tm tm;
1248 X       time_t t;
1249 X
1250 X       if (argc != 8)
1251 X               errx(1, "syntax: %s fmtstr y m d h m s\n", __progname);
1252 X
1253 X       memset(&tm, '\0', sizeof (struct tm));
1254 X
1255 X       CONVERT(2, tm_year, "year", LONG_MIN, LONG_MAX - 1900);
1256 X       CONVERT(3, tm_mon, "month", 1, 12);
1257 X       CONVERT(4, tm_mday, "day", 1, 31);
1258 X       CONVERT(5, tm_hour, "hour", 0, 23);
1259 X       CONVERT(6, tm_min, "minute", 0, 59);
1260 X       CONVERT(7, tm_sec, "second", 0, 60);
1261 X
1262 X       tm.tm_year -= 1900;
1263 X       --tm.tm_mon;
1264 X
1265 X       if ((t = mktime(&tm)) == (time_t)-1)
1266 X               errx(2, "invalid calendar time %04lld-%02d-%02d %02d:%02d:%02d",
1267 X                   (long long)tm.tm_year + 1900LL, tm.tm_mon + 1, tm.tm_mday,
1268 X                   tm.tm_hour, tm.tm_min, tm.tm_sec);
1269 X
1270 X       localtime_r(&t, &tm);
1271 X
1272 X       if (!strftime(buf, sizeof (buf), argv[1], &tm))
1273 X               errx(3, "format string 「%s」 too large", argv[1]);
1274 X
1275 X       puts(buf);
1276 X       return (0);
1277 X}
1278 END-of-mk/strftm.c
1279 echo x - mk/ttf2png
1280 sed 's/^X//' >mk/ttf2png << 'END-of-mk/ttf2png'
1281 X<?php
1282 X// $MirOS: www/mk/ttf2png,v 1.6 2009/09/25 19:10:45 tg Exp $
1283 X
1284 X/*-
1285 X * Copyright (c) 2009
1286 X *     Thorsten Glaser <tg@mirbsd.org>
1287 X *
1288 X * Provided that these terms and disclaimer and all copyright notices
1289 X * are retained or reproduced in an accompanying document, permission
1290 X * is granted to deal in this work without restriction, including un-
1291 X * limited rights to use, publicly perform, distribute, sell, modify,
1292 X * merge, give away, or sublicence.
1293 X *
1294 X * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
1295 X * the utmost extent permitted by applicable law, neither express nor
1296 X * implied; without malicious intent or gross negligence. In no event
1297 X * may a licensor, author or contributor be held liable for indirect,
1298 X * direct, other damage, loss, or other issues arising in any way out
1299 X * of dealing in the work, even if advised of the possibility of such
1300 X * damage or existence of a defect, except proven that it results out
1301 X * of said person's immediate fault when using the work as intended.
1302 X *-
1303 X * Syntax:
1304 X *     php ttf2png [text [size [/path/to/font.ttf]]] >out.png
1305 X */
1306 X
1307 X
1308 X/* if 0
1309 Xif (!function_exists('gd_info'))
1310 X       die("Install php5-gd first.");
1311 X$gd = gd_info();
1312 Xif ($gd["FreeType Support"] == false)
1313 X       die("Compile php5-gd with FreeType 2 support.");
1314 X * endif */
1315 X
1316 X
1317 X$font = "/usr/src/www/files/FNT/GenI102.ttf";
1318 X$fontsize = 30;
1319 X$text = "EINVAL";
1320 X
1321 Xif (isset($argv[1]))
1322 X       $text = $argv[1];
1323 Xif (isset($argv[2]))
1324 X       $fontsize = $argv[2];
1325 Xif (isset($argv[3]))
1326 X       $font = $argv[3];
1327 X
1328 X
1329 X// Get bounding box
1330 X$bbox = imageftbbox($fontsize, 0, $font, $text);
1331 X// Transform coordinates into width+height and position
1332 X$size_w = abs($bbox[2] - $bbox[0]);    // right - left
1333 X$size_h = abs($bbox[7] - $bbox[1]);    // top - bottom
1334 X$x = -$bbox[0];                                // left (offset)
1335 X$y = $size_h - abs($bbox[1]);          // lower
1336 X
1337 X// Create image
1338 X$im = imagecreatetruecolor($size_w, $size_h);
1339 X// Allocate colours
1340 X$bgcol = imagecolorallocate($im, 0x24, 0x24, 0x24);
1341 X$fgcol = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
1342 X
1343 X// Fill image with background colour
1344 Ximagefilledrectangle($im, 0, 0, $size_w - 1, $size_h - 1, $bgcol);
1345 X// Render text into image
1346 Ximagefttext($im, $fontsize, 0, $x, $y, $fgcol, $font, $text);
1347 X
1348 X// Convert true colour image (needed for above) to palette image
1349 Ximagetruecolortopalette($im, FALSE, 256);
1350 X
1351 X// Output created image
1352 Ximagepng($im, NULL, 9);
1353 Xexit;
1354 X?>
1355 END-of-mk/ttf2png
1356 exit