summaryrefslogtreecommitdiff
path: root/app/xfs/os
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2012-03-04 18:36:22 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2012-03-04 18:36:22 +0000
commit5365e45dc9da6604d2dc2d42ddff15e81a8b5a8e (patch)
treed442a4420df36948a161df96db78ef6ff3f8be8e /app/xfs/os
parent034c8416b7ce56b0b85c7814d36c9da37f9fcdfb (diff)
Update to xfs 1.1.2
Diffstat (limited to 'app/xfs/os')
-rw-r--r--app/xfs/os/access.c2
-rw-r--r--app/xfs/os/config.c75
-rw-r--r--app/xfs/os/config.h66
-rw-r--r--app/xfs/os/configstr.h2
-rw-r--r--app/xfs/os/connection.c2
-rw-r--r--app/xfs/os/daemon.c2
-rw-r--r--app/xfs/os/error.c12
-rw-r--r--app/xfs/os/io.c2
-rw-r--r--app/xfs/os/osglue.c8
-rw-r--r--app/xfs/os/osinit.c2
-rw-r--r--app/xfs/os/utils.c6
-rw-r--r--app/xfs/os/waitfor.c2
-rw-r--r--app/xfs/os/xfstrans.c8
13 files changed, 64 insertions, 125 deletions
diff --git a/app/xfs/os/access.c b/app/xfs/os/access.c
index 36c459cf3..da46556de 100644
--- a/app/xfs/os/access.c
+++ b/app/xfs/os/access.c
@@ -43,7 +43,7 @@ in this Software without prior written authorization from The Open Group.
* THIS SOFTWARE.
*/
-#include "xfs-config.h"
+#include "config.h"
#include <X11/Xos.h>
#include <sys/param.h>
diff --git a/app/xfs/os/config.c b/app/xfs/os/config.c
index 6b1b08e20..f592fcf28 100644
--- a/app/xfs/os/config.c
+++ b/app/xfs/os/config.c
@@ -45,7 +45,7 @@ in this Software without prior written authorization from The Open Group.
*
*/
-#include "xfs-config.h"
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
@@ -106,19 +106,20 @@ static ConfigOptionRec config_options[] = {
{NULL, NULL},
};
-char *ConfigErrors[] = {
- "",
- "CONFIG: insufficient memory to load configuration file \"%s\"\n",
- "CONFIG: can't open configuration file \"%s\"\n",
- "CONFIG: error reading configuration file \"%s\"\n",
- "CONFIG: bad value \"%s\" for parameter \"%s\"\n",
- "CONFIG: unknown parameter \"%s\"\n",
- "CONFIG: missing '=' after parameter \"%s\"\n",
- "CONFIG: value out of range for parameter \"%s\"\n",
- "CONFIG: syntax error near parameter \"%s\"\n",
- "CONFIG: missing value for parameter \"%s\"\n",
- "CONFIG: extra value for parameter \"%s\"\n",
-};
+/* max size in bytes of config file */
+#define CONFIG_MAX_FILESIZE 32767
+
+#define CONFIG_ERR_MEMORY \
+ "CONFIG: insufficient memory to load configuration file \"%s\"\n"
+#define CONFIG_ERR_OPEN "CONFIG: can't open configuration file \"%s\"\n"
+#define CONFIG_ERR_READ "CONFIG: error reading configuration file \"%s\"\n"
+#define CONFIG_ERR_VALUE "CONFIG: bad value \"%s\" for parameter \"%s\"\n"
+#define CONFIG_ERR_UNKNOWN "CONFIG: unknown parameter \"%s\"\n"
+#define CONFIG_ERR_NOEQUALS "CONFIG: missing '=' after parameter \"%s\"\n"
+#define CONFIG_ERR_RANGE "CONFIG: value out of range for parameter \"%s\"\n"
+#define CONFIG_ERR_SYNTAX "CONFIG: syntax error near parameter \"%s\"\n"
+#define CONFIG_ERR_NOVALUE "CONFIG: missing value for parameter \"%s\"\n"
+#define CONFIG_ERR_EXTRAVALUE "CONFIG: extra value for parameter \"%s\"\n"
#define iseol(c) ((c) == '\n' || (c) == '\r' || (c) == '\f')
#define skip_whitespace(c) while(isspace(*(c)) || *(c) == ',') (c)++;
@@ -217,14 +218,14 @@ parse_config(char *data)
/* check for junk */
if (!isspace(*c) && *c != '=') {
- ErrorF(ConfigErrors[CONFIG_ERR_SYNTAX], param_name);
+ ErrorF(CONFIG_ERR_SYNTAX, param_name);
/* eat garbage */
while (!isspace(*c) && *c != '=' && *c != '\0')
c++;
}
skip_whitespace(c);
if (*c != '=') {
- ErrorF(ConfigErrors[CONFIG_ERR_NOEQUALS], param_name);
+ ErrorF(CONFIG_ERR_NOEQUALS, param_name);
equals_missing = TRUE;
} else {
c++;
@@ -244,26 +245,26 @@ parse_config(char *data)
if (val <= c) {
/* no value, ignore */
- ErrorF(ConfigErrors[CONFIG_ERR_NOVALUE], param_name);
+ ErrorF(CONFIG_ERR_NOVALUE, param_name);
continue;
}
*val = '\0';
} else if (*c == '\0') {
/* no value, ignore */
- ErrorF(ConfigErrors[CONFIG_ERR_NOVALUE], param_name);
+ ErrorF(CONFIG_ERR_NOVALUE, param_name);
continue;
}
/* match parm name */
if (equals_missing) {
equals_missing = FALSE;
} else if ((param = match_param_name(param_name)) == NULL) {
- ErrorF(ConfigErrors[CONFIG_ERR_UNKNOWN], param_name);
+ ErrorF(CONFIG_ERR_UNKNOWN, param_name);
} else {
consumed = (param->set_func) (param, c);
skip_whitespace(consumed);
if (*consumed != '\0') {
- ErrorF(ConfigErrors[CONFIG_ERR_EXTRAVALUE],
+ ErrorF(CONFIG_ERR_EXTRAVALUE,
param_name);
}
}
@@ -331,7 +332,7 @@ ReadConfigFile(const char *filename)
data = (char *) fsalloc(CONFIG_MAX_FILESIZE);
if (!data) {
- ErrorF(ConfigErrors[CONFIG_ERR_MEMORY], filename);
+ ErrorF(CONFIG_ERR_MEMORY, filename);
return FSBadAlloc;
}
if (filename != NULL) {
@@ -340,7 +341,7 @@ ReadConfigFile(const char *filename)
#endif
fp = fopen(filename, "r");
if (fp == NULL) {
- ErrorF(ConfigErrors[CONFIG_ERR_OPEN], filename);
+ ErrorF(CONFIG_ERR_OPEN, filename);
}
} else {
for (i = 0; default_config_files[i] != NULL; i++) {
@@ -357,7 +358,7 @@ ReadConfigFile(const char *filename)
}
if (fp == NULL) {
for (i = 0; default_config_files[i] != NULL; i++) {
- ErrorF(ConfigErrors[CONFIG_ERR_OPEN], default_config_files[i]);
+ ErrorF(CONFIG_ERR_OPEN, default_config_files[i]);
}
}
}
@@ -369,7 +370,7 @@ ReadConfigFile(const char *filename)
if (ret <= 0) {
fsfree(data);
(void) fclose(fp);
- ErrorF(ConfigErrors[CONFIG_ERR_READ], filename);
+ ErrorF(CONFIG_ERR_READ, filename);
return FSBadName;
}
len = ftell(fp);
@@ -387,12 +388,13 @@ ReadConfigFile(const char *filename)
}
struct nameVal {
- char *name;
+ const char *name;
int val;
};
static char *
config_parse_nameVal (
+ ConfigOptionPtr parm,
char *c,
int *ret,
int *pval,
@@ -417,7 +419,7 @@ config_parse_nameVal (
return c;
}
}
- ErrorF(ConfigErrors[CONFIG_ERR_VALUE], start);
+ ErrorF(CONFIG_ERR_VALUE, start, parm->parm_name);
*c = t;
*ret = -1;
return c;
@@ -425,6 +427,7 @@ config_parse_nameVal (
static char *
config_parse_bool (
+ ConfigOptionPtr parm,
char *c,
int *ret,
Bool *pval)
@@ -440,11 +443,12 @@ config_parse_bool (
{ "false", FALSE },
{ (char *) 0, 0 },
};
- return config_parse_nameVal (c, ret, pval, bool_val);
+ return config_parse_nameVal (parm, c, ret, pval, bool_val);
}
static char *
config_parse_int(
+ ConfigOptionPtr parm,
char *c,
int *ret,
int *pval)
@@ -458,7 +462,7 @@ config_parse_int(
skip_val(c);
t = *c;
*c = '\0';
- ErrorF(ConfigErrors[CONFIG_ERR_VALUE], start);
+ ErrorF(CONFIG_ERR_VALUE, start, parm->parm_name);
*ret = -1;
*c = t;
return c;
@@ -484,7 +488,7 @@ config_set_int(
int ival,
ret;
- val = config_parse_int(val, &ret, &ival);
+ val = config_parse_int(parm, val, &ret, &ival);
if (ret == -1)
return val;
@@ -508,7 +512,7 @@ config_set_bool(
ret;
Bool bval;
- val = config_parse_bool(val, &ret, &bval);
+ val = config_parse_bool(parm, val, &ret, &bval);
if (ret == -1)
return val;
@@ -644,6 +648,7 @@ config_set_resolutions(
static char *
config_parse_endian(
+ ConfigOptionPtr parm,
char *c,
int *ret,
int *pval)
@@ -657,7 +662,7 @@ config_parse_endian(
{ "msbfirst", MSBFirst },
{ (char *) 0, 0 },
};
- return config_parse_nameVal (c, ret, pval, endian_val);
+ return config_parse_nameVal (parm, c, ret, pval, endian_val);
}
/* ARGSUSED */
@@ -669,19 +674,19 @@ config_set_snf_format (
int bit, byte, glyph, scan;
int ret;
- val = config_parse_endian (val, &ret, &bit);
+ val = config_parse_endian (parm, val, &ret, &bit);
if (ret == -1)
return val;
skip_whitespace (val);
- val = config_parse_endian (val, &ret, &byte);
+ val = config_parse_endian (parm, val, &ret, &byte);
if (ret == -1)
return val;
skip_whitespace (val);
- val = config_parse_int (val, &ret, &glyph);
+ val = config_parse_int (parm, val, &ret, &glyph);
if (ret == -1)
return val;
skip_whitespace (val);
- val = config_parse_int (val, &ret, &scan);
+ val = config_parse_int (parm, val, &ret, &scan);
if (ret == -1)
return val;
SnfSetFormat (bit, byte, glyph, scan);
diff --git a/app/xfs/os/config.h b/app/xfs/os/config.h
deleted file mode 100644
index 1a4de08a4..000000000
--- a/app/xfs/os/config.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-Copyright 1987, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
- * Copyright 1990, 1991 Network Computing Devices;
- * Portions Copyright 1987 by Digital Equipment Corporation
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Network Computing Devices,
- * or Digital not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. Network Computing Devices, or Digital
- * make no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * NETWORK COMPUTING DEVICES, AND DIGITAL DISCLAIM ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, OR DIGITAL BE
- * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifndef _CONFIG_H_
-#define _CONFIG_H_
-
-/* max size in bytes of config file */
-#define CONFIG_MAX_FILESIZE 32767
-
-/* error codes */
-/* these should be in the same order as the error strings in config.c */
-#define CONFIG_ERR_MEMORY 1
-#define CONFIG_ERR_OPEN 2
-#define CONFIG_ERR_READ 3
-#define CONFIG_ERR_VALUE 4
-#define CONFIG_ERR_UNKNOWN 5
-#define CONFIG_ERR_NOEQUALS 6
-#define CONFIG_ERR_RANGE 7
-#define CONFIG_ERR_SYNTAX 8
-#define CONFIG_ERR_NOVALUE 9
-#define CONFIG_ERR_EXTRAVALUE 10
-#endif /* _CONFIG_H_ */
diff --git a/app/xfs/os/configstr.h b/app/xfs/os/configstr.h
index 0d55e2325..9743852ff 100644
--- a/app/xfs/os/configstr.h
+++ b/app/xfs/os/configstr.h
@@ -51,7 +51,7 @@ in this Software without prior written authorization from The Open Group.
typedef struct _config_options ConfigOptionRec, *ConfigOptionPtr;
struct _config_options {
- char *parm_name;
+ const char *parm_name;
char *(*set_func) (ConfigOptionPtr, char *);
};
diff --git a/app/xfs/os/connection.c b/app/xfs/os/connection.c
index c086036b8..02d34e6a9 100644
--- a/app/xfs/os/connection.c
+++ b/app/xfs/os/connection.c
@@ -67,7 +67,7 @@ in this Software without prior written authorization from The Open Group.
* THIS SOFTWARE.
*/
-#include "xfs-config.h"
+#include "config.h"
#include <stdlib.h>
#include <X11/Xtrans/Xtrans.h>
diff --git a/app/xfs/os/daemon.c b/app/xfs/os/daemon.c
index e1f826ee0..45a8e3ea1 100644
--- a/app/xfs/os/daemon.c
+++ b/app/xfs/os/daemon.c
@@ -28,7 +28,7 @@ from the X Consortium.
*/
-#include "xfs-config.h"
+#include "config.h"
#include <X11/Xos.h>
#include <sys/types.h>
diff --git a/app/xfs/os/error.c b/app/xfs/os/error.c
index d078f640c..d868eded4 100644
--- a/app/xfs/os/error.c
+++ b/app/xfs/os/error.c
@@ -44,7 +44,7 @@ in this Software without prior written authorization from The Open Group.
* THIS SOFTWARE.
*/
-#include "xfs-config.h"
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
@@ -66,7 +66,7 @@ Bool log_open = FALSE;
char ErrorFile[PATH_MAX];
static char CurrentErrorFile[PATH_MAX];
-static void
+static void _X_NORETURN
abort_server(void)
{
fflush(stderr);
@@ -131,7 +131,7 @@ CloseErrors(void)
}
void
-Error(char *str)
+Error(const char *str)
{
#ifdef USE_SYSLOG
if (UseSyslog) {
@@ -146,7 +146,7 @@ Error(char *str)
* used for informational messages
*/
void
-NoticeF(char *f, ...)
+NoticeF(const char *f, ...)
{
/* XXX should Notices just be ignored if not using syslog? */
va_list args;
@@ -167,7 +167,7 @@ NoticeF(char *f, ...)
* used for non-fatal error messages
*/
void
-ErrorF(char * f, ...)
+ErrorF(const char * f, ...)
{
va_list args;
va_start(args, f);
@@ -184,7 +184,7 @@ ErrorF(char * f, ...)
}
void
-FatalError(char * f, ...)
+FatalError(const char * f, ...)
{
va_list args;
va_start(args, f);
diff --git a/app/xfs/os/io.c b/app/xfs/os/io.c
index 8d9659ab1..a21fd5749 100644
--- a/app/xfs/os/io.c
+++ b/app/xfs/os/io.c
@@ -46,7 +46,7 @@ in this Software without prior written authorization from The Open Group.
* THIS SOFTWARE.
*/
-#include "xfs-config.h"
+#include "config.h"
#include <X11/Xtrans/Xtrans.h>
#include <stdio.h>
diff --git a/app/xfs/os/osglue.c b/app/xfs/os/osglue.c
index bcfce2f1f..d2c3c3601 100644
--- a/app/xfs/os/osglue.c
+++ b/app/xfs/os/osglue.c
@@ -51,7 +51,7 @@ in this Software without prior written authorization from The Open Group.
* Catalogue support, alternate servers, and cloneing
*/
-#include "xfs-config.h"
+#include "config.h"
#include <X11/Xtrans/Xtrans.h>
#include "osstruct.h"
@@ -80,10 +80,10 @@ static AlternateServerPtr alt_servers = (AlternateServerPtr) 0;
*
*/
-static char *catalogue_name = "all";
+static const char *catalogue_name = "all";
static Bool /* stolen from R4 Match() */
-pattern_match(char *pat, int plen, char *string)
+pattern_match(const char *pat, int plen, const char *string)
{
register int i,
l;
@@ -153,7 +153,7 @@ pattern_match(char *pat, int plen, char *string)
}
int
-ListCatalogues(char *pattern, int patlen, int maxnames,
+ListCatalogues(const char *pattern, int patlen, int maxnames,
char **catalogues, int *len)
{
int count = 0;
diff --git a/app/xfs/os/osinit.c b/app/xfs/os/osinit.c
index dcefe2877..dbbaa7a6f 100644
--- a/app/xfs/os/osinit.c
+++ b/app/xfs/os/osinit.c
@@ -48,7 +48,7 @@ in this Software without prior written authorization from The Open Group.
*
*/
-#include "xfs-config.h"
+#include "config.h"
#include "os.h"
#include "globals.h"
diff --git a/app/xfs/os/utils.c b/app/xfs/os/utils.c
index 7714e7533..ff382c7b1 100644
--- a/app/xfs/os/utils.c
+++ b/app/xfs/os/utils.c
@@ -46,7 +46,7 @@ in this Software without prior written authorization from The Open Group.
* THIS SOFTWARE.
*/
-#include "xfs-config.h"
+#include "config.h"
#include <stdio.h>
#include <X11/Xos.h>
@@ -88,7 +88,7 @@ int OldListenCount = 0;
#endif
#define WRITES(s) write(STDERR_FILENO, s, strlen(s))
-static char *pidFile = XFSPIDDIR "/xfs.pid";
+static const char *pidFile = XFSPIDDIR "/xfs.pid";
static int pidFd;
static FILE *pidFilePtr;
static int StorePid (void);
@@ -187,7 +187,7 @@ GetTimeInMillis(void)
return ((tp.tv_sec * 1000) + (tp.tv_usec / 1000));
}
-static void
+static void _X_NORETURN
usage(void)
{
fprintf(stderr, "usage: %s [-config config_file] [-port tcp_port] [-droppriv] [-daemon] [-nodaemon] [-user user_name] [-ls listen_socket]\n",
diff --git a/app/xfs/os/waitfor.c b/app/xfs/os/waitfor.c
index 4e80eba3f..d09b0dc48 100644
--- a/app/xfs/os/waitfor.c
+++ b/app/xfs/os/waitfor.c
@@ -48,7 +48,7 @@ in this Software without prior written authorization from The Open Group.
*
*/
-#include "xfs-config.h"
+#include "config.h"
#include <X11/Xos.h> /* strings, time, etc */
diff --git a/app/xfs/os/xfstrans.c b/app/xfs/os/xfstrans.c
index b24e7ec0a..31f443dde 100644
--- a/app/xfs/os/xfstrans.c
+++ b/app/xfs/os/xfstrans.c
@@ -1,5 +1,5 @@
/*
- * $Id: xfstrans.c,v 1.3 2009/10/10 10:12:49 matthieu Exp $
+ * $Id: xfstrans.c,v 1.4 2012/03/04 18:36:21 matthieu Exp $
*
* Copyright © 2003 Keith Packard
*
@@ -22,7 +22,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-#include <xfs-config.h>
+#include <config.h>
#define FONT_t 1
#define TRANS_REOPEN 1
@@ -37,7 +37,7 @@
OldListenRec *
TRANS(GetInetdListenInfo) (int fd)
{
- char *port = "0";
+ char *port = NULL;
XtransConnInfo inetdCI;
OldListenRec *old_listen;
int portnum;
@@ -53,7 +53,7 @@ TRANS(GetInetdListenInfo) (int fd)
else
#endif
portnum = ntohs(((struct sockaddr_in *)(inetdCI->addr))->sin_port);
- inetdCI->port = xalloc(6); /* Base 10 integer <= 65535 + trailing NUL */
+ inetdCI->port = malloc(6); /* Base 10 integer <= 65535 + trailing NUL */
snprintf(inetdCI->port, 6, "%d", portnum);
/* Do the socket setup that xtrans normally takes care of in