本文整理汇总了C++中xmlrpc_strfree函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlrpc_strfree函数的具体用法?C++ xmlrpc_strfree怎么用?C++ xmlrpc_strfree使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlrpc_strfree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unescapeHostPathQuery
static void
unescapeHostPathQuery(const char *const host,
const char *const path,
const char *const query,
const char **const hostP,
const char **const pathP,
const char **const queryP,
const char **const errorP) {
/*----------------------------------------------------------------------------
Unescape each of the four components of a URI.
Each may be NULL, in which case we return NULL.
-----------------------------------------------------------------------------*/
if (host)
unescapeUri(host, hostP, errorP);
else
*hostP = NULL;
if (!*errorP) {
if (path)
unescapeUri(path, pathP, errorP);
else
*pathP = NULL;
if (!*errorP) {
if (query)
unescapeUri(query, queryP, errorP);
else
*queryP = NULL;
if (*errorP)
xmlrpc_strfree(*pathP);
} else {
if (*hostP)
xmlrpc_strfree(*hostP);
}
}
}
示例2: HandleTime
abyss_bool HandleTime(TSession *r)
{
char z[50];
time_t ltime;
TDate date;
const char * dateString;
const char * answer;
if (strcmp(r->uri,"/time")!=0)
return FALSE;
if (!RequestAuth(r,"Mot de passe","moez","hello"))
return TRUE;
time(<ime);
DateFromGMT(&date, ltime);
DateToString(&date, &dateString);
xmlrpc_asprintf(&answer, "The time is %s", dateString);
Answer(r, 200, answer);
xmlrpc_strfree(dateString);
xmlrpc_strfree(answer);
return TRUE;
}
示例3: sendHeader
static void
sendHeader(TConn * const connP,
TTable const fields) {
/*----------------------------------------------------------------------------
Send the HTTP response header whose fields are fields[].
Don't include the blank line that separates the header from the body.
fields[] contains syntactically valid HTTP header field names and values.
But to the extent that int contains undefined field names or semantically
invalid values, the header we send is invalid.
-----------------------------------------------------------------------------*/
unsigned int i;
for (i = 0; i < fields.size; ++i) {
TTableItem * const fieldP = &fields.item[i];
const char * const fieldValue = formatFieldValue(fieldP->value);
const char * line;
xmlrpc_asprintf(&line, "%s: %s\r\n", fieldP->name, fieldValue);
ConnWrite(connP, line, strlen(line));
xmlrpc_strfree(line);
xmlrpc_strfree(fieldValue);
}
}
示例4: RequestAuth
bool
RequestAuth(TSession * const sessionP,
const char * const credential,
const char * const user,
const char * const pass) {
/*----------------------------------------------------------------------------
Authenticate requester, in a very simplistic fashion.
If the request executing on session *sessionP specifies basic
authentication (via Authorization header) with username 'user', password
'pass', then return TRUE. Else, return FALSE and set up an authorization
failure response (HTTP response status 401) that says user must supply an
identity in the 'credential' domain.
When we return TRUE, we also set the username in the request info for the
session to 'user' so that a future SessionGetRequestInfo can get it.
-----------------------------------------------------------------------------*/
bool authorized;
char * authHdrPtr;
authHdrPtr = RequestHeaderValue(sessionP, "authorization");
if (authHdrPtr) {
const char * authType;
NextToken((const char **)&authHdrPtr);
GetTokenConst(&authHdrPtr, &authType);
authType = GetToken(&authHdrPtr);
if (authType) {
if (xmlrpc_strcaseeq(authType, "basic")) {
const char * userPass;
char userPassEncoded[80];
NextToken((const char **)&authHdrPtr);
xmlrpc_asprintf(&userPass, "%s:%s", user, pass);
xmlrpc_base64Encode(userPass, userPassEncoded);
xmlrpc_strfree(userPass);
if (xmlrpc_streq(authHdrPtr, userPassEncoded)) {
sessionP->requestInfo.user = strdup(user);
authorized = TRUE;
} else
authorized = FALSE;
} else
authorized = FALSE;
} else
authorized = FALSE;
} else
authorized = FALSE;
if (!authorized) {
const char * hdrValue;
xmlrpc_asprintf(&hdrValue, "Basic realm=\"%s\"", credential);
ResponseAddField(sessionP, "WWW-Authenticate", hdrValue);
xmlrpc_strfree(hdrValue);
ResponseStatus(sessionP, 401);
}
return authorized;
}
示例5: ServerFree
void
ServerFree(TServer * const serverP) {
struct _TServer * const srvP = serverP->srvP;
if (srvP->weCreatedListenSocket)
SocketDestroy(srvP->listenSocketP);
xmlrpc_strfree(srvP->name);
xmlrpc_strfree(srvP->filespath);
ListFree(&srvP->defaultfilenames);
terminateHandlers(&srvP->handlers);
ListFree(&srvP->handlers);
logClose(srvP);
if (srvP->logfilename)
xmlrpc_strfree(srvP->logfilename);
free(srvP);
}
示例6: handleDirectory
static void
handleDirectory(TSession *const sessionP,
const char *const dirName,
time_t const fileModTime,
MIMEType *const mimeTypeP) {
bool text;
bool ascending;
uint16_t sort; /* 1=by name, 2=by date */
const char *error;
determineSortType(sessionP->requestInfo.query,
&ascending, &sort, &text, &error);
if (error) {
ResponseStatus(sessionP, 400);
xmlrpc_strfree(error);
} else if (notRecentlyModified(sessionP, fileModTime)) {
ResponseStatus(sessionP, 304);
ResponseWriteStart(sessionP);
} else {
TPool pool;
bool succeeded;
succeeded = PoolCreate(&pool, 1024);
if (!succeeded)
ResponseStatus(sessionP, 500);
else {
TList list;
uint16_t responseStatus;
const char *error;
generateListing(&list, dirName, sessionP->requestInfo.uri,
&pool, &error, &responseStatus);
if (error) {
ResponseStatus(sessionP, responseStatus);
xmlrpc_strfree(error);
} else {
ResponseStatus(sessionP, 200);
ResponseContentType(sessionP,
text ? "text/plain" : "text/html");
addLastModifiedHeader(sessionP, fileModTime);
ResponseChunked(sessionP);
ResponseWriteStart(sessionP);
if (sessionP->requestInfo.method != m_head)
sendDirectoryDocument(&list, ascending, sort, text,
sessionP->requestInfo.uri, mimeTypeP,
sessionP);
HTTPWriteEndChunk(sessionP);
ListFree(&list);
}
PoolFree(&pool);
}
}
}
示例7: createServerBare
static void
createServerBare(xmlrpc_env * const envP,
const xmlrpc_server_abyss_parms * const parmsP,
unsigned int const parmSize,
TServer * const serverP,
TChanSwitch ** const chanSwitchPP) {
/*----------------------------------------------------------------------------
Create a bare server. It will need further setup before it is ready
to use.
-----------------------------------------------------------------------------*/
bool socketBound;
const struct sockaddr * sockAddrP;
socklen_t sockAddrLen;
unsigned int portNumber;
TOsSocket socketFd;
const char * logFileName;
extractServerCreateParms(envP, parmsP, parmSize,
&socketBound,
&sockAddrP, &sockAddrLen, &portNumber, &socketFd,
&logFileName);
if (!envP->fault_occurred) {
TChanSwitch * chanSwitchP;
if (socketBound)
createChanSwitchOsSocket(envP, socketFd, &chanSwitchP);
else {
if (sockAddrP)
createChanSwitchSockAddr(envP, sockAddrP, sockAddrLen,
&chanSwitchP);
else
createChanSwitchIpv4Port(envP, portNumber, &chanSwitchP);
}
if (!envP->fault_occurred) {
const char * error;
ServerCreateSwitch(serverP, chanSwitchP, &error);
if (error) {
xmlrpc_faultf(envP, "Abyss failed to create server. %s",
error);
xmlrpc_strfree(error);
} else {
*chanSwitchPP = chanSwitchP;
ServerSetName(serverP, "XmlRpcServer");
if (logFileName)
ServerSetLogFileName(serverP, logFileName);
}
if (envP->fault_occurred)
ChanSwitchDestroy(chanSwitchP);
}
if (logFileName)
xmlrpc_strfree(logFileName);
}
}
示例8: freeRequestInfo
static void
freeRequestInfo(TRequestInfo * const requestInfoP) {
if (requestInfoP->requestline)
xmlrpc_strfree(requestInfoP->requestline);
if (requestInfoP->user)
xmlrpc_strfree(requestInfoP->user);
}
示例9: unescapeUri
static void
unescapeUri(const char * const uriComponent,
const char ** const unescapedP,
const char ** const errorP) {
/*----------------------------------------------------------------------------
Unescape a component of a URI, e.g. the host name. That component may
have %HH encoding, especially of characters that are delimiters within
a URI like slash and colon.
Return the unescaped version as *unescapedP in newly malloced storage.
-----------------------------------------------------------------------------*/
char * buffer;
buffer = strdup(uriComponent);
if (!buffer)
xmlrpc_asprintf(errorP, "Couldn't get memory for URI unescape buffer");
else {
const char * src;
char * dst;
src = dst = buffer;
*errorP = NULL; /* initial value */
while (*src && !*errorP) {
switch (*src) {
case '%': {
char unescaped;
const char * error;
parsePerCentEscape(&src, &unescaped, &error);
if (error) {
xmlrpc_asprintf(errorP,
"Invalid %%HH escape sequence. %s",
error);
xmlrpc_strfree(error);
} else
*dst++ = unescaped;
} break;
default:
*dst++ = *src++;
break;
}
}
*dst = '\0';
if (*errorP)
xmlrpc_strfree(buffer);
else
*unescapedP = buffer;
}
}
示例10: freeRequestInfo
static void
freeRequestInfo(TRequestInfo * const requestInfoP) {
xmlrpc_strfreenull(requestInfoP->host);
xmlrpc_strfreenull(requestInfoP->user);
xmlrpc_strfree(requestInfoP->uri);
xmlrpc_strfree(requestInfoP->requestline);
}
示例11: releaseDecomposition
static void
releaseDecomposition(const struct decompTreeNode * const decompRootP,
bool const oldstyleMemMgmt) {
/*----------------------------------------------------------------------------
Assuming that Caller has decomposed something according to 'decompRootP',
release whatever resources the decomposed information occupies.
E.g. if it's an XML-RPC string, Caller would have allocated memory
for the C string that represents the decomposed value of XML-RPC string,
and we release that memory.
-----------------------------------------------------------------------------*/
switch (decompRootP->formatSpecChar) {
case 'i':
case 'b':
case 'd':
case 'n':
case 'I':
case 't':
case 'p':
/* Nothing was allocated; nothing to release */
break;
case '8':
xmlrpc_strfree(*decompRootP->store.Tdatetime8.valueP);
break;
case 's':
xmlrpc_strfree(*decompRootP->store.Tstring.valueP);
break;
case 'w':
free((void*)*decompRootP->store.TwideString.valueP);
break;
case '6':
free((void*)*decompRootP->store.TbitString.valueP);
break;
case 'V':
xmlrpc_DECREF(*decompRootP->store.Tvalue.valueP);
break;
case 'A':
xmlrpc_DECREF(*decompRootP->store.TarrayVal.valueP);
break;
case 'S':
xmlrpc_DECREF(*decompRootP->store.TstructVal.valueP);
break;
case '(':
releaseDecompArray(decompRootP->store.Tarray, oldstyleMemMgmt);
break;
case '{':
releaseDecompStruct(decompRootP->store.Tstruct, oldstyleMemMgmt);
break;
}
}
示例12: ServerInit2
void
ServerInit2(TServer * const serverP,
const char ** const errorP) {
/*----------------------------------------------------------------------------
Initialize a server to accept connections.
Do not confuse this with creating the server -- ServerCreate().
Not necessary or valid with a server that doesn't accept connections (i.e.
user supplies the channels (TCP connections)).
-----------------------------------------------------------------------------*/
struct _TServer * const srvP = serverP->srvP;
if (!srvP->serverAcceptsConnections)
xmlrpc_asprintf(errorP,
"ServerInit() is not valid on a server that doesn't "
"accept connections "
"(i.e. created with ServerCreateNoAccept)");
else {
*errorP = NULL; /* initial value */
if (!srvP->chanSwitchP) {
const char * error;
createChanSwitch(srvP, &error);
if (error) {
xmlrpc_asprintf(errorP, "Unable to create a channel switch "
"for the server. %s", error);
xmlrpc_strfree(error);
}
}
if (!*errorP) {
const char * error;
assert(srvP->chanSwitchP);
ChanSwitchListen(srvP->chanSwitchP, srvP->maxConnBacklog, &error);
if (error) {
xmlrpc_asprintf(errorP,
"Failed to listen on bound socket. %s",
error);
xmlrpc_strfree(error);
}
}
}
}
示例13: ServerCreateSocket
abyss_bool
ServerCreateSocket(TServer * const serverP,
const char * const name,
TOsSocket const socketFd,
const char * const filesPath,
const char * const logFileName) {
abyss_bool success;
TSocket * socketP;
createSocketFromOsSocket(socketFd, &socketP);
if (socketP) {
abyss_bool const noAcceptFalse = FALSE;
const char * error;
createServer(&serverP->srvP, noAcceptFalse, socketP, 0, &error);
if (error) {
TraceMsg(error);
success = FALSE;
xmlrpc_strfree(error);
} else {
success = TRUE;
setNamePathLog(serverP, name, filesPath, logFileName);
}
} else
success = FALSE;
return success;
}
示例14: SessionLog
abyss_bool
SessionLog(TSession * const sessionP) {
abyss_bool retval;
if (!sessionP->validRequest)
retval = FALSE;
else {
const char * const user = sessionP->request_info.user;
const char * logline;
char date[30];
DateToLogString(&sessionP->date, date);
xmlrpc_asprintf(&logline, "%d.%d.%d.%d - %s - [%s] \"%s\" %d %d",
IPB1(sessionP->conn->peerip),
IPB2(sessionP->conn->peerip),
IPB3(sessionP->conn->peerip),
IPB4(sessionP->conn->peerip),
user ? user : "",
date,
sessionP->request_info.requestline,
sessionP->status,
sessionP->conn->outbytes
);
if (logline) {
LogWrite(sessionP->conn->server, logline);
xmlrpc_strfree(logline);
}
retval = TRUE;
}
return retval;
}
示例15: curlMulti_addHandle
void
curlMulti_addHandle(xmlrpc_env * const envP,
curlMulti * const curlMultiP,
CURL * const curlSessionP) {
CURLMcode rc;
curlMultiP->lockP->acquire(curlMultiP->lockP);
rc = curl_multi_add_handle(curlMultiP->curlMultiP, curlSessionP);
curlMultiP->lockP->release(curlMultiP->lockP);
/* Old libcurl (e.g. 7.12) actually returns CURLM_CALL_MULTI_PERFORM
(by design) when it succeeds. Current libcurl returns CURLM_OK.
*/
if (rc != CURLM_OK && rc != CURLM_CALL_MULTI_PERFORM) {
const char * reason;
interpretCurlMultiError(&reason, rc);
xmlrpc_faultf(envP, "Could not add Curl session to the "
"curl multi manager. curl_multi_add_handle() "
"failed: %s", reason);
xmlrpc_strfree(reason);
}
}