5d2b49c9367f502b507dd77f77953baa8b4f8807
[oweals/cde.git] / cde / programs / dtpdmd / dtpdmdP.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: dtpdmdP.h /main/6 1996/10/30 19:11:15 cde-hp $ */
24 /******************************************************************************
25  ******************************************************************************
26  **
27  ** File:         dtpdmdP.h
28  **
29  ** Description:  misc header stuff for the dtpdmd
30  **
31  ** (c) Copyright 1995, 1996, Hewlett-Packard Company, all rights reserved.
32  **
33  ******************************************************************************
34  *****************************************************************************/
35
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <fcntl.h>
40 #include <signal.h>
41 #include <setjmp.h>
42 #include <sys/wait.h>
43 #include <sys/stat.h>
44 #include "X11/Xlibint.h"
45 #include "X11/Intrinsic.h"
46 #include "X11/Xatom.h"
47 #if 0 && defined(PRINTING_SUPPORTED)
48 #include <X11/extensions/Print.h>
49 #endif /* PRINTING_SUPPORTED */
50 #include <X11/Xauth.h>
51
52
53 /*****************************************************************************
54  *
55  * dtpdm/dtpdmd Protocol
56  */
57 #include <Dt/dtpdmd.h>
58
59
60 /******************************************************************************
61  *
62  * Child Tracking Record - for each fork/exec'ed child, the following
63  * structure is added to an array to maintain status on the child.
64  */
65 typedef struct
66 {
67     /*
68      * Manager selection portion.
69      */
70     Bool        mgr_flag;               /* is MGR tracking portion active */
71
72     char        *video_display_str;     /* Video Server Connection Info */
73     Window      video_window;
74
75     char        *print_display_str;     /* Print Server Connection Info */
76     Window      print_window;
77 #if 0 && defined(PRINTING_SUPPORTED)
78     XPContext   print_context;
79 #endif /* PRINTING_SUPPORTED */
80     char        *locale_hint;
81
82     Display     *selection_display;     /* Selection & Property Connection */
83     Window      requestor;
84     Atom        prop_atom;
85     Atom        selection;
86
87     Time        time;                   /* time of selection request */
88
89     Bool        seldpy_as_printdpy;     /* Can the selection display connection
90                                            be used in lieu of opening a new
91                                            print display connection? */
92
93     /*
94      * fork/exec and SIGCLD tracking portion.
95      */
96
97     /* pre-exec stage */
98
99     int         message_pipe[2];        /* pipe fildes, -1 if disconnected */
100     XtInputId   message_xtid;           /* XtAddInput id for message handler */
101     char        *message_string;        /* child's stderr */
102     char        *message_string2;       /* dtpdmd's addition to child's err */
103
104     /* exec stage */
105
106     char        **pdm_exec_argvs;       /* PDM exec string in argv[] format */
107     char        *pdm_exec_errormessage; /* exec error message (opt) for log */
108     Atom        pdm_exec_errorcode;     /* exec error code */
109     pid_t       pid;                    /* pid of child */
110     Bool        do_launch_reply;        /* can someone call mgr_launch_reply? */
111
112     /* shutdown stage */
113     Bool        exit_received;          /* child has exited (SIGCLD) */
114     int         exit_code;              /* exit code */
115
116     /*
117      * Mailbox selection portion.
118      */
119     Bool        mbox_flag;              /* do we have valid cookies */
120     Window      mbox_window;            /* assigned window serving as mbox */
121     char        *in_buf;                /* partial-cookie crumbs received */
122     int         in_sofar;               /*    - total in so far */
123     int         in_expected;            /*    - grand total expected */
124         
125     Xauth       **cookies;              /* completed cookie collection */
126     int         cookie_cnt;             /* cookie cnt - partial & completed */
127     short       cookie_state;           /* 0 = NULL term, 1 = non-NULL term,
128                                            2 = more to come */
129     char        auth_filename[L_tmpnam];
130     FILE        *auth_file;
131 } XpPdmServiceRec, *XpPdmServiceList;
132
133 /******************************************************************************
134  *
135  * Global dtpdmd information.   Rather than pass it around in
136  * parameter lists, clump in all in one global.
137  */
138 typedef struct
139 {
140     /*
141      * Type Atom References
142      */
143     Atom pdm_selection;                 /* PDM Selection */
144     Atom pdm_targets;                   /* - target */
145     Atom pdm_timestamp;                 /* - target */
146     Atom pdm_multiple;                  /* - target */
147     Atom pdm_start;                     /* - target */
148     Atom pdm_start_ok;                  /*   - status code */
149     Atom pdm_start_vxauth;              /*   - status code */
150     Atom pdm_start_pxauth;              /*   - status code */
151     Atom pdm_start_error;               /*   - status code */
152
153     Atom pdm_reply;                     /* OK/Cancel SendMessage type */
154     Atom pdm_exit_ok;                   /*   - status code */
155     Atom pdm_exit_cancel;               /*   - status code */
156     Atom pdm_exit_vxauth;               /*   - status code */
157     Atom pdm_exit_pxauth;               /*   - status code */
158     Atom pdm_exit_error;                /*   - status code */
159
160     Atom pdm_mbox;                      /* - target */
161
162     Atom pdm_mail;                      /* Cookie-Package SendMessage type */
163
164     /*
165      * X-Selection Information
166      */
167     char *alt_selection;
168
169     Time time;                          /* time selection was owned */
170
171     /*
172      * PDM Information
173      */
174     char *default_pdm, *override_pdm;
175
176     /*
177      * Child Service Tracking Record Information
178      */
179     int             serviceRecNum;
180     int             maxServiceRecNum;
181     XpPdmServiceRec **serviceRecs;
182
183     /*
184      * Xt Information
185      */
186     XtAppContext context;
187
188     /*
189      * Other
190      */
191     char  *log_file;
192     char  *prog_name;
193
194     unsigned char xerrno;
195     unsigned char xerrreq;
196     unsigned char xerrmin;
197 } XpPdmGlobals, *XpPdmGlobalsP;
198
199 /******************************************************************************
200  *
201  * Global functions.
202  *
203  * In each group, one module will define, and all other modules
204  * will make extern references to them.  Here are the extern
205  * reference statements.
206  */
207
208 /* dispatch.c */
209 extern void dispatch_mgr();
210 extern void dispatch_mbox();
211 extern void dispatch_targets();
212 extern void dispatch_multiple();
213 extern void dispatch_timestamp();
214 extern void dispatch_not_supported();
215
216 /* dtpdmd.c */
217 extern XpPdmGlobals g;
218
219 /* mailbox.c */
220 extern void mbox_initialize();
221 extern void mbox_build();
222 extern void mbox_reply();
223 extern void mbox_receive();
224
225 /* manager.c */
226 extern void mgr_initialize();
227 extern void mgr_launch_pdm();
228 extern void mgr_fetch_pdm();
229 extern void mgr_launch_reply();
230 extern void mgr_shutdown_reply();
231 extern void mgr_shutdown_scan();
232
233 /* records.c */
234 extern XpPdmServiceRec *find_rec();
235 extern XpPdmServiceRec *find_rec_by_mbox_win();
236 extern void delete_rec( XpPdmServiceRec *rec );
237
238 /* setup.c */
239 extern Bool _PdmMgrSetup();
240
241 /* util.c */
242 extern jmp_buf xio_quickie_jmp_buf;
243 extern int xio_quickie_handler();
244 extern char *xpstrdup();
245 extern int xpstrspn();
246 extern int xpstrcspn();
247 extern char *xpstrtok();
248 extern void xp_add_argv();
249