#ifndef AGENT_MON_H
#define AGENT_MON_H

#include <stdio.h>
#include <string.h>
#include <pwd.h>
#include <sys/types.h>


#include "agnt_def.h"
#include "agnt_bapi.h"

#include "iniparser.h"

#include "sapitab.h"
#include "strlib.h"

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

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

#define AGENT_INI_FILE 	 		"/etc/sapmon/agent.cfg"
#define AGENT_LOGIN_FILE 		"/etc/sapmon/login.cfg"
#define AG_EZ_FILE                      "/etc/sapmon/moni_tr.cfg"

#define SECTION_NAME   "TEMPLATE_"

#define AG_MAX_LOGIN_TEMPLATES		100

#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_NAME_LENGTH		255

#define AL_MONI_MAX_TEXT_LENGTH	        256
#define  AG_MAX_EZ_CFGS                 100


#define AL_MTE_MAX_NAME			256

#define MT_CLASS_PERFORMANCE	  	"100"
#define MT_CLASS_ML		  	"101"
#define MT_CLASS_SMES                   "102"
#define MT_CLASS_SHORTTEXT              "111"

#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];
	/*
	int  Highalval; 
	int  Highalsev; 
	*/
	/*
	char Alsysid[8];
	*/
	char Alertdate[MT_DATE_LENGTH+1];
	char Alerttime[MT_TIME_LENGTH+1];
	
	char Lastvaldat[MT_DATE_LENGTH+1];
	char Lastvaltim[MT_TIME_LENGTH+1];
	
	int  Actualval;
	int  Actualsev;
	/*
	char Valsysid[8];
	char Valertdate[8];
	char Valerttime[6];
	*/
	char currentValue[AL_MONI_MAX_TEXT_LENGTH];

} AlMoniNode_T;


typedef struct {
        char Name[AL_MONI_MAX_NAME_LENGTH];
        char MoniSetName [AL_MONI_SET_NAME_LENGHT];
        char MoniName [AL_MONI_NAME_LENGHT];
        char Pattern[AL_MONI_MAX_PATTERN_LENGTH +1];
} ez_cfg_t;

/*---------------------------------------------------------------------*/
/*--------GLOBAL VARS--------------------------------------------------*/
/*---------------------------------------------------------------------*/
int			trace_me;
 

/*---------------------------------------------------------------------*/
/*--------Prototypes---------------------------------------------------*/
/*---------------------------------------------------------------------*/



int sapmon_init (AlMoniHandle_T **MoniHandle, int *NrOfMoniTempl);
AlMoniTemplate_T *get_template_by_handle (AlMoniHandle_T MoniHandle);
char * sapmon_get_template_name (AlMoniHandle_T MoniHandle);
int Filter_MTEs ( AlMoniHandle_T MoniHandle);
char *  parse_login_file(char *templ );

#endif
