Skip to content
Browse files

cleanup the `.decodeKludges` method and add docs

  • Loading branch information...
1 parent af49a24 commit a1b0e053fa267f62b8d4a63cf441503ae273076b @Mithgol committed Jun 16, 2014
Showing with 21 additions and 27 deletions.
  1. +21 −1 README.md
  2. +0 −26 fidonet-jam.js
View
22 README.md
@@ -262,7 +262,7 @@ Before the value is returned, the following replacements are made:
### decodeHeader(header, options)
-Uses the encoding (determined by `.encodingFromHeader(header)`) to decode strings from the Buffer properties of the header.
+Uses the encoding (determined by `.encodingFromHeader(header)`) to decode strings from the Buffer properties of the header's Subfields.
* If `.encodingFromHeader` returns `null`, `options.defaultEncoding` is used.
@@ -307,6 +307,26 @@ The same returned object may also have one or more of the following properti
* `timezone` — sender's time zone in `+HHmm` or `-HHmm` form (for example, `-0400`) where `+` may be omitted.
+### decodeKludges(header, options)
+
+Does a minor part of what `decodeHeader` does: decodes only the kludge lines.
+
+Uses the encoding (determined by `.encodingFromHeader(header)`) to decode strings from the Buffer properties of the header's Subfields. If `.encodingFromHeader` returns `null`, uses `options` or defaults the same way `decodeHeader` does it.
+
+The kludges are decoded only from the following Subfield types:
+
+* `4 / 'MSGID'` — The ID of the message.
+* `5 / 'REPLYID'` — If the message is a reply to some other message, contains the MSGID of that message.
+* `7 / 'PID'` — The PID of the program that generated the message.
+* `2004 / 'TZUTCINFO'` — Time zone information in `+HHmm` or `-HHmm` form (for example, `-0400`) where `+` may be omitted. (Becomes a `TZUTC` kludge.)
+* `2000 / 'FTSKLUDGE'` — other FTS-compliant “kludge” lines.
+
+The other subfields (including `PATH` and `SEEN-BY`) are ignored.
+
+The kludge lines are decoded without the preceding SOH (`Ctrl+A`, `0x01`) code.
+
+The returned value is a string containing all the kludge lines separated by the Unix line endings (`LF`, `'\n'`).
+
### decodeMessage(header, options, callback)
Using the given header, reads the text of the corresponding message (calling `.readJDT` in the process). Then uses the encoding (determined by `.encodingFromHeader(header)`) to decode the text of the message. Calls `callback(error, messageText)` when the decoding is finished.
View
26 fidonet-jam.js
@@ -498,14 +498,6 @@ JAM.prototype.decodeKludges = function(header, decodeOptions){
for( var i = 0; i < header.Subfields.length; i++ ){
switch( header.Subfields[i].LoID ){
- case 0: // OADDRESS
- break;
- case 1: // DADDRESS
- break;
- case 2: // SENDERNAME
- break;
- case 3: // RECEIVERNAME
- break;
case 4: // MSGID
kludges.push(
'MSGID: ' + header.Subfields[i].Buffer.toString(encoding)
@@ -516,34 +508,16 @@ JAM.prototype.decodeKludges = function(header, decodeOptions){
'REPLY: ' + header.Subfields[i].Buffer.toString(encoding)
);
break;
- case 6: // SUBJECT
- break;
case 7: // PID
kludges.push(
'PID: ' + header.Subfields[i].Buffer.toString(encoding)
);
break;
- /*
- case 8: return 'TRACE'; //break;
- case 9: return 'ENCLOSEDFILE'; //break;
- case 10: return 'ENCLOSEDFILEWALIAS'; //break;
- case 11: return 'ENCLOSEDFREQ'; //break;
- case 12: return 'ENCLOSEDFILEWCARD'; //break;
- case 13: return 'ENCLOSEDINDIRECTFILE'; //break;
- case 1000: return 'EMBINDAT'; //break;
- */
case 2000: // FTSKLUDGE
kludges.push(
header.Subfields[i].Buffer.toString(encoding)
);
break;
- case 2001: // SEENBY2D
- break;
- case 2002: // PATH2D
- break;
- /*
- case 2003: return 'FLAGS'; //break;
- */
case 2004: // TZUTCINFO
kludges.push(
'TZUTC: ' + header.Subfields[i].Buffer.toString(encoding)

0 comments on commit a1b0e05

Please sign in to comment.
Something went wrong with that request. Please try again.