Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!abcfd20.larc.nasa.gov!amiga-request From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator) Newsgroups: comp.sources.amiga Subject: v90i241: manconv 1.0 - print UNIX man files, optimizing underlining, Part01/01 Message-ID: Date: 23 Aug 90 00:40:05 GMT Reply-To: Gregory Stelmack (CS) Lines: 440 Approved: tadguy@uunet.UU.NET (Tad Guy) X-Mail-Submissions-To: amiga@uunet.uu.net X-Post-Discussions-To: comp.sys.amiga Submitted-by: Gregory Stelmack (CS) Posting-number: Volume 90, Issue 241 Archive-name: util/manconv-1.0/part01 [ uuencoded executable enclosed ...tad ] This program was written to allow the printing of Unix man files from an Amiga. I do a lot of work at home, and I like to download files and print them on my Amiga's printer. Unfortunately, some files (notably the man files) use underscore-backspace ('_\b') to underline. This program converts these to Amiga underline-on underline-off format. It finds groups of letters that are underlined and brackets them with the above sequence to optimize length on underlined words/sentences (although individual underlined characters lead to increased file length). #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'ManConv.c' <<'END_OF_FILE' X/* X X FILE: manconv.c -- convert a Unix man file to Amiga print format by Xremoving underline characters and bracketing an underlined area with Amiga Xunderline on/off sequences. Underline on = ESC[4m, off = ESC[24m. X AUTHOR: Gregory M. Stelmack X REVISIONS: June 30, 1990 -- Version 1.0 X X*/ X X#include XFILE *infile, *outfile; X X#ifndef FALSE X #define FALSE 0 X#endif X X#ifndef TRUE X #define TRUE 1 X#endif X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X int FoundUnderScore = FALSE, FoundUnderLine = FALSE; X int FoundNormal = FALSE, i; X char c; X X if(argc!=3) X { X fprintf(stderr,"usage: manconv InFileName OutFileName\n"); X exit(1); X } X X infile = fopen(argv[1],"r"); X if(infile == NULL) X { X fprintf(stderr,"manconv: Could not open %s\n",argv[1]); X exit(2); X } X outfile = fopen(argv[2],"w"); X if(outfile == NULL) X { X fprintf(stderr,"manconv: Could not open %s\n",argv[2]); X exit(3); X } X X while( ( c = getc(infile) ) != EOF) X { X switch(c) X { X case '_': X FoundNormal = FALSE; X if(FoundUnderScore == TRUE) X { X putc('_',outfile); X if(FoundUnderLine == TRUE) X { X putc(27,outfile); X putc('[',outfile); X putc('2',outfile); X putc('4',outfile); X putc('m',outfile); X } X FoundUnderLine = FALSE; X } X else X FoundUnderScore = TRUE; X break; X case '\b': X if(FoundUnderScore == TRUE) X { X if(FoundUnderLine == FALSE) X { X putc(27,outfile); X putc('[',outfile); X putc('4',outfile); X putc('m',outfile); X FoundUnderLine = TRUE; X } X FoundUnderScore = FALSE; X break; X } X default: X FoundUnderScore = FALSE; X if(FoundNormal == TRUE) X { X if(FoundUnderLine == TRUE) X { X putc(27,outfile); X putc('[',outfile); X putc('2',outfile); X putc('4',outfile); X putc('m',outfile); X } X FoundUnderLine = FALSE; X } X FoundNormal = TRUE; X putc(c,outfile); X break; X } X } X X if(FoundUnderLine == TRUE) X { X putc(27,outfile); X putc('[',outfile); X putc('2',outfile); X putc('4',outfile); X putc('m',outfile); X } X X i=fcloseall(); X if(i==-1) X fprintf(stderr,"manconv: Not all files closed!"); X} END_OF_FILE if test 4252 -ne `wc -c <'ManConv.c'`; then echo shar: \"'ManConv.c'\" unpacked with wrong size! fi chmod +x 'ManConv.c' # end of 'ManConv.c' fi if test -f 'ManConv.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ManConv.doc'\" else echo shar: Extracting \"'ManConv.doc'\" \(1154 characters\) sed "s/^X//" >'ManConv.doc' <<'END_OF_FILE' XManConv 1.0 by Gregory M. Stelmack X XThis program was written to allow the printing of Unix man files from an XAmiga. I do a lot of work at home, and I like to download files and print Xthem on my Amiga's printer. Unfortunately, some files (notably the man files) Xuse underscore-backspace ('_\b') to underline. This program converts these to XAmiga underline-on underline-off format. It finds groups of letters that are Xunderlined and brackets them with the above sequence to optimize length on Xunderlined words/sentences (although individual underlined characters lead to Xincreased file length). X XTo use, simply type 'manconv InFileName OutFileName'. ManConv will read the XInFile, do the conversion, and write the OutFile. Then type 'copy OutFileName Xprt:' to print, and let the Amiga work. You will get a printout with Xunderlining where it should be. X XNOTICE: This code is copyright 1990 by Gregory M. Stelmack. You may use it as Xyou will, so long as this copyright notice accompanies it. X XBUG REPORTS, ENHANCEMENTS, WISHES to: XGregory M. Stelmack XEMail: stelmack@sol.csee.usf.edu or stelmack@sunrise.ec.usf.edu XUSMail: USF Box 1510, Tampa, FL 33620-1510 END_OF_FILE if test 1154 -ne `wc -c <'ManConv.doc'`; then echo shar: \"'ManConv.doc'\" unpacked with wrong size! fi chmod +x 'ManConv.doc' # end of 'ManConv.doc' fi if test -f 'ManConv.uu' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ManConv.uu'\" else echo shar: Extracting \"'ManConv.uu'\" \(13536 characters\) sed "s/^X//" >'ManConv.uu' <<'END_OF_FILE' Xbegin 700 ManConv XM```#\P`````````#``````````(`````$(FP$1$ZN_F).@ XMN@`\2JP"X&<:(BP"Z&<$3J[_W"QX``1.KO]\(FP"X$ZN_H8@'RYL`N1,WW]^_ XM3G5D;W,N;&EB0!.=4YU3E7_[$CG+Q`N+P`T)F\`."@'<#'`JP`89P9P\ XM_V```G`(*P`'`!I6P$0`2(!(P"P`2JL`%&8``(0(*P`"`!MF>G``)T``#'+_R XMOH%G``)"+PM.NA5J6$]*@&<,".L`!0`;0```!1.N@9T``````````!P84CG(#`F;P`0)$M*B XM$F6!TH+2@=*`8.8,$0`M9@)$- XM@20?(`A3@"!O``@@@9")3G5.5?_F2.`/M+PM.N@5@4$\H` XM`$J$:@0(QP`)"`<`"6<:&WP``?__*6W_\@1`+RW_[B\+3KH%Y%!/*`!*+?__^ XM9S8@!W)XTH'`@4J`9RI*A&LF+P1.N@8L2'@#[2\+3KH%#D_O``PH`&`.2'@#1 XM[2\+3KH$_%!/*`!*K`*\9P1P_V`()(8E1``$(`5,WPSP3EU.=0``````````] XM`````````````````````````````'!A2.P`Q XME"92(`MG0"`K``2PAVTRL(=F#"!3)(B?K`"8(`M@;B`K``20AW((L(%E%B!+> XMT</__3KKW%B`L!#Q,[0P`__A.74YU``!.5?_P2.``,0`!B9PH,0`!A9@QZ`&`&*CP``(``4H=RA XM*[(S>`!7P$0`2(!(P"@`<``0$PQ``'=G``"(#$````,D XM+SP``($"+RT`"$ZZ_%1/[P`,+`!P_[R`9@9P`&```-!*A&<&<$#0@&`"<`(N4 XM``!'0`!@``"(2H1G!'`"8`)P``!`@`!(>``,+P`O+0`(3KK\$$_O``PL`'#_$ XMO(!F!G``8```C$J$9P9P0-"`8`)P`2X`8$A*A&<$<`)@`G`!`$"```!``0``G XM0`(`2'@`#"\`+RT`"$ZZ^\I/[P`,+`!P_[R`9@1P`&!&2H1G!G!`T(!@`G`"> XM+@!@!'``8#*1R"5(`!!P`"5``!0E1@`<)6H`$``$)4``#"5```A*A68&(#P`R XM`(``(@>"@"5!`!@@"DS?#/!.74YU``````````!P84CG!Q!Z`"P%1^P`H"`+H XM9QI*JP`89Q`O"TZZ#:)83TJ`9P)Z_U*&)E-@XDJ%9P1P_V`"(`9,WPC@3G4`C XM`````````'!A2.<#$"XO`!!'[`"@(`MG-`@K``(`&V8H""L``0`;9R`@*P`$< XMD*L`$"P`2H9G$B\&+RL`$"\K`!Q.N@0R3^\`#"938,@O!TZZ"R!83TS?",!./ XM=0``2.B('I XM+&P$1$ZN_]QP`"X?3G5(YS``)``F`4A"2$/$P<;`P,'40TA"0D+0@DS?``Q.^ XM=4J`:@``'D2`2H%J```,1(%A```@1(%.=6$``!A$@$2!3G5*@6H```Q$@6$`& XM``9$@$YU+P)(030!9@``(DA`2$%(0C0`9P``!H3!,`)(0#0`A,$P`DA",@(D, XM'TYU+P-V$`Q!`(!D```&X9E10PQ!"`!D```&Z9E90PQ!(`!D```&Y9E50TI!T XM:P``!N.94T,T`.:H2$)"0N:J2$.`P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$AX`&U.N@%Z4$\B`'H`>`$@;`+T& XM4Z@`#&T:(FP"]"!I``12J0`$$"W_[Q"`<@`2`&``_((0+?_O<@`2`"\L`O0OJ XM`4ZZ`3Q03R(`8`#\:'`!NH!F``#R(&P"]%.H``QM%B)L`O0@:0`$4JD`!'`;U XM$(!R`!(`8!`O+`+T2'@`&TZZ`0!03R(`(&P"]%.H``QM%B)L`O0@:0`$4JD`2 XM!'!;$(!R`!(`8!`O+`+T2'@`6TZZ`-!03R(`(&P"]%.H``QM%B)L`O0@:0`$U XM4JD`!'`R$(!R`!(`8!`O+`+T2'@`,DZZ`*!03R(`(&P"]%.H``QM%B)L`O0@! XM:0`$4JD`!'`T$(!R`!(`8!`O+`+T2'@`-$ZZ`'!03R(`(&P"]%.H``QM%B)LL XM`O0@:0`$4JD`!'!M$(!R`!(`8!`O+`+T2'@`;4ZZ`$!03R(`3KH`)BM`__!2$ XM@&8.2&P`9$AL`.1.N@`>4$],WPCP3EU.=4[Y```%V$[Y```,&$[Y```9>$[YH XM```*:$[Y```!K$[Y```,7$[Y```$4'!A```#[`````<````````%6```!6H`# XM``5V```%7@``!7````5D```%4@````````/R```#Z@```*EU. Mail comments to the moderator at . Post requests for sources, and general discussion to comp.sys.amiga.