From a72a3e79d434d618ecedda5d0fd25114c9b11d7f Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Thu, 10 May 2018 19:06:46 +0000 Subject: [PATCH] A simple message base test script right now, but ultimately could (should) grow into something that could be used in lieu of smbutil for at least some message base admin functions. Committing in its current form for Bill McGarrity to use to help diagnose a Message-ID issue (w/newslink.js) --- exec/msgutil.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 exec/msgutil.js diff --git a/exec/msgutil.js b/exec/msgutil.js new file mode 100644 index 0000000000..6cc3c3de24 --- /dev/null +++ b/exec/msgutil.js @@ -0,0 +1,60 @@ +// $Id$ + +load('sbbsdefs.js'); + +function show_index(msgbase, first_msg, last_msg, include_votes) +{ + var i; + + var total_msgs = msgbase.total_msgs; + for(i = 0; i < total_msgs; i++) { +// print(i); + var idx = msgbase.get_msg_index(true, i, include_votes); + if(!idx) + continue; + print(i); + var p; + for(p in idx) + print(format("%10s = ", p) + idx[p]); + } +} + +function show_headers(msgbase, include_votes) +{ + alert("include votes = " + include_votes); + var hdrs = msgbase.get_all_msg_headers(include_votes); + + var i; + for(i in hdrs) { + var h; + print(i); + for(h in hdrs[i]) + print(format("%25s = ", h) + hdrs[i][h]); + } +} + +var i; +var basecode; +var option = []; + +for(i in argv) + if(argv[i].charAt(0) != '-') { + if(!basecode) + basecode = argv[i]; + } else + option[argv[i].slice(1)] = true; + +if(basecode == undefined) { + alert("Message base not specified"); + exit(); +} + +var start = time(); +var msgbase = MsgBase(basecode); +if(!msgbase.open()) { + alert("Error " + msgbase.last_error + " opening " + basecode); + exit(); +} +show_index(msgbase, msgbase.first_msg, msgbase.last_msg, option.votes); +show_headers(msgbase, option.votes); +print(Number(time() - start) + " seconds"); -- GitLab