ximsfunc.h 8.9 KB

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