August 9, 2001

Finally figured out the problem with the attachments in NewsHoard! Turns out that it wasn’t a coding problem at all but a bug in the component (which to be fair is in beta status at the moment) that I was using to access news server functionality – and I spent about two day’s trying to figure out what the heck was wrong :p I even tried out a few alternative components but in each case the documentation wasn’t ideal and I had to go through the source and then I was operating under one fatal misaprehension – I thought that attachments were encoded in base64 but it turns out they are uuencoded.

Anyway, what happened was that I had no success with any of the other components that I had and so I decided to buckle down and try to figure out what was going wrong with my initial approach. I’d save an attachment (usually a JPG or GIF) and AcdSee would open it but it would be blank. So I fired up Gravity and saved the same attachment and this time it was fine. Gravity shows the encoded file which is decoded and saved in the message view and so I then saved the encoded text into a file and did the same for NewsHoard. Run them through a comparison program and they were identical! So I knew that there was no problem with what NewsHoard downloaded – it had to be the decoding. Then I compared the saved images again through a hex editor and I noticed that while the files started out the same, after about 45 bytes the NewsHoard version had an extra 0F in there and then everything was the same again for about 45 bytes more and then there was an extra 0F and so on … Now I knew the problem – the component that I was using was decoding the file properly but was inserting a 0F after every 45 bytes or so :p

Now this is where using open source components comes in handy – because you get the source and can run through it with a debugger <g> I downloaded another file with NewsHoard and this time watched the decoding process to figure out where the extra 0F was coming from and realized that the decoder was reading the encoded text a line at a time and that the 0F went at the end of each line that was decoded! Then it was simply a matter of figuring out how to disable the addition of the extra 0F and I was all set!

Basic functionality in NewsHoard is now almost complete! I need to do a little bit more cleaning up – add a few missing features like unsubscribing from newsgroups and I should be set for the first beta! So stay tuned 🙂

Tags:
Posted by Fahim at 8:06 am  |  No Comments