Switch to unified view

a/libupnpp/soaphelp.cxx b/libupnpp/soaphelp.cxx
...
...
31
   
31
   
32
   As the top node name is qualified by a namespace, it's easier to just use 
32
   As the top node name is qualified by a namespace, it's easier to just use 
33
   action name passed in the libupnp action callback.
33
   action name passed in the libupnp action callback.
34
*/
34
*/
35
bool decodeSoapBody(const char *callnm, IXML_Document *actReq, 
35
bool decodeSoapBody(const char *callnm, IXML_Document *actReq, 
36
                    SoapArgs *res)
36
                    SoapDecodeOutput *res)
37
{
37
{
38
    bool ret = false;
38
    bool ret = false;
39
    IXML_NodeList* nl = 0;
39
    IXML_NodeList* nl = 0;
40
    IXML_Node* topNode = 
40
    IXML_Node* topNode = 
41
        ixmlNode_getFirstChild((IXML_Node *)actReq);
41
        ixmlNode_getFirstChild((IXML_Node *)actReq);
...
...
90
    if (nl)
90
    if (nl)
91
        ixmlNodeList_free(nl);
91
        ixmlNodeList_free(nl);
92
    return ret;
92
    return ret;
93
}
93
}
94
94
95
bool SoapArgs::getBool(const char *nm, bool *value) const
95
bool SoapDecodeOutput::getBool(const char *nm, bool *value) const
96
{
96
{
97
    map<string, string>::const_iterator it = args.find(nm);
97
    map<string, string>::const_iterator it = args.find(nm);
98
    if (it == args.end() || it->second.empty()) {
98
    if (it == args.end() || it->second.empty()) {
99
        return false;
99
        return false;
100
    }
100
    }
...
...
110
        return false;
110
        return false;
111
    }
111
    }
112
    return true;
112
    return true;
113
}
113
}
114
114
115
bool SoapArgs::getInt(const char *nm, int *value) const
115
bool SoapDecodeOutput::getInt(const char *nm, int *value) const
116
{
116
{
117
    map<string, string>::const_iterator it = args.find(nm);
117
    map<string, string>::const_iterator it = args.find(nm);
118
    if (it == args.end() || it->second.empty()) {
118
    if (it == args.end() || it->second.empty()) {
119
        return false;
119
        return false;
120
    }
120
    }
121
    *value = atoi(it->second.c_str());
121
    *value = atoi(it->second.c_str());
122
    return true;
122
    return true;
123
}
123
}
124
124
125
bool SoapArgs::getString(const char *nm, string *value) const
125
bool SoapDecodeOutput::getString(const char *nm, string *value) const
126
{
126
{
127
    map<string, string>::const_iterator it = args.find(nm);
127
    map<string, string>::const_iterator it = args.find(nm);
128
    if (it == args.end() || it->second.empty()) {
128
    if (it == args.end() || it->second.empty()) {
129
        return false;
129
        return false;
130
    }
130
    }
131
    *value = it->second;
131
    *value = it->second;
132
    return true;
132
    return true;
133
}
133
}
134
134
135
string SoapArgs::xmlQuote(const string& in)
135
string SoapDecodeOutput::xmlQuote(const string& in)
136
{
136
{
137
    string out;
137
    string out;
138
    for (unsigned int i = 0; i < in.size(); i++) {
138
    for (unsigned int i = 0; i < in.size(); i++) {
139
        switch(in[i]) {
139
        switch(in[i]) {
140
        case '"': out += "&quot;";break;
140
        case '"': out += "&quot;";break;
...
...
147
    }
147
    }
148
    return out;
148
    return out;
149
}
149
}
150
150
151
// Yes inefficient. whatever...
151
// Yes inefficient. whatever...
152
string SoapDecodeOutput::i2s(int val)
153
{
154
    char cbuf[30];
155
    sprintf(cbuf, "%d", val);
156
    return string(cbuf);
157
}
152
string SoapArgs::i2s(int val)
158
string SoapEncodeInput::i2s(int val)
153
{
159
{
154
    char cbuf[30];
160
    char cbuf[30];
155
    sprintf(cbuf, "%d", val);
161
    sprintf(cbuf, "%d", val);
156
    return string(cbuf);
162
    return string(cbuf);
157
}
163
}
158
164
159
IXML_Document *buildSoapBody(SoapData& data)
165
IXML_Document *buildSoapBody(const SoapEncodeInput& data, bool isResponse)
160
{
166
{
161
    IXML_Document *doc = ixmlDocument_createDocument();
167
    IXML_Document *doc = ixmlDocument_createDocument();
162
    if (doc == 0) {
168
    if (doc == 0) {
163
        cerr << "buildSoapResponse: out of memory" << endl;
169
        cerr << "buildSoapResponse: out of memory" << endl;
164
        return 0;
170
        return 0;
165
    }
171
    }
166
    string topname = string("u:") + data.name + "Response";
172
    string topname = string("u:") + data.name;
173
    if (isResponse)
174
        topname += "Response";
175
167
    IXML_Element *top =  
176
    IXML_Element *top =  
168
        ixmlDocument_createElementNS(doc, data.serviceType.c_str(), 
177
        ixmlDocument_createElementNS(doc, data.serviceType.c_str(), 
169
                                     topname.c_str());
178
                                     topname.c_str());
170
    ixmlElement_setAttribute(top, "xmlns:u", data.serviceType.c_str());
179
    ixmlElement_setAttribute(top, "xmlns:u", data.serviceType.c_str());
171
180