Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
#!/usr/bin/ksh
#####################################################################
### File: 0020.dtims
###
### Default Location: /usr/dt/config/Xsession.d/
###
### Purpose: Start desktop input method server if required
###
### Description:
### This script is invoked by means of the Xsession file
### at user login. It starts an input method server as
### required for selected locales.
###
### Invoked by: /usr/dt/bin/Xsession
###
### Product: @(#)Common Desktop Environment 1.0
###
### Note:
###
### The /usr/dt/config/Xsession.d/0020.dtims file is a
### factory-default file and will be unconditionally overwritten upon
### subsequent installation. To customize input method server startup
### behavior, copy this file to the configuration directory,
### /etc/dt/config/Xsession.d and customize that version
### of the file.
###
### The value of DTSTARTIMS determines whether this file,
### /usr/dt/config/Xsession.d/0020.dtims, will start
### the specified input method server. Should an input method server
### be started from /etc/dt/config/Xsession.d/0020.dtims
### or should an input method server not be desired, unset DTSTARTIMS
### to prevent this file from starting one.
###
### The general logic of this file is:
###
### if [ "$DTSTARTIMS" = "True" ]
### then
### <start input method server>
### unset DTSTARTIMS
### fi
###
### Revision: $XConsortium: 0020.dtims /main/2 1996/07/18 14:23:41 drk $
###
### (c) Copyright 1993, 1994 Hewlett-Packard Company
### (c) Copyright 1993, 1994 International Business Machines Corp.
### (c) Copyright 1993, 1994 Sun Microsystems, Inc.
### (c) Copyright 1993, 1994 Novell, Inc.
###
#####################################################################
if [ "$DTSTARTIMS" = "True" ]
then
#
# Start HP platform IM (Input Method) server for Asian locales.
#
if [[ -z "${CDE_IMS_PID:-}" ]]
then
case "$LANG" in
ja_JP* | japanese* | \
ko_KR* | korean* | \
zh_TW* | chinese-t* | \
zh_CN* | chinese-s* )
DTIMS_SCRIPT=0020.dtims
DTIMS_CMD="/usr/dt/bin/dtimsstart -env -shell ksh"
if [[ -x "${DTIMS_CMD%% *}" ]]; then
# execute DTIMS_CMD and 'eval' its output
Log "$DTIMS_SCRIPT: \"${DTIMS_CMD%% *}\" started."
eval ` $DTIMS_CMD `
# set CDE_IMS_PID to 0 (IMS started, but its pid is unknown.)
CDE_IMS_PID=0
else
Log "$DTIMS_SCRIPT: \"${DTIMS_CMD%% *}\" not found."
fi
unset DTIMS_CMD DTIMS_SCRIPT
;;
esac
unset DTSTARTIMS
fi
fi
########################## eof #####################

View File

@@ -0,0 +1,58 @@
!# @(#)$XConsortium: Dtimsstart /main/3 1996/09/20 18:08:17 cde-hp $
! dtimsstart
*fontList: %|nls-1-#-dt-interface user-medium-r-normal-m*-*-*-*-*-m-*:#|
! title on title bar
Dtimsstart*title: %|nls-2-#dtimsstart#|
! title
Dtimsstart*Selection*title.labelString: %|nls-3-#Input Method Selection#|
Dtimsstart*Host*title.labelString: %|nls-4-#Change Host#|
Dtimsstart*Mode*title.labelString: %|nls-5-#Input Method Selection Mode#|
! button label
Dtimsstart*OK.labelString: %|nls-6-#OK#|
Dtimsstart*Clear.labelString: %|nls-7-#Clear#|
Dtimsstart*Cancel.labelString: %|nls-8-#Cancel#|
Dtimsstart*ChangeHost.labelString: %|nls-9-#Change Host#|
Dtimsstart*Help.labelString: %|nls-10-#Help#|
! border width (selection dialog appears without window manager)
Dtimsstart*Selection.borderWidth: %|nls-11-#3#|
Dtimsstart*Host.borderWidth: %|nls-12-#3#|
Dtimsstart*XmDialogShell.borderWidth: %|nls-13-#0#|
! default spacing
Dtimsstart*cmd_rc.marginWidth: %|nls-14-#10#|
Dtimsstart*cmd_rc.spacing: %|nls-15-#10#|
! ims selection dialog
Dtimsstart*Selection*cmd_rc.spacing: %|nls-16-#4#|
Dtimsstart*Selection*cmd_rc.OK.marginWidth: %|nls-17-#16#|
Dtimsstart*Selection*select_rc.marginWidth: %|nls-18-#40#|
! change host dialog
Dtimsstart*host_label.labelString: %|nls-19-#Hostname:#|
Dtimsstart*Host*host_desc.alignment: %|nls-20-#XmALIGNMENT_BEGINNING#|
Dtimsstart*Host*host_desc.marginLeft: %|nls-21-#20#|
Dtimsstart*Host*host_desc.marginRight: %|nls-22-#20#|
Dtimsstart*Host*host_desc.labelString: %|nls-23-#Enter hostname message#|
Dtimsstart*Host*host_text.maxLength: %|nls-24-#63#|
Dtimsstart*Host*host_text.columns: %|nls-25-#14#|
Dtimsstart*Host*host_rc.marginWidth: %|nls-26-#60#|
Dtimsstart*Host*cmd_rc.marginWidth: %|nls-27-#20#|
Dtimsstart*Host*cmd_rc.spacing: %|nls-28-#90#|
! selection mode dialog
Dtimsstart*Mode*button_0.labelString: %|nls-29-#Ask at login#|
Dtimsstart*Mode*button_1.labelString: %|nls-30-#Resume current input method#|
Dtimsstart*Mode*cmd_rc.spacing: %|nls-31-#50#|
Dtimsstart*Mode*cmd_rc.marginWidth: %|nls-32-#20#|
! help message
Dtimsstart.selectionHelpMsg: %|nls-33-#Input method selection help#|
Dtimsstart.modeHelpMsg: %|nls-34-#IM Selection mode help#|
!#

View File

@@ -0,0 +1,39 @@
XCOMM $XConsortium: Imakefile /main/8 1996/04/21 19:55:32 drk $
DEFINES = -DNLS
INCLUDES = -I. -I$(CDELIBSRC)
#if defined (SunArchitecture)
DEPLIBS = $(DEPDTSVCLIB) $(DEPTTLIB) \
$(DEPXMLIB) $(DEPXTOOLLIB) $(DEPXPLIB) $(DEPXLIB)
LOCAL_LIBRARIES = $(DTSVCLIB) $(TTLIB) \
$(XMLIB) $(XTOOLLIB) $(XPLIB) $(XLIB)
#else
DEPLIBS = $(DEPDTHELPLIB) $(DEPDTSVCLIB) $(DEPTTLIB) \
$(DEPXMLIB) $(DEPXTOOLLIB) $(DEPXPLIB) $(DEPXLIB)
LOCAL_LIBRARIES = $(DTHELPLIB) $(DTSVCLIB) $(TTLIB) \
$(XMLIB) $(XTOOLLIB) $(XPLIB) $(XLIB)
#endif /* SunArchitecture */
SYS_LIBRARIES = DtClientSysLibs
#if defined (SunArchitecture)
EXTRA_CCOPTIONS = -xF
#endif
#if defined (RsArchitecture)
EXTRA_DEFINES = -DANSICPP
#endif /* RsArchitecture */
PROGRAMS=dtimsstart
SRCS = action.c env.c file.c \
main.c remote.c select.c \
start.c util.c win.c
OBJS = action.o env.o file.o \
main.o remote.o select.o \
start.o util.o win.o
ComplexProgramTarget($(PROGRAMS))

View File

@@ -0,0 +1,221 @@
/* @(#)$XConsortium: action.c /main/3 1996/05/07 13:57:56 drk $ */
#include <Xm/Xm.h>
#include <Dt/Dt.h>
#include <Dt/Action.h>
#include "xims.h"
static void DbReloadProc(/* cd */);
static bool init_action_env(/* */);
static void action_cb(DtActionInvocationID id, XtPointer cd,
DtActionArg *args, int argcnt, int status);
static void wait_action_done(/* */);
static bool actionEnabled = False;
static int actionDone = True;
static int actionErr = NoError;
static DtActionInvocationID actionId = 0;
/* ***** DtAction functions ***** */
static void DbReloadProc(cd)
XtPointer cd;
{
DPR(("DbReloadProc(): action database updated\n"));
DtDbLoad(); /* Pick up any dynamic changes to the database files */
}
static bool init_action_env()
{
init_window_env();
if (actionEnabled != True) {
if (DtAppInitialize(appC, Dpy, TopW, Wargv[0], DTIMS_CLASS) == False) {
/* DtInitialize() has already logged an appropriate error msg */
return False;
}
DtDbLoad(); /* Load the filetype/action databases */
DtDbReloadNotify(DbReloadProc, NULL);
actionEnabled = True;
}
return actionEnabled;
}
static void action_cb(id, cd, args, argcnt, status)
DtActionInvocationID id;
XtPointer cd; /* unused */
DtActionArg *args;
int argcnt;
int status;
{
if (actionId == 0) {
DPR(("action_cb(): invalid id %d != %d\n", id, actionId));
return;
}
if (id != actionId) {
DPR(("action_cb(): invalid id %d != %d\n", id, actionId));
return;
}
switch ((DtActionStatus) status) {
case DtACTION_INVOKED:
DPR((" ACTION_INVOKED\n"));
break;
case DtACTION_DONE:
DPR((" ACTION_DONE\n"));
actionId = 0;
actionDone = True;
break;
case DtACTION_CANCELED:
case DtACTION_FAILED:
DPR((" ACTION_%sED\n",
(status == DtACTION_CANCELED) ? "CANCEL" : "FAIL"));
if (args && argcnt > 0) {
int i;
for (i = 0; i < argcnt; i++) {
if (args[i].argClass == DtACTION_FILE) {
XtFree(args[i].u.file.name);
} else if (args[i].argClass == DtACTION_BUFFER) {
XtFree(args[i].u.buffer.bp);
XtFree(args[i].u.buffer.type);
XtFree(args[i].u.buffer.name);
}
}
XtFree((void *)args);
}
actionId = 0;
actionDone = False;
break;
case DtACTION_STATUS_UPDATE:
DPR((" ACTION_STATUS_UPDATE\n"));
actionDone = False;
break;
default: /* ignore */
DPR((" unknown status (%d)\n", status));
break;
}
if (actionId == 0) { /* action done */
send_dtims_msg(WIN_ST_ACTION_DONE, actionDone ? NoError : ErrRemoteAction);
}
return;
}
static void wait_action_done()
{
XEvent event;
DPR(("wait_action_done(): Begin\n"));
if (actionId == 0) return;
XtSetSensitive(TopW, False);
XtAddEventHandler(TopW, NoEventMask, True, dtims_msg_proc, 0);
while (actionId != 0 || actionErr != NoError) {
XtAppNextEvent(appC, &event);
XtDispatchEvent(&event);
}
XtRemoveEventHandler(TopW, XtAllEvents, True, dtims_msg_proc, 0);
XtSetSensitive(TopW, True);
DPR(("wait_action_done(): End\n"));
return;
}
int invoke_action(action, host)
char *action;
char *host;
{
if (init_action_env() != True) return ErrInternal;
DPR(("invoke_action(%s): host=%s\n", action, host));
if (!action || !*action) return ErrInternal;
if (host && !*host) host = NULL;
setErrFunc(action);
#ifdef DEBUG
if (DtActionExists(action) != True) {
DPR(("invoke_action(%s): action not exists\n", action));
}
#endif
/* Invoke the specified action */
actionId = DtActionInvoke(TopW, action, NULL, 0,
NULL, host, NULL, False, action_cb, NULL);
DPR(("invoke_action(%s): actionId=%d\n", actionId));
wait_action_done();
return actionErr;
}
void send_dtims_msg(msg, errcode)
int msg, errcode;
{
XEvent ev;
ev.xclient.type = ClientMessage;
ev.xclient.window = winEnv.atom_owner;
ev.xclient.message_type = winEnv.atom_status;
ev.xclient.format = 32;
ev.xclient.data.l[0] = msg;
ev.xclient.data.l[1] = errcode;
ev.xclient.data.l[2] = ev.xclient.data.l[3] = ev.xclient.data.l[4] = 0L;
XSendEvent(Dpy, XtWindow(TopW), False, NoEventMask, &ev);
}
void dtims_msg_proc(w, cd, event, continue_dispatch)
Widget w;
XtPointer cd;
XEvent *event;
Boolean *continue_dispatch; /* never changed */
{
XClientMessageEvent *ev = &event->xclient;
int msg, errcode;
DPR(("dtimsMessageProc()\n"));
if (event->type != ClientMessage) return;
if (ev->message_type != winEnv.atom_status && ev->format != 32) {
DPR(("\tinvalid type([%d]%s) or format(%d) -- ignored\n",
ev->message_type, XGetAtomName(Dpy, ev->message_type), ev->format));
return;
}
msg = (int)ev->data.l[0];
errcode = (int)ev->data.l[1];
switch (msg) {
case WIN_ST_REMOTE_CONF:
case WIN_ST_REMOTE_RUN:
actionId = 0;
case WIN_ST_ACTION_DONE:
DPR(("\tmsg=%d errcode=%d\n", msg, errcode));
actionErr = errcode;
break;
default:
DPR(("\tunknown msg value (%d) -- ignored\n", msg));
break;
}
return;
}

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: 組み込み日本語IM
!! no input method
none: 日本語入力なし

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: 組み込み日本語IM
!! no input method
none: 日本語入力なし

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: [Need T9N]Built-in Chinese IM
!! no input method
none: [Need T9N]No Chinese Input Method

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: [Need T9N]Built-in Chinese IM
!! no input method
none: [Need T9N]No Chinese Input Method

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: [Need T9N]Built-in Taiwanese IM
!! no input method
none: [Need T9N]No Taiwanese Input Method

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: [Need T9N]Built-in Taiwanese IM
!! no input method
none: [Need T9N]No Taiwanese Input Method

View File

@@ -0,0 +1,8 @@
protocols: Ximp, Xsi
server_name: aixims
class_name: Aixims
cmd_path: /usr/bin/X11/aixims
cmd_param:
env_set:
env_unset:
has_window: False

View File

@@ -0,0 +1,5 @@
protocols: None
env_set:
env_unset:
no_server: true
has_window: false

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: 組み込み日本語IM
!! no input method
none: 日本語入力なし

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: 組み込み日本語IM
!! no input method
none: 日本語入力なし

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: [Need T9N]Built-in Korean IM
!! no input method
none: [Need T9N]No Korean Input Method

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: [Need T9N]Built-in Korean IM
!! no input method
none: [Need T9N]No Korean Input Method

View File

@@ -0,0 +1,5 @@
protocols: None
env_set:
env_unset:
no_server: true
has_window: false

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: [Need T9N]Built-in Chinese IM
!! no input method
none: [Need T9N]No Chinese Input Method

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: [Need T9N]Built-in Chinese IM
!! no input method
none: [Need T9N]No Chinese Input Method

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: [Need T9N]Built-in Taiwanese IM
!! no input method
none: [Need T9N]No Taiwanese Input Method

View File

@@ -0,0 +1,7 @@
@DefaultIms: builtin
!! Ximp, Xsi
aixims: IBM AIX Input Method Server
!! builtin input method
builtin: [Need T9N]Built-in Taiwanese IM
!! no input method
none: [Need T9N]No Taiwanese Input Method

View File

@@ -0,0 +1,5 @@
protocols: None
env_set:
env_unset:
no_server: true
has_window: false

View File

@@ -0,0 +1,8 @@
protocols: XIM, DECXim
server_name: _XIM_ja_JP@DEC
class_name: DXjim
cmd_path: /usr/i18n/bin/X11/dxjim
cmd_param:
env_set:
env_unset:
has_window: True

View File

@@ -0,0 +1,7 @@
@DefaultIms: dxjim
!! XIM
dxjim: Digital Japanese Input Method
!! builtin input method
builtin: Builtin Japanese Input Method
!! no input method
none: No Input Method

View File

@@ -0,0 +1,5 @@
protocols: None
env_set:
env_unset:
no_server: true
has_window: false

View File

@@ -0,0 +1,10 @@
!# $XConsortium: atok8 /main/2 1996/07/18 14:24:08 drk $
protocols: Ximp
server_name: atok8
class_name: Atok8
cmd_path: /opt/atok/bin/atok8
cmd_param:
env_set:
env_unset:
has_window: true
!#

View File

@@ -0,0 +1,11 @@
!# $XConsortium: builtin.jpn /main/2 1996/07/18 14:24:24 drk $
protocols: XIM Ximp
server_name: jpn
class_name:
cmd_path: builtin
cmd_param:
env_set:
env_unset:
no_server: true
has_window: flase
!#

View File

@@ -0,0 +1,10 @@
!# $XConsortium: egb /main/2 1996/07/18 14:24:37 drk $
protocols: Ximp
server_name: egims
class_name: EGIms
cmd_path: /opt/egb/bin/egims
cmd_param:
env_set:
env_unset:
has_window: true
!#

View File

@@ -0,0 +1,13 @@
!# $Revision: 1.20 $
@DefaultIms: xjim
@SelectMode: 0
!! Ximp
xjim:  
atok8:
vje: γ
egb:
!! builtin input method
builtin.jpn: Built-in Japanese IM
!! no input method
none: 日本語入力なし
!#

View File

@@ -0,0 +1,13 @@
!# $Revision: 1.20 $
@DefaultIms: xjim
@SelectMode: 0
!! Ximp
xjim:  
atok8:
vje: γ
egb:
!! builtin input method
builtin.jpn: Built-in Japanese IM
!! no input method
none: 日本語入力なし
!#

View File

@@ -0,0 +1,8 @@
!# $XConsortium: ko_KR.eucKR /main/2 1996/07/18 14:24:51 drk $
@DefaultIms: xkim
@SelectMode: 1
!! Ximp
xkim: HP XKIM
!! no input method
none: No Input Method
!#

View File

@@ -0,0 +1,7 @@
!# $XConsortium: none /main/2 1996/07/18 14:25:04 drk $
protocols: None
env_set:
env_unset:
no_server: true
has_window: false
!#

View File

@@ -0,0 +1,10 @@
!# $XConsortium: vje /main/2 1996/07/18 14:25:19 drk $
protocols: Ximp
server_name: vje
class_name:
cmd_path: /opt/vje/bin/vje
cmd_param:
env_set:
env_unset:
has_window: true
!#

View File

@@ -0,0 +1,10 @@
!# $XConsortium: xjim /main/2 1996/07/18 14:25:33 drk $
protocols: Ximp Xsi
server_name: xjim
class_name: XJim
cmd_path: /usr/bin/X11/xjim
cmd_param: -useXsi
env_set:
env_unset:
has_window: true
!#

View File

@@ -0,0 +1,10 @@
!# $XConsortium: xkim /main/2 1996/07/18 14:25:48 drk $
protocols: Ximp
server_name: xkim
class_name: XKim
cmd_path: /usr/bin/X11/xkim
cmd_param:
env_set:
env_unset:
has_window: true
!#

View File

@@ -0,0 +1,9 @@
!# $XConsortium: xsim /main/2 1996/07/18 14:26:02 drk $
protocols: Ximp
server_name: xsim
class_name: XSim
cmd_path: /usr/bin/X11/xsim
cmd_param:
env_set:
env_unset:
!#

View File

@@ -0,0 +1,10 @@
!# $XConsortium: xtim /main/2 1996/07/18 14:26:16 drk $
protocols: Ximp
server_name: xtim
class_name: XTim
cmd_path: /usr/bin/X11/xtim
cmd_param:
env_set:
env_unset:
has_window: true
!#

View File

@@ -0,0 +1,8 @@
!# $Revision: 1.20 $
@DefaultIms: xsim
@SelectMode: 1
!! Ximp
xsim: HP XSIM (X 终端简体中文输入法服务程序)
!! no input method
none: 无输入法
!#

View File

@@ -0,0 +1,8 @@
!# $Revision: 1.20 $
@DefaultIms: xtim
@SelectMode: 1
!! Ximp
xtim: HP XTIM(X 終端機中文輸入法伺服器)
!! no input method
none: 無輸入法
!#

View File

@@ -0,0 +1,8 @@
!# $Revision: 1.20 $
@DefaultIms: xtim
@SelectMode: 1
!! Ximp
xtim: HP XTIM(X 址冏遂〃咋聰ら尊<E288A8>)
!! no input method
none: 奈聰ら尊
!#

View File

@@ -0,0 +1,8 @@
!# $Revision: 1.20 $
@DefaultIms: xtim
@SelectMode: 1
!! Ximp
xtim: HP XTIM(X ÜÜê¦ñ¢ÄãÅÆòÓÄ«ÎÎÈùΤðÂ)
!! no input method
none: àÒòÓÄ«ÎÎ
!#

View File

@@ -0,0 +1,46 @@
!# @(#)$XConsortium: start.conf /main/3 1996/07/18 14:26:33 drk $
!# configuration file for dtimsstart
!#
!# expansion of '%':
!# %C=/usr/dt/config, %I=/usr/dt/config/ims, %U=$HOME/.dt,
!# %H=$HOME, %L=$LANG, %D=$DISPLAY,
!# %h=<host_name>, %u=<user_name>, %d=<displaydir>,
!# %n=<ims_name>, %N=<full ims_name>, %c=<class_name>
!#
!! dtims config directory
ImsConfigDir: /usr/dt/config/ims
ImsAppDefDir: /usr/dt/app-defaults
ImsLogDir: /var/dt
ImsLogFile: imslog
ImsDirName: ims
!# CDE configuration
DtConfigDir: /usr/dt/config
DtUserDir: %H/.dt
!! resource file search path
DtResourcePath: %U/%d/current/dt.resources:%U/%d/home/dt.resources:%U/sessions/current/dt.resources:%U/sessions/home/dt.resources:%C/%L/sys.resources:%C/C/sys.resources
!! CDE user files (in $HOME)
UserImsDir: %H/.dt/ims
UserTmpDir: %H/.dt/tmp
UserAltTmpDir: /var/tmp
!! Actions
Action.GetRemoteConf: DtImsGetRemoteConf
Action.RunRemoteIms: DtImsRunRemoteIms
!! atom name created and owned by IMS
ImAtom.XIM: @server=%N
ImAtom.Ximp: _XIMP_%L@%n.0
ImAtom.Xsi: _XIM_INPUTMETHOD
!! format of XMODIFIERS
ImXmod.XIM: %n
ImXmod.Ximp: _XIMP_%L#%n.%s
ImXmod.Xsi: _XIM_INPUTMETHOD
!# End.

View File

@@ -0,0 +1,10 @@
!# $XConsortium: ja_JP /main/3 1996/10/28 14:02:58 drk $
@DefaultIms: xfeoak2
@SelectMode: 0
!! Xim
xfeoak2:
!! builtin input method
builtin.jpn: Built-in Japanese IM
!! no input method
none: 日本語入力なし
!#

View File

@@ -0,0 +1,9 @@
!# $XConsortium: xfeoak2 /main/2 1996/10/28 14:03:38 drk $
protocols: XIM Ximp
server_name: xfeoak2
class_name: Xfeoak2
cmd_path: /usr/dt/bin/xfeoak2
cmd_param: -noSetWmCommand
env_set:
env_unset:
has_window: true

View File

@@ -0,0 +1,55 @@
$ message catalog of dtimsstart
$ @(#)$XConsortium: dtimsstart.msg /main/4 1996/08/19 11:35:10 pascale $
$set 1
$ usage
1 Usage: %s [options ..]
2 print modified environment variables
3 override $SHELL
4 specifies input method name
5 specifies command options for input method server
6 specifies host where input method server should be run
7 change input method selection mode
8 print registered input method
9 show this message
$ selection mode
$ please do not translate ask_at_login and resume_current_input_method
20 SelectMode
21 ask_at_login
22 resume_current_input_method
23 force 'resume_current_input_method' mode
24 force 'ask_at_login' mode
$ error messages
31 invalid option '%s'
32 environment variable 'HOME' not defined
33 environment variable 'LANG' not defined
34 this locale is not supported by the desktop.
35 environment variable 'DISPLAY' not defined
36 cannot open file\n [%s]
37 cannot create file\n [%s]
38 cannot create directory\n [%s]
39 missing '%s' entry in configuration file\n [%s]
40 another '%s' is already running
41 no selection file for '%s'
42 cannot create selection file\n [%s]
43 no ims selected for '%s'
44 no locale configuration file for '%s'
45 no ims configured for '%s'
46 no ims configuration file for '%s'
47 ims '%s' not registered
48 no executable file for '%s'\n [%s]
49 ims '%s' is already running
50 cannot execute ims '%s'
51 ims '%s' aborted. See log file.\n [%s]
52 ims '%s' is not available yet
53 unknown host '%s'
54 action '%s' failed
55 remote execution failed on '%s'
56 remote functionality is not available on '%s'
57 no ims registered on '%s'
58 ims '%1$s' not registered on '%2$s'
59 cannot open display '%s'
$

View File

@@ -0,0 +1,540 @@
/* @(#)$XConsortium: env.c /main/9 1996/10/30 05:57:27 pascale $ */
#include <pwd.h>
#include "xims.h"
typedef enum {
P_Shell, /* posix shell */
K_Shell, /* Korn shell */
C_Shell /* C shell */
} ShellType;
/* local func */
static int shell_type(/* shell */);
int set_cmd_env()
{
int ret = NoError;
char **aliases = (char **)0;
char *p;
UserEnv *uenv = &userEnv;
if ((ret = get_user_environ()) != NoError)
return ret;
if ((ret = read_cmd_conf()) != NoError)
return ret;
# ifdef old_hpux
p = get_real_locale(uenv->locale, &aliases);
if (p) {
uenv->real_locale = NEWSTR(p);
uenv->locale_aliases = aliases;
}
# endif /* old_hpux */
expand_cmd_conf();
return ret;
}
int get_user_environ()
{
int ret = NoError;
char buf[BUFSIZ], *p;
int n;
UserEnv *uenv = &userEnv;
ret = NoError;
CLR(&userEnv, UserEnv);
if ((p = getenv("LANG")) && *p)
uenv->locale = NEWSTR(p);
else
return ErrNoLocale;
/* find the CDE generic locale name */
if (find_CDE_locale_name() != NoError)
return ErrNoCDELocale;
if ((p = getenv("HOME")) && *p)
uenv->homedir = NEWSTR(p);
else {
if (OpMode != MODE_LIST && OpMode != MODE_REMCONF) {
#ifdef ALLOW_NOHOME
p = "/var/tmp";
uenv->homedir = NEWSTR(p);
#else
ret = ErrNoHome;
#endif /* ALLOW_NOHOME */
}
}
if ((p = Opt.DisplayName) && *p) {
strcpy(buf, "DISPLAY=");
strcat(buf, p);
putenv(NEWSTR(buf));
} else
p = getenv("DISPLAY");
if (p && *p)
uenv->displayname = NEWSTR(p);
else {
if (OpMode == MODE_START /* || OpMode == MODE_CURRENT */
|| (OpMode == MODE_MODE && (OpFlag & USE_WINDOW_MASK)))
return ErrNoDisplay;
}
if (p = getenv("XMODIFIERS"))
uenv->xmodifiers = NEWSTR(p);
else
uenv->xmodifiers = NULL;
gethostname(buf, BUFSIZ);
uenv->hostname = NEWSTR(buf);
if (!(p = getlogin()))
{
struct passwd *pw;
pw = getpwuid(getuid());
p = pw->pw_name;
}
uenv->username = NEWSTR(p);
n = 0;
if (p = std_dpy_str(uenv->displayname, &n))
uenv->displaydir = p;
else
uenv->displaydir = NEWSTR(uenv->displayname);
uenv->screen_num = n;
return ret;
}
int expand_string(in_str, out_str, out_len, ims)
char *in_str, *out_str;
int out_len;
ImsConf *ims;
{
register char *p, *q, *ep;
char str[20];
int len = 0;
UserEnv *uenv = &userEnv;
CmdConf *conf = &Conf;
p = in_str; q = out_str;
if (*p == '~' && p[1] == '/') {
q = strcpyx(q, uenv->homedir);
*q++ = '/';
p += 2;
out_len -= q - out_str;
}
while (*p && out_len > 0) {
ep = NULL;
if (*p == '%') {
switch(p[1]) {
case 'I': ep = conf->imsConfDir; break;
case 'R': ep = conf->imsAppDir; break;
case 'G': ep = conf->imsLogDir; break;
case 'g': ep = conf->imsLogFile; break;
case 'b': ep = conf->imsDir; break;
case 'S': ep = conf->userImsDir; break;
case 'T': ep = conf->userTmpDir; break;
case 'A': ep = conf->userAltDir; break;
case 'C': ep = conf->dt->confDir; break;
case 'U': ep = conf->dt->userDir; break;
# ifdef old_hpux
case 'V': ep = conf->vue->confDir; break;
case 'X': ep = conf->vue->userDir; break;
# endif /* old_hpux */
case 'L': if (ep = uenv->real_locale) break;
case 'l': ep = uenv->locale; break;
case 'H': ep = uenv->homedir; break;
case 'u': ep = uenv->username; break;
case 'h': ep = uenv->hostname; break;
case 'D': ep = uenv->displayname; break;
case 'd': ep = uenv->displaydir; break;
case 'N': if (ims && (ep = ims->servername2)) break;
case 'n': if (ims) ep = ims->servername; break;
case 'c': if (ims) ep = ims->classname; break;
case 's': sprintf(str, "%ld", (long) uenv->screen_num);
if (str[0] != '\0') ep = str;
break;
case 'r': ep = userSel.hostname; break;
case '%': p++;
default: DPR2(("expand_string: '%%%c' unknown\n"));
ep = 0; break;
}
if (ep) {
if ((out_len -= (int) strlen(ep)) <= 0) break;
q = strcpyx(q, ep);
p += 2;
continue;
}
}
if (--out_len <= 0) break;
*q++ = *p++;
}
*q = 0;
len = q - out_str;
DPR3(("expand_string(\"%s\"):\t\"%s\"\n", in_str, out_str));
if (out_len <= 0) {
DPR(("expand_string(): buffer overflow (len=%d)\n", len));
}
return len;
}
static int shell_type(shell)
char *shell;
{
char *p;
int len;
if (!shell || !*shell) {
shell = getenv("SHELL");
if (!shell || !*shell) return P_Shell;
}
if (strchr(p = shell, '/')) {
for (len = strlen(p); len > 1 && p[len - 1] == '/'; len--) ;
shell[len] = 0;
if (p = strrchr(shell, '/')) shell = p + 1;
}
if (strstr(shell, "ksh") != NULL)
return K_Shell;
else if (strstr(shell, "csh") != NULL)
return C_Shell;
return P_Shell;
}
int make_new_environ(oenv, sel)
OutEnv *oenv;
UserSelection *sel;
{
ImsConf *ims;
EnvEnt *ep, *ep2;
int num, i;
int proto;
char *p, **pp;
char buf[BUFSIZ], *bp;
char *xmod, *xinput;
char **setp, **unsetp;
bool xmod_done, xinput_done;
RunEnv *renv;
/* if (!oenv) return ErrInternal; */
if (!sel) sel = &userSel;
CLR(oenv, OutEnv);
renv = sel->renv;
ims = sel->ent->ims;
xmod = ENV_XMODIFIERS;
xmod_done = False;
# ifdef old_hpux
xinput = xhp_xinput_name(NULL);
# else
xinput = NULL;
# endif /* old_hpux */
xinput_done = (xinput) ? False : True;
proto = renv ? renv->proto : default_protocol(ims);
setp = unsetp = 0;
if (ims->env_set) setp = parse_strlist(ims->env_set, ' ');
if (ims->env_unset) unsetp = parse_strlist(ims->env_unset, ' ');
/* set: ims->env_set, XMODIFIERS & X?INPUT */
num = 0;
if (setp) for (pp = setp; *pp; pp++, num++) ;
ep = oenv->set = ALLOC(num + 2 + 1, EnvEnt);
for (i = 0; i < num && (p = setp[i]); i++)
if (strcmp(p, xmod) && strcmp(p, xinput)) {
ep->name = NEWSTR(p);
ep++;
}
if (renv && renv->im_mod) {
ep->name = NEWSTR(xmod);
bp = strcpyx(bp = buf, ENV_MOD_IM); /* "@im=" */
bp = strcpyx(bp, renv->im_mod);
ep->value = NEWSTR(buf);
ep++;
xmod_done = True;
}
# ifdef old_hpux
if (!xinput_done && (proto == Proto_Xhp)) {
#ifdef DEBUG
if (!ims->servername) {
DPR(("make_new_environ(): '%s' servername not defined\n",
sel->name));
}
#endif
ep->name = NEWSTR(xinput);
ep->value = NEWSTR(ims->servername);
ep++;
xinput_done = True;
}
# endif /* old_hpux */
if (ep == oenv->set) {
FREE(oenv->set); oenv->set = (EnvEnt *)0;
} else
ep->name = NULL;
/* unset: XMODIFIERS & X?INPUT, ims->env_unset */
num = 0;
if (unsetp) for (pp = unsetp; *pp; pp++, num++) ;
ep = oenv->unset = ALLOC(num + 2 + 1, EnvEnt);
if (!xmod_done) {
ep->name = NEWSTR(xmod);
ep++;
xmod_done = True;
}
# ifdef old_hpux
if (!xinput_done) {
ep->name = NEWSTR(xinput);
ep++;
xinput_done = True;
}
# endif /* old_hpux */
for (i = 0; i < num && (p = unsetp[i]); i++) {
if (strcmp(p, xmod) == 0 || strcmp(p, xinput) == 0)
continue;
if (oenv->set) {
for (ep2 = oenv->set; ep2->name; ep2++)
if (strcmp(p, ep2->name) == 0) {
p = NULL;
break;
}
}
if (p) {
ep->name = NEWSTR(p);
ep++;
}
}
if (ep == oenv->unset) {
FREE(oenv->unset); oenv->unset = (EnvEnt *)0;
} else
ep->name = NULL;
FREE_LIST(setp);
FREE_LIST(unsetp);
FREE(xinput);
return NoError;
}
int put_new_environ(oenv) /* print modified environment variables */
OutEnv *oenv;
{
EnvEnt *ep;
char tmpbuf[BUFSIZ], *bp, *vp;
int typ = shell_type(Opt.ShellName);
int len;
/* if (!oenv) return ErrInternal; */
#ifdef DEBUG
if (DebugLvl >= 2)
pr_OutEnv(oenv);
#endif
if (!oenv->set && !oenv->unset) return NoError;
tmpbuf[0] = 0;
if (typ == C_Shell) { /* C-Shell format */
bp = strcpyx(tmpbuf, "set noglob;\n");
if (oenv->set) {
for (ep = oenv->set; ep->name; ep++) {
if (!(vp = ep->value) && (vp = strchr(ep->name, '=')))
*vp++ = '\0';
sprintf(bp, "setenv %s '%s';\n", ep->name, vp);
bp += strlen(bp);
}
}
if (oenv->unset) {
bp = strcpyx(bp, "unsetenv ");
for (ep = oenv->unset; ep->name; ep++) {
*bp++= ' ';
bp = strcpyx(bp, ep->name);
}
}
bp = strcpyx(bp, ";\nunset noglob;\n");
} else { /* B-Shell format */
bp = tmpbuf;
if (oenv->set) {
for (ep = oenv->set; ep->name; ep++) {
if (!(vp = ep->value) && (vp = strchr(ep->name, '=')))
*vp++ = '\0';
sprintf(bp, "%s='%s';\n", ep->name, vp);
bp += strlen(bp);
}
bp = strcpyx(bp, "export ");
for (ep = oenv->set; ep->name; ep++) {
*bp++= ' ';
bp = strcpyx(bp, ep->name);
}
bp = strcpyx(bp, ";\n");
}
if (oenv->unset) {
bp = strcpyx(bp, "unset ");
for (ep = oenv->unset; ep->name; ep++) {
*bp++= ' ';
bp = strcpyx(bp, ep->name);
}
bp = strcpyx(bp, ";\n");
}
}
len = bp - tmpbuf;
DPR3(("put_new_environ(len=%d):\t%s\n", len, tmpbuf));
if (len > 0)
write(1, tmpbuf, len);
return NoError;
}
int set_remote_env(ptr, env_pass)
char *ptr, *env_pass;
{
char *bp = ptr, *ep;
char **ls, **ls2, **pp, **pp2;
bool dup_ent;
ls = ls2 = 0;
if (Conf.remote->passEnv
&& (ls = parse_strlist(Conf.remote->passEnv, ' '))) {
for (pp = ls; *pp; pp++)
if (ep = getenv(*pp)) {
*bp++ = ' '; bp = strcpyx(bp, *pp); *bp++ = '=';
*bp++ = '"'; bp = strcpyx(bp, ep); *bp++ = '"';
}
}
if (env_pass && (ls2 = parse_strlist(env_pass, ' '))) {
for (pp2 = ls2; *pp2; pp2++) {
dup_ent = False;
if (ls) { /* eliminate duplicate entries */
for (pp = ls; *pp; pp++)
if (strcmp(*pp, *pp2) == 0) {
dup_ent = True;
break;
}
}
if (!dup_ent && (ep = getenv(*pp2))) {
*bp++ = ' '; bp = strcpyx(bp, *pp2); *bp++ = '=';
*bp++ = '"'; bp = strcpyx(bp, ep); *bp++ = '"';
}
}
FREE_LIST(ls2);
ls2 = 0;
}
if (ls) FREE_LIST(ls);
/* if (bp != ptr) *bp++ = ' '; */
*bp = 0;
DPR2(("set_remote_env('%s' & '%s'):\n\t'%s'\n",
Conf.remote->passEnv, env_pass, ptr));
return bp - ptr;
}
# ifdef old_hpux
char *xhp_xinput_name(locale)
char *locale;
{
char *xinput_name = "X@INPUT";
char **pp, *p;
int i, len;
XhpLocale *xhp = Conf.xhp;
char **ls;
char typ = 0;
if (!xhp) return NULL;
if (!locale) locale = userEnv.locale;
for (i = 0; !typ && i < XHP_LANG_NUM; i++) {
if (!(ls = parse_strlist(xhp[i].locales, ' '))) continue;
for (pp = ls; *pp; pp++) {
if (locale[0] != (*pp)[0]) continue;
len = strlen(p = *pp);
if ((p[len - 1] == '*' && strncmp(locale, p, len - 1) == 0)
|| strcmp(locale, p) == 0) {
typ = xhp[i].type;
break;
}
}
FREE_LIST(ls);
}
if (!typ) {
DPR2(("xhp_xinput_name(%s): unknown locale\n", locale));
return NULL;
}
xinput_name[1] = typ;
return NEWSTR(xinput_name);
}
char *get_real_locale(locale, aliases)
char *locale, ***aliases;
{
int i;
int match_idx = -1;
LocaleAlias **alias = Conf.alias, *ap;
char **ls, **pp;
char *real_locale = NULL;
if (!locale || !alias) return NULL;
for (i = 0; match_idx < 0 && (ap = alias[i]); i++) {
if (strcmp(ap->name, locale) == 0) {
match_idx = i;
if (aliases)
ls = parse_strlist(ap->aliases, ' ');
break;
}
if (ls = parse_strlist(ap->aliases, ' ')) {
for (pp = ls; *pp; pp++)
if (strcmp(locale, *pp) == 0) {
match_idx = i;
break;
}
FREE_LIST(ls);
ls = (char **)NULL;
}
}
if (match_idx >= 0) {
real_locale = alias[match_idx]->name;
if (aliases) {
*aliases = ls;
ls = (char **)NULL;
}
} else {
real_locale = NULL;
if (aliases) *aliases = (char **) NULL;
}
if (ls) FREE_LIST(ls);
DPR(("get_real_locale(%s): real_locale=%s aliases=%s\n",
locale, real_locale, aliases ? *aliases : NULL));
return real_locale;
}
# endif /* old_hpux */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,896 @@
/* @(#)$TOG: remote.c /main/9 1998/04/06 13:36:26 mgreess $ */
#include "xims.h"
#include <signal.h>
#include <sys/wait.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/errno.h>
#include <setjmp.h>
#include <fcntl.h>
#include <limits.h>
#include <X11/Xproto.h> /* for X_ChangeHosts */
#include <X11/Xatom.h> /* for XA_STRING */
#if !defined(linux)
extern char *sys_errlist[];
#endif
static char *conf_msg_id = STR_CONFDATA;
#define CONF_MSG_ID_LEN strlen(conf_msg_id)
#define CONF_MSG_DATASIZE_LEN 8
#define CONF_MSG_HEADER_LEN (CONF_MSG_ID_LEN + CONF_MSG_DATASIZE_LEN)
#define CONF_MSG_SIZE_MAX (8*1024 - 64) /* < PIPE_BUF (PIPSIZ) */
static int mk_remote_conf(/* list, locale, ims_name, status, confbuf, conflen */);
static char *mk_ims_ent(/* bp, idx, ent */);
static int parse_ims_list(/* ptr, list */);
static int parse_remote_conf(/* listp, locale, confbuf, conflen */);
static int prepare_action(/* act_typ, av, ac */);
static int read_property(/* prop, type, format, remove, datapp, lenp */);
#if 0 /* README */
Atom:
_DTIMSSTART_MAIN _DTIMSSTART_STATUS _DTIMSSTART_DATA
Property:
_DTIMSSTART_STATUS (format: 32) _DTIMSSTART_DATA (format: 8)
ClientMessage:
message_type: _DTIMSSTART_STATUS
format: 32
data.l[0]: _REMOTE_CONF or _REMOTE_RUN
data.l[1]: ErrorCode
data.l[2-4]: 0 (unused)
Status:
_NONE _INIT _REMOTE_CONF _REMOTE_RUN
Actions:
DtImsGetRemoteConf DtImsRunRemoteIms
Procedure:
<initialization>
* own _MAIN property
* set _STATUS property to _INIT
* set _DATA property to _INIT
<get remote configuratuon (DtImsGetRemoteConf)>
* clear _DATA property
* change _STATUS property to _REMOTE_CONF
* set additional command line options to _DATA property
* invoke DtImsGetRemoteConf action
[on remote dtimsstart]
- collect data
- check _STATUS property whether its value is _REMOTE_CONF
- set collected data to _DATA property of owner of _MAIN (Replace)
- send ClientMessage of ErrorCode to owner of _MAIN
- exit
* receive ClientMessage from remote dtimsstart (or action finished)
* change _STATUS property to _INIT
* read data from _DATA property (Delete)
* parse ErrCode and data (conf data or ErrorPath)
* update selection window
<run IMS on remote host (DtImsRunRemoteIms)>
* change _STATUS property to _REMOTE_RUN
* set additional command line options to _DATA property
* invoke DtImsRunRemoteIms action
* popdown selection window (if sucessfully invoked)
[on remote dtimsstart]
- check _STATUS property whether its value is _REMOTE_RUN
- invoke IMS and wait its preparation
- set ErrorPath to _DATA property of owner of _MAIN (Replace)
- send ClientMessage of ErrorCode to owner of _MAIN
- exit
* receive ClientMessage from remote dtimsstart (or action finished)
* change _STATUS property to _INIT
* parse ErrCode and data (ErrorPath)
<termination>
* disown _MAIN property
* exit
#endif /* README */
#ifdef NEED_STRCASECMP
/*
* In case strcasecmp is not provided by the system here is one
* which does the trick.
*/
static int
strcasecmp(register const char *s1,
register const char *s2)
{
register int c1, c2;
while (*s1 && *s2) {
c1 = isupper(*s1) ? tolower(*s1) : *s1;
c2 = isupper(*s2) ? tolower(*s2) : *s2;
if (c1 != c2)
return (c1 - c2);
s1++;
s2++;
}
return (int) (*s1 - *s2);
}
#endif
int put_remote_conf(locale, ims_name)
char *locale, *ims_name;
{
int ret;
int msg_status = NoError;
int conflen;
char confbuf[CONF_MSG_SIZE_MAX];
ImsList *list = (ImsList *) 0;
DPR(("put_remote_conf(locale=%s, ims=%s)\n", locale, ims_name));
ret = get_ims_list(&list, NULL, True);
msg_status = ret;
ret = mk_remote_conf(list, locale, ims_name, msg_status, confbuf, &conflen);
if (list) {
clear_ImsList(list);
FREE(list);
}
ret = set_remote_confdata(confbuf, conflen);
send_dtims_msg(WIN_ST_REMOTE_CONF, ret);
#if 0
NotifyErrCode(NoError);
(void) fwrite((void *)confbuf, (size_t)conflen, (size_t)1, stdout);
fflush(stdout);
#endif
return ret;
}
int get_remote_conf(listp, hostname, locale, ims_name)
ImsList **listp;
char *hostname, *locale, *ims_name;
{
int ret = NoError;
int conflen = 0;
char *confbuf = 0;
char *opts[16];
int n, num_opts;
char *CDE_locale = NULL;
if (!locale)
locale = userEnv.real_locale ? userEnv.real_locale : userEnv.locale;
CDE_locale = userEnv.CDE_locale;
if (CDE_locale)
DPR2(("get_remote_conf(%s, %s, %s)\n",
hostname, CDE_locale, ims_name ? ims_name : "<all>"));
else
DPR2(("get_remote_conf(%s, %s, %s)\n",
hostname, locale, ims_name ? ims_name : "<all>"));
n = 0;
/* Try to first use the CDE locale, else fallback to the locale. */
if (CDE_locale) {
opts[n++] = "-CDE_locale";
opts[n++] = CDE_locale;
}
else {
if (locale) {
opts[n++] = "-locale";
opts[n++] = locale;
}
}
if (ims_name) {
opts[n++] = "-ims";
opts[n++] = ims_name;
}
#ifdef DEBUG
if (DebugLvl >= 1) {
int i;
for (i = 0; i < DebugLvl; i++) opts[n++] = "-debug";
}
#endif
opts[n] = NULL;
num_opts = n;
ret = prepare_action(ACT_GETREMCONF, opts, num_opts);
if (ret != NoError) return ret;
ret = invoke_action(Conf.action[ACT_GETREMCONF], hostname);
change_window_status(WIN_ST_INIT);
if (ret != NoError) return ret;
ret = read_remote_confdata(&confbuf, &conflen);
if (ret != NoError) return ret;
if (ret == NoError) {
ret = parse_remote_conf(listp, locale, confbuf, conflen);
FREE(confbuf);
if (ims_name && ret == ErrRemoteNoIms)
ret = ErrRemoteMissIms;
}
return ret;
}
#define PUT_DATA(nm, val) *bp++ = ' ', bp = strcpyx(bp, (nm)), \
*bp++ = '=', bp = strcpyx(bp, (val)), *bp++ = '\n'
static int mk_remote_conf(list, locale, ims_name, status, confbuf, conflen)
ImsList *list;
int status;
char *locale, *ims_name, *confbuf;
int *conflen;
{
int num_ent;
int i, j;
char *bp;
int len;
int data_sz;
char sz_ptr[20];
ImsEnt *ent;
char var[20];
DPR(("mk_remote_conf(locale=%s, ims=%s)\n", locale, ims_name));
#ifdef DEBUG
if (DebugLvl >= 2 && list) pr_ImsList(list);
#endif
bp = confbuf + CONF_MSG_HEADER_LEN;
num_ent = 0;
if (status == NoError) {
for (i = 0; i < list->num_ent; i++) {
ent = list->elist[i];
if ((ims_name && strcmp(ent->name, ims_name))
|| (ent->ims && (ent->ims->flags & F_NO_REMOTE)))
ent->status = ErrRemoteIms;
else
num_ent++;
}
if (num_ent <= 0)
status = ErrRemoteNoIms;
}
bp = strcpyx(bp, "ImsList: "); bp = strcpyx(bp, locale); *bp++ = '\n';
sprintf(var, "%ld", (long) status);
PUT_DATA("ST", var);
if (num_ent > 0) {
sprintf(var, "%ld", (long) num_ent);
PUT_DATA("ne", var);
if (list->elist[list->default_idx]->status != ErrRemoteIms) {
PUT_DATA("df", list->elist[list->default_idx]->name);
}
sprintf(var, "%ld", (long) (list->def_selmode));
PUT_DATA("sm", var);
for (i = j = 0; i < list->num_ent; i++)
if (list->elist[i]->status != ErrRemoteIms)
bp = mk_ims_ent(bp, j++, list->elist[i]);
}
bp = strcpyx(bp, "END"); *bp++ = '\n';
data_sz = bp - (confbuf + CONF_MSG_HEADER_LEN);
/* header (conf_msg_id & data_sz) */
bp = confbuf;
memset((void *) bp, (int) ' ', (size_t) CONF_MSG_HEADER_LEN);
memcpy((void *) bp, conf_msg_id, CONF_MSG_ID_LEN);
sprintf(sz_ptr, "%ld", (long) data_sz);
len = strlen(sz_ptr);
bp = confbuf + CONF_MSG_HEADER_LEN - 1 - len;
memcpy((void *) bp, (void *) sz_ptr, (size_t) len);
confbuf[CONF_MSG_HEADER_LEN - 1] = '\n';
*conflen = CONF_MSG_HEADER_LEN + data_sz;
DPR2(("mk_remote_conf(): conflen=%d data_sz=%d\n confbuf=%s",
*conflen, data_sz, confbuf));
return NoError;
}
static char *mk_ims_ent(bp, idx, ent)
ImsEnt *ent;
int idx;
register char *bp;
{
ImsConf *ims = ent->ims;
char val[20];
sprintf(val, "%ld", (long) idx);
bp = strcpyx(bp, "Ent-"); bp = strcpyx(bp, val); *bp++ = '\n';
PUT_DATA("nm", ent->name);
sprintf(val, "%ld", (long) ent->status);
PUT_DATA("st", val);
sprintf(val, "%ld", (long) ims->flags);
PUT_DATA("fg", val);
sprintf(val, "%ld", (long) ims->protocols);
PUT_DATA("pr", val);
if (ent->label) { PUT_DATA("lb", ent->label); }
if (ims->timeout)
{
sprintf(val, "%ld", (long) ims->timeout);
PUT_DATA("to", val);
}
if (ims->interval)
{
sprintf(val, "%ld", (long) ims->interval);
PUT_DATA("it", val);
}
if (ims->servername) { PUT_DATA("sn", ims->servername); }
if (ims->servername2) { PUT_DATA("sN", ims->servername2); }
if (ims->classname) { PUT_DATA("cn", ims->classname); }
if (ims->property) { PUT_DATA("pp", ims->property); }
if (ims->cmd_path) { PUT_DATA("cp", ims->cmd_path); }
if (ims->cmd_param) { PUT_DATA("cr", ims->cmd_param); }
if (ims->env_set) { PUT_DATA("es", ims->env_set); }
if (ims->env_unset) { PUT_DATA("eu", ims->env_unset); }
if (ims->env_pass) { PUT_DATA("ep", ims->env_pass); }
return bp;
}
#undef PUT_DATA
static int parse_ims_list(ptr, list)
char *ptr;
ImsList *list;
{
register char *bp = ptr;
char *np, *vp;
char *def_name;
int i, num_ent;
ImsEnt *ent = 0;
ImsConf *ims;
CLR(list, ImsList);
list->default_idx = -1;
list->def_selmode = SEL_MODE_NOAUTO;
list->num_ent = 0;
def_name = NULL;
num_ent = 0;
while (np = strchr(bp, '\n')) {
if (np == bp) {
bp++;
continue;
}
*np = 0;
if (strncmp(bp, "Ent-", 4) == 0) {
#ifdef DEBUG
if (list->num_ent <= 0) {
DPR(("parse_ims_list(): ImsEnt: list->num_ent=%d\n", list->num_ent));
}
#endif
if (!list->elist)
list->elist = ALLOC(list->num_ent, ImsEnt *);
if (num_ent >= list->num_ent) {
DPR(("parse_ims_list(): too many entry: '%s'\n", bp));
break;
}
ent = list->elist[num_ent] = ALLOC(1, ImsEnt);
ims = ent->ims = ALLOC(1, ImsConf);
num_ent++;
} else if (strncmp(bp, "END", 3) == 0) {
break;
} else if (bp[0] == ' ' && bp[3] == '=') {
bp++; vp = bp + 3;
/*list */
if (strncmp(bp, "ST", 2) == 0) list->status = atoi(vp);
else if (strncmp(bp, "ne", 2) == 0) list->num_ent = atoi(vp);
else if (strncmp(bp, "df", 2) == 0) def_name = vp;
else if (strncmp(bp, "sm", 2) == 0) list->def_selmode = atoi(vp);
#ifdef DEBUG
else if (!ent) {
DPR(("parse_ims_list(): ImsEnt: list->elist[%d]=%%x\n", num_ent, ent));
}
#endif
/* ent */
else if (strncmp(bp, "nm", 2) == 0) { RENEWSTR(ent->name, vp); }
else if (strncmp(bp, "lb", 2) == 0) { RENEWSTR(ent->label, vp); }
else if (strncmp(bp, "st", 2) == 0) { ent->status = atoi(vp); }
else if (strncmp(bp, "fg", 2) == 0) { ims->flags = atoi(vp); }
else if (strncmp(bp, "pr", 2) == 0) { ims->protocols = atoi(vp); }
else if (strncmp(bp, "to", 2) == 0) { ims->timeout = atoi(vp); }
else if (strncmp(bp, "it", 2) == 0) { ims->interval = atoi(vp); }
else if (strncmp(bp, "sn", 2) == 0) { RENEWSTR(ims->servername, vp); }
else if (strncmp(bp, "sN", 2) == 0) { RENEWSTR(ims->servername2, vp); }
else if (strncmp(bp, "cn", 2) == 0) { RENEWSTR(ims->classname, vp); }
else if (strncmp(bp, "pp", 2) == 0) { RENEWSTR(ims->property, vp); }
else if (strncmp(bp, "cp", 2) == 0) { RENEWSTR(ims->cmd_path, vp); }
else if (strncmp(bp, "cr", 2) == 0) { RENEWSTR(ims->cmd_param, vp); }
else if (strncmp(bp, "es", 2) == 0) { RENEWSTR(ims->env_set, vp); }
else if (strncmp(bp, "eu", 2) == 0) { RENEWSTR(ims->env_unset, vp); }
else if (strncmp(bp, "ep", 2) == 0) { RENEWSTR(ims->env_pass, vp); }
else {
DPR(("parse_ims_list(): invalid line '%s'\n", bp - 1));
}
} else {
DPR(("parse_ims_list(): invalid line '%s'\n", bp));
}
bp = np + 1;
}
#ifdef DEBUG
if (num_ent != list->num_ent) {
DPR(("parse_ims_list(): num_ent(%d) != list->num_ent(%d)\n",
num_ent, list->num_ent));
}
#endif
list->num_ent = num_ent;
list->default_idx = -1;
if (num_ent > 0) {
for (i = 0; i < num_ent; i++) { /* check indispensable entry */
ent = list->elist[i];
if (ent->status == NoError)
ent->status = check_ims_conf(ent->ims, ent->name);
}
if (def_name) { /* set default_idx */
for (i = 0; i < num_ent; i++)
if (strcmp(list->elist[i]->name, def_name) == 0) {
list->default_idx = i;
break;
}
}
}
return list->status;
}
static int parse_remote_conf(listp, locale, confbuf, conflen)
ImsList **listp;
char *locale, *confbuf;
int conflen;
{
int ret = NoError;
char *bp = confbuf;
ImsList *list;
int data_sz = 0;
DPR(("parse_remote_conf(%s)\n", locale));
if (conflen < (int) CONF_MSG_HEADER_LEN /* check header */
|| strncmp(confbuf, conf_msg_id, CONF_MSG_ID_LEN)) {
ret = ErrNoImsstart;
} else {
confbuf[CONF_MSG_HEADER_LEN - 1] = 0; /* <= '\n' */
bp = confbuf + CONF_MSG_ID_LEN;
while (*bp == ' ') bp++;
if (!str_to_int(bp, &data_sz) || data_sz < 0) {
ret = ErrNoImsstart;
} else if (conflen < data_sz + (int) CONF_MSG_HEADER_LEN) {
DPR(("\tconflen(%d) != data_sz(%d) + HDR\n", conflen, data_sz));
data_sz = conflen - CONF_MSG_HEADER_LEN;
ret = ErrNoImsstart;
}
}
#ifdef DEBUG
if (ret != NoError && conflen > (int) CONF_MSG_HEADER_LEN) {
if (!confbuf[CONF_MSG_HEADER_LEN - 1])
confbuf[CONF_MSG_HEADER_LEN - 1] = '@';
confbuf[conflen] = 0;
DPR(("\tinvalid header[len=%d]: %s\n", conflen, confbuf));
}
#endif
if (ret != NoError) return ErrRemoteAction;
bp = confbuf + CONF_MSG_HEADER_LEN;
bp[data_sz] = 0;
if (strncmp(bp, "ImsList:", 8)
/* || strncmp(bp + 9, locale, strlen(locale)) */
|| !(bp = strchr(bp, '\n'))) {
return ErrRemoteAction;
}
/* confbuf[conflen] = 0; */
list = ALLOC(1, ImsList);
ret = parse_ims_list(bp, list);
if (ret != NoError || list->num_ent == 0) {
clear_ImsList(list);
FREE(list);
list = (ImsList *) 0;
ret = ErrRemoteNoIms;
}
*listp = list;
return ret;
}
int exec_remote_ims(sel)
UserSelection *sel;
{
int ret = NoError;
int n, num_opts, binc;
char *bp, *np;
char envbuf[BUFSIZ];
char tmpbuf[BUFSIZ];
char *opts[32];
char **av;
int ac;
char *ims_name = sel->name;
ImsConf *ims = sel->ent->ims;
char val[20];
DPR(("exec_remote_ims(): '%s' on %s\n", ims_name, sel->hostname));
/* build options */
n = 0;
bp = tmpbuf; tmpbuf[0] = 0;
opts[n++] = "-ims"; opts[n++] = ims_name;
opts[n++] = "-notify";
opts[n++] = "-nosave";
opts[n++] = "-nowindow";
#if 0
binc = expand_string(bp, "%L", BUFSIZ, 0);
opts[n++] = "-locale";
opts[n++] = bp; bp += binc + 1;
binc = expand_string(bp, "%d.%s", BUFSIZ, 0);
opts[n++] = "-display";
opts[n++] = bp; bp += binc = 1;
#endif
#ifdef DEBUG
if (DebugLvl >= 1) {
int i;
for (i = 0; i < DebugLvl; i++) opts[n++] = "-debug";
}
#endif
/* options */
if (OpFlag & FLAG_NOWAIT) opts[n++] = "-nowait";
if (OpFlag & FLAG_NOTIMEOUT) opts[n++] = "-notimeout";
if (OpFlag & FLAG_CONNECT) opts[n++] = "-connect";
if (Opt.Timeout > 0) {
sprintf(val, "%ld", (long)Opt.Timeout);
np = strcpyx(bp, val);
opts[n++] = "-timeout";
opts[n++] = bp; bp = np + 1;
}
if (Opt.Interval > 0) {
sprintf(val, "%ld", (long)Opt.Interval);
np = strcpyx(bp, val);
opts[n++] = "-interval";
opts[n++] = bp; bp = np + 1;
}
if (mk_ims_option(bp, sel)) {
sprintf(val, "%ld", (long)Opt.Interval);
np = strcpyx(bp, val);
opts[n++] = "-imsopt";
opts[n++] = bp; bp = np + 1;
}
bp = NULL;
opts[n] = NULL;
num_opts = n;
/* env variables */
set_remote_env(envbuf, ims->env_pass);
ret = prepare_action(ACT_RUNREMIMS, opts, num_opts);
if (ret != NoError) return ret;
ret = invoke_action(Conf.action[ACT_RUNREMIMS], sel->hostname);
change_window_status(WIN_ST_INIT);
if (ret != NoError) return ret;
if (ret == NoError) {
ac = 0; av = NULL;
ret = get_window_data(&ac, &av);
ret = NoError;
if (ret != NoError) return ret;
}
if (ret == NoError) {
put_xims_log("'%s' started for %s on %s.",
sel->name, userEnv.displayname, sel->hostname);
}
DPR2(("exec_remote_ims(): ret=%s[%d]\n", error_name(ret), ret));
return ret;
}
int check_hostname(hostname)
char *hostname;
{
int host_type = HOST_UNKNOWN;
char *local = userEnv.hostname;
struct hostent *hp;
unsigned long addr = 0L;
static unsigned long local_addr = 0L;
if (!hostname || !*hostname || strcasecmp(hostname, "local") == 0
|| strcasecmp(hostname, userEnv.hostname) == 0) {
host_type = HOST_LOCAL;
} else { /* compare inet address */
if (!local_addr) {
if ((hp = gethostbyname(local)) && hp->h_addrtype == AF_INET) {
local_addr = *((unsigned long *) hp->h_addr_list[0]);
} else {
DPR(("check_hostname(%s)\tgethostbyname() failed\n", local));
host_type = HOST_REMOTE;
}
}
if (host_type == HOST_UNKNOWN) {
if ((hp = gethostbyname(hostname)) && hp->h_addrtype == AF_INET) {
addr = *((unsigned long *) hp->h_addr_list[0]);
if (addr == local_addr)
host_type = HOST_LOCAL;
else
host_type = HOST_REMOTE;
} else {
DPR(("check_hostname(%s)\tunknown\n", hostname));
host_type = HOST_UNKNOWN;
}
}
}
DPR(("check_hostname(%s): [%s] addr=%#x, local=%#x\n", hostname,
host_type == HOST_LOCAL ? "LOCAL" :
(host_type == HOST_REMOTE ? "REMOTE" : "UNKNOWN"),
addr, local_addr));
return host_type;
}
int set_remote_confdata(confbuf, conflen)
char *confbuf;
int conflen;
{
char *av[2];
av[0] = confbuf; av[1] = NULL;
return set_window_data(1, av);
}
int read_remote_confdata(confbuf, conflen)
char **confbuf;
int *conflen;
{
char **av = NULL;
int ac = 0;
int ret;
ret = get_window_data(&ac, &av);
/* if (ac != 1) { FREE av[i]; return ErrBabData; } */
*confbuf = av[0];
*conflen = strlen(av[0]);
return NoError;
}
static int prepare_action(act_typ, av, ac)
int act_typ;
char **av;
int ac;
{
int ret;
ret = init_window_env();
if (ret != NoError) return ret;
switch (act_typ) {
case ACT_GETREMCONF:
change_window_status(WIN_ST_REMOTE_CONF);
break;
case ACT_RUNREMIMS:
change_window_status(WIN_ST_REMOTE_RUN);
break;
default: return ErrInternal;
}
ret = set_window_data(ac, av);
return NoError;
}
int get_window_status()
{
long *datap;
int len = 0;
int win_st;
if (winEnv.atom_status == None || winEnv.atom_owner == None)
return WIN_ST_NONE;
if (winEnv.atom_owner == None) return WIN_ST_NONE;
#if 0
if (winEnv.atom_owner == XtWindow(winEnv.TopW))
return winEnv.status;
#endif
win_st = WIN_ST_NONE;
if (read_property(winEnv.atom_status, XA_INTEGER, 32, False,
(char **)&datap, &len) == True && len > 0) {
win_st = datap[0];
FREE(datap);
}
return win_st;
}
int change_window_status(status)
int status;
{
if (winEnv.atom_status == None || winEnv.atom_owner == None)
return ErrInternal;
winEnv.status = status;
(void)XChangeProperty(winEnv.Dpy, winEnv.atom_owner,
winEnv.atom_status, XA_INTEGER,
32, PropModeReplace, (unsigned char *)&status, 1);
XSync(winEnv.Dpy, False);
DPR(("change_window_status(): new status=%d\n", status));
return NoError;
}
int set_window_data(ac, av)
int ac;
char **av;
{
register int i;
register int nbytes;
register char *buf, *bp;
if (winEnv.atom_data == None || winEnv.atom_owner == None)
return ErrInternal;
#ifdef DEBUG
if (DebugLvl >= 1) {
int i;
printf("set_window_data() av[%d] = { ", ac);
for (i = 0; i < ac; i++)
printf("\"%s\", ", av[i]);
printf("}\n");
}
#endif
for (i = 0, nbytes = 1; i < ac; i++)
nbytes += strlen(av[i]) + 1;
if (bp = buf = XtMalloc(nbytes)) { /* copy args into single buffer */
for (i = 0; i < ac; i++) {
if (av[i]) {
(void) strcpy(bp, av[i]);
bp += strlen(av[i]) + 1;
} else
*bp++ = '\0';
}
(void)XChangeProperty(winEnv.Dpy, winEnv.atom_owner,
winEnv.atom_data, XA_STRING, 8,
PropModeReplace, (unsigned char *)buf, nbytes);
XSync(winEnv.Dpy, False);
XtFree(buf);
}
DPR(("set_window_data(): len=%d data=\"%s\"\n", nbytes, buf));
return NoError;
}
int get_window_data(acp, avp)
int *acp;
char ***avp;
{
int ac;
char *data;
char **av;
int len = 0;
int i, j;
if (winEnv.atom_data == None || winEnv.atom_owner == None)
return ErrInternal;
if (read_property(winEnv.atom_data, XA_STRING, 8, True, &data, &len) != True) {
*acp = 0;
*avp = NULL;
return ErrRemoteData;
}
ac = 0; av = NULL;
if (len > 0) {
for (i = 1; i < len - 1; i++) if (data[i] == '\0') ac++;
av = (char **) ALLOC(ac + 1, char *);
j = 0;
if (ac == 1) {
av[j++] = data;
} else {
av[j++] = NEWSTR(data);
for (i = 1; i < len - 1; i++)
if (data[i] == '\0') {
av[j++] = NEWSTR(data + i + 1);
}
FREE(data);
}
av[j] = NULL;
}
#ifdef DEBUG
if (DebugLvl >= 2) {
int i;
printf("get_window_data() av[%d] = { ", ac);
for (i = 0; i < ac; i++)
printf("\"%s\", ", av[i]);
printf("}\n");
}
#endif
*acp = ac;
*avp = av;
return NoError;
}
static int read_property(prop, type, format, del_flag, datapp, lenp)
Atom prop;
Atom type;
int format;
int del_flag;
unsigned char **datapp;
unsigned long *lenp;
{
Atom realtype;
int realformat;
unsigned long bytesafter;
*datapp = NULL;
(void)XGetWindowProperty(winEnv.Dpy, winEnv.atom_owner,
prop, 0L, 1000000L, del_flag, type,
&realtype, &realformat, lenp,
&bytesafter, datapp);
if (realtype == None) {
return False;
} else if (realtype != type) { /* wrong type */
return False;
} else if (realformat != format) { /* wrong format */
if (*datapp != NULL) XtFree((char *)*datapp);
*datapp = NULL;
return False;
}
return True;
}

View File

@@ -0,0 +1,339 @@
/* @(#)$XConsortium: select.c /main/6 1996/11/21 12:17:43 cde-hp $ */
#include "xims.h"
static int fill_ims_ent(/* list, top, last */);
static int setup_local_selection(/* sel, list, conf_all */);
static int setup_remote_selection(/* sel */);
static int setup_user_selection(/* sel, list, idx */);
void ximsSelect()
{
int ret;
bool use_win;
char *def_ims;
ImsList *list = (ImsList *) 0;
FileSel *fsel = (FileSel *) 0;
UserSelection *sel = &userSel;
OpState = State_Select;
/* clear_UserSelection(sel); */
sel->iconic = -1;
if (!localList) {
if ((ret = get_ims_list(&list, NULL, False)) != NoError) {
OpState = State_Select_Err;
OpErrCode = ret;
return;
}
localList = list;
} else
list = localList;
use_win = True;
def_ims = NULL;
if (Opt.SelectMode == SEL_MODE_GIVEN) {
sel->name = NEWSTR(Opt.ImsName);
use_win = False;
} else {
if (read_user_selection(&sel->fsel, NULL) == NoError) {
fsel = sel->fsel;
#ifdef DEBUG
if (DebugLvl > 1) pr_FileSel(sel->fsel);
#endif
}
if (list->default_idx >= 0)
def_ims = list->elist[list->default_idx]->name;
if ((OpFlag & FLAG_NOSAVE) || Opt.SelectMode == SEL_MODE_NOAUTO) {
use_win = True;
} else if (Opt.SelectMode == SEL_MODE_AUTO) {
use_win = False;
#ifdef SelectMode_ONCE
} else if (Opt.SelectMode == SEL_MODE_ONCE) {
if (fsel->name)
use_win = False;
#endif /* SelectMode_ONCE */
#ifdef AutoSelectionForSoleIMS
} else if (list->num_ent == 1) {
DPR(("ximsSelect(): only one entry in locale_conf\n"));
sel->name = NEWSTR(list->elist[0]->name);
use_win = False;
#endif /* AutoSelectionForSoleIMS */
} else if (fsel) {
if (fsel->select_mode != SEL_MODE_NOAUTO
&& ((fsel->select_mode == SEL_MODE_AUTO ||
list->def_selmode == SEL_MODE_AUTO)
&& (def_ims || fsel->name))
#ifdef SelectMode_ONCE
|| ((fsel->select_mode == SEL_MODE_ONCE
|| list->def_selmode == SEL_MODE_ONCE)
&& fsel->name)
#endif /* SelectMode_ONCE */
)
use_win = False;
} else if (list->def_selmode == SEL_MODE_AUTO && def_ims) {
DPR(("ximsSelect(): def_selmode==AUTO in locale_conf\n"));
use_win = False;
}
}
if (sel->iconic == -1) {
sel->iconic = fsel ? fsel->iconic : 0;
} else if (sel->iconic != fsel->iconic) { /* this should never happen ! */
sel->flag |= F_SELECT_CHANGED;
}
if (fsel && fsel->select_mode == SEL_MODE_NONE) {
if (list->def_selmode != SEL_MODE_NONE) {
fsel->select_mode = list->def_selmode;
sel->flag |= F_SELECT_CHANGED;
}
}
if (!sel->name && fsel && fsel->name)
sel->name = NEWSTR(fsel->name);
else if (def_ims)
sel->name = NEWSTR(def_ims);
if (Opt.HostName)
sel->hostname = NEWSTR(Opt.HostName);
else if (fsel && fsel->hostname)
sel->hostname = NEWSTR(fsel->hostname);
if (sel->hostname)
sel->host_type = check_hostname(sel->hostname);
else
sel->host_type = HOST_LOCAL;
if (use_win == True) {
ret = setup_local_selection(sel, list, True);
ret = start_selection_window();
} else {
switch (sel->host_type) {
case HOST_REMOTE:
ret = setup_remote_selection(sel);
if (ret != NoError) {
put_xims_errmsg(ret, 0, 0, 0);
}
break;
case HOST_LOCAL:
ret = setup_local_selection(sel, list, False);
break;
case HOST_UNKNOWN:
ret = ErrUnknownHost;
/* put_xims_errmsg(ret, sel->hostname, 0, 0); */
break;
}
}
OpErrCode = ret;
OpState = ret == NoError ? State_Select_Done : State_Select_Err;
return;
}
static int fill_ims_ent(list, top, last)
ImsList *list;
int top, last;
{
int ret;
int i;
ImsConf *ims;
ImsEnt *ent;
/* if (top < 0 || last < 0) return 0; */
ims = (ImsConf *) 0;
for (i = top; i <= last; i++) { /* read IMS conf */
ret = NoError;
ent = list->elist[i];
if (!ent->ims) {
if (!ims) ims = ALLOC(1, ImsConf);
ret = read_imsconf(ims, ent->name, ent->fname);
if (ret == NoError) {
ent->ims = ims;
ims = (ImsConf *) 0;
}
}
if (ret == NoError)
set_ims_status(ent);
else
ent->status = ret;
}
if (ims) FREE(ims);
return last - top + 1;
}
static int setup_local_selection(sel, list, conf_all)
UserSelection *sel;
ImsList *list;
int conf_all;
{
int ret;
int idx, top, last;
idx = get_ims_idx(list, sel->name);
top = last = 0;
if (conf_all) last = list->num_ent - 1;
else if (idx >= 0) top = last = idx;
fill_ims_ent(list, top, last);
ret = setup_user_selection(sel, list, idx);
return ret;
}
static int setup_remote_selection(sel)
UserSelection *sel;
{
int ret;
int idx;
ImsList *new_list;
ret = get_remote_conf(&new_list, sel->hostname, NULL, sel->name);
if (ret == NoError) {
idx = get_ims_idx(new_list, sel->name);
ret = setup_user_selection(sel, new_list, idx);
}
return ret;
}
static int setup_user_selection(sel, list, idx)
UserSelection *sel;
ImsList *list;
int idx;
{
if (sel->name) {
if (idx >= 0) {
sel->ent = list->elist[idx];
sel->status = sel->ent->status;
} else {
/* this ims isn't registered in locale_conf */
sel->status = ErrNotRegistered;
}
} else
sel->status = ErrNoSelection;
sel->ims_idx = idx;
sel->list = list;
return sel->status;
}
int update_user_selection(sel, list, idx, host, host_type)
UserSelection *sel;
ImsList *list;
int idx;
char *host;
int host_type;
{
ImsEnt *ent;
if (idx < 0 || idx >= list->num_ent) return False;
ent = list->elist[idx];
if (ent->status != NoError) return False;
if (strcmp(sel->name, ent->name)) {
RENEWSTR(sel->name, ent->name);
}
if ((host) && (!(sel->hostname) || strcmp(sel->hostname, host))) {
RENEWSTR(sel->hostname, host);
}
sel->host_type = host_type;
if (sel->list && sel->list != localList && sel->list != list) {
clear_ImsList(sel->list);
FREE(sel->list);
}
sel->list = list;
sel->ent = ent;
sel->status = ent->status;
sel->ims_idx = idx;
sel->flag |= F_SELECT_CHANGED;
return True;
}
int get_ims_idx(list, name)
ImsList *list;
char *name;
{
int idx;
if (name) {
for (idx = 0; idx < list->num_ent; idx++)
if (strcmp(name, list->elist[idx]->name) == 0)
return idx;
}
return -1;
}
int set_ims_status(ent)
ImsEnt *ent;
{
int ret = NoError;
ImsConf *ims = ent->ims;
if (ent->name && strcmp(ent->name, NAME_NONE) == 0) {
ret = NoError;
} else if (!ims) {
ret = ErrNoImsConf;
} else if (ims->cmd_path && !(ims->flags & F_BUILTIN)
&& !is_executable(ims->cmd_path)) {
DPR(("set_ims_status(%s): executable '%s' not exist\n",
ent->name, ims->cmd_path));
ret = ErrNoExecutable;
}
ent->status = ret;
return ret;
}
int get_ims_list(listp, locale, fill_ent)
ImsList **listp;
char *locale;
int fill_ent;
{
int ret = NoError;
ImsList *list;
list = ALLOC(1, ImsList);
if ((ret = read_localeconf(list, locale)) != NoError) {
ret = ErrNoLocaleConf;
} else if (list->num_ent == 0) {
DPR(("get_ims_list(%s): no IMS in locale conf\n", locale));
ret = ErrNoImsEntry;
} else if (fill_ent) {
fill_ims_ent(list, 0, list->num_ent - 1);
}
if (ret == NoError) {
list->status = ret;
} else {
clear_ImsList(list);
FREE(list);
list = (ImsList *) 0;
}
*listp = list;
return ret;
}

View File

@@ -0,0 +1,946 @@
/* @(#)$TOG: start.c /main/9 1998/04/06 13:36:49 mgreess $ */
#include "xims.h"
#include <signal.h>
#include <sys/wait.h>
#include <setjmp.h>
#include <unistd.h>
#if (defined(USL) || defined(__uxp__) | defined(linux)) && !defined(_NFILE)
#define _NFILE FOPEN_MAX
#endif
#if !defined(linux)
extern char *sys_errlist[];
extern int sys_nerr;
#endif
/* local functions */
static int check_ims_opt(/* ptr */);
static char *find_session_resfile(/* res_type */);
static int check_selection(/* sel */);
static int build_run_env(/* sel */);
static int run_ims(/* sel */);
static int invoke_ims(/* sel */);
static void on_sig_chld(/* sig */);
static bool is_ims_running(/* renv, ims */);
static int settle_ims(/* sel */);
static Window property_owner(/* prop_atom, prop_str */);
# ifdef old_hpux
static void catch_alarm(/* sig */);
static int try_connection(/* sel */);
static int create_dummy_ic(/* xim */);
# endif /* old_hpux */
void ximsStart()
{
int ret;
UserSelection *sel = &userSel;
OpStateVal oldOpState = OpState;
DPR(("ximsStart(): OpState=%s OpErrCode=%s[%d]\n",
StateName(), error_name(OpErrCode), OpErrCode));
OpState = State_Start;
#ifdef DEBUG
if (DebugLvl > 1) pr_UserSelection(sel);
#endif
ret = NoError;
if (oldOpState == State_Select_Err) {
/* don't change OpErrCode */
OpState = State_Start_Err;
return;
}
if (oldOpState == State_Select_Canceled) {
clear_UserSelection(sel);
ret = ErrNoSelection;
} else { /* save selection */
if (!(OpFlag & FLAG_NOSAVE) && (sel->flag & F_SELECT_CHANGED)) {
if (save_user_selection(sel, NULL) != NoError) {
DPR(("save_user_selection(): failed\n"));
put_xims_warnmsg(ErrSaveSelection, 0, 0, 0);
/* ret = ErrSaveSelection; */
}
}
}
if (ret != NoError) {
OpErrCode = ret;
OpState = State_Start_Err;
return;
}
if ((ret = check_selection(sel)) != NoError) {
if (ret == ErrIsNone || ret == ErrNotRun) {
build_run_env(sel); /* for make_new_environ() */
}
OpErrCode = ret;
OpState = State_Start_Done;
return;
}
build_run_env(sel);
if (useWINDOW()) /* initilaize Xt */
init_window_env();
ret = run_ims(sel);
OpErrCode = ret;
OpState = ret == NoError ? State_Start_Done : State_Start_Err;
return;
}
void ximsWait()
{
OpStateVal oldOpState = OpState;
UserSelection *sel = &userSel;
struct timeval interval;
time_t start_tm = 0;
int lapse;
DPR(("ximsWait(): OpState=%s OpErrCode=%s[%d]\n",
StateName(), error_name(OpErrCode), OpErrCode));
OpState = State_Wait;
if (oldOpState == State_Start_Err) {
/* don't change OpErrCode */
OpState = State_Wait_Err;
return;
}
if (!is_waiting() || (OpFlag & FLAG_NOWAIT)) {
ximsWaitDone();
}
if (im_mod_available(sel->renv) != 1) {
if (useWINDOW()) {
xt_start_waiting(); /* never returns unless failed */
}
/* waiting */
lapse = 0;
interval.tv_sec = Opt.Interval / 1000;
interval.tv_usec = (Opt.Interval % 1000) * 1000;
start_tm = time((time_t) 0);
while (is_waiting()) {
select(0, 0, 0, 0, &interval); /* usleep */
lapse = (int) time((time_t) 0) - start_tm;
if (im_mod_available(sel->renv) != 0 || lapse >= Opt.Timeout) {
DPR(("ximsWait(tmout=%d): wait done (%d sec.)\n",
Opt.Timeout, lapse));
break;
}
}
}
ximsWaitDone();
}
void ximsWaitDone()
{
int ret;
UserSelection *sel = &userSel;
DPR(("ximsWaitDone():\tOpState=%s OpErrCode=%s[%d]\n",
StateName(), error_name(OpErrCode), OpErrCode));
set_sig_chld(False);
ret = sel->renv->status;
switch (ret) {
case ErrImsWaiting:
sel->status = ErrImsTimeout;
put_xims_log("'%s' timed-out.", sel->name, 0, 0);
break;
case ErrImsWaitDone:
sel->status = NoError;
# ifdef old_hpux
if ((OpFlag & FLAG_CONNECT)
|| (sel->ent->ims->flags & F_TRY_CONNECT)) {
sel->status = try_connection(sel);
}
# endif /* old_hpux */
break;
case ErrImsConnecting:
case ErrImsConnectDone:
sel->status = NoError;
break;
case ErrImsAborted:
/* put_xims_log("'%s' aborted.", sel->name, 0, 0); */
case ErrImsExecution:
default:
sel->status = ret;
break;
}
if (sel->status != NoError) {
OpErrCode = sel->status;
DPR(("ximsWaitDone(): OpErrCode=%s[%d]\n",
error_name(OpErrCode), OpErrCode));
}
restore_resources();
settle_ims(sel); /* clear WM_COMMAND property */
OpState = OpErrCode == NoError ? State_Wait_Done : State_Wait_Err;
ximsMain();
}
int is_waiting()
{
return userSel.renv && userSel.renv->status == ErrImsWaiting;
}
void set_sig_chld(enable)
int enable;
{
DPR(("set_sig_chld(%s)\n", enable ? "Enabled" : "Disabled"));
signal(SIGCLD, enable ? on_sig_chld : SIG_IGN);
}
int im_mod_available(renv)
RunEnv *renv;
{
Window owner;
if (!renv) {
if (!(renv = userSel.renv))
return -1;
}
if (renv->status != ErrImsWaiting)
return -1;
#ifdef DEBUG
if (DebugLvl >= 1) putc('.', LogFp), fflush(LogFp);
#endif
owner = property_owner(&renv->prop_atom, renv->atom_name);
if (owner != None) {
#ifdef ReconfirmProperty
{
int wait_period = 2; /* 2 sec. */
DPR(("im_mod_available(): [RECONFIRM] sleep(%d)\n", wait_period));
sleep(wait_period);
if (property_owner(&renv->prop_atom, renv->atom_name) == None) {
DPR(("\t[RECONFIRM] owner lost\n"));
return 0;
}
}
#endif /* ReconfirmProperty */
#ifdef DEBUG
if (DebugLvl >= 1) putc('\n', LogFp), fflush(LogFp);
#endif
DPR2(("check_im_mod(): wait done\n"));
renv->status = ErrImsWaitDone;
return 1;
}
return 0;
}
/* ***** IMS options ***** */
int mk_ims_option(ptr, sel)
char *ptr;
UserSelection *sel;
{
char *bp = ptr;
FileSel *fsel = sel->fsel;
ImsConf *ims = sel->ent->ims;
*bp = 0;
if (ims->flags & F_NO_OPTION) /* not applicable */
return 0;
if (fsel) {
if (fsel->com_opt /* common option */
&& check_ims_opt(fsel->com_opt)) {
/* bp = strcpyx(bp, fsel->com_opt); */
bp += expand_string(fsel->com_opt, bp, BUFSIZ, ims);
*bp++ = ' ';
}
if (fsel->opts) { /* individual option */
ImsOpt **op;
for (op = fsel->opts; *op; op++) {
if (strcmp((*op)->ims_name, sel->name) == 0
&& check_ims_opt((*op)->opt_str)) {
/* bp = strcpyx(bp, (*op)->opt_str); */
bp += expand_string((*op)->opt_str, bp, BUFSIZ, ims);
*bp++ = ' ';
}
}
}
}
if (Opt.ImsOption && check_ims_opt(Opt.ImsOption)) {
/* bp = strcpyx(bp, Opt.ImsOption); */
bp += expand_string(Opt.ImsOption, bp, BUFSIZ, ims);
}
if (sel->iconic > 0 && strstr(ptr, STR_ICONIC_OPT) == NULL) {
bp = strcpyx(bp, STR_ICONIC_OPT);
}
*bp = 0;
return (int) (bp - ptr);
}
static int check_ims_opt(ptr)
char *ptr;
{
/* option string must not contain any of shell's metacaharacters */
if (strpbrk(ptr, "`'\"#;&()|<>\n")) {
put_xims_log("ims option ignored: %s", ptr, 0, 0);
DPR(("\tshell's meta-char in option \"%s\" -- ignored\n", ptr));
return False;
}
return True;
}
/* ******** resource ******** */
#define RES_TYPE_DT 0
#define RES_TYPE_VUE 1
static bool resource_loaded = False;
int load_resources()
{
int ret;
int empty;
char *sess_res, *res_file;
if (resource_loaded) {
DPR2(("load_resources: already done -- not loaded\n"));
return False;
}
empty = !save_RM();
if (!empty) { /* load if RESOURCE_MANAGER is empty */
DPR2(("load_resources: RESOURCE_MANGER is not empty -- not loaded\n"));
return False;
}
sess_res = res_file = NULL;
if (!(OpFlag & FLAG_NORESOURCE)) {
if (isDT()) {
sess_res = find_session_resfile(RES_TYPE_DT);
}
# ifdef old_hpux
else if (isVUE()) {
sess_res = find_session_resfile(RES_TYPE_VUE);
}
# endif /* old_hpux */
if (sess_res && !is_readable(sess_res, False)) {
FREE(sess_res);
sess_res = NULL;
}
}
if (Opt.ResourceFile && is_readable(Opt.ResourceFile, False))
res_file = Opt.ResourceFile;
DPR(("load_resources():\tsess='%s' res='%s'\n", sess_res, res_file));
if (!isDT() && !sess_res && !res_file) return False;
if ((ret = open_display()) != NoError) return False;
ret = merge_RM(sess_res, res_file);
resource_loaded = True;
if (sess_res) FREE(sess_res);
return ret;
}
int restore_resources()
{
if (!resource_loaded) {
DPR2(("restore_resources: not loaded yet -- not restored\n"));
return False;
}
resource_loaded = False;
return restore_RM();
}
static char *find_session_resfile(res_type)
int res_type;
{
char path[MAXPATHLEN];
char **ls = (char **) 0, **pp;
char *res = NULL;
bool found = False;
if (res_type == RES_TYPE_DT) { /* DT */
res = Conf.dt ? (Conf.dt)->resPath : NULL;
}
# ifdef old_hpux
else if (res_type == RES_TYPE_VUE && Conf.vue) { /* VUE */
VueEnv *vue = Conf.vue;
res = vue->resPath;
if (vue->uselite) {
expand_string(vue->uselite, path, MAXPATHLEN, (ImsConf *)0);
if (access(path, R_OK) == 0)
res = vue->litePath;
}
}
# endif /* old_hpux */
if (!res) return NULL;
if (ls = parse_strlist(res, ':')) {
for (pp = ls; *pp; pp++) {
expand_string(*pp, path, MAXPATHLEN, (ImsConf *)0);
if (access(path, R_OK) == 0) {
found = True;
break;
}
}
FREE_LIST(ls);
}
/* DPR2(("find_session_resfile(): '%s'\n", path)); */
if (found)
return NEWSTR(path);
return NULL;
}
/* ***** local functions ***** */
static int check_selection(sel)
UserSelection *sel;
{
int ret = NoError;
if (!sel->name || !sel->list)
ret = ErrNoSelection;
else if (sel->ims_idx < 0 || sel->ims_idx >= sel->list->num_ent)
ret = ErrNoSelection;
else if (sel->status != NoError)
ret = sel->status;
else if (strcmp(sel->name, NAME_NONE) == 0)
ret = sel->status = ErrIsNone;
else if (sel->ent->ims->flags & F_NO_SERVER)
ret = sel->status = ErrNotRun;
else if (OpFlag & FLAG_NOSTART)
ret = sel->status = ErrNotRun;
return ret;
}
static int build_run_env(sel)
UserSelection *sel;
{
char *p;
int proto;
int len;
int tmout, intv;
char *log_path;
char *bp;
char envbuf[BUFSIZ], optbuf[BUFSIZ];
RunEnv *renv;
ImsConf *ims = sel->ent->ims;
char *cmd_param = ims->cmd_param ? ims->cmd_param : "";
renv = ALLOC(1, RunEnv);
renv->is_remote = sel->host_type == HOST_REMOTE ? True : False;
/* proto, im_mod & atom */
proto = renv->proto = default_protocol(ims);
if (p = Conf.xmod[proto]) {
char buf[BUFSIZ];
expand_string(p, buf, BUFSIZ, ims);
renv->im_mod = NEWSTR(buf);
}
if (p = Conf.atom[proto]) {
char buf[BUFSIZ];
expand_string(p, buf, BUFSIZ, ims);
renv->atom_name = NEWSTR(buf);
} else { /* copy im_mod, instead */
renv->atom_name = NEWSTR(renv->im_mod);
# ifdef old_hpux
if ((p = renv->atom_name) && strchr(p, '#')) {
while (p = strchr(p, '#')) /* replace '#' with '@' */
*p++ = '@';
}
# endif /* old_hpux */
}
/* others */
renv->pid = (pid_t) 0;
renv->status = NoError;
renv->wait_status = 0;
sel->renv = renv;
if (sel->status != NoError) /* ErrIsNone or ErrNotRun */
return sel->status;
if (renv->is_remote)
return NoError;
/* command line */
optbuf[0] = envbuf[0] = 0;
log_path = Opt.LogPath;
bp = envbuf;
/* set XMODIFIERS */
bp = strcpyx(bp, "XMODIFIERS='");
bp = strcpyx(bp, ENV_MOD_IM);
bp = strcpyx(bp, renv->im_mod);
bp = strcpyx(bp, "'");
*bp = 0;
/* Local, LANG & DISPLAY have been already set to *environ by putenv() */
/* IMS options */
mk_ims_option(optbuf, sel);
/* len = sysconf(_SC_ARG_MAX) / 2; len = Max(len, BUFSIZ); */
len = strlen(envbuf) + strlen(ims->cmd_path)
+ strlen(cmd_param) + strlen(optbuf) + strlen(log_path) + 40;
/* for local execution */
renv->cmdbuf = ALLOC(len, char);
sprintf(renv->cmdbuf, " %s; export XMODIFIERS; exec %s %s %s >> %s 2>&1 ",
envbuf, ims->cmd_path, cmd_param, optbuf, log_path);
/* timeout & interval */
if (Opt.Timeout > 0) tmout = Opt.Timeout;
else if (ims->timeout > 0) tmout = ims->timeout;
else tmout = DEFAULT_TIMEOUT;
if (Opt.Interval > 0) intv = Opt.Interval;
else if (ims->interval > 0) intv = ims->interval;
else intv = DEFAULT_INTERVAL;
tmout = Max(tmout, MIN_TIMEOUT);
intv = Max(intv, MIN_INTERVAL);
if (intv/1000 > tmout) intv = tmout * 1000;
/* else if (intv/10 < tmout) intv = tmout * 10; */
Opt.Timeout = tmout;
Opt.Interval = intv;
#ifdef DEBUG
if (DebugLvl >= 1) pr_RunEnv(sel->renv);
DPR(("build_run_env(): Timeout=%d (sec) Interval=%d (msec)\n",
tmout, intv));
#endif
return NoError;
}
static int run_ims(sel)
UserSelection *sel;
{
int ret = NoError;
if ((ret = open_display()) != NoError)
return ret;
if (is_ims_running(sel->renv, sel->ent->ims)) {
sel->status = ErrImsRunning;
DPR(("run_ims(): '%s' is already running\n", sel->name));
return sel->status;
}
load_resources();
if (sel->renv->is_remote) {
/* ret = set_host_acss(sel->hostname); */
ret = exec_remote_ims(sel);
return ret;
}
ret = invoke_ims(sel);
return ret;
}
static int invoke_ims(sel)
UserSelection *sel;
{
RunEnv *renv = sel->renv;
pid_t pid;
int i;
set_sig_chld(True);
pid = fork();
if (pid == (pid_t) -1) {
put_xims_log("fork failed [%s]",
(errno <= sys_nerr) ? sys_errlist[errno] : NULL, 0, 0);
#ifdef DEBUG
perror("fork");
#endif
return renv->status = ErrImsExecution;
}
if (pid == (pid_t) 0) { /* child */
for (i = 0; i < _NFILE; i++)
(void) close(i);
#ifdef __osf__
setsid();
#else
setpgrp();
#endif
execl(SH_PATH, "sh", "-c", renv->cmdbuf, NULL);
put_xims_log("%s: exec failed [%s]", SH_PATH,
(errno <= sys_nerr) ? sys_errlist[errno] : NULL, 0, 0);
/* perror(SH_PATH); */
sleep(1);
_exit(1);
}
/* parent */
renv->pid = pid;
renv->wait_status = 0;
renv->status = ErrImsWaiting;
put_xims_log("'%s' started for %s", sel->name, userEnv.displayname, 0);
DPR(("invoke_ims(%s): pid=%d\n", sel->name, pid));
return NoError;
}
static void on_sig_chld(sig)
int sig;
{
int wait_status = 0;
pid_t pid;
int cause;
RunEnv *renv = userSel.renv;
errno = 0;
do {
#ifdef _XPG4_EXTENDED
pid = wait3(&wait_status, WNOHANG, (struct rusage *)NULL);
#else
pid = waitpid((pid_t) -1, &wait_status, WNOHANG);
#endif /* _XPG4_EXTENDED */
} while (pid == -1 && errno == EINTR);
DPR(("\ton_sig_chld(): pid=%d errno=%d\n", pid, errno));
if (pid == -1)
return;
signal(SIGCLD, on_sig_chld);
if (WIFEXITED(wait_status)) {
cause = ErrImsAborted;
} else if (WIFSIGNALED(wait_status)) {
cause = ErrImsAborted;
} else { /* WIFSTOPPED(wait_status) */
return;
}
if (renv->pid == pid) {
if (renv->status == ErrImsWaiting || renv->status == ErrImsConnecting) {
renv->status = cause;
renv->wait_status = wait_status;
DPR(("on_sig_chld(): '%s' aborts (wait_status=%#x)\n",
userSel.name, wait_status));
put_xims_log("'%s' aborted.", userSel.name, 0, 0);
ximsWaitDone();
}
#ifdef DEBUG
else {
DPR(("\tsig_chld: renv->state=%s is not ErrImsWaiting\n",
error_name(renv->status)));
}
#endif
}
#ifdef DEBUG
else {
DPR(("\tsig_chld: pid=%d != renv->pid=%d\n", pid, renv->pid));
}
#endif
return;
}
static bool is_ims_running(renv, ims)
RunEnv *renv;
ImsConf *ims;
{
char *prop_str;
Window owner;
Atom *atomp;
if (prop_str = ims->property) {
atomp = (Atom *)0;
} else {
if (!(prop_str = renv->atom_name))
return False;
atomp = &renv->prop_atom;
}
owner = property_owner(atomp, prop_str);
DPR2(("is_ims_running(): prop='%s'[%d] owned by %#x\n",
prop_str, atomp ? *atomp : -1, owner));
#ifdef unused
/* check primary server name for XIM */
if (owner == None && !ims->property && renv->proto == Proto_XIM
&& ims->server_name2 && strstr(renv->atom_name, ims->server_name2) {
char buf[BUFSIZ], *p;
prop_str = strcpy(buf, renv->atom_name);
if (p = strchr(prop_str, '=')) {
strcpy(p + 1, ims->servername);
atomp = (Atom *)0;
owner = property_owner(atomp, prop_str);
DPR2(("is_ims_running(): prop='%s'[%d] owned by %#x\n",
prop_str, atomp ? *atomp : -1, owner));
}
}
#endif
return owner == None ? False : True;
}
static int settle_ims(sel)
UserSelection *sel;
{
if (isXsession()) {
char *prop_str;
Window owner;
Atom *atomp;
ImsConf *ims = sel->ent->ims;
owner = None;
if (prop_str = ims->property) {
atomp = (Atom *)0;
owner = property_owner(atomp, prop_str);
}
#if 0
else if (sel->renv) {
if (prop_str = sel->renv->atom_name)
owner = search_clear_cmd_property(prop_str);
}
#endif
if (owner)
clear_cmd_property(owner);
}
return NoError;
}
static Window property_owner(prop_atom, prop_str)
Atom *prop_atom;
char *prop_str;
{
Atom property = prop_atom ? *prop_atom : None;
if (property == None) {
property = XInternAtom(Dpy, prop_str, True);
if (property == None)
return None;
if (prop_atom)
*prop_atom = property;
}
return XGetSelectionOwner(Dpy, property);
}
# ifdef old_hpux
/* ***** try_connection ***** */
#define MAX_RETRY 5
static jmp_buf jmp_env;
static Window dmy_win = 0; /* temporary window used for XCreateIC() */
static void catch_alarm(sig)
int sig;
{
signal(SIGALRM, SIG_IGN);
alarm(0);
longjmp(jmp_env, 1);
}
static int try_connection(sel)
UserSelection *sel;
{
RunEnv *renv = sel->renv;
ImsConf *ims = sel->ent->ims;
char envbuf[BUFSIZ], *bp;
XIM xim;
int ic_ok, retry_cnt;
static char *saved_xmod = NULL;
#ifdef DEBUG
time_t last_time;
#endif
DPR(("try_connection(%s):\n", sel->name));
if (sel->status != NoError || !renv->im_mod)
return sel->status;
renv->status = ErrImsConnecting;
set_sig_chld(True);
/* set XMODIFIERS */
saved_xmod = NULL;
bp = strcpyx(envbuf, ENV_MOD_IM);
bp = strcpyx(bp, renv->im_mod);
saved_xmod = XSetLocaleModifiers(envbuf);
DPR(("\tXSetLocaleModifiers(%s)\n", envbuf));
ic_ok = False;
if (setjmp(jmp_env) == 0) {
signal(SIGALRM, catch_alarm);
alarm(Opt.Timeout);
for (retry_cnt = 0; !ic_ok && retry_cnt <= MAX_RETRY; retry_cnt++) {
if (retry_cnt) sleep(retry_cnt * retry_cnt);
#ifdef DEBUG
last_time = time((time_t)0);
#endif
xim = XOpenIM(Dpy, (XrmDatabase)0, ims->servername, ims->classname);
if (xim) {
DPR(("try_connection(%d): XOpenIM() OK [%d sec.]",
retry_cnt, time((time_t)0) - last_time));
#ifdef DEBUG
last_time = time((time_t)0);
#endif
ic_ok = create_dummy_ic(xim);
DPR(("\tXCreateIC() %s [%d sec.]\n",
ic_ok ? "OK" : "Failed", time((time_t)0) - last_time));
XCloseIM(xim); xim = 0;
} else {
DPR(("try_connection(%d): XOpenIM() failed.\n", retry_cnt));
ic_ok = False;
}
}
} else { /* long_jmp() by alarm [timeout] */
alarm(0); signal(SIGALRM, SIG_IGN);
DPR(("try_connection(): XOpenIM() & XCreateIC() timed-out.\n"));
if (dmy_win) {
XDestroyWindow(Dpy, dmy_win); dmy_win = 0;
}
/* neither XDestroyIC() nor XCloseIM() should be called */
xim = 0;
ic_ok = False;
}
alarm(0); signal(SIGALRM, SIG_IGN);
/* restore XMODIFIERS */
if (saved_xmod) {
DPR2(("\tXSetLocaleModifiers(save='%s')\n", saved_xmod));
XSetLocaleModifiers(saved_xmod);
}
set_sig_chld(False);
renv->status = ErrImsConnectDone;
return ic_ok ? NoError : ErrImsTimeout; /* ErrImsConnect; */
}
static int create_dummy_ic(xim)
XIM xim;
{
int scr;
XFontSet fset;
XIMStyles *im_styles;
XIMStyle style;
XIC ic;
unsigned long fg, bg;
XRectangle area;
XVaNestedList status_attr;
scr = DefaultScreen(Dpy);
fg = BlackPixel(Dpy, scr);
bg = WhitePixel(Dpy, scr);
dmy_win = XCreateSimpleWindow(Dpy, RootWindow(Dpy, scr),
0, 0, 1, 1, 0, bg, fg);
/* search (PreeditNothing | StatusNothing [or StatusArea]) style */
ic = 0;
style = (XIMStyle) 0;
im_styles = (XIMStyles *) 0;
if (XGetIMValues(xim, XNQueryInputStyle, &im_styles, NULL)) {
DPR(("create_dummy_ic(): XGetIMValues(XNQueryInutStyle) failed.\n"));
goto _err;
}
if (!im_styles || !im_styles->count_styles) {
DPR(("create_dummy_ic(): No input styles supported on IMS.\n"));
if (im_styles) XFree(im_styles);
goto _err;
}
if ((int)im_styles->count_styles > 0) {
int i, alt;
for (i = 0, alt = -1; i < (int)im_styles->count_styles; i++)
if (im_styles->supported_styles[i] & XIMPreeditNothing) {
if (im_styles->supported_styles[i] & XIMStatusNothing) {
style = im_styles->supported_styles[i];
break;
} else if (im_styles->supported_styles[i] & XIMStatusArea) {
alt = i;
}
}
if (!style && alt >= 0) style = im_styles->supported_styles[alt];
XFree(im_styles);
}
if (!style) {
DPR(("create_dummy_ic(): 'PreeditNothing' styles not supported.\n"));
goto _err;
/* style = XIMPreeditNothing | XIMStatusNothing; */
}
fset = 0;
status_attr = (XVaNestedList) 0;
if (style & XIMStatusArea) {
area.x = area.y = 0; area.width = area.height = 1;
status_attr = XVaCreateNestedList(NULL,
XNArea, &area,
XNForeground, fg,
XNBackground, bg,
XNFontSet, fset,
NULL );
}
ic = XCreateIC(xim, XNInputStyle, style,
XNClientWindow, dmy_win,
XNStatusAttributes, status_attr,
XNFocusWindow, dmy_win,
NULL );
/* if (fset) XFreeFontSet(Dpy, fset); */
if (ic) XDestroyIC(ic);
_err:
if (dmy_win) XDestroyWindow(Dpy, dmy_win);
dmy_win = 0;
return ic ? True : False;
}
# endif /* old_hpux */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,444 @@
/* $XConsortium: xims.h /main/6 1996/04/17 16:25:50 pascale $ */
/*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
#ifndef _XIMS_H_
#define _XIMS_H_ 1
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/param.h>
#include <sys/time.h>
#include "ximspath.h"
#include "ximserr.h"
/* operation modes */
#define MODE_START 0 /* default */
#define MODE_MODE 1 /* -mode option */
#define MODE_STYLE 2 /* -style option */
#define MODE_LIST 3 /* -list option */ /* no window */
#define MODE_CURRENT 4 /* -current option */ /* no window */
#define MODE_REMCONF 5 /* -remoteconf */ /* no window */
#define MODE_LISTNAME 6 /* -listname option */
/* operation flags */
#define FLAG_ENV (1<<0) /* -env option */
#define FLAG_NOSAVE (1<<1) /* -nosave option */
#define FLAG_NOSTART (1<<2) /* -nostart option (DEBUG) */
#define FLAG_NOWAIT (1<<3) /* -nowait option */
#define FLAG_NOTIMEOUT (1<<4) /* -notimeout option */
#define FLAG_NORESOURCE (1<<5) /* -noresource option */
#define FLAG_NOREMOTE (1<<6) /* -noremote option */
#define FLAG_NOTIFY (1<<7) /* -notify option */
#define FLAG_CONNECT (1<<8) /* -connect option */
#define FLAG_REMOTERUN (1<<9) /* -remoterun option */
#define FLAG_WINDOW (1<<10) /* -window option */
#define FLAG_DT (1<<11) /* -dt option */
# ifdef old_hpux
#define FLAG_VUE (1<<12) /* -vue option */
# endif /* old_hpux */
#define FLAG_DEFAULT (FLAG_DT)
# ifdef old_hpux
#define USE_WINDOW_MASK (FLAG_WINDOW|FLAG_VUE|FLAG_DT)
# else
#define USE_WINDOW_MASK (FLAG_WINDOW|FLAG_DT)
# endif /* old_hpux */
#define MAXIMSENT 32 /* max # of ims for each locale */
#define MIN_INTERVAL 100 /* msec */
#define DEFAULT_INTERVAL 1000 /* msec */
#define MIN_TIMEOUT 1 /* sec */
#define DEFAULT_TIMEOUT 180 /* sec */
#define REMOTE_TIMEOUT 60 /* sec */
#define TAG_END_CHAR ':'
#define TAG_SEP_CHAR '.'
#define LIST_SEP_CHAR ','
#define COMMENT_CHAR '!'
#define COMMENT_CHAR2 '#'
#define COMMENT_CHARS "!#"
#define NAME_NONE "none"
#define NAME_LOCAL "local"
#define NAME_BUILTIN "builtin"
#define NAME_DEFAULT "@"
#define NAME_DEFAULT_CHAR '@'
#define DUMMY_SERVER_NAME NAME_DEFAULT
#define STR_PREFIX_CHAR '@'
#define STR_DEFAULTIMS "DefaultIms"
#define STR_SELECTMODE "SelectMode"
#define STR_IMSNAME "ImsName"
#define STR_HOSTNAME "HostName"
#define STR_ICONIC "IconicMode"
#define STR_IMSOPTION "ImsOption"
#define STR_ERRORCODE "#ErrorCode"
#define STR_ERRORPATH "#ErrorPath"
#define STR_CONFDATA "#IMSSTART-CONFDATA-1.0"
#define STR_ICONIC_OPT "-iconic"
/* protocol index */
#define Proto_None 0
#define Proto_XIM 1
#define Proto_Ximp 2
#define Proto_Xsi 3
# ifdef old_hpux
#define Proto_Xhp 4
#define NUM_PROTOCOLS 5
# else
#define NUM_PROTOCOLS 4
# endif /* old_hpux */
/* protocol flag */
#define ProtoBit(i) (1<<(i))
/* window state */
#define WIN_ST_NONE 0
#define WIN_ST_INIT 1
#define WIN_ST_REMOTE_CONF 2
#define WIN_ST_REMOTE_RUN 3
#define WIN_ST_ACTION_DONE 4
/* ims server flag */
#define F_NO_SERVER (1<<0)
#define F_NO_REMOTE (1<<1)
#define F_NO_OPTION (1<<2)
#define F_HAS_WINDOW (1<<3)
#define F_TRY_CONNECT (1<<4)
#define F_BUILTIN (1<<8)
/* user selection flag */
#define F_SELECT_NONE 0
#define F_SELECT_FILE (1<<0)
#define F_SELECT_WINDOW (1<<1)
#define F_SELECT_CHANGED (1<<4)
/* select_mode */
#define NUM_SEL_MODE 2
#define SEL_MODE_NOAUTO 0
#define SEL_MODE_AUTO 1
#define SEL_MODE_ONCE 2
#define SEL_MODE_NONE -1
#define SEL_MODE_GIVEN -2
#define SEL_MODE_QUERY -3
#define SEL_MODE_WIN -4
/* host type */
#define HOST_LOCAL 0
#define HOST_REMOTE 1
#define HOST_UNKNOWN 2
# ifdef old_hpux
/* index for XhpLocale */
#define XHP_JPN 0
#define XHP_KOR 1
#define XHP_CHS 2
#define XHP_CHT 3
#define XHP_LANG_NUM 4
# endif /* old_hpux */
/* message type for put_msg_win() */
#define MSGTYP_INFO 0
#define MSGTYP_WARN 1
#define MSGTYP_FATAL 2
#define MSGTYP_CONFIRM 3
/* help message type for ximsHelp() */
#define HELP_SELECTION 0
#define HELP_MODE 1
/* actions internally used */
#define ACT_GETREMCONF 0
#define ACT_RUNREMIMS 1
#define NUM_ACTIONS 2
#define ACTION_MASK 0xf0
typedef short bool;
/* operation states */
typedef enum {
State_None = 0,
State_Init,
State_Init_Err,
State_Init_Done,
State_Select,
State_Select_Err,
State_Select_Canceled,
State_Select_Done,
State_Start,
State_Start_Err,
State_Start_Done,
State_Wait,
State_Wait_Err,
State_Wait_Done,
State_Finish,
State_Finish_Err,
State_Finish_Defered,
State_Finish_Done,
State_Mode,
State_Mode_Canceled,
State_Mode_Done,
State_Action_Invoked,
State_Action_Waiting,
State_Action_Done,
State_Action_Err,
State_Last
} OpStateVal;
/* structure definitions */
typedef struct {
char *name;
char *value;
} EnvEnt;
typedef struct {
char *ims_name;
char *opt_str;
} ImsOpt;
typedef struct {
EnvEnt *set;
EnvEnt *unset;
} OutEnv;
# ifdef old_hpux
typedef struct {
char *name;
char *aliases;
} LocaleAlias;
typedef struct {
char type;
char *locales;
} XhpLocale;
typedef struct {
char *confDir; /* override /etc/vue/config */
char *userDir; /* override .vue */
char *uselite; /* $HOME/.vue/sessions/usevuelite */
char *resPath; /* path of session resource (colon separated) */
char *litePath;
} VueEnv;
# endif /* old_hpux */
typedef struct {
char *confDir; /* override /usr/dt/config */
char *userDir; /* override .dt */
char *resPath; /* path of session resource (colon separated) */
} DtEnv;
typedef struct {
bool disabled; /* disable remote execution */
bool useRemsh; /* use remsh(1) instead of action */
int timeout; /* timeout for remote execution */
char *passEnv; /* env vars passed to remote IMS */
} RemoteEnv;
typedef struct {
int flags;
int protocols;
int timeout;
int interval;
char *servername;
char *servername2;
char *classname;
char *property;
char *cmd_path;
char *cmd_param;
char *env_set;
char *env_unset;
char *env_pass;
} ImsConf;
typedef struct {
int status;
char *name;
char *fname;
char *label;
ImsConf *ims;
} ImsEnt;
typedef struct {
short status;
short default_idx;
short def_selmode;
short num_ent;
ImsEnt **elist;
} ImsList;
typedef struct {
int status;
int wait_status;
pid_t pid;
bool is_remote;
int proto;
char *im_mod;
char *atom_name;
char *cmdbuf;
Atom prop_atom;
} RunEnv;
typedef struct {
bool dpy_specific;
short select_mode;
short iconic;
char *name;
char *hostname;
char *com_opt;
ImsOpt **opts;
char *real_fname; /* actually read */
} FileSel;
typedef struct {
int flag; /* F_SELECT_* */
int status; /* error code */
int ims_idx; /* index of selected ims to list->elist[] */
int host_type; /* host type: HOST_{LOCAL|REMOTE|UNKNOWN} */
int iconic; /* iconic mode: */
char *name; /* selected ims */
char *hostname; /* current host */
ImsList *list; /* current list */
ImsEnt *ent; /* selected ims ent */
FileSel *fsel; /* original selection on file */
RunEnv *renv; /* run env used on start.c & env.c */
} UserSelection;
typedef struct {
char *hostname;
char *username;
char *locale;
char *real_locale;
char *CDE_locale;
char **locale_aliases;
char *homedir;
char *displayname;
char *displaydir;
char *xmodifiers;
short screen_num;
} UserEnv;
typedef struct {
char *DisplayName; /* override $DISPLAY */
char *LocaleName; /* override $LANG */
char *ConfPath; /* override $CONF/start.conf */
char *UserPath; /* override $HOME/.xims/<locale> */
char *LogPath; /* override $HOME/.xims/ximslog */
char *ResourceFile; /* resource file for IMS */
char *ImsName; /* IMS name */
char *ImsOption; /* IMS option */
char *HostName; /* remote host name */
char *ShellName; /* shell name */
int Timeout; /* wait timeout (sec) */
int Interval; /* check interval (msec) */
int SelectMode; /* SEL_MODE_* */
int Listname; /* Used only from dtstyle */
} CmdOpt;
typedef struct {
char *imsConfDir; /* [%I] /usr/dt/config/ims/ */
char *imsAppDir; /* [%R] /usr/dt/app-defaults/ */
char *imsLogDir; /* [%G] /var/dt/ */
char *imsLogFile; /* [%g] imslog */
char *imsDir; /* [%b] ims */
char *userImsDir; /* [%S] $HOME/.dt/ims/ */
char *userTmpDir; /* [%T] $HOME/.dt/tmp/ */
char *userAltDir; /* [%A] alt tmp /var/tmp/ */
char *xmod[NUM_PROTOCOLS]; /* format of XMODIFIERS */
char *atom[NUM_PROTOCOLS]; /* atom name to be examined */
char *action[NUM_ACTIONS]; /* actions internally used */
DtEnv *dt;
RemoteEnv *remote;
# ifdef old_hpux
VueEnv *vue;
XhpLocale *xhp;
LocaleAlias **alias;
# endif /* old_hpux */
} CmdConf;
typedef struct {
int status;
Display *Dpy;
Widget TopW;
Window atom_owner;
Atom atom_main;
Atom atom_status;
Atom atom_data;
XtAppContext appC;
} WinEnv;
/* Global Variables */
extern char *ProgramRevision; /* on main.c */
extern Display *Dpy; /* display (on win.c) */
extern Widget TopW; /* toplevel-shell (on win.c) */
extern XtAppContext appC;
# ifdef _EXTERN_DEFINE_
#define Extern
# else
#define Extern extern
# endif /* _EXTERN_DEFINE_ */
Extern OpStateVal OpState;
Extern int OpMode; /* one of MODE_* */
Extern int OpFlag; /* bitOR of FLAG_* */
Extern CmdOpt Opt; /* command line options */
Extern CmdConf Conf;
Extern WinEnv winEnv;
Extern UserEnv userEnv;
Extern UserSelection userSel;
Extern ImsList *localList;
Extern char *ProgramName; /* invoked program name */
Extern int ProgramType; /* same as OpMode */
Extern int Verbose; /* verbose flag */
Extern int DebugLvl; /* debug flag */
Extern FILE *LogFp; /* log file */
Extern int Wargc; /* argc for XtAppInitialize */
Extern char **Wargv; /* argv for XtAppInitialize */
Extern bool WaitingDialogReply;
Extern bool WaitingActionDone;
Extern bool UseMsgWindow;
Extern bool IsRemote;
Extern int LastErrMsg;
#undef Extern
# ifdef old_hpux
#define isXsession() ((OpFlag & (FLAG_VUE|FLAG_DT)) ? True : False)
#define isVUE() ((OpFlag & FLAG_VUE) ? True : False)
# else
#define isXsession() ((OpFlag & FLAG_DT) ? True : False)
#define isVUE() (False)
# endif /* old_hpux */
#define isDT() ((OpFlag & FLAG_DT) ? True : False)
#define useWINDOW() \
(((OpFlag & USE_WINDOW_MASK) || window_env_ok()) ? True : False)
#define RemoteOn() \
(((OpFlag & FLAG_NOREMOTE) || Conf.remote->disabled) ? False : True)
#include "ximsfunc.h"
#endif /* _XIMS_H_ */

View File

@@ -0,0 +1,97 @@
/* @(#)$XConsortium: ximserr.h /main/3 1996/05/07 14:02:24 drk $ */
#ifndef _XIMSERR_H_
#define _XIMSERR_H_ 1
#include <errno.h>
/* Error Codes */
#define NO_ERROR 0
#define ERROR_BASE -200
typedef enum {
NoError = 0,
ErrSyntax = ERROR_BASE, /* -200 */
ErrNoHome, /* -199 */
ErrNoLocale, /* -198 */
ErrNoCDELocale, /* -197 */
ErrNoDisplay, /* -196 */
ErrDisabled, /* -195 */
ErrSignaled, /* -194 */
/* File I/O */
ErrFileOpen, /* -193 */
ErrFileCreate, /* -192 */
ErrDirCreate, /* -191 */
ErrMissEntry, /* -190 */
/* Selection */
ErrAnotherProg, /* -189 */
ErrNoSelectionFile, /* -188 */
ErrSaveSelection, /* -187 */
ErrNoSelection, /* -186 */
ErrNoLocaleConf, /* -185 */
ErrNoImsEntry, /* -184 */
ErrNoImsConf, /* -183 */
ErrNotRegistered, /* -182 */
ErrNoExecutable, /* -181 */
/* Start */
ErrImsRunning, /* -180 */
ErrImsExecution, /* -179 */
ErrImsAborted, /* -178 */
ErrImsTimeout, /* -177 */
/* Remote */
ErrUnknownHost, /* -176 */
ErrRemoteAction, /* -175 */
ErrRemoteData, /* -174 */
ErrRemoteNoIms, /* -173 */
ErrRemoteMissIms, /* -172 */
ErrNoImsstart, /* -171 */
ErrRemoteIms, /* -170 */
/* X */
ErrOpenDpy, /* -169 */
ErrOpenResource, /* -168 */
/* Misc */
ErrMemory, /* -167 */
/* Internal */
ErrIsNone, /* -166 */
ErrNotRun, /* -165 */
ErrImsWaiting, /* -164 */
ErrImsWaitDone, /* -163 */
ErrImsConnecting, /* -162 */
ErrImsConnectDone, /* -161 */
ErrInvState, /* -160 */
ErrInternal, /* -159 */
LastErrorCode /* -158 */
} ximsError;
/* Global Variabls */
# ifdef _EXTERN_DEFINE_
#define Extern
# else
#define Extern extern
# endif /* _EXTERN_DEFINE_ */
Extern ximsError OpErrCode;
Extern void *ximsErrArgs[3];
Extern char errFilePath[MAXPATHLEN];
Extern char *errFuncName;
/* Macros for setting parameters of error messages */
#define _setErrArg(n, arg) ximsErrArgs[n] = (void *)(arg)
#define setErrArg1(arg) _setErrArg(0, arg)
#define setErrArg2(arg) _setErrArg(1, arg)
#define setErrArg3(arg) _setErrArg(2, arg)
#define setErrFile(path) strcpy(errFilePath, (path))
#define setErrFunc(name) errFuncName = (name)
#undef Extern
#endif /* _XIMSERR_H_ */

View File

@@ -0,0 +1,223 @@
/* @(#)$XConsortium: ximsfunc.h /main/2 1996/05/07 14:02:55 drk $ */
#ifndef _XIMSFUNC_H_
#define _XIMSFUNC_H_ 1
/* External Functions */
/* main.c */
extern void sigExit(/* sig */);
extern void Exit(/* err_code */);
extern int NotifyErrCode(/* err_code */);
extern int ErrFilePathNeeded(/* error */);
extern int InWaitingState(/* */);
extern void ximsMain(/* */);
extern void ximsFinish(/* */);
extern char *xims_errmsg(/* err_num, arg1, arg2, arg3 */);
/* env.c */
extern int set_cmd_env(/* */);
extern int get_user_environ(/* */);
extern int expand_string(/* in_str, out_str, out_len, ims */);
extern int make_new_environ(/* oenv, sel */);
extern int put_new_environ(/* oenv */);
extern int set_remote_env(/* ptr, env_pass */);
extern char *xhp_xinput_name(/* locale */);
extern char *get_real_locale(/* locale, aliases */);
/* select.c */
extern void ximsSelect(/* */);
extern int update_user_selection(/* sel, list, idx, host, host_type */);
extern int get_ims_idx(/* list, name */);
extern int set_ims_status(/* ent */);
extern int get_ims_list(/* listp, locale, fill_ent */);
/* start.c */
extern void ximsStart(/* */);
extern void ximsWait(/* */);
extern void ximsWaitDone(/* */);
extern int is_waiting(/* */);
extern void set_sig_chld(/* enable */);
extern int im_mod_available(/* renv */);
extern int mk_ims_option(/* ptr, sel */);
extern int load_resources(/* */);
extern int restore_resources(/* */);
/* remote.c */
extern int put_remote_conf(/* locale, ims_name */);
extern int get_remote_conf(/* listp, hostname, locale, ims_name */);
extern int exec_remote_ims(/* sel */);
extern int check_hostname(/* hostname */);
extern int set_remote_confdata(/* confbuf, conflen */);
extern int read_remote_confdata(/* confbuf, conflen */);
extern int get_window_status(/* */);
extern int change_window_status(/* status */);
extern int set_window_data(/* ac, av */);
extern int get_window_data(/* acp, avp */);
/* action.c */
extern int invoke_action(/* action, host */);
extern void send_dtims_msg(/* msg, errcode */);
extern void dtims_msg_proc(/* w, cd, event, continue_dispatch */);
/* file.c */
extern int create_xims_dir(/* */);
extern int init_log_file(/* org_path, check_size */);
extern int set_errorlog(/* path */);
extern int read_cmd_conf(/* */);
extern int expand_cmd_conf(/* */);
extern int read_imsconf(/* conf, ims_name, ims_fname */);
extern int check_ims_conf(/* ims, ims_name */);
extern int read_localeconf(/* list, locale_name */);
extern int read_user_selection(/* fselp, locale_name */);
extern int read_selection_file(/* fsel, fp */);
extern int save_user_selection(/* sel, locale_name */);
extern int get_select_mode(/* */);
extern int set_select_mode(/* cur_mode, new_mode */);
extern int parse_protolist(/* valp */);
extern int default_protocol(/* conf */);
/* win.c */
extern int open_display(/* */);
extern void close_display(/* */);
extern int window_env_ok(/* */);
extern int init_window_env(/* */);
extern void end_window_env(/* */);
extern int clear_cmd_property(/* win */);
extern int save_RM(/* */);
extern int merge_RM(/* res1, res2 */);
extern int restore_RM(/* */);
extern int start_selection_window(/* */);
extern int start_mode_window(/* cur_mode */);
extern void stop_help(/* */);
extern void ximsHelp(/* help_type */);
extern int put_msg_win(/* type, msg */);
extern void xevent_loop(/* */);
extern void xt_start_waiting(/* */);
extern void xt_stop_waiting(/* */);
/* util.c */
/* string */
extern char *strcpyx(/* dest, src */);
extern char *strcpy2(/* dest, src1, src2 */);
extern char *newstradded(/* src1, src2, src3 */);
extern int str_to_int(/* ptr, val */);
extern bool str_to_bool(/* ptr, def_val */);
extern char *trim_line(/* ptr */);
extern char **parse_strlist(/* ptr, sep_ch */);
extern int pack_strlist(/* ptr, listp, sep_ch */);
extern void free_strlist(/* pp */);
extern bool parse_dpy_str(/* display_str, host, dnum, snum, dnet */);
extern char *std_dpy_str(/* display_str, snum */);
/* file & dir */
extern int make_user_dir(/* path */);
extern char *dirname(/* path */);
extern int is_directory(/* path, must_writable */);
extern int is_regularfile(/* path */);
extern int is_emptyfile(/* path */);
extern int is_executable(/* path */);
extern int is_writable(/* path */);
extern int is_readable(/* path, allow_empty */);
/* file read */
extern int start_tag_line(/* fname */);
extern int read_tag_line(/* fp, tagp, valp */);
/* error messges */
extern void put_xims_msg(/* msg_type, err_num, arg1, arg2, arg3 */);
extern void put_xims_errmsg(/* err_num, arg1, arg2, arg3 */);
extern void put_xims_warnmsg(/* err_num, arg1, arg2, arg3 */);
extern void print_msg(/* fmt, arg1, arg2, arg3, arg4, arg5 */);
extern int put_xims_log(/* fmt, arg1, arg2, arg3 */);
/* clear structure */
extern void clear_ImsConf(/* ims */);
extern void clear_ImsEnt(/* ent */);
extern void clear_ImsList(/* list */);
extern void clear_FileSel(/* fsel */);
extern void clear_UserSelection(/* sel */);
extern void clear_RunEnv(/* renv */);
extern void clear_OutEnv(/* oenv */);
extern void clear_UserEnv(/* */);
extern void clear_CmdConf(/* */);
extern void clear_WinEnv(/* */);
extern void clear_CmdOpt(/* */);
extern void clear_All(/* */);
# ifdef DEBUG
/* print structure */
extern void pr_FileSel(/* fsel */);
extern void pr_UserSelection(/* sel */);
extern void pr_ImsConf(/* conf, ims_name */);
extern void pr_ImsEnt(/* ent, idx */);
extern void pr_ImsList(/* list */);
extern void pr_WinEnv(/* wenv */);
extern void pr_RunEnv(/* renv */);
extern void pr_UserEnv(/* */);
extern void pr_OutEnv(/* oenv */);
extern void pr_CmdConf(/* */);
extern void pr_CmdOpt(/* */);
extern void pr_OpModeFlag(/* */);
extern char *StateName(/* */);
extern char *error_name(/* error */);
extern char *proto_name(/* proto_idx */);
extern char *sig_name(/* sig */);
extern void pr_brk(/* msg */);
# endif /* DEBUG */
/* Macros */
/* memory */
#define CLR(p, st) memset((void *) p, 0, sizeof(st))
#define COPY(d, s, n, st) memcpy((void *)(d), (void *)(s), (n) * sizeof(st))
# ifdef DEBUG_MEM
void *_mp_;
#define ALLOC(n, st) (_mp_ = XtCalloc(n, sizeof(st)), \
print_msg("ALLOC(%d, " #st "): _mp_=%p sz=%d\n", n, _mp_, sizeof(st)), (st *) _mp_)
#define REALLOC(p, n, st) ( _mp = XtRealloc((char *) (p), (n) * sizeof(st)), \
print_msg("REALLOC(%p, %d, " #st "): _mp_=%p\n", p, n, _mp_), (st *) _mp_)
#define NEWSTR(s) (_mp_ = (s) && *(s) ? XtNewString(s) : NULL, \
print_msg("NEWSTR(%s): _mp_=%p\n", s, _mp_), (char *) _mp_)
#define FREE(p) (print_msg("FREE(%p)\n", p), XtFree((char *) p), (p) = 0)
#define RENEWSTR(p, s) (_mp_ = (s) && *(s) ? XtNewString(s) : NULL, \
print_msg("RENEWSTR(" #p "): %p(%s) => %p(%s)\n", p, p, _mp_, s), \
XtFree((char *) p), (p) = (char *) _mp_)
# else /* DEBUG_MEM */
#define ALLOC(n, st) (st *) XtCalloc(n, sizeof(st))
#define REALLOC(p, n, st) (st *) XtRealloc((char *) (p), (n) * sizeof(st))
#define NEWSTR(s) ((s) && *(s)) ? XtNewString(s) : NULL
#define FREE(p) XtFree((char *) p), (p) = 0
#define RENEWSTR(p, s) XtFree((char *) p), (p) = NEWSTR(s)
# endif /* DEBUG_MEM */
#define FREE_LIST(pp) free_strlist(pp), (pp) = 0
/* string */
#define is_default_name(p) (*(p) == NAME_DEFAULT_CHAR)
#define to_upper_ch(c) ((c) & ~0x20)
#define to_lower_ch(c) ((c) | 0x20)
#define to_upper_str(p) while (*(p)) *(p)++ &= ~0x20
#define to_lower_str(p) while (*(p)) *(p)++ |= 0x20
#define is_comment_char(c) ((c) == COMMENT_CHAR || (c) == COMMENT_CHAR2)
#define is_white(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
#define skip_white(p) while (is_white(*(p))) (p)++
#define next_field(p) \
for ((p)++; *(p) && !is_white(*(p)); (p)++) ; skip_white(p)
#define cut_field(p) \
for ((p)++; *(p) && !is_white(*(p)); (p)++) ; *(p)++ = 0; skip_white(p)
/* misc */
#define Max(a, b) ((a) < (b) ? (b) : (a))
#define Min(a, b) ((a) > (b) ? (b) : (a))
/* for DEBUG */
# ifdef DEBUG
#define DPR(msg) if (DebugLvl >= 1) print_msg msg
#define DPR2(msg) if (DebugLvl >= 2) print_msg msg
#define DPR3(msg) if (DebugLvl >= 3) print_msg msg
# else
#define DPR(msg)
#define DPR2(msg)
#define DPR3(msg)
# endif /* DEBUG */
#endif /* _XIMSFUNC_H_ */

View File

@@ -0,0 +1,92 @@
/* @(#)$XConsortium: ximspath.h /main/3 1996/05/07 14:03:38 drk $ */
#ifndef _XIMSPATH_H_
#define _XIMSPATH_H_
#include <sys/param.h>
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
/* dtimsstart */
/* command */
#define DTIMS_PROGNAME "dtimsstart"
#define DTIMS_CLASS "Dtimsstart"
/* atom for properties */
#define DTIMS_ATOM_MAIN "_DTIMSSTART_MAIN"
#define DTIMS_ATOM_STATUS "_DTIMSSTART_STATUS"
#define DTIMS_ATOM_DATA "_DTIMSSTART_DATA"
/* environment */
#define ENV_DTIMS_STARTCONF "DTIMS_STARTCONF"
#define ENV_NO_DTIMSSTART "NODTIMSSTART"
#define ENV_XFILESEARCHPATH "XFILESEARCHPATH"
#define ENV_XFILESEARCHPATH_STRING \
"/etc/dt/app-defaults/%L/%N:/etc/dt/app-defaults/C/%N:/usr/dt/app-defaults/%L/%N:/usr/dt/app-defaults/C/%N"
#define ENV_NLSPATH "NLSPATH"
#define ENV_NLSPATH_STRING \
"/usr/dt/lib/nls/msg/%L/%N.cat:/usr/dt/lib/nls/msg/C/%N.cat"
/* configuration */
#define DTIMS_CONFDIR "/usr/dt/config/ims"
#define DTIMS_APPDIR "/usr/dt/app-defaults"
#define DTIMS_CONFFILE "start.conf"
/* path of executable (used for remote execution) */
#define DTIMS_CMDPATH "/usr/dt/bin/dtimsstart"
/* user dir */
#define DTIMS_IMSDIR "ims" /* [%b] */
#define DTIMS_LOGDIR "/var/dt" /* [%G] */
#define DTIMS_LOGFILE "imslog" /* [%g] */
/* user dir */
#define DTIMS_USRIMSDIR "%U/ims" /* [%S] $HOME/.dt/ims/ */
#define DTIMS_USRTMPDIR "%U/tmp" /* [%T] $HOME/.dt/tmp/ */
#define DTIMS_USRALTDIR "/var/tmp" /* [%A] */
#define DEFAULT_LOGPATH "%S/%g" /* $HOME/.dt/ims/imslog */
#define ALT_LOGPATH "%A/%g.%u" /* /var/tmp/imslog.$USER */
#define MAX_LOGSIZE (20 * 1024) /* 20 KB */
/* Actions */
#define NAME_ACT_GETREMCONF "DtImsGetRemoteConf"
#define NAME_ACT_RUNREMIMS "DtImsRunRemoteIms"
/* IMS */
/* environment */
#define ENV_XMODIFIERS "XMODIFIERS"
#define ENV_DISPLAY "DISPLAY"
#define ENV_LANG "LANG"
#define ENV_MOD_IM "@im="
/* format of XMODFIERS=@im */
#define IM_XMOD_XIM "%n"
#define IM_XMOD_XIMP "_XIMP_%L#%n.%s"
#define IM_XMOD_XSI "_XIM_INPUTMETHOD"
/* protocol atom name */
#define IM_ATOM_XIM "@server=%N"
#define IM_ATOM_XIMP "_XIMP_%L@%n.%s"
#define IM_ATOM_XSI "_XIM_INPUTMETHOD"
/* command path */
#define SH_PATH "/usr/bin/sh"
#define CAT_PATH "/usr/bin/cat"
#define XRDB_PATH "/usr/bin/X11/xrdb"
#define DTSESSION_RES_PATH "/usr/dt/bin/dtsession_res"
# ifdef old_hpux
/* VUE dirs */
#define VUE_CONFDIR "/etc/vue/config"
#define VUE_USERDIR "%H/.vue"
# endif /* old_hpux */
/* DT dirs */
#define DT_CONFDIR "/usr/dt/config"
#define DT_USERDIR "%H/.dt"
#endif /* _XIMSPATH_H_ */