Termcap question

Martin Weitzel martin at mwtech.UUCP
Thu Mar 1 21:02:46 AEST 1990


In article <5708 at star.cs.vu.nl> gpvos at cs.vu.nl (Vos G P) writes:
[first part deleted]
>
>This introduces another problem, though. Now i can't get a \0 in my strings!
>Can someone help me with that? As no high bits are stripped, \200 gives me
>a neat \200, instead of the \0 the man pages say.

If your application does *not* strip the high order bit from the
termcap strings on output, IMHO(%) there's only one chance to output
a \0-Byte, and that chance depends on your system:
Modern TTY-Drivers often support "output translate tables" which
let the driver translate any character to any other character (or
sometimes even to a string) immediatly, before this character is
sent to the port. So, use one character you don't ever need and
translate it to \0 in the output translate tables.

(%): There is a small design flaw in termcap: The strings you
read with "tgetstr" are stored \0-terminated, as usual in C
and you only have the adress of the first character, so you can
not distinguish an 'embedded' \0 from the terminating \0. Of
course, if you are willing to write (parts of) the termcap library
functions new, you may correct this by adding a length-count ...

Another question is, why do you *need* \0-Bytes on output? I don't
know of any hardware, which requires them for a particular function
other than 'padding' and - sometimes - cursor positioning to the
left/top column/row. Padding - if required - is done by some
other mechanism in termcap and "tgoto" avoids outputing a \0-Byte
by positioning to column/row 1 and back-/upspace.
-- 
Martin Weitzel, email: martin at mwtech.UUCP, voice: 49-(0)6151-6 56 83



More information about the Comp.unix.questions mailing list