1/******************************************************************************
2
3Copyright 1994, 1998  The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall not be
22used in advertising or otherwise to promote the sale, use or other dealings
23in this Software without prior written authorization from The Open Group.
24
25Author:  Ralph Mor, X Consortium
26******************************************************************************/
27
28#ifdef HAVE_CONFIG_H
29# include "config.h"
30#endif
31
32#include <X11/Xosdefs.h>
33#include <X11/Xfuncs.h>
34
35#include <X11/StringDefs.h>
36#include <X11/Intrinsic.h>
37#include <X11/Xatom.h>
38#include <X11/Xlib.h>
39#include <X11/SM/SMlib.h>
40
41#ifndef _POSIX_SOURCE
42#define _POSIX_SOURCE
43#include <stdio.h>
44#undef _POSIX_SOURCE
45#else
46#include <stdio.h>
47#endif
48#include <stdlib.h>
49
50#ifdef _POSIX_SOURCE
51#include <limits.h>
52#else
53#define _POSIX_SOURCE
54#include <limits.h>
55#undef _POSIX_SOURCE
56#endif
57
58#ifndef PATH_MAX
59#include <sys/param.h>
60#ifndef PATH_MAX
61#ifdef MAXPATHLEN
62#define PATH_MAX MAXPATHLEN
63#else
64#define PATH_MAX 1024
65#endif
66#endif
67#endif /* PATH_MAX */
68
69
70typedef struct WinInfo {
71    Window window;
72    SmcConn smc_conn;
73    XtInputId input_id;
74    char *client_id;
75    char **wm_command;
76    int wm_command_count;
77    XClassHint class;
78    char *wm_name;
79    XTextProperty wm_client_machine;
80    struct WinInfo *next;
81
82    unsigned int tested_for_sm_client_id : 1;
83    unsigned int has_save_yourself : 1;
84    unsigned int waiting_for_update : 1;
85    unsigned int got_first_save_yourself : 1;
86
87} WinInfo;
88
89typedef struct ProxyFileEntry
90{
91    struct ProxyFileEntry *next;
92    int tag;
93    char *client_id;
94    XClassHint class;
95    char *wm_name;
96    int wm_command_count;
97    char **wm_command;
98} ProxyFileEntry;
99
100extern int WriteProxyFileEntry ( FILE *proxyFile, WinInfo *theWindow );
101extern int ReadProxyFileEntry ( FILE *proxyFile, ProxyFileEntry **pentry );
102extern void ReadProxyFile ( char *filename );
103extern char * WriteProxyFile ( void );
104extern char * LookupClientID ( WinInfo *theWindow );
105
106extern WinInfo *win_head;
107
108#define SAVEFILE_VERSION 1
109
110#ifndef HAVE_ASPRINTF
111_X_HIDDEN int _X_ATTRIBUTE_PRINTF(2,3) asprintf(char ** ret,
112                                                const char *format, ...);
113#endif
114