SINetworkMessages.h

00001 #ifndef _SINETWORKMESSAGES_H_
00002 #define _SINETWORKMESSAGES_H_
00003 
00004 #include <SIBCUtil.h>
00005 
00006 #define SI_NETMSG_FREAD_PACKET_SIZE     256
00007 #define SI_NET_FILE_TRANSFER_ATTEMPTS   5
00008 
00009 //
00010 // Messages
00011 //
00012 
00013 enum
00014 {
00015     SI_NETMSG_LOADFILE,
00016     SI_NETMSG_MERGEFILE,
00017     SI_NETMSG_SETHOSTNAME,
00018 
00019     SI_NETMSG_FILEOPEN,
00020     SI_NETMSG_FILEOPEN_ANSWER,
00021 
00022     SI_NETMSG_EOF,
00023     SI_NETMSG_EOF_ANSWER,
00024 
00025     SI_NETMSG_FGETC,
00026     SI_NETMSG_FGETC_ANSWER,
00027 
00028     SI_NETMSG_FILECLOSE,
00029     SI_NETMSG_FILECLOSE_ANSWER,
00030 
00031     SI_NETMSG_FTELL,
00032     SI_NETMSG_FTELL_ANSWER,
00033 
00034     SI_NETMSG_FSEEK,
00035     SI_NETMSG_FSEEK_ANSWER,
00036 
00037     SI_NETMSG_FREAD,
00038     SI_NETMSG_FREAD_PACKET,
00039     SI_NETMSG_FREAD_END,
00040 
00041     SI_NETMSG_FREAD_CONFIRM,
00042     
00043     SI_NETMSG_SETPARAMVALUE,
00044     SI_NETMSG_GETPARAMHANDLE,
00045     SI_NETMSG_PARAMHANDLE,
00046     
00047     SI_NETMSG_CMDEND
00048 
00049 };
00050 
00051 #if defined(_WIN32) || defined(_WIN32_WCE) || defined(_XBOX)
00052 #pragma pack( push )
00053 #pragma pack( 1 )
00054 #elif defined(CODEWARRIOR)
00055 #pragma options align= native 
00056 #endif
00057 
00058 struct SINetMsgLoadFile
00059 {
00060     SI_Char     l_szFilename[128];
00061 };
00062 
00063 struct SINetMsgSetParamValue
00064 {
00065     SI_Long     m_lHandle;
00066     SI_Float    m_fValue;
00067 };
00068 
00069 struct SINetMsgSetHostName
00070 {
00071     SI_Char     m_szHostName[128];
00072 };
00073 
00074 struct SINetMsgFileOpen
00075 {
00076     SI_Char     m_szFilename[256];
00077     SI_Char     m_szMode[4];
00078 };
00079 
00080 struct SINetMsgFileOpenAnswer
00081 {
00082     SI_Long     m_lHandle;
00083 };
00084 
00085 struct SINetMsgFileEOF
00086 {
00087     SI_Long     m_lHandle;
00088 };
00089 
00090 struct SINetMsgFileEOFAnswer
00091 {
00092     SI_Int      m_iResult;
00093 };
00094 
00095 struct SINetMsgFGETC
00096 {
00097     SI_Long     m_lHandle;
00098 };
00099 
00100 struct SINetMsgFGETCAnswer
00101 {
00102     SI_Int      m_iChar;
00103 };
00104 
00105 
00106 struct SINetMsgFileClose
00107 {
00108     SI_Long     m_lHandle;
00109 };
00110 
00111 struct SINetMsgFileCloseAnswer
00112 {
00113     SI_Int      m_iChar;
00114 };
00115 
00116 struct SINetMsgFileTell
00117 {
00118     SI_Long     m_lHandle;
00119 
00120 };
00121 
00122 struct SINetMsgFileEnd
00123 {
00124     SI_Long     m_lTotalBytes;
00125 
00126 };
00127 
00128 
00129 struct SINetMsgFileTellAnswer
00130 {
00131     SI_Long     m_lOffset;
00132 };
00133 
00134 struct SINetMsgFileSeek
00135 {
00136     SI_Long     m_lHandle;
00137     SI_Long     m_lOffset;
00138     SI_Int      m_iMode;
00139 
00140 };
00141 
00142 struct SINetMsgFileSeekAnswer
00143 {
00144     SI_Int      m_iAnswer;
00145 
00146 };
00147 
00148 struct SINetMsgFileRead
00149 {
00150     SI_Long     m_lHandle;
00151     SI_Long     m_lSize;
00152 
00153 };
00154 
00155 struct SINetMsgFileReadPacket
00156 {
00157     SI_Long     m_lOffset;
00158     SI_Long     m_lSize;
00159     SI_Char     m_pData[SI_NETMSG_FREAD_PACKET_SIZE];
00160 
00161 };
00162 
00163 struct SINetMsgFileReadConfirm
00164 {
00165     SI_Long     m_lOffset;
00166     SI_Long     m_lSize;
00167 };
00168 
00169 struct SINetMsgParamName
00170 {
00171     SI_Char     m_szName[256];
00172 };
00173 
00174 struct SINetMsgParamHandle
00175 {
00176     SI_Long     m_lHandle;
00177 };
00178 
00179 #if defined(_WIN32) || defined(_WIN32_WCE) || defined(_XBOX)
00180 #pragma pack( pop )
00181 #elif defined(CODEWARRIOR)
00182 #pragma options align= reset
00183 #endif
00184 
00185 struct XSICOREEXPORT SINetMsg
00186 {
00187     SI_Char m_bID;
00188 
00189     union
00190     {
00191         
00192         SINetMsgLoadFile        m_LoadFile;
00193         SINetMsgSetParamValue   m_ParamValue;
00194         SINetMsgSetHostName     m_HostName;
00195 
00196         SINetMsgFileOpen        m_FileOpen;
00197         SINetMsgFileOpenAnswer  m_FileOpenAnswer;
00198 
00199 
00200         SINetMsgFileEOF         m_FileEOF;
00201         SINetMsgFileEOFAnswer   m_FileEOFAnswer;
00202 
00203         SINetMsgFGETC           m_FGETC;
00204         SINetMsgFGETCAnswer     m_FGETCAnswer;
00205 
00206         SINetMsgFileClose       m_FileClose;
00207         SINetMsgFileCloseAnswer m_FileCloseAnswer;
00208 
00209         SINetMsgFileTell        m_FileTell;
00210         SINetMsgFileTellAnswer  m_FileTellAnswer;
00211 
00212         SINetMsgFileSeek        m_FileSeek;
00213         SINetMsgFileSeekAnswer  m_FileSeekAnswer;
00214 
00215         SINetMsgFileRead        m_FileRead;
00216         SINetMsgFileReadPacket  m_FileReadPacket;
00217 
00218         SINetMsgFileReadConfirm m_FileReadConfirm;
00219 
00220         SINetMsgFileEnd         m_FileReadEnd;
00221 
00222         SINetMsgParamName       m_ParamName;
00223         SINetMsgParamHandle     m_ParamHandle;
00224 
00225     };
00226 
00227 public:
00228 
00229     explicit SINetMsg( SI_Char in_bID = 0 );
00230 
00231     //
00232     // Accessors
00233     //
00234 
00235     SINetMsgLoadFile&           GetLoadFile()       { return m_LoadFile;}
00236     SINetMsgSetParamValue&      GetSetParamValue()  { return m_ParamValue;}
00237     SINetMsgSetHostName&        GetHostName()       { return m_HostName;}
00238 
00239     SINetMsgFileOpen&           GetFileOpen()           { return m_FileOpen;}
00240     SINetMsgFileOpenAnswer&     GetFileOpenAnswer()     { return m_FileOpenAnswer;}
00241 
00242     SINetMsgFileEOF&            GetFileEOF()        { return m_FileEOF;};
00243     SINetMsgFileEOFAnswer&      GetFileEOFAnswer()      { return m_FileEOFAnswer;};
00244 
00245     SINetMsgFGETC&              GetFGETC()          { return m_FGETC;};
00246     SINetMsgFGETCAnswer&        GetFGETCAnswer()    { return m_FGETCAnswer;};
00247 
00248     SINetMsgFileClose&          GetFileClose()      { return m_FileClose;};
00249     SINetMsgFileCloseAnswer&    GetFileCloseAnswer(){ return m_FileCloseAnswer;};
00250 
00251     SINetMsgFileTell&           GetFileTell()       { return m_FileTell;};
00252     SINetMsgFileTellAnswer&     GetFileTellAnswer()     { return m_FileTellAnswer;};
00253 
00254     SINetMsgFileSeek&           GetFileSeek()       { return m_FileSeek;};
00255     SINetMsgFileSeekAnswer&     GetFileSeekAnswer()     { return m_FileSeekAnswer;};
00256 
00257     SINetMsgFileRead&           GetFileRead()       { return m_FileRead; };
00258     SINetMsgFileReadPacket&     GetFileReadPacket() { return m_FileReadPacket; };
00259     
00260     SINetMsgFileReadConfirm&    GetFileReadConfirm() { return m_FileReadConfirm; };
00261 
00262     SINetMsgFileEnd&            GetFileReadEnd()    { return m_FileReadEnd; };
00263 
00264     SINetMsgParamName&          GetParamName()      { return m_ParamName; };
00265     SINetMsgParamHandle&        GetParamHandle()        { return m_ParamHandle; };
00266 
00267         
00268 
00269     SI_Char GetId()         const   { return m_bID; }
00270     SI_Int  GetMaxSize()    const   { return sizeof(*this); } 
00271     SI_Int  GetSize()       const;
00272 };
00273 
00274 
00275 #endif