Convert (most) functions in src to standard C.
[bpt/emacs.git] / src / xrdb.c
index 4c9f3c6..8706726 100644 (file)
@@ -1,13 +1,16 @@
 /* Deal with the X Resource Manager.
    Copyright (C) 1990, 1993, 1994, 2000, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007 Free Software Foundation, Inc.
+                 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Author: Joseph Arceneaux
+Created: 4/90
 
 This file is part of GNU Emacs.
 
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs 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 2, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,11 +18,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
-
-/* Written by jla, 4/90 */
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifdef emacs
 #include <config.h>
@@ -29,28 +28,14 @@ Boston, MA 02110-1301, USA.  */
 #include <unistd.h>
 #endif
 
+#include <errno.h>
 #include <epaths.h>
 
 #include <stdio.h>
-
-#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.  Don't do it on Solaris, because it breaks compilation with
-   XFree86 4.0.3 (and probably many other X11R6 releases) on Solaris
-   2 */
-#if defined(USG5) && !defined(SOLARIS2)
-#ifndef SYSV
-#define SYSV
-#endif
-#endif /* USG5 && !SOLARIS2 */
-
-#endif /* 1 */
+#include <setjmp.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>
@@ -65,7 +50,7 @@ Boston, MA 02110-1301, USA.  */
 
 #include "lisp.h"
 
-extern char *getenv ();
+extern char *getenv (const char *);
 
 /* This does cause trouble on AIX.  I'm going to take the comment at
    face value.  */
@@ -79,8 +64,8 @@ extern short getuid ();               /* If this causes portability problems,
 extern struct passwd *getpwuid (uid_t);
 extern struct passwd *getpwnam (const char *);
 #else
-extern struct passwd *getpwuid ();
-extern struct passwd *getpwnam ();
+extern struct passwd *getpwuid (uid_t);
+extern struct passwd *getpwnam (const char *);
 #endif
 
 extern char *get_system_name ();
@@ -97,8 +82,8 @@ extern char *get_system_name ();
 #define free xfree
 #endif
 
-char *x_get_string_resource ();
-static int file_p ();
+char *x_get_string_resource (XrmDatabase rdb, char *name, char *class);
+static int file_p (char *filename);
 
 \f
 /* X file search path processing.  */
@@ -113,9 +98,7 @@ char *x_customization_string;
    resource, for later use in search path decoding.  If we find no
    such resource, return zero.  */
 char *
-x_get_customization_string (db, name, class)
-     XrmDatabase db;
-     char *name, *class;
+x_get_customization_string (XrmDatabase db, char *name, char *class)
 {
   char *full_name
     = (char *) alloca (strlen (name) + sizeof ("customization") + 3);
@@ -170,10 +153,7 @@ x_get_customization_string (db, name, class)
    Return NULL otherwise.  */
 
 static char *
-magic_file_p (string, string_len, class, escaped_suffix, suffix)
-     char *string;
-     int string_len;
-     char *class, *escaped_suffix, *suffix;
+magic_file_p (char *string, int string_len, char *class, char *escaped_suffix, char *suffix)
 {
   char *lang = getenv ("LANG");
 
@@ -296,7 +276,7 @@ magic_file_p (string, string_len, class, escaped_suffix, suffix)
 
 
 static char *
-gethomedir ()
+gethomedir (void)
 {
   struct passwd *pw;
   char *ptr;
@@ -326,8 +306,7 @@ gethomedir ()
 
 
 static int
-file_p (filename)
-     char *filename;
+file_p (char *filename)
 {
   struct stat status;
 
@@ -342,8 +321,7 @@ file_p (filename)
    the path name of the one we found otherwise.  */
 
 static char *
-search_magic_path (search_path, class, escaped_suffix, suffix)
-     char *search_path, *class, *escaped_suffix, *suffix;
+search_magic_path (char *search_path, char *class, char *escaped_suffix, char *suffix)
 {
   register char *s, *p;
 
@@ -378,8 +356,7 @@ search_magic_path (search_path, class, escaped_suffix, suffix)
 /* Producing databases for individual sources.  */
 
 static XrmDatabase
-get_system_app (class)
-     char *class;
+get_system_app (char *class)
 {
   XrmDatabase db = NULL;
   char *path;
@@ -399,16 +376,14 @@ get_system_app (class)
 
 
 static XrmDatabase
-get_fallback (display)
-     Display *display;
+get_fallback (Display *display)
 {
   return NULL;
 }
 
 
 static XrmDatabase
-get_user_app (class)
-     char *class;
+get_user_app (char *class)
 {
   char *path;
   char *file = 0;
@@ -433,20 +408,17 @@ get_user_app (class)
     {
       XrmDatabase db = XrmGetFileDatabase (file);
       free (file);
-      if (free_it)
-       free (free_it);
+      free (free_it);
       return db;
     }
 
-  if (free_it)
-    free (free_it);
+  free (free_it);
   return NULL;
 }
 
 
 static XrmDatabase
-get_user_db (display)
-     Display *display;
+get_user_db (Display *display)
 {
   XrmDatabase db;
   char *xdefs;
@@ -487,7 +459,7 @@ get_user_db (display)
 }
 
 static XrmDatabase
-get_environ_db ()
+get_environ_db (void)
 {
   XrmDatabase db;
   char *p;
@@ -506,8 +478,8 @@ get_environ_db ()
 
   db = XrmGetFileDatabase (p);
 
-  if (path) free (path);
-  if (home) free (home);
+  free (path);
+  free (home);
 
   return db;
 }
@@ -522,9 +494,7 @@ XrmRepresentation x_rm_string;      /* Quark representation */
 /* Load X resources based on the display and a possible -xrm option. */
 
 XrmDatabase
-x_load_resources (display, xrm_string, myname, myclass)
-     Display *display;
-     char *xrm_string, *myname, *myclass;
+x_load_resources (Display *display, char *xrm_string, char *myname, char *myclass)
 {
   XrmDatabase user_database;
   XrmDatabase rdb;
@@ -614,8 +584,7 @@ x_load_resources (display, xrm_string, myname, myclass)
 
   /* Figure out what the "customization string" is, so we can use it
      to decode paths.  */
-  if (x_customization_string)
-    free (x_customization_string);
+  free (x_customization_string);
   x_customization_string
     = x_get_customization_string (user_database, myname, myclass);
 
@@ -659,11 +628,7 @@ x_load_resources (display, xrm_string, myname, myclass)
    and of type TYPE from database RDB.  The value is returned in RET_VALUE. */
 
 int
-x_get_resource (rdb, name, class, expected_type, ret_value)
-     XrmDatabase rdb;
-     char *name, *class;
-     XrmRepresentation expected_type;
-     XrmValue *ret_value;
+x_get_resource (XrmDatabase rdb, char *name, char *class, XrmRepresentation expected_type, XrmValue *ret_value)
 {
   XrmValue value;
   XrmName namelist[100];
@@ -691,12 +656,14 @@ x_get_resource (rdb, name, class, expected_type, ret_value)
    database RDB. */
 
 char *
-x_get_string_resource (rdb, name, class)
-     XrmDatabase rdb;
-     char *name, *class;
+x_get_string_resource (XrmDatabase rdb, char *name, char *class)
 {
   XrmValue value;
 
+  if (inhibit_x_resources)
+    /* --quick was passed, so this is a no-op.  */
+    return NULL;
+
   if (x_get_resource (rdb, name, class, x_rm_string, &value))
     return (char *) value.addr;
 
@@ -733,8 +700,6 @@ fatal (msg, prog, x1, x2, x3, x4, x5)
     char *msg, *prog;
     int x1, x2, x3, x4, x5;
 {
-    extern int errno;
-
     if (errno)
       perror (prog);