/*=============================================================================
                    

              


FILE:  logparser.h

SERVICES:  
   Header file for the logparser
DESCRIPTION:
   This file provides defintions for the logging data types that need to be 
   shared between the phone and log parser

        Copyright © 2000-2001 QUALCOMM Incorporated.
               All Rights Reserved.
            QUALCOMM Proprietary/GTDR
=============================================================================*/

#ifndef LOGPARSER_INCLUDED
#define LOGPARSER_INCLUDED

#include "brewlogitemhdr.h"
/*-----------------------------------------------------------------------------
   Defines
-----------------------------------------------------------------------------*/

#define MSGHDRSTRLEN            1024
#define MSGBODYSTRLEN           1500
#define LOGOUTLEN				(MSGBODYSTRLEN*2 + (MSGBODYSTRLEN/2) + 1) 
// LOGOUTLEN : In case the user wants a Hex Dump, for 1500 bytes (max size)
// Of the response, the resulting hex output will be 1500*2 (for every byte
// There will be 2 characters associated) + 1500/2 (for every 2 bytes, there
// will be a space + 1 (last one will be a /0) 

typedef enum {
	FILE_TO_FILE,
	BYTE_TO_STRING
} OutMode;

/*=============================================================================
   PUBLIC DATA DECLARATIONS
=============================================================================*/

char pTmp                       [MSGBODYSTRLEN];

char LogLevels[3][5] = 
{
    "LOW",
    "MED",
    "HIGH"
};

/*---------------------------------------------------------------------------
   Class and Structure Definitions
---------------------------------------------------------------------------*/

// BrewLogItemHdr
class BrewLogItemHdr
{
private:
    brewlogitemhdr_type * logitemhdr;

public:

    BrewLogItemHdr();
    ~BrewLogItemHdr();

    const brewlogitemhdr_type * GetLogItemHdr()
    { 
        return logitemhdr; 
    }

    friend ifstream &operator>>(ifstream &is, BrewLogItemHdr&);
};

//----------------LogMsg (whew, finally the data!!)---------------//
class LogMsg : public BrewLogItemHdr
{
public:
    uint8           * logmsgdata;
    uint8           * pmsghdr;
    uint8           * pmsgbody;
    char            * pLogOut;

public:
    LogMsg();
    ~LogMsg();

    const uint8 * GetLogMsgData()
    { 
        return logmsgdata; 
    }


    void Decode(char *buf);   // Log Decoder
                              // Parses the logs and decode QSP
	
	void PrintHex(); // Function call for printing the hex dump
	
	void SetMode(OutMode x) { mode = x; } 
	
	void SetOutputFileName(char* x) { strcpy(filename,x); }
	char* GetOutputFileName() { return filename; }

	int GetHexMode() { return hexMode; }
	void SethexMode(int x) { hexMode = x; }// Function to set the hex mode
											// ASCII dump, 1 for hex dump

	void SetDataAvailable(int x) { dataAvailable = x; }
	int GetDataAvailable() { return dataAvailable; }

	void PrintILoggerASCII();
	void PrintILoggerBinaryToASCII(int size);

	void SetTimeStamp(char* ts) { strcpy(timeStamp, ts); }
	char* GetTimeStamp() { return timeStamp; }

	int GetLogCode() { return m_logCode; }
	void SetLogCode(int x) { m_logCode = x; }
	
	int GetLength() { return m_length; }
	void SetLength(int x) { m_length = x; } 
private:
	char filename[50];
	OutMode mode;
	char* strHexString;
	int hexMode;
	int dataAvailable;
	char timeStamp[30];
	int m_logCode;
	int m_length;
};


#ifdef _USRDLL

class CBREWLogParser 
{
public:
	CBREWLogParser();

	int getASCIIresponse(char* pInfileName);
	int getASCIIresponse_inStr( unsigned char* byteIn,uint16 len, char& strOut,uint16 lenOut, char* ts,int logcode,int base_logcode, int hexDumpFlag);
	int getDbgASCIIresponse(char* timeStamp,uint16 ts_len,char* szMsgData,uint16 msgLen, char* fileName, uint16 fnameLen, unsigned char level, uint16 line_num, char& strOut, uint16 lenOut);
};

extern CBREWLogParser gBREWLogParser;
#endif

#ifdef LOGPARSER_DLL_EXPORTS
#define LOGPARSER_API __declspec(dllexport)
#else
#define LOGPARSER_API __declspec(dllimport)
#endif








#endif