testexecmgmt/ucc/Source/CSProtocolLibrary/sprotocol/CXServer.h
changeset 0 3da2a79470a7
equal deleted inserted replaced
-1:000000000000 0:3da2a79470a7
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 * Filename: CXServer.h
       
    16 * Author: Sanjeet Matharu 
       
    17 * This is the server side of the protocol which takes name/value pairs and does stuff
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 #ifndef __CXSERVER_H__
       
    24 #define __CXSERVER_H__
       
    25 
       
    26 #define MAXLISTLENGTH		100	//this is the name/value pair max list length
       
    27 #define MAXBUFFERLEN		64	//maximum length of the name and value strings
       
    28 
       
    29 #define HT_SOCKET			0
       
    30 #define HT_WIN32FILEHANDLE	1
       
    31 #define HT_LINUXFILEHANDLE	2
       
    32 
       
    33 #define REPLY_OK			"OK"
       
    34 #define	REPLY_ERROR			"ERROR"
       
    35 #define REPLY_TIMEOUT		"TIMEOUT"
       
    36 
       
    37 #define CSP_LISTFULL		2001
       
    38 #define CSP_BUFFERFULL		2002
       
    39 
       
    40 //Types
       
    41 typedef enum 
       
    42 {
       
    43 	RECEIVE_HELLO,
       
    44 	RECEIVE_NAME,
       
    45 	RECEIVE_VALUE,
       
    46 	RECEIVE_GOODBYE
       
    47 } TReceiveStatus;
       
    48 
       
    49 //struct required for the name/value pairs
       
    50 typedef struct 
       
    51 {
       
    52 	char iName[MAXBUFFERLEN];
       
    53 	char iValue[MAXBUFFERLEN];
       
    54 } TNameValuePair;
       
    55 
       
    56 //----------------------------------------------------------------------------------
       
    57 //generic server class
       
    58 class CXServer
       
    59 {
       
    60 	public:
       
    61 
       
    62 		//constructor/destructor
       
    63 		CXServer();
       
    64 		~CXServer();
       
    65 
       
    66 		//functions
       
    67 		int OnExecute(int handle, int handletype);
       
    68 
       
    69 		//data
       
    70 		TReceiveStatus iStatus;
       
    71 		TNameValuePair iList[MAXLISTLENGTH];
       
    72 		
       
    73 	private:
       
    74 
       
    75 		//functions
       
    76 		int CheckForHello(int handle, int handletype, int freeslot);
       
    77 		int CheckForData(int handle, int handletype, int freeslot);
       
    78 		void CheckForGoodbye(int handle, int handletype, int latestposition);
       
    79 		int CheckForTimeout(int handle);
       
    80 
       
    81 		int Read(int handle, int handletype, char* c);
       
    82 		int Write(int handle, int handletype, char *buff, int bufflen );
       
    83 		
       
    84 		//data
       
    85 		char* iListPtr;
       
    86 
       
    87 		char iGoodbyebuffer[8];
       
    88 		char iHellobuffer[6];
       
    89 
       
    90 		fd_set iReadSocketSet;
       
    91 		struct timeval timeout;
       
    92 };
       
    93 
       
    94 //----------------------------------------------------------------------------------
       
    95 
       
    96 #endif __CXSERVER_H__
       
    97