aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/os')
-rw-r--r--xorg-server/os/log.c161
-rw-r--r--xorg-server/os/utils.c36
2 files changed, 136 insertions, 61 deletions
diff --git a/xorg-server/os/log.c b/xorg-server/os/log.c
index 21a548178..ca457bdd9 100644
--- a/xorg-server/os/log.c
+++ b/xorg-server/os/log.c
@@ -171,6 +171,9 @@ asm (".desc ___crashreporter_info__, 0x10");
#ifndef X_NOT_IMPLEMENTED_STRING
#define X_NOT_IMPLEMENTED_STRING "(NI)"
#endif
+#ifndef X_NONE_STRING
+#define X_NONE_STRING ""
+#endif
/*
* LogInit is called to start logging to a file. It is also called (with
@@ -332,58 +335,65 @@ LogWrite(int verb, const char *f, ...)
va_end(args);
}
+/* Returns the Message Type string to prepend to a logging message, or NULL
+ * if the message will be dropped due to insufficient verbosity. */
+static const char *
+LogMessageTypeVerbString(MessageType type, int verb)
+{
+ if (type == X_ERROR)
+ verb = 0;
+
+ if (logVerbosity < verb && logFileVerbosity < verb)
+ return NULL;
+
+ switch (type) {
+ case X_PROBED:
+ return X_PROBE_STRING;
+ case X_CONFIG:
+ return X_CONFIG_STRING;
+ case X_DEFAULT:
+ return X_DEFAULT_STRING;
+ case X_CMDLINE:
+ return X_CMDLINE_STRING;
+ case X_NOTICE:
+ return X_NOTICE_STRING;
+ case X_ERROR:
+ return X_ERROR_STRING;
+ case X_WARNING:
+ return X_WARNING_STRING;
+ case X_INFO:
+ return X_INFO_STRING;
+ case X_NOT_IMPLEMENTED:
+ return X_NOT_IMPLEMENTED_STRING;
+ case X_UNKNOWN:
+ return X_UNKNOWN_STRING;
+ case X_NONE:
+ return X_NONE_STRING;
+ default:
+ return X_UNKNOWN_STRING;
+ }
+}
+
void
LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
{
- const char *s = X_UNKNOWN_STRING;
- char tmpBuf[1024];
-
- /* Ignore verbosity for X_ERROR */
- if (logVerbosity >= verb || logFileVerbosity >= verb || type == X_ERROR) {
- switch (type) {
- case X_PROBED:
- s = X_PROBE_STRING;
- break;
- case X_CONFIG:
- s = X_CONFIG_STRING;
- break;
- case X_DEFAULT:
- s = X_DEFAULT_STRING;
- break;
- case X_CMDLINE:
- s = X_CMDLINE_STRING;
- break;
- case X_NOTICE:
- s = X_NOTICE_STRING;
- break;
- case X_ERROR:
- s = X_ERROR_STRING;
- if (verb > 0)
- verb = 0;
- break;
- case X_WARNING:
- s = X_WARNING_STRING;
- break;
- case X_INFO:
- s = X_INFO_STRING;
- break;
- case X_NOT_IMPLEMENTED:
- s = X_NOT_IMPLEMENTED_STRING;
- break;
- case X_UNKNOWN:
- s = X_UNKNOWN_STRING;
- break;
- case X_NONE:
- s = NULL;
- break;
- }
-
- /* if s is not NULL we need a space before format */
- snprintf(tmpBuf, sizeof(tmpBuf), "%s%s%s", s ? s : "",
- s ? " " : "",
- format);
- LogVWrite(verb, tmpBuf, args);
+ const char *type_str;
+ char tmpFormat[1024];
+ char *new_format;
+
+ type_str = LogMessageTypeVerbString(type, verb);
+ if (!type_str)
+ return;
+
+ /* if type_str is not "", prepend it and ' ', to format */
+ if (type_str[0] == '\0')
+ new_format = format;
+ else {
+ new_format = tmpFormat;
+ snprintf(tmpFormat, sizeof(tmpFormat), "%s %s", type_str, format);
}
+
+ LogVWrite(verb, new_format, args);
}
/* Log message with verbosity level specified. */
@@ -408,6 +418,61 @@ LogMessage(MessageType type, const char *format, ...)
va_end(ap);
}
+
+void
+LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
+ va_list msg_args, const char *hdr_format, va_list hdr_args)
+{
+ const char *type_str;
+ char tmpFormat[1024];
+ char *tmpFormat_end = &tmpFormat[sizeof(tmpFormat)];
+ char *p;
+ int left;
+
+ type_str = LogMessageTypeVerbString(type, verb);
+ if (!type_str)
+ return;
+
+ /* if type_str != "", copy it and ' ' to tmpFormat; set p after ' ' */
+ p = tmpFormat;
+ if (type_str[0] != '\0')
+ p += snprintf(tmpFormat, sizeof(tmpFormat), "%s ", type_str);
+
+ /* append as much of hdr as fits after type_str (if there was one) */
+ left = tmpFormat_end - p;
+ if (left > 1)
+ p += vsnprintf(p, left, hdr_format, hdr_args);
+
+ /* append as much of msg_format as will fit after hdr */
+ left = tmpFormat_end - p;
+ if (left > 1)
+ snprintf(p, left, "%s", msg_format);
+
+ LogVWrite(verb, tmpFormat, msg_args);
+}
+
+void
+LogHdrMessageVerb(MessageType type, int verb, const char *msg_format,
+ va_list msg_args, const char *hdr_format, ...)
+{
+ va_list hdr_args;
+
+ va_start(hdr_args, hdr_format);
+ LogVHdrMessageVerb(type, verb, msg_format, msg_args, hdr_format, hdr_args);
+ va_end(hdr_args);
+}
+
+void
+LogHdrMessage(MessageType type, const char *msg_format, va_list msg_args,
+ const char *hdr_format, ...)
+{
+ va_list hdr_args;
+
+ va_start(hdr_args, hdr_format);
+ LogVHdrMessageVerb(type, 1, msg_format, msg_args, hdr_format, hdr_args);
+ va_end(hdr_args);
+}
+
void
AbortServer(void) _X_NORETURN;
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index d2d027ed9..7f2ca2355 100644
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -201,6 +201,8 @@ Bool PanoramiXExtensionDisabledHack = FALSE;
int auditTrailLevel = 1;
+char *SeatId = NULL;
+
#ifdef _MSC_VER
static HANDLE s_hSmartScheduleTimer = NULL;
static HANDLE s_hSmartScheduleTimerQueue = NULL;
@@ -241,7 +243,7 @@ OsSignal(int sig, OsSigHandlerPtr handler)
#define LOCK_SUFFIX "-lock"
static Bool StillLocking = FALSE;
-static char szLockFile[PATH_MAX];
+static char LockFile[PATH_MAX];
static Bool nolock = FALSE;
/*
@@ -261,26 +263,26 @@ LockServer(void)
FatalError("Server is already active for display %d\n", atoi(display));
}
#else
- char port[20];
char tmp[PATH_MAX], pid_str[12];
int lfd, i, haslock, l_pid, t;
char *tmppath = NULL;
int len;
+ char port[20];
if (nolock) return;
/*
* Path names
*/
tmppath = LOCK_DIR;
- sprintf(port, "%d", atoi(display));
+ sprintf(port, "%d", atoi(display));
len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) :
strlen(LOCK_TMP_PREFIX);
len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1;
- if (len > sizeof(szLockFile))
+ if (len > sizeof(LockFile))
FatalError("Display name `%s' is too long\n", port);
(void)sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
- (void)sprintf(szLockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
+ (void)sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
/*
* Create a temporary file containing our PID. Attempt three times
@@ -322,7 +324,7 @@ LockServer(void)
i = 0;
haslock = 0;
while ((!haslock) && (i++ < 3)) {
- haslock = (link(tmp,szLockFile) == 0);
+ haslock = (link(tmp,LockFile) == 0);
if (haslock) {
/*
* We're done.
@@ -333,17 +335,17 @@ LockServer(void)
/*
* Read the pid from the existing file
*/
- lfd = open(szLockFile, O_RDONLY);
+ lfd = open(LockFile, O_RDONLY);
if (lfd < 0) {
unlink(tmp);
- FatalError("Can't read lock file %s\n", szLockFile);
+ FatalError("Can't read lock file %s\n", LockFile);
}
pid_str[0] = '\0';
if (read(lfd, pid_str, 11) != 11) {
/*
* Bogus lock file.
*/
- unlink(szLockFile);
+ unlink(LockFile);
close(lfd);
continue;
}
@@ -360,7 +362,7 @@ LockServer(void)
/*
* Stale lock file.
*/
- unlink(szLockFile);
+ unlink(LockFile);
continue;
}
else if (((t < 0) && (errno == EPERM)) || (t == 0)) {
@@ -370,13 +372,13 @@ LockServer(void)
unlink(tmp);
FatalError("Server is already active for display %s\n%s %s\n%s\n",
port, "\tIf this server is no longer running, remove",
- szLockFile, "\tand start again.");
+ LockFile, "\tand start again.");
}
}
}
unlink(tmp);
if (!haslock)
- FatalError("Could not create server lock file: %s\n", szLockFile);
+ FatalError("Could not create server lock file: %s\n", LockFile);
StillLocking = FALSE;
#endif
}
@@ -392,7 +394,7 @@ UnlockServer(void)
if (!StillLocking){
- (void) unlink(szLockFile);
+ (void) unlink(LockFile);
}
}
@@ -532,6 +534,7 @@ void UseMsg(void)
ErrorF("r turns on auto-repeat \n");
ErrorF("-render [default|mono|gray|color] set render color alloc policy\n");
ErrorF("-retro start with classic stipple\n");
+ ErrorF("-seat string seat to run on\n");
ErrorF("-t # default pointer threshold (pixels/t)\n");
ErrorF("-terminate terminate at server reset\n");
ErrorF("-to # connection time out\n");
@@ -824,6 +827,13 @@ ProcessCommandLine(int argc, char *argv[])
else
UseMsg();
}
+ else if ( strcmp( argv[i], "-seat") == 0)
+ {
+ if(++i < argc)
+ SeatId = argv[i];
+ else
+ UseMsg();
+ }
else if ( strcmp( argv[i], "-t") == 0)
{
if(++i < argc)