Article View: comp.windows.x
Article #24958XGetDefault for use by daemons and others
From: jmsellens
Date: Sun, 22 Feb 1987 00:47
Date: Sun, 22 Feb 1987 00:47
102 lines
3302 bytes
3302 bytes
I was fooling with a comsat (mail notification) daemon for use with X,
and observed that the author had had to set up a dummy environment
variable so that the daemon could read from the mail recipient's
.Xdefaults file. So I hacked XGetDefault.c to add a new routine
XGetDefaultHome() (for lack of a better name) that allows you to
give the routine the home directory to read the .Xdefaults file
from. The following is a context diff of what I did. Trivial
changes actually ...
John Sellens -- Logic Programming and Artificial Intelligence Group
{decvax|utzoo|ihnp4|allegra|clyde}!watmath!watdragon!jmsellens
jmsellens@dragon.waterloo.{edu,CDN} jsellens@watmta.BITNET
jmsellens%dragon@waterloo.csnet
*** XGetDefault.c.orig Mon Dec 1 19:04:53 1986
--- XGetDefault.c Fri Feb 20 16:19:04 1987
***************
*** 31,37 ****
--- 31,67 ----
char bal; /* for avl use */
} *head;
+
+ #ifdef waterloo
+
+ static char *XGetDefaultInternal();
+ static ReadFile();
+ static insert();
+
+
+ char *
+ XGetDefault( prog, name )
+ char *prog, *name;
+ {
+ return( XGetDefaultInternal( (char *)NULL, prog, name ) );
+ }
+
+ char *
+ XGetDefaultHome( home, prog, name )
+ char *home, *prog, *name;
+ {
+ return( XGetDefaultInternal( home, prog, name ) );
+ }
+
+ #endif
+
+
+ #ifdef waterloo
+ static char *XGetDefaultInternal(home, prog, name)
+ char *home; /* place to look for the file */
+ #else
char *XGetDefault(prog, name)
+ #endif
register char *name; /* name of option program wants */
char *prog; /* name of program for option */
{ /* to get, for example, "font" */
***************
*** 47,53 ****
--- 77,87 ----
pv++;
}
if (nent == -1)
+ #ifdef waterloo
+ nent = ReadFile(home,prog);/* if not, parse the file.*/
+ #else
nent = ReadFile(prog);/* if not, parse the file.*/
+ #endif
if (nent == 0)
return(NULL);
cur = head;
***************
*** 59,65 ****
--- 93,104 ----
return(NULL); /* if no match, let him know */
}
+ #ifdef waterloo
+ static ReadFile(home,prog)
+ char *home;
+ #else
static ReadFile(prog)
+ #endif
char *prog; /* program name to match */
{
register char *point,*colon; /* where in the line the keys are */
***************
*** 72,78 ****
--- 111,122 ----
char fname[BUFSIZ]; /* longer than any conceivable size */
char line[BUFSIZ]; /* line buffer for each line of file*/
char *getenv();
+ #ifndef waterloo
char *home = getenv("HOME");
+ #else
+ if ( home == (char *)NULL )
+ home = getenv( "HOME" );
+ #endif
if ((pv = rindex(prog,'/')) != NULL)
prog = pv + 1; /* if full path, get last component */
Technical Details
Message-ID:
<8702220047.AA13567@watdragon.uucp>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!ames!ucbcad!ucbvax!watdragon.waterloo.edu!jmsellensShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!ames!ucbcad!ucbvax!watdragon.waterloo.edu!jmsellens From: jmsellens@watdragon.waterloo.edu.UUCP Newsgroups: comp.windows.x Subject: XGetDefault for use by daemons and others Message-ID: <8702220047.AA13567@watdragon.uucp> Date: Sat, 21-Feb-87 19:47:37 EST Article-I.D.: watdrago.8702220047.AA13567 Posted: Sat Feb 21 19:47:37 1987 Date-Received: Sun, 22-Feb-87 05:45:27 EST Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 102