#ifndef __SAP_MON_H__
#define __SAP_MON_H__

#include "saprfc.h"

/*=======================================================================
  (C) Copyright SAP AG, 2002


 Author  : Dostert/SAP
 Project : Get data from R/3 using XMB
 Used    : SXMI_LOGON, SXMI_LOGOFF
 Using   : RFCSDK
 ========================================================================*/

/*
 * Error Codes
 */

#define SAP_OK                          0
#define AG_FIRST_ERROR                  100
#define AG_INVALID_ARGUMENTS            100
#define AG_CALL_INVALID                 101
#define AG_RFC_EXCEPTION                102
#define AG_TEMPLATE_ERROR               200
#define AG_EZ_CFG_FILE_ERROR            210


/*
 * Structs
 */


#define AL_MONI_MAX_DESCRIPTION_LENGTH  255
#define AL_MONI_MAX_TEMPL_NAME_LENGTH   255
#define AL_MONI_SET_NAME_LENGHT         60
#define AL_MONI_NAME_LENGHT             60
#define AL_MONI_MAX_PATTERNS            100
#define AL_MONI_MAX_PATTERN_LENGTH      255



#define AL_MONI_MAX_TEXT_LENGTH         256
#define MT_SYSID_LENGTH                 8
#define MT_MCNAME_LENGTH                40
#define OBJECTNAME_LENGTH               40
#define MT_NAMESHRT_LENGTH              40
#define MT_DATE_LENGTH                  8
#define MT_TIME_LENGTH                  6


typedef struct  {
        char TemplateName[AL_MONI_MAX_TEMPL_NAME_LENGTH];
                /* Name of the template */
        char Description [AL_MONI_MAX_DESCRIPTION_LENGTH];
                /* Description */
        char MoniSetName [AL_MONI_SET_NAME_LENGHT+1];
                /* Name of the moni-set */
        char MoniName [AL_MONI_NAME_LENGHT+1];
                /* Name of the monitor */
        int  MaxTreeDepth;
                /* max depth of tree */
        ITAB_H TreeNodes;
                /* itab with treenodes */
        ITAB_H TreeNodeValues;
                /* itab with values of treenodes */
        char Pattern  [AL_MONI_MAX_PATTERNS] [AL_MONI_MAX_PATTERN_LENGTH + 1];
                /* Pattern read from .ini-file */
        int NumberOfPatterns;
                /* Number of patterns above */
} AlMoniTemplate_T;


typedef AlMoniTemplate_T*  AlMoniHandle_T;

typedef struct {
        char Mtsysid[MT_SYSID_LENGTH+1];
        char Mtmcname[MT_MCNAME_LENGTH+1];
        char Objectname[OBJECTNAME_LENGTH+1];
        char Mtnameshrt[MT_NAMESHRT_LENGTH+1];
        
	char Alertdate[MT_DATE_LENGTH+1];
        char Alerttime[MT_TIME_LENGTH+1];

        char Lastvaldat[MT_TIME_LENGTH+1];
        char Lastvaltim[6];

        int  Actualval;
        int  Actualsev;

        char currentValue[AL_MONI_MAX_TEXT_LENGTH];

} AlMoniNode_T;

/*
 * Prototypes
 */

int sapmon_init(AlMoniHandle_T **MoniHandle, int *NrOfMoniTempl);
int sapmon_connect(char *Login_Template, RFC_HANDLE *rfc_handle);
int sapmon_disconnect(RFC_HANDLE *rfc_handle);

int sapmon_request(RFC_HANDLE *rfc_handle, AlMoniHandle_T *MoniHandle, int NrOfMoniTempl);
int sapmon_refresh(RFC_HANDLE *rfc_handle, AlMoniHandle_T *MoniHandle, int NrOfMoniTempl);

int sapmon_request_tree(AlMoniHandle_T MoniHandle, AlMoniNode_T **nodes, unsigned int *NrOfNodes);

char * sapmon_get_template_description (AlMoniHandle_T MoniHandle);
char * sapmon_get_template_name        (AlMoniHandle_T MoniHandle);

int sapmon_sap_start_ssh(char *sid, char *hostname, char *nr);
int sapmon_sap_stop_ssh (char *sid, char *hostname, char *nr);
int sapmon_sap_start    (char *sid, char *hostname, char *nr);
int sapmon_sap_stop     (char *sid, char *hostname, char *nr);



#endif
