Commit 6f29dbf5 authored by Jeremy Huddleston's avatar Jeremy Huddleston

XQuartz: Use ErrorF rather than fprintf to log errors

Signed-off-by: default avatarJeremy Huddleston <jeremyhu@apple.com>
parent cb083b05
......@@ -507,7 +507,7 @@ bool getGlCapabilities(struct glCapabilities *cap) {
err = CGLQueryRendererInfo((GLuint)-1, &info, &numRenderers);
if(err) {
fprintf(stderr, "CGLQueryRendererInfo error: %s\n", CGLErrorString(err));
ErrorF("CGLQueryRendererInfo error: %s\n", CGLErrorString(err));
return err;
}
......@@ -518,8 +518,8 @@ bool getGlCapabilities(struct glCapabilities *cap) {
err = handleRendererDescriptions(info, r, &tmpconf);
if(err) {
fprintf(stderr, "handleRendererDescriptions returned error: %s\n", CGLErrorString(err));
fprintf(stderr, "trying to continue...\n");
ErrorF("handleRendererDescriptions returned error: %s\n", CGLErrorString(err));
ErrorF("trying to continue...\n");
continue;
}
......
......@@ -978,7 +978,7 @@ static inline pthread_t create_thread(void *(*func)(void *), void *arg) {
static void *xpbproxy_x_thread(void *args) {
xpbproxy_run();
fprintf(stderr, "xpbproxy thread is terminating unexpectedly.\n");
ErrorF("xpbproxy thread is terminating unexpectedly.\n");
return NULL;
}
......@@ -1021,15 +1021,15 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
last_key_layout = TISCopyCurrentKeyboardLayoutInputSource();
if(!last_key_layout)
fprintf(stderr, "X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n");
ErrorF("X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n");
#else
KLGetCurrentKeyboardLayout(&last_key_layout);
if(!last_key_layout)
fprintf(stderr, "X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n");
ErrorF("X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n");
#endif
if (!QuartsResyncKeymap(FALSE)) {
fprintf(stderr, "X11ApplicationMain: Could not build a valid keymap.\n");
ErrorF("X11ApplicationMain: Could not build a valid keymap.\n");
}
/* Tell the server thread that it can proceed */
......@@ -1370,7 +1370,7 @@ static const char *untrusted_str(NSEvent *e) {
#endif
/* Update keyInfo */
if (!QuartsResyncKeymap(TRUE)) {
fprintf(stderr, "sendX11NSEvent: Could not build a valid keymap.\n");
ErrorF("sendX11NSEvent: Could not build a valid keymap.\n");
}
}
}
......
......@@ -136,9 +136,9 @@ const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
void
DarwinPrintBanner(void)
{
// this should change depending on which specific server we are building
ErrorF("Xquartz starting:\n");
ErrorF("X.Org X Server %s\nBuild Date: %s\n", XSERVER_VERSION, BUILD_DATE );
ErrorF("X.Org X Server %s\n", XSERVER_VERSION);
ErrorF("Build Date: %s\n", BUILD_DATE );
}
......
This diff is collapsed.
......@@ -53,12 +53,22 @@ static void signal_handler (int sig) {
}
}
void
ErrorF(const char * f, ...)
{
va_list args;
va_start(args, f);
vfprintf(stderr, f, args);
va_end(args);
}
int main (int argc, const char *argv[]) {
const char *s;
int i;
#ifdef DEBUG
printf("pid: %u\n", getpid());
ErrorF("pid: %u\n", getpid());
#endif
xpbproxy_is_standalone = YES;
......@@ -70,13 +80,13 @@ int main (int argc, const char *argv[]) {
if(strcmp (argv[i], "--prefs-domain") == 0 && i+1 < argc) {
app_prefs_domain = argv[++i];
} else if (strcmp (argv[i], "--help") == 0) {
printf("usage: xpbproxy OPTIONS\n"
ErrorF("usage: xpbproxy OPTIONS\n"
"Pasteboard proxying for X11.\n\n"
"--prefs-domain <domain> Change the domain used for reading preferences\n"
" (default: %s)\n", app_prefs_domain);
return 0;
} else {
fprintf(stderr, "usage: xpbproxy OPTIONS...\n"
ErrorF("usage: xpbproxy OPTIONS...\n"
"Try 'xpbproxy --help' for more information.\n");
return 1;
}
......
......@@ -105,7 +105,7 @@ int xpbproxy_run (void) {
}
if (xpbproxy_dpy == NULL) {
fprintf (stderr, "xpbproxy: can't open default display\n");
ErrorF("xpbproxy: can't open default display\n");
[pool release];
return EXIT_FAILURE;
}
......@@ -115,7 +115,7 @@ int xpbproxy_run (void) {
if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
&xpbproxy_apple_wm_error_base)) {
fprintf (stderr, "xpbproxy: can't open AppleWM server extension\n");
ErrorF("xpbproxy: can't open AppleWM server extension\n");
[pool release];
return EXIT_FAILURE;
}
......@@ -147,19 +147,3 @@ Time xpbproxy_current_timestamp (void) {
/* FIXME: may want to fetch a timestamp from the server.. */
return CurrentTime;
}
void debug_printf (const char *fmt, ...) {
static int spew = -1;
if (spew == -1) {
char *x = getenv ("DEBUG");
spew = (x != NULL && atoi (x) != 0);
}
if (spew) {
va_list args;
va_start(args, fmt);
vfprintf (stderr, fmt, args);
va_end(args);
}
}
......@@ -77,14 +77,16 @@ extern BOOL xpbproxy_have_xfixes;
/* from x-input.m */
extern BOOL xpbproxy_input_register (void);
/* os/log.c or app-main.m */
extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
#ifdef DEBUG
/* BEWARE: this can cause a string memory leak, according to the leaks program. */
# define DB(msg, args...) debug_printf("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args)
# define DebugF(msg, args...) ErrorF("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args)
#else
# define DB(msg, args...) do {} while (0)
# define DebugF(...) /* */
#endif
#define TRACE() DB("TRACE\n")
extern void debug_printf (const char *fmt, ...);
#define TRACE() DebugF("TRACE\n")
#endif /* PBPROXY_H */
......@@ -87,7 +87,7 @@ static void xpbproxy_process_xevents(void) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if(pool == nil) {
fprintf(stderr, "unable to allocate/init auto release pool!\n");
ErrorF("unable to allocate/init auto release pool!\n");
return;
}
......
This diff is collapsed.
......@@ -367,9 +367,9 @@ static void DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue
if (pDev->kbdfeed)
memcpy(pDev->kbdfeed->ctrl.autoRepeats, ctrl->per_key_repeat, XkbPerKeyBitArraySize);
//fprintf(stderr, "per_key_repeat =\n");
//ErrorF("per_key_repeat =\n");
//for(i=0; i < XkbPerKeyBitArraySize; i++)
// fprintf(stderr, "%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n");
// ErrorF("%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n");
/* And now we notify the puppies about the changes */
XkbDDXChangeControls(pDev, &old, ctrl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment