lufia #6722(2008/07/12 13:19 GMT) [ Other ] Rating0/0=0.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
implement Comment; include "sys.m"; sys: Sys; print, fprint, sprint, create, OWRITE: import sys; include "draw.m"; include "bufio.m"; include "xml.m"; xml: Xml; Parser, Item, Locator, Attributes, Mark: import xml; Comment: module { init: fn(ctxt: ref Draw->Context, argv: list of string); }; init(nil: ref Draw->Context, nil: list of string) { sys = load Sys Sys->PATH; xml = load Xml Xml->PATH; xml->init(); data := "<?xml .."; fout := create("/tmp/comment.xml", OWRITE, 8r600); if(fout == nil) raise "open"; fprint(fout, "%s", data); fout = nil; printlastbuilddate("/tmp/comment.xml"); } printlastbuilddate(f: string) { warningch := chan of (Xml->Locator, string); spawn warningproc(warningch); (x, e) := xml->open(f, warningch, ""); if(x == nil) raise e; for(xi := x.next(); xi != nil; xi = x.next()) pick i := xi { Tag => case i.name { "rss" or "channel" => x.down(); "lastBuildDate" => x.down(); print("%s\n", gettext(x)); warningch <- = (x.loc, nil); # term exit; } Error => raise i.msg; } warningch <- = (x.loc, nil); raise "no item"; } gettext(x: ref Parser): string { for(xi := x.next(); xi != nil; xi = x.next()) pick i := xi { Text => return i.ch; } raise "error"; } warningproc(c: chan of (Xml->Locator, string)) { for(;;){ (loc, msg) := <- c; if(msg == nil) break; print("%s:%d: %s", loc.systemid, loc.line, msg); } }
Rating0/0=0.00-0+
[ reply ]
lufia
#6722()
[
Other
]
Rating0/0=0.00
implement Comment; include "sys.m"; sys: Sys; print, fprint, sprint, create, OWRITE: import sys; include "draw.m"; include "bufio.m"; include "xml.m"; xml: Xml; Parser, Item, Locator, Attributes, Mark: import xml; Comment: module { init: fn(ctxt: ref Draw->Context, argv: list of string); }; init(nil: ref Draw->Context, nil: list of string) { sys = load Sys Sys->PATH; xml = load Xml Xml->PATH; xml->init(); data := "<?xml .."; fout := create("/tmp/comment.xml", OWRITE, 8r600); if(fout == nil) raise "open"; fprint(fout, "%s", data); fout = nil; printlastbuilddate("/tmp/comment.xml"); } printlastbuilddate(f: string) { warningch := chan of (Xml->Locator, string); spawn warningproc(warningch); (x, e) := xml->open(f, warningch, ""); if(x == nil) raise e; for(xi := x.next(); xi != nil; xi = x.next()) pick i := xi { Tag => case i.name { "rss" or "channel" => x.down(); "lastBuildDate" => x.down(); print("%s\n", gettext(x)); warningch <- = (x.loc, nil); # term exit; } Error => raise i.msg; } warningch <- = (x.loc, nil); raise "no item"; } gettext(x: ref Parser): string { for(xi := x.next(); xi != nil; xi = x.next()) pick i := xi { Text => return i.ch; } raise "error"; } warningproc(c: chan of (Xml->Locator, string)) { for(;;){ (loc, msg) := <- c; if(msg == nil) break; print("%s:%d: %s", loc.systemid, loc.line, msg); } }Rating0/0=0.00-0+
[ reply ]