diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:48:58 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:48:58 +0000 |
commit | 2a637a09ff68246161945821392656492f1fbde1 (patch) | |
tree | d515711c9476997088e583fe4a737d5c7e67df1b | |
parent | f4d5033f594bf278ff1171091219b3c28dc45446 (diff) |
XFree86 4.3.0.1xf86-4_3_99_903_specialxf86-4_3_99_902xf86-4_3_99_901xf86-4_3_99_16xf86-4_3_0_1xf86-012804-2330PRE_xf86-4_3_0_1
-rw-r--r-- | save.c | 72 | ||||
-rw-r--r-- | smproxy.c | 63 | ||||
-rw-r--r-- | smproxy.h | 27 | ||||
-rw-r--r-- | smproxy.man | 5 |
4 files changed, 121 insertions, 46 deletions
@@ -25,32 +25,33 @@ in this Software without prior written authorization from The Open Group. Author: Ralph Mor, X Consortium ******************************************************************************/ +/* $XFree86: xc/programs/smproxy/save.c,v 1.8 2001/12/14 20:01:05 dawes Exp $ */ #include "smproxy.h" +#ifdef HAS_MKSTEMP +#include <unistd.h> +#endif -typedef struct ProxyFileEntry -{ - struct ProxyFileEntry *next; - int tag; - char *client_id; - XClassHint class; - char *wm_name; - int wm_command_count; - char **wm_command; -} ProxyFileEntry; ProxyFileEntry *proxyFileHead = NULL; extern WinInfo *win_head; +static int write_byte ( FILE *file, unsigned char b ); +static int write_short ( FILE *file, unsigned short s ); +static int write_counted_string ( FILE *file, char *string ); +static int read_byte ( FILE *file, unsigned char *bp ); +static int read_short ( FILE *file, unsigned short *shortp ); +static int read_counted_string ( FILE *file, char **stringp ); +#ifndef HAS_MKSTEMP +static char * unique_filename ( char *path, char *prefix ); +#else +static char * unique_filename ( char *path, char *prefix, int *pFd ); +#endif static int -write_byte (file, b) - -FILE *file; -unsigned char b; - +write_byte (FILE *file, unsigned char b) { if (fwrite ((char *) &b, 1, 1, file) != 1) return 0; @@ -59,11 +60,7 @@ unsigned char b; static int -write_short (file, s) - -FILE *file; -unsigned short s; - +write_short (FILE *file, unsigned short s) { unsigned char file_short[2]; @@ -224,7 +221,7 @@ ProxyFileEntry **pentry; { ProxyFileEntry *entry; - char byte; + unsigned char byte; int i; *pentry = entry = (ProxyFileEntry *) malloc ( @@ -333,13 +330,21 @@ char *filename; +#ifndef HAS_MKSTEMP static char * unique_filename (path, prefix) - char *path; char *prefix; +#else +static char * +unique_filename (path, prefix, pFd) +char *path; +char *prefix; +int *pFd; +#endif { +#ifndef HAS_MKSTEMP #ifndef X_NOT_POSIX return ((char *) tempnam (path, prefix)); #else @@ -357,6 +362,19 @@ char *prefix; else return (NULL); #endif +#else + char tempFile[PATH_MAX]; + char *ptr; + + sprintf (tempFile, "%s/%sXXXXXX", path, prefix); + ptr = (char *)malloc(strlen(tempFile) + 1); + if (ptr != NULL) + { + strcpy(ptr, tempFile); + *pFd = mkstemp(ptr); + } + return ptr; +#endif } @@ -367,6 +385,9 @@ WriteProxyFile () { FILE *proxyFile = NULL; char *filename = NULL; +#ifdef HAS_MKSTEMP + int fd; +#endif char *path; WinInfo *winptr; Bool success = False; @@ -379,12 +400,19 @@ WriteProxyFile () path = "."; } +#ifndef HAS_MKSTEMP if ((filename = unique_filename (path, ".prx")) == NULL) goto bad; if (!(proxyFile = fopen (filename, "wb"))) goto bad; +#else + if ((filename = unique_filename (path, ".prx", &fd)) == NULL) + goto bad; + if (!(proxyFile = fdopen(fd, "wb"))) + goto bad; +#endif if (!write_short (proxyFile, SAVEFILE_VERSION)) goto bad; @@ -25,8 +25,11 @@ in this Software without prior written authorization from The Open Group. Author: Ralph Mor, X Consortium ******************************************************************************/ +/* $XFree86: xc/programs/smproxy/smproxy.c,v 3.9 2001/12/14 20:01:05 dawes Exp $ */ #include "smproxy.h" +#include <unistd.h> +#include <X11/Xmu/WinUtil.h> XtAppContext appContext; Display *disp; @@ -57,6 +60,39 @@ Bool sent_save_done = 0; int Argc; char **Argv; +Bool HasSaveYourself ( Window window ); +Bool HasXSMPsupport ( Window window ); +WinInfo * GetClientLeader ( WinInfo *winptr ); +char * CheckFullyQuantifiedName ( char *name, int *newstring ); +void FinishSaveYourself ( WinInfo *winInfo, Bool has_WM_SAVEYOURSELF ); +void SaveYourselfCB ( SmcConn smcConn, SmPointer clientData, int saveType, + Bool shutdown, int interactStyle, Bool fast ); +void DieCB ( SmcConn smcConn, SmPointer clientData ); +void SaveCompleteCB ( SmcConn smcConn, SmPointer clientData ); +void ShutdownCancelledCB ( SmcConn smcConn, SmPointer clientData ); +void ProcessIceMsgProc ( XtPointer client_data, int *source, XtInputId *id ); +void NullIceErrorHandler ( IceConn iceConn, Bool swap, + int offendingMinorOpCode, + unsigned long offendingSequence, + int errorClass, int severity, IcePointer values ); +void ConnectClientToSM ( WinInfo *winInfo ); +int MyErrorHandler ( Display *display, XErrorEvent *event ); +Bool LookupWindow ( Window window, WinInfo **ptr_ret, WinInfo **prev_ptr_ret ); +WinInfo * AddNewWindow ( Window window ); +void RemoveWindow ( WinInfo *winptr ); +void Got_WM_STATE ( WinInfo *winptr ); +void HandleCreate ( XCreateWindowEvent *event ); +void HandleDestroy ( XDestroyWindowEvent *event ); +void HandleUpdate ( XPropertyEvent *event ); +void ProxySaveYourselfPhase2CB ( SmcConn smcConn, SmPointer clientData ); +void ProxySaveYourselfCB ( SmcConn smcConn, SmPointer clientData, + int saveType, Bool shutdown, int interactStyle, + Bool fast ); +void ProxyDieCB ( SmcConn smcConn, SmPointer clientData ); +void ProxySaveCompleteCB ( SmcConn smcConn, SmPointer clientData ); +void ProxyShutdownCancelledCB ( SmcConn smcConn, SmPointer clientData ); +Status ConnectProxyToSM ( char *previous_id ); +void CheckForExistingWindows ( Window root ); Bool @@ -237,7 +273,7 @@ Bool has_WM_SAVEYOURSELF; prop1val.value = (SmPointer) winInfo->wm_command[0]; prop1val.length = strlen (winInfo->wm_command[0]); - sprintf (userId, "%d", getuid()); + sprintf (userId, "%ld", (long)getuid()); prop2.name = SmUserID; prop2.type = SmARRAY8; prop2.num_vals = 1; @@ -347,7 +383,8 @@ Bool fast; if (debug) { - printf ("Sent SAVE YOURSELF to 0x%x\n", winInfo->window); + printf ("Sent SAVE YOURSELF to 0x%x\n", + (unsigned int)winInfo->window); printf ("\n"); } } @@ -356,7 +393,7 @@ Bool fast; if (debug) { printf ("Failed to send SAVE YOURSELF to 0x%x\n", - winInfo->window); + (unsigned int)winInfo->window); printf ("\n"); } } @@ -381,7 +418,7 @@ SmPointer clientData; /* Now tell the client to die */ if (debug) - printf ("Trying to kill 0x%x\n", winInfo->window); + printf ("Trying to kill 0x%x\n", (unsigned int)winInfo->window); XSync (disp, 0); XKillClient (disp, winInfo->window); @@ -529,7 +566,8 @@ WinInfo *winInfo; if (debug) { - printf ("Connected to SM, window = 0x%x\n", winInfo->window); + printf ("Connected to SM, window = 0x%x\n", + (unsigned int)winInfo->window); printf ("\n"); } @@ -538,6 +576,7 @@ WinInfo *winInfo; +int MyErrorHandler (display, event) Display *display; @@ -545,6 +584,7 @@ XErrorEvent *event; { caught_error = 1; + return 0; } @@ -866,7 +906,8 @@ XDestroyWindowEvent *event; if (debug) { - printf ("Removed window (window = 0x%x)\n", winptr->window); + printf ("Removed window (window = 0x%x)\n", + (unsigned int)winptr->window); printf ("\n"); } @@ -941,7 +982,7 @@ SmPointer clientData; prop1val.value = Argv[0]; prop1val.length = strlen (Argv[0]); - sprintf (userId, "%d", getuid()); + sprintf (userId, "%ld", (long)getuid()); prop2.name = SmUserID; prop2.type = SmARRAY8; prop2.num_vals = 1; @@ -1211,11 +1252,8 @@ Window root; -main (argc, argv) - -int argc; -char **argv; - +int +main (int argc, char *argv[]) { char *restore_filename = NULL; char *client_id = NULL; @@ -1311,4 +1349,5 @@ char **argv; break; } } + exit(0); } @@ -25,6 +25,7 @@ in this Software without prior written authorization from The Open Group. Author: Ralph Mor, X Consortium ******************************************************************************/ +/* $XFree86: xc/programs/smproxy/smproxy.h,v 1.6 2001/12/14 20:01:05 dawes Exp $ */ #include <X11/Xosdefs.h> #include <X11/Xfuncs.h> @@ -42,13 +43,7 @@ Author: Ralph Mor, X Consortium #else #include <stdio.h> #endif - -#ifndef X_NOT_STDC_ENV #include <stdlib.h> -#else -extern char *malloc(), *calloc(), *realloc(), *getenv(); -extern void free(); -#endif #ifndef X_NOT_POSIX #ifdef _POSIX_SOURCE @@ -90,12 +85,22 @@ typedef struct WinInfo { } WinInfo; +typedef struct ProxyFileEntry +{ + struct ProxyFileEntry *next; + int tag; + char *client_id; + XClassHint class; + char *wm_name; + int wm_command_count; + char **wm_command; +} ProxyFileEntry; -extern int WriteProxyFileEntry (); -extern int ReadProxyFileEntry (); -extern void ReadProxyFile (); -extern char *WriteProxyFile (); -extern char *LookupClientID (); +extern int WriteProxyFileEntry ( FILE *proxyFile, WinInfo *theWindow ); +extern int ReadProxyFileEntry ( FILE *proxyFile, ProxyFileEntry **pentry ); +extern void ReadProxyFile ( char *filename ); +extern char * WriteProxyFile ( void ); +extern char * LookupClientID ( WinInfo *theWindow ); #define SAVEFILE_VERSION 1 diff --git a/smproxy.man b/smproxy.man index 0c1c355..d18650d 100644 --- a/smproxy.man +++ b/smproxy.man @@ -22,7 +22,10 @@ .\" 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. -.TH XSM 1 "Release 6.4" "X Version 11" +.\" +.\" $XFree86: xc/programs/smproxy/smproxy.man,v 1.7 2001/12/14 20:01:05 dawes Exp $ +.\" +.TH XSM 1 __xorgversion__ .SH NAME smproxy \- Session Manager Proxy .SH SYNOPSIS |