+++ /dev/null
-noinst_LIBRARIES = libServer.a
-noinst_PROGRAMS = buftest msgtest
-
-if ENABLE_MSERVER_AS
-
-MSERVER_AS = \
- msg_0001_hello.cxx \
- msg_0001_hello.hxx \
- messagebuf.cxx \
- messagebuf.hxx \
- message.cxx \
- message.hxx
-
-MSERVER_BUF = buftest.cxx
-
-MSERVER_MSG = msgtest.cxx
-
-else
-
-MSERVER_AS =
-
-MSERVER_BUF =
-
-MSERVER_MSG =
-
-endif
-
-libServer_a_SOURCES = $(MSERVER_AS)
-
-buftest_SOURCES = $(MSERVER_BUF)
-buftest_LDADD = libServer.a
-
-msgtest_SOURCES = $(MSERVER_MSG)
-msgtest_LDADD = libServer.a
-
-INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
+++ /dev/null
-#include "message.hxx"\r
-\r
-void dumpmessage(string msg)\r
-{\r
- FGMPSMessageBuf buf;\r
-\r
- buf.set(msg);\r
- buf.ofs(0);\r
-\r
- bool done=false;\r
- while (!done) {\r
- unsigned char mid8, uval8;\r
- unsigned int mid16, uval16;\r
- unsigned long uval32;\r
- unsigned long long uval64;\r
- char val8;\r
- int val16;\r
- long val32;\r
- long long val64;\r
- float valf;\r
- double vald;\r
- string vals;\r
- printf("dump: ");\r
- for (int i=0; i<16; i++) printf("%02x ", buf.peek(i));\r
- printf("\n");\r
- try {\r
- int tag = buf.get(true);\r
- switch (tag) {\r
- case fgmps_som8:\r
- mid8 = *(unsigned char *)buf.read1();\r
- printf("Start Message ID = %02x\n", mid8);\r
- break;\r
- case fgmps_som16:\r
- mid16 = *(unsigned int *)buf.read2();\r
- printf("Start Message ID = %04x\n", mid16);\r
- break;\r
- case fgmps_eom:\r
- printf("End Of Message\n", tag);\r
- done = true;\r
- break;\r
- case fgmps_uchar:\r
- uval8 = *(unsigned char *)buf.read1();\r
- printf("uchar = %02x\n", uval8);\r
- break;\r
- case fgmps_uint:\r
- uval16 = *(unsigned int *)buf.read2();\r
- printf("uint = %04x\n", uval16);\r
- break;\r
- case fgmps_ulong:\r
- uval32 = *(unsigned long *)buf.read4();\r
- printf("ulong = %08lx\n", uval32);\r
- break;\r
- case fgmps_ulonglong:\r
- uval64 = *(unsigned long long *)buf.read8();\r
- printf("ulonglong = %16llx\n", uval64);\r
- break;\r
- case fgmps_char:\r
- val8 = *(char *)buf.read1();\r
- printf("char = %02x\n", val8);\r
- break;\r
- case fgmps_int:\r
- val16 = *(int *)buf.read2();\r
- printf("int = %04x\n", val16);\r
- break;\r
- case fgmps_long:\r
- val32 = *(long *)buf.read4();\r
- printf("long = %08lx\n", val32);\r
- break;\r
- case fgmps_longlong:\r
- val64 = *(long long *)buf.read8();\r
- printf("longlong = %16llx\n", val64);\r
- break;\r
- case fgmps_float:\r
- valf = buf.readf();\r
- printf("float = %f\n", valf);\r
- break;\r
- case fgmps_double:\r
- vald = buf.readd();\r
- printf("double = %g\n", vald);\r
- break;\r
- case fgmps_string:\r
- uval8 = buf.get();\r
- vals = buf.reads(uval8);\r
- printf("string = %s\n", vals.c_str());\r
- break;\r
- default:\r
- printf("Unknown prefix = %02x\n", tag);\r
- done = true;\r
- break;\r
- }\r
- } catch (FGMPSDataException e) {\r
- printf("Data Exception\n");\r
- done = true;\r
- }\r
- }\r
-}\r
-\r
-main(int argc, char **argv)\r
-{\r
- FGMPSMessageBuf buf;\r
-\r
- unsigned char uval8;\r
- unsigned int uval16;\r
- unsigned long uval32;\r
- unsigned long long uval64;\r
- char val8;\r
- int val16;\r
- long val32;\r
- long long val64;\r
- float valf;\r
- double vald;\r
- string vals;\r
-\r
- buf.clr();\r
- buf.put(fgmps_som8, true);\r
- buf.put(1);\r
- for (int i=0; i<256; i++) {\r
- buf.put(fgmps_uchar, true);\r
- buf.put(i);\r
- }\r
- buf.put(fgmps_eom, true);\r
- dumpmessage(buf.str());\r
-\r
- buf.clr();\r
- buf.put(fgmps_som8, true); buf.put(1);\r
-\r
- uval8 = 251; buf.put(fgmps_uchar, true); buf.write1(&uval8);\r
- uval16 = 34567; buf.put(fgmps_uint, true); buf.write2(&uval16);\r
- uval32 = 1345678901; buf.put(fgmps_ulong, true); buf.write4(&uval32);\r
- //uval64 = 9999999999; buf.put(fgmps_ulonglong, true); buf.write8(&uval64);\r
- val8 = -120; buf.put(fgmps_char, true); buf.write1(&val8);\r
- val16 = -17890; buf.put(fgmps_int, true); buf.write2(&val16);\r
- val32 = -1345678901; buf.put(fgmps_long, true); buf.write4(&val32);\r
- //val64 = -9999999999; buf.put(fgmps_longlong, true); buf.write8(&val64);\r
- valf = 2 * 3.14; buf.put(fgmps_float, true); buf.writef(valf);\r
- vald = 3 * 3.1415927; buf.put(fgmps_double, true); buf.writed(vald);\r
- vals = "hi there"; buf.put(fgmps_string, true); buf.writes(vals);\r
- buf.put(fgmps_eom, true);\r
- dumpmessage(buf.str());\r
-}\r
+++ /dev/null
-// message.hxx -- Multiplayer Client/Server message base class
-//
-// Written by John Barrett, started November 2003.
-//
-// Copyright (C) 2003 John R. Barrett - jbarrett@accesshosting.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-
-
-#include "message.hxx"
-
-FGMPSInstanceFuncMap FGMPSMessage::funcmap;
-
-FGMPSMessage::FGMPSMessage()
-{
- msgid = 0x0000;
- elements[0].type = fgmps_null;
- elements[0].data = NULL;
-
-}
-
-string FGMPSMessage::encodemsg()
-{
- FGMPSMsgElementEntry* ptr = getelements();
-
- buf.clr();
- if (msgid > 255) {
- buf.put(fgmps_som16, true);
- buf.write2(&msgid);
- } else {
- buf.put(fgmps_som8, true);
- buf.write1(&msgid);
- }
- while (ptr->type != fgmps_null) {
- buf.put(ptr->type, true);
- //printf ("adding %02x\n", ptr->type);
- switch (ptr->type) {
- case fgmps_uchar:
- case fgmps_char:
- buf.write1(ptr->data);
- break;
- case fgmps_uint:
- case fgmps_int:
- buf.write2(ptr->data);
- break;
- case fgmps_ulong:
- case fgmps_long:
- buf.write4(ptr->data);
- break;
- case fgmps_float:
- buf.writef(*(float*)ptr->data);
- break;
- case fgmps_double:
- buf.writed(*(double*)ptr->data);
- break;
- case fgmps_string:
- buf.writes(*(string*)ptr->data);
- break;
- }
- ptr++;
- }
-
- buf.put(fgmps_eom, true);
-
- return buf.str();
-}
-
-FGMPSMessage* FGMPSMessage::decodemsg(string msg)
-{
- FGMPSMessageBuf buf;
- unsigned char ch;
- unsigned int mid;
- FGMPSInstanceFuncMap::iterator fmitr;
-
- buf.set(msg);
- buf.ofs(0);
- ch = buf.get(true);
- if (ch != fgmps_som8 && ch != fgmps_som16) {
- throw FGMPSDataException("Invalid start of message");
- }
- if (ch == fgmps_som8) {
- ch = buf.get();
- mid = ch;
- } else {
- mid = *(unsigned int *)buf.read2();
- }
-
- fmitr = funcmap.find(mid);
- if (fmitr == funcmap.end()) {
- throw FGMPSDataException("MessageID has no registered Message Class");
- }
- FGMPSMessage* msgclass = (fmitr->second)();
- FGMPSMsgElementEntry* elements = msgclass->getelements();
- while ((ch = buf.get()) != fgmps_eom) {
- //printf("dump: ");
- //for (int i=-1; i<16; i++) printf("%02x ", buf.peek(i));
- //printf("\n");
-
- if (ch != elements->type) {
- delete msgclass;
- throw FGMPSDataException("Decode: Message Structure Error");
- }
- switch (ch) {
- case fgmps_uchar:
- case fgmps_char:
- memcpy(elements->data, buf.read1(), 1);
- break;
- case fgmps_uint:
- case fgmps_int:
- memcpy(elements->data, buf.read2(), 2);
- break;
- case fgmps_ulong:
- case fgmps_long:
- memcpy(elements->data, buf.read4(), 4);
- break;
- case fgmps_float:
- *(float*)elements->data = buf.readf();
- break;
- case fgmps_double:
- *(double*)elements->data = buf.readd();
- break;
- case fgmps_string:
- ch = buf.get();
- *(string*)elements->data = buf.reads(ch);
- break;
- default:
- delete msgclass;
- throw FGMPSDataException("Decode: Unknown data type");
- break;
- }
- elements++;
- }
- return msgclass;
-}
-
-
+++ /dev/null
-// message.hxx -- Multiplayer Client/Server message base class
-//
-// Written by John Barrett, started November 2003.
-//
-// Copyright (C) 2003 John R. Barrett - jbarrett@accesshosting.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-
-
-#ifndef _FG_MPS_MESSAGE_HXX
-#define _FG_MPS_MESSAGE_HXX
-
-#include <simgear/compiler.h>
-
-#include STL_STRING
-#include <stdexcept>
-#include <map>
-
-SG_USING_STD(string);
-SG_USING_STD(invalid_argument);
-SG_USING_STD(map);
-
-#include "messagebuf.hxx"
-
-typedef enum
-{
- fgmps_null = 0x00,
- fgmps_uchar = 0xf0,
- fgmps_uint = 0xf1,
- fgmps_ulong = 0xf2,
- fgmps_ulonglong = 0xf3,
- fgmps_char = 0xf4,
- fgmps_int = 0xf5,
- fgmps_long = 0xf6,
- fgmps_longlong = 0xf7,
- fgmps_float = 0xf8,
- fgmps_double = 0xf9,
- fgmps_string = 0xfa,
- fgmps_reserved = 0xfb,
- fgmps_eom = 0xfc,
- fgmps_som8 = 0xfd,
- fgmps_som16 = 0xfe,
- fgmps_esc = 0xfe
-} FGMPSMsgElementType;
-
-typedef struct
-{
- FGMPSMsgElementType type;
- void * data;
-} FGMPSMsgElementEntry;
-
-#define FGMPSMsgElementArrayEnd {fgmps_null, 0}
-
-class FGMPSMessage;
-
-typedef FGMPSMessage* FGMPSMessagePtr;
-typedef FGMPSMessagePtr (*FGMPSMsgInstanceFunc)(void);
-
-typedef map<unsigned int, FGMPSMsgInstanceFunc> FGMPSInstanceFuncMap;
-
-class FGMPSMessage
-{
-private:
- static FGMPSInstanceFuncMap funcmap;
- FGMPSMsgElementEntry elements[1];
-protected:
- FGMPSMessageBuf buf;
- unsigned int msgid;
-public:
- static int registermsg(int msgid, FGMPSMsgInstanceFunc func)
- {
- funcmap[msgid] = func;
- }
-
- FGMPSMessage();
- ~FGMPSMessage() {}
-
- string encodemsg();
- static FGMPSMessage* decodemsg(string msg);
- unsigned int getmessageid() { return msgid; }
-
- virtual FGMPSMsgElementEntry* getelements() { return elements; }
-};
-
-#endif
+++ /dev/null
-#include "messagebuf.hxx"\r
-\r
-#include <netinet/in.h>\r
-\r
-unsigned char FGMPSMessageBuf::get(bool raw)\r
-{\r
- if (pos >= buf.length())\r
- throw FGMPSDataException( "FGMPSMessageBuf: Read past end of buffer" );\r
- if (raw) return buf[pos++];\r
- if ((unsigned char)buf[pos] == 0xff) {\r
- pos++;\r
- return ((unsigned char)buf[pos++] ^ 0xff);\r
- }\r
- return buf[pos++];\r
-}\r
-\r
-void FGMPSMessageBuf::put(unsigned char byte, bool raw)\r
-{\r
- if (!raw) {\r
- if ((byte & 0xf0) == 0xf0) {\r
- buf += 0xff;\r
- byte = byte ^ 0xff;\r
- }\r
- }\r
- buf += byte;\r
-}\r
-\r
-void FGMPSMessageBuf::write1(void* data)\r
-{\r
- put(*(unsigned char *)data);\r
-}\r
-\r
-void FGMPSMessageBuf::write2(void* data)\r
-{\r
- *((uint16_t*)tmp) = htons(*((uint16_t*)data));\r
- put(tmp[0]); \r
- put(tmp[1]); \r
-}\r
-\r
-void FGMPSMessageBuf::write4(void* data)\r
-{\r
- *((uint32_t*)tmp) = htonl(*((uint32_t*)data));\r
- put(tmp[0]); \r
- put(tmp[1]); \r
- put(tmp[2]); \r
- put(tmp[3]); \r
-}\r
-\r
-void FGMPSMessageBuf::write8(void* data)\r
-{\r
- *((uint32_t*)tmp+0) = htonl(*((uint32_t*)data+4));\r
- *((uint32_t*)tmp+4) = htonl(*((uint32_t*)data+0));\r
- put(tmp[0]); \r
- put(tmp[1]); \r
- put(tmp[2]); \r
- put(tmp[3]); \r
- put(tmp[4]); \r
- put(tmp[5]); \r
- put(tmp[6]); \r
- put(tmp[7]); \r
-}\r
-\r
-void FGMPSMessageBuf::writef(float data)\r
-{\r
- write4(&data);\r
-}\r
-\r
-void FGMPSMessageBuf::writed(double data)\r
-{\r
- write8(&data);\r
-}\r
-\r
-void FGMPSMessageBuf::writes(const string& data)\r
-{\r
- put(data.length());\r
- for (int i=0; i<data.length(); i++) put(data[i]);\r
-}\r
-\r
-void* FGMPSMessageBuf::read1()\r
-{\r
- tmp[0] = get();\r
- return tmp;\r
-}\r
-\r
-void* FGMPSMessageBuf::read2()\r
-{\r
- tmp[0] = get();\r
- tmp[1] = get();\r
- *((uint16_t*)tmp) = ntohs(*((uint16_t*)tmp));\r
- return tmp;\r
-}\r
-\r
-void* FGMPSMessageBuf::read4()\r
-{\r
- tmp[0] = get();\r
- tmp[1] = get();\r
- tmp[2] = get();\r
- tmp[3] = get();\r
- *((uint32_t*)tmp) = ntohl(*((uint32_t*)tmp));\r
- return tmp;\r
-}\r
-\r
-void* FGMPSMessageBuf::read8()\r
-{\r
- unsigned char res[32];\r
-\r
- res[0] = get();\r
- res[1] = get();\r
- res[2] = get();\r
- res[3] = get();\r
- res[4] = get();\r
- res[5] = get();\r
- res[6] = get();\r
- res[7] = get();\r
- *((uint32_t*)tmp+4) = ntohl(*((uint32_t*)res+0));\r
- *((uint32_t*)tmp+0) = ntohl(*((uint32_t*)res+4));\r
- return tmp;\r
-}\r
-\r
-float FGMPSMessageBuf::readf()\r
-{\r
- return *((float*)read4());\r
-}\r
-\r
-double FGMPSMessageBuf::readd()\r
-{\r
- return *((double*)read8());\r
-}\r
-\r
-string FGMPSMessageBuf::reads(size_t length)\r
-{\r
- string res = "";\r
- for (int i=0; i<length; i++) res += get();\r
- return res;\r
-}\r
-\r
-\r
-\r
+++ /dev/null
-// messagebuf.hxx -- Multiplayer Client/Server message buffer class\r
-//\r
-// Written by John Barrett, started November 2003.\r
-//\r
-// Copyright (C) 2003 John R. Barrett - jbarrett@accesshosting.com\r
-//\r
-// This program is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU General Public License as\r
-// published by the Free Software Foundation; either version 2 of the\r
-// License, or (at your option) any later version.\r
-//\r
-// This program is distributed in the hope that it will be useful, but\r
-// WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-// General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with this program; if not, write to the Free Software\r
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
-//\r
-\r
-\r
-#ifndef _FG_MPS_MESSAGEBUF_HXX\r
-#define _FG_MPS_MESSAGEBUF_HXX\r
-\r
-#include <simgear/compiler.h>\r
-\r
-#include STL_STRING\r
-#include <stdexcept>\r
-\r
-SG_USING_STD(string);\r
-SG_USING_STD(invalid_argument);\r
-\r
-class FGMPSDataException : public invalid_argument\r
-{\r
-public:\r
- FGMPSDataException( const string& what_string )\r
- : invalid_argument(what_string) {}\r
-};\r
-\r
-class FGMPSMessageBuf \r
-{\r
-\r
-private:\r
- string buf;\r
- size_t pos;\r
- unsigned char tmp[16];\r
-\r
-public:\r
-\r
- FGMPSMessageBuf() { init(""); }\r
- FGMPSMessageBuf(const string& data) { init(data); }\r
-\r
- ~FGMPSMessageBuf() {}\r
-\r
- void init(const string& data)\r
- {\r
- buf = data;\r
- pos = 0;\r
- }\r
-\r
- void clr() { buf = ""; }\r
- void add(const string& data) { buf += data; }\r
- void set(const string& data) { buf = data; }\r
- const string& str() { return buf; }\r
- size_t ofs() { return pos; }\r
- void ofs(size_t val) { pos = val; }\r
-\r
- unsigned char get(bool raw = false);\r
- unsigned char peek(size_t ofs = 0) { return buf[pos+ofs]; }\r
- void put(unsigned char byte, bool raw = false);\r
-\r
- void write1(void* data);\r
- void write2(void* data);\r
- void write4(void* data);\r
- void write8(void* data);\r
- void writef(float data);\r
- void writed(double data);\r
- void writes(string data);\r
-\r
- void* read1();\r
- void* read2();\r
- void* read4();\r
- void* read8();\r
- float readf();\r
- double readd();\r
- string reads(size_t length);\r
-\r
- const string& buffer() { return buf; }\r
-};\r
-\r
-#endif\r
+++ /dev/null
-// message.hxx -- Multiplayer Client/Server message base class\r
-//\r
-// Written by John Barrett, started November 2003.\r
-//\r
-// Copyright (C) 2003 John R. Barrett - jbarrett@accesshosting.com\r
-//\r
-// This program is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU General Public License as\r
-// published by the Free Software Foundation; either version 2 of the\r
-// License, or (at your option) any later version.\r
-//\r
-// This program is distributed in the hope that it will be useful, but\r
-// WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-// General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with this program; if not, write to the Free Software\r
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
-//\r
-\r
-\r
-#include "msg_0001_hello.hxx"\r
-\r
-FGMPSMsg0001Hello::FGMPSMsg0001Hello() \r
-{\r
- msgid = FGMPSMsg0001HelloID;\r
- elements[0].type = fgmps_uint; elements[0].data = &vermajor; \r
- elements[1].type = fgmps_uint; elements[1].data = &verminor; \r
- elements[2].type = fgmps_uint; elements[2].data = &verpatch; \r
- elements[3].type = fgmps_string; elements[3].data = &servname; \r
- elements[4].type = fgmps_null; elements[4].data = NULL; \r
-}\r
-\r
-\r
-\r
-\r
+++ /dev/null
-// message.hxx -- Multiplayer Client/Server message base class\r
-//\r
-// Written by John Barrett, started November 2003.\r
-//\r
-// Copyright (C) 2003 John R. Barrett - jbarrett@accesshosting.com\r
-//\r
-// This program is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU General Public License as\r
-// published by the Free Software Foundation; either version 2 of the\r
-// License, or (at your option) any later version.\r
-//\r
-// This program is distributed in the hope that it will be useful, but\r
-// WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-// General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with this program; if not, write to the Free Software\r
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
-//\r
-\r
-\r
-#ifndef _FG_MPS_MSG0001_HXX\r
-#define _FG_MPS_MSG0001_HXX\r
-\r
-#include "message.hxx"\r
-\r
-#define FGMPSMsg0001HelloID 0x0001\r
-\r
-class FGMPSMsg0001Hello: public FGMPSMessage\r
-{\r
-private:\r
- FGMPSMsgElementEntry elements[5];\r
-public:\r
-\r
- static void registerme() \r
- { \r
- FGMPSMessage::registermsg(FGMPSMsg0001HelloID, &FGMPSMsg0001Hello::instance);\r
- }\r
-\r
- static FGMPSMessage* instance() { return (FGMPSMessage*) new FGMPSMsg0001Hello; }\r
-\r
- virtual FGMPSMsgElementEntry* getelements() { return elements; }\r
-\r
- FGMPSMsg0001Hello();\r
- ~FGMPSMsg0001Hello() {}\r
-\r
- unsigned int vermajor;\r
- unsigned int verminor;\r
- unsigned int verpatch;\r
- string servname;\r
-};\r
-\r
-#endif\r
+++ /dev/null
-#include "msg_0001_hello.hxx"\r
-\r
-main(int argc, char **argv)\r
-{\r
- string str;\r
- FGMPSMsg0001Hello msg1, *msg2;\r
-\r
- FGMPSMsg0001Hello::registerme();\r
-\r
- msg1.vermajor = 3;\r
- msg1.verminor = 7;\r
- msg1.verpatch = 42;\r
- msg1.servname = "test";\r
-\r
- str = msg1.encodemsg();\r
-\r
- printf("Message ID = %ui\n", msg1.getmessageid());\r
- printf("major = %u\n", msg1.vermajor);\r
- printf("minor = %u\n", msg1.verminor);\r
- printf("patch = %u\n", msg1.verpatch);\r
- printf("sname = %s\n", msg1.servname.c_str());\r
-\r
- printf("dump: ");\r
- for (int i=0; i<str.length(); i++) printf("%02x ", (unsigned char)str[i]);\r
- printf("\n");\r
-\r
- try {\r
- msg2 = (FGMPSMsg0001Hello*)FGMPSMessage::decodemsg(str);\r
- } catch (FGMPSDataException e) {\r
- printf("Exception: %s\n", e.what());\r
- exit(1);\r
- }\r
-\r
- printf("Message ID = %u\n", msg2->getmessageid());\r
- printf("major = %u\n", msg2->vermajor);\r
- printf("minor = %u\n", msg2->verminor);\r
- printf("patch = %u\n", msg2->verpatch);\r
- printf("sname = %s\n", msg2->servname.c_str());\r
- \r
-}\r