#if !defined(__tecwhllapi_h) // Sentry, use file only if it's not already included.
#define __tecwhllapi_h
/*  Project Tec3270

	 Copyright © 1998-2005. All Rights Reserved.

	 SUBSYSTEM:    WHllApi.ddl library
	 FILE:         tecwhllapi.h
	 AUTHOR:       Alcindo Ferreira Filho


	 OVERVIEW
	 ========
	 Source file for defining Tec3270 Win HLL Api library.
*/
/***************************************************************************\

* whllapi.h -   Windows HLLAPI functions, types, and definitions            *

*               Version 1.0                                                 *

\****************************************************************************/

#include "whllapis.h"

/****** Function numbers ****************************************************/

#define OEMFUNCTION                0  /* OEM Function */

#define CONNECTPS                  1  /* Connect Presentation Space */

#define DISCONNECTPS               2  /* Disconnect Presentation Space */

#define SENDKEY                    3  /* Send Key */

#define WAIT                       4  /* Wait */

#define COPYPS                     5  /* Copy Presentation Space */

#define SEARCHPS                   6  /* Search Presentation Space */

#define QUERYCURSORLOC             7  /* Query Cursor Location */

#define COPYPSTOSTR                8  /* Copy Presentation Space To String */

#define SETSESSIONPARAMETERS       9  /* Set Session Parameters */

#define QUERYSESSIONS             10  /* Query Sessions */

#define RESERVE                   11  /* Reserve */

#define RELEASE                   12  /* Release */

#define COPYOIA                   13  /* Copy OIA Information */

#define QUERYFIELDATTRIBUTE       14  /* Query Field Attribute */

#define COPYSTRTOPS               15  /* Copy String To Presentation Space */

#define STORAGEMGR                17  /* Storage Manager */

#define PAUSE                     18  /* Pause */

#define QUERYSYSTEM               20  /* Query System */

#define RESETSYSTEM               21  /* Reset System */

#define QUERYSESSIONSTATUS        22  /* Query Session Status */

#define STARTHOSTNOTIFICATION     23  /* Start Host Notification */

#define QUERYHOSTUPDATE           24  /* Query Host Update */

#define STOPHOSTNOTIFICATION      25  /* Stop Host Notification */

#define SEARCHFIELD               30  /* Search Field */

#define FINDFIELDPOSITION         31  /* Find Field Position */

#define FINDFIELDLENGTH           32  /* Find Field Length */

#define COPYSTRINGTOFIELD         33  /* Copy String To Field */

#define COPYFIELDTOSTRING         34  /* Copy String To Field */

#define SETCURSOR                 40  /* Set Cursor */

#define STARTCLOSEINTERCEPT       41  /* Start Close Intercept */

#define QUERYCLOSEINTERCEPT       42  /* Query Close Intercept */

#define STOPCLOSEINTERCEPT        43  /* Stop Close Intercept */

#define STARTKSINTERCEPT          50  /* Start Keystroke Intercept */

#define GETKEY                    51  /* Get Key */

#define POSTINTERCEPTSTATUS       52  /* Post Intercept Status */

#define STOPKSINTERCEPT           53  /* Stop  Keystroke Intercept */

#define LOCKPSAPI                 60  /* Lock Presentation Space API */

#define LOCKWSAPI                 61  /* Lock Window Services API */

#define QUERYCLIENTCERTIFICATE    70  /* Query Client Certificate on Secured Connections */

#define QUERYSERVERCERTIFICATE    71  /* Query Server Certificate on Secured Connections */

#define SENDFILE                  90  /* Send File */

#define RECEIVEFILE               91  /* Receive File */

#define CONVERT                   99  /* Convert Position or RowCol */

#define CONNECTWINDOWSERVICES    101  /* Connect Window Services */

#define DISCONNECTWINDOWSERVICES 102  /* Disconnect Window Services */

#define QUERYWINDOWCOORDINATES   103  /* Query or Set Window Coordinates */

#define WINDOWSTATUS             104  /* Query or Set Window Status */

#define CHANGEPSNAME             105  /* Change Presentation Space Name */

#define CONNECTSTRFLDS           120  /* Connect Structured Fields */

#define DISCONSTRFLDS            121  /* Disconnect Structured Fields */

#define QUERYCOMMBUFSIZ          122  /* Query Communications Buffer Size */

#define ALLOCCOMMBUFF            123  /* Allocate Communications Buffer */

#define FREECOMMBUFF             124  /* Free Communications Buffer */

#define GETREQUESTCOMP           125  /* Get Request Completion */

#define READSTRFLDS              126  /* Read Structured Fields */

#define WRITESTRFLDS             127  /* Write Structured Fields */



/****** SetSessionParameters values *****************************************/



#define WHLL_SSP_NEWRET      (DWORD)0x00000001

#define WHLL_SSP_OLDRET      (DWORD)0x00000002

#define WHLL_SSP_ATTRB       (DWORD)0x00000004

#define WHLL_SSP_NOATTRB     (DWORD)0x00000008

#define WHLL_SSP_NWAIT       (DWORD)0x00000010

#define WHLL_SSP_LWAIT       (DWORD)0x00000020

#define WHLL_SSP_TWAIT       (DWORD)0x00000040

#define WHLL_SSP_EAB         (DWORD)0x00000080

#define WHLL_SSP_NOEAB       (DWORD)0x00000100

#define WHLL_SSP_AUTORESET   (DWORD)0x00000200

#define WHLL_SSP_NORESET     (DWORD)0x00000400

#define WHLL_SSP_SRCHALL     (DWORD)0x00001000

#define WHLL_SSP_SRCHFROM    (DWORD)0x00002000

#define WHLL_SSP_SRCHFRWD    (DWORD)0x00004000

#define WHLL_SSP_SRCHBKWD    (DWORD)0x00008000

#define WHLL_SSP_FPAUSE      (DWORD)0x00010000

#define WHLL_SSP_IPAUSE      (DWORD)0x00020000



/****** Convert Row or Column values ****************************************/



#define WHLL_CONVERT_POSITION 'P'

#define WHLL_CONVERT_ROW      'R'



/******* Storage Manager Sub-Function values ********************************/



#define WHLL_GETSTORAGE        1

#define WHLL_FREESTORAGE       2

#define WHLL_FREEALLSTORAGE    3

#define WHLL_QUERYFREESTORAGE  4



/****** Change PS Name values ***********************************************/



#define WHLL_CHANGEPSNAME_SET			0x01

#define WHLL_CHANGEPSNAME_RESET			0x02



/****** Window Status values ************************************************/



#define WHLL_WINDOWSTATUS_SET				0x01

#define WHLL_WINDOWSTATUS_QUERY				0x02

#define WHLL_WINDOWSTATUS_EXTQUERY			0x03



#define WHLL_WINDOWSTATUS_NULL				0x0000

#define WHLL_WINDOWSTATUS_SIZE				0x0001

#define WHLL_WINDOWSTATUS_MOVE				0x0002

#define WHLL_WINDOWSTATUS_ZORDER			0x0004

#define WHLL_WINDOWSTATUS_SHOW				0x0008

#define WHLL_WINDOWSTATUS_HIDE				0x0010

#define WHLL_WINDOWSTATUS_ACTIVATE			0x0080

#define WHLL_WINDOWSTATUS_DEACTIVATE		0x0100

#define WHLL_WINDOWSTATUS_MINIMIZE			0x0400

#define WHLL_WINDOWSTATUS_MAXIMIZE			0x0800

#define WHLL_WINDOWSTATUS_RESTORE			0x1000



#define WHLL_WINDOWSTATUS_FRONT		(DWORD)0x00000003

#define WHLL_WINDOWSTATUS_BACK		(DWORD)0x00000004



/****** Lock API values *****************************************************/



#define WHLL_LOCKAPI_LOCK			'L'

#define WHLL_LOCKAPI_UNLOCK		'U'

#define WHLL_LOCKAPI_RETURN		'R'

#define WHLL_LOCKAPI_QUEUE			'Q'


/****** QUERYCLIENTCERTIFICATE / QUERYSERVERCERTIFICATE  Values *************/

#define WHLL_QUERY_CERTIFICATE_ISSUER               1
#define WHLL_QUERY_CERTIFICATE_SUBJECT              2
#define WHLL_QUERY_CERTIFICATE_NOTBEFORE            3
#define WHLL_QUERY_CERTIFICATE_NOTAFTER             4
#define WHLL_QUERY_CERTIFICATE_SUBJECTALTNAMES      5


/****** Windows HLLAPI Return Codes *****************************************/
#define WHLLOK                   0   /* Successful */
#define WHLLNOTCONNECTED         1   /* Not Connected To Presentation Space */
#define WHLLBLOCKNOTAVAIL        1   /* Requested size is not available */
#define WHLLPARAMETERERROR       2   /* Parameter Error/Invalid Function */
#define WHLLBLOCKIDINVALID       2   /* Invalid Block ID was specified */
#define WHLLFTXCOMPLETE          3   /* File Transfer Complete */
#define WHLLFTXSEGMENTED         4   /* File Transfer Complete / segmented */
#define WHLLPSBUSY               4   /* Presentation Space is Busy */
#define WHLLINHIBITED            5   /* Inhibited/Keyboard Locked */
#define WHLLTRUNCATED            6   /* Data Truncated */
#define WHLLPOSITIONERROR        7   /* Invalid Presentation Space Position */
#define WHLLNOTAVAILABLE         8   /* Unavailable Operation */
#define WHLLSYSERROR             9   /* System Error */
#define WHLLNOTSUPPORTED         10  /* Function Not Supported */
#define WHLLUNAVAILABLE          11  /* Resource is unavailable */
#define WHLLPSENDED              12  /* The session was stopped */
#define WHLLUNDEFINEDKEY         20  /* Undefined Key Combination */
#define WHLLOIAUPDATE            21  /* OIA Updated */
#define WHLLPSUPDATE             22  /* PS Updated */
#define WHLLBOTHUPDATE           23  /* Both PS And OIA Updated */
#define WHLLNOFIELD              24  /* No Such Field Found */
#define WHLLNOKEYSTROKES         25  /* No Keystrokes are available */
#define WHLLPSCHANGED            26  /* PS or OIA changed */
#define WHLLFTXABORTED           27  /* File transfer aborted */
#define WHLLZEROLENFIELD         28  /* Field length is zero */
#define WHLLKEYOVERFLOW          31  /* Keystroke overflow */
#define WHLLSFACONN              32  /* Other application already connected */
#define WHLLTRANCANCLI           34  /* Message sent inbound to host cancelled */
#define WHLLTRANCANCL            35  /* Outbound trans from host cancelled */
#define WHLLHOSTCLOST            36  /* Contact with host was lost */
#define WHLLOKDISABLED           37  /* The function was successful */
#define WHLLNOTCOMPLETE          38  /* The requested fn was not completed */
#define WHLLSFDDM                39  /* One DDM session already connected */
#define WHLLSFDPEND              40  /* Disconnected w async requests pending */
#define WHLLBUFFINUSE            41  /* Specified buffer currently in use */
#define WHLLNOMATCH              42  /* No matching request found */
#define WHLLLOCKERROR            43  /* API already locked or unlocked */
#define WHLLNOCERTIFICATE        70  /* No client certificate is available  */
#define WHLLCERTPWD              71  /* No certificate password was supplied or it's invalid */
#define WHLLREVOKEDCERT          72  /* The client certificate supplied is revoked */
#define WHLLEXPIREDCERT          73  /* The client certificate supplied is expired or not yet valid */
#define WHLLINVALIDCERT          74  /* The certificate has an issuer not trusted, or is not valid */
#define WHLLNOCERTCRL            75  /* There is no valid CRL for checking the certificate supplied */

#define WHLLINVALIDFUNCTIONNUM  101  /* Invalid function number */
#define WHLLFILENOTFOUND        102  /* File Not Found */
#define WHLLACCESSDENIED        105  /* Access Denied */
#define WHLLMEMORY              108  /* Insufficient Memory */
#define WHLLINVALIDENVIRONMENT  110  /* Invalid environment */
#define WHLLINVALIDFORMAT       111  /* Invalid format */

#define WHLLINVALIDPSID         201  /* Invalid Presentation Space ID */
#define WHLLINVALIDRC           202  /* Invalid Row or Column Code */

/****** Windows HLLAPI Extentions Return Codes ******************************/
#define WHLLALREADY             300  /* An HLLAPI call is already outstanding */
#define WHLLINVALID             301  /* Async Task Id is invalid */
#define WHLLCANCEL              302  /* Blocking call was cancelled */
#define WHLLSYSNOTREADY         303 /* Underlying subsystem not started */
#define WHLLVERNOTSUPPORTED     304  /* Application version not supported */


/**** TEC3270 WHLLAPI Extended Errors for WHLLSYSERROR and WHLLSYSNOTREADY ****/
//
// DDEML ERRORS : See ::DdeGetLastError() on Windows API Help for their meaning
//
#define     TEC3270_WHLLNOERROR                         0   /* must be 0 */

#define     TEC3270_FIRST                       	0x4000

#define     TEC3270_ADVACKTIMEOUT               	0x4000   // A request for a synchronous advise transaction has timed out.
#define     TEC3270_BUSY                        	0x4001   // The response to the transaction caused the DDE_FBUSY flag to be set.
#define     TEC3270_DATAACKTIMEOUT              	0x4002   // A request for a synchronous data transaction has timed out.
#define     TEC3270_DLL_NOT_INITIALIZED         	0x4003   // A DDEML function was called without first calling the DdeInitialize function, or an invalid instance identifier was passed to a DDEML function.
#define     TEC3270_DLL_USAGE                   	0x4004   // An application initialized as APPCLASS_MONITOR has attempted to perform a dynamic data exchange (DDE) transaction, or an application initialized as APPCMD_CLIENTONLY has attempted to perform server transactions.
#define     TEC3270_EXECACKTIMEOUT              	0x4005   // A request for a synchronous execute transaction has timed out.
#define     TEC3270_INVALIDPARAMETER            	0x4006   // A parameter failed to be validated by the DDEML.
#define     TEC3270_LOW_MEMORY                  	0x4007   // A DDEML application has created a prolonged race condition (in which the server application outruns the client), causing large amounts of memory to be consumed.
#define     TEC3270_MEMORY_ERROR                	0x4008   // A memory allocation has failed.
#define     TEC3270_NOTPROCESSED                	0x4009   // A transaction has failed.
#define     TEC3270_NO_CONV_ESTABLISHED         	0x400a   // A client's attempt to establish a conversation has failed.
#define     TEC3270_POKEACKTIMEOUT              	0x400b   // A request for a synchronous poke transaction has timed out
#define     TEC3270_POSTMSG_FAILED              	0x400c   // An internal call to the PostMessage function has failed.
#define     TEC3270_REENTRANCY                  	0x400d   // An application instance with a synchronous transaction already in progress attempted to initiate another synchronous transaction, or the DdeEnableCallback function was called from within a DDEML callback function.
#define     TEC3270_SERVER_DIED                 	0x400e   // A server-side transaction was attempted on a conversation terminated by the client, or the server terminated before completing a transaction.
#define     TEC3270_SYS_ERROR                   	0x400f   // An internal error has occurred in the DDEML.
#define     TEC3270_UNADVACKTIMEOUT             	0x4010   // A request to end an advise transaction has timed out.
#define     TEC3270_UNFOUND_QUEUE_ID            	0x4011   // An invalid transaction identifier was passed to a DDEML function. Once the application has returned from an XTYP_XACT_COMPLETE callback, the transaction identifier for that callback function  is no longer valid.
//
// TEC3270 WinHLLAPI Extended ERRORS :
//
#define     TEC3270_WHLLMAXAPPEXCEEDED             0x4100   // Max number of simultaneous apps connected exceeded
#define     TEC3270_WHLLMAXSESSEXCEEDED            0x4101   // Max number of simultaneous sessions connected exceeded (including all apps connected)
#define     TEC3270_WHLLSESSPARMNOTALLOWED         0x4102   // App is trying to modify session parameters and it is not allowed because it has no rights to do it.
#define     TEC3270_WHLLTRACEFILEERROR             0x4103   // A função SETSESSIONPARAMETERS informou o parametro TRON e não foi possível ativar o arquivo de trace.
#define     TEC3270_WHLLNO3270BUFSTR               0x4104   // A função COPYPSTOSTR/COPYSTRTOPS  recebeu o string solicitado ao 3270 Buffer com tamanho 0.
#define     TEC3270_WHLLNO3270SESSION              0x4105   // Não foi possível criar ou localizar uma sessão 3270 disponível.
#define     TEC3270_WHLLCONNECTIONTIMEDOUT         0x4106   // A conexão da sessão solicitada não foi realizada dentro do tempo máximo de 30 segundos.
#define     TEC3270_WHLLCONNECTIONSSLERROR         0x4107   // A conexão da sessão solicitada não foi realizada porque ocorreu um erro de SSL.
#define     TEC3270_WHLLNOTBLOCKING                0x4108   // Não existe nenhuma chamada de função ativa, portanto não é possível cancelar.
#define     TEC3270_WHLLINVALIDWAITOPT             0x4109   // Erro interno do Tec3270. O parâmetro WAIT não é TWAIT, nem LWAIT, nem NWAIT.

#define     TEC3270_LAST                           0x4109
/****** Windows HLLAPI structure ********************************************/
#define WHLLDESCRIPTION_LEN	127

typedef struct tagWHLLAPIDATA {

	WORD	wVersion;

	char	szDescription[WHLLDESCRIPTION_LEN+1];

} WHLLAPIDATA, *PWHLLAPIDATA, FAR* LPWHLLAPIDATA;



/****** Windows HLLAPI Function Prototypes **********************************/
extern "C"
{
void WINAPI _TECWHLLFUNC WinHLLAPI(LPWORD, LPSTR, LPWORD, LPWORD);

HANDLE WINAPI _TECWHLLFUNC WinHLLAPIAsync(HWND, LPWORD, LPSTR, LPWORD, LPWORD);

BOOL WINAPI _TECWHLLFUNC WinHLLAPICleanup(void);

BOOL WINAPI _TECWHLLFUNC WinHLLAPIIsBlocking(void);

int WINAPI _TECWHLLFUNC WinHLLAPICancelAsyncRequest(HANDLE, WORD);

int WINAPI _TECWHLLFUNC WinHLLAPICancelBlockingCall(void);

int WINAPI _TECWHLLFUNC WinHLLAPIStartup(WORD, LPWHLLAPIDATA);

FARPROC WINAPI _TECWHLLFUNC WinHLLAPISetBlockingHook(FARPROC);

BOOL WINAPI _TECWHLLFUNC WinHLLAPIUnhookBlockingHook(void);
int  WINAPI _TECWHLLFUNC WinHLLAPIGetExtendedError(void);
//#ifdef _cplusplus
}

//#endif

#endif

