home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume9 / pep / part01 next >
Text File  |  1989-12-29  |  20KB  |  557 lines

  1. Newsgroups: comp.sources.misc
  2. organization: gisle@ifi.uio.no
  3. subject: v09i092: PEP filter program [ part 1 of 5 ]
  4. from: gisle@ifi.uio.no (Gisle Hannemyr)
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 9, Issue 92
  8. Submitted-by: gisle@ifi.uio.no (Gisle Hannemyr)
  9. Archive-name: pep/part01
  10.  
  11. # This is a shell archive [ part 1 of of 5 ]
  12. # Remove everything above and including the cut line.
  13. # Then run the rest of the file through /bin/sh (not csh).
  14. #--cut here-----cut here-----cut here-----cut here-----cut here-----cut here--#
  15. #!/bin/sh
  16. # shar: Shell Archiver
  17. # Execute the following text with /bin/sh to create the file(s):
  18. #    Doc/aaaread.me
  19. #    Doc/header.txt
  20. #    ansi.c
  21. # This archive created: Fri Dec 29 14:56:49 1989
  22. # Wrapped by: Gisle Hannemyr (gisle@ifi.uio.no)
  23. echo shar: extracting aaaread.me
  24. sed 's/^XX//' << \SHAR_EOF > aaaread.me
  25. XXRELEASE-NOTES
  26. XX=============
  27. XX
  28. XXName:         pep, ver. 2.1
  29. XXAuthor:         Gisle Hannemyr, Brageveien 3A, N-0452 Oslo, Norway.
  30. XX         EAN:  gisle@nr.uninett
  31. XX         Inet: gisle@ifi.uio.no
  32. XX         UUCP: ..!mcvax!ifi!gisle
  33. XXPurpose:     Detergent for "dirty" files
  34. XXLanguage:    K&R C
  35. XXEnvironment: Fairly generic (CP/M, MS-DOS, UNIX, VMS)
  36. XXFiles:         PEP21.ARC
  37. XX         Contents:
  38. XX        aaaread.me   -- this file
  39. XX        header.txt   -- advice about portability of pep
  40. XX        pep.1l         -- manual page (nroff source)
  41. XX        Makefile.dos -- commands to make distribution (MS-DOS)
  42. XX        Makefile.unx -- commands to make distribution (Unix)
  43. XX        Makevms.com  -- DCL script to compile and link (VMS)
  44. XX        ansi.c         -- ansi terminal interpreter
  45. XX        bdmg.c         -- DUCOS brain damage compensation
  46. XX        main.c         -- root module
  47. XX        plain.c         -- standard filter module
  48. XX        bdmg.h         -- bdmg.c types and functions
  49. XX        pep.h         -- types and functions for pep
  50. XX        mac2ibm         -- sample conversion table
  51. XX        ibm2mac         -- sample conversion table
  52. XX        ebc2ns7         -- conv.-table EBCDIC to NS 4551
  53. XX        ibm2ro8         -- conv.-table IBM-PC to ROMAN8
  54. XX        ro82ibm         -- ditto
  55. XX        ibm2iso         -- conv.-table CP 850 to ISO 8859/1
  56. XX        iso2ibm         -- ditto
  57. XX
  58. XX
  59. XXDescription:
  60. XX   Pep is a general purpose filter and file cleaning program.
  61. XX   It is named after an excellent Norwegian detergent.    Pep may
  62. XX   be used to expand/compress tabs; convert to and from several
  63. XX   character sets; to interprete ANSI escape sequences; and to
  64. XX   remove unanted line noise from files.  See the file pep.doc
  65. XX   for a complete description.
  66. XX
  67. XX
  68. XXInstallation:
  69. XX   The steps required to install pep are:
  70. XX
  71. XX   1) Print the manual page pep.doc on paper, and read it.
  72. XX   2) Compile the source file pep.c to a executable file.
  73. XX   3) Install the executable file.
  74. XX   4) Install the conversion tables.
  75. XX   5) Modify your startup profile as required.
  76. XX
  77. XX   In more detail:
  78. XX
  79. XX   1) If you have troff or ptroff, you may want to typeset the manual.
  80. XX      The troff command is: troff -man pep.1l .
  81. XX
  82. XX   2) One executable file (pep.exe) for MS-DOS systems is included
  83. XX      in the distribution archive.  If you are able to use this,
  84. XX      you may skip the compilation.
  85. XX
  86. XX      If you want to install pep on another operating system, you must
  87. XX      first compile it.     Instructions for compilation on several common
  88. XX      systems are at the start of the source file. A makefile is
  89. XX      also supplied.  Pep is fairly generic and should compile with
  90. XX      almost any C-compiler after very little tweaking.     Read the file
  91. XX      "header.txt" for advise about what pep expect to find in the
  92. XX      header files.
  93. XX
  94. XX   3) The executable will be named pep.exe, pep.com, pep.cmd or just
  95. XX      pep, depending upon which operating system you are using.     See
  96. XX      operating system notes below for recommended placement.
  97. XX
  98. XX   4) This are the files named mac2ibm, ro82ibm, ibm2ro8, etc.
  99. XX      You may want to add your conversion tables, which should be
  100. XX      installed in the same directory as those in the distribution.
  101. XX      As with executables, see the notes below for hints about where
  102. XX      tables should be installed on different systems.
  103. XX
  104. XX   5) Pep uses one environment variable: PEP, which should be defined
  105. XX      in the startup profile if possible.
  106. XX
  107. XX
  108. XXOperating system notes:
  109. XX   Below is some notes on points pertaining to the different operating
  110. XX   systems:
  111. XX
  112. XX   * CP/M systems:
  113. XX     Install the executable file and the conversion filters under
  114. XX     user 0.  CP/M does not have a startup profile or environment
  115. XX     variables.
  116. XX
  117. XX   * MS-DOS systems:
  118. XX     Install PEP.EXE in a directory that is defined in your PATH
  119. XX     environment variable, and define an environment variable PEP
  120. XX     pointing to the directory where the conversion filters are
  121. XX     installed.     If this is "c:\usr\lib" your startup profile
  122. XX     AUTOEXEC.BAT should contain a line like this:
  123. XX
  124. XX    set PEP=c:\usr\lib
  125. XX
  126. XX     Alternatively, you may put the conversion tables in the same
  127. XX     directory as you put the executables.  If you use this alternative,
  128. XX     it is not necessary to define the PEP environment variable.
  129. XX
  130. XX   * UNIX systems:
  131. XX     Install the executable file pep in a directory that is defined
  132. XX     in your PATH environment variable (a canonical place will be
  133. XX     /usr/local/bin).  Install the conversion table in a directory of
  134. XX     your choice (a canonical place will be /usr/local/lib).
  135. XX     Define an environment variable PEP pointing to the directory where
  136. XX     the conversion filters are installed.  If this is "/usr/local/lib"
  137. XX     your startup profile (.login on BSD systems, .profile on SYS-V)
  138. XX     should contain a line like this:
  139. XX
  140. XX    setenv PEP /usr/local/lib
  141. XX
  142. XX     Also, Unix users may want to install the manpage "pep.1l" in the
  143. XX     online manual.  The canonical placement is /usr/man/manl.
  144. XX
  145. XX   * VMS systems:
  146. XX     Pep need to be installed as a "foreign command", and you need
  147. XX     to define a symbol pointing to the conversion filters.  If both
  148. XX     the executable file and the filters is placed in directory named
  149. XX     "disk_daf:<d_progbib.vms>", you need to have the following two
  150. XX     lines in your startup profile LOGIN.COM.
  151. XX
  152. XX    $ pep :== $disk_daf:<d_progbib.vms>pep
  153. XX    $ define PEP "disk_daf:<d_progbib.vms>"
  154. XX
  155. XX     Incidently, this is where pep is installed on the University of
  156. XX     Oslo VMS Vax cluster.  If you have an account on one of the
  157. XX     machines in this cluster, having the two lines above in your
  158. XX     LOGIN.COM is all you need to use pep on these machines.
  159. XX
  160. XX     Also note that VMS does not support pipes and redirection, and
  161. XX     it is therefore awkward to use pep as a filter under VMS.    The
  162. XX     distributed version does not even try to run as a filter under
  163. XX     VMS, it has the -o option (write output back on file named as
  164. XX     input file) permanently enabled.
  165. XX
  166. XX
  167. XXVersion 2.1, news:
  168. XX   * The -u option is expanded to allow user's to specify canonical
  169. XX     line terminator.
  170. XX   * New option: -v, to make pep generate hard line terminators only
  171. XX     between paragraphs.
  172. XX   * New conversion table "ebc2ns7" for EBCDIC and DisplayWrite.
  173. XX   * Some old conversion tables are expanded.
  174. XX   * Bugfixes.
  175. XX
  176. XX..EOF
  177. SHAR_EOF
  178. if test 6074 -ne "`wc -c aaaread.me`"
  179. then
  180. echo shar: error transmitting aaaread.me '(should have been 6074 characters)'
  181. fi
  182. echo shar: extracting header.txt
  183. sed 's/^XX//' << \SHAR_EOF > header.txt
  184. XX(( Last edit: 1 dec 89 ))
  185. XX
  186. XX
  187. XX            Microcomputer C header files assumptions
  188. XX            ========================================
  189. XX
  190. XXTo avoid having my C programs looking like a  tangle  of  macroes
  191. XXand ifdefs,  I've started canonizing  the  header  files  for the
  192. XXdifferent C compilers I use.  My starting point is the draft ANSI
  193. XXC standard,  with generous influence  from  Borlands  Turbo-C 2.0
  194. XXand Microsoft C 5.1.
  195. XX
  196. XXBelow is what my programs assume about the standard header files.
  197. XXIf your compiler has  trouble  compiling  a  program  written  or
  198. XXsupported by me, the assumptions below should help you a long way
  199. XXtowards successful compilation.
  200. XX
  201. XX(( If you don't want to hack the standard headers  supplied  with
  202. XXyour compiler,  you may create an extra  header named  "gh.h"  or
  203. XXsomething, put everything in it, and include that. ))
  204. XX
  205. XX
  206. XXDOS.H
  207. XX=====
  208. XX
  209. XX* There should exist a header named dos.h, which  should  contain
  210. XX  macro definitions,  function declarations and  type definitions
  211. XX  for the operating system functions.
  212. XX
  213. XX* Dos.h is supplied with Turbo C and  Microsoft  C.  AZTEC  users
  214. XX  should copy (or rename) IO.H to DOS.H.
  215. XX
  216. XX* Dos.h  should  define  symbolic  names  for  the  file   system
  217. XX  attribute flags.
  218. XX
  219. XX  For MS-DOS, this should look like:
  220. XX
  221. XX  #ifdef __MSDOS__
  222. XX  #define _A_NORMAL 0x00 /* Normal (r/w) file         */
  223. XX  #define _A_RDONLY 0x01 /* Read only attribute       */
  224. XX  #define _A_HIDDEN 0x02 /* Hidden file               */
  225. XX  #define _A_SYSTEM 0x04 /* System file               */
  226. XX  #define _A_LABEL  0x08 /* Volume label              */
  227. XX  #define _A_DIREC  0x10 /* Directory                 */
  228. XX  #define _A_ARCH   0x20 /* Archive                   */
  229. XX  #endif
  230. XX
  231. XX
  232. XXSTDIO.H
  233. XX=======
  234. XX
  235. XX* Stdio.h  should  define  symbolic  names  for   standard   file
  236. XX  descriptors (see ref. 1, sec. 8.1, p. 160) as follows:
  237. XX
  238. XX  #define STDIN  (0)
  239. XX  #define STDOUT (1)
  240. XX  #define STDERR (2)
  241. XX
  242. XX
  243. XXReferences
  244. XX----------
  245. XX
  246. XX1) Brian W. Kernighan and Dennis M. Ritchie (1st edition):  The C
  247. XX   Programming Language; Prentice-Hall, New Jersey, 1978.
  248. XX
  249. XX2) Richard Relph:  Preparing for ANSI C; Dr. Dobb's Journal, vol.
  250. XX   12, issue 7,  p. 16-23, M&T Publishing,  Redwood City,  August
  251. XX   1987.
  252. XX
  253. XX3) ISO/TC97/SC22/WG14-C, N369;   Programming  Language  C  (Final
  254. XX   Working Draft), ISO, August 1987.
  255. XX
  256. XX                                                         -gisle h
  257. XX
  258. XXComments, suggestions or flames to:
  259. XX   smail: Gisle Hannemyr, Brageveien 3A, N-0452 Oslo, Norway.
  260. XX   EAN:      gisle@nr.uninett
  261. XX   Inet:  gisle@ifi.uio.no
  262. XX   UUCP:  ..!mcvax!ifi!gisle
  263. XX   BBS:      a number of Oslo based BBS's
  264. XX
  265. XX..EOF
  266. SHAR_EOF
  267. if test 2579 -ne "`wc -c header.txt`"
  268. then
  269. echo shar: error transmitting header.txt '(should have been 2579 characters)'
  270. fi
  271. echo shar: extracting ansi.c
  272. sed 's/^XX//' << \SHAR_EOF > ansi.c
  273. XX/* ansi.c  1989 december 10 [gh]
  274. XX+-----------------------------------------------------------------------------
  275. XX| Abstract:
  276. XX|    Ansi terminal interpreter.
  277. XX|
  278. XX| Authorship:
  279. XX|    Copyright (c) 1988, 1989 Gisle Hannemyr.
  280. XX|    Permission is granted to hack, make and distribute copies of this module
  281. XX|    as long as this notice and the copyright notices are not removed.
  282. XX|    If you intend to distribute changed versions of this module, please make
  283. XX|    an entry in the "history" log (below) and mark the hacked lines with your
  284. XX|    initials. I maintain the module, and shall appreiciate copies of bug
  285. XX|    fixes and new versions.
  286. XX|    Flames, bug reports, comments and improvements to:
  287. XX|       snail: Gisle Hannemyr, Brageveien 3A, 0452 Oslo, Norway
  288. XX|       email: X400: gisle@nr.uninett
  289. XX|              RFC:  gisle@ifi.uio.no
  290. XX|              (and several BBS mailboxes in the Oslo area).
  291. XX|
  292. XX| Access programs:
  293. XX|    void doansi() : Interprete one file.
  294. XX|
  295. XX| History:
  296. XX|     4 jun 89 [gh] Latest update.
  297. XX|
  298. XX| Bugs:
  299. XX|    * Currently, highlighting etc. in ANSI sequences is removed. It might be
  300. XX|      fun to translate the lot into Postscript.
  301. XX|    * Not all ANSI sequences are implemented so far.  It should cover
  302. XX|      ANSI.SYS, but some exotic stuff are left out, as well as the NANSI.SYS
  303. XX|      extensions.  All unknown sequences produces an error message.  Users
  304. XX|      who can explain the exact sematics of such sequences are encouraged
  305. XX|      to contact author.
  306. XX|
  307. XX| See main module for more comments.
  308. XX+---------------------------------------------------------------------------*/
  309. XX
  310. XX#include <stdio.h>
  311. XX#include "pep.h"
  312. XX#include <ctype.h>
  313. XX
  314. XX
  315. XX/*---( defines )------------------------------------------------------------*/
  316. XX
  317. XX#define MAXPAR      3                   /* Max no. of ANSI param's to store */
  318. XX#define MAXX        80                  /* ANSI terminal screen width       */
  319. XX#define MAXY        25                  /* ANSI terminal screen height      */
  320. XX
  321. XX/*---( variables )----------------------------------------------------------*/
  322. XX
  323. XXstatic unsigned char Screen[MAXX][MAXY];    /* Output ANSI terminal screen  */
  324. XXstatic int  GuardL;                         /* ANSI overwrite guard level   */
  325. XXstatic int  LineYy = 0;                     /* ANSI terminal cursor pos.    */
  326. XX
  327. XX
  328. XX/*---( housekeeping )-------------------------------------------------------*/
  329. XX
  330. XX/*
  331. XX| Abs: Display ansi warning message.
  332. XX*/
  333. XXstatic void amess(err,cc)
  334. XXint err, cc;
  335. XX{
  336. XX   fprintf(stderr,"\ransi (%ld): ",LCount);
  337. XX   switch(err) {
  338. XX      case  1: fprintf(stderr,"exepected 5bh  (got <%02xh>)",cc); break;
  339. XX      case  2: fprintf(stderr,"unknown ANSI command <%02xh>",cc); break;
  340. XX      case  3: fprintf(stderr,"unknown control code <%02xh>",cc); break;
  341. XX      case  4: fputs("X right of screen edge",     stderr);       break;
  342. XX      case  5: fputs("X left of screen edge",      stderr);       break;
  343. XX      case  6: fputs("Y above screen edge",        stderr);       break;
  344. XX      case  7: fputs("auto line wrap (warning)",   stderr);       break;
  345. XX      case  8: fputs("cursor outside screen",      stderr);       break;
  346. XX      default: fputs("unknown error",              stderr);       break;
  347. XX   } /* switch */
  348. XX   putc('\n',stderr);
  349. XX} /* amess */
  350. XX
  351. XX
  352. XX/*---( ansi emulation )-----------------------------------------------------*/
  353. XX
  354. XX/*
  355. XX| Abs: Erase entire screen and send cursor home.
  356. XX*/
  357. XXstatic void clearscreen()
  358. XX{
  359. XX   int xx, yy;
  360. XX
  361. XX   for (xx = 0; xx < MAXX; xx++) for (yy = 0; yy < MAXY; yy++)
  362. XX      Screen[xx][yy] = ' ';
  363. XX   LineXx = 0;
  364. XX   LineYy = 0;
  365. XX} /* clearscreen */
  366. XX
  367. XX
  368. XXstatic void docrlf()
  369. XX{
  370. XX   if      (EndOLn == -1) { putc('\r',Fdo); putc('\n',Fdo); }
  371. XX   else if (EndOLn != -2)   putc(EndOLn,Fdo);
  372. XX} /* docrlf */
  373. XX
  374. XX
  375. XX/*
  376. XX| Abs: Print a horizontal line,
  377. XX*/
  378. XXstatic void horline()
  379. XX{
  380. XX   int xx;
  381. XX   for (xx = 0; xx < (MAXX-1); xx++) putc('=',Fdo); docrlf();
  382. XX} /* horline */
  383. XX
  384. XX
  385. XX/*
  386. XX| Abs: Print screen image.
  387. XX*/
  388. XXstatic void printscreen(frame)
  389. XXint frame;
  390. XX{
  391. XX   int xx, yy;
  392. XX   static int oldframe = FALSE;
  393. XX
  394. XX   if (oldframe) horline();
  395. XX   for (yy = 0; yy < MAXY; yy++) {
  396. XX      xx = MAXX-1;
  397. XX      while ((xx) && (Screen[xx][yy] == ' ')) { Screen[xx][yy] = '\0'; xx--; }
  398. XX      xx = 0;
  399. XX      while (Screen[xx][yy]) { putc(Screen[xx][yy],Fdo); xx++; }
  400. XX      docrlf();
  401. XX      showprogress();
  402. XX   }
  403. XX   if (oldframe) horline();
  404. XX   oldframe = frame;
  405. XX   clearscreen();
  406. XX} /* printscreen */
  407. XX
  408. XX
  409. XXstatic void pputc(cc)
  410. XXchar cc;
  411. XX{
  412. XX   if (LineXx >= MAXX) {
  413. XX      LineXx = 0; LineYy++;
  414. XX      amess(7); /* auto line wrap (warning) */
  415. XX   } else if ((LineXx < 0) || (LineYy >= MAXY) || (LineYy < 0)) {
  416. XX      amess(8); /* cursor outside screen */
  417. XX      printscreen(FALSE);
  418. XX   }
  419. XX   switch (GuardL) {
  420. XX      case 2: if (Screen[LineXx][LineYy] != ' ') break;
  421. XX      case 1: if (cc == ' ') break;
  422. XX      case 0: Screen[LineXx][LineYy] = cc;
  423. XX   }
  424. XX   LineXx++;
  425. XX} /* pputc */
  426. XX
  427. XX
  428. XX/*
  429. XX| Abs: Interprete ANSI command after ESC CSI.
  430. XX*/
  431. XXstatic void esccsi()
  432. XX{
  433. XX   int ii, jj, cc, dd;
  434. XX   int pp[MAXPAR];
  435. XX   static int oldxx, oldyy;
  436. XX
  437. XX   for (ii = 0; ii < MAXPAR; ii++) pp[ii] = 0; dd = ii = 0;
  438. XX   while ((cc = getc(Fdi)) != EOF) {
  439. XX      if (isdigit(cc)) { pp[ii] = pp[ii] * 10 + cc - '0'; dd++; }
  440. XX      else if (cc == ';') {
  441. XX         if (!dd) pp[ii] = 1; /* default to 1 */
  442. XX         dd = 0;
  443. XX         if (ii < MAXPAR-1) ii++;
  444. XX      }
  445. XX      else break;
  446. XX   }
  447. XX   if (dd) ii++; /* We've one parameter that's not terminated */
  448. XX   for (jj = ii; jj < MAXPAR; jj++) pp[jj] = 1;    /* Default */
  449. XX   /* Exotic stuff we do not attempt to interprete       *
  450. XX   |  case 'h': break; /* + SM  -- set   mode            *
  451. XX   |  case 'l': break; /* + RM  -- reset mode            *
  452. XX   |  case 'p': break; /* + KKR -- keyboard key reassign *
  453. XX   |  case 'R': break; /* + CPR -- cursor position rep.  *
  454. XX   |
  455. XX   |  NANSI stuff for future implementation              *
  456. XX   |  case '@': /*   ICH -- insert characters            *
  457. XX   |  case 'L': /*   IL  -- insert lines                 *
  458. XX   |  case 'M': /*   DL  -- delete lines                 *
  459. XX   |  case 'P': /*   DCH -- delete characters            *
  460. XX   |  case 'y': /*   OCT -- output chr. translate        *
  461. XX   */
  462. XX   switch (cc) {
  463. XX      case 'A': /* + CUU -- cursor up             */
  464. XX         LineYy -= pp[0];
  465. XX         if (LineYy < 0) { amess(6); LineYy = 0; } /* Y above screen edge  */
  466. XX         break;
  467. XX      case 'B': /* + CUD -- cursor down           */
  468. XX         LineYy += pp[0];
  469. XX         if (LineYy >= MAXY) printscreen(FALSE);
  470. XX         break;
  471. XX      case 'C': /* + CUF -- cursor forward        */
  472. XX         LineXx += pp[0];
  473. XX         if (LineXx >= MAXX) { amess(4); LineXx = MAXX - 1; } /* X right of screen */
  474. XX         break;
  475. XX      case 'D': /* + CUB -- cursor backward       */
  476. XX         LineXx -= pp[0];
  477. XX         if (LineXx < 0) { amess(5); LineXx = 0; } /* X left of screen edge */
  478. XX         break;
  479. XX      case 'H': /* + CUP -- cursor position       */
  480. XX         LineXx = pp[1] - 1; LineYy = pp[0] -1;
  481. XX         break;
  482. XX      case 'J': /* + ED  -- erase display         */
  483. XX         if (pp[0] == 2) printscreen(TRUE);
  484. XX         else { amess(2,cc); pputc(cc); } /* unknown ANSI command */
  485. XX         break;
  486. XX      case 'K': /* + EL  -- erase in line         */
  487. XX         if (!GuardL) while (LineXx < MAXX) Screen[LineXx++][LineYy] = ' ';
  488. XX         break;
  489. XX      case 'f': /*   HVP -- cursor position       */
  490. XX         LineXx = pp[1] - 1; LineYy = pp[0] - 1;
  491. XX         break;
  492. XX      case 'n': /* + DSR -- device staus report   */
  493. XX         break;
  494. XX      case 'm': /* + SGR -- set graphic rendition */
  495. XX         break;
  496. XX      case 's': /* + SCP -- save cursor position  */
  497. XX         oldxx = LineXx;
  498. XX         oldyy = LineYy;
  499. XX         break;
  500. XX      case 'u': /* + RCP -- restore cursor pos.   */
  501. XX         LineXx = oldxx;
  502. XX         LineYy = oldyy;
  503. XX         break;
  504. XX      default: amess(2,cc); pputc(cc); /* unknown ANSI command */
  505. XX   } /* switch */
  506. XX   /*
  507. XX   if (hack) {
  508. XX      printf("CSI: ");
  509. XX      for (jj = 0; jj < ii; jj++) printf("%d;",pp[jj]);
  510. XX      printf("%c\n",cc);
  511. XX   }
  512. XX   */
  513. XX} /* esccsi */
  514. XX
  515. XX
  516. XX/*---( file loop )----------------------------------------------------------*/
  517. XX
  518. XX/*
  519. XX| Abs: Read (and write) one complete ANSI-file.
  520. XX| Par: guardl = ANSI overwrite guard level.
  521. XX*/
  522. XXvoid doansi(guardl)
  523. XXint guardl;
  524. XX{
  525. XX   int cc;
  526. XX
  527. XX   GuardL = guardl;
  528. XX   clearscreen();
  529. XX   while ((cc = getc(Fdi)) != EOF) {
  530. XX      if ((cc >= 0x20) && (cc <= 0xff)) pputc(cc);
  531. XX      else if (cc == 0x07) ; /* BELL    */
  532. XX      else if (cc == '\b') { /* BS      */
  533. XX         LineXx--;
  534. XX         if (LineXx < 0) { amess(5); LineXx = 0; } /* X left of screen edge */
  535. XX      }
  536. XX      else if (cc == '\t') LineXx = (LineXx / ITabSz + 1) * ITabSz;
  537. XX      else if (cc == '\n') { LineYy++; if (LineYy >= MAXY) printscreen(FALSE); }
  538. XX      else if (cc == '\r') LineXx = 0;
  539. XX      else if (cc == 0x1b) { /* ESC     */
  540. XX         cc = getc(Fdi);
  541. XX         if (cc == 0x5b) esccsi(); else amess(1,cc); /* exepected 5bh */
  542. XX      }
  543. XX      else amess(3,cc); /* unknown control code */
  544. XX   } /* while */
  545. XX   printscreen(FALSE);
  546. XX} /* doansi */
  547. XX
  548. XX/* EOF */
  549. SHAR_EOF
  550. if test 8911 -ne "`wc -c ansi.c`"
  551. then
  552. echo shar: error transmitting ansi.c '(should have been 8911 characters)'
  553. fi
  554. #    End of shell archive
  555. exit 0
  556.  
  557.