Thread View: comp.unix.programmer
6 messages
6 total messages
Started by C Wayne Huling
Tue, 27 Nov 1990 02:04
Reading termcap database other than termcap
Author: C Wayne Huling
Date: Tue, 27 Nov 1990 02:04
Date: Tue, 27 Nov 1990 02:04
13 lines
1025 bytes
1025 bytes
I have written a small program to accept the name of a printer and search the printcap for the hostmachine. I use the termcap routines supplied in the Unix PRM. Unfortunatly it reads from a environment set variable. My problem is if I set this variable "TERM" to be /etc/printcap and then run another program that needs "TERM" to be /etc/termcap then it will bomb. Is there any way of setting the file to be read from internally? Wayne -- ---> Sometimes I have evil thoughts...... ---> GC.
Re: Reading termcap database other than termcap
Author: Marcus J. Ranum
Date: Tue, 27 Nov 1990 14:56
Date: Tue, 27 Nov 1990 14:56
26 lines
1991 bytes
1991 bytes
In article <WAYNE.90Nov26180444@forchammer.cs.odu.edu> wayne@cs.odu.edu (C Wayne Huling) writes: > > I have written a small program to accept the name of a printer and search >the printcap for the hostmachine. I use the termcap routines supplied in the >Unix PRM. Unfortunatly it reads from a environment set variable. My problem >is if I set this variable "TERM" to be /etc/printcap and then run another >program that needs "TERM" to be /etc/termcap then it will bomb. Is there any >way of setting the file to be read from internally? I have a hacked up copy of the printcap code from the BSD 'lpr' command that implements a "caplib" library - generic "termcap" capabilities. It differs from the "standard" termcap in that it wants to know the sizes of the buffers passed to it, and checks for overflow. It also doesn't support the egregious tc= kludge. There's no support for grabbing the entry out of the environment, but that shouldn't be very hard at all. [the way BSD does that also is a kludge - getting it out of the environment or not should be done at a higher level than in capgetent(), IE: if there is no XXXXCAP in the environment, *then* it uses capgetent(), etc] If anyone wants a copy, let me know. mjr. -- Good software will grow smaller and faster as time goes by and the code is improved and features that proved to be less useful are weeded out. [from the programming notebooks of a heretic, 1990]
Re: Reading termcap database other than termcap
Author: the main man
Date: Wed, 28 Nov 1990 16:09
Date: Wed, 28 Nov 1990 16:09
27 lines
1959 bytes
1959 bytes
In article <WAYNE.90Nov26180444@forchammer.cs.odu.edu>, wayne@cs.odu.edu (C Wayne Huling) writes:
>
> I have written a small program to accept the name of a printer and search
> the printcap for the hostmachine. I use the termcap routines supplied in the
> Unix PRM. Unfortunatly it reads from a environment set variable. My problem
> is if I set this variable "TERM" to be /etc/printcap and then run another
> program that needs "TERM" to be /etc/termcap then it will bomb. Is there any
> way of setting the file to be read from internally?
You could do a:
putenv("TERMCAP=/etc/printcap");
within your program before using terminfo or curses routines but
remember that if the program spawns a new process it will have this
in its environment.
By the way I assume you mean the TERMCAP environment variable and not
TERM since TERM specifies the terminal type and not the database location.
.===========================================================================.
| ACSnet: berny@tndsyd.oz UUCP: uunet!munnari.oz!tndsyd.oz.au!berny |
| INTERNET: berny@tndsyd.oz.au DOMAIN: goodheart_berny@tandem.com |
| PSMAIL: smtpgate @comm(berny@tndsyd.oz@munnari.oz.au) |
| FIDONET: berny@f614.n713.z3.fidonet.org@tndsyd.oz.au (3:713/614.0) |
`==========================================================================='
TANDEM Computers Incorporated 76 Berry St, North Sydney, NSW, 2060, Australia
Re: Reading termcap database other than termcap
Author: Horst Laumer
Date: Thu, 29 Nov 1990 00:42
Date: Thu, 29 Nov 1990 00:42
25 lines
1693 bytes
1693 bytes
mjr@hussar.dco.dec.com (Marcus J. Ranum) writes: > I have a hacked up copy of the printcap code from the BSD 'lpr' >command that implements a "caplib" library - generic "termcap" capabilities. >It differs from the "standard" termcap in that it wants to know the sizes >of the buffers passed to it, and checks for overflow. It also doesn't >support the egregious tc= kludge. There's no support for grabbing the >entry out of the environment, but that shouldn't be very hard at all. >[the way BSD does that also is a kludge - getting it out of the environment >or not should be done at a higher level than in capgetent(), IE: if there >is no XXXXCAP in the environment, *then* it uses capgetent(), etc] > If anyone wants a copy, let me know. I would be very interested in a copy. BTW, wouldn't it be good posting it ? (Rich Salz and c.s.u., ok, ok) thanks ahead hl -- ============================================================================ Horst Laumer, Kantstrasse 107, D-1000 Berlin 12 ! Bang-Adress: Domain: hotte@sunrise.in-berlin.de ! Junk-Food for Autorouters Bang: ...unido!fub!geminix!sunrise!hotte ! -- me --
Re: Reading termcap database other than termcap
Author: Simon J Gerraty
Date: Thu, 29 Nov 1990 22:36
Date: Thu, 29 Nov 1990 22:36
39 lines
2205 bytes
2205 bytes
In <WAYNE.90Nov26180444@forchammer.cs.odu.edu> wayne@cs.odu.edu (C Wayne Huling) writes: > I have written a small program to accept the name of a printer and search >the printcap for the hostmachine. I use the termcap routines supplied in the >Unix PRM. Unfortunatly it reads from a environment set variable. My problem >is if I set this variable "TERM" to be /etc/printcap and then run another >program that needs "TERM" to be /etc/termcap then it will bomb. Is there any >way of setting the file to be read from internally? I could not find any clean method of using the termcap routines to handle files like /etc/printcap. I ran into the same problem that you have while writing a daemon to service remote printers attached to terminal servers. After some mucking about, I wrote a simple library module to mimic (as far as I can tell) the termcap routines but providing a more generalised mechanism. Here is an extract: /* NAME: * cap.c - facility like termcap * * SYNOPSIS: * int cap_getent(char *buf, char *name); * int cap_getnum(char *id); * int cap_getflag(char *id); * char *cap_getstr(char *id, char **area); * * DESCRIPTION: * This module provides a general analogy to the TERMCAP facility. * If the variable _cap_database is not set, cap behaves like termcap. It handles things like following tc=like entries. If the "like" entry is in the same file it is simply absorbed into the entity being retrieved, otherwise the tc=like entry is left at the end. The source is about 4k. Let me know if you want a copy. -- Simon J. Gerraty <sjg@melb.bull.oz.au> #include <disclaimer,_witty_comment>
Re: Reading termcap database other than termcap
Author: Peter da Silva
Date: Thu, 29 Nov 1990 22:54
Date: Thu, 29 Nov 1990 22:54
9 lines
923 bytes
923 bytes
Use the replacement termlib routines I recently posted to alt.sources (mainly to help people porting "elvis"). Not only are the compatible, but they support multicharacter sequences (:foo=...:), which really helps when you're using termcap for other purposes and you want to avoid really strained mnemonics. -- Peter da Silva. `-_-' +1 713 274 5180. 'U` peter@ferranti.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads