• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

src/ctermcap.c

00001 
00002 //Copyright (C) 1985,   86,     93,     94,     95,     2000, 2001
00003 //Free Software Foundation, Inc.
00004 //
00005 //This program is       free software; you can redistribute     it and/or modify
00006 //it under the terms of the GNU General Public License as       published by
00007 //the   Free Software Foundation; either version 2,     or (at your     option)
00008 //any   later version.
00009 //
00010 //This program is       distributed     in the hope     that it will be useful,
00011 //but   WITHOUT ANY     WARRANTY; without even the implied warranty     of
00012 //MERCHANTABILITY       or FITNESS FOR A PARTICULAR     PURPOSE.  See the
00013 //GNU   General Public License for more details.
00014 //
00015 //You   should have     received a copy of the GNU General Public License
00016 //along with this       program; see the file COPYING.  If not, write to
00017 //the   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018 //Boston,       MA 02111-1307, USA.      */
00019 //
00021 //
00022 //#include <stdlib.h>
00023 //
00024 //#ifdef _WIN32
00025 //#include <spl/configwin32.h>
00026 //#else
00027 //#include <spl/autoconf/config.h>
00028 //#endif
00029 //
00030 //#include <ctype.h>
00031 //#ifdef HAVE_STRING_H
00032 //#include <string.h>
00033 //#endif
00034 //#ifdef HAVE_IO_H
00035 //#include <io.h>
00036 //#endif
00037 //#ifdef HAVE_FCNTL_H
00038 //#include <fcntl.h>
00039 //#endif
00040 //#ifdef HAVE_SYS_FCNTL_H
00041 //#include <sys/fcntl.h>
00042 //#endif
00043 //
00044 //#include <spl/term/ctermcap.h>
00045 //#include <spl/term/acs.h>
00046 //#include <spl/cstring.h>
00047 //
00048 //#ifndef HAVE_BCOPY
00051 //#define       bcopy(s, d,     n) memcpy ((d), (s), (n))
00053 //#endif
00054 //
00055 //#ifdef HAVE_UNISTD_H
00056 //#include <unistd.h>
00057 //#endif
00058 //#ifdef _POSIX_VERSION
00059 //#include <fcntl.h>
00060 //#endif
00061 //
00062 //#ifndef       NULL
00063 //#define       NULL (char *) 0
00064 //#endif
00065 //
00066 //#ifndef       O_RDONLY
00067 //#define       O_RDONLY 0
00068 //#endif
00069 //
00071 //gives meaning of character following \,       or a space if no special meaning.
00072 //Eight characters per line within the string.  */
00073 //
00074 //static char   esctab[]
00075 //= "   \007\010  \033\014 \
00076 //  \012 \
00077 //  \015 \011   \013 \
00078 //  ";
00079 //
00081 //
00082 //static char   *tgetst1 ();
00083 //
00085 //Return a pointer to   the     capability (in BP) if found,
00086 //0 if not found.        */
00087 //
00088 //static char   * find_capability (register char *bp, const char *cap)
00089 //{
00090 //      for     (; *bp; bp++)
00091 //              if (bp[0] == ':'
00092 //                      && bp[1] ==     cap[0]
00093 //                      && bp[2] ==     cap[1])
00094 //                              return &bp[4];
00095 //                      return NULL;
00096 //}
00097 //
00098 //int tgetnum   (termcap *capsbuf, const char *cap)
00099 //{
00105 //*/
00106 //      string *str;
00107 //      termcapValidateMem( capsbuf );
00108 //      if ( NULL != (str = (string *)hashtableGetChar(capsbuf->m_caps, cap, (int)strlen(cap))) )
00109 //      {
00110 //              return atoi     (str->cstr);
00111 //      }
00112 //      return -1;
00113 //}
00114 //
00115 //bool tgetflag (termcap *capsbuf, const char *cap)
00116 //{
00117 //      /*register char *ptr = find_capability (capsbuf->m_capstr, cap);*/
00118 //      /*return ptr && ptr[-1] == ':';*/
00119 //      termcapValidateMem( capsbuf );
00120 //      if ( NULL == (string *)hashtableGetChar(capsbuf->m_caps, cap, (int)strlen(cap)) )
00121 //      {
00122 //              return false;
00123 //      }
00124 //      return true;
00125 //}
00126 //
00127 //bool tgets( string *capstr, char *buf, const int buflen )
00128 //{
00129 //      int bufpos = 0;
00130 //      int cappos = 0;
00131 //      while ( cappos < capstr->len && bufpos < buflen )
00132 //      {
00133 //              char ch = capstr->cstr[cappos++];
00134 //              if ( '^' == ch )
00135 //              {
00136 //                      // control
00137 //                      ch = capstr->cstr[cappos++];
00138 //                      if ( isalpha(ch) )
00139 //                      {
00140 //                              if ( islower(ch) )
00141 //                              {
00142 //                                      buf[bufpos++] = (ch - 'a') + 1;
00143 //                              }
00144 //                              else
00145 //                              {
00146 //                                      buf[bufpos++] = (ch - 'A') + 1;
00147 //                              }
00148 //                      }
00149 //                      else if ( isdigit(ch) )
00150 //                      {
00151 //                              if ( '2' == ch )
00152 //                              {
00153 //                                      buf[bufpos++] = 0;
00154 //                              }
00155 //                              else if ( 6 == ch )
00156 //                              {
00157 //                                      buf[bufpos++] = 30;
00158 //                              }
00159 //                              else
00160 //                              {
00161 //                                      return false;
00162 //                              }
00163 //                      }
00164 //                      else if ( '[' == ch )
00165 //                      {
00166 //                              buf[bufpos++] = 27;
00167 //                      }
00168 //                      else if ( ']' == ch )
00169 //                      {
00170 //                              buf[bufpos++] = 29;
00171 //                      }
00172 //                      else
00173 //                      {
00174 //                              return false;
00175 //                      }
00176 //              }
00177 //              else if ( '\\' == buf[0] )
00178 //              {
00179 //                      // escape
00180 //                      ch = capstr->cstr[cappos++];
00181 //                      switch ( ch )
00182 //                      {
00183 //                      case 'E':
00184 //                              buf[bufpos++] = 27;
00185 //                              break;
00186 //                      case 't':
00187 //                              buf[bufpos++] = '\t';
00188 //                              break;
00189 //                      case '\\':
00190 //                              buf[bufpos++] = '\\';
00191 //                              break;
00192 //                      case '^':
00193 //                              buf[bufpos++] = '^';
00194 //                              break;
00195 //                      default:
00196 //                              return false;
00197 //                      }
00198 //              }
00199 //              else
00200 //              {
00201 //                      buf[bufpos++] = ch;
00202 //              }
00203 //      }
00204 //      ASSERT( bufpos < buflen );
00205 //      buf[bufpos] = '\0';
00206 //      return true;
00207 //}
00208 //
00210 //If AREA       is non-null, it points to a     pointer to a block in which
00211 //to store the string.  That pointer is advanced over   the     space used.
00212 //If AREA       is null, space is allocated     with `malloc'.  */
00213 //
00214 //bool tgetstr (termcap *capsbuf, const char *cap, char *buf, const int buflen)
00215 //{
00216 //      /*register char *ptr = find_capability (capsbuf->m_capstr, cap);
00217 //      //if (!ptr ||   (ptr[-1] !=     '='     && ptr[-1] != '~'))
00218 //      //{
00219 //      //      return NULL;
00220 //      //}
00221 //      //return tgetst1 (ptr, area);*/
00222 //
00223 //      string *str;
00224 //      termcapValidateMem( capsbuf );
00225 //      if ( NULL == (str = (string *)hashtableGetChar(capsbuf->m_caps, cap, (int)strlen(cap))) )
00226 //      {
00227 //              return false;
00228 //      }
00229 //      return tgets(str, buf, buflen);
00230 //}
00231 //
00233 //
00234 //short ospeed;
00236 //int   tputs_baud_rate;
00237 //char PC;
00238 //
00240 //- baud rate   / 100 if negative.      */
00241 //
00242 //static int speeds[]   =
00243 //{
00244 //      0, 50, 75, 110, 135, 150, -2, -3, -6, -12,
00245 //              -18, -24, -48, -96,     -192, -288,     -384, -576,     -1152
00246 //};
00247 //
00248 //void tputs (register const char       *str, int nlines, register int (*outfun) (int))
00249 //{
00250 //      register int padcount = 0;
00251 //      register int speed;
00252 //
00253 //      if (ospeed == 0)
00254 //              speed = tputs_baud_rate;
00255 //      else
00256 //              speed = speeds[ospeed];
00257 //
00258 //      if (!str)
00259 //              return;
00260 //
00261 //      while (*str     >= '0' && *str <= '9')
00262 //      {
00263 //              padcount +=     *(str++) - '0';
00264 //              padcount *=     10;
00265 //      }
00266 //      if (*str ==     '.')
00267 //      {
00268 //              str++;
00269 //              padcount +=     *(str++) - '0';
00270 //      }
00271 //      if (*str ==     '*')
00272 //      {
00273 //              str++;
00274 //              padcount *=     nlines;
00275 //      }
00276 //      while (*str)
00277 //              (*outfun) (*(str++));
00278 //
00279 //      /* PADCOUNT     is now in units of tenths of msec.
00280 //      SPEED is measured in characters per     10 seconds
00281 //      or in characters per .1 seconds (if     negative).
00282 //      We use the smaller units for larger     speeds to avoid overflow.  */
00283 //      padcount *=     speed;
00284 //      padcount +=     500;
00285 //      padcount /=     1000;
00286 //      if (speed <     0)
00287 //              padcount = -padcount;
00288 //      else
00289 //      {
00290 //              padcount +=     50;
00291 //              padcount /=     100;
00292 //      }
00293 //
00294 //      while (padcount-- >     0)
00295 //              (*outfun) (PC);
00296 //}
00297 //
00298 //static const int base10 = 10;
00299 //static const char cHexa[] = {'A','B','C','D','E','F'};
00300 //static const int iHexaNumeric[] = {10,11,12,13,14,15};
00301 //static const int iHexaIndices[] = {0,1,2,3,4,5};
00302 //static const int asciiDiff = 48;
00303 //
00304 //static int baseToInt(char *sbase, const int numbase)
00305 //{
00306 //      int i;
00307 //    int dec = 0;
00308 //    int b;
00309 //    int iProduct = 1;
00310 //      int sbaselen = (int)strlen(sbase);
00311 //
00312 //    for ( i = sbaselen - 1; i >= 0; i--, iProduct *= numbase )
00313 //    {
00314 //        char ch = sbase[i];
00315 //          if ( numbase > base10 && isalpha(ch) )
00316 //              {
00317 //                      if ( ch >= 'A' )
00318 //                      {
00319 //                              ASSERT( 'A' > 'a' );
00320 //                              b = iHexaNumeric[ch-'A'];
00321 //                      }
00322 //                      else
00323 //                      {
00324 //                              ASSERT( 'A' > 'a' );
00325 //                              b = iHexaNumeric[ch-'a'];
00326 //                      }
00327 //              }
00328 //        else 
00329 //              {
00330 //            b = (int) sbase[i] - asciiDiff;
00331 //              }
00332 //        dec += (b * iProduct);
00333 //    } 
00334 //    return dec; 
00335 //}
00336 //
00337 //#define CAPBUFSIZE 256
00338 //#define CAPKEYBUFSIZE 8
00339 //static char keybuf[CAPKEYBUFSIZE];
00340 //static char capbuf[CAPBUFSIZE];
00341 //
00342 //bool parseEntry( termcap *capsbuf, string *tcfile, int *pos );
00343 //
00344 //bool parseTerm( termcap *capsbuf, string *tcfile, const char *termname)
00345 //{
00346 //      char ch;
00347 //      bool isesc = false;
00348 //      bool linecont = false;
00349 //      int pos = 0;
00350 //      char term_name[128];
00351 //      int term_name_len;
00352 //      int term_desc_pos = 0;
00353 //      char *tcenv     = NULL;         /* TERMCAP value, if it contains :tc=.  */
00354 //      char *indirect = NULL;  /* Terminal     type in :tc= in TERMCAP value.  */
00355 //
00356 //      termcapValidateMem( capsbuf );
00357 //
00358 //      strcpylen( term_name, termname, 128 );
00359 //      term_name_len = (int)strlen(term_name);
00360 //      while ( term_name_len > 0 )
00361 //      {
00362 //              /*DEBUG_CLEAR_MEM_CHECK_POINTS();
00363 //              termcapCheckMem( capsbuf);
00364 //              DEBUG_NOTE_MEM_ALLOCATION(tcfile);
00365 //              stringCheckMem( tcfile );
00366 //              DEBUG_DUMP_MEM_LEAKS();
00367 //              */
00368 //              if ( 0 > (pos = stringIndexOfFrom(tcfile, pos, term_name)) )
00369 //              {
00370 //                      return false;
00371 //              }
00372 //              ASSERT(0xcd == capsbuf->m_eos);
00373 //              ASSERT( stringCharAt( tcfile, pos ) == term_name[0] );
00374 //              /*printf("%.20s\n", &tcfile->cstr[pos]);*/
00375 //              if ( stringCharAt( tcfile, pos+term_name_len ) != '|' )
00376 //              {
00377 //                      pos++;
00378 //                      continue;
00379 //              }
00380 //              if ( stringCharAt( tcfile, pos-1 ) == '#' )
00381 //              {
00382 //                      pos++;
00383 //                      continue;
00384 //              }
00385 //              if ( 0 == term_desc_pos )
00386 //              {
00387 //                      while ( '\n' != (ch = stringCharAt(tcfile, pos++)) )
00388 //                      {
00389 //                      }
00390 //              }
00391 //              /*
00392 //               *  We've located the terminal entry, load the colin delimited entries.
00393 //               *  The terminal entry is a single line, using line contiueation chars '\'
00394 //               */
00395 //              while ( pos < tcfile->len )
00396 //              {
00397 //                      /*DEBUG_CLEAR_MEM_CHECK_POINTS();
00398 //                      termcapCheckMem( capsbuf);
00399 //                      DEBUG_NOTE_MEM_ALLOCATION(tcfile);
00400 //                      stringCheckMem( tcfile );
00401 //                      DEBUG_DUMP_MEM_LEAKS();
00402 //                      */
00403 //                      if ( ! parseEntry( capsbuf, tcfile, &pos ) )
00404 //                      {
00405 //                              return false;
00406 //                      }
00407 //                      /*
00408 //                      DEBUG_CLEAR_MEM_CHECK_POINTS();
00409 //                      termcapCheckMem( capsbuf);
00410 //                      DEBUG_NOTE_MEM_ALLOCATION(tcfile);
00411 //                      stringCheckMem( tcfile );
00412 //                      DEBUG_DUMP_MEM_LEAKS();
00413 //                      */
00414 //                      linecont = false;
00415 //                      ch = stringCharAt(tcfile, pos);
00416 //                      if ( !isalnum(ch) )
00417 //                      {
00418 //                              while ( pos < tcfile->len && '\n' != ch && ':' != ch )
00419 //                              {
00420 //                                      if ( '\\' == ch )
00421 //                                      {
00422 //                                              linecont = true;
00423 //                                      }
00424 //                                      ch = stringCharAt(tcfile, pos++);
00425 //                              }
00426 //                              if ( !linecont && ':' != ch )
00427 //                              {
00428 //                                      pos = tcfile->len;
00429 //                              }
00430 //                      }
00431 //                      else if ( ':' != ch )
00432 //                      {
00433 //                              ch = stringCharAt(tcfile, --pos);
00434 //                              ASSERT( ':' == ch );
00435 //                      }
00436 //                      /*DEBUG_CLEAR_MEM_CHECK_POINTS();
00437 //                      termcapCheckMem( capsbuf);
00438 //                      DEBUG_NOTE_MEM_ALLOCATION(tcfile);
00439 //                      stringCheckMem( tcfile );
00440 //                      DEBUG_DUMP_MEM_LEAKS();
00441 //                      */
00442 //              }
00443 //              ASSERT(0xcd == capsbuf->m_eos);
00444 //              if ( pos == tcfile->len )
00445 //              {
00446 //                      break;
00447 //              }
00448 //      }
00449 //      termcapValidateMem( capsbuf );
00450 //      return true;
00451 //}
00452 //
00453 //bool parseEntry( termcap *capsbuf, string *tcfile, int *pos )
00454 //{
00455 //      bool isesc = false;
00456 //      int capbufpos = 0;
00457 //      int keybufpos = 0;
00458 //      char ch = stringCharAt(tcfile, (*pos)++);
00459 //
00460 //      termcapValidateMem( capsbuf );
00461 //
00462 //      /* advance to ':', or eof */
00463 //      while ( ':' != ch && *pos < tcfile->len )
00464 //      {
00465 //              ch = stringCharAt(tcfile, (*pos)++);
00466 //      }
00467 //      if ( *pos >= tcfile->len )
00468 //      {
00469 //              return false;
00470 //      }
00471 //      ASSERT( ':' == ch );
00472 //
00473 //      /* load the entry's key */
00474 //      ch = stringCharAt(tcfile, (*pos)++);
00475 //      while ( ':' != ch && '#' != ch && '=' != ch && *pos < tcfile->len )
00476 //      {
00477 //              keybuf[keybufpos++] = ch;
00478 //              ASSERT(keybufpos < CAPKEYBUFSIZE);
00479 //              ch = stringCharAt(tcfile, (*pos)++);
00480 //      }
00481 //      keybuf[keybufpos] = '\0';
00482 //      if ( ':' == ch )
00483 //      {
00484 //              /* flag */
00485 //              string *fl = stringConstructChar(&keybuf[0]);
00486 //              ASSERT_MEM( fl, sizeof(string) );
00487 //              vectorAdd(capsbuf->m_vcaps, &fl);
00488 //              ASSERT_MEM( (string *)vectorPeek(capsbuf->m_vcaps), sizeof(string) );
00489 //              return hashtableAddChar(capsbuf->m_caps, &keybuf[0], keybufpos, fl);
00490 //      }
00491 //
00492 //      /* load the value */
00493 //      while ( ':' != (ch = stringCharAt(tcfile, (*pos)++)) )
00494 //      {
00495 //              if ( isesc )
00496 //              {
00497 //                      switch ( ch )
00498 //                      {
00499 //                      case 'E':
00500 //                              capbuf[capbufpos++] = 27;
00501 //                              break;
00502 //                      case '\\':
00503 //                              capbuf[capbufpos++] = '\\';
00504 //                              break;
00505 //                      default:
00506 //                              if ( isdigit(ch) )
00507 //                              {
00508 //                                      /* three digit octal */
00509 //                                      char buf[4];
00510 //                                      buf[0] = ch;
00511 //                                      buf[1] = '\0';
00512 //                                      ch = stringCharAt(tcfile, *pos);
00513 //                                      if ( isdigit(ch) )
00514 //                                      {
00515 //                                              buf[1] = ch;
00516 //                                              buf[2] = '\0';
00517 //                                              (*pos)++;
00518 //                                              ch = stringCharAt(tcfile, *pos);
00519 //                                              if ( isdigit( ch ) )
00520 //                                              {
00521 //                                                      buf[2] = ch;
00522 //                                                      buf[3] = '\0';
00523 //                                                      (*pos)++;
00524 //                                              }
00525 //                                      }
00526 //                                      capbuf[capbufpos++] = baseToInt(buf, 8);
00527 //                              }
00528 //                              else
00529 //                              {
00530 //                                      capbuf[capbufpos++] = '\\';
00531 //                                      capbuf[capbufpos++] = ch;
00532 //                              }
00533 //                      }
00534 //                      isesc = false;
00535 //              }
00536 //              else
00537 //              {
00538 //                      if ( '\\' == ch )
00539 //                      {
00540 //                              isesc = true;
00541 //                      }
00542 //                      else if ( '\r' == ch || '\n' == ch || '\t' == ch )
00543 //                      {
00544 //                              isesc = false;
00545 //                      }
00546 //                      else
00547 //                      {
00548 //                              capbuf[capbufpos++] = ch;
00549 //                      }
00550 //              }
00551 //              ASSERT( CAPBUFSIZE > capbufpos );
00552 //      }
00553 //      capbuf[capbufpos] = '\0';
00554 //      if ( strcmp(keybuf, "tc") == 0 )
00555 //      {
00556 //              parseTerm(capsbuf, tcfile, &capbuf[0]);
00557 //      }
00558 //      else
00559 //      {
00560 //              string *val;
00561 //              if ( hashtableGetChar( capsbuf->m_caps, &keybuf[0], keybufpos ) != NULL )
00562 //              {
00563 //                      stringDestruct( (string *)hashtableGetChar( capsbuf->m_caps, &keybuf[0], keybufpos ) );
00564 //              }
00565 //              val = stringConstructChar(&capbuf[0]);
00566 //              ASSERT_MEM( val, sizeof(string) );
00567 //              vectorAdd(capsbuf->m_vcaps, &val);
00568 //              ASSERT_MEM( vectorPeek(capsbuf->m_vcaps), sizeof(string) );
00569 //              hashtableAddChar(capsbuf->m_caps, &keybuf[0], keybufpos, val);
00570 //      }
00571 //      capbufpos = 0;
00572 //      termcapValidateMem( capsbuf );
00573 //      return true;
00574 //}
00575 //
00577 //and   store it in     the     block that BP points to.
00578 //Record its address for future use.
00579 //
00580 //If BP is null, space is       dynamically     allocated.
00581 //
00582 //Return -1 if there is some difficulty accessing       the     data base
00583 //of terminal   types,
00584 //0 if the data base is accessible but the type NAME is not defined
00585 //in it, and some       other value     otherwise.      */
00586 //
00587 //int termcapConstruct (termcap *capsbuf, const char *name)
00588 //{
00589 //      string *tcfile;
00590 //
00591 //      capsbuf->m_eos = 0xcd;
00592 //
00593 //      if ( NULL == (capsbuf->m_caps = hashtableConstruct()) )
00594 //      {
00595 //              return -1;
00596 //      }
00597 //      if ( NULL == (capsbuf->m_vcaps = vectorConstruct(sizeof(string *))) )
00598 //      {
00599 //              hashtableDestruct(capsbuf->m_caps);
00600 //              return -1;
00601 //      }
00602 //      if ( NULL == (tcfile = fileLoadText(TERMCAP_FILE)) )
00603 //      {
00604 //              if ( NULL == (tcfile = stringConstructChar( termcap_src_new )) )
00605 //              {
00606 //                      vectorDestruct( capsbuf->m_vcaps );
00607 //                      hashtableDestruct( capsbuf->m_caps );
00608 //                      return false;
00609 //              }
00610 //      }
00611 //      ASSERT(0xcd == capsbuf->m_eos);
00612 //      /*
00613 //      DEBUG_CLEAR_MEM_CHECK_POINTS();
00614 //      termcapCheckMem( capsbuf);
00615 //      DEBUG_NOTE_MEM_ALLOCATION(tcfile);
00616 //      stringCheckMem( tcfile );
00617 //      DEBUG_DUMP_MEM_LEAKS();
00618 //      */
00619 //      if ( ! parseTerm(capsbuf, tcfile, name) )
00620 //      {
00621 //              stringDestruct( tcfile );
00622 //              termcapDestruct( capsbuf );
00623 //              return false;
00624 //      }
00625 //      stringDestruct( tcfile );
00626 //
00627 //      ASSERT(0xcd == capsbuf->m_eos);
00628 //
00629 //      if ( indexof(name, "ansi.sys") > -1 || indexof(name, "pcansi") > -1 )
00630 //      {
00631 //              capsbuf->m_acsmap[ULCORNER] = DOS_ULCORNER;
00632 //              capsbuf->m_acsmap[LLCORNER] = DOS_LLCORNER;
00633 //              capsbuf->m_acsmap[URCORNER] = DOS_URCORNER;
00634 //              capsbuf->m_acsmap[LRCORNER] = DOS_LRCORNER;
00635 //              capsbuf->m_acsmap[LTEE] = DOS_LTEE;
00636 //              capsbuf->m_acsmap[RTEE] = DOS_RTEE;
00637 //              capsbuf->m_acsmap[BTEE] = DOS_BTEE;
00638 //              capsbuf->m_acsmap[TTEE] = DOS_TTEE;
00639 //              capsbuf->m_acsmap[HLINE] = DOS_HLINE;
00640 //              capsbuf->m_acsmap[VLINE] = DOS_VLINE;
00641 //              capsbuf->m_acsmap[PLUS] = DOS_PLUS;
00642 //              capsbuf->m_acsmap[S1] = DOS_S1;
00643 //              capsbuf->m_acsmap[S9] = DOS_S9;
00644 //              capsbuf->m_acsmap[DIAMOND] = DOS_DIAMOND; 
00645 //              capsbuf->m_acsmap[CKBOARD] = DOS_CKBOARD;
00646 //              capsbuf->m_acsmap[DEGREE] = DOS_DEGREE;
00647 //              capsbuf->m_acsmap[PLMINUS] = DOS_PLMINUS;
00648 //              capsbuf->m_acsmap[BULLET] = DOS_BULLET;
00649 //              capsbuf->m_acsmap[LARROW] = DOS_LARROW;
00650 //              capsbuf->m_acsmap[RARROW] = DOS_RARROW;
00651 //              capsbuf->m_acsmap[DARROW] = DOS_DARROW;
00652 //              capsbuf->m_acsmap[UARROW] = DOS_UARROW;
00653 //              capsbuf->m_acsmap[BOARD] = DOS_BOARD;
00654 //              capsbuf->m_acsmap[LANTERN] = DOS_LANTERN;
00655 //              capsbuf->m_acsmap[BLOCK] = DOS_BLOCK;
00656 //              capsbuf->m_acsmap[S3] = DOS_S3;
00657 //              capsbuf->m_acsmap[S7] = DOS_S7;
00658 //              capsbuf->m_acsmap[LEQUAL] = DOS_LEQUAL;
00659 //              capsbuf->m_acsmap[GEQUAL] = DOS_GEQUAL;
00660 //              capsbuf->m_acsmap[PI] = DOS_PI;
00661 //              capsbuf->m_acsmap[NEQUAL] = DOS_NEQUAL;
00662 //              capsbuf->m_acsmap[STERLING] = DOS_STERLING;
00663 //              capsbuf->m_isdos = true;
00664 //              capsbuf->m_hasacs = false;
00665 //              capsbuf->m_hasS0S1 = false;
00666 //      }
00667 //      else if (indexof(name, "cygwin") > -1)
00668 //      {
00669 //              capsbuf->m_acsmap[ULCORNER] = '*';
00670 //              capsbuf->m_acsmap[LLCORNER] = '*';
00671 //              capsbuf->m_acsmap[URCORNER] = '*';
00672 //              capsbuf->m_acsmap[LRCORNER] = '*';
00673 //              capsbuf->m_acsmap[LTEE] = '+';
00674 //              capsbuf->m_acsmap[RTEE] = '+';
00675 //              capsbuf->m_acsmap[BTEE] = '+';
00676 //              capsbuf->m_acsmap[TTEE] = '+';
00677 //              capsbuf->m_acsmap[HLINE] = '-';
00678 //              capsbuf->m_acsmap[VLINE] = '|';
00679 //              capsbuf->m_acsmap[PLUS] = '+';
00680 //              capsbuf->m_acsmap[S1] = '-';
00681 //              capsbuf->m_acsmap[S9] = '_';
00682 //              capsbuf->m_acsmap[DIAMOND] = (char)14; 
00683 //              capsbuf->m_acsmap[CKBOARD] = (char)23;
00684 //              capsbuf->m_acsmap[DEGREE] = '.';
00685 //              capsbuf->m_acsmap[PLMINUS] = ' ';
00686 //              capsbuf->m_acsmap[BULLET] = '>';
00687 //              capsbuf->m_acsmap[LARROW] = (char)17;
00688 //              capsbuf->m_acsmap[RARROW] = (char)16;
00689 //              capsbuf->m_acsmap[DARROW] = (char)31;
00690 //              capsbuf->m_acsmap[UARROW] = (char)30;
00691 //              capsbuf->m_acsmap[BOARD] = DOS_BOARD;
00692 //              capsbuf->m_acsmap[LANTERN] = DOS_LANTERN;
00693 //              capsbuf->m_acsmap[BLOCK] = (char)25;
00694 //              capsbuf->m_acsmap[S3] = (char)22;
00695 //              capsbuf->m_acsmap[S7] = (char)13;
00696 //              capsbuf->m_acsmap[LEQUAL] = (char)28;
00697 //              capsbuf->m_acsmap[GEQUAL] = (char)29;
00698 //              capsbuf->m_acsmap[PI] = (char)30;
00699 //              capsbuf->m_acsmap[NEQUAL] = DOS_NEQUAL;
00700 //              capsbuf->m_acsmap[STERLING] = (char)32;
00701 //              capsbuf->m_isdos = false;
00702 //              capsbuf->m_hasacs = true;
00703 //              capsbuf->m_hasS0S1 = false;
00704 //      }
00705 //      else if (indexof(name, "linux") > -1 || indexof(name, "xterm") > -1)
00706 //      {
00707 //              capsbuf->m_acsmap[ULCORNER] = (char)108;
00708 //              capsbuf->m_acsmap[LLCORNER] = (char)109;
00709 //              capsbuf->m_acsmap[URCORNER] = (char)107;
00710 //              capsbuf->m_acsmap[LRCORNER] = (char)106;
00711 //              capsbuf->m_acsmap[LTEE] = (char)116;
00712 //              capsbuf->m_acsmap[RTEE] = (char)117;
00713 //              capsbuf->m_acsmap[BTEE] = (char)118;
00714 //              capsbuf->m_acsmap[TTEE] = (char)119;
00715 //              capsbuf->m_acsmap[HLINE] = (char)113;/*'-';*/
00716 //              capsbuf->m_acsmap[VLINE] = (char)120;/*'|';*/
00717 //              capsbuf->m_acsmap[PLUS] = (char)110;/*'+';*/
00718 //              capsbuf->m_acsmap[S1] = (char)113;
00719 //              capsbuf->m_acsmap[S9] = (char)115;
00720 //              capsbuf->m_acsmap[DIAMOND] = (char)96; 
00721 //              capsbuf->m_acsmap[CKBOARD] = (char)97;
00722 //              capsbuf->m_acsmap[DEGREE] = '.';
00723 //              capsbuf->m_acsmap[PLMINUS] = ' ';
00724 //              capsbuf->m_acsmap[BULLET] = '>';
00725 //              capsbuf->m_acsmap[LARROW] = '<'; /*(char)60;*/
00726 //              capsbuf->m_acsmap[RARROW] = (char)62;
00727 //              capsbuf->m_acsmap[DARROW] = (char)19;
00728 //              capsbuf->m_acsmap[UARROW] = (char)94;
00729 //              capsbuf->m_acsmap[BOARD] = DOS_BOARD;
00730 //              capsbuf->m_acsmap[LANTERN] = DOS_LANTERN;
00731 //              capsbuf->m_acsmap[BLOCK] = (char)25;
00732 //              capsbuf->m_acsmap[S3] = (char)22;
00733 //              capsbuf->m_acsmap[S7] = (char)13;
00734 //              capsbuf->m_acsmap[LEQUAL] = (char)28;
00735 //              capsbuf->m_acsmap[GEQUAL] = (char)29;
00736 //              capsbuf->m_acsmap[PI] = (char)30;
00737 //              capsbuf->m_acsmap[NEQUAL] = DOS_NEQUAL;
00738 //              capsbuf->m_acsmap[STERLING] = (char)32;
00739 //              capsbuf->m_isdos = false;
00740 //              capsbuf->m_hasacs = false;
00741 //              capsbuf->m_hasS0S1 = true;
00742 //              ASSERT( capsbuf->m_hasS0S1 );
00743 //      }
00744 //      else if (indexof(name, "vt100") > -1)
00745 //      {
00746 //              capsbuf->m_acsmap[ULCORNER] = ACS_ULCORNER;
00747 //              capsbuf->m_acsmap[LLCORNER] = ACS_LLCORNER;
00748 //              capsbuf->m_acsmap[URCORNER] = ACS_URCORNER;
00749 //              capsbuf->m_acsmap[LRCORNER] = ACS_LRCORNER;
00750 //              capsbuf->m_acsmap[LTEE] = ACS_LTEE;
00751 //              capsbuf->m_acsmap[RTEE] = ACS_RTEE;
00752 //              capsbuf->m_acsmap[BTEE] = ACS_BTEE;
00753 //              capsbuf->m_acsmap[TTEE] = ACS_TTEE;
00754 //              capsbuf->m_acsmap[HLINE] = ACS_HLINE;
00755 //              capsbuf->m_acsmap[VLINE] = ACS_VLINE;
00756 //              capsbuf->m_acsmap[PLUS] = ACS_PLUS;
00757 //              capsbuf->m_acsmap[S1] = ACS_S1;
00758 //              capsbuf->m_acsmap[S9] = ACS_S9;
00759 //              capsbuf->m_acsmap[DIAMOND] = ACS_DIAMOND; 
00760 //              capsbuf->m_acsmap[CKBOARD] = ACS_CKBOARD;
00761 //              capsbuf->m_acsmap[DEGREE] = ACS_DEGREE;
00762 //              capsbuf->m_acsmap[PLMINUS] = ACS_PLMINUS;
00763 //              capsbuf->m_acsmap[BULLET] = ACS_BULLET;
00764 //              capsbuf->m_acsmap[LARROW] = ACS_LARROW;
00765 //              capsbuf->m_acsmap[RARROW] = ACS_RARROW;
00766 //              capsbuf->m_acsmap[DARROW] = ACS_DARROW;
00767 //              capsbuf->m_acsmap[UARROW] = ACS_UARROW;
00768 //              capsbuf->m_acsmap[BOARD] = ACS_BOARD;
00769 //              capsbuf->m_acsmap[LANTERN] = ACS_LANTERN;
00770 //              capsbuf->m_acsmap[BLOCK] = ACS_BLOCK;
00771 //              capsbuf->m_acsmap[S3] = ACS_S3;
00772 //              capsbuf->m_acsmap[S7] = ACS_S7;
00773 //              capsbuf->m_acsmap[LEQUAL] = ACS_LEQUAL;
00774 //              capsbuf->m_acsmap[GEQUAL] = ACS_GEQUAL;
00775 //              capsbuf->m_acsmap[PI] = ACS_PI;
00776 //              capsbuf->m_acsmap[NEQUAL] = ACS_NEQUAL;
00777 //              capsbuf->m_acsmap[STERLING] = ACS_STERLING;
00778 //              capsbuf->m_isdos = false;
00779 //              capsbuf->m_hasacs = true;
00780 //              capsbuf->m_hasS0S1 = false;
00781 //      }
00782 //      else
00783 //      {
00784 //              capsbuf->m_acsmap[ULCORNER] = ANSI_ULCORNER;
00785 //              capsbuf->m_acsmap[LLCORNER] = ANSI_LLCORNER;
00786 //              capsbuf->m_acsmap[URCORNER] = ANSI_URCORNER;
00787 //              capsbuf->m_acsmap[LRCORNER] = ANSI_LRCORNER;
00788 //              capsbuf->m_acsmap[LTEE] = ANSI_LTEE;
00789 //              capsbuf->m_acsmap[RTEE] = ANSI_RTEE;
00790 //              capsbuf->m_acsmap[BTEE] = ANSI_BTEE;
00791 //              capsbuf->m_acsmap[TTEE] = ANSI_TTEE;
00792 //              capsbuf->m_acsmap[HLINE] = ANSI_HLINE;
00793 //              capsbuf->m_acsmap[VLINE] = ANSI_VLINE;
00794 //              capsbuf->m_acsmap[PLUS] = ANSI_PLUS;
00795 //              capsbuf->m_acsmap[S1] = ANSI_S1;
00796 //              capsbuf->m_acsmap[S9] = ANSI_S9;
00797 //              capsbuf->m_acsmap[DIAMOND] = ANSI_DIAMOND; 
00798 //              capsbuf->m_acsmap[CKBOARD] = ANSI_CKBOARD;
00799 //              capsbuf->m_acsmap[DEGREE] = ANSI_DEGREE;
00800 //              capsbuf->m_acsmap[PLMINUS] = ANSI_PLMINUS;
00801 //              capsbuf->m_acsmap[BULLET] = ANSI_BULLET;
00802 //              capsbuf->m_acsmap[LARROW] = ANSI_LARROW;
00803 //              capsbuf->m_acsmap[RARROW] = ANSI_RARROW;
00804 //              capsbuf->m_acsmap[DARROW] = ANSI_DARROW;
00805 //              capsbuf->m_acsmap[UARROW] = ANSI_UARROW;
00806 //              capsbuf->m_acsmap[BOARD] = ANSI_BOARD;
00807 //              capsbuf->m_acsmap[LANTERN] = ANSI_LANTERN;
00808 //              capsbuf->m_acsmap[BLOCK] = ANSI_BLOCK;
00809 //              capsbuf->m_acsmap[S3] = ANSI_S3;
00810 //              capsbuf->m_acsmap[S7] = ANSI_S7;
00811 //              capsbuf->m_acsmap[LEQUAL] = ANSI_LEQUAL;
00812 //              capsbuf->m_acsmap[GEQUAL] = ANSI_GEQUAL;
00813 //              capsbuf->m_acsmap[PI] = ANSI_PI;
00814 //              capsbuf->m_acsmap[NEQUAL] = ANSI_NEQUAL;
00815 //              capsbuf->m_acsmap[STERLING] = ANSI_STERLING;
00816 //              capsbuf->m_isdos = false;
00817 //              capsbuf->m_hasacs = true;
00818 //              capsbuf->m_hasS0S1 = false;
00819 //      }
00820 //      ASSERT(0xcd == capsbuf->m_eos);
00821 //      termcapValidateMem( capsbuf );
00822 //      return 1;
00823 //}
00824 //
00825 //void termcapDestruct (termcap *caps)
00826 //{
00827 //      int x;
00828 //      int count;
00829 //
00830 //      termcapValidateMem( caps );
00831 //
00832 //      ASSERT(0xcd == caps->m_eos);
00833 //      if ( NULL != caps->m_caps )
00834 //      {
00835 //              ASSERT_MEM( caps->m_caps, sizeof(hashtable) );
00836 //              hashtableValidateMem( caps->m_caps );
00837 //
00838 //              ASSERT_MEM( caps->m_vcaps, sizeof(vector) );
00839 //              vectorValidateMem( caps->m_vcaps );
00840 //              count = vectorCount( caps->m_vcaps );
00841 //              for ( x = 0; x < count; x++ )
00842 //              {
00843 //                      string *dsc = (string *)vectorElementAt(caps->m_vcaps, x);
00844 //                      ASSERT_MEM( dsc, sizeof(string) );
00845 //                      stringDestruct( dsc );
00846 //              }
00847 //              hashtableDestruct( caps->m_caps );
00848 //              caps->m_caps = NULL;
00849 //      }
00850 //      if ( NULL != caps->m_vcaps )
00851 //      {
00852 //              vectorDestruct(caps->m_vcaps);
00853 //              caps->m_vcaps = NULL;
00854 //      }
00855 //      termcapValidateMem( caps );
00856 //}
00857 //
00858 //#ifdef DEBUG
00859 //void termcapValidateMem( termcap *caps )
00860 //{
00861 //      int x;
00862 //      int count;
00863 //      string *dsc;
00864 //
00865 //      ASSERT(0xcd == caps->m_eos);
00866 //      if ( NULL == caps->m_caps )
00867 //      {
00868 //              ASSERT( NULL == caps->m_vcaps );
00869 //              return;
00870 //      }
00871 //      ASSERT_MEM( caps->m_caps, sizeof(hashtable) );
00872 //      hashtableValidateMem( caps->m_caps );
00873 //      ASSERT_MEM( caps->m_vcaps, sizeof(vector) );
00874 //      vectorValidateMem( caps->m_vcaps );
00875 //
00876 //      vectorValidateMem(caps->m_vcaps);
00877 //      count = vectorCount( caps->m_vcaps );
00878 //      for ( x = 0; x < count; x++ )
00879 //      {
00880 //              vectorValidateMem(caps->m_vcaps);
00881 //              ASSERT_MEM( caps->m_vcaps, sizeof(vector) );
00882 //              dsc = (string *)vectorElementAt(caps->m_vcaps, x);
00883 //              ASSERT_MEM( dsc, sizeof(string) );
00884 //              stringValidateMem( dsc );
00885 //      }
00886 //}
00887 //
00888 //void termcapCheckMem( termcap *caps )
00889 //{
00890 //      //vector *items;
00891 //      int x;
00892 //      int count;
00893 //
00894 //      //DEBUG_VALIDATE();
00895 //
00896 //      ASSERT(0xcd == caps->m_eos);
00897 //      if ( NULL == caps->m_caps )
00898 //      {
00899 //              return;
00900 //      }
00901 //      hashtableValidateMem( caps->m_caps );
00902 //
00903 //      DEBUG_NOTE_MEM_ALLOCATION( caps->m_caps );
00904 //      hashtableCheckMem( caps->m_caps );
00905 //      DEBUG_NOTE_MEM_ALLOCATION( caps->m_vcaps );
00906 //      vectorCheckMem( caps->m_vcaps );
00907 //
00908 //      count = vectorCount( caps->m_vcaps );
00909 //      for ( x = 0; x < count; x++ )
00910 //      {
00911 //              string *dsc = (string *)vectorElementAt(caps->m_vcaps, x);
00912 //              ASSERT_MEM( dsc, sizeof(string) );
00913 //              DEBUG_NOTE_MEM_ALLOCATION( dsc );
00914 //              stringValidateMem( dsc );
00915 //              stringCheckMem( dsc );
00916 //      }
00917 //}
00918 //#endif
00919 //