1 |
693 |
jeremybenn |
extern "C" {
|
2 |
|
|
typedef struct __locale_struct {
|
3 |
|
|
}
|
4 |
|
|
*__locale_t;
|
5 |
|
|
union wait {
|
6 |
|
|
};
|
7 |
|
|
extern "C" {
|
8 |
|
|
}
|
9 |
|
|
typedef struct _IO_FILE FILE;
|
10 |
|
|
typedef struct {
|
11 |
|
|
union {
|
12 |
|
|
}
|
13 |
|
|
__value;
|
14 |
|
|
}
|
15 |
|
|
_G_fpos64_t;
|
16 |
|
|
struct _IO_marker {
|
17 |
|
|
}
|
18 |
|
|
_IO_cookie_io_functions_t;
|
19 |
|
|
extern struct _IO_FILE *stderr;
|
20 |
|
|
extern int fprintf (FILE *__restrict __stream, __const char *__restrict __format, ...);
|
21 |
|
|
}
|
22 |
|
|
enum {
|
23 |
|
|
kPOVMSObjectClassID = 'OCLA', kPOVMSMessageClassID = 'MCLA', kPOVMSMessageIdentID = 'MIDE', kPOVMSSourceAddressID = 'MSRC', kPOVMSDestinationAddressID = 'MDST', kPOVMSMessageTimeoutID = 'TOUT', kPOVMSMessageErrorID = 'MERR' };
|
24 |
|
|
typedef void * POVMSContext;
|
25 |
|
|
typedef struct POVMSData POVMSObject, *POVMSObjectPtr;
|
26 |
|
|
typedef struct POVMSData POVMSAttribute, *POVMSAttributePtr;
|
27 |
|
|
typedef struct POVMSData POVMSAttributeList, *POVMSAttributeListPtr;
|
28 |
|
|
struct POVMSData {
|
29 |
|
|
int size;
|
30 |
|
|
union {
|
31 |
|
|
void *ptr;
|
32 |
|
|
struct POVMSNode *root;
|
33 |
|
|
};
|
34 |
|
|
};
|
35 |
|
|
struct POVMSNode {
|
36 |
|
|
struct POVMSNode *next;
|
37 |
|
|
unsigned int key;
|
38 |
|
|
struct POVMSData data;
|
39 |
|
|
};
|
40 |
|
|
int POVMSObject_Set (POVMSObjectPtr object, POVMSAttributePtr attr, unsigned int key);
|
41 |
|
|
int POVMSAttr_Copy (POVMSAttributePtr sourceattr, POVMSAttributePtr destattr);
|
42 |
|
|
int POVMSUtil_GetType (POVMSObjectPtr object, unsigned int key, unsigned int *typevalue);
|
43 |
|
|
namespace pov_base {
|
44 |
|
|
enum {
|
45 |
|
|
kNoError = 0, kNoErr = kNoError, kParamErr = -1, kMemFullErr = -2, kOutOfMemoryErr = kMemFullErr, kInvalidDataSizeErr = -3, kCannotHandleDataErr = -4, kNullPointerErr = -5, kChecksumErr = -6, kParseErr = -7, kCannotOpenFileErr = -8, kInvalidDestAddrErr = -9, kCannotConnectErr = -10, kDisconnectedErr = -11, kHostDisconnectedErr = -12, kNetworkDataErr = -13, kNetworkConnectionErr = -14, kObjectAccessErr = -15, kVersionErr = -16, kFileDataErr = -17, kAuthorisationErr = -18, kDataTypeErr = -19, kTimeoutErr = -20, kInvalidContextErr = -21 };
|
46 |
|
|
}
|
47 |
|
|
using namespace pov_base;
|
48 |
|
|
struct POVMSContextData {
|
49 |
|
|
};
|
50 |
|
|
int POVMS_AssertFunction (int cond, const char *str, const char *filename, int line);
|
51 |
|
|
int POVMS_OpenContext(POVMSContext *contextrefptr) {
|
52 |
|
|
POVMSContextData *context = __null;
|
53 |
|
|
if(contextrefptr == __null) return kParamErr;
|
54 |
|
|
if(POVMS_AssertFunction(context != __null, "POVMS_Open_Context failed, out of memory", "povms.cpp", 283) == false) return kMemFullErr;
|
55 |
|
|
return kNoErr;
|
56 |
|
|
}
|
57 |
|
|
int POVMS_AssertFunction(int cond, const char *str, const char *filename, int line) {
|
58 |
|
|
if(cond == false) {
|
59 |
|
|
fprintf(stderr, "POVMS_ASSERT failed in %s line %d: %s\n", filename, (int)line, str);
|
60 |
|
|
}
|
61 |
|
|
}
|
62 |
|
|
int POVMSObject_Copy(POVMSObjectPtr sourceobject, POVMSObjectPtr destobject) {
|
63 |
|
|
POVMSNode *cur = __null;
|
64 |
|
|
POVMSAttribute attr;
|
65 |
|
|
unsigned int t1, t2;
|
66 |
|
|
int ret = kNoErr;
|
67 |
|
|
if(destobject == __null) return kParamErr;
|
68 |
|
|
if(POVMSUtil_GetType(sourceobject, kPOVMSObjectClassID, &t1) != kNoErr) return kObjectAccessErr;
|
69 |
|
|
if(POVMSUtil_GetType(sourceobject, kPOVMSObjectClassID, &t2) != kNoErr) return kObjectAccessErr;
|
70 |
|
|
if(t1 != t2) return kDataTypeErr;
|
71 |
|
|
for(cur = sourceobject->root;
|
72 |
|
|
cur != __null;
|
73 |
|
|
cur = cur->next) {
|
74 |
|
|
if(POVMS_AssertFunction(POVMSAttr_Copy(&(cur->data), &attr) == kNoErr, "POVMSObject_Merge failed, out of memory", "povms.cpp", 2084) == false) {
|
75 |
|
|
}
|
76 |
|
|
if(POVMS_AssertFunction(POVMSObject_Set(destobject, &attr, cur->key) == kNoErr, "POVMSObject_Merge failed, out of memory", "povms.cpp", 2090) == false) {
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
return ret;
|
80 |
|
|
}
|
81 |
|
|
int POVMSObject_Set(POVMSObjectPtr object, POVMSAttributePtr attr, unsigned int key) {
|
82 |
|
|
}
|
83 |
|
|
int POVMSAttrList_Copy(POVMSAttributeListPtr sourcelist, POVMSAttributeListPtr destlist) {
|
84 |
|
|
int cnt;
|
85 |
|
|
int err = kNoErr;
|
86 |
|
|
if(sourcelist == __null) return kParamErr;
|
87 |
|
|
if(destlist == __null) return kParamErr;
|
88 |
|
|
if(sourcelist == destlist) return kParamErr;
|
89 |
|
|
if(sourcelist->size < 0) return kParamErr;
|
90 |
|
|
if(sourcelist->size > 0) {
|
91 |
|
|
if(sourcelist->ptr != __null) {
|
92 |
|
|
if(POVMS_AssertFunction(destlist->ptr != __null, "POVMSAttrList_Copy failed, out of memory", "povms.cpp", 3020) == false) return -1;
|
93 |
|
|
}
|
94 |
|
|
for(cnt = 0;
|
95 |
|
|
cnt < sourcelist->size;
|
96 |
|
|
cnt++) {
|
97 |
|
|
}
|
98 |
|
|
}
|
99 |
|
|
return err;
|
100 |
|
|
}
|