/*
Copyright 1990-2001 Sun Microsystems, Inc. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions: The above copyright notice and this
permission notice shall be included in all copies or substantial
portions of the Software.


THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.


Except as contained in this notice, the names of The Open Group and/or
Sun Microsystems, Inc. shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without prior
written authorization from The Open Group and/or Sun Microsystems,
Inc., as applicable.


X Window System is a trademark of The Open Group

OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
logo, LBX, X Window System, and Xinerama are trademarks of the Open
Group. All other trademarks and registered trademarks mentioned herein
are the property of their respective owners. No right, title or
interest in or to any trademark, service mark, logo or trade name of
Sun Microsystems, Inc. or its licensors is granted.

*/
#pragma ident   "@(#)XSunIMCm.h	1.2 95/11/01        Sun Microsystems,Inc."

/*   derivded from :
static char     sccsid[] = "@(#)XSunIMCm.h	2.4 94/08/08 SMI";
*/

/******************************************************************

              Copyright 1990, 1991, by Sun Microsystems, Inc.

Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear
in supporting documentation, and that the name of Sun Microsystems, Inc.
not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.
Sun Microsystems, Inc. makes no representations about the suitability of
this software for any purpose.  It is provided "as is" without
express or implied warranty.

Sun Microsystems Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
IN NO EVENT SHALL Sun Microsystems, Inc. BE LIABLE FOR ANY SPECIAL, INDIRECT
OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
OR PERFORMANCE OF THIS SOFTWARE.

  Author: Hideki Hiura (hhiura@Sun.COM)
	  				     Sun Microsystems, Inc.
******************************************************************/

#ifndef xim_imlogic_jle103_DEFIND
#define xim_imlogic_jle103_DEFIND

/*
 * cm status string management data
 */
typedef struct {
    wchar_t	name[STATUSNAMELEN];
    wchar_t	value[STATUSVALUELEN];
    wchar_t	string[STATUSSTRINGLEN];
    int		order ;
} IMStatusString ;

typedef struct {
    wchar_t	*name;
    wchar_t	*value;
    wchar_t	*string;
    int		order ;
} IMCurrentStatusString ;

typedef struct _iml_session {
/* ---- Inherit Base class [imlogic_session] ----- */

#define xim_iml_inheritance_DEFIND
#include "XSunIMCore.h"
#undef  xim_iml_inheritance_DEFIND

/* ----- Derived class [jle103_session] declaration ---- */

wchar_t conversion_on_key ;
Bool	nego;

} iml_session_t;

#define xim_imlogic_session_DEFIND

typedef struct _cmif_spec_t {
/*
 * Status region
 */
    int NStatusInFile ;
    int NStatus ;
    IMStatusString StatusString[MAXSTATUS] ;
    IMCurrentStatusString CurrentStatusString[MAXSTATUS] ;
} cmif_spec_t ;

#define DEFAULTPreEditTextBufferSize 512
#define DEFAULTPreEditAttrBufferSize 512
#define DEFAULTStatusStringRemainBufferSize 512
/*
 * for the active_ regions
 */
#define PREEDIT_IS_ACTIVE	0x00000001
#define STATUS_IS_ACTIVE	0x00000002
#define LOOKUP_IS_ACTIVE	0x00000004
#define AUX_IS_ACTIVE		0x00000008

/*
 * for the remainder flag due to handle pseudo_packet in eval_it()
 */

#define PRE_EDIT_DONE_REQUIRED	0x00000001
#define STATUS_DONE_REQUIRED	0x00000002
#define STATUS_DRAW_REQUIRED	0x00000004
#define IMM_COMMIT_REQUIRED	0x00000008

#define DEFAULT_OPENWINHOME "/usr/openwin"
#define OW_LOCALE_PATH "lib/locale"
#define MODE_DAT_PATH "htt/mode.dat"
#define XXXCOMPAT_MODE_DAT_PATH "se/sunview/mode.dat"
#define DEFAULT_MLEPATH "/usr/lib/mle"

#define MAX_ENV_OPCODE 153

/*
 * cm interface module private member functions
 */

Private void cm_destruct_session(iml_session_t *);
Private int destruct_session(iml_session_t*);
Private void cm_reset(iml_session_t *, iml_inst **);
Private void cm_conversion_on(iml_session_t *);
Private void cm_send_commit(iml_session_t *);
Private void cm_make_conversion_on(iml_session_t *);
Private void cm_make_conversion_off(iml_session_t *);
Private int cm_make_status_string(iml_session_t *, wchar_t *,
				  unsigned char *,int);
Private void cm_set_choice(iml_session_t *, int);
Private void cm_attr2feedback(XIMFeedback*, unsigned char*,
			      int, char*);
Private int cm_create_session(int, iml_session_t*, Bool);
Private void cm_select_unknown_control(iml_session_t *);
Private void cm_opsw_init(void);
Private int construct_cm_initial_data(struct cm_initstruct *);
Private iml_inst **eval_it(iml_session_t*, struct cm_to_env*, iml_inst**);
Private void  init_status_string(iml_session_t *);

Private void eval_cm_to_env_packet(iml_session_t*, struct cm_to_env*);

Private struct cm_to_env *get_cte(struct cm_to_env **);
Private env_commit(iml_session_t*, iml_inst **, struct cm_to_env**);
Private void cm_eval_results(iml_session_t*, iml_inst *);
Private Bool	ims_cm_negotiation_pool(int, iml_session_t*, 
					char*, void*);
Private ReadOneLine(char*, int, int);	/* Alternative function of fgets() */

extern struct cm_to_env *cm_put(int, int, struct env_to_cm*);
extern int cm_open(int, struct cm_initstruct*, struct cm_to_env**);
extern struct cm_to_env *cm_close(int, int);

#endif  xim_imlogic_jle103_DEFINED
