#!/usr/bin/perl # Dictionary of the Gargish language # # This script has several options to display the dictionary database # # no args displays the whole database in three colums, # Gargish script, Gargish in english alphabet, English. # # ?english=word displays all matches of in the # database. # # ?gargish=word displays all matches of in the # database. This tolerates several ways to write gargish words, # extends x, q, w to their counterparts, ignores spaces between # gargish syllables and of course accepts kl, ch, zh etc. # # ?add&gargish=gword&english=eword adds a suggested phrase # to the suggestion file. # # # # special syllables have extra characters # 9 == gl # 5 == sh # G == ng # Z == zh # C == ch # K == kl $dictfile = 'gargdict.txt'; %extrachars = ( '9', 'gl', '5', 'sh', 'G', 'ng', 'Z', 'zh', 'C', 'ch', 'K', 'kl', ); %gifs = ( 'a','', 'b','', 'c','', 'C','', 'd','', 'e','', 'f','', 'g','', '9','', 'h','', 'H','', 'i','', 'j','', 'k','', 'K','', 'l','', 'm','', 'n','', 'G','', 'N','', 'Y','', 'o','', 'p','', 'r','', 's','', '5','', 't','', 'u','', 'v','', 'z','', 'Z','', ':','', '/','', '.','', '-','', ' ','', ); $query_string = $ENV{'QUERY_STRING'}; $path_info = $ENV{'PATH_INFO'}; $script_name = $ENV{'SCRIPT_NAME'}; $hostname = $ENV{'HTTP_HOST'}; &parse_form_data(*OPTIONS); print "Content-type: text/html","\n\n"; print "\n"; print "Gargish Dictionary\n"; print qq|\n|; if (!$OPTIONS{'noscript'}) { &printjavascript(); } print "

",&makerunes("gar9-liG-kodeks"),"

\n"; print "

Gargish Dictionary

\n"; # load dictionary from file if (open(DICT, "<" . $dictfile)) { print "\n"; print qq|
|,&makerunes("gar9-liG"),qq|gargl-lingEnglish\n|; while () { next if /^#/; ($gargish, $english) = split(/\t/,$_); $runes = &makerunes($gargish); $gargish =~ s/'([auieo])/\&$1acute;/g; $gargish =~ s/([95GZCK])/$extrachars{$1}/g; $english =~ s/;/; /g; print "
$runes$gargish$english\n"; } print "
\n"; close(DICT); } #print "\n"; &print_footer(); exit(0); #------------------------------------------------------------------ sub makerunes { ($garg) = @_; local($rune, $c, $ex); $rune = ''; if ($OPTIONS{'noscript'}) { while ($garg) { $c = chop($garg); next if $c =~/'/; $ex = '???' unless $ex = $gifs{$c}; $rune = qq|$ex$rune|; } } else { $rune = qq||; } return $rune; } sub printjavascript { print < function printgarg(text) { var len = text.length; var inword = 0; for (i = 0; i < len; ++i) { c = text.substring(i, i+1); width = 17; switch (c) { case "9": c = "gl"; break; case "C": c = "ch"; width = 16; break; case "H": c = "hl"; break; case "i": width = 15; break; case "K": c = "kl"; break; case "G": c = "ng"; break; case "N": c = "nl"; break; case "Y": c = "ny"; width = 16; break; case "5": c = "sh"; width = 16; break; case "Z": c = "zh"; width = 16; break; case ":": c = "dpunkt"; width = 13; break; case "/": c = "minus"; width = 15; break; case ".": c = "punkt"; width = 14; break; case "-": case " ": c = "space"; width = 10; break; } if (c == "space") { if (inword) { document.write("\\n"); inword = 0; } } else if (c == "\\'") { continue; } else { if (!inword) { document.write(""); inword = 1; } } document.write(""); } } End_of_Script } #------------------------------------------------------------------ sub print_footer { print "
\n"; @crtime = localtime; $ctime = &mydtime(@crtime); print "Automatically generated ", $ctime, qq| Martin\@Brenner.de

\n|; @starr = stat($dictfile); @filetime = localtime($starr[9]); $ctime = &mydtime(@filetime); print "Dictionary last updated ", $ctime, ".

\n"; print "\n"; } #------------------------------------------------------------------ # myctime() return ctime() style date string from date/time array sub myctime { ($mysec,$mymin,$myhour,$mymday,$mymon,$myyear, $mywday) = @_; return sprintf( ('Sun','Mon','Tue','Wed','Thu','Fri','Sat','Sun')[$mywday]." ". ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep', 'Oct','Nov','Dec')[$mymon]." %d %02d:%02d:%02d 19%02d", $mymday, $myhour, $mymin, $mysec, $myyear); } sub mydtime { ($mysec,$mymin,$myhour,$mymday,$mymon,$myyear, $mywday) = @_; return sprintf("%02d-". ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep', 'Oct','Nov','Dec')[$mymon]."-%02d %02d:%02d:%02d", $mymday, $myyear, $myhour, $mymin, $mysec); } #------------------------------------------------------------------ sub parse_form_data { local (*FORM_DATA) = @_; local ($request_method, $query_string, @key_value_pairs); local ($key_value, $key, $value); $request_method = $ENV{'REQUEST_METHOD'}; if ($request_method eq "GET") { $query_string = $ENV{'QUERY_STRING'}; } elsif ($request_method eq "POST") { read(STDIN, $query_string, $ENV{'CONTENT_LENGTH'}); } else { &return_error(500, $error, "Unknown method used."); } @key_value_pairs = split(/&/, $query_string); foreach $key_value (@key_value_pairs) { ($key, $value) = split(/=/, $key_value); $value =~ tr/+/ /; $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex($1))/eg; if (defined($FORM_DATA{$key})) { $FORM_DATA{$key} = join("\0", $FORM_DATA{$key}, $value); } else { $FORM_DATA{$key} = $value; } } } sub return_error { local ($status, $keyword, $message) = @_; print "Content-type: text/html\n"; print "Status: ", $status, " ", $keyword, "\n\n"; print < CGI programm unexpected error

$keyword


$message Further information from $webmaster. End_of_Error exit(1); }