#ifndef SMEG_PUB_H
#define SMEG_PUB_H

#include "smeg_smpp.h"
#include "smtp_struct.h"

#define SMEG_MAX_ALLOWED_PREFIX_ENTRY	17

void	smpp_send_email(SMTP_MSG *smtp_msg, int recipient_num);
void	smpp_tx_fsm(SMEG_SMPP_PORT *);
int 	smpp_tx_port_assign(const char *, const char *, const char *, const char *);
void 	smpp_tx_port_release(SMEG_SMPP_PORT *p);

int email2sm(SMPP_MSG  *pMsg, SMTP_MSG *pSmtpMsg, int offset, int recipient_index);
int smpp_rx_DataRecv(BYTE , SMPP_MSG *, WORD);
int smpp_rx_LinkStateChange(BYTE linkNo, BYTE linkstate);
int smpp_onLinkStateChange(BYTE linkNo, BYTE linkstate);
void smppMsg_send(BYTE* msg);
int smpp_onDataRecv(BYTE linkNo, SMPP_MSG *pMsg, WORD dataLen);

void decode7bitdata(char *in_buffer, char *out_buffer, int len_of_data);
void decode8byte7bitdata(char *in_buffer, char *out_buffer, int len_of_data);
void from_default_alphabet(char *in_buffer,int in_buffer_len);
void byteswap(char *input, int input_len);
int unicode_conv (const char *, const char *, char *, char *, int, int);
char *sm_decode(int, char *, int);

void smpp_tx_register_link();
int smpp_tx_DataRecv(BYTE, SMPP_MSG *, WORD );
int smpp_tx_LinkStateChange(BYTE, BYTE);
void save_smpp_tx_msg();
void smpp_tx_port_assign_contiue(const char *, const char *, const char *, int, const char *, int);


int smeg_loadParam();
int smeg_writeParam();

int smeg_setmib ( BYTE oidlen, DWORD * oid, BYTE * pdata, WORD datalen );
int smeg_getmib ( BYTE oidlen, DWORD * oid, BYTE * pdata, BYTE * vartype );
void smeg_trapcallback ( BYTE oidlen, DWORD * oid, BYTE * pdata, WORD len, snmp_addr * addr );

void smeg_init(BYTE *, int, int, int);
void smeg_main();
void smeg_debugTimer();
void smeg_debugInit();
void smeg_mib_init();
void retset_call_statistics();
extern void smeg_debug_log(const char *fmt,...);

int uIntToByte(BYTE * buf, int bufLen, unsigned long uIntValue);
int get_license();
int smeg_SendHeartBeating();
int GetCSTA_Record(BYTE instance, BYTE *pdata);

int check_user(const char *recipient);

void smtp_init();
void smpp_init();
void smtp_main();
void smpp_main();








void smtp_rx_begin(void *);
void smtp_rx_send_helo_resp(void *);
void smtp_rx_send_mail_resp(void *);
void smtp_rx_send_rcpt_resp(void *);
void smtp_rx_send_data_resp(void *);
void smtp_rx_send_data_input_resp(void *);
void smtp_rx_quit_resp(void *);
void smtp_rx_failed(void *);
void smtp_rx_fsm(struct tSmtpPort *p);
void save_smtp_tx_msg();
void smtp_init();
void smtp_main();
void smtp_send_sm(const char *, char *);

void smeg_send_ascout(char *sdBuf);

inline BYTE *get_service_number();
inline BYTE* get_mailserver_ip();
inline BYTE get_smtp_auth_flag();
inline BYTE* get_smtp_auth_user();
inline BYTE* get_smtp_auth_passwd();
inline int get_license();
inline BYTE* get_cc();
inline BYTE* get_ndc();
inline BYTE get_max_sms_per_email();
inline BYTE* get_localdomain();
inline BYTE* get_emaildomain();
inline BYTE* get_allowed_prefixes(int i);
inline BYTE get_max_sms_per_email();

inline int get_smtp_link_state();
inline int get_smpp_tx_link_state();
inline int get_smpp_rx_link_state();
inline void set_smtp_link_state(int i);
inline void set_smpp_tx_link_state(int i);
inline void set_smpp_rx_link_state(int i);

void smeg_print(const char *fmt, ...);
#endif
