home *** CD-ROM | disk | FTP | other *** search
/ World of Ham Radio 1997 / WOHR97_AmSoft_(1997-02-01).iso / packet / pak_13 / amsoft.iii next >
Text File  |  1997-02-01  |  39KB  |  786 lines

  1.  
  2.  
  3.  
  4.                             Chunk 'n Glue V1.5
  5.  
  6. I.   Introduction
  7.  
  8. As you probably know, the packet radio channels have become extremely
  9. crowded.  One of the contributing factors to this crowding is long file
  10. transfers, usually via the linked BBS system.  Transfers of files larger
  11. than about 10kb are usually impractical and always considered to be anti-
  12. social behavior.  And if you are interested in sending ASCII-encoded binary
  13. files using one of the popular protocols such as PAK, PAK/UNPAK, BTOA, BSQ,
  14. etc., you know the problem is even more severe.  These files are HUGE.  So
  15. what to do.  Well the obvious solution is to break the large files up into
  16. little chunks for transmission and recombine them at the receiving end.
  17. PAK/UNPAK supports small files, but its encoding scheme is fairly
  18. inefficient resulting in much more transmission data than do the others.
  19. And PAK/UNPAK cannot break up text files without encoding them thus
  20. expanding their sizes. So again, what to do.
  21.  
  22. Well, a cry from the wilderness was heard, saying "Write a program.....
  23. write a program....", so I did!  I am a firm believer in the UNIX concept
  24. which is one of a "toolbox" of programs and utilities.  Each tool is
  25. designed to do only 1 thing but do it well.
  26.  
  27. So the obvious solution was to write a program that would take an ascii
  28. textfile, split it up into little chunks and wrap the chunks in sufficient
  29. protection so as to have a reasonable assurance that they will survive the
  30. trip over the packet channels.  Thus CHUNK which chunks 'em up and GLUE
  31. which glues them back together again.
  32.  
  33. II.  A usage example.
  34.  
  35. Suppose I had a group of related files that I wanted to send to a friend in
  36. Florida via the packet network.  For example, lets take this package,
  37. Chunk'n'Glue.  The files would be CHUNK.EXE, CHUNK.C, GLUE.EXE, GLUE.C,
  38. CHUNK, GLUE, and CHKNGLUE.DOC.  The most efficient way would be to combine
  39. them into an ARChive file using the popular public domain program ARC.EXE.
  40. The command line would be:
  41.  
  42. ARC A CHUNK *.*<CR>
  43.  
  44. which would result in a file CHUNK.ARC being created and all the above
  45. files being included.  ARC does a very sophisticated data compression
  46. algorithm on the incoming files, so the arc file will be much smaller than
  47. the total size of all the input files.
  48.  
  49. So now we have an ARC file which is still pure binary and thus incompatible
  50. with the bbs system.  Well there are several programs available such as
  51. PAK, BSQ, and BTOA, but all but BTOA attempt their own compression as they
  52. encode.  Generally speaking, it's a no-no to recompress data that's already
  53. been compressed.  The resulting file tends to be HUGE.  So, since we're
  54. already compressed in the ARC file, BTOA is the weapon of choice.  The
  55. command line would be:
  56.  
  57. BTOA CHUNK.ARC CHUNK.BTA<CR>
  58.  
  59. This will produce CHUNK.BTA which will be about 20% larger than CHUNK.ARC.
  60. CHUNK.BTA is consists entirely of printable ASCII characters and so is
  61. compatible with packet bbs's.  Only one problem.  When I encoded this file,
  62. the BTA file was over 44k long!  Sending something like that is clearly
  63. anti-social!
  64.  
  65. "So wiseguy", you might ask, "just what IS social?"  Good question.
  66. Several considerations enter into the discussion.  First is the "good
  67. neighbor" philosophy.  That is, since a packet channel can only really
  68. support one user at a time if he is sending files, one should not hog the
  69. channel.  Everyone has his own opinion about hogging, but in general, I try
  70. to limit my occupancy of the channel to no more than about 10 minutes at a
  71. time.  Another very important consideration is the capability of the BBSs
  72. that will be handling the files.  If your local bbs is a XEROX-based
  73. system, he'll probably have 50-75k of free storage for "mail" files.  A PC
  74. system running off floppies is not much better off.  So you really should
  75. not fill the whole system up with your file transfer.
  76.  
  77. You obviously have to look at the transmission medium when making your
  78. decision.  If you are sending to an adjacent bbs or a friend one digi hop
  79. away, then much larger files are tolerable than if you are going through 4
  80. digis or out on HF.  Similarly, at 3:00am in the morning, you can send
  81. larger files than at 7:00pm!
  82.  
  83. All of these arguments point to sending via a bunch of small files but
  84. there is a consideration that argues to the contrary.  A whole bunch of
  85. files, say >10, files are likely to get lost or at least take forever
  86. getting to your destination.  So a compromise is in order.
  87.  
  88. What I've found to work well is to send files in about 10k chunks if you
  89. are going over a solid 1 hop VHF link.  For HF or poor links, no more than
  90. 5K is indicated.
  91.  
  92. So for our example, lets assume we've got a good solid VHF path so we can
  93. use 10k chunks.  The objective therefore is to break this 44k .BTA file up
  94. into 10k chunks for transmission and then be able to put them back together
  95. into the original file on the receiving end.  Well you could use your
  96. favorite editor but this is generally a poor solution.  First, editors
  97. generally don't like really big files.  Second, they tend to put funny
  98. things like ^z's in the files.  Third, there is no way of knowing if a
  99. portion of a chunk has been lost somehow.  Then, of course, on the
  100. receiving end, you have to make sure you put the chunks back together in
  101. the right order.
  102.  
  103. Here's where Chunk'N'Glue come in.  Chunk simply breaks up the input file
  104. into small chunks and then surround each chunk with "tokens" or markers
  105. that show exactly where the chunk begins and ends.  You can tell Chunk how
  106. big to make each chunk, but if you don't, it defaults to 5k.  Convenient,
  107. eh?  In this example, we'll use a chunksize of 10k.  So to chunk the
  108. CHUNK.ARC file, you would simply type:
  109.  
  110. CHUNK CHUNK.BTA -s10000<CR>
  111.  
  112. Chunk would then process the .BTA file into little chunks, in this case 5,
  113. and tell you what it did.  Each chunk file has the name:
  114.  
  115. CHUNK.CHx  Where x is a sequential letter starting with A.
  116.  
  117. So in this case, the files CHUNK.CHA, CHUNK.CHB, CHUNK.CHC, CHUNK.CHD, &
  118. CHUNK.CHE were created.
  119.  
  120. Now you can send these files, one at a time to your friend via packet.
  121. When he gets them, he simply types:
  122.  
  123. GLUE CHUNK<CR>
  124.  
  125. Glue first checks to see if all the chunk files are there, and if so
  126. processes them back into the original CHUNK.BTA file. (This assumes your
  127. friend somehow already had GLUE, hi!).  Glue is smart enough to ignore BBS
  128. header lines or prompts that may have become embedded in the chunk files so
  129. he doesn't have to worry about editing this stuff out.  Just plug'n'play!
  130.  
  131. He would then convert it back into an ARC file by typing:
  132.  
  133. ATOB CHUNK.BTA<CR>
  134.  
  135. and extract the individual files by typing:
  136.  
  137. ARC E CHUNK<CR>
  138.  
  139. So there you have it. Simple and efficient.  You can automate this
  140. procedure with simple batch files.
  141.  
  142. Now lets look back above for a minute.  Suppose you were going to transmit
  143. over a poor path or on HF and thus wanted smaller chunk files, say 2.5k.
  144. The Chunk command line becomes:
  145.  
  146. CHUNK CHUNK.BTA -S2500   or
  147. CHUNK -S2500 CHUNK.BTA
  148.  
  149. The "-s" or "size" option tells Chunk to make 2.5k files instead of it's
  150. default of 5k.  There is a somewhat arbitrary upper limit of 32k.  This is
  151. primarily for my convenience in programming but it should not be a problem.
  152. After all, it's not nice to send 32k files on packet!  If you specify a
  153. number larger than 32k, Chunk will assume you made an error in typing and
  154. use the default of 5k byte chunks.
  155.  
  156. Chunk has an optimizer built in which will eliminate so-called straggler
  157. files.  Stragglers contain only a few bytes and occur when the original
  158. file is just a tiny bit larger than an integral number of chunks.  Using a
  159. chunksize of 5k for example, a file that is 25400 bytes long would create 6
  160. chunks, the last of which would contain only 400 bytes.  When Chunk sees
  161. this situation, it adjusts the chunksize to accommodate the bytes in one
  162. less chunkfile.  So in this case, Chunk would make 5 chunkfiles, each about
  163. 5,080 bytes long.  Again, a somewhat arbitrary limit of 500 bytes has been
  164. used as the cutoff to identify a straggler.  This feature will really cut
  165. down the traffic on a packet channel because of the overhead involved in
  166. sending a message.
  167.  
  168. III.   OPTIONS
  169.  
  170.      CHUNK options
  171.  
  172. In the example above, the use of Chunk and Glue was simple and
  173. straightforward.  There are several options that change the performance of
  174. both Chunk and Glue.  You've already seen one, the -s option on Chunk.
  175. We'll look at Chunk first.  The complete command line for Chunk is:
  176.  
  177. CHUNK INFILE [-SXXXX] [-B] [-Z] [-M]
  178.  
  179. The items in the square brackets are optional.  It is important to note
  180. that the options can be specified in any order, and before or after the
  181. INFILE name.  Thus you could type:
  182.  
  183. CHUNK -S4000 INFILE -B
  184.  
  185. Lets look at each option in sequence.
  186.  
  187.      -S Option
  188.  
  189. You are already familiar with the -s option.  This specifies a chunkfile
  190. size other than the default of 5k.  This specification can be up to 32,767
  191. bytes.  If you specify a chunkfile larger than 32,767, Chunk will assume
  192. you made a typing error and use the default of 5k.
  193.  
  194.      -B & -Z Option
  195.  
  196. The -b and -z options do the same thing; they are interchangeable.
  197. Normally, as Chunk processes a file, it looks out for control-z characters
  198. in the input file, and if it finds any, it ZAPS them to spaces.  Why?
  199. Well, embedded control-z's royally screw up packet bbs systems.  When the
  200. bbs sees a control-z, it simply thinks that the end of message has been
  201. reached and stops accepting any more data.  Of course, anything following
  202. the first control-z is lost, including the footer for CHUNK.
  203.  
  204. BUT, there are times you may not want to Zap Zee's.  If you are chunking a
  205. binary file for transmission either in the transparent mode on packet or
  206. via phone modem, killing Zee's is not nice.  So an option to turn this
  207. killing mode off is included.  The -b and -z tell Chunk NOT to ZAP any
  208. control-Z characters it finds in the input file as it processes it.  You
  209. can think of this as either being a (Z)apping Zee's or a (B)inary mode.
  210.  
  211. The Zee-Zapping mode also enables one other feature.  This feature insures
  212. that carriage return-line feed pairs don't get split up.  DOS and CP/M are
  213. somewhat unique in that lines of text are ended with the 2 character
  214. sequence, <CR>-<LF>.  Both characters are necessary and in this order.
  215. Other systems, such as Unix use only a "newline" character which is also
  216. called "linefeed", same as above.  The difference is that in Unix, the
  217. printer driver takes care of making sure the printer carriage is returned
  218. after each line as well as feeding the paper to the new line.  For DOS and
  219. CP/M, we have to explicitly instruct the printer to return the printhead
  220.  
  221.  
  222. with a <CR> and then feed a line with the <LF>.  Even though <CR> and <LF>
  223. are two separate bytes, with few exceptions, they are always mated at the
  224. end of each line of text.
  225.  
  226. Problems start to arise when we start chunking files.  If an odd chunksize
  227. is specified with a file that has predominately even numbers of characters
  228. in each line, it can occur that the chunk can end on a <CR> character and
  229. its companion <LF> will end up as the first byte of the next chunkfile.
  230.  
  231. At this point, we don't have a problem.  Glue assumes that the chunks are
  232. made up of arbitrary data and so will mate the errant <CR> and <LF>.  The
  233. real problem occurs when we load the chunkfiles into a packet system for
  234. transmission.  The BBS software looks for errant <CR>'s and <LF>'s and when
  235. it finds one, inserts its mate.  So in the first chunkfile, a <LF> would be
  236. added after the <CR> and in the second chunkfile, a <CR> will be added
  237. before the <LF>.  Or, stated another way, the BBS has corrupted the
  238. chunkfiles.  GLUE will notice the extra 2 bytes added and complain loudly.
  239. And if the original chunked file was encoded binary from lets say, BTOA,
  240. then these added bytes will corrupt the file when it is un-BTA'd.
  241.  
  242. So if Chunk is in the Zee-Zapping mode, it also looks for a <CR>-<LF>
  243. sequence that is going to be split.  If it finds this occurrence, it goes
  244. ahead and reads an additional byte from the original file and puts it in
  245. the chunkfile.  (Sorta think of it as a marriage counselor for data!)  It
  246. adjusts the bytecount in the chunkfile header accordingly.  Chunk also
  247. looks at this extra byte, and if it is not a <LF> character, Chunk
  248. complains that it has found a <CR> without a mating <LF> in the input file.
  249. Whether or not this is a problem will have to be determined by you.  One
  250. thing is for sure though, the chunkfile with the unmated <CR> WILL be
  251. corrupted by the packet BBS system.
  252.  
  253.      -M Option
  254.  
  255. The -M option is the Memo option.  This option activates a small line
  256. editor within Chunk which lets you add a memo or note to the beginning of
  257. the first chunkfile.  Glue will display this memo on the screen while it is
  258. putting the chunkfiles back together again.  This is a very handy feature
  259. that will allow you to identify the contents of ASCII-Encoded chunkfile to
  260. the recipient or place instructions in the chunkfile pertaining to the
  261. contents.  When you have entered the Memo, type a ^Z to end it.
  262.  
  263.  
  264.      Glue Options
  265.  
  266. Glue currently has 2 command line options.  You can specify an optional
  267. name to be used for the output file and you can specify a queried ignore
  268. option for errors.  The command line would be:
  269.  
  270. GLUE CHUNKFIL [OUTFILE] [-i]
  271.  
  272. Chunk stores the original file's name in the header of each chunkfile and
  273. this name is normally used by Glue for its output filename.  If you specify
  274. an output file name however, that name will override the name in the
  275. chunkfile header.  So if you type the command:
  276.  
  277. GLUE CHKNGLUE GLUE.DOC
  278.  
  279. Glue would combine CHKNGLUE.CHA, CHKNGLUE.CHB, etc into one file, but
  280. instead of using the name in the header line, it would call the output file
  281. GLUE.DOC.
  282.  
  283.      -I Option
  284.  
  285. If you specify the -i option, telling GLUE to selectively ignore certain
  286. error conditions, the program will notify you of any errors it encounters
  287. and give you the option of ignoring them.  This is especially useful when a
  288. chunkfile set has been corrupted, perhaps by a "*** CONNECT REQUEST" from
  289. the tnc or from the <CR>-<LF> problem mentioned above.  If the original
  290. file was plaintext, often times the corruption can be ignored or can be
  291. more easily fixed with an editor after Glue is finished processing.  In
  292. these cases, GLUE will generate an error message and then ask you whether
  293. to quit or ignore the error.  If you choose to ignore the error, GLUE will
  294. do its best to finish processing the chunkfiles and then provide you with a
  295. more detailed error analysis regarding the error condition.  If BTOA or PAK
  296. chunkfiles are being processed, obvious errors such as the *** Connect
  297. Request messages can also be fixed manually, but care must be taken to
  298. eliminate all extra <CR>-<LF> sequences also.  The -i option is NOT
  299. recommended for binary files.
  300.  
  301.  
  302. IV.   Other Features
  303.  
  304. A new feature starting with V1.3 is the so called "straggler file"
  305. elimination algorithm.  A straggler file is one that contains only a few
  306. bytes of data.  For example, suppose you had a file to transmit that is
  307. 25,100 bytes long.  Before now, Chunk would have made 6 chunkfiles, 5 of
  308. which would contain 5000 bytes of data and the last which would contain
  309. only 100 bytes - the straggler!  Since there is a large overhead involved
  310. in any packet message or file transfer, I decided to get rid of the
  311. straggler.  What Chunk does is look at the straggler and if it's going to
  312. be less than 500 bytes, the sizes of the other chunkfiles are enlarged
  313. enough to contain the straggler.  Thus, Chunk would now make only 5
  314. chunkfiles and each would contain about 5020 bytes.
  315.  
  316.  
  317. V. The CHUNK file format.
  318.  
  319. If you look at the first chunk file, CHUNK.CHA, you will see something like
  320. this:
  321.  
  322. This file CHUNKed by the WD4OQC CHUNK'r
  323. ~~~ FcHuNk WD4OQC Vers 1.5 File A of E, chunk.bta 10000 47325
  324. xbtoa Begin chunk.arc
  325. )@/]$<DH0ez!!!!g!!!".%SN8"?=Ns8!":L"\9K5fNK+2M5X7Z_B$M5),ZO+qLi<ck3c<LW/>toZ!K
  326.  
  327. more data...
  328.  
  329.  
  330.  
  331.  
  332. more data... (10k worth)...
  333.  
  334. 6j743*@pD;@j#qciG\L!IM=?n1Xk5!,+=d%uF,jMdQuEE",F$#Z]dn=HE\i0FUk["Z%81*ZtVa!$5?
  335. Q!15SJ%H%q7U(@:n!Eu]2EqX??Fb-"#%j[N\XM=q][LYK^!-E/j4O=/"O
  336. ~~~ EnDfChUnK Vers 1.5
  337.  
  338. A bunch of gobbledygook!  Lets look more closely.  The first line is a brag
  339. line that essentially does nothing except positively identify to humans the
  340. source and type of the file.  The second line is what we call a "token" or
  341. header line.  It serves 2 purposes.  One is to positively mark where the
  342. data starts.  Second, it contains vital data needed by Glue, such as the
  343. original file's name and how many files are in this set.  Each bit of text
  344. separated by a space is called a field.  Lets look at them more closely.
  345.  
  346. ~~~            The triple tilde string.  This is a unique marker used by
  347.                Glue to figure out where the header begins. Since the tilde
  348.                is a rare character in the English language, most likely its
  349.                occurrence in a file will mark a header.
  350.  
  351. FcHuNk         This field identifies the datafile as coming from chunk.  It
  352.                is highly desirable that a header line contain highly unique
  353.                data in order to simplify recognition.  Thus the alternate
  354.                upper and lower case letters.
  355.  
  356. WD4OQC         My call, to identify the author in the event someone cannot
  357.                find out what's making those funny files and wants to look
  358.                me up in the callbook.
  359.  
  360. Vers 1.5       Current version number.  Generally expect files generated
  361.                with pre- version 1.3 to be incompatible with newer ones,
  362.                since the major reason for upgrades is to fix deficiencies
  363.                in the program.  Look to the release notes, CHANGES.CNG, for
  364.                details.  Minor changes to old chunk files can be made with
  365.                an editor.  Major changes will probably be supplied with a
  366.                conversion program.
  367.  
  368. File A of E,   This field tells GLUE first, which file in sequence it is
  369.                dealing with and second, how many total files there are.
  370.                The numbering sequence is A through Z for a total of 25
  371.                possible files.  Thus with a limit of 25 chunkfiles at a
  372.                maximum size of 32k each, you can chunk files over 800k!
  373.  
  374. chunk.bta      This is the name of the original file that was chunked.
  375.                This file is recreated by GLUE.
  376.  
  377. 10000          This is the exact size in bytes of the data area in the
  378.                chunk file, ie, the data between the header token and the
  379.                footer token.  This count is EXACT and excludes the CR-LF
  380.                sequence CHUNK places after the header line and before the
  381.                footer line.  These are, of course, stripped out by GLUE.
  382.  
  383.  
  384.  
  385.  
  386.  
  387. 47325          This is the exact file size of the original file in bytes.
  388.                This number is used as an extra error check to insure the
  389.                GLUE'd file is the same as the one that was CHUNK'd.
  390.  
  391. <CR><LF>       The CR-LF sequence ends the header line.  The NEXT byte is
  392.                the first byte of the data area.
  393.  
  394. The next line, "xbtoa Begin chunk.arc" also looks suspiciously like a
  395. header and it is!  But it's the header of the chunked file itself, in BTA
  396. format.  It's also the first data in the chunk file.
  397.  
  398. Looking at the end of the chunkfile, we see the line:
  399.  
  400.      ~~~ EnDfChUnK Vers 1.5
  401.  
  402. This is the footer of the chunkfile that tells GLUE exactly where to stop
  403. and to ignore any characters that may follow it.  Characters such as the
  404. BBS prompt following a download from the BBS.
  405.  
  406. VI.  ERROR MESSAGES
  407.  
  408. Chunk and Glue provide a wide variety of error messages to inform you of
  409. what is happening or what happened to cause failure.  Most are self-
  410. explanatory and all are listed below.
  411.  
  412. CHUNK Error Messages
  413.  
  414. -  *** WARNING - Bad chunksize - Using 5,000 bytes
  415. -  *** WARNING - Bad Option on command line - x - Ignored.
  416. -  *** WARNING - Specified chunksize > 32767 bytes - using 5,000 bytes.
  417. -  *** WARNING - A <CR> without a <LF> was found at the end of chunk X.
  418.  
  419. 0. ---         No errors encountered, OK.
  420. 1. *** ERROR - File name must be specified on command line
  421. 2. *** ERROR - Not enough ram to proceed. - Exiting ...
  422. 3. *** ERROR - Filename xxx not found",infilename - Exiting ...
  423. 4. *** ERROR - Can't open xxx - Disk full?? - Exiting ...
  424. 5. *** ERROR - Error Writing file xxx - Disk full??? - Exiting ...
  425. 6. *** ERROR - Chunksize selected will result in too many files - Increase");
  426.                chunksize and try again - Exiting ...
  427. 7. *** ERROR - *deleted* v1.3 - not used in this version.
  428. 8. *** ERROR - Written Bytes not equal to read bytes.
  429.  
  430. The number out to the side of each error is the EXIT CODE Chunk returns to
  431. DOS when it exits.  You can make use of these error codes in DOS batch
  432. files through the ERRORLEVEL statement to do different things according to
  433. what went wrong.
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442. GLUE Error Messages
  443.  
  444. 1. *** ERROR - File name must be specified on command line");
  445. 2. *** ERROR - Not enough ram to proceed. - Exiting ...
  446. 3. *** ERROR - First chunkfile, xx not found - Exiting ...
  447. 3. *** ERROR - Chunkfile xx not found - Exiting ...
  448. 4. *** ERROR - Can't open output file xxx - Disk full???
  449. 5. *** ERROR - Writing file xxx - Disk full??? - exiting ...
  450. 6. *** ERROR - Opening header not found - Maybe not a CHUNK file? - Exiting ...
  451. 7. *** ERROR - BAD option - exiting ...
  452. 8. *** ERROR - Invalid Beginning token found - Exiting ...
  453. 9. *** ERROR - Chunkfile corrupted - File is too short
  454. 10.*** ERROR - Chunkfile corrupted - File is too long.
  455. 11.*** ERROR - Actual file size different than header file size.
  456.  
  457.  
  458. VII.   WHAT CAN GO WRONG
  459.  
  460. The three most common problems will be:
  461.  
  462. 1.   Chunkfile too long corruption
  463. 2.   Footer missing
  464. 3.   Extraneous ^z's.
  465.  
  466. 1.   Chunkfile too long corruption - The most common cause of this error is
  467.      a connect request coming into your station while you are downloading a
  468.      file.  It will consist of the line "*** connect request: wd4xxx".
  469.      Since there is no way to suppress this effect, you should occasionally
  470.      expect it, especially if, for some reason, yours is a popular station
  471.      to connect to. (A good store of dirty jokes on disk, fer'instance.)
  472.      The easiest solution is to use your editor to find the offending
  473.      string and delete it.  CAUTION: you MUST be exact in your deletions
  474.      including <CR><LF> sequences.  On PAK'd and BTOA'd files this is easy,
  475.      since each line will be exactly the same length.  In general, expect
  476.      to have to delete the string and one <CR><LF> sequence.
  477.  
  478. 2.   Footer Missing - This will most likely happen in the last chunkfile if
  479.      the original file had a ^z EOF marker at its end.  CHUNK processes a
  480.      file into chunkfiles EXACTLY - It does no filtering of any kind.  Thus
  481.      the ^Z gets passed through like any other data.  The ^z WILL terminate
  482.      the file when it is uploaded to the BBS or if an editor like WordStar,
  483.      which respond to ^z, is used.  The solution is generally simple.
  484.      Generally no data is actually lost so the footer should be added
  485.      manually with an editor.  Since the ^z was represented in the byte
  486.      count stored in the header, you will have to put a space at the end of
  487.      the last line before the footer to make up for this byte.  Use the
  488.      Zee-Zapping Chunk option to insure this is not a problem.
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497. 3.   Extraneous ^z's - Similar to the above problem except that if a ^z
  498.      gets embedded in the data at other than the end and the chunkfiles are
  499.      handled by BBS, all following data in that file will be lost.  Some
  500.      editors, such as PC-WRITE, will allow you to put a ^Z anywhere in a
  501.      datafile by keying ALT-26.  PC-WRITE and Chunk ignore the ^Z but the
  502.      BBS does not!!!!  The only real solution is to have the sender rechunk
  503.      the original file and re-send the offended one AND all subsequent
  504.      ones.  Of course, the Zee-Zapping Chunk option will eliminate this
  505.      problem.
  506.  
  507. VIII.  OTHER USES
  508.  
  509. Though CHUNK was originally written for use on Amateur Packet radio, it has
  510. many other uses.  Some are outlined below.
  511.  
  512.      1.   Binary files
  513.  
  514. CHUNK handles binary data with the same ease as text - at least in the DOS
  515. environment.  (This may not be strictly true on such systems as CP/M which
  516. use a special byte to signal EOF.)  So it can be used to chunk binary files
  517. as well as text.  Why would you want to do this?
  518.  
  519. Well, consider one of my experiences.  I've collected a few games for the
  520. PC over the years.  I've kept them in a single ARC file on my hard disk.
  521. This ARC has grown until it now approaches 800k!  Since it was taking up a
  522. large amount of disk space, I wanted to off-load it to floppies.  But it's
  523. too big for one floppy.  CHUNK to the rescue.  I simply chunked the ARC
  524. into 32k chunks and copied them to floppies.  This is a very efficient
  525. method, as it will waste at most, <32k of floppy space.  When I want to
  526. recover the ARC file, I simply copy all the chunk files over to the hard
  527. disk and let GLUE put 'em back together again.
  528.  
  529.      2.   Phone Modem Operations
  530.  
  531. Another use is in phone modem operation.  Say I wanted to transfer that
  532. same game ARC file to a friend of mine.  I COULD send the file in one piece
  533. using XMODEM or whatever.  This is inadvisable for several reasons.  First,
  534. I really would not want my phone tied up for hours.  Second, XMODEM can be
  535. crashed by noise or poor line conditions.  If it crashed 700k into the
  536. transfer, it'd be something to cry about!  It is much better to CHUNK the
  537. file and send the pieces a group at a time.  If you wanted to limit
  538. yourself to perhaps an hour per night, it would take several nights but you
  539. would eventually get them all sent.  And if the transfer crashes, at most
  540. one file would have to be resent.
  541.  
  542. Yet a third use is on CompuServ.  Lets suppose you've just completed an
  543. expository essay on why programmers that release public domain software
  544. without source are such hairballs.  This could easily run 30k or more.
  545. Problem is that the message section of most services such as CompuServ have
  546. a limit of perhaps 2k on messages.  You realize that if you upload your
  547. work of art as a file, it will probably be ignored.  CHUNK to the rescue.
  548. Simply CHUNK your text file into, say 1800 byte chunks and upload them
  549.  
  550.  
  551.  
  552. sequentially.  Title your messages appropriately, say "Hairballs, 1 of 20".
  553. From the reader's point of view, he can read each message sequentially,
  554. ignoring the CHUNK headers or he can capture them all and GLUE them back
  555. together for reading or printing.  NEET, huh?
  556.  
  557.  
  558.  
  559. IX   PATCHING CHUNK OPTIONS
  560.  
  561. Chunk is shipped set up so that the Zee-Zapping option defaults ON and the
  562. Memo option defaults OFF.  So the command line option -Z turns Zee-Zapping
  563. OFF and the -M option turns the memo field ON.  This should be the way most
  564. people use the program under normal conditions for Packet radio.  Most
  565. chunkfiles will not need a memo field, so this is off.  However, if these 2
  566. defaults are not convenient, Chunk has provisions for patching them to the
  567. opposite state.
  568.  
  569. The simplest way to change default states is to change the flag in the C
  570. source code file and re-compile.  However, in the event you don't have a
  571. professional C compiler, you can use a sector editor such as the Norton
  572. Utilities or the public domain PATCH program (included) to effect the
  573. change.
  574.  
  575. At this point I must warn you that this type patching requires that you be
  576. familiar with patching in general and also familiar with your patching
  577. program.  In particular, if you use the DOS DEBUG program, use extreme
  578. caution.  DEBUG can alter any arbitrary sector on your disk and will do so
  579. without warning or confirmation.
  580.  
  581. The major problem in patching C programs at the executable file level is
  582. finding the right place to patch.  The compiler and linker can put the
  583. patch area at any arbitrary place in the .EXE file.  The Microsoft C v4.0
  584. compiler puts all initialized variables near the end of the .EXE file.  To
  585. facilitate finding the patch area, I've defined a couple of patch FLAG
  586. labels that will show up when you peruse the binary data.  These 2 flags
  587. are ZAPFLAG and MEMOFLAG.  These 2 words will appear in the binary data
  588. immediately BEFORE the patch bytes.  And remember that the string will be
  589. terminated with a 0 so the actual patch area starts AFTER the 0.  Both
  590. flags are stored as 2 byte integers with 00 00 being false and 01 00 being
  591. true.  At least in the 8086 world, the bytes are stored LSB first, so the
  592. FIRST byte is the one to change.  Simply change the 00 to a 01 or a 01 to a
  593. 00.
  594.  
  595. I cannot give you a more detailed instruction on patching because there are
  596. a myriad of patching tools available and all are different.  Since CHUNK
  597. will tell you what it is doing, a simple test will verify the correctness
  598. of the patching.
  599.  
  600. An important note.  The -Z and -M options on the command line actual TOGGLE
  601. the state of the option.  For example, the Zee-Zapping mode is shipped
  602. defaulting ON so a -Z will toggle it OFF.  If you patch CHUNK so that Zee-
  603. Zapping defaults OFF, the -Z option will toggle it OFF.  Same for the Memo
  604. option.  This is very important to understand.
  605.  
  606.  
  607. If you type CHUNK on the command line without a filename argument, CHUNK
  608. will give you a short help screen and exit.  This help screen will indicate
  609. the action of all options and will reflect any patching.  So if you get
  610. lost or forget what the defaults are, simply type CHUNK and look at the
  611. help message.
  612.  
  613.  
  614. X  AVAILABILITY, SOURCE, ETC.
  615.  
  616. CHUNK'N'GLUE is available directly from me at:
  617.  
  618. John G. De Armond WD4OQC
  619. po box 3657
  620. Cleveland, TN 37311
  621.  
  622. It is shipped complete with C source code, DOC files, a bug list, and
  623. Microsoft MAKE files.If you'd like a copy, send me 3 things:
  624.  
  625. 1.   An IBM DSDD formatted disk - 360k 5".
  626. 2.   A reusable disk mailer with return address labels
  627. 3.   Enuf postage to cover it's return.
  628.  
  629. All 3 must be included.  Since I'm giving this program set away, I WILL NOT
  630. go to any extra trouble to fix up your FUBARS.  If all three items are not
  631. included, I'll simply add what you DID send to my user-donated collection
  632. and be done with it.
  633.  
  634. If, when you send me a disk, you'll send a little note telling me you are
  635. interested, I'll include a copy of PAK, BTOA, BSQ and so on.  These tools
  636. should really be in any professional packeteer's toolkit!
  637.  
  638. I don't like the concept of BEGware (ShareWare to some) for such simple
  639. utilities, but if you were to include a small contribution sufficient to at
  640. least cover future mailings,  I'd be most inclined to put you on my mailing
  641. list for future updates, packet goodies and the like.
  642.  
  643. I'll post this set on as many phone BBS sets as possible.  I don't have any
  644. in mind at the moment, so none are listed.  I am not currently on
  645. CompuServ, since our backwater little town does not have a Tymnet node and
  646. I won't pay the buzzards connect charges AND long distance.  If anyone
  647. wants to upload this to Compuserv, feel free to do so.
  648.  
  649. This program set is copywrited by me!  You may use them, hack them, give
  650. them away, use them in your business, or make a zillion copies to your
  651. hearts' delite.  You may NOT:
  652.  
  653. 1.   Sell this program - This includes charging for copying, other than
  654.      media costs.
  655. 2.   Distribute modified versions using the names CHUNK, GLUE or
  656.      CHUNK'N'GLUE.
  657. 3.   Change revision numbers and then re-release the programs to the public
  658.      domain.  PLEASE... I'm willing to handle the drudgery of maintaining
  659.      orderly revisions.  Just send your enhancements to me and I'll take it
  660.      from there!
  661.  
  662. Source code in Microsoft C v4.0 is included (Only a Troll would do
  663. otherwise!), you should feel free to embellish it.  If you come up with
  664. enhancements, bugfixes or the like, please send them to me either by US
  665. SNAIL at the above address or via packet radio @ WD4OQC BBS.  I'll
  666. incorporate the changes into an official update.
  667.  
  668. XI  OTHER MACHINES.
  669.  
  670. This code was written for the MicroSoft C V4.0 compiler under MS-DOS.
  671. There is little if any machine- or compiler-specific code in it.  It should
  672. therefore compile and run on most other environments.  If your compiler
  673. and/or operating system does not supply exact file size information to-the-
  674. byte, you will have to write a little function to count bytes in order to
  675. be able to store bytecounts in the chunkfiles.  This will somewhat slow the
  676. system down.
  677.  
  678. The major requirement is that your compiler be ANSI-draft compatible.
  679. (Before you ask, NO, BDS-C is NOT.)  Most all DOS compilers and some CP/M
  680. compilers such as Aztec should meet this requirement.  if you convert this
  681. program for another compiler/environment, PLEASE send me a copy for
  682. distribution.  PC-format disks preferred, though I can handle most CP/M 5"
  683. formats.
  684.  
  685. XII   KNOWN TRAPS AND "UNDOCUMENTED BEHAVIOR
  686.  
  687. 1.   With the current header line parser routine, if a tilde, "~" appears
  688.      anywhere BEFORE the header line, the program will report an error.  It
  689.      simply expects to find the header at the first tilde.  So if any of
  690.      the BBS headers have a tilde in them, simply edit them out of the
  691.      chunk files before Glueing them.  This will be fixed in the next
  692.      release.  I got lazy, hi!
  693.  
  694. 2.   If 2 original files have the same file name but with different
  695.      extensions, say BIGFILE.1 and BIGFILE.2, and you want to chunk them
  696.      both, Chunk will overwrite the first series of chunkfiles with the
  697.      second.  This is because both will produce a set of chunkfiles named
  698.      BIGFILE.CHx.  I'm not sure this is a real problem worth the fairly
  699.      extensive coding needed to intelligently trap it, but if you think so,
  700.      let me know.  The easy workaround is to rename the chunkfiles to
  701.      another non-conflicting name before chunking the next one.  The DOS
  702.      command would be "REN BIGFILE.CH* BIGFILE1.CH*".  I will probably make
  703.      the provision to specify the chunkfile names in the next release which
  704.      will positively eliminate this problem.
  705.  
  706. 3.   The GLUE program will terminate with an error message if there is not
  707.      enough RAM available to process the chunkfile in one complete chunk.
  708.      Since I've placed an arbitrary limit of 32k on chunkfile sizes, this
  709.      should not be a problem.  It would be a rare PC indeed that did not
  710.      have 32k of ram available after loading this program.  If this does
  711.      give you a problem, let me know.  I can code the routine to use
  712.      whatever RAM is available.  CP/M users may have a problem, depending
  713.      on how bad your C compiler is.
  714.  
  715.  
  716.  
  717. XIII   COMING ATTRACTIONS
  718.  
  719. I have a couple of related programs up my sleeve.  The first will be a
  720. fixer program which will read a chunkfile and fix the header to match.
  721. This will permit you to edit chunked textfiles without the necessity to
  722. glue them back together and then rechunk them afterwards.
  723.  
  724. The second one, primarily of interest to the W0RLI CBBS sysops and those
  725. who use the CBBS code as a personal mailbox, will automatically merge
  726. chunkfiles into the CBBS mail file as messages.  It will have the ability
  727. to be programmed for time so that it will feed a designated number of
  728. chunks per unit time.  And perhaps look at the mail file to determine when
  729. the previous chunks went out and hold off sending more till they move. This
  730. is designed to remove some of the drudgery from the sysop's life.  Sorry
  731. MBL users, but you will not be compatible with this feature.  With no
  732. source, I don't have the time to muddle through Jeff's mailfile format.
  733.  
  734. I may even write a little program for the users that will squirt the
  735. chunkfiles out to the local bbs per a schedule.  My time constraints will
  736. determine this one.  If anyone is interested in working with me on any of
  737. these,  please contact me by mail or packet or phone and let's coordinate
  738. our efforts.
  739.  
  740. XIV.   CLOSING NOTE
  741.  
  742. There are basically 2 schools of thought regarding public domain software.
  743. One school says that you should not release a program until it's perfect.
  744. That you should spend months picking all the nits and eliminating all
  745. possible rough edges.  Never release source and ask for money when you do
  746. finally release only the object file. The other school says that you should
  747. craft a program into reasonably fine order, eliminating all known bugs and
  748. as many rough edges as possible, and then release the program for the early
  749. good of all who can use it.  Make note any known rough edges in the DOC
  750. file, note that there may be other problems, and release the program with
  751. source so others can change things around to suit the specific situation.
  752.  
  753. I'm a member of this latter school of thought.  I believe that a program
  754. that has a few known bugs but is nonetheless useful is better than promises
  755. of a perfect but non-existent one. Hard to load and execute promises, hi.
  756. As I look over the history of public domain software, I realize that the
  757. truly great programs were handled in just this manner.  This list starts
  758. with the very first commercial grade software, the modem program, XMODEM by
  759. Ward Christensen.  Now Ward probably could have made a handsome chunk of
  760. change selling XMODEM.  Remember, back then there was NO method of sending
  761. data via modem in an error-free fashion.  It could have perhaps taken the
  762. place of CrossTalk as the best seller of modem programs.  Instead, Ward
  763. released the program and the protocol to the public domain.  The rest is
  764. history.  I still use MODEM7 on my CP/M machines and the list of credits to
  765. people who have worked on it would fill a page.
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772. CHUNK'N'GLUE is by no means in the same league with XMODEM, but it does
  773. fill a need and is offered in the same spirit.  Hack it, play with it,
  774. study it, perhaps, criticize it, but please remember that it is free.
  775. Therefore, I cannot support it like a commercial program.  Letters, disks
  776. and packet messages are welcome; phone calls for simple questions are not.
  777. (If you want to collaborate on this or other projects, please DO call. I'm
  778. listed in Information.)  Also remember that this is an early release.
  779. THERE MAY STILL BE UNDISCOVERED BUGS.  I have tested the program
  780. extensively in the PC-DOS 3.1 environment using MicroSoft C v4.0.  I try to
  781. write portable code, but there's no guarantee this program will run on
  782. other than DOS machines.  So, have fun y'all.
  783.  
  784.                                 --- END ---
  785.  
  786.