Skip to content
Snippets Groups Projects
Commit 2093995d authored by rswindell's avatar rswindell
Browse files

Added stop-semaphore-file support (data/binarydecoder.stop).

sub-boards in .ini file are not scanned if sub-board regexp specified in argv.
Fixed size mismatch error message in combine_parts().
parent ab97332a
No related branches found
No related tags found
No related merge requests found
...@@ -19,10 +19,7 @@ sub = new Array(); ...@@ -19,10 +19,7 @@ sub = new Array();
var ini_fname = system.ctrl_dir + "binarydecoder.ini"; var ini_fname = system.ctrl_dir + "binarydecoder.ini";
file = new File(ini_fname); file = new File(ini_fname);
if(file.open("r")) { file.open("r");
sub = file.iniGetAllObjects("code","sub:");
file.close();
}
if(argc) { if(argc) {
print("Searching for sub-boards matching pattern: " + argv[0]); print("Searching for sub-boards matching pattern: " + argv[0]);
...@@ -30,10 +27,20 @@ if(argc) { ...@@ -30,10 +27,20 @@ if(argc) {
for(i in msg_area.sub) for(i in msg_area.sub)
if(re.test(i)) if(re.test(i))
sub.push(msg_area.sub[i]); sub.push(msg_area.sub[i]);
} } else
sub = file.iniGetAllObjects("code","sub:");
// get global ini settings here
file.close();
var stop_semaphore=system.data_dir+"binarydecoder.stop";
file_remove(stop_semaphore);
for(i in sub) { for(i in sub) {
if(file_exists(stop_semaphore))
break;
msgbase = new MsgBase(sub[i].code); msgbase = new MsgBase(sub[i].code);
if(msgbase.open()==false) { if(msgbase.open()==false) {
printf("!ERROR %s opening msgbase: %s\r\n",msgbase.last_error,sub[i].code); printf("!ERROR %s opening msgbase: %s\r\n",msgbase.last_error,sub[i].code);
...@@ -99,9 +106,8 @@ for(i in sub) { ...@@ -99,9 +106,8 @@ for(i in sub) {
printf("Scanning %s\r\n",msgbase.cfg.code); printf("Scanning %s\r\n",msgbase.cfg.code);
last_msg=msgbase.last_msg; last_msg=msgbase.last_msg;
for(;ptr<=last_msg && bbs.online;ptr++) { for(;ptr<=last_msg && !file_exists(stop_semaphore);ptr++) {
console.inkey(); /* allow ^O toggle */
printf("%s %lu of %lu\r\n" printf("%s %lu of %lu\r\n"
,msgbase.cfg.code, ptr, last_msg); ,msgbase.cfg.code, ptr, last_msg);
...@@ -239,7 +245,8 @@ for(i in sub) { ...@@ -239,7 +245,8 @@ for(i in sub) {
if(!add_part(parts_list,msgbase.cfg.code,hdr if(!add_part(parts_list,msgbase.cfg.code,hdr
,fname,"yenc" /* codec */ ,fname,"yenc" /* codec */
,part,total,first_line,li-1 /* last_line */ ,part,total,first_line,li-1 /* last_line */
,begin,end,part_crc32,size,crc32)) ,begin,end,part_crc32,size,crc32)
&& console!=undefined)
console.pause(); console.pause();
continue; continue;
} }
...@@ -314,7 +321,7 @@ for(i in sub) { ...@@ -314,7 +321,7 @@ for(i in sub) {
,fname,"uue" /* codec */ ,fname,"uue" /* codec */
,part,undefined ,part,undefined
,first_line,li-1 /* last_line */ ,first_line,li-1 /* last_line */
)) ) && console!=undefined)
console.pause(); console.pause();
} }
...@@ -333,7 +340,7 @@ for(i in sub) { ...@@ -333,7 +340,7 @@ for(i in sub) {
/* Save Attachment MD5 history */ /* Save Attachment MD5 history */
if(md5_list.length!=md5_list_length) { if(md5_list.length!=md5_list_length) {
print("Saving MD5 history"); printf("Saving MD5 history (%lu files)\r\n",md5_list.length);
if(md5_file.open("w")) { if(md5_file.open("w")) {
md5_file.writeAll(md5_list); md5_file.writeAll(md5_list);
md5_file.close(); md5_file.close();
...@@ -342,7 +349,7 @@ for(i in sub) { ...@@ -342,7 +349,7 @@ for(i in sub) {
/* Save Attachment CRC-32 history */ /* Save Attachment CRC-32 history */
if(crc_list.length!=crc_list_length) { if(crc_list.length!=crc_list_length) {
print("Saving CRC-32 History"); printf("Saving CRC-32 History (%lu files)\r\n",crc_list.length);
if(crc_file.open("w")) { if(crc_file.open("w")) {
crc_file.writeAll(crc_list); crc_file.writeAll(crc_list);
crc_file.close(); crc_file.close();
...@@ -356,13 +363,13 @@ for(i in sub) { ...@@ -356,13 +363,13 @@ for(i in sub) {
combine_parts(parts_list); combine_parts(parts_list);
/* Save the Partial file/parts Database */ /* Save the Partial file/parts Database */
print("Saving partial file database"); printf("Saving partial file database (%lu files)\r\n", parts_list.length);
parts_file.open("w"); parts_file.open("w");
for(o in parts_list) { for(o in parts_list) {
obj=parts_list[o]; obj=parts_list[o];
parts_file.writeln("[" + obj.name + "]"); parts_file.writeln("[" + obj.name + "]");
for(prop in obj) for(prop in obj)
parts_file.printf("%-20s=%s\r\n" parts_file.printf("%-20s=%s\n"
,prop.toString(), obj[prop].toString()); ,prop.toString(), obj[prop].toString());
parts_file.writeln("; end of file: " + obj.name ); parts_file.writeln("; end of file: " + obj.name );
parts_file.writeln(); parts_file.writeln();
...@@ -521,8 +528,8 @@ function add_part(list,sub_code,hdr ...@@ -521,8 +528,8 @@ function add_part(list,sub_code,hdr
obj[format("part%u.begin",part)]=begin; obj[format("part%u.begin",part)]=begin;
if(end!=undefined) if(end!=undefined)
obj[format("part%u.end",part)]=end; obj[format("part%u.end",part)]=end;
if(pcrc32!=undefined) // if(pcrc32!=undefined)
obj[format("part%u.crc32",part)]=format("%08lxh",pcrc32); // obj[format("part%u.crc32",part)]=format("%08lxh",pcrc32);
obj.parts++; obj.parts++;
...@@ -597,9 +604,9 @@ function combine_parts(list,attachment_dir) ...@@ -597,9 +604,9 @@ function combine_parts(list,attachment_dir)
} }
if(obj.size!=undefined && obj.size!=file.length) { if(obj.size!=undefined && obj.size!=file.length) {
file.remove();
printf("!File length mismatch, actual: %lu, expected: %lu\r\n" printf("!File length mismatch, actual: %lu, expected: %lu\r\n"
,file.length, obj.size); ,file.length, obj.size);
file.remove();
continue; continue;
} }
...@@ -608,9 +615,9 @@ function combine_parts(list,attachment_dir) ...@@ -608,9 +615,9 @@ function combine_parts(list,attachment_dir)
file_crc32=file.crc32; file_crc32=file.crc32;
crc32=parseInt(obj.crc32,16); crc32=parseInt(obj.crc32,16);
if(crc32!=file_crc32) { if(crc32!=file_crc32) {
file.remove();
printf("!CRC-32 failure, actual: %08lx, expected: %08lx\r\n" printf("!CRC-32 failure, actual: %08lx, expected: %08lx\r\n"
,file_crc32, crc32); ,file_crc32, crc32);
file.remove();
continue; continue;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment