From 5683cf77402a772e3d7d132fec36e31335f77acf Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 31 May 2010 19:12:20 +0200 Subject: import thunderbird-enigmail-1.0.1 --- enigmail-fixlang.php | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 enigmail-fixlang.php (limited to 'enigmail-fixlang.php') diff --git a/enigmail-fixlang.php b/enigmail-fixlang.php new file mode 100644 index 0000000..188b558 --- /dev/null +++ b/enigmail-fixlang.php @@ -0,0 +1,91 @@ +#!/usr/bin/php +$/', $buf, $res)) { + //echo "+ Line '".$res[1]."'\n"; + $ind=trim($res[1]); + $tab[$ind] = $res[1].'"'.$res[2].'">'; + $prev=false; + } else if (preg_match('/^$/', $buf, $res)) { + //echo "+ End '".$prev."'\n"; + $tab[$prev] .= "\n".$res[1].'">'; + $prev=false; + } else if ($prev && preg_match('/^(.*)$/', $buf, $res)) { + //echo "+ Cont. '".$prev."'\n"; + $tab[$prev] .= "\n".$res[1]; + } else { + die("- unkonwn ($buf) !\n"); + } + } +} +function loadprop ($file, &$tab) { + + echo "+ Loading $file\n"; + $tab=array(); + + $fic=fopen($file, "r"); + if ($fic) while ($buf=fgets($fic)) { + if (empty($buf) || $buf=="\n") { + //echo "+ empty\n"; + } else if (preg_match('/^#/', $buf, $res)) { + //echo "+ comments\n"; + } else if (preg_match('/^([A-Za-z0-9._]*)[[:space:]]*=[[:space:]]*(.*)/', $buf, $res)) { + //echo "+ Value '".$res[1]."'\n"; + $ind=trim($res[1]); + $tab[$ind] = $res[1].'='.$res[2]; + } else { + echo("\tIgnored ($buf) !\n"); + } + } +} +if ($_SERVER["argc"]<3) die ("usage enigmail-fixlang.php fromdir destdir\n"); +$from=$_SERVER["argv"][1]; +$dest=$_SERVER["argv"][2]; +if (!is_file("$from/enigmail.dtd")) die ("$from/enigmail.dtd not found\n"); +if (!is_file("$from/enigmail.properties")) die ("$from/enigmail.properties not found\n"); +if (!is_file("$dest/enigmail.dtd")) die ("$dest/enigmail.dtd not found\n"); +if (!is_file("$dest/enigmail.properties")) die ("$dest/enigmail.properties not found\n"); + +loaddtd("$from/enigmail.dtd", $endtd); +loaddtd("$dest/enigmail.dtd", $frdtd); + +echo "+ Writing $dest/enigmail.dtd\n"; +$fic=fopen("$dest/enigmail.dtd", "w"); +foreach($endtd as $ind => $line) + if (isset($frdtd[$ind])) { + fputs($fic, " $line) + if (isset($frprop[$ind])) { + fputs($fic, $frprop[$ind]."\n"); + } else { + echo "\tAdding missing $ind\n"; + fputs($fic, $enprop[$ind]."\n"); + } +fclose($fic); +?> + -- cgit