Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!emory!swrinde!elroy.jpl.nasa.gov!hacgate!ladcgw.ladc.bull.com!melb.bull.oz.au!sjg From: sjg@melb.bull.oz.au (Simon J Gerraty) Newsgroups: comp.unix.programmer Subject: Re: Reading termcap database other than termcap Message-ID: <1990Nov29.223625.10094@melb.bull.oz.au> Date: 29 Nov 90 22:36:25 GMT References: Organization: Bull HN Information Systems Australia. Lines: 39 In 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 #include