Portál AbcLinuxu, 23. prosince 2025 03:16
for filename in *; do ...), výsledky zapisuje do adresáře output.Já už jsem svojí hisorii přenášel do 4. klienta, a proti konverzi z Mirandy tohle bylo docela jednoduché.
#!/bin/awk -f
function writetext()
{
if(text)
{
from = dir_in ? nick : mynick;
filename = nick;
gsub("\\.","-",filename)
filename = "output/" filename "." date ".xml";
if( filename != oldfile )
{
print "<!DOCTYPE Kopete-History>\n<kopete-history version=\"0.7\" >\n <head>" > filename;
print " <date month=\"" (date % 100) "\" year=\"" sprintf("%d", date / 100) "\" />" > filename;
print " <contact contactId=\"" mynick "\" type=\"myself\" />" > filename;
print " <contact contactId=\"" nick "\" />\n </head>" > filename;
if(oldfile) print "</kopete-history>" > oldfile;
}
print " <msg from=\"" from "\" in=\"" dir_in "\" time=\"" time "\" >" text "</msg>" > filename;
oldfile = filename;
}
}
BEGIN { name = ARGV[1];
sub(".*/","",name);
split(name,splitname,"\\.");
if(splitname[1] == "Jabber")
{
sub("Jabber.","+",name);
split(name,splitname,"+");
}
nick = splitname[3];
mynick = splitname[2];
}
/^\[/ { writetext();
text = 0;
dir_in = 0;
}
/^(Server)?Text=/ { sub("^[^=]*=\"","");
sub("\"$","");
gsub("\\\\x0d","");
gsub("\\\\n","\n");
gsub("\\\\\"","\\"");
text = $0;
}
/^Time=/ { sub("^Time=","");
date = strftime("%Y%m", $0);
time = strftime("%d %H:%M:%S", $0);
}
/^Flags=1/ { dir_in=1 }
END { writetext();
if(filename) print "</kopete-history>" > filename;
}
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.