#!/usr/bin/perl


$qmailsource=$ARGV[0];

die "Usage: extractqmailstrings <qmail source dir>" if not -d $qmailsource; 

open FILE,"<$qmailsource/qmail-local.c" or die "Couldn't open $qmailsource/qmail-local.c";
while(<FILE>){
	print "_($1)\n" if /strerr_die1x\(100\,(\"[^"]*\")\)/;
	print "_($1)\n" if /strerr_die1x\(111\,(\"[^"]*\")\)/;
}
close FILE;

open FILE,"<$qmailsource/qmail-remote.c" or die "Couldn't open $qmailsource/qmail-local.c";
while(<FILE>){
	chop;
	while(/\\$/){
		chop;
		$_.=<FILE>;
		chop;
	}
	print "_(\"$1\")\n" if /out\(\"[rhsZD]([^"]+)\"\)/;
	print "/**/ _(\"$1.\")\n" if /quit\(\"[rhsZD]\",\"([^"]+)\"\)/;
	print "_(\"$1\") /**/ _(\"$2.\")\n" if /quit\(\"[rhsZD]([^"]+)\",\"([^"]+)\"\)/;
	print "_(\"$1\") /**/\n" if /quit\(\"[rhsZD]([^"]+)\",\"\"\)/;
}
close FILE;
