xims.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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: xims.h /main/6 1996/04/17 16:25:50 pascale $ */
  24. /*
  25. * (c) Copyright 1996 Digital Equipment Corporation.
  26. * (c) Copyright 1996 Hewlett-Packard Company.
  27. * (c) Copyright 1996 International Business Machines Corp.
  28. * (c) Copyright 1996 Sun Microsystems, Inc.
  29. * (c) Copyright 1996 Novell, Inc.
  30. * (c) Copyright 1996 FUJITSU LIMITED.
  31. * (c) Copyright 1996 Hitachi.
  32. */
  33. #ifndef _XIMS_H_
  34. #define _XIMS_H_ 1
  35. #include <X11/X.h>
  36. #include <X11/Xlib.h>
  37. #include <X11/Intrinsic.h>
  38. #include <stdio.h>
  39. #include <stdlib.h>
  40. #include <unistd.h>
  41. #include <string.h>
  42. #include <sys/param.h>
  43. #include <sys/time.h>
  44. #include "ximspath.h"
  45. #include "ximserr.h"
  46. /* operation modes */
  47. #define MODE_START 0 /* default */
  48. #define MODE_MODE 1 /* -mode option */
  49. #define MODE_STYLE 2 /* -style option */
  50. #define MODE_LIST 3 /* -list option */ /* no window */
  51. #define MODE_CURRENT 4 /* -current option */ /* no window */
  52. #define MODE_REMCONF 5 /* -remoteconf */ /* no window */
  53. #define MODE_LISTNAME 6 /* -listname option */
  54. /* operation flags */
  55. #define FLAG_ENV (1<<0) /* -env option */
  56. #define FLAG_NOSAVE (1<<1) /* -nosave option */
  57. #define FLAG_NOSTART (1<<2) /* -nostart option (DEBUG) */
  58. #define FLAG_NOWAIT (1<<3) /* -nowait option */
  59. #define FLAG_NOTIMEOUT (1<<4) /* -notimeout option */
  60. #define FLAG_NORESOURCE (1<<5) /* -noresource option */
  61. #define FLAG_NOREMOTE (1<<6) /* -noremote option */
  62. #define FLAG_NOTIFY (1<<7) /* -notify option */
  63. #define FLAG_CONNECT (1<<8) /* -connect option */
  64. #define FLAG_REMOTERUN (1<<9) /* -remoterun option */
  65. #define FLAG_WINDOW (1<<10) /* -window option */
  66. #define FLAG_DT (1<<11) /* -dt option */
  67. # ifdef old_hpux
  68. #define FLAG_VUE (1<<12) /* -vue option */
  69. # endif /* old_hpux */
  70. #define FLAG_DEFAULT (FLAG_DT)
  71. # ifdef old_hpux
  72. #define USE_WINDOW_MASK (FLAG_WINDOW|FLAG_VUE|FLAG_DT)
  73. # else
  74. #define USE_WINDOW_MASK (FLAG_WINDOW|FLAG_DT)
  75. # endif /* old_hpux */
  76. #define MAXIMSENT 32 /* max # of ims for each locale */
  77. #define MIN_INTERVAL 100 /* msec */
  78. #define DEFAULT_INTERVAL 1000 /* msec */
  79. #define MIN_TIMEOUT 1 /* sec */
  80. #define DEFAULT_TIMEOUT 180 /* sec */
  81. #define REMOTE_TIMEOUT 60 /* sec */
  82. #define TAG_END_CHAR ':'
  83. #define TAG_SEP_CHAR '.'
  84. #define LIST_SEP_CHAR ','
  85. #define COMMENT_CHAR '!'
  86. #define COMMENT_CHAR2 '#'
  87. #define COMMENT_CHARS "!#"
  88. #define NAME_NONE "none"
  89. #define NAME_LOCAL "local"
  90. #define NAME_BUILTIN "builtin"
  91. #define NAME_DEFAULT "@"
  92. #define NAME_DEFAULT_CHAR '@'
  93. #define DUMMY_SERVER_NAME NAME_DEFAULT
  94. #define STR_PREFIX_CHAR '@'
  95. #define STR_DEFAULTIMS "DefaultIms"
  96. #define STR_SELECTMODE "SelectMode"
  97. #define STR_IMSNAME "ImsName"
  98. #define STR_HOSTNAME "HostName"
  99. #define STR_ICONIC "IconicMode"
  100. #define STR_IMSOPTION "ImsOption"
  101. #define STR_ERRORCODE "#ErrorCode"
  102. #define STR_ERRORPATH "#ErrorPath"
  103. #define STR_CONFDATA "#IMSSTART-CONFDATA-1.0"
  104. #define STR_ICONIC_OPT "-iconic"
  105. /* protocol index */
  106. #define Proto_None 0
  107. #define Proto_XIM 1
  108. #define Proto_Ximp 2
  109. #define Proto_Xsi 3
  110. # ifdef old_hpux
  111. #define Proto_Xhp 4
  112. #define NUM_PROTOCOLS 5
  113. # else
  114. #define NUM_PROTOCOLS 4
  115. # endif /* old_hpux */
  116. /* protocol flag */
  117. #define ProtoBit(i) (1<<(i))
  118. /* window state */
  119. #define WIN_ST_NONE 0
  120. #define WIN_ST_INIT 1
  121. #define WIN_ST_REMOTE_CONF 2
  122. #define WIN_ST_REMOTE_RUN 3
  123. #define WIN_ST_ACTION_DONE 4
  124. /* ims server flag */
  125. #define F_NO_SERVER (1<<0)
  126. #define F_NO_REMOTE (1<<1)
  127. #define F_NO_OPTION (1<<2)
  128. #define F_HAS_WINDOW (1<<3)
  129. #define F_TRY_CONNECT (1<<4)
  130. #define F_BUILTIN (1<<8)
  131. /* user selection flag */
  132. #define F_SELECT_NONE 0
  133. #define F_SELECT_FILE (1<<0)
  134. #define F_SELECT_WINDOW (1<<1)
  135. #define F_SELECT_CHANGED (1<<4)
  136. /* select_mode */
  137. #define NUM_SEL_MODE 2
  138. #define SEL_MODE_NOAUTO 0
  139. #define SEL_MODE_AUTO 1
  140. #define SEL_MODE_ONCE 2
  141. #define SEL_MODE_NONE -1
  142. #define SEL_MODE_GIVEN -2
  143. #define SEL_MODE_QUERY -3
  144. #define SEL_MODE_WIN -4
  145. /* host type */
  146. #define HOST_LOCAL 0
  147. #define HOST_REMOTE 1
  148. #define HOST_UNKNOWN 2
  149. # ifdef old_hpux
  150. /* index for XhpLocale */
  151. #define XHP_JPN 0
  152. #define XHP_KOR 1
  153. #define XHP_CHS 2
  154. #define XHP_CHT 3
  155. #define XHP_LANG_NUM 4
  156. # endif /* old_hpux */
  157. /* message type for put_msg_win() */
  158. #define MSGTYP_INFO 0
  159. #define MSGTYP_WARN 1
  160. #define MSGTYP_FATAL 2
  161. #define MSGTYP_CONFIRM 3
  162. /* help message type for ximsHelp() */
  163. #define HELP_SELECTION 0
  164. #define HELP_MODE 1
  165. /* actions internally used */
  166. #define ACT_GETREMCONF 0
  167. #define ACT_RUNREMIMS 1
  168. #define NUM_ACTIONS 2
  169. #define ACTION_MASK 0xf0
  170. typedef short bool;
  171. /* operation states */
  172. typedef enum {
  173. State_None = 0,
  174. State_Init,
  175. State_Init_Err,
  176. State_Init_Done,
  177. State_Select,
  178. State_Select_Err,
  179. State_Select_Canceled,
  180. State_Select_Done,
  181. State_Start,
  182. State_Start_Err,
  183. State_Start_Done,
  184. State_Wait,
  185. State_Wait_Err,
  186. State_Wait_Done,
  187. State_Finish,
  188. State_Finish_Err,
  189. State_Finish_Defered,
  190. State_Finish_Done,
  191. State_Mode,
  192. State_Mode_Canceled,
  193. State_Mode_Done,
  194. State_Action_Invoked,
  195. State_Action_Waiting,
  196. State_Action_Done,
  197. State_Action_Err,
  198. State_Last
  199. } OpStateVal;
  200. /* structure definitions */
  201. typedef struct {
  202. char *name;
  203. char *value;
  204. } EnvEnt;
  205. typedef struct {
  206. char *ims_name;
  207. char *opt_str;
  208. } ImsOpt;
  209. typedef struct {
  210. EnvEnt *set;
  211. EnvEnt *unset;
  212. } OutEnv;
  213. # ifdef old_hpux
  214. typedef struct {
  215. char *name;
  216. char *aliases;
  217. } LocaleAlias;
  218. typedef struct {
  219. char type;
  220. char *locales;
  221. } XhpLocale;
  222. typedef struct {
  223. char *confDir; /* override /etc/vue/config */
  224. char *userDir; /* override .vue */
  225. char *uselite; /* $HOME/.vue/sessions/usevuelite */
  226. char *resPath; /* path of session resource (colon separated) */
  227. char *litePath;
  228. } VueEnv;
  229. # endif /* old_hpux */
  230. typedef struct {
  231. char *confDir; /* override /usr/dt/config */
  232. char *userDir; /* override .dt */
  233. char *resPath; /* path of session resource (colon separated) */
  234. } DtEnv;
  235. typedef struct {
  236. bool disabled; /* disable remote execution */
  237. bool useRemsh; /* use remsh(1) instead of action */
  238. int timeout; /* timeout for remote execution */
  239. char *passEnv; /* env vars passed to remote IMS */
  240. } RemoteEnv;
  241. typedef struct {
  242. int flags;
  243. int protocols;
  244. int timeout;
  245. int interval;
  246. char *servername;
  247. char *servername2;
  248. char *classname;
  249. char *property;
  250. char *cmd_path;
  251. char *cmd_param;
  252. char *env_set;
  253. char *env_unset;
  254. char *env_pass;
  255. } ImsConf;
  256. typedef struct {
  257. int status;
  258. char *name;
  259. char *fname;
  260. char *label;
  261. ImsConf *ims;
  262. } ImsEnt;
  263. typedef struct {
  264. short status;
  265. short default_idx;
  266. short def_selmode;
  267. short num_ent;
  268. ImsEnt **elist;
  269. } ImsList;
  270. typedef struct {
  271. int status;
  272. int wait_status;
  273. pid_t pid;
  274. bool is_remote;
  275. int proto;
  276. char *im_mod;
  277. char *atom_name;
  278. char *cmdbuf;
  279. Atom prop_atom;
  280. } RunEnv;
  281. typedef struct {
  282. bool dpy_specific;
  283. short select_mode;
  284. short iconic;
  285. char *name;
  286. char *hostname;
  287. char *com_opt;
  288. ImsOpt **opts;
  289. char *real_fname; /* actually read */
  290. } FileSel;
  291. typedef struct {
  292. int flag; /* F_SELECT_* */
  293. int status; /* error code */
  294. int ims_idx; /* index of selected ims to list->elist[] */
  295. int host_type; /* host type: HOST_{LOCAL|REMOTE|UNKNOWN} */
  296. int iconic; /* iconic mode: */
  297. char *name; /* selected ims */
  298. char *hostname; /* current host */
  299. ImsList *list; /* current list */
  300. ImsEnt *ent; /* selected ims ent */
  301. FileSel *fsel; /* original selection on file */
  302. RunEnv *renv; /* run env used on start.c & env.c */
  303. } UserSelection;
  304. typedef struct {
  305. char *hostname;
  306. char *username;
  307. char *locale;
  308. char *real_locale;
  309. char *CDE_locale;
  310. char **locale_aliases;
  311. char *homedir;
  312. char *displayname;
  313. char *displaydir;
  314. char *xmodifiers;
  315. short screen_num;
  316. } UserEnv;
  317. typedef struct {
  318. char *DisplayName; /* override $DISPLAY */
  319. char *LocaleName; /* override $LANG */
  320. char *ConfPath; /* override $CONF/start.conf */
  321. char *UserPath; /* override $HOME/.xims/<locale> */
  322. char *LogPath; /* override $HOME/.xims/ximslog */
  323. char *ResourceFile; /* resource file for IMS */
  324. char *ImsName; /* IMS name */
  325. char *ImsOption; /* IMS option */
  326. char *HostName; /* remote host name */
  327. char *ShellName; /* shell name */
  328. int Timeout; /* wait timeout (sec) */
  329. int Interval; /* check interval (msec) */
  330. int SelectMode; /* SEL_MODE_* */
  331. int Listname; /* Used only from dtstyle */
  332. } CmdOpt;
  333. typedef struct {
  334. char *imsConfDir; /* [%I] /usr/dt/config/ims/ */
  335. char *imsAppDir; /* [%R] /usr/dt/app-defaults/ */
  336. char *imsLogDir; /* [%G] /var/dt/ */
  337. char *imsLogFile; /* [%g] imslog */
  338. char *imsDir; /* [%b] ims */
  339. char *userImsDir; /* [%S] $HOME/.dt/ims/ */
  340. char *userTmpDir; /* [%T] $HOME/.dt/tmp/ */
  341. char *userAltDir; /* [%A] alt tmp /var/tmp/ */
  342. char *xmod[NUM_PROTOCOLS]; /* format of XMODIFIERS */
  343. char *atom[NUM_PROTOCOLS]; /* atom name to be examined */
  344. char *action[NUM_ACTIONS]; /* actions internally used */
  345. DtEnv *dt;
  346. RemoteEnv *remote;
  347. # ifdef old_hpux
  348. VueEnv *vue;
  349. XhpLocale *xhp;
  350. LocaleAlias **alias;
  351. # endif /* old_hpux */
  352. } CmdConf;
  353. typedef struct {
  354. int status;
  355. Display *Dpy;
  356. Widget TopW;
  357. Window atom_owner;
  358. Atom atom_main;
  359. Atom atom_status;
  360. Atom atom_data;
  361. XtAppContext appC;
  362. } WinEnv;
  363. /* Global Variables */
  364. extern char *ProgramRevision; /* on main.c */
  365. extern Display *Dpy; /* display (on win.c) */
  366. extern Widget TopW; /* toplevel-shell (on win.c) */
  367. extern XtAppContext appC;
  368. # ifdef _EXTERN_DEFINE_
  369. #define Extern
  370. # else
  371. #define Extern extern
  372. # endif /* _EXTERN_DEFINE_ */
  373. Extern OpStateVal OpState;
  374. Extern int OpMode; /* one of MODE_* */
  375. Extern int OpFlag; /* bitOR of FLAG_* */
  376. Extern CmdOpt Opt; /* command line options */
  377. Extern CmdConf Conf;
  378. Extern WinEnv winEnv;
  379. Extern UserEnv userEnv;
  380. Extern UserSelection userSel;
  381. Extern ImsList *localList;
  382. Extern char *ProgramName; /* invoked program name */
  383. Extern int ProgramType; /* same as OpMode */
  384. Extern int Verbose; /* verbose flag */
  385. Extern int DebugLvl; /* debug flag */
  386. Extern FILE *LogFp; /* log file */
  387. Extern int Wargc; /* argc for XtAppInitialize */
  388. Extern char **Wargv; /* argv for XtAppInitialize */
  389. Extern bool WaitingDialogReply;
  390. Extern bool WaitingActionDone;
  391. Extern bool UseMsgWindow;
  392. Extern bool IsRemote;
  393. Extern int LastErrMsg;
  394. #undef Extern
  395. # ifdef old_hpux
  396. #define isXsession() ((OpFlag & (FLAG_VUE|FLAG_DT)) ? True : False)
  397. #define isVUE() ((OpFlag & FLAG_VUE) ? True : False)
  398. # else
  399. #define isXsession() ((OpFlag & FLAG_DT) ? True : False)
  400. #define isVUE() (False)
  401. # endif /* old_hpux */
  402. #define isDT() ((OpFlag & FLAG_DT) ? True : False)
  403. #define useWINDOW() \
  404. (((OpFlag & USE_WINDOW_MASK) || window_env_ok()) ? True : False)
  405. #define RemoteOn() \
  406. (((OpFlag & FLAG_NOREMOTE) || Conf.remote->disabled) ? False : True)
  407. #include "ximsfunc.h"
  408. #endif /* _XIMS_H_ */