/* Deal with the X Resource Manager.
- Copyright (C) 1990 Free Software Foundation.
+ Copyright (C) 1990, 1992 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
/* Written by jla, 4/90 */
+#ifdef emacs
+#include "config.h"
+#endif
+
+#if 1 /* I'd really appreciate it if this code could go away... -JimB */
+/* this avoids lossage in the `dual-universe' headers on AT&T SysV X11 */
+#ifdef USG5
+#define SYSV
+#include <unistd.h>
+#endif /* USG5 */
+
+#endif /* 1 */
+
+/* This should be included before the X include files; otherwise, we get
+ warnings about redefining NULL under BSD 4.3. */
+#include <sys/param.h>
+
#include <X11/Xlib.h>
#include <X11/Xatom.h>
+#if 0
#include <X11/Xos.h>
+#endif
#include <X11/X.h>
#include <X11/Xutil.h>
#include <X11/Xresource.h>
-#include <sys/param.h>
+#ifdef VMS
+#include "vms-pwd.h"
+#else
#include <pwd.h>
+#endif
#include <sys/stat.h>
-#include <sys/types.h>
-#ifdef emacs
-#include "config.h"
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 256
#endif
extern char *getenv ();
-extern uid_t getuid ();
+
+/* This does cause trouble on AIX. I'm going to take the comment at
+ face value. */
+#if 0
+extern short getuid (); /* If this causes portability problems,
+ I think we should just delete it; it'll
+ default to `int' anyway. */
+#endif
+
extern struct passwd *getpwuid ();
extern struct passwd *getpwnam ();
{
struct stat status;
- return (access (path, R_OK) == 0 /* exists and is readable */
+ return (access (path, 4) == 0 /* exists and is readable */
&& stat (path, &status) == 0 /* get the status */
&& (status.st_mode & S_IFDIR) == 0); /* not a directory */
}
{
register char *s = incantation_string;
register char *p;
- register char string[MAXPATHLEN];
+
+ /* Must be big enough for "%N%S". */
+ register int string_size = MAXPATHLEN;
+ register char *string = (char *) alloca (string_size * sizeof (*string));
while (*s)
{
if (*p == ':' && *(p + 1) == ':')
{
+ /* We know string is big enough for this. */
bcopy ("%N%S", string, 5);
if (decode_magic (string, file, return_path))
return 1;
{
int len = p - s;
+ if (string_size < len+1)
+ {
+ string_size = 2 * len;
+ string = (char *) alloca (string_size * sizeof (*string));
+ }
bcopy (s, string, len);
string[len + 1] = '\0';
if (decode_magic (string, file, return_path))
XrmDatabase db;
char *xdefs;
+#ifdef PBaseSize /* Cheap way to test for X11R4 or later. */
xdefs = XResourceManagerString (display);
+#else
+ xdefs = display->xdefaults;
+#endif
+
if (xdefs != NULL)
db = XrmGetStringDatabase (xdefs);
else
&& (type == expected_type))
{
if (type == x_rm_string)
- (char *) ret_value->addr = value.addr;
+ ret_value->addr = (char *) value.addr;
else
bcopy (value.addr, ret_value->addr, ret_value->size);