xims.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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. #define FLAG_DEFAULT (FLAG_DT)
  68. #define USE_WINDOW_MASK (FLAG_WINDOW|FLAG_DT)
  69. #define MAXIMSENT 32 /* max # of ims for each locale */
  70. #define MIN_INTERVAL 100 /* msec */
  71. #define DEFAULT_INTERVAL 1000 /* msec */
  72. #define MIN_TIMEOUT 1 /* sec */
  73. #define DEFAULT_TIMEOUT 180 /* sec */
  74. #define REMOTE_TIMEOUT 60 /* sec */
  75. #define TAG_END_CHAR ':'
  76. #define TAG_SEP_CHAR '.'
  77. #define LIST_SEP_CHAR ','
  78. #define COMMENT_CHAR '!'
  79. #define COMMENT_CHAR2 '#'
  80. #define COMMENT_CHARS "!#"
  81. #define NAME_NONE "none"
  82. #define NAME_LOCAL "local"
  83. #define NAME_BUILTIN "builtin"
  84. #define NAME_DEFAULT "@"
  85. #define NAME_DEFAULT_CHAR '@'
  86. #define DUMMY_SERVER_NAME NAME_DEFAULT
  87. #define STR_PREFIX_CHAR '@'
  88. #define STR_DEFAULTIMS "DefaultIms"
  89. #define STR_SELECTMODE "SelectMode"
  90. #define STR_IMSNAME "ImsName"
  91. #define STR_HOSTNAME "HostName"
  92. #define STR_ICONIC "IconicMode"
  93. #define STR_IMSOPTION "ImsOption"
  94. #define STR_ERRORCODE "#ErrorCode"
  95. #define STR_ERRORPATH "#ErrorPath"
  96. #define STR_CONFDATA "#IMSSTART-CONFDATA-1.0"
  97. #define STR_ICONIC_OPT "-iconic"
  98. /* protocol index */
  99. #define Proto_None 0
  100. #define Proto_XIM 1
  101. #define Proto_Ximp 2
  102. #define Proto_Xsi 3
  103. #define NUM_PROTOCOLS 4
  104. /* protocol flag */
  105. #define ProtoBit(i) (1<<(i))
  106. /* window state */
  107. #define WIN_ST_NONE 0
  108. #define WIN_ST_INIT 1
  109. #define WIN_ST_REMOTE_CONF 2
  110. #define WIN_ST_REMOTE_RUN 3
  111. #define WIN_ST_ACTION_DONE 4
  112. /* ims server flag */
  113. #define F_NO_SERVER (1<<0)
  114. #define F_NO_REMOTE (1<<1)
  115. #define F_NO_OPTION (1<<2)
  116. #define F_HAS_WINDOW (1<<3)
  117. #define F_TRY_CONNECT (1<<4)
  118. #define F_BUILTIN (1<<8)
  119. /* user selection flag */
  120. #define F_SELECT_NONE 0
  121. #define F_SELECT_FILE (1<<0)
  122. #define F_SELECT_WINDOW (1<<1)
  123. #define F_SELECT_CHANGED (1<<4)
  124. /* select_mode */
  125. #define NUM_SEL_MODE 2
  126. #define SEL_MODE_NOAUTO 0
  127. #define SEL_MODE_AUTO 1
  128. #define SEL_MODE_ONCE 2
  129. #define SEL_MODE_NONE -1
  130. #define SEL_MODE_GIVEN -2
  131. #define SEL_MODE_QUERY -3
  132. #define SEL_MODE_WIN -4
  133. /* host type */
  134. #define HOST_LOCAL 0
  135. #define HOST_REMOTE 1
  136. #define HOST_UNKNOWN 2
  137. /* message type for put_msg_win() */
  138. #define MSGTYP_INFO 0
  139. #define MSGTYP_WARN 1
  140. #define MSGTYP_FATAL 2
  141. #define MSGTYP_CONFIRM 3
  142. /* help message type for ximsHelp() */
  143. #define HELP_SELECTION 0
  144. #define HELP_MODE 1
  145. /* actions internally used */
  146. #define ACT_GETREMCONF 0
  147. #define ACT_RUNREMIMS 1
  148. #define NUM_ACTIONS 2
  149. #define ACTION_MASK 0xf0
  150. typedef short bool;
  151. /* operation states */
  152. typedef enum {
  153. State_None = 0,
  154. State_Init,
  155. State_Init_Err,
  156. State_Init_Done,
  157. State_Select,
  158. State_Select_Err,
  159. State_Select_Canceled,
  160. State_Select_Done,
  161. State_Start,
  162. State_Start_Err,
  163. State_Start_Done,
  164. State_Wait,
  165. State_Wait_Err,
  166. State_Wait_Done,
  167. State_Finish,
  168. State_Finish_Err,
  169. State_Finish_Defered,
  170. State_Finish_Done,
  171. State_Mode,
  172. State_Mode_Canceled,
  173. State_Mode_Done,
  174. State_Action_Invoked,
  175. State_Action_Waiting,
  176. State_Action_Done,
  177. State_Action_Err,
  178. State_Last
  179. } OpStateVal;
  180. /* structure definitions */
  181. typedef struct {
  182. char *name;
  183. char *value;
  184. } EnvEnt;
  185. typedef struct {
  186. char *ims_name;
  187. char *opt_str;
  188. } ImsOpt;
  189. typedef struct {
  190. EnvEnt *set;
  191. EnvEnt *unset;
  192. } OutEnv;
  193. typedef struct {
  194. char *confDir; /* override /usr/dt/config */
  195. char *userDir; /* override .dt */
  196. char *resPath; /* path of session resource (colon separated) */
  197. } DtEnv;
  198. typedef struct {
  199. bool disabled; /* disable remote execution */
  200. bool useRemsh; /* use remsh(1) instead of action */
  201. int timeout; /* timeout for remote execution */
  202. char *passEnv; /* env vars passed to remote IMS */
  203. } RemoteEnv;
  204. typedef struct {
  205. int flags;
  206. int protocols;
  207. int timeout;
  208. int interval;
  209. char *servername;
  210. char *servername2;
  211. char *classname;
  212. char *property;
  213. char *cmd_path;
  214. char *cmd_param;
  215. char *env_set;
  216. char *env_unset;
  217. char *env_pass;
  218. } ImsConf;
  219. typedef struct {
  220. int status;
  221. char *name;
  222. char *fname;
  223. char *label;
  224. ImsConf *ims;
  225. } ImsEnt;
  226. typedef struct {
  227. short status;
  228. short default_idx;
  229. short def_selmode;
  230. short num_ent;
  231. ImsEnt **elist;
  232. } ImsList;
  233. typedef struct {
  234. int status;
  235. int wait_status;
  236. pid_t pid;
  237. bool is_remote;
  238. int proto;
  239. char *im_mod;
  240. char *atom_name;
  241. char *cmdbuf;
  242. Atom prop_atom;
  243. } RunEnv;
  244. typedef struct {
  245. bool dpy_specific;
  246. short select_mode;
  247. short iconic;
  248. char *name;
  249. char *hostname;
  250. char *com_opt;
  251. ImsOpt **opts;
  252. char *real_fname; /* actually read */
  253. } FileSel;
  254. typedef struct {
  255. int flag; /* F_SELECT_* */
  256. int status; /* error code */
  257. int ims_idx; /* index of selected ims to list->elist[] */
  258. int host_type; /* host type: HOST_{LOCAL|REMOTE|UNKNOWN} */
  259. int iconic; /* iconic mode: */
  260. char *name; /* selected ims */
  261. char *hostname; /* current host */
  262. ImsList *list; /* current list */
  263. ImsEnt *ent; /* selected ims ent */
  264. FileSel *fsel; /* original selection on file */
  265. RunEnv *renv; /* run env used on start.c & env.c */
  266. } UserSelection;
  267. typedef struct {
  268. char *hostname;
  269. char *username;
  270. char *locale;
  271. char *real_locale;
  272. char *CDE_locale;
  273. char **locale_aliases;
  274. char *homedir;
  275. char *displayname;
  276. char *displaydir;
  277. char *xmodifiers;
  278. short screen_num;
  279. } UserEnv;
  280. typedef struct {
  281. char *DisplayName; /* override $DISPLAY */
  282. char *LocaleName; /* override $LANG */
  283. char *ConfPath; /* override $CONF/start.conf */
  284. char *UserPath; /* override $HOME/.xims/<locale> */
  285. char *LogPath; /* override $HOME/.xims/ximslog */
  286. char *ResourceFile; /* resource file for IMS */
  287. char *ImsName; /* IMS name */
  288. char *ImsOption; /* IMS option */
  289. char *HostName; /* remote host name */
  290. char *ShellName; /* shell name */
  291. int Timeout; /* wait timeout (sec) */
  292. int Interval; /* check interval (msec) */
  293. int SelectMode; /* SEL_MODE_* */
  294. int Listname; /* Used only from dtstyle */
  295. } CmdOpt;
  296. typedef struct {
  297. char *imsConfDir; /* [%I] /usr/dt/config/ims/ */
  298. char *imsAppDir; /* [%R] /usr/dt/app-defaults/ */
  299. char *imsLogDir; /* [%G] /var/dt/ */
  300. char *imsLogFile; /* [%g] imslog */
  301. char *imsDir; /* [%b] ims */
  302. char *userImsDir; /* [%S] $HOME/.dt/ims/ */
  303. char *userTmpDir; /* [%T] $HOME/.dt/tmp/ */
  304. char *userAltDir; /* [%A] alt tmp /var/tmp/ */
  305. char *xmod[NUM_PROTOCOLS]; /* format of XMODIFIERS */
  306. char *atom[NUM_PROTOCOLS]; /* atom name to be examined */
  307. char *action[NUM_ACTIONS]; /* actions internally used */
  308. DtEnv *dt;
  309. RemoteEnv *remote;
  310. } CmdConf;
  311. typedef struct {
  312. int status;
  313. Display *Dpy;
  314. Widget TopW;
  315. Window atom_owner;
  316. Atom atom_main;
  317. Atom atom_status;
  318. Atom atom_data;
  319. XtAppContext appC;
  320. } WinEnv;
  321. /* Global Variables */
  322. extern char *ProgramRevision; /* on main.c */
  323. extern Display *Dpy; /* display (on win.c) */
  324. extern Widget TopW; /* toplevel-shell (on win.c) */
  325. extern XtAppContext appC;
  326. # ifdef _EXTERN_DEFINE_
  327. #define Extern
  328. # else
  329. #define Extern extern
  330. # endif /* _EXTERN_DEFINE_ */
  331. Extern OpStateVal OpState;
  332. Extern int OpMode; /* one of MODE_* */
  333. Extern int OpFlag; /* bitOR of FLAG_* */
  334. Extern CmdOpt Opt; /* command line options */
  335. Extern CmdConf Conf;
  336. Extern WinEnv winEnv;
  337. Extern UserEnv userEnv;
  338. Extern UserSelection userSel;
  339. Extern ImsList *localList;
  340. Extern char *ProgramName; /* invoked program name */
  341. Extern int ProgramType; /* same as OpMode */
  342. Extern int Verbose; /* verbose flag */
  343. Extern int DebugLvl; /* debug flag */
  344. Extern FILE *LogFp; /* log file */
  345. Extern int Wargc; /* argc for XtAppInitialize */
  346. Extern char **Wargv; /* argv for XtAppInitialize */
  347. Extern bool WaitingDialogReply;
  348. Extern bool WaitingActionDone;
  349. Extern bool UseMsgWindow;
  350. Extern bool IsRemote;
  351. Extern int LastErrMsg;
  352. #undef Extern
  353. #define isXsession() ((OpFlag & FLAG_DT) ? True : False)
  354. #define isVUE() (False)
  355. #define isDT() ((OpFlag & FLAG_DT) ? True : False)
  356. #define useWINDOW() \
  357. (((OpFlag & USE_WINDOW_MASK) || window_env_ok()) ? True : False)
  358. #define RemoteOn() \
  359. (((OpFlag & FLAG_NOREMOTE) || Conf.remote->disabled) ? False : True)
  360. #include "ximsfunc.h"
  361. #endif /* _XIMS_H_ */