allbery@ncoast.UUCP (Brandon Allbery) (07/26/86)
Expires: Quoted from <29000001@ndm20.UUCP> ["Re: tgetstr on system V R2 (HELP!)"], by lvs@ndm20.UUCP... +--------------- | | | > I am trying to get a recently posted reminder program (rs) | >to run on my machine (VAX 11/780 running Sys V R2). The program | >seems to run okay, except that all calls to tgetstr() do not | >return the correct escape sequence (they return null). | > | > The sequence being used is: | > tgetent(bp, terminal name) /* works fine - return of 1 */ | > tgetnum("co") /* works fine - returns 80 */ | > tgetstr("so",&some_buffer) or | > tgetstr("bl",&some_buffer) or anything else | > /* returns 0's in buffer */ | > | > Does anyone know why it doesn't? Am I doing something wrong? | >Please respond via email. | > | >Lee Vallone AT&T Information Systems Merlin | >{... ihnp4, mtuxo}!mtsbb!lav | | No, you are not doing anything wrong, AT&T is! They have broken the | way tgetent and tgetstr work. The only help you get from AT&T | software support is "Sorry, we don't support termcap anymore". Oh | well, so it goes. | | The original definition for tgetstr was | | char *tgetstr( char *code, char **bufptr ) | | tgetstr would get the string you desired (if it can find it) and | place it in your buffer, supplied by bufptr. It would then update | bufptr to point just beyond the string just added and return the | original value of the buffer pointer (unless the code couldn't be | found in which case it returns NULL). | | Well, so much for the way it SHOULD work. The version supplied by | AT&T in SVR2 is just plain broken. It does nothing with the buffer | you supply it, nor does it update the pointer. The only usefull | information is the return value. If it is not NULL it will point to | the string you requested. Therefore, you must save the return value | from the call, that is you can't use bufptr because it doesn't point | to the string. If you want the strings in a buffer you will have to | copy them into it yourself. +--------------- I always declare the buffer as automatic within a function and copy the result, to be sure. Please note that the tget* functions are a compatibility aid only, and you really should not use them under System V; they may go away. +--------------- | Alas, it seems AT&T has broken termcap and instead of fixing it, they | decided not to support it. +--------------- Huh??? I hate to tell you, but what you're so blithely calling termcap is in reality terminfo. Read TERM(4) in the UNIX Programmer's Reference Guide. The current version of terminfo supports access of terminfo capabilities by the old termcap names via compatibility calls to tget*; however, the two work in totally different ways. (Tgetstr() doesn't need a buffer; terminfo uses an internal buffer instead. Which is a step forward in my opinion.) +--------------- | BTW, the machine I have checked this on is an AT&T PC6300PLUS. It | exibited the same problems you described. It now works by doing it | the way I described above. +--------------- Read TERM(4) and rewrite using terminfo. You won't be sorry; terminfo is much cleaner than termcap. ++Brandon -- ---------------- /--/ Brandon S. Allbery UUCP: / / /|\/ Tridelta Industries, Inc. decvax!cwruecmp!ncoast! ---- -------- /-++ 7350 Corporate Blvd. tdi2!brandon / / /---, /--/ Mentor, Ohio 44060 PHONE: (home) / / / / / / -- HOME -- +1 216 974 9210 / / / / / / 6615 Center St. Apt. A1-105 ARPA: ncoast!allbery% ---- /----~ /--/ Mentor, Ohio 44060-4101 case.CSNET@csnet-relay ------------------------------------------------------------------------------- Space -- The Final Frontier