• TYPEHTML.SRC

    From Digital Man@VERT to All on Mon Oct 9 11:41:27 2000
    I'm converting my "working documents" for Synchronet (to-do list, FAQs, etc) toãHTML and needed an easy way to "share" these files with the users on the BBS,ãwithout requiring them to download them and view them in a web browser.ããSo, I spent "some time" today creating this little "diddy" in Baja and justãthought I'd post the source here since it's probably the most intense Bajaãcoding I've done since QNET.SRC (QWK networking module for SBBS v2). I'll beãputting this on Vertrauen for download too.ããIt only handles BASIC HTML right now, so don't be too shocked if it doesn'tãprint your more elaborate HTML files very nicely. Obviously, things likeãgraphics and fonts can't be well represented on a typical telnet terminal.ã(HTML to RIP anyone?)ããWell, here it is:ãã# TypeHTMLãã# Synchronet Baja Modules to Display HTML files to TTY/ANSI usersãã# Created October 09, 2000 by Rob Swindellãã!include file_io.incã!include sbbsdefs.incãã# Color Attributes for HTML type stylesã!define NORMAL "\1N\1H"ã!define HEADING1 "\1H\1Y"ã!define HEADING2 "\1H\1C"ã!define HEADING3 "\1H\1M"ã!define HEADING4 "\1H\1G"ã!define HEADING5 "\1H\1B" ã!define HEADING6 "\1H\1R"ã!define BOLD "\1H\1C\x014"ã!define ITALIC "\1H\1G\x012"ã!define UNDERLINE "\1H\1W\x016"ã!define STRIKE_THROUGH "\1N\1K\x017"ã!define LIST_ITEM " \1H\1Wo \1G"ããstr filenameãstr hrefãstr tmpãint iãint file ãint hlevel # header levelãint col # current cursor columnãint last_line_len # length of last line printedãint lines # total lines printedãint printing # printing onãint newline # new line read from html fileããcopy filename strããcompare_str ""ãif_trueã print "usage: *typehtml <filename>"ã returnã end_ifããfopen file O_RDONLY|O_DENYNONE filenameãif_falseã printf "!Error %d opening %s\r\n" _ERRNO filenameã returnã end_ifããset col 0 # reset column counterãset last_line_len 0 # reset last line lengthãset lines 0 # reset line counterãset printing 1 # printing by defaultãcls # clear screenãprint NORMAL # normal colorãã:next_lineãã # Check abort flagã copy i _sys_statusã and i SS_ABORTã compare i 0ã if_not_equal # user aborting listingã returnã end_ifãã # Read a line ã fread_line file strã if_false # end of fileã crlfã pauseã returnã end_ifãã set newline 1ãã # truncate whitespaceã strip_ctrl strã :skip_whitespaceã compare_word " "ã if_falseã compare_word "\t"ã end_ifã if_trueã shift_str 1ã goto skip_whitespaceã end_ifãã :next_charã compare_str ""ã if_trueã goto next_lineã end_ifã sprintf tmp "%.1s" strã shift_str 1ã compare tmp "<"ã if_falseã compare printing 1ã if_trueã # handle word wrapã compare newline 1ã if_equalã compare col 0ã if_not_equalã print " " ã add col 1ã end_ifã end_ifã set newline 0ãã # don't start lines with white-spaceã compare col 0ã if_trueã compare tmp " " ã end_ifã if_falseã print tmpã add col 1ã compare col 79ã if_greater_or_equalã call crlfã end_ifã end_ifã end_ifã goto next_charã end_ifãã # Titleã compare_word "TITLE>"ã if_trueã set printing 0ã call find_close_bracketã goto next_charã end_ifã compare_word "/TITLE>"ã if_trueã set printing 1ã call find_close_bracketã goto next_charã end_ifããã # List itemã compare_word "LI>"ã if_falseã compare_word "LI "ã end_ifã if_trueã compare col 0ã if_not_equalã call crlfã end_ifã printf LIST_ITEMã set col 6ã call find_close_bracketã goto next_charã end_ifãã # Strike-throughã compare_word "S>"ã if_falseã compare_word "STRIKE>"ã end_ifã if_trueã printf STRIKE_THROUGHã call find_close_bracketã goto next_charã end_ifãã # Boldã compare_word "B>"ã if_falseã compare_word "STONG>"ã end_ifã if_trueã printf BOLDã call find_close_bracketã goto next_charã end_ifãã # Italicsã compare_word "I>"ã if_falseã compare_word "EM>"ã end_ifã if_trueã printf ITALICã call find_close_bracketã goto next_charã end_ifãã # Underlineã compare_word "U>"ã if_falseã compare_word "U>"ã end_ifã if_trueã printf UNDERLINEã call find_close_bracketã goto next_charã end_ifããã # Attribute offã compare_word "/S>"ã if_falseã compare_word "/STRIKE>"ã end_ifã if_falseã compare_word "/B>"ã end_ifã if_falseã compare_word "/STONG>"ã end_ifã if_falseã compare_word "/I>"ã end_ifã if_falseã compare_word "/EM>"ã end_ifã if_falseã compare_word "/U>"ã end_ifã if_trueã print NORMALã call find_close_bracketã goto next_charã end_ifãã # Table cellã compare_word "TD>"ã if_falseã compare_word "TD "ã end_ifã if_trueã # visually separate cellsã compare col 0ã if_greaterã print " " ã add col 1ã end_ifã call find_close_bracketã goto next_charã end_ifã ãã # Dumb CR/LF block ã compare_word "BR>"ã if_falseã compare_word "BR "ã end_ifã if_falseã compare_word "P>"ã end_ifã if_falseã compare_word "P "ã end_ifã if_falseã compare_word "TR>"ã end_ifã if_falseã compare_word "TR " ã end_ifã if_trueã call crlfã call find_close_bracketã goto next_charã end_ifã ãã # Intelligent CR/LF block (force single blank line)ã compare_word "/UL>"ã if_falseã compare_word "/OL>"ã end_ifã if_falseã compare_word "/DIR>"ã end_ifã if_falseã compare_word "/MENU>"ã end_ifã if_trueã print NORMALã end_ifã if_falseã compare_word "H"ã if_trueã shift_str 1ã copy hlevel strã compare hlevel 0 ã if_greaterã switch hlevelã case 1ã print HEADING1ã end_caseã case 2ã print HEADING2ã end_caseã case 3ã print HEADING3ã end_caseã case 4ã print HEADING4ã end_caseã case 5ã print HEADING5ã end_caseã defaultã print HEADING6ã end_caseã end_switchã setlogic TRUEã elseã setlogic FALSEã end_ifã end_ifã end_ifã if_falseã compare_word "/H"ã if_trueã shift_str 2ã copy hlevel strã compare hlevel 0 ã if_greaterã print NORMALã setlogic TRUEã elseã setlogic FALSEã end_if ã end_ifã end_ifã if_trueã compare lines 0ã if_equalã compare col 0ã end_ifã if_greaterã compare last_line_len 0ã if_equalã compare col 0ã end_ifã if_not_equalã call crlfã call crlfã end_ifã end_ifã call find_close_bracketã goto next_charã end_ifã ã # Hyper-linkã compare_word "A HREF="ã if_trueã shift_str 7ã set href ""ã :copy_hrefã sprintf tmp "%.1s" strã compare tmp ">"ã if_falseã shift_str 1ã strcat href tmpã goto copy_hrefã end_ifã end_ifãã # Show hyper-linkã compare_word "/A>"ã if_trueã compare href ""ã if_falseã strlen i hrefã add i 3ã add col iã compare col 79ã if_equal_or_greaterã call crlfã sub i 1ã copy col iã elseã print " "ã end_if ã printf "<%s>" hrefã end_ifã set href ""ã end_ifãã call find_close_bracketã goto next_charã ãreturnãã# Carriage-return/Line-feed with column resetã:crlfãcopy last_line_len colãcrlfãset col 0ãadd lines 1ãreturnãã# Shift str past first close bracketã:find_close_bracketãcompare_str ""ãif_trueã returnã end_ifããsprintf tmp "%.1s" strãshift_str 1ãcompare tmp ">"ãif_falseã goto find_close_bracketã end_if ãreturnã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From Amcleod@VERT to Digital Man on Wed Oct 11 00:50:53 2000
    RE: TYPEHTML.SRCãBY: Digital Man to All on Mon Oct 09 2000 06:41 pmãã > So, I spent "some time" today creating this little "diddy" in Baja and justã > thought I'd post the source here since it's probably the most intense Bajaã > coding I've done since QNET.SRC (QWK networking module for SBBS v2). I'll beã > putting this on Vertrauen for download too.ããAny reason why I can't FTP this file?ããI can't seem to get Z-Modem working on this box, and when I tried to connect toãthe FTP server it kept refusing to allow me online. I get "530 not logged in"ãas soon as I put in the password.ã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From Digital Man@VERT to Amcleod on Wed Oct 11 04:54:52 2000
    RE: TYPEHTML.SRCãBY: Amcleod to Digital Man on Wed Oct 11 2000 07:50 amãã > RE: TYPEHTML.SRCã > BY: Digital Man to All on Mon Oct 09 2000 06:41 pmã > ã > > So, I spent "some time" today creating this little "diddy" in Baja and juã > > thought I'd post the source here since it's probably the most intense Bajã > > coding I've done since QNET.SRC (QWK networking module for SBBS v2). I'llã > > putting this on Vertrauen for download too.ã > ã > Any reason why I can't FTP this file?ã > ã > I can't seem to get Z-Modem working on this box, and when I tried to connectã > the FTP server it kept refusing to allow me online. I get "530 not logged iã > as soon as I put in the password.ããI don't know. Other people (and myself) have been able to login just fine. Isãit possible you forgot the "user" command?ããRobã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From Amcleod@VERT to Digital Man on Wed Oct 11 06:31:17 2000
    RE: TYPEHTML.SRCãBY: Digital Man to Amcleod on Wed Oct 11 2000 11:54 amãã > > Any reason why I can't FTP this file?ã > ã > I don't know. Other people (and myself) have been able to login just fine. Iã > it possible you forgot the "user" command?ãã alfred:~$ ftp ftp.synchro.netã Connected to www.synchro.net.ã 220 Serv-U FTP-Server v2.5a for WinSock ready...ã Name (ftp.synchro.net:amcleod): amcleodã 331 User name okay, need password.ã Password:ã 530 Not logged in.ã Login failed.ã Remote system type is UNIX.ã Using binary mode to transfer files.ã ftp> lsã 530 Not logged in.ã ftp: bind: Address already in useã ftp> byeã 221 Goodbye!ã alfred:~$ããI don't know what to make of it. The PW is not shown because it doesn'tãecho. I am _sure_ I'm getting it right - I've tried maybe 20 times, and I'veãused various capitalization on the username and the password. Wait, let me tryãsomething:ããOkay! I can get onto vert.synchro.net but not ftp.synchro.net for some reason.ãLet me try something else:ããHehehe! :) <-- red face! Okay, so if I use anonymous FTP then I get onãto ftp.synchro.net without problems. Sorry about that - I guess I need moreãsleep or something...ã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From Digital Man@VERT to Amcleod on Wed Oct 11 11:33:15 2000
    RE: TYPEHTML.SRCãBY: Amcleod to Digital Man on Wed Oct 11 2000 01:31 pmãã > > > Any reason why I can't FTP this file?ã > >ã > > I don't know. Other people (and myself) have been able to login just fineã > > it possible you forgot the "user" command?ã > ã > alfred:~$ ftp ftp.synchro.netããYeah, wrong hostname. :-)ããRobã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From Plunder Point@VERT/CANNONIA to Digital Man on Fri Oct 13 17:54:00 2000
    RE: TYPEHTML.SRCãBY: Digital Man to All on Mon Oct 09 2000 06:41 pmããI had to change line 44 of TYPEHTML.SRC to:ããfopen file O_RDONLY|O_DENYNONE filenameããto make it compile without an error. Was that a typo on your part, or do Iãhave an outdated version of the BAJA compiler that just wouldn't accept whatãyou had in your source code?ãã---ã þ Synchronet þ Cannonia BBS - cannonia.darktech.org:5003ã
  • From Amcleod@VERT to Plunder Point on Sat Oct 14 01:28:34 2000
    RE: TYPEHTML.SRCãBY: Plunder Point to Digital Man on Sat Oct 14 2000 12:54 amãã > I had to change line 44 of TYPEHTML.SRC to:ã > ã > fopen file O_RDONLY|O_DENYNONE filenameã > ã > to make it compile without an error......ããDuuuh... You changed it ããFROM: fopen file O_RDONLY|O_DENYNONE filenameãTO: fopen file O_RDONLY|O_DENYNONE filenameããAnd it corrected the error??? Mow THAT is a feat of debugging skill, the likesãof which has not been seen for many a day.....ããHow long did it take you to figure out the changes?ããDigital Man: SHAME on you for leaving such an obvious bug in your code! ;-)ã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From Plunder Point@VERT/CANNONIA to Amcleod on Sat Oct 14 19:53:00 2000
    RE: TYPEHTML.SRCãBY: Amcleod to Plunder Point on Sat Oct 14 2000 08:28 amãã > RE: TYPEHTML.SRCã > BY: Plunder Point to Digital Man on Sat Oct 14 2000 12:54 amã > ã > > I had to change line 44 of TYPEHTML.SRC to:ã > >ã > > fopen file O_RDONLY|O_DENYNONE filenameã > >ã > > to make it compile without an error......ã > ã > Duuuh... You changed itã > ã > FROM: fopen file O_RDONLY|O_DENYNONE filenameã > TO: fopen file O_RDONLY|O_DENYNONE filenameã > ã > And it corrected the error??? Mow THAT is a feat of debugging skill, the liã > of which has not been seen for many a day.....ã > ã > How long did it take you to figure out the changes?ã > ã > Digital Man: SHAME on you for leaving such an obvious bug in your code! ;-)ã > ãTypo on my part. I had to change it to:ããfopen file O_RDONLY|O_DENYNONE filenameããto make it compile.ãã---ã þ Synchronet þ Cannonia BBS - cannonia.darktech.org:5003ã
  • From Plunder Point@VERT/CANNONIA to Plunder Point on Sun Oct 15 06:53:00 2000
    RE: TYPEHTML.SRCãBY: Plunder Point to Amcleod on Sun Oct 15 2000 02:53 amãã > fopen file O_RDONLY|O_DENYNONE filenameããThat's O_RDONLY followed by a pipe and then O_DENYNONE. Apparently the pipeãgets itself garbled when posted here? That would explain it.ãã---ã þ Synchronet þ Cannonia BBS - cannonia.darktech.org:5003ã
  • From Digital Man@VERT to Plunder Point on Sun Oct 15 15:58:30 2000
    RE: TYPEHTML.SRCãBY: Plunder Point to Digital Man on Sat Oct 14 2000 12:54 amãã > I had to change line 44 of TYPEHTML.SRC to:ã > ã > fopen file O_RDONLY|O_DENYNONE filenameã > ã > to make it compile without an error. Was that a typo on your part, or do Iã > have an outdated version of the BAJA compiler that just wouldn't accept whatã > you had in your source code?ããYou probalby have Celerity or Renegade color codes enabled on your system, inãwhich case the "pipe" symbol gets eaten.ããRobã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From Amcleod@VERT to Plunder Point on Sun Oct 15 22:06:35 2000
    RE: TYPEHTML.SRCãBY: Plunder Point to Plunder Point on Sun Oct 15 2000 01:53 pmãã > > fopen file O_RDONLY|O_DENYNONE filenameã > ã > That's O_RDONLY followed by a pipe and then O_DENYNONE. Apparently the pipeã > gets itself garbled when posted here? That would explain it.ããI'm seeing a pipe in the original and in both your "corrections". Hmmm Iãwonder if those pesky colour codes (is it WWIV?) are to blame?ã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From Digital Man@VERT to Amcleod on Mon Oct 16 05:08:49 2000
    RE: TYPEHTML.SRCãBY: Amcleod to Plunder Point on Mon Oct 16 2000 05:06 amãã > > > fopen file O_RDONLY|O_DENYNONE filenameã > >ã > > That's O_RDONLY followed by a pipe and then O_DENYNONE. Apparently the pã > > gets itself garbled when posted here? That would explain it.ã > ã > I'm seeing a pipe in the original and in both your "corrections". Hmmm Iã > wonder if those pesky colour codes (is it WWIV?) are to blame?ããThey're Celerity and Renegade color codes, and I have them disabled here onãVertrauen. :-)ããRobã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From Amcleod@VERT to Digital Man on Mon Oct 16 13:09:36 2000
    RE: TYPEHTML.SRCãBY: Digital Man to Amcleod on Mon Oct 16 2000 12:08 pmãã > > > > fopen file O_RDONLY|O_DENYNONE filenameã > > >ã > > > That's O_RDONLY followed by a pipe and then O_DENYNONE. Apparently thã > > > gets itself garbled when posted here? That would explain it.ã > >ã > > I'm seeing a pipe in the original and in both your "corrections". Hmmm Iã > > wonder if those pesky colour codes (is it WWIV?) are to blame?ã > ã > They're Celerity and Renegade color codes, and I have them disabled here onã > Vertrauen. :-)ããI seem to recall doing O_RDONLY+O_DENYNONE instead of O_RDONLY|O_DENYNONE inãthe past to avoid this problem. It isn't exactly perfect but it _usually_ãworks, so long as the items you are ORing are single-bit-on values...ããPity you can't do <code><pre>Yada Yada</pre></code> eh? At least, not YET...ãã:)ã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From Plunder Point@VERT/CANNONIA to Digital Man on Mon Oct 16 16:15:00 2000
    RE: TYPEHTML.SRCãBY: Digital Man to Amcleod on Mon Oct 16 2000 12:08 pmãã > They're Celerity and Renegade color codes, and I have them disabled here onã > Vertrauen. :-)ãAnd they're going to be disabled here on Cannonia in just a few minutes... ãSorry to bother you with a typo that didn't really exist. :)ãã---ã þ Synchronet þ Cannonia BBS - cannonia.darktech.org:5003ã
  • From Reaper Man@VERT/FLAMINT to Amcleod on Wed Oct 18 11:40:00 2000
    RE: TYPEHTML.SRCãBY: Amcleod to Plunder Point on Sat Oct 14 2000 08:28:00ãã > FROM: fopen file O_RDONLY|O_DENYNONE filenameã > TO: fopen file O_RDONLY|O_DENYNONE filenameã > ã > And it corrected the error??? Mow THAT is a feat of debugging skill, the liã > of which has not been seen for many a day.....ã > ã > How long did it take you to figure out the changes?ã > ã > Digital Man: SHAME on you for leaving such an obvious bug in your code! ;-)ããagghhh, i can't see a difference, oh my god I'm going blind!!!!ãã---ã þ Synchronet þ Flamin' Torch BBS - Fired Up and ready to go flamint.dyndns.orgã
  • From Reaper Man@VERT/FLAMINT to Plunder Point on Wed Oct 18 11:42:00 2000
    RE: TYPEHTML.SRCãBY: Plunder Point to Plunder Point on Sun Oct 15 2000 13:53:00ãã > > fopen file O_RDONLY|O_DENYNONE filenameã > ã > That's O_RDONLY followed by a pipe and then O_DENYNONE. Apparently the pipeã > gets itself garbled when posted here? That would explain it.ããoh god, i was gettin' really worried there for a minute.ãã---ã þ Synchronet þ Flamin' Torch BBS - Fired Up and ready to go flamint.dyndns.orgã