Link with C++ linker
[oweals/cde.git] / cde / programs / dtimsstart / ximsfunc.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: ximsfunc.h /main/2 1996/05/07 14:02:55 drk $ */
24
25 #ifndef _XIMSFUNC_H_
26 #define _XIMSFUNC_H_    1
27
28
29     /* External Functions */
30
31         /* main.c */
32 extern  void    sigExit(/* sig */);
33 extern  void    Exit(/* err_code */);
34 extern  int     NotifyErrCode(/* err_code */);
35 extern  int     ErrFilePathNeeded(/* error */);
36 extern  int     InWaitingState(/*  */);
37 extern  void    ximsMain(/*  */);
38 extern  void    ximsFinish(/*  */);
39 extern  char    *xims_errmsg(/* err_num, arg1, arg2, arg3 */);
40
41         /* env.c */
42 extern  int     set_cmd_env(/*  */);
43 extern  int     get_user_environ(/*  */);
44 extern  int     expand_string(/* in_str, out_str, out_len, ims */);
45 extern  int     make_new_environ(/* oenv, sel */);
46 extern  int     put_new_environ(/* oenv */);
47 extern  int     set_remote_env(/* ptr, env_pass */);
48 extern  char    *xhp_xinput_name(/* locale */);
49 extern  char    *get_real_locale(/* locale, aliases */);
50
51         /* select.c */
52 extern  void    ximsSelect(/*  */);
53 extern  int     update_user_selection(/* sel, list, idx, host, host_type */);
54 extern  int     get_ims_idx(/* list, name */);
55 extern  int     set_ims_status(/* ent */);
56 extern  int     get_ims_list(/* listp, locale, fill_ent */);
57
58         /* start.c */
59 extern  void    ximsStart(/*  */);
60 extern  void    ximsWait(/*  */);
61 extern  void    ximsWaitDone(/*  */);
62 extern  int     is_waiting(/*  */);
63 extern  void    set_sig_chld(/* enable */);
64 extern  int     im_mod_available(/* renv */);
65 extern  int     mk_ims_option(/* ptr, sel */);
66 extern  int     load_resources(/*  */);
67 extern  int     restore_resources(/*  */);
68
69         /* remote.c */
70 extern  int     put_remote_conf(/* locale, ims_name */);
71 extern  int     get_remote_conf(/* listp, hostname, locale, ims_name */);
72 extern  int     exec_remote_ims(/* sel */);
73 extern  int     check_hostname(/* hostname */);
74 extern  int     set_remote_confdata(/* confbuf, conflen */);
75 extern  int     read_remote_confdata(/* confbuf, conflen */);
76 extern  int     get_window_status(/*  */);
77 extern  int     change_window_status(/* status */);
78 extern  int     set_window_data(/* ac, av */);
79 extern  int     get_window_data(/* acp, avp */);
80
81         /* action.c */
82 extern  int     invoke_action(/* action, host */);
83 extern  void    send_dtims_msg(/* msg, errcode */);
84 extern  void    dtims_msg_proc(/* w, cd, event, continue_dispatch */);
85
86         /* file.c */
87 extern  int     create_xims_dir(/*  */);
88 extern  int     init_log_file(/* org_path, check_size */);
89 extern  int     set_errorlog(/* path */);
90 extern  int     read_cmd_conf(/*  */);
91 extern  int     expand_cmd_conf(/*  */);
92 extern  int     read_imsconf(/* conf, ims_name, ims_fname */);
93 extern  int     check_ims_conf(/* ims, ims_name */);
94 extern  int     read_localeconf(/* list, locale_name */);
95 extern  int     read_user_selection(/* fselp, locale_name */);
96 extern  int     read_selection_file(/* fsel, fp */);
97 extern  int     save_user_selection(/* sel, locale_name */);
98 extern  int     get_select_mode(/*  */);
99 extern  int     set_select_mode(/* cur_mode, new_mode */);
100 extern  int     parse_protolist(/* valp */);
101 extern  int     default_protocol(/* conf */);
102
103         /* win.c */
104 extern  int     open_display(/*  */);
105 extern  void    close_display(/*  */);
106 extern  int     window_env_ok(/*  */);
107 extern  int     init_window_env(/*  */);
108 extern  void    end_window_env(/*  */);
109 extern  int     clear_cmd_property(/* win */);
110 extern  int     save_RM(/*  */);
111 extern  int     merge_RM(/* res1, res2 */);
112 extern  int     restore_RM(/*  */);
113 extern  int     start_selection_window(/*  */);
114 extern  int     start_mode_window(/* cur_mode */);
115 extern  void    stop_help(/*  */);
116 extern  void    ximsHelp(/* help_type */);
117 extern  int     put_msg_win(/* type, msg */);
118 extern  void    xevent_loop(/*  */);
119 extern  void    xt_start_waiting(/*  */);
120 extern  void    xt_stop_waiting(/*  */);
121
122         /* util.c */
123                 /* string */
124 extern  char    *strcpyx(/* dest, src */);
125 extern  char    *strcpy2(/* dest, src1, src2 */);
126 extern  char    *newstradded(/* src1, src2, src3 */);
127 extern  int     str_to_int(/* ptr, val */);
128 extern  bool    str_to_bool(/* ptr, def_val */);
129 extern  char    *trim_line(/* ptr */);
130 extern  char    **parse_strlist(/* ptr, sep_ch */);
131 extern  int     pack_strlist(/* ptr, listp, sep_ch */);
132 extern  void    free_strlist(/* pp */);
133 extern  bool    parse_dpy_str(/* display_str, host, dnum, snum, dnet */);
134 extern  char    *std_dpy_str(/* display_str, snum */);
135                 /* file & dir */
136 extern  int     make_user_dir(/* path */);
137 extern  char    *dirname(/* path */);
138 extern  int     is_directory(/* path, must_writable */);
139 extern  int     is_regularfile(/* path */);
140 extern  int     is_emptyfile(/* path */);
141 extern  int     is_executable(/* path */);
142 extern  int     is_writable(/* path */);
143 extern  int     is_readable(/* path, allow_empty */);
144                 /* file read */
145 extern  int     start_tag_line(/* fname */);
146 extern  int     read_tag_line(/* fp, tagp, valp */);
147                 /* error messges */
148 extern  void    put_xims_msg(/* msg_type, err_num, arg1, arg2, arg3 */);
149 extern  void    put_xims_errmsg(/* err_num, arg1, arg2, arg3 */);
150 extern  void    put_xims_warnmsg(/* err_num, arg1, arg2, arg3 */);
151 extern  void    print_msg(/* fmt, arg1, arg2, arg3, arg4, arg5 */);
152 extern  int     put_xims_log(/* fmt, arg1, arg2, arg3 */);
153                 /* clear structure */
154 extern  void    clear_ImsConf(/* ims */);
155 extern  void    clear_ImsEnt(/* ent */);
156 extern  void    clear_ImsList(/* list */);
157 extern  void    clear_FileSel(/* fsel */);
158 extern  void    clear_UserSelection(/* sel */);
159 extern  void    clear_RunEnv(/* renv */);
160 extern  void    clear_OutEnv(/* oenv */);
161 extern  void    clear_UserEnv(/*  */);
162 extern  void    clear_CmdConf(/*  */);
163 extern  void    clear_WinEnv(/*  */);
164 extern  void    clear_CmdOpt(/*  */);
165 extern  void    clear_All(/*  */);
166 # ifdef DEBUG
167                 /* print structure */
168 extern  void    pr_FileSel(/* fsel */);
169 extern  void    pr_UserSelection(/* sel */);
170 extern  void    pr_ImsConf(/* conf, ims_name */);
171 extern  void    pr_ImsEnt(/* ent, idx */);
172 extern  void    pr_ImsList(/* list */);
173 extern  void    pr_WinEnv(/* wenv */);
174 extern  void    pr_RunEnv(/* renv */);
175 extern  void    pr_UserEnv(/*  */);
176 extern  void    pr_OutEnv(/* oenv */);
177 extern  void    pr_CmdConf(/*  */);
178 extern  void    pr_CmdOpt(/*  */);
179 extern  void    pr_OpModeFlag(/*  */);
180 extern  char    *StateName(/*  */);
181 extern  char    *error_name(/* error */);
182 extern  char    *proto_name(/* proto_idx */);
183 extern  char    *sig_name(/* sig */);
184 extern  void    pr_brk(/* msg */);
185 # endif /* DEBUG */
186
187
188     /* Macros */
189         /* memory */
190 #define CLR(p, st)              memset((void *) p, 0, sizeof(st))
191 #define COPY(d, s, n, st)       memcpy((void *)(d), (void *)(s), (n) * sizeof(st))
192
193 # ifdef DEBUG_MEM
194 void    *_mp_;
195
196 #define ALLOC(n, st)            (_mp_ = XtCalloc(n, sizeof(st)), \
197     print_msg("ALLOC(%d, " #st "): _mp_=%p sz=%d\n", n, _mp_, sizeof(st)), (st *) _mp_)
198 #define REALLOC(p, n, st)       ( _mp = XtRealloc((char *) (p), (n) * sizeof(st)), \
199     print_msg("REALLOC(%p, %d, " #st "): _mp_=%p\n", p, n, _mp_), (st *) _mp_)
200 #define NEWSTR(s)               (_mp_ = (s) && *(s) ? XtNewString(s) : NULL, \
201     print_msg("NEWSTR(%s): _mp_=%p\n", s, _mp_), (char *) _mp_)
202 #define FREE(p)                 (print_msg("FREE(%p)\n", p), XtFree((char *) p), (p) = 0)
203 #define RENEWSTR(p, s)          (_mp_ = (s) && *(s) ? XtNewString(s) : NULL, \
204     print_msg("RENEWSTR(" #p "): %p(%s) => %p(%s)\n", p, p, _mp_, s), \
205     XtFree((char *) p), (p) = (char *) _mp_)
206 # else  /* DEBUG_MEM */
207 #define ALLOC(n, st)            (st *) XtCalloc(n, sizeof(st))
208 #define REALLOC(p, n, st)       (st *) XtRealloc((char *) (p), (n) * sizeof(st))
209 #define NEWSTR(s)               ((s) && *(s)) ? XtNewString(s) : NULL
210 #define FREE(p)                 XtFree((char *) p), (p) = 0
211 #define RENEWSTR(p, s)          XtFree((char *) p), (p) = NEWSTR(s)
212 # endif /* DEBUG_MEM */
213
214 #define FREE_LIST(pp)           free_strlist(pp), (pp) = 0
215
216         /* string */
217 #define is_default_name(p)      (*(p) == NAME_DEFAULT_CHAR)
218 #define to_upper_ch(c)          ((c) & ~0x20)
219 #define to_lower_ch(c)          ((c) | 0x20)
220 #define to_upper_str(p)         while (*(p))    *(p)++ &= ~0x20
221 #define to_lower_str(p)         while (*(p))    *(p)++ |= 0x20
222 #define is_comment_char(c)      ((c) == COMMENT_CHAR || (c) == COMMENT_CHAR2)
223 #define is_white(c)             ((c) == ' ' || (c) == '\t' || (c) == '\n')
224 #define skip_white(p)           while (is_white(*(p)))  (p)++
225 #define next_field(p)   \
226         for ((p)++; *(p) && !is_white(*(p)); (p)++) ; skip_white(p)
227 #define cut_field(p)    \
228         for ((p)++; *(p) && !is_white(*(p)); (p)++) ; *(p)++ = 0; skip_white(p)
229
230         /* misc */
231 #define Max(a, b)       ((a) < (b) ? (b) : (a))
232 #define Min(a, b)       ((a) > (b) ? (b) : (a))
233
234         /* for DEBUG */
235 # ifdef DEBUG
236 #define DPR(msg)                if (DebugLvl >= 1)      print_msg msg
237 #define DPR2(msg)               if (DebugLvl >= 2)      print_msg msg
238 #define DPR3(msg)               if (DebugLvl >= 3)      print_msg msg
239 # else
240 #define DPR(msg)
241 #define DPR2(msg)
242 #define DPR3(msg)
243 # endif /* DEBUG */
244
245 #endif  /* _XIMSFUNC_H_ */