Link with C++ linker
[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 librararies 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 #include <X11/extensions/Print.h>
48 #include <X11/Xauth.h>
49
50
51 /*****************************************************************************
52  *
53  * dtpdm/dtpdmd Protocol
54  */
55 #include <Dt/dtpdmd.h>
56
57
58 /******************************************************************************
59  *
60  * Child Tracking Record - for each fork/exec'ed child, the following
61  * structure is added to an array to maintain status on the child.
62  */
63 typedef struct
64 {
65     /*
66      * Manager selection portion.
67      */
68     Bool        mgr_flag;               /* is MGR tracking portion active */
69
70     char        *video_display_str;     /* Video Server Connection Info */
71     Window      video_window;
72
73     char        *print_display_str;     /* Print Server Connection Info */
74     Window      print_window;
75     XPContext   print_context;
76     char        *locale_hint;
77
78     Display     *selection_display;     /* Selection & Property Connection */
79     Window      requestor;
80     Atom        prop_atom;
81     Atom        selection;
82
83     Time        time;                   /* time of selection request */
84
85     Bool        seldpy_as_printdpy;     /* Can the selection display connection
86                                            be used in lieu of opening a new
87                                            print display connection? */
88
89     /*
90      * fork/exec and SIGCLD tracking portion.
91      */
92
93     /* pre-exec stage */
94
95     int         message_pipe[2];        /* pipe fildes, -1 if disconnected */
96     XtInputId   message_xtid;           /* XtAddInput id for message handler */
97     char        *message_string;        /* child's stderr */
98     char        *message_string2;       /* dtpdmd's addition to child's err */
99
100     /* exec stage */
101
102     char        **pdm_exec_argvs;       /* PDM exec string in argv[] format */
103     char        *pdm_exec_errormessage; /* exec error message (opt) for log */
104     Atom        pdm_exec_errorcode;     /* exec error code */
105     pid_t       pid;                    /* pid of child */
106     Bool        do_launch_reply;        /* can someone call mgr_launch_reply? */
107
108     /* shutdown stage */
109     Bool        exit_received;          /* child has exited (SIGCLD) */
110     int         exit_code;              /* exit code */
111
112     /*
113      * Mailbox selection portion.
114      */
115     Bool        mbox_flag;              /* do we have valid cookies */
116     Window      mbox_window;            /* assigned window serving as mbox */
117     char        *in_buf;                /* partial-cookie crumbs received */
118     int         in_sofar;               /*    - total in so far */
119     int         in_expected;            /*    - grand total expected */
120         
121     Xauth       **cookies;              /* completed cookie collection */
122     int         cookie_cnt;             /* cookie cnt - partial & completed */
123     short       cookie_state;           /* 0 = NULL term, 1 = non-NULL term,
124                                            2 = more to come */
125     char        auth_filename[L_tmpnam];
126     FILE        *auth_file;
127 } XpPdmServiceRec, *XpPdmServiceList;
128
129 /******************************************************************************
130  *
131  * Global dtpdmd information.   Rather than pass it around in
132  * parameter lists, clump in all in one global.
133  */
134 typedef struct
135 {
136     /*
137      * Type Atom References
138      */
139     Atom pdm_selection;                 /* PDM Selection */
140     Atom pdm_targets;                   /* - target */
141     Atom pdm_timestamp;                 /* - target */
142     Atom pdm_multiple;                  /* - target */
143     Atom pdm_start;                     /* - target */
144     Atom pdm_start_ok;                  /*   - status code */
145     Atom pdm_start_vxauth;              /*   - status code */
146     Atom pdm_start_pxauth;              /*   - status code */
147     Atom pdm_start_error;               /*   - status code */
148
149     Atom pdm_reply;                     /* OK/Cancel SendMessage type */
150     Atom pdm_exit_ok;                   /*   - status code */
151     Atom pdm_exit_cancel;               /*   - status code */
152     Atom pdm_exit_vxauth;               /*   - status code */
153     Atom pdm_exit_pxauth;               /*   - status code */
154     Atom pdm_exit_error;                /*   - status code */
155
156     Atom pdm_mbox;                      /* - target */
157
158     Atom pdm_mail;                      /* Cookie-Package SendMessage type */
159
160     /*
161      * X-Selection Information
162      */
163     char *alt_selection;
164
165     Time time;                          /* time selection was owned */
166
167     /*
168      * PDM Information
169      */
170     char *default_pdm, *override_pdm;
171
172     /*
173      * Child Service Tracking Record Information
174      */
175     int             serviceRecNum;
176     int             maxServiceRecNum;
177     XpPdmServiceRec **serviceRecs;
178
179     /*
180      * Xt Information
181      */
182     XtAppContext context;
183
184     /*
185      * Other
186      */
187     char  *log_file;
188     char  *prog_name;
189
190     unsigned char xerrno;
191     unsigned char xerrreq;
192     unsigned char xerrmin;
193 } XpPdmGlobals, *XpPdmGlobalsP;
194
195 /******************************************************************************
196  *
197  * Global functions.
198  *
199  * In each group, one module will define, and all other modules
200  * will make extern references to them.  Here are the extern
201  * reference statements.
202  */
203
204 /* dispatch.c */
205 extern void dispatch_mgr();
206 extern void dispatch_mbox();
207 extern void dispatch_targets();
208 extern void dispatch_multiple();
209 extern void dispatch_timestamp();
210 extern void dispatch_not_supported();
211
212 /* dtpdmd.c */
213 extern XpPdmGlobals g;
214
215 /* mailbox.c */
216 extern void mbox_initialize();
217 extern void mbox_build();
218 extern void mbox_reply();
219 extern void mbox_receive();
220
221 /* manager.c */
222 extern void mgr_initialize();
223 extern void mgr_launch_pdm();
224 extern void mgr_fetch_pdm();
225 extern void mgr_launch_reply();
226 extern void mgr_shutdown_reply();
227 extern void mgr_shutdown_scan();
228
229 /* records.c */
230 extern XpPdmServiceRec *find_rec();
231 extern XpPdmServiceRec *find_rec_by_mbox_win();
232 extern void delete_rec( XpPdmServiceRec *rec );
233
234 /* setup.c */
235 extern Bool _PdmMgrSetup();
236
237 /* util.c */
238 extern jmp_buf xio_quickie_jmp_buf;
239 extern int xio_quickie_handler();
240 extern char *xpstrdup();
241 extern int xpstrspn();
242 extern int xpstrcspn();
243 extern char *xpstrtok();
244 extern void xp_add_argv();
245