1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * INTERFACE: C Rappture Outcome Interface Source |
---|
4 | * |
---|
5 | * ====================================================================== |
---|
6 | * AUTHOR: Derrick Kearney, Purdue University |
---|
7 | * Copyright (c) 2004-2007 Purdue Research Foundation |
---|
8 | * |
---|
9 | * See the file "license.terms" for information on usage and |
---|
10 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
11 | * ====================================================================== |
---|
12 | */ |
---|
13 | |
---|
14 | #include "RpOutcome.h" |
---|
15 | #include "RpOutcomeCInterface.h" |
---|
16 | #include "RpOutcomeCHelper.h" |
---|
17 | |
---|
18 | |
---|
19 | #ifdef __cplusplus |
---|
20 | extern "C" { |
---|
21 | #endif |
---|
22 | |
---|
23 | int |
---|
24 | RapptureOutcomeInit(RapptureOutcome* status) |
---|
25 | { |
---|
26 | if (status == NULL) { |
---|
27 | return -1; |
---|
28 | } |
---|
29 | |
---|
30 | status->_status = NULL; |
---|
31 | |
---|
32 | return 0; |
---|
33 | } |
---|
34 | |
---|
35 | int |
---|
36 | RapptureOutcomeNew(RapptureOutcome* status) |
---|
37 | { |
---|
38 | if (status == NULL) { |
---|
39 | return -1; |
---|
40 | } |
---|
41 | |
---|
42 | RapptureOutcomeFree(status); |
---|
43 | status->_status = (void*) new Rappture::Outcome(); |
---|
44 | |
---|
45 | return 0; |
---|
46 | } |
---|
47 | |
---|
48 | int |
---|
49 | RapptureOutcomeFree(RapptureOutcome* status) |
---|
50 | { |
---|
51 | if (status->_status != NULL) { |
---|
52 | delete ((Rappture::Outcome*)status->_status); |
---|
53 | status->_status = NULL; |
---|
54 | } |
---|
55 | return 0; |
---|
56 | } |
---|
57 | |
---|
58 | int |
---|
59 | RpOutcomeToCOutcome(Rappture::Outcome* rpoutcome, RapptureOutcome* status) |
---|
60 | { |
---|
61 | if (rpoutcome == NULL) { |
---|
62 | return -1; |
---|
63 | } |
---|
64 | |
---|
65 | if (status == NULL) { |
---|
66 | return -1; |
---|
67 | } |
---|
68 | |
---|
69 | RapptureOutcomeFree(status); |
---|
70 | status->_status = new Rappture::Outcome(*rpoutcome); |
---|
71 | return 0; |
---|
72 | } |
---|
73 | |
---|
74 | int |
---|
75 | RapptureOutcomeError( RapptureOutcome* outcome, |
---|
76 | const char* errmsg, |
---|
77 | int status ) |
---|
78 | { |
---|
79 | if (outcome == NULL) { |
---|
80 | return -1; |
---|
81 | } |
---|
82 | |
---|
83 | if (outcome->_status == NULL) { |
---|
84 | return -1; |
---|
85 | } |
---|
86 | |
---|
87 | ((Rappture::Outcome*)outcome->_status)->error(errmsg,status); |
---|
88 | return 0; |
---|
89 | } |
---|
90 | |
---|
91 | int |
---|
92 | RapptureOutcomeClear(RapptureOutcome* status) |
---|
93 | { |
---|
94 | if (status == NULL) { |
---|
95 | return -1; |
---|
96 | } |
---|
97 | |
---|
98 | if (status->_status == NULL) { |
---|
99 | return -1; |
---|
100 | } |
---|
101 | |
---|
102 | ((Rappture::Outcome*)status->_status)->clear(); |
---|
103 | return 0; |
---|
104 | } |
---|
105 | |
---|
106 | int |
---|
107 | RapptureOutcomeAddContext(RapptureOutcome* status, const char* msg) |
---|
108 | { |
---|
109 | if (status == NULL) { |
---|
110 | return -1; |
---|
111 | } |
---|
112 | |
---|
113 | if (status->_status == NULL) { |
---|
114 | return -1; |
---|
115 | } |
---|
116 | |
---|
117 | ((Rappture::Outcome*)status->_status)->addContext(msg); |
---|
118 | return 0; |
---|
119 | } |
---|
120 | |
---|
121 | const char* |
---|
122 | RapptureOutcomeRemark(RapptureOutcome* status) |
---|
123 | { |
---|
124 | return NULL; |
---|
125 | } |
---|
126 | |
---|
127 | const char* |
---|
128 | RapptureOutcomeContext(RapptureOutcome* status) |
---|
129 | { |
---|
130 | return NULL; |
---|
131 | } |
---|
132 | |
---|
133 | int |
---|
134 | RapptureOutcomeCheck(RapptureOutcome* status) |
---|
135 | { |
---|
136 | return ((int)((Rappture::Outcome*)status->_status)); |
---|
137 | } |
---|
138 | |
---|
139 | #ifdef __cplusplus |
---|
140 | } |
---|
141 | #endif // ifdef __cplusplus |
---|