mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Copying ede-bug-report from branches in trunk
This commit is contained in:
3
ede-bug-tools/ede-bug-report/xmlrpc-c/README
Normal file
3
ede-bug-tools/ede-bug-report/xmlrpc-c/README
Normal file
@ -0,0 +1,3 @@
|
||||
This directory contains customized xmlrpc-c (http://xmlrpc-c.sourceforge.net)
|
||||
library suitable only for EDE usage. Besides that, some things are removed because
|
||||
they are not used (abyss server and C++ wrapper).
|
@ -0,0 +1,311 @@
|
||||
/*=============================================================================
|
||||
curlMulti
|
||||
===============================================================================
|
||||
This is an extension to Curl's CURLM object. The extensions are:
|
||||
|
||||
1) It has a lock so multiple threads can use it simultaneously.
|
||||
|
||||
2) Its "select" file descriptor vectors are self-contained. CURLM
|
||||
requires the user to maintain them separately.
|
||||
=============================================================================*/
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#if !MSVCRT
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h>
|
||||
#include <curl/easy.h>
|
||||
#include <curl/multi.h>
|
||||
|
||||
#include "mallocvar.h"
|
||||
#include "xmlrpc-c/util.h"
|
||||
#include "xmlrpc-c/string_int.h"
|
||||
|
||||
#include "curlversion.h"
|
||||
#include "lock.h"
|
||||
#include "lock_pthread.h"
|
||||
|
||||
#include "curlmulti.h"
|
||||
|
||||
|
||||
|
||||
static void
|
||||
interpretCurlMultiError(const char ** const descriptionP,
|
||||
CURLMcode const code) {
|
||||
|
||||
#if HAVE_CURL_STRERROR
|
||||
*descriptionP = strdup(curl_multi_strerror(code));
|
||||
#else
|
||||
xmlrpc_asprintf(descriptionP, "Curl error code (CURLMcode) %d", code);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct curlMulti {
|
||||
CURLM * curlMultiP;
|
||||
lock * lockP;
|
||||
/* Hold this lock while accessing or using *curlMultiP. You're
|
||||
using the multi manager whenever you're calling a Curl
|
||||
library multi manager function.
|
||||
*/
|
||||
/* The following file descriptor sets are an integral part of the
|
||||
CURLM object; Our curlMulti_fdset() routine binds them to the
|
||||
CURLM object, and said object expects us to use them in a very
|
||||
specific way, including doing a select() on them. It is very,
|
||||
very messy.
|
||||
*/
|
||||
fd_set readFdSet;
|
||||
fd_set writeFdSet;
|
||||
fd_set exceptFdSet;
|
||||
};
|
||||
|
||||
|
||||
|
||||
curlMulti *
|
||||
curlMulti_create(void) {
|
||||
|
||||
curlMulti * retval;
|
||||
curlMulti * curlMultiP;
|
||||
|
||||
MALLOCVAR(curlMultiP);
|
||||
|
||||
if (curlMultiP == NULL)
|
||||
retval = NULL;
|
||||
else {
|
||||
curlMultiP->lockP = curlLock_create_pthread();
|
||||
|
||||
if (curlMultiP->lockP == NULL)
|
||||
retval = NULL;
|
||||
else {
|
||||
curlMultiP->curlMultiP = curl_multi_init();
|
||||
if (curlMultiP->curlMultiP == NULL)
|
||||
retval = NULL;
|
||||
else
|
||||
retval = curlMultiP;
|
||||
|
||||
if (retval == NULL)
|
||||
curlMultiP->lockP->destroy(curlMultiP->lockP);
|
||||
}
|
||||
if (retval == NULL)
|
||||
free(curlMultiP);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
curlMulti_destroy(curlMulti * const curlMultiP) {
|
||||
|
||||
curl_multi_cleanup(curlMultiP->curlMultiP);
|
||||
|
||||
curlMultiP->lockP->destroy(curlMultiP->lockP);
|
||||
|
||||
free(curlMultiP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
curlMulti_perform(xmlrpc_env * const envP,
|
||||
curlMulti * const curlMultiP,
|
||||
bool * const immediateWorkToDoP,
|
||||
int * const runningHandlesP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Do whatever work is ready to be done under the control of multi
|
||||
manager 'curlMultiP'. E.g. if HTTP response data has recently arrived
|
||||
from the network, process it as an HTTP response.
|
||||
|
||||
Iff this results in some work being finished from our point of view,
|
||||
return *immediateWorkToDoP. (Caller can query the multi manager for
|
||||
messages and find out what it is).
|
||||
|
||||
Return as *runningHandlesP the number of Curl easy handles under the
|
||||
multi manager's control that are still running -- yet to finish.
|
||||
-----------------------------------------------------------------------------*/
|
||||
CURLMcode rc;
|
||||
|
||||
curlMultiP->lockP->acquire(curlMultiP->lockP);
|
||||
|
||||
rc = curl_multi_perform(curlMultiP->curlMultiP, runningHandlesP);
|
||||
|
||||
curlMultiP->lockP->release(curlMultiP->lockP);
|
||||
|
||||
if (rc == CURLM_CALL_MULTI_PERFORM) {
|
||||
*immediateWorkToDoP = true;
|
||||
} else {
|
||||
*immediateWorkToDoP = false;
|
||||
|
||||
if (rc != CURLM_OK) {
|
||||
const char * reason;
|
||||
interpretCurlMultiError(&reason, rc);
|
||||
xmlrpc_faultf(envP, "Impossible failure of curl_multi_perform(): "
|
||||
"%s", reason);
|
||||
xmlrpc_strfree(reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
if (rc != CURLM_OK) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
curlMulti_removeHandle(curlMulti * const curlMultiP,
|
||||
CURL * const curlSessionP) {
|
||||
|
||||
curlMultiP->lockP->acquire(curlMultiP->lockP);
|
||||
|
||||
curl_multi_remove_handle(curlMultiP->curlMultiP, curlSessionP);
|
||||
|
||||
curlMultiP->lockP->release(curlMultiP->lockP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
curlMulti_getMessage(curlMulti * const curlMultiP,
|
||||
bool * const endOfMessagesP,
|
||||
CURLMsg * const curlMsgP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Get the next message from the queue of things the Curl multi manager
|
||||
wants to say to us.
|
||||
|
||||
Return the message as *curlMsgP.
|
||||
|
||||
Iff there are no messages in the queue, return *endOfMessagesP == true.
|
||||
-----------------------------------------------------------------------------*/
|
||||
int remainingMsgCount;
|
||||
CURLMsg * privateCurlMsgP;
|
||||
/* Note that this is a pointer into the multi manager's memory,
|
||||
so we have to use it under lock.
|
||||
*/
|
||||
|
||||
curlMultiP->lockP->acquire(curlMultiP->lockP);
|
||||
|
||||
privateCurlMsgP = curl_multi_info_read(curlMultiP->curlMultiP,
|
||||
&remainingMsgCount);
|
||||
|
||||
if (privateCurlMsgP == NULL)
|
||||
*endOfMessagesP = true;
|
||||
else {
|
||||
*endOfMessagesP = false;
|
||||
*curlMsgP = *privateCurlMsgP;
|
||||
}
|
||||
curlMultiP->lockP->release(curlMultiP->lockP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
curlMulti_fdset(xmlrpc_env * const envP,
|
||||
curlMulti * const curlMultiP,
|
||||
fd_set * const readFdSetP,
|
||||
fd_set * const writeFdSetP,
|
||||
fd_set * const exceptFdSetP,
|
||||
int * const maxFdP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Set the CURLM object's file descriptor sets to those in the
|
||||
curlMulti object, update those file descriptor sets with the
|
||||
current needs of the multi manager, and return the resulting values
|
||||
of the file descriptor sets.
|
||||
|
||||
This is a bizarre operation, but is necessary because of the nonmodular
|
||||
way in which the Curl multi interface works with respect to waiting
|
||||
for work with select().
|
||||
-----------------------------------------------------------------------------*/
|
||||
CURLMcode rc;
|
||||
|
||||
curlMultiP->lockP->acquire(curlMultiP->lockP);
|
||||
|
||||
/* curl_multi_fdset() doesn't _set_ the fdsets. It adds to existing
|
||||
ones (so you can easily do a select() on other fds and Curl
|
||||
fds at the same time). So we have to clear first:
|
||||
*/
|
||||
FD_ZERO(&curlMultiP->readFdSet);
|
||||
FD_ZERO(&curlMultiP->writeFdSet);
|
||||
FD_ZERO(&curlMultiP->exceptFdSet);
|
||||
|
||||
/* WARNING: curl_multi_fdset() doesn't just update the fdsets pointed
|
||||
to by its arguments. It makes the CURLM object remember those
|
||||
pointers and refer back to them later! In fact, curl_multi_perform
|
||||
expects its caller to have done a select() on those masks. No,
|
||||
really. The man page even admits it.
|
||||
|
||||
Inspection of the Libcurl code in March 2007 indicates that
|
||||
this isn't actually true -- curl_multi_fdset() updates your
|
||||
fdset and doesn't remember the pointer at all. I.e. it's just
|
||||
what you would expect. The man pages still says it's as
|
||||
described above. My guess is that Libcurl was fixed at some
|
||||
time and the man page not updated. In any case, we have to
|
||||
work with old Libcurl if at all possible, so we still maintain
|
||||
these fdsets as if they belong to the CURLM object.
|
||||
*/
|
||||
|
||||
rc = curl_multi_fdset(curlMultiP->curlMultiP,
|
||||
&curlMultiP->readFdSet,
|
||||
&curlMultiP->writeFdSet,
|
||||
&curlMultiP->exceptFdSet,
|
||||
maxFdP);
|
||||
|
||||
*readFdSetP = curlMultiP->readFdSet;
|
||||
*writeFdSetP = curlMultiP->writeFdSet;
|
||||
*exceptFdSetP = curlMultiP->exceptFdSet;
|
||||
|
||||
curlMultiP->lockP->release(curlMultiP->lockP);
|
||||
|
||||
if (rc != CURLM_OK) {
|
||||
const char * reason;
|
||||
interpretCurlMultiError(&reason, rc);
|
||||
xmlrpc_faultf(envP, "Impossible failure of curl_multi_fdset(): %s",
|
||||
reason);
|
||||
xmlrpc_strfree(reason);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
curlMulti_updateFdSet(curlMulti * const curlMultiP,
|
||||
fd_set const readFdSet,
|
||||
fd_set const writeFdSet,
|
||||
fd_set const exceptFdSet) {
|
||||
/*----------------------------------------------------------------------------
|
||||
curl_multi_perform() expects the file descriptor sets, which were bound
|
||||
to the CURLM object via a prior curlMulti_fdset(), to contain the results
|
||||
of a recent select(). This subroutine provides you a way to supply those.
|
||||
-----------------------------------------------------------------------------*/
|
||||
curlMultiP->readFdSet = readFdSet;
|
||||
curlMultiP->writeFdSet = writeFdSet;
|
||||
curlMultiP->exceptFdSet = exceptFdSet;
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,51 @@
|
||||
#ifndef CURLMULTI_H_INCLUDED
|
||||
#define CURLMULTI_H_INCLUDED
|
||||
|
||||
#include "bool.h"
|
||||
#include "xmlrpc-c/util.h"
|
||||
|
||||
#include "curltransaction.h"
|
||||
|
||||
typedef struct curlMulti curlMulti;
|
||||
|
||||
curlMulti *
|
||||
curlMulti_create(void);
|
||||
|
||||
void
|
||||
curlMulti_destroy(curlMulti * const curlMultiP);
|
||||
|
||||
void
|
||||
curlMulti_perform(xmlrpc_env * const envP,
|
||||
curlMulti * const curlMultiP,
|
||||
bool * const immediateWorkToDoP,
|
||||
int * const runningHandlesP);
|
||||
|
||||
void
|
||||
curlMulti_addHandle(xmlrpc_env * const envP,
|
||||
curlMulti * const curlMultiP,
|
||||
CURL * const curlSessionP);
|
||||
|
||||
void
|
||||
curlMulti_removeHandle(curlMulti * const curlMultiP,
|
||||
CURL * const curlSessionP);
|
||||
|
||||
void
|
||||
curlMulti_getMessage(curlMulti * const curlMultiP,
|
||||
bool * const endOfMessagesP,
|
||||
CURLMsg * const curlMsgP);
|
||||
|
||||
void
|
||||
curlMulti_fdset(xmlrpc_env * const envP,
|
||||
curlMulti * const curlMultiP,
|
||||
fd_set * const readFdSetP,
|
||||
fd_set * const writeFdSetP,
|
||||
fd_set * const exceptFdSetP,
|
||||
int * const maxFdP);
|
||||
|
||||
void
|
||||
curlMulti_updateFdSet(curlMulti * const curlMultiP,
|
||||
fd_set const readFdSet,
|
||||
fd_set const writeFdSet,
|
||||
fd_set const exceptFdSet);
|
||||
|
||||
#endif
|
@ -0,0 +1,621 @@
|
||||
/*=============================================================================
|
||||
curlTransaction
|
||||
=============================================================================*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "mallocvar.h"
|
||||
|
||||
#include "xmlrpc-c/util.h"
|
||||
#include "xmlrpc-c/string_int.h"
|
||||
#include "xmlrpc-c/client.h"
|
||||
#include "xmlrpc-c/client_int.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
#include "curlversion.h"
|
||||
|
||||
#include "curltransaction.h"
|
||||
|
||||
|
||||
struct curlTransaction {
|
||||
/* This is all stuff that really ought to be in a Curl object, but
|
||||
the Curl library is a little too simple for that. So we build
|
||||
a layer on top of Curl, and define this "transaction," as an
|
||||
object subordinate to a Curl "session." A Curl session has
|
||||
zero or one transactions in progress. The Curl session
|
||||
"private data" is a pointer to the CurlTransaction object for
|
||||
the current transaction.
|
||||
*/
|
||||
CURL * curlSessionP;
|
||||
/* Handle for the Curl session that hosts this transaction.
|
||||
Note that only one transaction at a time can use a particular
|
||||
Curl session, so this had better not be a session that some other
|
||||
transaction is using simultaneously.
|
||||
*/
|
||||
curlt_finishFn * finish;
|
||||
curlt_progressFn * progress;
|
||||
void * userContextP;
|
||||
/* Meaningful to our client; opaque to us */
|
||||
CURLcode result;
|
||||
/* Result of the transaction (succeeded, TCP connect failed, etc.).
|
||||
A properly executed HTTP transaction (request & response) counts
|
||||
as a successful transaction. When 'result' show success,
|
||||
curl_easy_get_info() tells you whether the transaction succeeded
|
||||
at the HTTP level.
|
||||
*/
|
||||
char curlError[CURL_ERROR_SIZE];
|
||||
/* Error message from Curl */
|
||||
struct curl_slist * headerList;
|
||||
/* The HTTP headers for the transaction */
|
||||
const char * serverUrl; /* malloc'ed - belongs to this object */
|
||||
};
|
||||
|
||||
|
||||
|
||||
static void
|
||||
addHeader(xmlrpc_env * const envP,
|
||||
struct curl_slist ** const headerListP,
|
||||
const char * const headerText) {
|
||||
|
||||
struct curl_slist * newHeaderList;
|
||||
newHeaderList = curl_slist_append(*headerListP, headerText);
|
||||
if (newHeaderList == NULL)
|
||||
xmlrpc_faultf(envP,
|
||||
"Could not add header '%s'. "
|
||||
"curl_slist_append() failed.", headerText);
|
||||
else
|
||||
*headerListP = newHeaderList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
addContentTypeHeader(xmlrpc_env * const envP,
|
||||
struct curl_slist ** const headerListP) {
|
||||
|
||||
addHeader(envP, headerListP, "Content-Type: text/xml");
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
addUserAgentHeader(xmlrpc_env * const envP,
|
||||
struct curl_slist ** const headerListP,
|
||||
const char * const userAgent) {
|
||||
|
||||
if (userAgent) {
|
||||
/* Note: Curl has a CURLOPT_USERAGENT option that does some of this
|
||||
work. We prefer to be totally in control, though, so we build
|
||||
the header explicitly.
|
||||
*/
|
||||
|
||||
curl_version_info_data * const curlInfoP =
|
||||
curl_version_info(CURLVERSION_NOW);
|
||||
char curlVersion[32];
|
||||
const char * userAgentHeader;
|
||||
|
||||
snprintf(curlVersion, sizeof(curlVersion), "%u.%u.%u",
|
||||
(curlInfoP->version_num >> 16) && 0xff,
|
||||
(curlInfoP->version_num >> 8) && 0xff,
|
||||
(curlInfoP->version_num >> 0) && 0xff
|
||||
);
|
||||
|
||||
xmlrpc_asprintf(&userAgentHeader,
|
||||
"User-Agent: %s Xmlrpc-c/%s Curl/%s",
|
||||
userAgent, XMLRPC_C_VERSION, curlVersion);
|
||||
|
||||
if (userAgentHeader == xmlrpc_strsol)
|
||||
xmlrpc_faultf(envP, "Couldn't allocate memory for "
|
||||
"User-Agent header");
|
||||
else {
|
||||
addHeader(envP, headerListP, userAgentHeader);
|
||||
|
||||
xmlrpc_strfree(userAgentHeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
addAuthorizationHeader(xmlrpc_env * const envP,
|
||||
struct curl_slist ** const headerListP,
|
||||
const char * const hdrValue) {
|
||||
|
||||
const char * authorizationHeader;
|
||||
|
||||
xmlrpc_asprintf(&authorizationHeader, "Authorization: %s", hdrValue);
|
||||
|
||||
if (authorizationHeader == xmlrpc_strsol)
|
||||
xmlrpc_faultf(envP, "Couldn't allocate memory for "
|
||||
"Authorization header");
|
||||
else {
|
||||
addHeader(envP, headerListP, authorizationHeader);
|
||||
|
||||
xmlrpc_strfree(authorizationHeader);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
createCurlHeaderList(xmlrpc_env * const envP,
|
||||
const char * const authHdrValue,
|
||||
const char * const userAgent,
|
||||
struct curl_slist ** const headerListP) {
|
||||
|
||||
struct curl_slist * headerList;
|
||||
|
||||
headerList = NULL; /* initial value - empty list */
|
||||
|
||||
addContentTypeHeader(envP, &headerList);
|
||||
if (!envP->fault_occurred) {
|
||||
addUserAgentHeader(envP, &headerList, userAgent);
|
||||
if (!envP->fault_occurred) {
|
||||
if (authHdrValue)
|
||||
addAuthorizationHeader(envP, &headerList, authHdrValue);
|
||||
}
|
||||
}
|
||||
if (envP->fault_occurred)
|
||||
curl_slist_free_all(headerList);
|
||||
else
|
||||
*headerListP = headerList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static size_t
|
||||
collect(void * const ptr,
|
||||
size_t const size,
|
||||
size_t const nmemb,
|
||||
FILE * const stream) {
|
||||
/*----------------------------------------------------------------------------
|
||||
This is a Curl output function. Curl calls this to deliver the
|
||||
HTTP response body to the Curl client. Curl thinks it's writing to
|
||||
a POSIX stream.
|
||||
-----------------------------------------------------------------------------*/
|
||||
xmlrpc_mem_block * const responseXmlP = (xmlrpc_mem_block *) stream;
|
||||
char * const buffer = ptr;
|
||||
size_t const length = nmemb * size;
|
||||
|
||||
size_t retval;
|
||||
xmlrpc_env env;
|
||||
|
||||
xmlrpc_env_init(&env);
|
||||
xmlrpc_mem_block_append(&env, responseXmlP, buffer, length);
|
||||
if (env.fault_occurred)
|
||||
retval = (size_t)-1;
|
||||
else
|
||||
/* Really? Shouldn't it be like fread() and return 'nmemb'? */
|
||||
retval = length;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
curlProgress(void * const contextP,
|
||||
double const dltotal ATTR_UNUSED,
|
||||
double const dlnow ATTR_UNUSED,
|
||||
double const ultotal ATTR_UNUSED,
|
||||
double const ulnow ATTR_UNUSED) {
|
||||
/*----------------------------------------------------------------------------
|
||||
This is a Curl "progress function." It's something various Curl
|
||||
functions call every so often, including whenever something gets
|
||||
interrupted by the process receiving, and catching, a signal.
|
||||
There are two purposes of a Curl progress function: 1) lets us log
|
||||
the progress of a long-running transaction such as a big download,
|
||||
e.g. by displaying a progress bar somewhere. In Xmlrpc-c, we don't
|
||||
implement this purpose. 2) allows us to tell the Curl function,
|
||||
via our return code, that calls it that we don't want to wait
|
||||
anymore for the operation to complete.
|
||||
|
||||
In Curl versions before March 2007, we get called once per second
|
||||
and signals have no effect. In current Curl, we usually get called
|
||||
immediately after a signal gets caught while Curl is waiting to
|
||||
receive a response from the server. But Curl doesn't properly
|
||||
synchronize with signals, so it may miss one and then we don't get
|
||||
called until the next scheduled one-per-second call.
|
||||
|
||||
All we do is tell Caller it's time to give up if the transport's
|
||||
client says it is via his "interrupt" flag.
|
||||
|
||||
This function is not as important as it once was. This module used
|
||||
to use curl_easy_perform(), which can be interrupted only via this
|
||||
progress function. But because of the above-mentioned failure of
|
||||
Curl to properly synchronize signals (and Bryan's failure to get
|
||||
Curl developers to accept code to fix it), we now use the Curl
|
||||
"multi" facility instead and do our own pselect(). But
|
||||
This function still normally gets called by curl_multi_perform(),
|
||||
which the transport tries to call even when the user has requested
|
||||
interruption, because we don't trust our ability to abort a running
|
||||
Curl transaction. curl_multi_perform() reliably winds up a Curl
|
||||
transaction when this function tells it to.
|
||||
-----------------------------------------------------------------------------*/
|
||||
curlTransaction * const curlTransactionP = contextP;
|
||||
|
||||
bool abort;
|
||||
|
||||
/* We require anyone setting us up as the Curl progress function to
|
||||
supply a progress function:
|
||||
*/
|
||||
assert(curlTransactionP);
|
||||
assert(curlTransactionP->progress);
|
||||
|
||||
curlTransactionP->progress(curlTransactionP->userContextP, &abort);
|
||||
|
||||
return abort;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
setupAuth(xmlrpc_env * const envP ATTR_UNUSED,
|
||||
CURL * const curlSessionP,
|
||||
const xmlrpc_server_info * const serverInfoP,
|
||||
const char ** const authHdrValueP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Set the options in the Curl session 'curlSessionP' to set up the HTTP
|
||||
authentication described by *serverInfoP.
|
||||
|
||||
But we have an odd special function for backward compatibility, because
|
||||
this code dates to a time when libcurl did not have the ability to
|
||||
handle authentication, but we provided such function nonetheless by
|
||||
building our own Authorization: header. But we did this only for
|
||||
HTTP basic authentication.
|
||||
|
||||
So the special function is this: if libcurl is too old to have
|
||||
authorization options and *serverInfoP allows basic authentication,
|
||||
return as *basicAuthHdrParamP an appropriate parameter for the
|
||||
Authorization: Basic: HTTP header. Otherwise, return
|
||||
*basicAuthHdrParamP == NULL.
|
||||
-----------------------------------------------------------------------------*/
|
||||
if (serverInfoP->allowedAuth.basic) {
|
||||
CURLcode rc;
|
||||
rc = curl_easy_setopt(curlSessionP, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
|
||||
if (rc == CURLE_OK)
|
||||
*authHdrValueP = NULL;
|
||||
else {
|
||||
*authHdrValueP = strdup(serverInfoP->basicAuthHdrValue);
|
||||
if (*authHdrValueP == NULL)
|
||||
xmlrpc_faultf(envP, "Unable to allocate memory for basic "
|
||||
"authentication header");
|
||||
}
|
||||
} else
|
||||
*authHdrValueP = NULL;
|
||||
|
||||
/* We don't worry if libcurl is too old for these other kinds of
|
||||
authentication; they're only defined as _allowed_
|
||||
authentication methods, for when client and server are capable
|
||||
of using it, and unlike with basic authentication, we have no
|
||||
historical commitment to consider an old libcurl as capable of
|
||||
doing these.
|
||||
*/
|
||||
|
||||
if (serverInfoP->userNamePw)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_USERPWD,
|
||||
serverInfoP->userNamePw);
|
||||
|
||||
if (serverInfoP->allowedAuth.digest)
|
||||
curl_easy_setopt(
|
||||
curlSessionP, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
|
||||
if (serverInfoP->allowedAuth.gssnegotiate)
|
||||
curl_easy_setopt(
|
||||
curlSessionP, CURLOPT_HTTPAUTH, CURLAUTH_GSSNEGOTIATE);
|
||||
if (serverInfoP->allowedAuth.ntlm)
|
||||
curl_easy_setopt(
|
||||
curlSessionP, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
setCurlTimeout(CURL * const curlSessionP ATTR_UNUSED,
|
||||
unsigned int const timeout ATTR_UNUSED) {
|
||||
|
||||
#if HAVE_CURL_NOSIGNAL
|
||||
unsigned int const timeoutMs = (timeout + 999)/1000;
|
||||
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_NOSIGNAL, 1);
|
||||
|
||||
assert((long)timeoutMs == (int)timeoutMs);
|
||||
/* Calling requirement */
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_TIMEOUT, (long)timeoutMs);
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
assertConstantsMatch(void) {
|
||||
/*----------------------------------------------------------------------------
|
||||
There are some constants that we define as part of the Xmlrpc-c
|
||||
interface that are identical to constants in the Curl interface to
|
||||
make curl option setting work. This function asserts such
|
||||
formally.
|
||||
-----------------------------------------------------------------------------*/
|
||||
assert(XMLRPC_SSLVERSION_DEFAULT == CURL_SSLVERSION_DEFAULT);
|
||||
assert(XMLRPC_SSLVERSION_TLSv1 == CURL_SSLVERSION_TLSv1);
|
||||
assert(XMLRPC_SSLVERSION_SSLv2 == CURL_SSLVERSION_SSLv2);
|
||||
assert(XMLRPC_SSLVERSION_SSLv3 == CURL_SSLVERSION_SSLv3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
setupCurlSession(xmlrpc_env * const envP,
|
||||
curlTransaction * const curlTransactionP,
|
||||
xmlrpc_mem_block * const callXmlP,
|
||||
xmlrpc_mem_block * const responseXmlP,
|
||||
const xmlrpc_server_info * const serverInfoP,
|
||||
const char * const userAgent,
|
||||
const struct curlSetup * const curlSetupP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Set up the Curl session for the transaction *curlTransactionP so that
|
||||
a subsequent curl_easy_perform() would perform said transaction.
|
||||
|
||||
The data curl_easy_perform() would send for that transaction would
|
||||
be the contents of *callXmlP; the data curl_easy_perform() gets back
|
||||
would go into *responseXmlP.
|
||||
|
||||
*serverInfoP tells what sort of authentication to set up. This is
|
||||
an embarassment, as the xmlrpc_server_info type is part of the
|
||||
Xmlrpc-c interface. Some day, we need to replace this with a type
|
||||
(probably identical) not tied to Xmlrpc-c.
|
||||
-----------------------------------------------------------------------------*/
|
||||
CURL * const curlSessionP = curlTransactionP->curlSessionP;
|
||||
|
||||
assertConstantsMatch();
|
||||
|
||||
/* A Curl session is serial -- it processes zero or one transaction
|
||||
at a time. We use the "private" attribute of the Curl session to
|
||||
indicate which transaction it is presently processing. This is
|
||||
important when the transaction finishes, because libcurl will just
|
||||
tell us that something finished on a particular session, not that
|
||||
a particular transaction finished.
|
||||
*/
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_PRIVATE, curlTransactionP);
|
||||
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_POST, 1);
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_URL, curlTransactionP->serverUrl);
|
||||
|
||||
XMLRPC_MEMBLOCK_APPEND(char, envP, callXmlP, "\0", 1);
|
||||
if (!envP->fault_occurred) {
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_POSTFIELDS,
|
||||
XMLRPC_MEMBLOCK_CONTENTS(char, callXmlP));
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_WRITEFUNCTION, collect);
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_FILE, responseXmlP);
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_HEADER, 0);
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_ERRORBUFFER,
|
||||
curlTransactionP->curlError);
|
||||
if (curlTransactionP->progress) {
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_NOPROGRESS, 0);
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_PROGRESSFUNCTION,
|
||||
curlProgress);
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_PROGRESSDATA,
|
||||
curlTransactionP);
|
||||
} else
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_NOPROGRESS, 1);
|
||||
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_SSL_VERIFYPEER,
|
||||
curlSetupP->sslVerifyPeer);
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_SSL_VERIFYHOST,
|
||||
curlSetupP->sslVerifyHost ? 2 : 0);
|
||||
|
||||
if (curlSetupP->networkInterface)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_INTERFACE,
|
||||
curlSetupP->networkInterface);
|
||||
if (curlSetupP->sslCert)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_SSLCERT,
|
||||
curlSetupP->sslCert);
|
||||
if (curlSetupP->sslCertType)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_SSLCERTTYPE,
|
||||
curlSetupP->sslCertType);
|
||||
if (curlSetupP->sslCertPasswd)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_SSLCERTPASSWD,
|
||||
curlSetupP->sslCertPasswd);
|
||||
if (curlSetupP->sslKey)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_SSLKEY,
|
||||
curlSetupP->sslKey);
|
||||
if (curlSetupP->sslKeyType)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_SSLKEYTYPE,
|
||||
curlSetupP->sslKeyType);
|
||||
if (curlSetupP->sslKeyPasswd)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_SSLKEYPASSWD,
|
||||
curlSetupP->sslKeyPasswd);
|
||||
if (curlSetupP->sslEngine)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_SSLENGINE,
|
||||
curlSetupP->sslEngine);
|
||||
if (curlSetupP->sslEngineDefault)
|
||||
/* 3rd argument seems to be required by some Curl */
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_SSLENGINE_DEFAULT, 1l);
|
||||
if (curlSetupP->sslVersion != XMLRPC_SSLVERSION_DEFAULT)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_SSLVERSION,
|
||||
curlSetupP->sslVersion);
|
||||
if (curlSetupP->caInfo)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_CAINFO,
|
||||
curlSetupP->caInfo);
|
||||
if (curlSetupP->caPath)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_CAPATH,
|
||||
curlSetupP->caPath);
|
||||
if (curlSetupP->randomFile)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_RANDOM_FILE,
|
||||
curlSetupP->randomFile);
|
||||
if (curlSetupP->egdSocket)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_EGDSOCKET,
|
||||
curlSetupP->egdSocket);
|
||||
if (curlSetupP->sslCipherList)
|
||||
curl_easy_setopt(curlSessionP, CURLOPT_SSL_CIPHER_LIST,
|
||||
curlSetupP->sslCipherList);
|
||||
|
||||
if (curlSetupP->timeout)
|
||||
setCurlTimeout(curlSessionP, curlSetupP->timeout);
|
||||
|
||||
{
|
||||
const char * authHdrValue;
|
||||
/* NULL means we don't have to construct an explicit
|
||||
Authorization: header. non-null means we have to
|
||||
construct one with this as its value.
|
||||
*/
|
||||
|
||||
setupAuth(envP, curlSessionP, serverInfoP, &authHdrValue);
|
||||
if (!envP->fault_occurred) {
|
||||
struct curl_slist * headerList;
|
||||
createCurlHeaderList(envP, authHdrValue, userAgent,
|
||||
&headerList);
|
||||
if (!envP->fault_occurred) {
|
||||
curl_easy_setopt(
|
||||
curlSessionP, CURLOPT_HTTPHEADER, headerList);
|
||||
curlTransactionP->headerList = headerList;
|
||||
}
|
||||
if (authHdrValue)
|
||||
xmlrpc_strfree(authHdrValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
curlTransaction_create(xmlrpc_env * const envP,
|
||||
CURL * const curlSessionP,
|
||||
const xmlrpc_server_info * const serverP,
|
||||
xmlrpc_mem_block * const callXmlP,
|
||||
xmlrpc_mem_block * const responseXmlP,
|
||||
const char * const userAgent,
|
||||
const struct curlSetup * const curlSetupStuffP,
|
||||
void * const userContextP,
|
||||
curlt_finishFn * const finish,
|
||||
curlt_progressFn * const progress,
|
||||
curlTransaction ** const curlTransactionPP) {
|
||||
|
||||
curlTransaction * curlTransactionP;
|
||||
|
||||
MALLOCVAR(curlTransactionP);
|
||||
if (curlTransactionP == NULL)
|
||||
xmlrpc_faultf(envP, "No memory to create Curl transaction.");
|
||||
else {
|
||||
curlTransactionP->finish = finish;
|
||||
curlTransactionP->curlSessionP = curlSessionP;
|
||||
curlTransactionP->userContextP = userContextP;
|
||||
curlTransactionP->progress = progress;
|
||||
|
||||
curlTransactionP->serverUrl = strdup(serverP->serverUrl);
|
||||
if (curlTransactionP->serverUrl == NULL)
|
||||
xmlrpc_faultf(envP, "Out of memory to store server URL.");
|
||||
else {
|
||||
setupCurlSession(envP, curlTransactionP,
|
||||
callXmlP, responseXmlP,
|
||||
serverP, userAgent,
|
||||
curlSetupStuffP);
|
||||
|
||||
if (envP->fault_occurred)
|
||||
xmlrpc_strfree(curlTransactionP->serverUrl);
|
||||
}
|
||||
if (envP->fault_occurred)
|
||||
free(curlTransactionP);
|
||||
}
|
||||
*curlTransactionPP = curlTransactionP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
curlTransaction_destroy(curlTransaction * const curlTransactionP) {
|
||||
|
||||
curl_slist_free_all(curlTransactionP->headerList);
|
||||
xmlrpc_strfree(curlTransactionP->serverUrl);
|
||||
|
||||
free(curlTransactionP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
interpretCurlEasyError(const char ** const descriptionP,
|
||||
CURLcode const code) {
|
||||
|
||||
#if HAVE_CURL_STRERROR
|
||||
*descriptionP = strdup(curl_easy_strerror(code));
|
||||
#else
|
||||
xmlrpc_asprintf(descriptionP, "Curl error code (CURLcode) %d", code);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
curlTransaction_getError(curlTransaction * const curlTransactionP,
|
||||
xmlrpc_env * const envP) {
|
||||
|
||||
if (curlTransactionP->result != CURLE_OK) {
|
||||
/* We've seen Curl just return a null string for an explanation
|
||||
(e.g. when TCP connect() fails because IP address doesn't exist).
|
||||
*/
|
||||
const char * explanation;
|
||||
|
||||
if (strlen(curlTransactionP->curlError) == 0)
|
||||
interpretCurlEasyError(&explanation, curlTransactionP->result);
|
||||
else
|
||||
xmlrpc_asprintf(&explanation, "%s", curlTransactionP->curlError);
|
||||
|
||||
xmlrpc_env_set_fault_formatted(
|
||||
envP, XMLRPC_NETWORK_ERROR, "libcurl failed to execute the "
|
||||
"HTTP POST transaction. %s", explanation);
|
||||
|
||||
xmlrpc_strfree(explanation);
|
||||
} else {
|
||||
CURLcode res;
|
||||
long http_result;
|
||||
|
||||
res = curl_easy_getinfo(curlTransactionP->curlSessionP,
|
||||
CURLINFO_HTTP_CODE, &http_result);
|
||||
|
||||
if (res != CURLE_OK)
|
||||
xmlrpc_env_set_fault_formatted(
|
||||
envP, XMLRPC_INTERNAL_ERROR,
|
||||
"Curl performed the HTTP POST request, but was "
|
||||
"unable to say what the HTTP result code was. "
|
||||
"curl_easy_getinfo(CURLINFO_HTTP_CODE) says: %s",
|
||||
curlTransactionP->curlError);
|
||||
else {
|
||||
if (http_result != 200)
|
||||
xmlrpc_env_set_fault_formatted(
|
||||
envP, XMLRPC_NETWORK_ERROR,
|
||||
"HTTP response code is %ld, not 200",
|
||||
http_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
curlTransaction_finish(xmlrpc_env * const envP,
|
||||
curlTransaction * const curlTransactionP,
|
||||
CURLcode const result) {
|
||||
|
||||
curlTransactionP->result = result;
|
||||
|
||||
if (curlTransactionP->finish)
|
||||
curlTransactionP->finish(envP, curlTransactionP->userContextP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
CURL *
|
||||
curlTransaction_curlSession(curlTransaction * const curlTransactionP) {
|
||||
|
||||
return curlTransactionP->curlSessionP;
|
||||
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
#ifndef CURLTRANSACTION_H_INCLUDED
|
||||
#define CURLTRANSACTION_H_INCLUDED
|
||||
|
||||
#include "bool.h"
|
||||
#include "xmlrpc-c/util.h"
|
||||
#include "xmlrpc-c/client.h"
|
||||
#include <curl/curl.h>
|
||||
|
||||
typedef struct curlTransaction curlTransaction;
|
||||
|
||||
typedef void curlt_finishFn(xmlrpc_env * const, void * const);
|
||||
typedef void curlt_progressFn(void * const, bool * const);
|
||||
|
||||
struct curlSetup {
|
||||
|
||||
/* This is all client transport properties that are implemented as
|
||||
simple Curl session properties (i.e. the transport basically just
|
||||
passes them through to Curl without looking at them).
|
||||
|
||||
People occasionally want to replace all this with something where
|
||||
the Xmlrpc-c user simply does the curl_easy_setopt() call and this
|
||||
code need not know about all these options. Unfortunately, that's
|
||||
a significant modularity violation. Either the Xmlrpc-c user
|
||||
controls the Curl object or he doesn't. If he does, then he
|
||||
shouldn't use libxmlrpc_client -- he should just copy some of this
|
||||
code into his own program. If he doesn't, then he should never see
|
||||
the Curl library.
|
||||
|
||||
Speaking of modularity: the only reason this is a separate struct
|
||||
is to make the code easier to manage. Ideally, the fact that these
|
||||
particular properties of the transport are implemented by simple
|
||||
Curl session setup would be known only at the lowest level code
|
||||
that does that setup.
|
||||
*/
|
||||
|
||||
const char * networkInterface;
|
||||
/* This identifies the network interface on the local side to
|
||||
use for the session. It is an ASCIIZ string in the form
|
||||
that the Curl recognizes for setting its CURLOPT_INTERFACE
|
||||
option (also the --interface option of the Curl program).
|
||||
E.g. "9.1.72.189" or "giraffe-data.com" or "eth0".
|
||||
|
||||
It isn't necessarily valid, but it does have a terminating NUL.
|
||||
|
||||
NULL means we have no preference.
|
||||
*/
|
||||
bool sslVerifyPeer;
|
||||
/* In an SSL connection, we should authenticate the server's SSL
|
||||
certificate -- refuse to talk to him if it isn't authentic.
|
||||
This is equivalent to Curl's CURLOPT_SSL_VERIFY_PEER option.
|
||||
*/
|
||||
bool sslVerifyHost;
|
||||
/* In an SSL connection, we should verify that the server's
|
||||
certificate (independently of whether the certificate is
|
||||
authentic) indicates the host name that is in the URL we
|
||||
are using for the server.
|
||||
*/
|
||||
|
||||
const char * sslCert;
|
||||
const char * sslCertType;
|
||||
const char * sslCertPasswd;
|
||||
const char * sslKey;
|
||||
const char * sslKeyType;
|
||||
const char * sslKeyPasswd;
|
||||
const char * sslEngine;
|
||||
bool sslEngineDefault;
|
||||
unsigned int sslVersion;
|
||||
const char * caInfo;
|
||||
const char * caPath;
|
||||
const char * randomFile;
|
||||
const char * egdSocket;
|
||||
const char * sslCipherList;
|
||||
unsigned int timeout;
|
||||
/* 0 = no Curl timeout. This is in milliseconds. */
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
curlTransaction_create(xmlrpc_env * const envP,
|
||||
CURL * const curlSessionP,
|
||||
const xmlrpc_server_info * const serverP,
|
||||
xmlrpc_mem_block * const callXmlP,
|
||||
xmlrpc_mem_block * const responseXmlP,
|
||||
const char * const userAgent,
|
||||
const struct curlSetup * const curlSetupStuffP,
|
||||
void * const userContextP,
|
||||
curlt_finishFn * const finish,
|
||||
curlt_progressFn * const progress,
|
||||
curlTransaction ** const curlTransactionPP);
|
||||
|
||||
void
|
||||
curlTransaction_destroy(curlTransaction * const curlTransactionP);
|
||||
|
||||
void
|
||||
curlTransaction_finish(xmlrpc_env * const envP,
|
||||
curlTransaction * const curlTransactionP,
|
||||
CURLcode const result);
|
||||
|
||||
void
|
||||
curlTransaction_getError(curlTransaction * const curlTransactionP,
|
||||
xmlrpc_env * const envP);
|
||||
|
||||
CURL *
|
||||
curlTransaction_curlSession(curlTransaction * const curlTransactionP);
|
||||
|
||||
#endif
|
@ -0,0 +1,20 @@
|
||||
#ifndef CURLVERSION_H_INCLUDED
|
||||
#define CURLVERSION_H_INCLUDED
|
||||
|
||||
#define CMAJOR LIBCURL_VERSION_MAJOR
|
||||
#define CMINOR LIBCURL_VERSION_MINOR
|
||||
#if CMAJOR > 7 || (CMAJOR == 7 && CMINOR >= 10)
|
||||
#define HAVE_CURL_NOSIGNAL 1
|
||||
#else
|
||||
#define HAVE_CURL_NOSIGNAL 0
|
||||
#endif
|
||||
#if CMAJOR > 7 || (CMAJOR == 7 && CMINOR >= 12)
|
||||
#define HAVE_CURL_STRERROR 1
|
||||
#else
|
||||
#define HAVE_CURL_STRERROR 0
|
||||
#endif
|
||||
|
||||
#undef CMAJOR
|
||||
#undef CMINOR
|
||||
|
||||
#endif
|
@ -0,0 +1,24 @@
|
||||
#ifndef CURL_LOCK_H_INCLUDED
|
||||
#define CURL_LOCK_H_INCLUDED
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
typedef struct lock lock;
|
||||
|
||||
typedef void lockAcquireFn(lock *);
|
||||
typedef void lockReleaseFn(lock *);
|
||||
typedef void lockDestroyFn(lock *);
|
||||
|
||||
struct lock {
|
||||
/* To finish the job of making an abstract lock class that can use locks
|
||||
other than pthread mutexes, we need to replace 'theLock' with a
|
||||
"void * implementationP" and make curlLock_create_pthread() malloc
|
||||
the mutex.
|
||||
*/
|
||||
pthread_mutex_t theLock;
|
||||
lockAcquireFn * acquire;
|
||||
lockReleaseFn * release;
|
||||
lockDestroyFn * destroy;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,49 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "mallocvar.h"
|
||||
#include "pthreadx.h"
|
||||
|
||||
#include "lock.h"
|
||||
|
||||
#include "lock_pthread.h"
|
||||
|
||||
static lockAcquireFn acquire;
|
||||
|
||||
static void
|
||||
acquire(struct lock * const lockP) {
|
||||
pthread_mutex_lock(&lockP->theLock);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static lockReleaseFn release;
|
||||
|
||||
static void
|
||||
release(struct lock * const lockP) {
|
||||
pthread_mutex_unlock(&lockP->theLock);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static lockDestroyFn destroy;
|
||||
|
||||
static void
|
||||
destroy(struct lock * const lockP) {
|
||||
pthread_mutex_destroy(&lockP->theLock);
|
||||
free(lockP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct lock *
|
||||
curlLock_create_pthread(void) {
|
||||
struct lock * lockP;
|
||||
MALLOCVAR(lockP);
|
||||
if (lockP) {
|
||||
pthread_mutex_init(&lockP->theLock, NULL);
|
||||
lockP->acquire = &acquire;
|
||||
lockP->release = &release;
|
||||
lockP->destroy = &destroy;
|
||||
}
|
||||
return lockP;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
#ifndef CURL_LOCK_PTHREAD_H_INCLUDED
|
||||
#define CURL_LOCK_PTHREAD_H_INCLUDED
|
||||
|
||||
#include "lock.h"
|
||||
|
||||
lock *
|
||||
curlLock_create_pthread(void);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
93
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/expat.html
Normal file
93
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/expat.html
Normal file
@ -0,0 +1,93 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
|
||||
<HTML>
|
||||
|
||||
<TITLE>expat</TITLE>
|
||||
|
||||
<BODY>
|
||||
|
||||
<H1>expat - XML Parser Toolkit</H1>
|
||||
|
||||
<p>This is outdated stuff from the independently developed Expat which
|
||||
was forked in 2001 to make the Xmlrpc-c embedded version.
|
||||
|
||||
<H3>Version 1.2</H3>
|
||||
|
||||
<P>Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center
|
||||
Ltd. Expat is freely available with source under a very liberal <a
|
||||
href="copying.txt">license</a> (the MIT license).</P>
|
||||
|
||||
<P>This is a production version of expat. Relative to expat 1.1, it
|
||||
adds support for parsing external DTDs and parameter entities.
|
||||
Compiling with -DXML_DTD enables this support. There's a new
|
||||
<CODE>-p</CODE> option for xmlwf which will cause it to process
|
||||
external DTDs and parameter entities; this implies the <CODE>-x</CODE>
|
||||
option. See the comment above <CODE>XML_SetParamEntityParsing</CODE>
|
||||
in <CODE>xmlparse.h</CODE> for the API addition that enables this.</P>
|
||||
|
||||
<p>For Xmlrpc-c, we find no reason to exclude this function from the
|
||||
library, and ifdefs make code harder to maintain, so we include the
|
||||
function unconditionally. (i.e. -DXML_DTD does nothing).
|
||||
|
||||
<P>Expat is an <A
|
||||
HREF="http://www.w3.org/TR/1998/REC-xml-19980210">XML 1.0</A> parser
|
||||
written in C. It aims to be fully conforming. It is currently not a
|
||||
validating XML processor. The current production version of expat 1.X
|
||||
can be downloaded from <A href =
|
||||
"ftp://ftp.jclark.com/pub/xml/expat.zip"
|
||||
>ftp://ftp.jclark.com/pub/xml/expat.zip</A>.</P>
|
||||
|
||||
<P>Development of expat 2.0 is being handled by a team led by Clark
|
||||
Cooper, hosted by <A
|
||||
href="http://www.sourceforge.net">sourceforge.net</A>. See <A href=
|
||||
"http://expat.sourceforge.net">http://expat.sourceforge.net</A> for
|
||||
the latest on expat 2.0.</P>
|
||||
|
||||
<P>The directory <SAMP>xmltok</SAMP> contains a low-level library for
|
||||
tokenizing XML. The interface is documented in
|
||||
<SAMP>xmltok/xmltok.h</SAMP>.</P>
|
||||
|
||||
<P>The directory <SAMP>xmlparse</SAMP> contains an XML parser library
|
||||
which is built on top of the <SAMP>xmltok</SAMP> library. The
|
||||
interface is documented in <SAMP>xmlparse/xmlparse.h</SAMP>. The
|
||||
directory <SAMP>sample</SAMP> contains a simple example program using
|
||||
this interface; <SAMP>sample/build.bat</SAMP> is a batch file to build
|
||||
the example using Visual C++.</P>
|
||||
|
||||
<P>The directory <SAMP>xmlwf</SAMP> contains the <SAMP>xmlwf</SAMP>
|
||||
application, which uses the <SAMP>xmlparse</SAMP> library. The
|
||||
arguments to <SAMP>xmlwf</SAMP> are one or more files which are each
|
||||
to be checked for well-formedness. An option <SAMP>-d
|
||||
<VAR>dir</VAR></SAMP> can be specified; for each well-formed input
|
||||
file the corresponding <A
|
||||
href="http://www.jclark.com/xml/canonxml.html">canonical XML</A> will
|
||||
be written to <SAMP>dir/<VAR>f</VAR></SAMP>, where
|
||||
<SAMP><VAR>f</VAR></SAMP> is the filename (without any path) of the
|
||||
input file. A <CODE>-x</CODE> option will cause references to
|
||||
external general entities to be processed. A <CODE>-s</CODE> option
|
||||
will make documents that are not standalone cause an error (a document
|
||||
is considered standalone if either it is intrinsically standalone
|
||||
because it has no external subset and no references to parameter
|
||||
entities in the internal subset or it is declared as standalone in the
|
||||
XML declaration).</P>
|
||||
|
||||
<P>The <SAMP>bin</SAMP> directory contains Win32 executables. The
|
||||
<SAMP>lib</SAMP> directory contains Win32 import libraries.</P>
|
||||
|
||||
<P>Answers to some frequently asked questions about expat can be found
|
||||
in the <A
|
||||
HREF="http://www.jclark.com/xml/expatfaq.html">expat
|
||||
FAQ</A>.</P>
|
||||
|
||||
<P></P>
|
||||
|
||||
<ADDRESS>
|
||||
|
||||
<A HREF="mailto:jjc@jclark.com">James Clark</A>
|
||||
|
||||
</ADDRESS>
|
||||
|
||||
</BODY>
|
||||
|
||||
</HTML>
|
4658
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmlparse/xmlparse.c
Normal file
4658
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmlparse/xmlparse.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,556 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef XMLPARSE_H_INCLUDED
|
||||
#define XMLPARSE_H_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef XMLPARSEAPI
|
||||
#define XMLPARSEAPI /* as nothing */
|
||||
#endif
|
||||
|
||||
typedef void *XML_Parser;
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
|
||||
/* XML_UNICODE_WCHAR_T will work only if sizeof(wchar_t) == 2 and wchar_t
|
||||
uses Unicode.
|
||||
*/
|
||||
/* Information is UTF-16 encoded as wchar_ts */
|
||||
|
||||
#ifndef XML_UNICODE
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
typedef wchar_t XML_Char;
|
||||
typedef wchar_t XML_LChar;
|
||||
|
||||
#else /* not XML_UNICODE_WCHAR_T */
|
||||
|
||||
#ifdef XML_UNICODE
|
||||
|
||||
/* Information is UTF-16 encoded as unsigned shorts */
|
||||
typedef unsigned short XML_Char;
|
||||
typedef char XML_LChar;
|
||||
|
||||
#else /* not XML_UNICODE */
|
||||
|
||||
/* Information is UTF-8 encoded. */
|
||||
typedef char XML_Char;
|
||||
typedef char XML_LChar;
|
||||
|
||||
#endif /* not XML_UNICODE */
|
||||
|
||||
#endif /* not XML_UNICODE_WCHAR_T */
|
||||
|
||||
|
||||
/* Constructs a new parser; encoding is the encoding specified by the external
|
||||
protocol or null if there is none specified. */
|
||||
|
||||
XML_Parser XMLPARSEAPI
|
||||
xmlrpc_XML_ParserCreate(const XML_Char * const encoding);
|
||||
|
||||
/* Constructs a new parser and namespace processor. Element type names
|
||||
and attribute names that belong to a namespace will be expanded;
|
||||
unprefixed attribute names are never expanded; unprefixed element type
|
||||
names are expanded only if there is a default namespace. The expanded
|
||||
name is the concatenation of the namespace URI, the namespace separator character,
|
||||
and the local part of the name. If the namespace separator is '\0' then
|
||||
the namespace URI and the local part will be concatenated without any
|
||||
separator. When a namespace is not declared, the name and prefix will be
|
||||
passed through without expansion. */
|
||||
|
||||
XML_Parser XMLPARSEAPI
|
||||
xmlrpc_XML_ParserCreateNS(const XML_Char * const encoding,
|
||||
XML_Char const namespaceSeparator);
|
||||
|
||||
|
||||
/* atts is array of name/value pairs, terminated by 0;
|
||||
names and values are 0 terminated. */
|
||||
|
||||
typedef void (*XML_StartElementHandler)(void *userData,
|
||||
const XML_Char *name,
|
||||
const XML_Char **atts);
|
||||
|
||||
typedef void (*XML_EndElementHandler)(void *userData,
|
||||
const XML_Char *name);
|
||||
|
||||
/* s is not 0 terminated. */
|
||||
typedef void (*XML_CharacterDataHandler)(void *userData,
|
||||
const XML_Char *s,
|
||||
int len);
|
||||
|
||||
/* target and data are 0 terminated */
|
||||
typedef void (*XML_ProcessingInstructionHandler)(void *userData,
|
||||
const XML_Char *target,
|
||||
const XML_Char *data);
|
||||
|
||||
/* data is 0 terminated */
|
||||
typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);
|
||||
|
||||
typedef void (*XML_StartCdataSectionHandler)(void *userData);
|
||||
typedef void (*XML_EndCdataSectionHandler)(void *userData);
|
||||
|
||||
/* This is called for any characters in the XML document for
|
||||
which there is no applicable handler. This includes both
|
||||
characters that are part of markup which is of a kind that is
|
||||
not reported (comments, markup declarations), or characters
|
||||
that are part of a construct which could be reported but
|
||||
for which no handler has been supplied. The characters are passed
|
||||
exactly as they were in the XML document except that
|
||||
they will be encoded in UTF-8. Line boundaries are not normalized.
|
||||
Note that a byte order mark character is not passed to the default handler.
|
||||
There are no guarantees about how characters are divided between calls
|
||||
to the default handler: for example, a comment might be split between
|
||||
multiple calls. */
|
||||
|
||||
typedef void (*XML_DefaultHandler)(void *userData,
|
||||
const XML_Char *s,
|
||||
int len);
|
||||
|
||||
/* This is called for the start of the DOCTYPE declaration when the
|
||||
name of the DOCTYPE is encountered. */
|
||||
typedef void (*XML_StartDoctypeDeclHandler)(void *userData,
|
||||
const XML_Char *doctypeName);
|
||||
|
||||
/* This is called for the start of the DOCTYPE declaration when the
|
||||
closing > is encountered, but after processing any external subset. */
|
||||
typedef void (*XML_EndDoctypeDeclHandler)(void *userData);
|
||||
|
||||
/* This is called for a declaration of an unparsed (NDATA)
|
||||
entity. The base argument is whatever was set by XML_SetBase.
|
||||
The entityName, systemId and notationName arguments will never be null.
|
||||
The other arguments may be. */
|
||||
|
||||
typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId,
|
||||
const XML_Char *notationName);
|
||||
|
||||
/* This is called for a declaration of notation.
|
||||
The base argument is whatever was set by XML_SetBase.
|
||||
The notationName will never be null. The other arguments can be. */
|
||||
|
||||
typedef void (*XML_NotationDeclHandler)(void *userData,
|
||||
const XML_Char *notationName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId);
|
||||
|
||||
typedef void (*XML_ExternalParsedEntityDeclHandler)(void *userData,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId);
|
||||
|
||||
typedef void (*XML_InternalParsedEntityDeclHandler)(void *userData,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *replacementText,
|
||||
int replacementTextLength);
|
||||
|
||||
/* When namespace processing is enabled, these are called once for
|
||||
each namespace declaration. The call to the start and end element
|
||||
handlers occur between the calls to the start and end namespace
|
||||
declaration handlers. For an xmlns attribute, prefix will be null.
|
||||
For an xmlns="" attribute, uri will be null. */
|
||||
|
||||
typedef void (*XML_StartNamespaceDeclHandler)(void *userData,
|
||||
const XML_Char *prefix,
|
||||
const XML_Char *uri);
|
||||
|
||||
typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
|
||||
const XML_Char *prefix);
|
||||
|
||||
/* This is called if the document is not standalone (it has an
|
||||
external subset or a reference to a parameter entity, but does not
|
||||
have standalone="yes"). If this handler returns 0, then processing
|
||||
will not continue, and the parser will return a
|
||||
XML_ERROR_NOT_STANDALONE error. */
|
||||
|
||||
typedef int (*XML_NotStandaloneHandler)(void *userData);
|
||||
|
||||
/* This is called for a reference to an external parsed general entity.
|
||||
The referenced entity is not automatically parsed.
|
||||
The application can parse it immediately or later using
|
||||
XML_ExternalEntityParserCreate.
|
||||
The parser argument is the parser parsing the entity containing the reference;
|
||||
it can be passed as the parser argument to XML_ExternalEntityParserCreate.
|
||||
The systemId argument is the system identifier as specified in the entity declaration;
|
||||
it will not be null.
|
||||
The base argument is the system identifier that should be used as the base for
|
||||
resolving systemId if systemId was relative; this is set by XML_SetBase;
|
||||
it may be null.
|
||||
The publicId argument is the public identifier as specified in the entity declaration,
|
||||
or null if none was specified; the whitespace in the public identifier
|
||||
will have been normalized as required by the XML spec.
|
||||
The context argument specifies the parsing context in the format
|
||||
expected by the context argument to
|
||||
XML_ExternalEntityParserCreate; context is valid only until the handler
|
||||
returns, so if the referenced entity is to be parsed later, it must be copied.
|
||||
The handler should return 0 if processing should not continue because of
|
||||
a fatal error in the handling of the external entity.
|
||||
In this case the calling parser will return an XML_ERROR_EXTERNAL_ENTITY_HANDLING
|
||||
error.
|
||||
Note that unlike other handlers the first argument is the parser, not userData. */
|
||||
|
||||
typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
|
||||
const XML_Char *context,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId);
|
||||
|
||||
/* This structure is filled in by the XML_UnknownEncodingHandler
|
||||
to provide information to the parser about encodings that are unknown
|
||||
to the parser.
|
||||
The map[b] member gives information about byte sequences
|
||||
whose first byte is b.
|
||||
If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalar value c.
|
||||
If map[b] is -1, then the byte sequence is malformed.
|
||||
If map[b] is -n, where n >= 2, then b is the first byte of an n-byte
|
||||
sequence that encodes a single Unicode scalar value.
|
||||
The data member will be passed as the first argument to the convert function.
|
||||
The convert function is used to convert multibyte sequences;
|
||||
s will point to a n-byte sequence where map[(unsigned char)*s] == -n.
|
||||
The convert function must return the Unicode scalar value
|
||||
represented by this byte sequence or -1 if the byte sequence is malformed.
|
||||
The convert function may be null if the encoding is a single-byte encoding,
|
||||
that is if map[b] >= -1 for all bytes b.
|
||||
When the parser is finished with the encoding, then if release is not null,
|
||||
it will call release passing it the data member;
|
||||
once release has been called, the convert function will not be called again.
|
||||
|
||||
Expat places certain restrictions on the encodings that are supported
|
||||
using this mechanism.
|
||||
|
||||
1. Every ASCII character that can appear in a well-formed XML document,
|
||||
other than the characters
|
||||
|
||||
$@\^`{}~
|
||||
|
||||
must be represented by a single byte, and that byte must be the
|
||||
same byte that represents that character in ASCII.
|
||||
|
||||
2. No character may require more than 4 bytes to encode.
|
||||
|
||||
3. All characters encoded must have Unicode scalar values <= 0xFFFF,
|
||||
(ie characters that would be encoded by surrogates in UTF-16
|
||||
are not allowed). Note that this restriction doesn't apply to
|
||||
the built-in support for UTF-8 and UTF-16.
|
||||
|
||||
4. No Unicode character may be encoded by more than one distinct sequence
|
||||
of bytes. */
|
||||
|
||||
typedef struct {
|
||||
int map[256];
|
||||
void *data;
|
||||
int (*convert)(void *data, const char *s);
|
||||
void (*release)(void *data);
|
||||
} XML_Encoding;
|
||||
|
||||
/* This is called for an encoding that is unknown to the parser.
|
||||
The encodingHandlerData argument is that which was passed as the
|
||||
second argument to XML_SetUnknownEncodingHandler.
|
||||
The name argument gives the name of the encoding as specified in
|
||||
the encoding declaration.
|
||||
If the callback can provide information about the encoding,
|
||||
it must fill in the XML_Encoding structure, and return 1.
|
||||
Otherwise it must return 0.
|
||||
If info does not describe a suitable encoding,
|
||||
then the parser will return an XML_UNKNOWN_ENCODING error. */
|
||||
|
||||
typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
|
||||
const XML_Char *name,
|
||||
XML_Encoding *info);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetElementHandler(XML_Parser parser,
|
||||
XML_StartElementHandler start,
|
||||
XML_EndElementHandler end);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetCharacterDataHandler(XML_Parser parser,
|
||||
XML_CharacterDataHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetProcessingInstructionHandler(
|
||||
XML_Parser parser,
|
||||
XML_ProcessingInstructionHandler handler);
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetCommentHandler(XML_Parser parser,
|
||||
XML_CommentHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetCdataSectionHandler(XML_Parser parser,
|
||||
XML_StartCdataSectionHandler start,
|
||||
XML_EndCdataSectionHandler end);
|
||||
|
||||
/* This sets the default handler and also inhibits expansion of
|
||||
internal entities. The entity reference will be passed to the default
|
||||
handler.
|
||||
*/
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetDefaultHandler(XML_Parser parser,
|
||||
XML_DefaultHandler handler);
|
||||
|
||||
/* This sets the default handler but does not inhibit expansion of internal entities.
|
||||
The entity reference will not be passed to the default handler. */
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetDefaultHandlerExpand(XML_Parser parser,
|
||||
XML_DefaultHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetDoctypeDeclHandler(XML_Parser parser,
|
||||
XML_StartDoctypeDeclHandler start,
|
||||
XML_EndDoctypeDeclHandler end);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
|
||||
XML_UnparsedEntityDeclHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetNotationDeclHandler(XML_Parser parser,
|
||||
XML_NotationDeclHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetExternalParsedEntityDeclHandler(
|
||||
XML_Parser parser,
|
||||
XML_ExternalParsedEntityDeclHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetInternalParsedEntityDeclHandler(
|
||||
XML_Parser parser,
|
||||
XML_InternalParsedEntityDeclHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetNamespaceDeclHandler(XML_Parser parser,
|
||||
XML_StartNamespaceDeclHandler start,
|
||||
XML_EndNamespaceDeclHandler end);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetNotStandaloneHandler(XML_Parser parser,
|
||||
XML_NotStandaloneHandler handler);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetExternalEntityRefHandler(XML_Parser parser,
|
||||
XML_ExternalEntityRefHandler handler);
|
||||
|
||||
/* If a non-null value for arg is specified here, then it will be
|
||||
passed as the first argument to the external entity ref handler
|
||||
instead of the parser object.
|
||||
*/
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
|
||||
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetUnknownEncodingHandler(XML_Parser parser,
|
||||
XML_UnknownEncodingHandler handler,
|
||||
void *encodingHandlerData);
|
||||
|
||||
/* This can be called within a handler for a start element, end element,
|
||||
processing instruction or character data. It causes the corresponding
|
||||
markup to be passed to the default handler.
|
||||
*/
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_DefaultCurrent(XML_Parser parser);
|
||||
|
||||
/* This value is passed as the userData argument to callbacks. */
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_SetUserData(XML_Parser parser, void *userData);
|
||||
|
||||
/* Returns the last value set by XML_SetUserData or null. */
|
||||
#define XML_GetUserData(parser) (*(void **)(parser))
|
||||
|
||||
/* This is equivalent to supplying an encoding argument
|
||||
to XML_ParserCreate. It must not be called after XML_Parse
|
||||
or XML_ParseBuffer. */
|
||||
|
||||
int XMLPARSEAPI
|
||||
xmlrpc_XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
|
||||
|
||||
/* If this function is called, then the parser will be passed
|
||||
as the first argument to callbacks instead of userData.
|
||||
The userData will still be accessible using XML_GetUserData.
|
||||
*/
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_UseParserAsHandlerArg(XML_Parser parser);
|
||||
|
||||
/* Sets the base to be used for resolving relative URIs in system
|
||||
identifiers in declarations. Resolving relative identifiers is left
|
||||
to the application: this value will be passed through as the base
|
||||
argument to the XML_ExternalEntityRefHandler, XML_NotationDeclHandler
|
||||
and XML_UnparsedEntityDeclHandler. The base argument will be copied.
|
||||
Returns zero if out of memory, non-zero otherwise.
|
||||
*/
|
||||
int XMLPARSEAPI
|
||||
xmlrpc_XML_SetBase(XML_Parser parser, const XML_Char *base);
|
||||
|
||||
const XML_Char XMLPARSEAPI *
|
||||
xmlrpc_XML_GetBase(XML_Parser parser);
|
||||
|
||||
/* Returns the number of the attribute/value pairs passed in last call
|
||||
to the XML_StartElementHandler that were specified in the start-tag
|
||||
rather than defaulted. Each attribute/value pair counts as 2; thus
|
||||
this correspondds to an index into the atts array passed to the
|
||||
XML_StartElementHandler.
|
||||
*/
|
||||
int XMLPARSEAPI
|
||||
xmlrpc_XML_GetSpecifiedAttributeCount(XML_Parser parser);
|
||||
|
||||
/* Returns the index of the ID attribute passed in the last call to
|
||||
XML_StartElementHandler, or -1 if there is no ID attribute. Each
|
||||
attribute/value pair counts as 2; thus this correspondds to an index
|
||||
into the atts array passed to the XML_StartElementHandler.
|
||||
*/
|
||||
int XMLPARSEAPI
|
||||
xmlrpc_XML_GetIdAttributeIndex(XML_Parser parser);
|
||||
|
||||
/* Parses some input. Returns 0 if a fatal error is detected.
|
||||
The last call to XML_Parse must have isFinal true;
|
||||
len may be zero for this call (or any other).
|
||||
*/
|
||||
int XMLPARSEAPI
|
||||
xmlrpc_XML_Parse(XML_Parser const parser, const char * const s, int const len, int const isFinal);
|
||||
|
||||
void XMLPARSEAPI *
|
||||
xmlrpc_XML_GetBuffer(XML_Parser parser, int len);
|
||||
|
||||
int XMLPARSEAPI
|
||||
xmlrpc_XML_ParseBuffer(XML_Parser const parser, int const len, int const isFinal);
|
||||
|
||||
/* Creates an XML_Parser object that can parse an external general
|
||||
entity; context is a '\0'-terminated string specifying the parse
|
||||
context; encoding is a '\0'-terminated string giving the name of the
|
||||
externally specified encoding, or null if there is no externally
|
||||
specified encoding. The context string consists of a sequence of
|
||||
tokens separated by formfeeds (\f); a token consisting of a name
|
||||
specifies that the general entity of the name is open; a token of the
|
||||
form prefix=uri specifies the namespace for a particular prefix; a
|
||||
token of the form =uri specifies the default namespace. This can be
|
||||
called at any point after the first call to an
|
||||
ExternalEntityRefHandler so longer as the parser has not yet been
|
||||
freed. The new parser is completely independent and may safely be
|
||||
used in a separate thread. The handlers and userData are initialized
|
||||
from the parser argument. Returns 0 if out of memory. Otherwise
|
||||
returns a new XML_Parser object.
|
||||
*/
|
||||
XML_Parser XMLPARSEAPI
|
||||
xmlrpc_XML_ExternalEntityParserCreate(XML_Parser parser,
|
||||
const XML_Char *context,
|
||||
const XML_Char *encoding);
|
||||
|
||||
enum XML_ParamEntityParsing {
|
||||
XML_PARAM_ENTITY_PARSING_NEVER,
|
||||
XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
|
||||
XML_PARAM_ENTITY_PARSING_ALWAYS
|
||||
};
|
||||
|
||||
/* Controls parsing of parameter entities (including the external DTD
|
||||
subset). If parsing of parameter entities is enabled, then references
|
||||
to external parameter entities (including the external DTD subset)
|
||||
will be passed to the handler set with
|
||||
XML_SetExternalEntityRefHandler. The context passed will be 0.
|
||||
Unlike external general entities, external parameter entities can only
|
||||
be parsed synchronously. If the external parameter entity is to be
|
||||
parsed, it must be parsed during the call to the external entity ref
|
||||
handler: the complete sequence of XML_ExternalEntityParserCreate,
|
||||
XML_Parse/XML_ParseBuffer and XML_ParserFree calls must be made during
|
||||
this call. After XML_ExternalEntityParserCreate has been called to
|
||||
create the parser for the external parameter entity (context must be 0
|
||||
for this call), it is illegal to make any calls on the old parser
|
||||
until XML_ParserFree has been called on the newly created parser. If
|
||||
the library has been compiled without support for parameter entity
|
||||
parsing (ie without XML_DTD being defined), then
|
||||
XML_SetParamEntityParsing will return 0 if parsing of parameter
|
||||
entities is requested; otherwise it will return non-zero.
|
||||
*/
|
||||
int XMLPARSEAPI
|
||||
xmlrpc_XML_SetParamEntityParsing(XML_Parser parser,
|
||||
enum XML_ParamEntityParsing parsing);
|
||||
|
||||
enum XML_Error {
|
||||
XML_ERROR_NONE,
|
||||
XML_ERROR_NO_MEMORY,
|
||||
XML_ERROR_SYNTAX,
|
||||
XML_ERROR_NO_ELEMENTS,
|
||||
XML_ERROR_INVALID_TOKEN,
|
||||
XML_ERROR_UNCLOSED_TOKEN,
|
||||
XML_ERROR_PARTIAL_CHAR,
|
||||
XML_ERROR_TAG_MISMATCH,
|
||||
XML_ERROR_DUPLICATE_ATTRIBUTE,
|
||||
XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
|
||||
XML_ERROR_PARAM_ENTITY_REF,
|
||||
XML_ERROR_UNDEFINED_ENTITY,
|
||||
XML_ERROR_RECURSIVE_ENTITY_REF,
|
||||
XML_ERROR_ASYNC_ENTITY,
|
||||
XML_ERROR_BAD_CHAR_REF,
|
||||
XML_ERROR_BINARY_ENTITY_REF,
|
||||
XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
|
||||
XML_ERROR_MISPLACED_XML_PI,
|
||||
XML_ERROR_UNKNOWN_ENCODING,
|
||||
XML_ERROR_INCORRECT_ENCODING,
|
||||
XML_ERROR_UNCLOSED_CDATA_SECTION,
|
||||
XML_ERROR_EXTERNAL_ENTITY_HANDLING,
|
||||
XML_ERROR_NOT_STANDALONE
|
||||
};
|
||||
|
||||
/* If xmlrpc_XML_Parse or xmlrpc_XML_ParseBuffer have returned 0, then
|
||||
xmlrpc_XML_GetErrorString and xmlrpc_XML_GetErrorCode return
|
||||
information about the error.
|
||||
*/
|
||||
|
||||
enum XML_Error XMLPARSEAPI
|
||||
xmlrpc_XML_GetErrorCode(XML_Parser const parser);
|
||||
|
||||
const char * XMLPARSEAPI
|
||||
xmlrpc_XML_GetErrorString(XML_Parser const parser);
|
||||
|
||||
/* These functions return information about the current parse location.
|
||||
They may be called when XML_Parse or XML_ParseBuffer return 0;
|
||||
in this case the location is the location of the character at which
|
||||
the error was detected.
|
||||
They may also be called from any other callback called to report
|
||||
some parse event; in this the location is the location of the first
|
||||
of the sequence of characters that generated the event.
|
||||
*/
|
||||
|
||||
int XMLPARSEAPI
|
||||
xmlrpc_XML_GetCurrentLineNumber(XML_Parser parser);
|
||||
int XMLPARSEAPI
|
||||
xmlrpc_XML_GetCurrentColumnNumber(XML_Parser parser);
|
||||
long XMLPARSEAPI
|
||||
xmlrpc_XML_GetCurrentByteIndex(XML_Parser parser);
|
||||
|
||||
/* Return the number of bytes in the current event.
|
||||
Returns 0 if the event is in an internal entity. */
|
||||
|
||||
int XMLPARSEAPI
|
||||
xmlrpc_XML_GetCurrentByteCount(XML_Parser parser);
|
||||
|
||||
/* For backwards compatibility with previous versions. */
|
||||
#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
|
||||
#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
|
||||
#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
|
||||
|
||||
/* Frees memory used by the parser. */
|
||||
void XMLPARSEAPI
|
||||
xmlrpc_XML_ParserFree(XML_Parser parser);
|
||||
|
||||
/* Returns a string describing the error. */
|
||||
const XML_LChar XMLPARSEAPI *
|
||||
xmlrpc_XML_ErrorString(int const code);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#define ASCII_A 0x41
|
||||
#define ASCII_B 0x42
|
||||
#define ASCII_C 0x43
|
||||
#define ASCII_D 0x44
|
||||
#define ASCII_E 0x45
|
||||
#define ASCII_F 0x46
|
||||
#define ASCII_G 0x47
|
||||
#define ASCII_H 0x48
|
||||
#define ASCII_I 0x49
|
||||
#define ASCII_J 0x4A
|
||||
#define ASCII_K 0x4B
|
||||
#define ASCII_L 0x4C
|
||||
#define ASCII_M 0x4D
|
||||
#define ASCII_N 0x4E
|
||||
#define ASCII_O 0x4F
|
||||
#define ASCII_P 0x50
|
||||
#define ASCII_Q 0x51
|
||||
#define ASCII_R 0x52
|
||||
#define ASCII_S 0x53
|
||||
#define ASCII_T 0x54
|
||||
#define ASCII_U 0x55
|
||||
#define ASCII_V 0x56
|
||||
#define ASCII_W 0x57
|
||||
#define ASCII_X 0x58
|
||||
#define ASCII_Y 0x59
|
||||
#define ASCII_Z 0x5A
|
||||
|
||||
#define ASCII_a 0x61
|
||||
#define ASCII_b 0x62
|
||||
#define ASCII_c 0x63
|
||||
#define ASCII_d 0x64
|
||||
#define ASCII_e 0x65
|
||||
#define ASCII_f 0x66
|
||||
#define ASCII_g 0x67
|
||||
#define ASCII_h 0x68
|
||||
#define ASCII_i 0x69
|
||||
#define ASCII_j 0x6A
|
||||
#define ASCII_k 0x6B
|
||||
#define ASCII_l 0x6C
|
||||
#define ASCII_m 0x6D
|
||||
#define ASCII_n 0x6E
|
||||
#define ASCII_o 0x6F
|
||||
#define ASCII_p 0x70
|
||||
#define ASCII_q 0x71
|
||||
#define ASCII_r 0x72
|
||||
#define ASCII_s 0x73
|
||||
#define ASCII_t 0x74
|
||||
#define ASCII_u 0x75
|
||||
#define ASCII_v 0x76
|
||||
#define ASCII_w 0x77
|
||||
#define ASCII_x 0x78
|
||||
#define ASCII_y 0x79
|
||||
#define ASCII_z 0x7A
|
||||
|
||||
#define ASCII_0 0x30
|
||||
#define ASCII_1 0x31
|
||||
#define ASCII_2 0x32
|
||||
#define ASCII_3 0x33
|
||||
#define ASCII_4 0x34
|
||||
#define ASCII_5 0x35
|
||||
#define ASCII_6 0x36
|
||||
#define ASCII_7 0x37
|
||||
#define ASCII_8 0x38
|
||||
#define ASCII_9 0x39
|
||||
|
||||
#define ASCII_TAB 0x09
|
||||
#define ASCII_SPACE 0x20
|
||||
#define ASCII_EXCL 0x21
|
||||
#define ASCII_QUOT 0x22
|
||||
#define ASCII_AMP 0x26
|
||||
#define ASCII_APOS 0x27
|
||||
#define ASCII_MINUS 0x2D
|
||||
#define ASCII_PERIOD 0x2E
|
||||
#define ASCII_COLON 0x3A
|
||||
#define ASCII_SEMI 0x3B
|
||||
#define ASCII_LT 0x3C
|
||||
#define ASCII_EQUALS 0x3D
|
||||
#define ASCII_GT 0x3E
|
||||
#define ASCII_LSQB 0x5B
|
||||
#define ASCII_RSQB 0x5D
|
||||
#define ASCII_UNDERSCORE 0x5F
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#define STRICT 1
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
|
||||
/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
@ -0,0 +1,150 @@
|
||||
static const unsigned namingBitmap[] = {
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
|
||||
0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
|
||||
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
|
||||
0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
|
||||
0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
|
||||
0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
|
||||
0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
|
||||
0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
|
||||
0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
|
||||
0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
|
||||
0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
|
||||
0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
|
||||
0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
|
||||
0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
|
||||
0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
|
||||
0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
|
||||
0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
|
||||
0x40000000, 0xF580C900, 0x00000007, 0x02010800,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
|
||||
0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
|
||||
0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
|
||||
0x00000000, 0x00004C40, 0x00000000, 0x00000000,
|
||||
0x00000007, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||
0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
|
||||
0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
|
||||
0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
|
||||
0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
|
||||
0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
|
||||
0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
|
||||
0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
|
||||
0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
|
||||
0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
|
||||
0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
|
||||
0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
|
||||
0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
|
||||
0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
|
||||
0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
|
||||
0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
|
||||
0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
|
||||
0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
|
||||
0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
|
||||
0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||
0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF,
|
||||
};
|
||||
static const unsigned char nmstrtPages[] = {
|
||||
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
|
||||
0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||
0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
static const unsigned char namePages[] = {
|
||||
0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
|
||||
0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
|
||||
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||
0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
|
||||
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
|
||||
/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef XML_WINLIB
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#ifndef STRICT
|
||||
#define STRICT 1
|
||||
#endif
|
||||
#include <windows.h>
|
||||
|
||||
#define malloc(x) HeapAlloc(GetProcessHeap(), 0, (x))
|
||||
#define calloc(x, y) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (x)*(y))
|
||||
#define free(x) HeapFree(GetProcessHeap(), 0, (x))
|
||||
#define realloc(x, y) HeapReAlloc(GetProcessHeap(), 0, x, y)
|
||||
#define abort() /* as nothing */
|
||||
|
||||
#else /* not XML_WINLIB */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#endif /* not XML_WINLIB */
|
||||
|
||||
/* This file can be used for any definitions needed in
|
||||
particular environments. */
|
||||
|
||||
/* Mozilla specific defines */
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
#include "nspr.h"
|
||||
#define malloc(x) PR_Malloc((size_t)(x))
|
||||
#define realloc(x, y) PR_Realloc((x), (size_t)(y))
|
||||
#define calloc(x, y) PR_Calloc((x),(y))
|
||||
#define free(x) PR_Free(x)
|
||||
#if PR_BYTES_PER_INT != 4
|
||||
#define int int32
|
||||
#endif
|
||||
|
||||
/* Enable Unicode string processing in expat. */
|
||||
#ifndef XML_UNICODE
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
1262
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmltok/xmlrole.c
Normal file
1262
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmltok/xmlrole.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,96 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef XmlRole_INCLUDED
|
||||
#define XmlRole_INCLUDED 1
|
||||
|
||||
#include "xmltok.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
XML_ROLE_ERROR = -1,
|
||||
XML_ROLE_NONE = 0,
|
||||
XML_ROLE_XML_DECL,
|
||||
XML_ROLE_INSTANCE_START,
|
||||
XML_ROLE_DOCTYPE_NAME,
|
||||
XML_ROLE_DOCTYPE_SYSTEM_ID,
|
||||
XML_ROLE_DOCTYPE_PUBLIC_ID,
|
||||
XML_ROLE_DOCTYPE_CLOSE,
|
||||
XML_ROLE_GENERAL_ENTITY_NAME,
|
||||
XML_ROLE_PARAM_ENTITY_NAME,
|
||||
XML_ROLE_ENTITY_VALUE,
|
||||
XML_ROLE_ENTITY_SYSTEM_ID,
|
||||
XML_ROLE_ENTITY_PUBLIC_ID,
|
||||
XML_ROLE_ENTITY_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_NO_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_PUBLIC_ID,
|
||||
XML_ROLE_ATTRIBUTE_NAME,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_CDATA,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ID,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREF,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
|
||||
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
|
||||
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
|
||||
XML_ROLE_ATTLIST_ELEMENT_NAME,
|
||||
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_ELEMENT_NAME,
|
||||
XML_ROLE_CONTENT_ANY,
|
||||
XML_ROLE_CONTENT_EMPTY,
|
||||
XML_ROLE_CONTENT_PCDATA,
|
||||
XML_ROLE_GROUP_OPEN,
|
||||
XML_ROLE_GROUP_CLOSE,
|
||||
XML_ROLE_GROUP_CLOSE_REP,
|
||||
XML_ROLE_GROUP_CLOSE_OPT,
|
||||
XML_ROLE_GROUP_CLOSE_PLUS,
|
||||
XML_ROLE_GROUP_CHOICE,
|
||||
XML_ROLE_GROUP_SEQUENCE,
|
||||
XML_ROLE_CONTENT_ELEMENT,
|
||||
XML_ROLE_CONTENT_ELEMENT_REP,
|
||||
XML_ROLE_CONTENT_ELEMENT_OPT,
|
||||
XML_ROLE_CONTENT_ELEMENT_PLUS,
|
||||
XML_ROLE_TEXT_DECL,
|
||||
XML_ROLE_IGNORE_SECT,
|
||||
XML_ROLE_INNER_PARAM_ENTITY_REF,
|
||||
XML_ROLE_PARAM_ENTITY_REF,
|
||||
XML_ROLE_EXTERNAL_GENERAL_ENTITY_NO_NOTATION
|
||||
};
|
||||
|
||||
typedef struct prolog_state {
|
||||
int (*handler)(struct prolog_state *state,
|
||||
int tok,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const ENCODING *enc);
|
||||
unsigned level;
|
||||
unsigned includeLevel;
|
||||
int documentEntity;
|
||||
} PROLOG_STATE;
|
||||
|
||||
XMLTOKAPI void
|
||||
xmlrpc_XmlPrologStateInit(PROLOG_STATE * const state);
|
||||
|
||||
XMLTOKAPI void
|
||||
xmlrpc_XmlPrologStateInitExternalEntity(PROLOG_STATE * const state);
|
||||
|
||||
#define XmlTokenRole(state, tok, ptr, end, enc) \
|
||||
(((state)->handler)(state, tok, ptr, end, enc))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not XmlRole_INCLUDED */
|
1538
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmltok/xmltok.c
Normal file
1538
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmltok/xmltok.c
Normal file
File diff suppressed because it is too large
Load Diff
316
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmltok/xmltok.h
Normal file
316
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmltok/xmltok.h
Normal file
@ -0,0 +1,316 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef XmlTok_INCLUDED
|
||||
#define XmlTok_INCLUDED 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef XMLTOKAPI
|
||||
#define XMLTOKAPI /* as nothing */
|
||||
#endif
|
||||
|
||||
/* The following token may be returned by XmlContentTok */
|
||||
#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be start of
|
||||
illegal ]]> sequence */
|
||||
/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */
|
||||
#define XML_TOK_NONE -4 /* The string to be scanned is empty */
|
||||
#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan;
|
||||
might be part of CRLF sequence */
|
||||
#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
|
||||
#define XML_TOK_PARTIAL -1 /* only part of a token */
|
||||
#define XML_TOK_INVALID 0
|
||||
|
||||
/* The following tokens are returned by XmlContentTok; some are also
|
||||
returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok */
|
||||
|
||||
#define XML_TOK_START_TAG_WITH_ATTS 1
|
||||
#define XML_TOK_START_TAG_NO_ATTS 2
|
||||
#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
|
||||
#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
|
||||
#define XML_TOK_END_TAG 5
|
||||
#define XML_TOK_DATA_CHARS 6
|
||||
#define XML_TOK_DATA_NEWLINE 7
|
||||
#define XML_TOK_CDATA_SECT_OPEN 8
|
||||
#define XML_TOK_ENTITY_REF 9
|
||||
#define XML_TOK_CHAR_REF 10 /* numeric character reference */
|
||||
|
||||
/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */
|
||||
#define XML_TOK_PI 11 /* processing instruction */
|
||||
#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
|
||||
#define XML_TOK_COMMENT 13
|
||||
#define XML_TOK_BOM 14 /* Byte order mark */
|
||||
|
||||
/* The following tokens are returned only by XmlPrologTok */
|
||||
#define XML_TOK_PROLOG_S 15
|
||||
#define XML_TOK_DECL_OPEN 16 /* <!foo */
|
||||
#define XML_TOK_DECL_CLOSE 17 /* > */
|
||||
#define XML_TOK_NAME 18
|
||||
#define XML_TOK_NMTOKEN 19
|
||||
#define XML_TOK_POUND_NAME 20 /* #name */
|
||||
#define XML_TOK_OR 21 /* | */
|
||||
#define XML_TOK_PERCENT 22
|
||||
#define XML_TOK_OPEN_PAREN 23
|
||||
#define XML_TOK_CLOSE_PAREN 24
|
||||
#define XML_TOK_OPEN_BRACKET 25
|
||||
#define XML_TOK_CLOSE_BRACKET 26
|
||||
#define XML_TOK_LITERAL 27
|
||||
#define XML_TOK_PARAM_ENTITY_REF 28
|
||||
#define XML_TOK_INSTANCE_START 29
|
||||
|
||||
/* The following occur only in element type declarations */
|
||||
#define XML_TOK_NAME_QUESTION 30 /* name? */
|
||||
#define XML_TOK_NAME_ASTERISK 31 /* name* */
|
||||
#define XML_TOK_NAME_PLUS 32 /* name+ */
|
||||
#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
|
||||
#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
|
||||
#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
|
||||
#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
|
||||
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
|
||||
#define XML_TOK_COMMA 38
|
||||
|
||||
/* The following token is returned only by XmlAttributeValueTok */
|
||||
#define XML_TOK_ATTRIBUTE_VALUE_S 39
|
||||
|
||||
/* The following token is returned only by XmlCdataSectionTok */
|
||||
#define XML_TOK_CDATA_SECT_CLOSE 40
|
||||
|
||||
/* With namespace processing this is returned by XmlPrologTok
|
||||
for a name with a colon. */
|
||||
#define XML_TOK_PREFIXED_NAME 41
|
||||
|
||||
#define XML_TOK_IGNORE_SECT 42
|
||||
|
||||
#define XML_N_STATES 4
|
||||
|
||||
#define XML_PROLOG_STATE 0
|
||||
#define XML_CONTENT_STATE 1
|
||||
#define XML_CDATA_SECTION_STATE 2
|
||||
#define XML_IGNORE_SECTION_STATE 3
|
||||
|
||||
#define XML_N_LITERAL_TYPES 2
|
||||
#define XML_ATTRIBUTE_VALUE_LITERAL 0
|
||||
#define XML_ENTITY_VALUE_LITERAL 1
|
||||
|
||||
/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
|
||||
#define XML_UTF8_ENCODE_MAX 4
|
||||
/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
|
||||
#define XML_UTF16_ENCODE_MAX 2
|
||||
|
||||
typedef struct position {
|
||||
/* first line and first column are 0 not 1 */
|
||||
unsigned long lineNumber;
|
||||
unsigned long columnNumber;
|
||||
} POSITION;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *valuePtr;
|
||||
const char *valueEnd;
|
||||
char normalized;
|
||||
} ATTRIBUTE;
|
||||
|
||||
struct encoding;
|
||||
typedef struct encoding ENCODING;
|
||||
|
||||
struct encoding {
|
||||
int (*scanners[XML_N_STATES])(const ENCODING *,
|
||||
const char *,
|
||||
const char *,
|
||||
const char **);
|
||||
int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *,
|
||||
const char *,
|
||||
const char *,
|
||||
const char **);
|
||||
int (*sameName)(const ENCODING *,
|
||||
const char *, const char *);
|
||||
int (*nameMatchesAscii)(const ENCODING *,
|
||||
const char *, const char *, const char *);
|
||||
int (*nameLength)(const ENCODING *, const char *);
|
||||
const char *(*skipS)(const ENCODING *, const char *);
|
||||
int (*getAtts)(const ENCODING *enc, const char *ptr,
|
||||
int attsMax, ATTRIBUTE *atts);
|
||||
int (*charRefNumber)(const ENCODING *enc, const char *ptr);
|
||||
int (*predefinedEntityName)(const ENCODING *, const char *, const char *);
|
||||
void (*updatePosition)(const ENCODING *,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
POSITION *);
|
||||
int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **badPtr);
|
||||
void (*utf8Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
char **toP,
|
||||
const char *toLim);
|
||||
void (*utf16Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
unsigned short **toP,
|
||||
const unsigned short *toLim);
|
||||
int minBytesPerChar;
|
||||
char isUtf8;
|
||||
char isUtf16;
|
||||
};
|
||||
|
||||
/*
|
||||
Scan the string starting at ptr until the end of the next complete token,
|
||||
but do not scan past eptr. Return an integer giving the type of token.
|
||||
|
||||
Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
|
||||
|
||||
Return XML_TOK_PARTIAL when the string does not contain a complete token;
|
||||
nextTokPtr will not be set.
|
||||
|
||||
Return XML_TOK_INVALID when the string does not start a valid token; nextTokPtr
|
||||
will be set to point to the character which made the token invalid.
|
||||
|
||||
Otherwise the string starts with a valid token; nextTokPtr will be set to point
|
||||
to the character following the end of that token.
|
||||
|
||||
Each data character counts as a single token, but adjacent data characters
|
||||
may be returned together. Similarly for characters in the prolog outside
|
||||
literals, comments and processing instructions.
|
||||
*/
|
||||
|
||||
|
||||
#define XmlTok(enc, state, ptr, end, nextTokPtr) \
|
||||
(((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
|
||||
|
||||
#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlContentTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
/* This is used for performing a 2nd-level tokenization on
|
||||
the content of a literal that has already been returned by XmlTok. */
|
||||
|
||||
#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
|
||||
(((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
|
||||
|
||||
#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
|
||||
|
||||
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
|
||||
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
|
||||
|
||||
#define XmlNameLength(enc, ptr) \
|
||||
(((enc)->nameLength)(enc, ptr))
|
||||
|
||||
#define XmlSkipS(enc, ptr) \
|
||||
(((enc)->skipS)(enc, ptr))
|
||||
|
||||
#define XmlGetAttributes(enc, ptr, attsMax, atts) \
|
||||
(((enc)->getAtts)(enc, ptr, attsMax, atts))
|
||||
|
||||
#define XmlCharRefNumber(enc, ptr) \
|
||||
(((enc)->charRefNumber)(enc, ptr))
|
||||
|
||||
#define XmlPredefinedEntityName(enc, ptr, end) \
|
||||
(((enc)->predefinedEntityName)(enc, ptr, end))
|
||||
|
||||
#define XmlUpdatePosition(enc, ptr, end, pos) \
|
||||
(((enc)->updatePosition)(enc, ptr, end, pos))
|
||||
|
||||
#define XmlIsPublicId(enc, ptr, end, badPtr) \
|
||||
(((enc)->isPublicId)(enc, ptr, end, badPtr))
|
||||
|
||||
#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
typedef struct {
|
||||
ENCODING initEnc;
|
||||
const ENCODING **encPtr;
|
||||
} INIT_ENCODING;
|
||||
|
||||
XMLTOKAPI int
|
||||
xmlrpc_XmlParseXmlDecl(int const isGeneralTextEntity,
|
||||
const ENCODING * const enc,
|
||||
const char * const ptr,
|
||||
const char * const end,
|
||||
const char ** const badPtr,
|
||||
const char ** const versionPtr,
|
||||
const char ** const encodingNamePtr,
|
||||
const ENCODING ** const namedEncodingPtr,
|
||||
int * const standalonePtr);
|
||||
|
||||
XMLTOKAPI const ENCODING *
|
||||
xmlrpc_XmlGetUtf8InternalEncoding(void);
|
||||
|
||||
XMLTOKAPI const ENCODING *
|
||||
xmlrpc_XmlGetUtf16InternalEncoding(void);
|
||||
|
||||
XMLTOKAPI int
|
||||
xmlrpc_XmlInitEncoding(INIT_ENCODING * const p,
|
||||
const ENCODING ** const encPtr,
|
||||
const char * const name);
|
||||
|
||||
XMLTOKAPI int
|
||||
xmlrpc_XmlUtf8Encode(int const c,
|
||||
char * const buf);
|
||||
|
||||
XMLTOKAPI int
|
||||
xmlrpc_XmlUtf16Encode(int const charNum,
|
||||
unsigned short * const buf);
|
||||
|
||||
XMLTOKAPI int
|
||||
xmlrpc_XmlSizeOfUnknownEncoding(void);
|
||||
|
||||
XMLTOKAPI ENCODING *
|
||||
xmlrpc_XmlInitUnknownEncoding(void * const mem,
|
||||
int * const table,
|
||||
int (*convert)(void *userData, const char *p),
|
||||
void * const userData);
|
||||
|
||||
int
|
||||
xmlrpc_XmlParseXmlDeclNS(int const isGeneralTextEntity,
|
||||
const ENCODING * const enc,
|
||||
const char * const ptr,
|
||||
const char * const end,
|
||||
const char ** const badPtr,
|
||||
const char ** const versionPtr,
|
||||
const char ** const encodingNamePtr,
|
||||
const ENCODING ** const namedEncodingPtr,
|
||||
int * const standalonePtr);
|
||||
|
||||
int
|
||||
xmlrpc_XmlInitEncodingNS(INIT_ENCODING * const p,
|
||||
const ENCODING ** const encPtr,
|
||||
const char * const name);
|
||||
|
||||
const ENCODING *
|
||||
xmlrpc_XmlGetUtf8InternalEncodingNS(void);
|
||||
|
||||
const ENCODING *
|
||||
xmlrpc_XmlGetUtf16InternalEncodingNS(void);
|
||||
|
||||
ENCODING *
|
||||
xmlrpc_XmlInitUnknownEncodingNS(void * const mem,
|
||||
int * const table,
|
||||
int (*convert)(void *userData, const char *p),
|
||||
void * const userData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not XmlTok_INCLUDED */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
enum {
|
||||
BT_NONXML,
|
||||
BT_MALFORM,
|
||||
BT_LT,
|
||||
BT_AMP,
|
||||
BT_RSQB,
|
||||
BT_LEAD2,
|
||||
BT_LEAD3,
|
||||
BT_LEAD4,
|
||||
BT_TRAIL,
|
||||
BT_CR,
|
||||
BT_LF,
|
||||
BT_GT,
|
||||
BT_QUOT,
|
||||
BT_APOS,
|
||||
BT_EQUALS,
|
||||
BT_QUEST,
|
||||
BT_EXCL,
|
||||
BT_SOL,
|
||||
BT_SEMI,
|
||||
BT_NUM,
|
||||
BT_LSQB,
|
||||
BT_S,
|
||||
BT_NMSTRT,
|
||||
BT_COLON,
|
||||
BT_HEX,
|
||||
BT_DIGIT,
|
||||
BT_NAME,
|
||||
BT_MINUS,
|
||||
BT_OTHER, /* known not to be a name or name start character */
|
||||
BT_NONASCII, /* might be a name or name start character */
|
||||
BT_PERCNT,
|
||||
BT_LPAR,
|
||||
BT_RPAR,
|
||||
BT_AST,
|
||||
BT_PLUS,
|
||||
BT_COMMA,
|
||||
BT_VERBAR
|
||||
};
|
||||
|
||||
#include <stddef.h>
|
@ -0,0 +1,112 @@
|
||||
const ENCODING *
|
||||
NS(xmlrpc_XmlGetUtf8InternalEncoding)(void) {
|
||||
|
||||
return &ns(internal_utf8_encoding).enc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const ENCODING *
|
||||
NS(xmlrpc_XmlGetUtf16InternalEncoding)(void) {
|
||||
|
||||
#if XML_BYTE_ORDER == 12
|
||||
return &ns(internal_little2_encoding).enc;
|
||||
#elif XML_BYTE_ORDER == 21
|
||||
return &ns(internal_big2_encoding).enc;
|
||||
#else
|
||||
const short n = 1;
|
||||
return *(const char *)&n ?
|
||||
&ns(internal_little2_encoding).enc :
|
||||
&ns(internal_big2_encoding).enc;
|
||||
#endif
|
||||
}
|
||||
|
||||
static
|
||||
const ENCODING *NS(encodings)[] = {
|
||||
&ns(latin1_encoding).enc,
|
||||
&ns(ascii_encoding).enc,
|
||||
&ns(utf8_encoding).enc,
|
||||
&ns(big2_encoding).enc,
|
||||
&ns(big2_encoding).enc,
|
||||
&ns(little2_encoding).enc,
|
||||
&ns(utf8_encoding).enc /* NO_ENC */
|
||||
};
|
||||
|
||||
static
|
||||
int NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr)
|
||||
{
|
||||
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr);
|
||||
}
|
||||
|
||||
static
|
||||
int NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr)
|
||||
{
|
||||
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, ptr, end, nextTokPtr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
NS(xmlrpc_XmlInitEncoding)(INIT_ENCODING * const p,
|
||||
const ENCODING ** const encPtr,
|
||||
const char * const name) {
|
||||
|
||||
int i = getEncodingIndex(name);
|
||||
if (i == UNKNOWN_ENC)
|
||||
return 0;
|
||||
SET_INIT_ENC_INDEX(p, i);
|
||||
p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
|
||||
p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
|
||||
p->initEnc.updatePosition = initUpdatePosition;
|
||||
p->encPtr = encPtr;
|
||||
*encPtr = &(p->initEnc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static
|
||||
const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
|
||||
{
|
||||
#define ENCODING_MAX 128
|
||||
char buf[ENCODING_MAX];
|
||||
char *p = buf;
|
||||
int i;
|
||||
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
|
||||
if (ptr != end)
|
||||
return 0;
|
||||
*p = 0;
|
||||
if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
|
||||
return enc;
|
||||
i = getEncodingIndex(buf);
|
||||
if (i == UNKNOWN_ENC)
|
||||
return 0;
|
||||
return NS(encodings)[i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
NS(xmlrpc_XmlParseXmlDecl)(int const isGeneralTextEntity,
|
||||
const ENCODING * const enc,
|
||||
const char * const ptr,
|
||||
const char * const end,
|
||||
const char ** const badPtr,
|
||||
const char ** const versionPtr,
|
||||
const char ** const encodingName,
|
||||
const ENCODING ** const encoding,
|
||||
int * const standalone) {
|
||||
|
||||
return doParseXmlDecl(NS(findEncoding),
|
||||
isGeneralTextEntity,
|
||||
enc,
|
||||
ptr,
|
||||
end,
|
||||
badPtr,
|
||||
versionPtr,
|
||||
encodingName,
|
||||
encoding,
|
||||
standalone);
|
||||
}
|
@ -0,0 +1,209 @@
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ../../..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
ABYSS_SUBDIR = @ABYSS_SUBDIR@
|
||||
AS = @AS@
|
||||
ASYNCH_CLIENT = @ASYNCH_CLIENT@
|
||||
AUTH_CLIENT = @AUTH_CLIENT@
|
||||
AVAILABLE_MODULES = @AVAILABLE_MODULES@
|
||||
CC = @CC@
|
||||
CC_WARN_FLAGS = @CC_WARN_FLAGS@
|
||||
CLIENTTEST = @CLIENTTEST@
|
||||
CONFIGURE_DATE = @CONFIGURE_DATE@
|
||||
CPPTEST = @CPPTEST@
|
||||
CPP_WARN_FLAGS = @CPP_WARN_FLAGS@
|
||||
CXX = @CXX@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
EFRPCTEST = @EFRPCTEST@
|
||||
EFRPCTEST_WRAPPER = @EFRPCTEST_WRAPPER@
|
||||
INTEROP_CGI = @INTEROP_CGI@
|
||||
INTEROP_CLIENT_SUBDIR = @INTEROP_CLIENT_SUBDIR@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIBWWW_CFLAGS = @LIBWWW_CFLAGS@
|
||||
LIBWWW_CONFIG = @LIBWWW_CONFIG@
|
||||
LIBWWW_LDADD = @LIBWWW_LDADD@
|
||||
LIBWWW_LIBDIR = @LIBWWW_LIBDIR@
|
||||
LIBWWW_RPATH = @LIBWWW_RPATH@
|
||||
LIBWWW_WL_RPATH = @LIBWWW_WL_RPATH@
|
||||
LIBXMLRPC_ABYSS_SERVER_LA = @LIBXMLRPC_ABYSS_SERVER_LA@
|
||||
LIBXMLRPC_CGI_LA = @LIBXMLRPC_CGI_LA@
|
||||
LIBXMLRPC_CLIENT_LA = @LIBXMLRPC_CLIENT_LA@
|
||||
LIBXMLRPC_CPP_A = @LIBXMLRPC_CPP_A@
|
||||
LN_S = @LN_S@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MEERKAT_APP_LIST = @MEERKAT_APP_LIST@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
PACKAGE = @PACKAGE@
|
||||
QUERY_MEERKAT = @QUERY_MEERKAT@
|
||||
RANLIB = @RANLIB@
|
||||
SAMPLE_CGI_CGI = @SAMPLE_CGI_CGI@
|
||||
SERVER = @SERVER@
|
||||
SERVERTEST = @SERVERTEST@
|
||||
SYNCH_CLIENT = @SYNCH_CLIENT@
|
||||
VALIDATEE = @VALIDATEE@
|
||||
VERSION = @VERSION@
|
||||
VERSION_INFO = @VERSION_INFO@
|
||||
XMLRPCCPP_H = @XMLRPCCPP_H@
|
||||
XMLRPC_ABYSS_H = @XMLRPC_ABYSS_H@
|
||||
XMLRPC_CGI_H = @XMLRPC_CGI_H@
|
||||
XMLRPC_CLIENT_H = @XMLRPC_CLIENT_H@
|
||||
XML_RPC_API2CPP_SUBDIR = @XML_RPC_API2CPP_SUBDIR@
|
||||
|
||||
EXTRA_DIST = codepage.c filemap.h unixfilemap.c xmlfile.c xmltchar.h xmlwf.dsp codepage.h readfilemap.c win32filemap.c xmlfile.h xmlwf.c
|
||||
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../../../xmlrpc_config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
DIST_COMMON = Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
tags: TAGS
|
||||
TAGS:
|
||||
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = lib/expat/xmlwf
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am:
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am:
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-generic clean-am
|
||||
-rm -f libtool
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-generic distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: tags distdir info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#include "codepage.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define STRICT 1
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
int codepageMap(int cp, int *map)
|
||||
{
|
||||
int i;
|
||||
CPINFO info;
|
||||
if (!GetCPInfo(cp, &info) || info.MaxCharSize > 2)
|
||||
return 0;
|
||||
for (i = 0; i < 256; i++)
|
||||
map[i] = -1;
|
||||
if (info.MaxCharSize > 1) {
|
||||
for (i = 0; i < MAX_LEADBYTES; i++) {
|
||||
int j, lim;
|
||||
if (info.LeadByte[i] == 0 && info.LeadByte[i + 1] == 0)
|
||||
break;
|
||||
lim = info.LeadByte[i + 1];
|
||||
for (j = info.LeadByte[i]; j < lim; j++)
|
||||
map[j] = -2;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (map[i] == -1) {
|
||||
char c = i;
|
||||
unsigned short n;
|
||||
if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
|
||||
&c, 1, &n, 1) == 1)
|
||||
map[i] = n;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int codepageConvert(int cp, const char *p)
|
||||
{
|
||||
unsigned short c;
|
||||
if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
|
||||
p, 2, &c, 1) == 1)
|
||||
return c;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else /* not WIN32 */
|
||||
|
||||
int codepageMap(int cp, int *map)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int codepageConvert(int cp, const char *p)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* not WIN32 */
|
@ -0,0 +1,7 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
int codepageMap(int cp, int *map);
|
||||
int codepageConvert(int cp, const char *p);
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef XML_UNICODE
|
||||
int filemap(const wchar_t *name,
|
||||
void (*processor)(const void *, size_t, const wchar_t *, void *arg),
|
||||
void *arg);
|
||||
#else
|
||||
int filemap(const char *name,
|
||||
void (*processor)(const void *, size_t, const char *, void *arg),
|
||||
void *arg);
|
||||
#endif
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef S_ISREG
|
||||
#ifndef S_IFREG
|
||||
#define S_IFREG _S_IFREG
|
||||
#endif
|
||||
#ifndef S_IFMT
|
||||
#define S_IFMT _S_IFMT
|
||||
#endif
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#endif /* not S_ISREG */
|
||||
|
||||
#ifndef O_BINARY
|
||||
#ifdef _O_BINARY
|
||||
#define O_BINARY _O_BINARY
|
||||
#else
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int filemap(const char *name,
|
||||
void (*processor)(const void *, size_t, const char *, void *arg),
|
||||
void *arg)
|
||||
{
|
||||
size_t nbytes;
|
||||
int fd;
|
||||
int n;
|
||||
struct stat sb;
|
||||
void *p;
|
||||
|
||||
fd = open(name, O_RDONLY|O_BINARY);
|
||||
if (fd < 0) {
|
||||
perror(name);
|
||||
return 0;
|
||||
}
|
||||
if (fstat(fd, &sb) < 0) {
|
||||
perror(name);
|
||||
return 0;
|
||||
}
|
||||
if (!S_ISREG(sb.st_mode)) {
|
||||
fprintf(stderr, "%s: not a regular file\n", name);
|
||||
return 0;
|
||||
}
|
||||
nbytes = sb.st_size;
|
||||
p = malloc(nbytes);
|
||||
if (!p) {
|
||||
fprintf(stderr, "%s: out of memory\n", name);
|
||||
return 0;
|
||||
}
|
||||
n = read(fd, p, nbytes);
|
||||
if (n < 0) {
|
||||
perror(name);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (n != nbytes) {
|
||||
fprintf(stderr, "%s: read unexpected number of bytes\n", name);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
processor(p, nbytes, name, arg);
|
||||
free(p);
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0
|
||||
#endif
|
||||
|
||||
#include "filemap.h"
|
||||
|
||||
int filemap(const char *name,
|
||||
void (*processor)(const void *, size_t, const char *, void *arg),
|
||||
void *arg)
|
||||
{
|
||||
int fd;
|
||||
size_t nbytes;
|
||||
struct stat sb;
|
||||
void *p;
|
||||
|
||||
fd = open(name, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
perror(name);
|
||||
return 0;
|
||||
}
|
||||
if (fstat(fd, &sb) < 0) {
|
||||
perror(name);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (!S_ISREG(sb.st_mode)) {
|
||||
close(fd);
|
||||
fprintf(stderr, "%s: not a regular file\n", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nbytes = sb.st_size;
|
||||
p = (void *)mmap((caddr_t)0, (size_t)nbytes, PROT_READ,
|
||||
MAP_FILE|MAP_PRIVATE, fd, (off_t)0);
|
||||
if (p == (void *)-1) {
|
||||
perror(name);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
processor(p, nbytes, name, arg);
|
||||
munmap((caddr_t)p, nbytes);
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#define STRICT 1
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
#ifndef XML_UNICODE
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE
|
||||
#define UNICODE
|
||||
#define _UNICODE
|
||||
#endif /* XML_UNICODE */
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include "filemap.h"
|
||||
|
||||
static void win32perror(const TCHAR *);
|
||||
|
||||
int filemap(const TCHAR *name,
|
||||
void (*processor)(const void *, size_t, const TCHAR *, void *arg),
|
||||
void *arg)
|
||||
{
|
||||
HANDLE f;
|
||||
HANDLE m;
|
||||
DWORD size;
|
||||
DWORD sizeHi;
|
||||
void *p;
|
||||
|
||||
f = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
||||
FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||
if (f == INVALID_HANDLE_VALUE) {
|
||||
win32perror(name);
|
||||
return 0;
|
||||
}
|
||||
size = GetFileSize(f, &sizeHi);
|
||||
if (size == (DWORD)-1) {
|
||||
win32perror(name);
|
||||
return 0;
|
||||
}
|
||||
if (sizeHi) {
|
||||
_ftprintf(stderr, _T("%s: bigger than 2Gb\n"), name);
|
||||
return 0;
|
||||
}
|
||||
/* CreateFileMapping barfs on zero length files */
|
||||
if (size == 0) {
|
||||
static const char c = '\0';
|
||||
processor(&c, 0, name, arg);
|
||||
CloseHandle(f);
|
||||
return 1;
|
||||
}
|
||||
m = CreateFileMapping(f, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
if (m == NULL) {
|
||||
win32perror(name);
|
||||
CloseHandle(f);
|
||||
return 0;
|
||||
}
|
||||
p = MapViewOfFile(m, FILE_MAP_READ, 0, 0, 0);
|
||||
if (p == NULL) {
|
||||
win32perror(name);
|
||||
CloseHandle(m);
|
||||
CloseHandle(f);
|
||||
return 0;
|
||||
}
|
||||
processor(p, size, name, arg);
|
||||
UnmapViewOfFile(p);
|
||||
CloseHandle(m);
|
||||
CloseHandle(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static
|
||||
void win32perror(const TCHAR *s)
|
||||
{
|
||||
LPVOID buf;
|
||||
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &buf,
|
||||
0,
|
||||
NULL)) {
|
||||
_ftprintf(stderr, _T("%s: %s"), s, buf);
|
||||
fflush(stderr);
|
||||
LocalFree(buf);
|
||||
}
|
||||
else
|
||||
_ftprintf(stderr, _T("%s: unknown Windows error\n"), s);
|
||||
}
|
217
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmlwf/xmlfile.c
Normal file
217
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmlwf/xmlfile.c
Normal file
@ -0,0 +1,217 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include "xmlparse.h"
|
||||
#include "xmlfile.h"
|
||||
#include "xmltchar.h"
|
||||
#include "filemap.h"
|
||||
|
||||
#if MSVCRT
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#ifdef _POSIX_SOURCE
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
#ifdef _O_BINARY
|
||||
#define O_BINARY _O_BINARY
|
||||
#else
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define READ_SIZE 16
|
||||
#else
|
||||
#define READ_SIZE (1024*8)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
XML_Parser parser;
|
||||
int *retPtr;
|
||||
} PROCESS_ARGS;
|
||||
|
||||
static
|
||||
void reportError(XML_Parser parser, const XML_Char *filename)
|
||||
{
|
||||
int code = XML_GetErrorCode(parser);
|
||||
const XML_Char *message = XML_ErrorString(code);
|
||||
if (message)
|
||||
ftprintf(stdout, T("%s:%d:%d: %s\n"),
|
||||
filename,
|
||||
XML_GetErrorLineNumber(parser),
|
||||
XML_GetErrorColumnNumber(parser),
|
||||
message);
|
||||
else
|
||||
ftprintf(stderr, T("%s: (unknown message %d)\n"), filename, code);
|
||||
}
|
||||
|
||||
static
|
||||
void processFile(const void *data,
|
||||
size_t size,
|
||||
const XML_Char *filename,
|
||||
void *args)
|
||||
{
|
||||
XML_Parser parser = ((PROCESS_ARGS *)args)->parser;
|
||||
int *retPtr = ((PROCESS_ARGS *)args)->retPtr;
|
||||
if (!XML_Parse(parser, data, size, 1)) {
|
||||
reportError(parser, filename);
|
||||
*retPtr = 0;
|
||||
}
|
||||
else
|
||||
*retPtr = 1;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
static
|
||||
int isAsciiLetter(XML_Char c)
|
||||
{
|
||||
return (T('a') <= c && c <= T('z')) || (T('A') <= c && c <= T('Z'));
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
static
|
||||
const XML_Char *resolveSystemId(const XML_Char *base, const XML_Char *systemId, XML_Char **toFree)
|
||||
{
|
||||
XML_Char *s;
|
||||
*toFree = 0;
|
||||
if (!base
|
||||
|| *systemId == T('/')
|
||||
#ifdef WIN32
|
||||
|| *systemId == T('\\')
|
||||
|| (isAsciiLetter(systemId[0]) && systemId[1] == T(':'))
|
||||
#endif
|
||||
)
|
||||
return systemId;
|
||||
*toFree = (XML_Char *)malloc((tcslen(base) + tcslen(systemId) + 2)*sizeof(XML_Char));
|
||||
if (!*toFree)
|
||||
return systemId;
|
||||
tcscpy(*toFree, base);
|
||||
s = *toFree;
|
||||
if (tcsrchr(s, T('/')))
|
||||
s = tcsrchr(s, T('/')) + 1;
|
||||
#ifdef WIN32
|
||||
if (tcsrchr(s, T('\\')))
|
||||
s = tcsrchr(s, T('\\')) + 1;
|
||||
#endif
|
||||
tcscpy(s, systemId);
|
||||
return *toFree;
|
||||
}
|
||||
|
||||
static
|
||||
int externalEntityRefFilemap(XML_Parser parser,
|
||||
const XML_Char *context,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId)
|
||||
{
|
||||
int result;
|
||||
XML_Char *s;
|
||||
const XML_Char *filename;
|
||||
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, context, 0);
|
||||
PROCESS_ARGS args;
|
||||
args.retPtr = &result;
|
||||
args.parser = entParser;
|
||||
filename = resolveSystemId(base, systemId, &s);
|
||||
XML_SetBase(entParser, filename);
|
||||
if (!filemap(filename, processFile, &args))
|
||||
result = 0;
|
||||
free(s);
|
||||
XML_ParserFree(entParser);
|
||||
return result;
|
||||
}
|
||||
|
||||
static
|
||||
int processStream(const XML_Char *filename, XML_Parser parser)
|
||||
{
|
||||
int fd = topen(filename, O_BINARY|O_RDONLY);
|
||||
if (fd < 0) {
|
||||
tperror(filename);
|
||||
return 0;
|
||||
}
|
||||
for (;;) {
|
||||
int nread;
|
||||
char *buf = XML_GetBuffer(parser, READ_SIZE);
|
||||
if (!buf) {
|
||||
close(fd);
|
||||
ftprintf(stderr, T("%s: out of memory\n"), filename);
|
||||
return 0;
|
||||
}
|
||||
nread = read(fd, buf, READ_SIZE);
|
||||
if (nread < 0) {
|
||||
tperror(filename);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (!XML_ParseBuffer(parser, nread, nread == 0)) {
|
||||
reportError(parser, filename);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (nread == 0) {
|
||||
close(fd);
|
||||
break;;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static
|
||||
int externalEntityRefStream(XML_Parser parser,
|
||||
const XML_Char *context,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId)
|
||||
{
|
||||
XML_Char *s;
|
||||
const XML_Char *filename;
|
||||
int ret;
|
||||
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, context, 0);
|
||||
filename = resolveSystemId(base, systemId, &s);
|
||||
XML_SetBase(entParser, filename);
|
||||
ret = processStream(filename, entParser);
|
||||
free(s);
|
||||
XML_ParserFree(entParser);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int XML_ProcessFile(XML_Parser parser,
|
||||
const XML_Char *filename,
|
||||
unsigned flags)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (!XML_SetBase(parser, filename)) {
|
||||
ftprintf(stderr, T("%s: out of memory"), filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (flags & XML_EXTERNAL_ENTITIES)
|
||||
XML_SetExternalEntityRefHandler(parser,
|
||||
(flags & XML_MAP_FILE)
|
||||
? externalEntityRefFilemap
|
||||
: externalEntityRefStream);
|
||||
if (flags & XML_MAP_FILE) {
|
||||
PROCESS_ARGS args;
|
||||
args.retPtr = &result;
|
||||
args.parser = parser;
|
||||
if (!filemap(filename, processFile, &args))
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
result = processStream(filename, parser);
|
||||
return result;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#define XML_MAP_FILE 01
|
||||
#define XML_EXTERNAL_ENTITIES 02
|
||||
|
||||
extern int XML_ProcessFile(XML_Parser parser,
|
||||
const XML_Char *filename,
|
||||
unsigned flags);
|
@ -0,0 +1,36 @@
|
||||
#ifdef XML_UNICODE
|
||||
#ifndef XML_UNICODE_WCHAR_T
|
||||
#error xmlwf requires a 16-bit Unicode-compatible wchar_t
|
||||
#endif
|
||||
#define T(x) L ## x
|
||||
#define ftprintf fwprintf
|
||||
#define tfopen _wfopen
|
||||
#define fputts fputws
|
||||
#define puttc putwc
|
||||
#define tcscmp wcscmp
|
||||
#define tcscpy wcscpy
|
||||
#define tcscat wcscat
|
||||
#define tcschr wcschr
|
||||
#define tcsrchr wcsrchr
|
||||
#define tcslen wcslen
|
||||
#define tperror _wperror
|
||||
#define topen _wopen
|
||||
#define tmain wmain
|
||||
#define tremove _wremove
|
||||
#else /* not XML_UNICODE */
|
||||
#define T(x) x
|
||||
#define ftprintf fprintf
|
||||
#define tfopen fopen
|
||||
#define fputts fputs
|
||||
#define puttc putc
|
||||
#define tcscmp strcmp
|
||||
#define tcscpy strcpy
|
||||
#define tcscat strcat
|
||||
#define tcschr strchr
|
||||
#define tcsrchr strrchr
|
||||
#define tcslen strlen
|
||||
#define tperror perror
|
||||
#define topen open
|
||||
#define tmain main
|
||||
#define tremove remove
|
||||
#endif /* not XML_UNICODE */
|
766
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmlwf/xmlwf.c
Normal file
766
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmlwf/xmlwf.c
Normal file
@ -0,0 +1,766 @@
|
||||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file copying.txt for copying permission.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "xmlparse.h"
|
||||
#include "codepage.h"
|
||||
#include "xmlfile.h"
|
||||
#include "xmltchar.h"
|
||||
|
||||
#if MSVCRT
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
/* This ensures proper sorting. */
|
||||
|
||||
#define NSSEP T('\001')
|
||||
|
||||
static void characterData(void *userData, const XML_Char *s, int len)
|
||||
{
|
||||
FILE *fp = userData;
|
||||
for (; len > 0; --len, ++s) {
|
||||
switch (*s) {
|
||||
case T('&'):
|
||||
fputts(T("&"), fp);
|
||||
break;
|
||||
case T('<'):
|
||||
fputts(T("<"), fp);
|
||||
break;
|
||||
case T('>'):
|
||||
fputts(T(">"), fp);
|
||||
break;
|
||||
#ifdef W3C14N
|
||||
case 13:
|
||||
fputts(T("
"), fp);
|
||||
break;
|
||||
#else
|
||||
case T('"'):
|
||||
fputts(T("""), fp);
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 13:
|
||||
ftprintf(fp, T("&#%d;"), *s);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
puttc(*s, fp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void attributeValue(FILE *fp, const XML_Char *s)
|
||||
{
|
||||
puttc(T('='), fp);
|
||||
puttc(T('"'), fp);
|
||||
for (;;) {
|
||||
switch (*s) {
|
||||
case 0:
|
||||
case NSSEP:
|
||||
puttc(T('"'), fp);
|
||||
return;
|
||||
case T('&'):
|
||||
fputts(T("&"), fp);
|
||||
break;
|
||||
case T('<'):
|
||||
fputts(T("<"), fp);
|
||||
break;
|
||||
case T('"'):
|
||||
fputts(T("""), fp);
|
||||
break;
|
||||
#ifdef W3C14N
|
||||
case 9:
|
||||
fputts(T("	"), fp);
|
||||
break;
|
||||
case 10:
|
||||
fputts(T("
"), fp);
|
||||
break;
|
||||
case 13:
|
||||
fputts(T("
"), fp);
|
||||
break;
|
||||
#else
|
||||
case T('>'):
|
||||
fputts(T(">"), fp);
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 13:
|
||||
ftprintf(fp, T("&#%d;"), *s);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
puttc(*s, fp);
|
||||
break;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Lexicographically comparing UTF-8 encoded attribute values,
|
||||
is equivalent to lexicographically comparing based on the character number. */
|
||||
|
||||
static int attcmp(const void *att1, const void *att2)
|
||||
{
|
||||
return tcscmp(*(const XML_Char **)att1, *(const XML_Char **)att2);
|
||||
}
|
||||
|
||||
static void startElement(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
int nAtts;
|
||||
const XML_Char **p;
|
||||
FILE *fp = userData;
|
||||
puttc(T('<'), fp);
|
||||
fputts(name, fp);
|
||||
|
||||
p = atts;
|
||||
while (*p)
|
||||
++p;
|
||||
nAtts = (p - atts) >> 1;
|
||||
if (nAtts > 1)
|
||||
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, attcmp);
|
||||
while (*atts) {
|
||||
puttc(T(' '), fp);
|
||||
fputts(*atts++, fp);
|
||||
attributeValue(fp, *atts);
|
||||
atts++;
|
||||
}
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
static void endElement(void *userData, const XML_Char *name)
|
||||
{
|
||||
FILE *fp = userData;
|
||||
puttc(T('<'), fp);
|
||||
puttc(T('/'), fp);
|
||||
fputts(name, fp);
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
static int nsattcmp(const void *p1, const void *p2)
|
||||
{
|
||||
const XML_Char *att1 = *(const XML_Char **)p1;
|
||||
const XML_Char *att2 = *(const XML_Char **)p2;
|
||||
int sep1 = (tcsrchr(att1, NSSEP) != 0);
|
||||
int sep2 = (tcsrchr(att1, NSSEP) != 0);
|
||||
if (sep1 != sep2)
|
||||
return sep1 - sep2;
|
||||
return tcscmp(att1, att2);
|
||||
}
|
||||
|
||||
static void startElementNS(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
int nAtts;
|
||||
int nsi;
|
||||
const XML_Char **p;
|
||||
FILE *fp = userData;
|
||||
const XML_Char *sep;
|
||||
puttc(T('<'), fp);
|
||||
|
||||
sep = tcsrchr(name, NSSEP);
|
||||
if (sep) {
|
||||
fputts(T("n1:"), fp);
|
||||
fputts(sep + 1, fp);
|
||||
fputts(T(" xmlns:n1"), fp);
|
||||
attributeValue(fp, name);
|
||||
nsi = 2;
|
||||
}
|
||||
else {
|
||||
fputts(name, fp);
|
||||
nsi = 1;
|
||||
}
|
||||
|
||||
p = atts;
|
||||
while (*p)
|
||||
++p;
|
||||
nAtts = (p - atts) >> 1;
|
||||
if (nAtts > 1)
|
||||
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, nsattcmp);
|
||||
while (*atts) {
|
||||
name = *atts++;
|
||||
sep = tcsrchr(name, NSSEP);
|
||||
puttc(T(' '), fp);
|
||||
if (sep) {
|
||||
ftprintf(fp, T("n%d:"), nsi);
|
||||
fputts(sep + 1, fp);
|
||||
}
|
||||
else
|
||||
fputts(name, fp);
|
||||
attributeValue(fp, *atts);
|
||||
if (sep) {
|
||||
ftprintf(fp, T(" xmlns:n%d"), nsi++);
|
||||
attributeValue(fp, name);
|
||||
}
|
||||
atts++;
|
||||
}
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
static void endElementNS(void *userData, const XML_Char *name)
|
||||
{
|
||||
FILE *fp = userData;
|
||||
const XML_Char *sep;
|
||||
puttc(T('<'), fp);
|
||||
puttc(T('/'), fp);
|
||||
sep = tcsrchr(name, NSSEP);
|
||||
if (sep) {
|
||||
fputts(T("n1:"), fp);
|
||||
fputts(sep + 1, fp);
|
||||
}
|
||||
else
|
||||
fputts(name, fp);
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
#ifndef W3C14N
|
||||
|
||||
static void processingInstruction(void *userData, const XML_Char *target, const XML_Char *data)
|
||||
{
|
||||
FILE *fp = userData;
|
||||
puttc(T('<'), fp);
|
||||
puttc(T('?'), fp);
|
||||
fputts(target, fp);
|
||||
puttc(T(' '), fp);
|
||||
fputts(data, fp);
|
||||
puttc(T('?'), fp);
|
||||
puttc(T('>'), fp);
|
||||
}
|
||||
|
||||
#endif /* not W3C14N */
|
||||
|
||||
static void defaultCharacterData(XML_Parser parser, const XML_Char *s, int len)
|
||||
{
|
||||
XML_DefaultCurrent(parser);
|
||||
}
|
||||
|
||||
static void defaultStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
XML_DefaultCurrent(parser);
|
||||
}
|
||||
|
||||
static void defaultEndElement(XML_Parser parser, const XML_Char *name)
|
||||
{
|
||||
XML_DefaultCurrent(parser);
|
||||
}
|
||||
|
||||
static void defaultProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
|
||||
{
|
||||
XML_DefaultCurrent(parser);
|
||||
}
|
||||
|
||||
static void nopCharacterData(XML_Parser parser, const XML_Char *s, int len)
|
||||
{
|
||||
}
|
||||
|
||||
static void nopStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
}
|
||||
|
||||
static void nopEndElement(XML_Parser parser, const XML_Char *name)
|
||||
{
|
||||
}
|
||||
|
||||
static void nopProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
|
||||
{
|
||||
}
|
||||
|
||||
static void markup(XML_Parser parser, const XML_Char *s, int len)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
for (; len > 0; --len, ++s)
|
||||
puttc(*s, fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaLocation(XML_Parser parser)
|
||||
{
|
||||
const XML_Char *uri = XML_GetBase(parser);
|
||||
if (uri)
|
||||
ftprintf(XML_GetUserData(parser), T(" uri=\"%s\""), uri);
|
||||
ftprintf(XML_GetUserData(parser),
|
||||
T(" byte=\"%ld\" nbytes=\"%d\" line=\"%d\" col=\"%d\""),
|
||||
XML_GetCurrentByteIndex(parser),
|
||||
XML_GetCurrentByteCount(parser),
|
||||
XML_GetCurrentLineNumber(parser),
|
||||
XML_GetCurrentColumnNumber(parser));
|
||||
}
|
||||
|
||||
static
|
||||
void metaStartDocument(XML_Parser parser)
|
||||
{
|
||||
fputts(T("<document>\n"), XML_GetUserData(parser));
|
||||
}
|
||||
|
||||
static
|
||||
void metaEndDocument(XML_Parser parser)
|
||||
{
|
||||
fputts(T("</document>\n"), XML_GetUserData(parser));
|
||||
}
|
||||
|
||||
static
|
||||
void metaStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
const XML_Char **specifiedAttsEnd
|
||||
= atts + XML_GetSpecifiedAttributeCount(parser);
|
||||
const XML_Char **idAttPtr;
|
||||
int idAttIndex = XML_GetIdAttributeIndex(parser);
|
||||
if (idAttIndex < 0)
|
||||
idAttPtr = 0;
|
||||
else
|
||||
idAttPtr = atts + idAttIndex;
|
||||
|
||||
ftprintf(fp, T("<starttag name=\"%s\""), name);
|
||||
metaLocation(parser);
|
||||
if (*atts) {
|
||||
fputts(T(">\n"), fp);
|
||||
do {
|
||||
ftprintf(fp, T("<attribute name=\"%s\" value=\""), atts[0]);
|
||||
characterData(fp, atts[1], tcslen(atts[1]));
|
||||
if (atts >= specifiedAttsEnd)
|
||||
fputts(T("\" defaulted=\"yes\"/>\n"), fp);
|
||||
else if (atts == idAttPtr)
|
||||
fputts(T("\" id=\"yes\"/>\n"), fp);
|
||||
else
|
||||
fputts(T("\"/>\n"), fp);
|
||||
} while (*(atts += 2));
|
||||
fputts(T("</starttag>\n"), fp);
|
||||
}
|
||||
else
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaEndElement(XML_Parser parser, const XML_Char *name)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<endtag name=\"%s\""), name);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaProcessingInstruction(XML_Parser parser, const XML_Char *target, const XML_Char *data)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<pi target=\"%s\" data=\""), target);
|
||||
characterData(fp, data, tcslen(data));
|
||||
puttc(T('"'), fp);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaComment(XML_Parser parser, const XML_Char *data)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
fputts(T("<comment data=\""), fp);
|
||||
characterData(fp, data, tcslen(data));
|
||||
puttc(T('"'), fp);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaStartCdataSection(XML_Parser parser)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
fputts(T("<startcdata"), fp);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaEndCdataSection(XML_Parser parser)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
fputts(T("<endcdata"), fp);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaCharacterData(XML_Parser parser, const XML_Char *s, int len)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
fputts(T("<chars str=\""), fp);
|
||||
characterData(fp, s, len);
|
||||
puttc(T('"'), fp);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaStartDoctypeDecl(XML_Parser parser, const XML_Char *doctypeName)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<startdoctype name=\"%s\""), doctypeName);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaEndDoctypeDecl(XML_Parser parser)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
fputts(T("<enddoctype"), fp);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaUnparsedEntityDecl(XML_Parser parser,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId,
|
||||
const XML_Char *notationName)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<entity name=\"%s\""), entityName);
|
||||
if (publicId)
|
||||
ftprintf(fp, T(" public=\"%s\""), publicId);
|
||||
fputts(T(" system=\""), fp);
|
||||
characterData(fp, systemId, tcslen(systemId));
|
||||
puttc(T('"'), fp);
|
||||
ftprintf(fp, T(" notation=\"%s\""), notationName);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaNotationDecl(XML_Parser parser,
|
||||
const XML_Char *notationName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<notation name=\"%s\""), notationName);
|
||||
if (publicId)
|
||||
ftprintf(fp, T(" public=\"%s\""), publicId);
|
||||
if (systemId) {
|
||||
fputts(T(" system=\""), fp);
|
||||
characterData(fp, systemId, tcslen(systemId));
|
||||
puttc(T('"'), fp);
|
||||
}
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void metaExternalParsedEntityDecl(XML_Parser parser,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<entity name=\"%s\""), entityName);
|
||||
if (publicId)
|
||||
ftprintf(fp, T(" public=\"%s\""), publicId);
|
||||
fputts(T(" system=\""), fp);
|
||||
characterData(fp, systemId, tcslen(systemId));
|
||||
puttc(T('"'), fp);
|
||||
metaLocation(parser);
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaInternalParsedEntityDecl(XML_Parser parser,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *text,
|
||||
int textLen)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
ftprintf(fp, T("<entity name=\"%s\""), entityName);
|
||||
metaLocation(parser);
|
||||
puttc(T('>'), fp);
|
||||
characterData(fp, text, textLen);
|
||||
fputts(T("</entity/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaStartNamespaceDecl(XML_Parser parser,
|
||||
const XML_Char *prefix,
|
||||
const XML_Char *uri)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
fputts(T("<startns"), fp);
|
||||
if (prefix)
|
||||
ftprintf(fp, T(" prefix=\"%s\""), prefix);
|
||||
if (uri) {
|
||||
fputts(T(" ns=\""), fp);
|
||||
characterData(fp, uri, tcslen(uri));
|
||||
fputts(T("\"/>\n"), fp);
|
||||
}
|
||||
else
|
||||
fputts(T("/>\n"), fp);
|
||||
}
|
||||
|
||||
static
|
||||
void metaEndNamespaceDecl(XML_Parser parser, const XML_Char *prefix)
|
||||
{
|
||||
FILE *fp = XML_GetUserData(parser);
|
||||
if (!prefix)
|
||||
fputts(T("<endns/>\n"), fp);
|
||||
else
|
||||
ftprintf(fp, T("<endns prefix=\"%s\"/>\n"), prefix);
|
||||
}
|
||||
|
||||
static
|
||||
int unknownEncodingConvert(void *data, const char *p)
|
||||
{
|
||||
return codepageConvert(*(int *)data, p);
|
||||
}
|
||||
|
||||
static
|
||||
int unknownEncoding(void *userData,
|
||||
const XML_Char *name,
|
||||
XML_Encoding *info)
|
||||
{
|
||||
int cp;
|
||||
static const XML_Char prefixL[] = T("windows-");
|
||||
static const XML_Char prefixU[] = T("WINDOWS-");
|
||||
int i;
|
||||
|
||||
for (i = 0; prefixU[i]; i++)
|
||||
if (name[i] != prefixU[i] && name[i] != prefixL[i])
|
||||
return 0;
|
||||
|
||||
cp = 0;
|
||||
for (; name[i]; i++) {
|
||||
static const XML_Char digits[] = T("0123456789");
|
||||
const XML_Char *s = tcschr(digits, name[i]);
|
||||
if (!s)
|
||||
return 0;
|
||||
cp *= 10;
|
||||
cp += s - digits;
|
||||
if (cp >= 0x10000)
|
||||
return 0;
|
||||
}
|
||||
if (!codepageMap(cp, info->map))
|
||||
return 0;
|
||||
info->convert = unknownEncodingConvert;
|
||||
/* We could just cast the code page integer to a void *,
|
||||
and avoid the use of release. */
|
||||
info->release = free;
|
||||
info->data = malloc(sizeof(int));
|
||||
if (!info->data)
|
||||
return 0;
|
||||
*(int *)info->data = cp;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static
|
||||
int notStandalone(void *userData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
void usage(const XML_Char *prog)
|
||||
{
|
||||
ftprintf(stderr, T("usage: %s [-n] [-p] [-r] [-s] [-w] [-x] [-d output-dir] [-e encoding] file ...\n"), prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int tmain(int argc, XML_Char **argv)
|
||||
{
|
||||
int i, j;
|
||||
const XML_Char *outputDir = 0;
|
||||
const XML_Char *encoding = 0;
|
||||
unsigned processFlags = XML_MAP_FILE;
|
||||
int windowsCodePages = 0;
|
||||
int outputType = 0;
|
||||
int useNamespaces = 0;
|
||||
int requireStandalone = 0;
|
||||
int paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
|
||||
|
||||
#if MSVCRT
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
|
||||
i = 1;
|
||||
j = 0;
|
||||
while (i < argc) {
|
||||
if (j == 0) {
|
||||
if (argv[i][0] != T('-'))
|
||||
break;
|
||||
if (argv[i][1] == T('-') && argv[i][2] == T('\0')) {
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
switch (argv[i][j]) {
|
||||
case T('r'):
|
||||
processFlags &= ~XML_MAP_FILE;
|
||||
j++;
|
||||
break;
|
||||
case T('s'):
|
||||
requireStandalone = 1;
|
||||
j++;
|
||||
break;
|
||||
case T('n'):
|
||||
useNamespaces = 1;
|
||||
j++;
|
||||
break;
|
||||
case T('p'):
|
||||
paramEntityParsing = XML_PARAM_ENTITY_PARSING_ALWAYS;
|
||||
/* fall through */
|
||||
case T('x'):
|
||||
processFlags |= XML_EXTERNAL_ENTITIES;
|
||||
j++;
|
||||
break;
|
||||
case T('w'):
|
||||
windowsCodePages = 1;
|
||||
j++;
|
||||
break;
|
||||
case T('m'):
|
||||
outputType = 'm';
|
||||
j++;
|
||||
break;
|
||||
case T('c'):
|
||||
outputType = 'c';
|
||||
useNamespaces = 0;
|
||||
j++;
|
||||
break;
|
||||
case T('t'):
|
||||
outputType = 't';
|
||||
j++;
|
||||
break;
|
||||
case T('d'):
|
||||
if (argv[i][j + 1] == T('\0')) {
|
||||
if (++i == argc)
|
||||
usage(argv[0]);
|
||||
outputDir = argv[i];
|
||||
}
|
||||
else
|
||||
outputDir = argv[i] + j + 1;
|
||||
i++;
|
||||
j = 0;
|
||||
break;
|
||||
case T('e'):
|
||||
if (argv[i][j + 1] == T('\0')) {
|
||||
if (++i == argc)
|
||||
usage(argv[0]);
|
||||
encoding = argv[i];
|
||||
}
|
||||
else
|
||||
encoding = argv[i] + j + 1;
|
||||
i++;
|
||||
j = 0;
|
||||
break;
|
||||
case T('\0'):
|
||||
if (j > 1) {
|
||||
i++;
|
||||
j = 0;
|
||||
break;
|
||||
}
|
||||
/* fall through */
|
||||
default:
|
||||
usage(argv[0]);
|
||||
}
|
||||
}
|
||||
if (i == argc)
|
||||
usage(argv[0]);
|
||||
for (; i < argc; i++) {
|
||||
FILE *fp = 0;
|
||||
XML_Char *outName = 0;
|
||||
int result;
|
||||
XML_Parser parser;
|
||||
if (useNamespaces)
|
||||
parser = XML_ParserCreateNS(encoding, NSSEP);
|
||||
else
|
||||
parser = XML_ParserCreate(encoding);
|
||||
if (requireStandalone)
|
||||
XML_SetNotStandaloneHandler(parser, notStandalone);
|
||||
XML_SetParamEntityParsing(parser, paramEntityParsing);
|
||||
if (outputType == 't') {
|
||||
/* This is for doing timings; this gives a more realistic estimate of
|
||||
the parsing time. */
|
||||
outputDir = 0;
|
||||
XML_SetElementHandler(parser, nopStartElement, nopEndElement);
|
||||
XML_SetCharacterDataHandler(parser, nopCharacterData);
|
||||
XML_SetProcessingInstructionHandler(parser, nopProcessingInstruction);
|
||||
}
|
||||
else if (outputDir) {
|
||||
const XML_Char *file = argv[i];
|
||||
if (tcsrchr(file, T('/')))
|
||||
file = tcsrchr(file, T('/')) + 1;
|
||||
#ifdef WIN32
|
||||
if (tcsrchr(file, T('\\')))
|
||||
file = tcsrchr(file, T('\\')) + 1;
|
||||
#endif
|
||||
outName = malloc((tcslen(outputDir) + tcslen(file) + 2) * sizeof(XML_Char));
|
||||
tcscpy(outName, outputDir);
|
||||
tcscat(outName, T("/"));
|
||||
tcscat(outName, file);
|
||||
fp = tfopen(outName, T("wb"));
|
||||
if (!fp) {
|
||||
tperror(outName);
|
||||
exit(1);
|
||||
}
|
||||
setvbuf(fp, NULL, _IOFBF, 16384);
|
||||
#ifdef XML_UNICODE
|
||||
puttc(0xFEFF, fp);
|
||||
#endif
|
||||
XML_SetUserData(parser, fp);
|
||||
switch (outputType) {
|
||||
case 'm':
|
||||
XML_UseParserAsHandlerArg(parser);
|
||||
XML_SetElementHandler(parser, metaStartElement, metaEndElement);
|
||||
XML_SetProcessingInstructionHandler(parser, metaProcessingInstruction);
|
||||
XML_SetCommentHandler(parser, metaComment);
|
||||
XML_SetCdataSectionHandler(parser, metaStartCdataSection, metaEndCdataSection);
|
||||
XML_SetCharacterDataHandler(parser, metaCharacterData);
|
||||
XML_SetDoctypeDeclHandler(parser, metaStartDoctypeDecl, metaEndDoctypeDecl);
|
||||
XML_SetUnparsedEntityDeclHandler(parser, metaUnparsedEntityDecl);
|
||||
XML_SetNotationDeclHandler(parser, metaNotationDecl);
|
||||
XML_SetExternalParsedEntityDeclHandler(parser, metaExternalParsedEntityDecl);
|
||||
XML_SetInternalParsedEntityDeclHandler(parser, metaInternalParsedEntityDecl);
|
||||
XML_SetNamespaceDeclHandler(parser, metaStartNamespaceDecl, metaEndNamespaceDecl);
|
||||
metaStartDocument(parser);
|
||||
break;
|
||||
case 'c':
|
||||
XML_UseParserAsHandlerArg(parser);
|
||||
XML_SetDefaultHandler(parser, markup);
|
||||
XML_SetElementHandler(parser, defaultStartElement, defaultEndElement);
|
||||
XML_SetCharacterDataHandler(parser, defaultCharacterData);
|
||||
XML_SetProcessingInstructionHandler(parser, defaultProcessingInstruction);
|
||||
break;
|
||||
default:
|
||||
if (useNamespaces)
|
||||
XML_SetElementHandler(parser, startElementNS, endElementNS);
|
||||
else
|
||||
XML_SetElementHandler(parser, startElement, endElement);
|
||||
XML_SetCharacterDataHandler(parser, characterData);
|
||||
#ifndef W3C14N
|
||||
XML_SetProcessingInstructionHandler(parser, processingInstruction);
|
||||
#endif /* not W3C14N */
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (windowsCodePages)
|
||||
XML_SetUnknownEncodingHandler(parser, unknownEncoding, 0);
|
||||
result = XML_ProcessFile(parser, argv[i], processFlags);
|
||||
if (outputDir) {
|
||||
if (outputType == 'm')
|
||||
metaEndDocument(parser);
|
||||
fclose(fp);
|
||||
if (!result)
|
||||
tremove(outName);
|
||||
free(outName);
|
||||
}
|
||||
XML_ParserFree(parser);
|
||||
}
|
||||
return 0;
|
||||
}
|
136
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmlwf/xmlwf.dsp
Normal file
136
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/expat/xmlwf/xmlwf.dsp
Normal file
@ -0,0 +1,136 @@
|
||||
# Microsoft Developer Studio Project File - Name="xmlwf" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=xmlwf - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "xmlwf.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "xmlwf.mak" CFG="xmlwf - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "xmlwf - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "xmlwf - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "xmlwf - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir "."
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir "."
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\xmlparse" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D XMLTOKAPI=__declspec(dllimport) /D XMLPARSEAPI=__declspec(dllimport) /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"..\bin\xmlwf.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "xmlwf - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir "."
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir "."
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I ".\xmlparse" /I "..\xmlparse" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D XMLTOKAPI=__declspec(dllimport) /D XMLPARSEAPI=__declspec(dllimport) /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
|
||||
# ADD LINK32 setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"..\dbgbin\xmlwf.exe"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "xmlwf - Win32 Release"
|
||||
# Name "xmlwf - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\codepage.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readfilemap.c
|
||||
# PROP Exclude_From_Build 1
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\unixfilemap.c
|
||||
# PROP Exclude_From_Build 1
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\win32filemap.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlfile.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlwf.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\codepage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmlfile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xmltchar.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
116
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/asprintf.c
Normal file
116
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/asprintf.c
Normal file
@ -0,0 +1,116 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "xmlrpc_config.h" /* For HAVE_ASPRINTF, __inline__ */
|
||||
#include "xmlrpc-c/string_int.h"
|
||||
|
||||
|
||||
|
||||
static __inline__ void
|
||||
simpleVasprintf(char ** const retvalP,
|
||||
const char * const fmt,
|
||||
va_list varargs) {
|
||||
/*----------------------------------------------------------------------------
|
||||
This is a poor man's implementation of vasprintf(), of GNU fame.
|
||||
-----------------------------------------------------------------------------*/
|
||||
size_t const initialSize = 4096;
|
||||
char * result;
|
||||
|
||||
result = malloc(initialSize);
|
||||
if (result != NULL) {
|
||||
size_t bytesNeeded;
|
||||
bytesNeeded = XMLRPC_VSNPRINTF(result, initialSize, fmt, varargs);
|
||||
if (bytesNeeded > initialSize) {
|
||||
free(result);
|
||||
result = malloc(bytesNeeded);
|
||||
if (result != NULL)
|
||||
XMLRPC_VSNPRINTF(result, bytesNeeded, fmt, varargs);
|
||||
} else if (bytesNeeded == initialSize) {
|
||||
if (result[initialSize-1] != '\0') {
|
||||
/* This is one of those old systems where vsnprintf()
|
||||
returns the number of bytes it used, instead of the
|
||||
number that it needed, and it in fact needed more than
|
||||
we gave it. Rather than mess with this highly unlikely
|
||||
case (old system and string > 4095 characters), we just
|
||||
treat this like an out of memory failure.
|
||||
*/
|
||||
free(result);
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
*retvalP = result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char * const xmlrpc_strsol = "[insufficient memory to build string]";
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_vasprintf(const char ** const retvalP,
|
||||
const char * const fmt,
|
||||
va_list varargs) {
|
||||
|
||||
char * string;
|
||||
|
||||
#if HAVE_ASPRINTF
|
||||
vasprintf(&string, fmt, varargs);
|
||||
#else
|
||||
simpleVasprintf(&string, fmt, varargs);
|
||||
#endif
|
||||
|
||||
if (string == NULL)
|
||||
*retvalP = xmlrpc_strsol;
|
||||
else
|
||||
*retvalP = string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GNU_PRINTF_ATTR(2,3)
|
||||
xmlrpc_asprintf(const char ** const retvalP, const char * const fmt, ...) {
|
||||
|
||||
va_list varargs; /* mysterious structure used by variable arg facility */
|
||||
|
||||
va_start(varargs, fmt); /* start up the mysterious variable arg facility */
|
||||
|
||||
xmlrpc_vasprintf(retvalP, fmt, varargs);
|
||||
|
||||
va_end(varargs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
xmlrpc_strdupnull(const char * const string) {
|
||||
|
||||
if (string)
|
||||
return strdup(string);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_strfree(const char * const string) {
|
||||
|
||||
if (string != xmlrpc_strsol)
|
||||
free((void *)string);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_strfreenull(const char * const string) {
|
||||
|
||||
if (string)
|
||||
xmlrpc_strfree(string);
|
||||
}
|
||||
|
||||
|
||||
|
163
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/error.c
Normal file
163
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/error.c
Normal file
@ -0,0 +1,163 @@
|
||||
/* Copyright information is at end of file */
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "xmlrpc-c/util_int.h"
|
||||
#include "xmlrpc-c/string_int.h"
|
||||
#include "xmlrpc-c/util.h"
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_assertion_failed(const char * const fileName,
|
||||
int const lineNumber) {
|
||||
|
||||
fprintf(stderr, "%s:%d: assertion failed\n", fileName, lineNumber);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const char * const default_fault_string =
|
||||
"Not enough memory for error message";
|
||||
|
||||
void xmlrpc_env_init (xmlrpc_env* env)
|
||||
{
|
||||
XMLRPC_ASSERT(env != NULL);
|
||||
|
||||
env->fault_occurred = 0;
|
||||
env->fault_code = 0;
|
||||
env->fault_string = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
xmlrpc_env_clean(xmlrpc_env * const envP) {
|
||||
|
||||
XMLRPC_ASSERT(envP != NULL);
|
||||
XMLRPC_ASSERT(envP->fault_string != XMLRPC_BAD_POINTER);
|
||||
|
||||
/* env->fault_string may be one of three things:
|
||||
** 1) a NULL pointer
|
||||
** 2) a pointer to the default_fault_string
|
||||
** 3) a pointer to a malloc'd fault string
|
||||
** If we have case (3), we'll need to free it. */
|
||||
if (envP->fault_string && envP->fault_string != default_fault_string)
|
||||
free(envP->fault_string);
|
||||
envP->fault_string = XMLRPC_BAD_POINTER;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_env_set_fault(xmlrpc_env * const envP,
|
||||
int const faultCode,
|
||||
const char * const faultDescription) {
|
||||
|
||||
char * buffer;
|
||||
|
||||
XMLRPC_ASSERT(envP != NULL);
|
||||
XMLRPC_ASSERT(faultDescription != NULL);
|
||||
|
||||
/* Clean up any leftover pointers. */
|
||||
xmlrpc_env_clean(envP);
|
||||
|
||||
envP->fault_occurred = 1;
|
||||
envP->fault_code = faultCode;
|
||||
|
||||
/* Try to copy the fault string. If this fails, use a default. */
|
||||
buffer = strdup(faultDescription);
|
||||
if (buffer == NULL)
|
||||
envP->fault_string = (char *)default_fault_string;
|
||||
else {
|
||||
xmlrpc_force_to_utf8(buffer);
|
||||
xmlrpc_force_to_xml_chars(buffer);
|
||||
envP->fault_string = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_set_fault_formatted_v(xmlrpc_env * const envP,
|
||||
int const code,
|
||||
const char * const format,
|
||||
va_list const args) {
|
||||
|
||||
const char * faultDescription;
|
||||
|
||||
xmlrpc_vasprintf(&faultDescription, format, args);
|
||||
|
||||
xmlrpc_env_set_fault(envP, code, faultDescription);
|
||||
|
||||
xmlrpc_strfree(faultDescription);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_env_set_fault_formatted(xmlrpc_env * const envP,
|
||||
int const code,
|
||||
const char * const format,
|
||||
...) {
|
||||
va_list args;
|
||||
|
||||
XMLRPC_ASSERT(envP != NULL);
|
||||
XMLRPC_ASSERT(format != NULL);
|
||||
|
||||
/* Print our error message to the buffer. */
|
||||
va_start(args, format);
|
||||
xmlrpc_set_fault_formatted_v(envP, code, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_faultf(xmlrpc_env * const envP,
|
||||
const char * const format,
|
||||
...) {
|
||||
|
||||
va_list args;
|
||||
|
||||
XMLRPC_ASSERT(envP != NULL);
|
||||
XMLRPC_ASSERT(format != NULL);
|
||||
|
||||
/* Print our error message to the buffer. */
|
||||
va_start(args, format);
|
||||
xmlrpc_set_fault_formatted_v(envP, XMLRPC_INTERNAL_ERROR, format, args);
|
||||
va_end(args);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE. */
|
||||
|
@ -0,0 +1,101 @@
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
#include "xmlrpc-c/string_int.h"
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
xmlrpc_makePrintable_lp(const char * const input,
|
||||
size_t const inputLength) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Convert an arbitrary string of characters in length-pointer form to
|
||||
printable ASCII. E.g. convert newlines to "\n".
|
||||
|
||||
Return the result in newly malloc'ed storage. Return NULL if we can't
|
||||
get the storage.
|
||||
-----------------------------------------------------------------------------*/
|
||||
char * output;
|
||||
|
||||
output = malloc(inputLength*4+1);
|
||||
/* Worst case, we render a character like \x01 -- 4 characters */
|
||||
|
||||
if (output != NULL) {
|
||||
unsigned int inputCursor, outputCursor;
|
||||
|
||||
for (inputCursor = 0, outputCursor = 0;
|
||||
inputCursor < inputLength;
|
||||
++inputCursor) {
|
||||
|
||||
if (0) {
|
||||
} else if (input[inputCursor] == '\\') {
|
||||
output[outputCursor++] = '\\';
|
||||
output[outputCursor++] = '\\';
|
||||
} else if (input[inputCursor] == '\n') {
|
||||
output[outputCursor++] = '\\';
|
||||
output[outputCursor++] = 'n';
|
||||
} else if (input[inputCursor] == '\t') {
|
||||
output[outputCursor++] = '\\';
|
||||
output[outputCursor++] = 't';
|
||||
} else if (input[inputCursor] == '\a') {
|
||||
output[outputCursor++] = '\\';
|
||||
output[outputCursor++] = 'a';
|
||||
} else if (input[inputCursor] == '\r') {
|
||||
output[outputCursor++] = '\\';
|
||||
output[outputCursor++] = 'r';
|
||||
} else if (isprint(input[inputCursor])) {
|
||||
output[outputCursor++] = input[inputCursor];
|
||||
} else {
|
||||
snprintf(&output[outputCursor], 5, "\\x%02x",
|
||||
input[inputCursor]);
|
||||
outputCursor += 4;
|
||||
}
|
||||
}
|
||||
output[outputCursor++] = '\0';
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
xmlrpc_makePrintable(const char * const input) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Convert an arbitrary string of characters (NUL-terminated, though) to
|
||||
printable ASCII. E.g. convert newlines to "\n".
|
||||
|
||||
Return the result in newly malloc'ed storage. Return NULL if we can't
|
||||
get the storage.
|
||||
-----------------------------------------------------------------------------*/
|
||||
return xmlrpc_makePrintable_lp(input, strlen(input));
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
xmlrpc_makePrintableChar(char const input) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Return an ASCIIZ string consisting of the character 'input',
|
||||
properly escaped so as to be printable. E.g., in C notation, '\n'
|
||||
turns into "\\n"
|
||||
-----------------------------------------------------------------------------*/
|
||||
const char * retval;
|
||||
|
||||
if (input == '\0')
|
||||
retval = strdup("\\0");
|
||||
else {
|
||||
char buffer[2];
|
||||
|
||||
buffer[0] = input;
|
||||
buffer[1] = '\0';
|
||||
|
||||
retval = xmlrpc_makePrintable(buffer);
|
||||
}
|
||||
return retval;
|
||||
}
|
214
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/memblock.c
Normal file
214
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/memblock.c
Normal file
@ -0,0 +1,214 @@
|
||||
/* Copyright information is at end of file */
|
||||
#include "xmlrpc_config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "xmlrpc-c/util_int.h"
|
||||
#include "xmlrpc-c/util.h"
|
||||
|
||||
#ifdef EFENCE
|
||||
/* when looking for corruption don't allocate extra slop */
|
||||
#define BLOCK_ALLOC_MIN (1)
|
||||
#else
|
||||
#define BLOCK_ALLOC_MIN (16)
|
||||
#endif
|
||||
#define BLOCK_ALLOC_MAX (128 * 1024 * 1024)
|
||||
|
||||
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_mem_block_new(xmlrpc_env * const env,
|
||||
size_t const size) {
|
||||
|
||||
xmlrpc_mem_block* block;
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(env);
|
||||
|
||||
block = (xmlrpc_mem_block*) malloc(sizeof(xmlrpc_mem_block));
|
||||
XMLRPC_FAIL_IF_NULL(block, env, XMLRPC_INTERNAL_ERROR,
|
||||
"Can't allocate memory block");
|
||||
|
||||
xmlrpc_mem_block_init(env, block, size);
|
||||
XMLRPC_FAIL_IF_FAULT(env);
|
||||
|
||||
cleanup:
|
||||
if (env->fault_occurred) {
|
||||
if (block)
|
||||
free(block);
|
||||
return NULL;
|
||||
} else {
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
||||
/* Destroy an existing xmlrpc_mem_block, and everything it contains. */
|
||||
void
|
||||
xmlrpc_mem_block_free(xmlrpc_mem_block * const blockP) {
|
||||
|
||||
XMLRPC_ASSERT(blockP != NULL);
|
||||
XMLRPC_ASSERT(blockP->_block != NULL);
|
||||
|
||||
xmlrpc_mem_block_clean(blockP);
|
||||
free(blockP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Initialize the contents of the provided xmlrpc_mem_block. */
|
||||
void
|
||||
xmlrpc_mem_block_init(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const blockP,
|
||||
size_t const size) {
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT(blockP != NULL);
|
||||
|
||||
blockP->_size = size;
|
||||
if (size < BLOCK_ALLOC_MIN)
|
||||
blockP->_allocated = BLOCK_ALLOC_MIN;
|
||||
else
|
||||
blockP->_allocated = size;
|
||||
|
||||
blockP->_block = (void*) malloc(blockP->_allocated);
|
||||
if (!blockP->_block)
|
||||
xmlrpc_faultf(envP, "Can't allocate %u-byte memory block",
|
||||
blockP->_allocated);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Deallocate the contents of the provided xmlrpc_mem_block, but not
|
||||
the block itself.
|
||||
*/
|
||||
void
|
||||
xmlrpc_mem_block_clean(xmlrpc_mem_block * const blockP) {
|
||||
|
||||
XMLRPC_ASSERT(blockP != NULL);
|
||||
XMLRPC_ASSERT(blockP->_block != NULL);
|
||||
|
||||
free(blockP->_block);
|
||||
blockP->_block = XMLRPC_BAD_POINTER;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Get the size of the xmlrpc_mem_block. */
|
||||
size_t
|
||||
xmlrpc_mem_block_size(const xmlrpc_mem_block * const blockP) {
|
||||
|
||||
XMLRPC_ASSERT(blockP != NULL);
|
||||
return blockP->_size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Get the contents of the xmlrpc_mem_block. */
|
||||
void *
|
||||
xmlrpc_mem_block_contents(const xmlrpc_mem_block * const blockP) {
|
||||
|
||||
XMLRPC_ASSERT(blockP != NULL);
|
||||
return blockP->_block;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Resize an xmlrpc_mem_block, preserving as much of the contents as
|
||||
possible.
|
||||
*/
|
||||
void
|
||||
xmlrpc_mem_block_resize (xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const blockP,
|
||||
size_t const size) {
|
||||
|
||||
size_t proposed_alloc;
|
||||
void* new_block;
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT(blockP != NULL);
|
||||
|
||||
/* Check to see if we already have enough space. Maybe we'll get lucky. */
|
||||
if (size <= blockP->_allocated) {
|
||||
blockP->_size = size;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Calculate a new allocation size. */
|
||||
#ifdef EFENCE
|
||||
proposed_alloc = size;
|
||||
#else
|
||||
proposed_alloc = blockP->_allocated;
|
||||
while (proposed_alloc < size && proposed_alloc <= BLOCK_ALLOC_MAX)
|
||||
proposed_alloc *= 2;
|
||||
#endif /* DEBUG_MEM_ERRORS */
|
||||
|
||||
if (proposed_alloc > BLOCK_ALLOC_MAX)
|
||||
XMLRPC_FAIL(envP, XMLRPC_INTERNAL_ERROR, "Memory block too large");
|
||||
|
||||
/* Allocate our new memory block. */
|
||||
new_block = (void*) malloc(proposed_alloc);
|
||||
XMLRPC_FAIL_IF_NULL(new_block, envP, XMLRPC_INTERNAL_ERROR,
|
||||
"Can't resize memory block");
|
||||
|
||||
/* Copy over our data and update the xmlrpc_mem_block struct. */
|
||||
memcpy(new_block, blockP->_block, blockP->_size);
|
||||
free(blockP->_block);
|
||||
blockP->_block = new_block;
|
||||
blockP->_size = size;
|
||||
blockP->_allocated = proposed_alloc;
|
||||
|
||||
cleanup:
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_mem_block_append(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const blockP,
|
||||
const void * const data,
|
||||
size_t const len) {
|
||||
|
||||
int size;
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT(blockP != NULL);
|
||||
|
||||
size = blockP->_size;
|
||||
xmlrpc_mem_block_resize(envP, blockP, size + len);
|
||||
XMLRPC_FAIL_IF_FAULT(envP);
|
||||
|
||||
memcpy(((unsigned char*) blockP->_block) + size, data, len);
|
||||
|
||||
cleanup:
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE.
|
||||
*/
|
59
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/select.c
Normal file
59
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/select.c
Normal file
@ -0,0 +1,59 @@
|
||||
#define _XOPEN_SOURCE 600 /* Get pselect() in <sys/select.h> */
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock.h>
|
||||
#else
|
||||
/* In some systems (SUS), the select() interface comes from <sys/time.h>;
|
||||
in others, from <sys/select.h>, and other from both. Including both
|
||||
in this order appears to work on all.
|
||||
*/
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
|
||||
#include "xmlrpc-c/select_int.h"
|
||||
|
||||
|
||||
/* xmlrpc_pselect() is just for use with sockets. In a POSIX system,
|
||||
it technically works for any file descriptor, but in Windows, select()
|
||||
is part of the socket facility.
|
||||
*/
|
||||
|
||||
int
|
||||
xmlrpc_pselect(int const n,
|
||||
fd_set * const readfdsP,
|
||||
fd_set * const writefdsP,
|
||||
fd_set * const exceptfdsP,
|
||||
const xmlrpc_timespec * const timeoutP,
|
||||
sigset_t * const sigmaskP) {
|
||||
|
||||
int retval;
|
||||
|
||||
#if HAVE_PSELECT
|
||||
#if !HAVE_TIMESPEC
|
||||
#error "Impossible configuration -- has pselect(), but not struct timespec"
|
||||
#else
|
||||
retval = pselect(n, readfdsP, writefdsP, exceptfdsP, timeoutP, sigmaskP);
|
||||
#endif
|
||||
#else /* HAVE_PSELECT */
|
||||
struct timeval timeout;
|
||||
|
||||
timeout.tv_sec = timeoutP->tv_sec;
|
||||
timeout.tv_usec = timeoutP->tv_nsec/1000;
|
||||
#ifdef WIN32
|
||||
retval = select(n, readfdsP, writefdsP, exceptfdsP, &timeout);
|
||||
#else
|
||||
{
|
||||
sigset_t origmask;
|
||||
sigprocmask(SIG_SETMASK, sigmaskP, &origmask);
|
||||
retval = select(n, readfdsP, writefdsP, exceptfdsP, &timeout);
|
||||
sigprocmask(SIG_SETMASK, &origmask, NULL);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
}
|
21
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/sleep.c
Normal file
21
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/sleep.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include "bool.h"
|
||||
|
||||
#include "xmlrpc-c/sleep_int.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_millisecond_sleep(unsigned int const milliseconds) {
|
||||
|
||||
#ifdef WIN32
|
||||
SleepEx(milliseconds, true);
|
||||
#else
|
||||
usleep(milliseconds * 1000);
|
||||
#endif
|
||||
}
|
173
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/time.c
Normal file
173
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/time.c
Normal file
@ -0,0 +1,173 @@
|
||||
#include "xmlrpc_config.h"
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
|
||||
#if !MSVCRT
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if MSVCRT
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "xmlrpc-c/string_int.h"
|
||||
#include "xmlrpc-c/time_int.h"
|
||||
|
||||
|
||||
/* A note about struct timeval and Windows: There is a 'struct
|
||||
timeval' type in Windows, but it is just an argument to select(),
|
||||
which is just part of the sockets interface. It's defined
|
||||
identically to the POSIX type of the same name, but not meant for
|
||||
general timekeeping as the POSIX type is.
|
||||
*/
|
||||
|
||||
#if HAVE_GETTIMEOFDAY
|
||||
static void
|
||||
gettimeofdayPosix(xmlrpc_timespec * const todP) {
|
||||
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
todP->tv_sec = tv.tv_sec;
|
||||
todP->tv_nsec = tv.tv_usec * 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if MSVCRT
|
||||
static void
|
||||
gettimeofdayWindows(xmlrpc_timespec * const todP) {
|
||||
|
||||
__int64 const epochOffset = 116444736000000000i64;
|
||||
/* Number of 100-nanosecond units between the beginning of the
|
||||
Windows epoch (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970).
|
||||
*/
|
||||
FILETIME ft;
|
||||
LARGE_INTEGER li;
|
||||
__int64 t;
|
||||
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
li.LowPart = ft.dwLowDateTime;
|
||||
li.HighPart = ft.dwHighDateTime;
|
||||
t = (li.QuadPart - epochOffset) * 100; /* nanoseconds */
|
||||
todP->tv_sec = (long)(t / 1E9);
|
||||
todP->tv_nsec = (long)(t - (__int64)todP->tv_sec * 1E9);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_gettimeofday(xmlrpc_timespec * const todP) {
|
||||
|
||||
assert(todP);
|
||||
|
||||
#if HAVE_GETTIMEOFDAY
|
||||
gettimeofdayPosix(todP);
|
||||
#else
|
||||
#if MSVCRT
|
||||
gettimeofdayWindows(todP);
|
||||
#else
|
||||
#error "We don't know how to get the time of day on this system"
|
||||
#endif
|
||||
#endif /* HAVE_GETTIMEOFDAY */
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool
|
||||
isLeapYear(unsigned int const yearOfAd) {
|
||||
|
||||
return
|
||||
(yearOfAd % 4) == 0 &&
|
||||
((yearOfAd % 100) != 0 || (yearOfAd % 400) == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_timegm(const struct tm * const tmP,
|
||||
time_t * const timeValueP,
|
||||
const char ** const errorP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
This does what GNU libc's timegm() does.
|
||||
-----------------------------------------------------------------------------*/
|
||||
if (tmP->tm_year < 70 ||
|
||||
tmP->tm_mon > 11 ||
|
||||
tmP->tm_mon < 0 ||
|
||||
tmP->tm_mday > 31 ||
|
||||
tmP->tm_min > 60 ||
|
||||
tmP->tm_sec > 60 ||
|
||||
tmP->tm_hour > 24) {
|
||||
|
||||
xmlrpc_asprintf(errorP, "Invalid time specification; a member "
|
||||
"of struct tm is out of range");
|
||||
} else {
|
||||
static unsigned int const monthDaysNonLeap[12] =
|
||||
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
|
||||
unsigned int totalDays;
|
||||
unsigned int year;
|
||||
unsigned int month;
|
||||
|
||||
totalDays = 0; /* initial value */
|
||||
|
||||
for (year = 70; year < (unsigned int)tmP->tm_year; ++year)
|
||||
totalDays += isLeapYear(1900 + year) ? 366 : 365;
|
||||
|
||||
for (month = 0; month < (unsigned int)tmP->tm_mon; ++month)
|
||||
totalDays += monthDaysNonLeap[month];
|
||||
|
||||
if (tmP->tm_mon > 1 && isLeapYear(1900 + tmP->tm_year))
|
||||
totalDays += 1;
|
||||
|
||||
totalDays += tmP->tm_mday - 1;
|
||||
|
||||
*errorP = NULL;
|
||||
|
||||
*timeValueP = ((totalDays * 24 +
|
||||
tmP->tm_hour) * 60 +
|
||||
tmP->tm_min) * 60 +
|
||||
tmP->tm_sec;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_localtime(time_t const datetime,
|
||||
struct tm * const tmP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Convert datetime from standard to broken-down format in the local
|
||||
time zone.
|
||||
|
||||
For Windows, this is not thread-safe. If you run a version of Abyss
|
||||
with multiple threads, you can get arbitrary results here.
|
||||
-----------------------------------------------------------------------------*/
|
||||
#if HAVE_LOCALTIME_R
|
||||
localtime_r(&datetime, tmP);
|
||||
#else
|
||||
*tmP = *localtime(&datetime);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_gmtime(time_t const datetime,
|
||||
struct tm * const resultP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Convert datetime from standard to broken-down UTC format.
|
||||
|
||||
For Windows, this is not thread-safe. If you run a version of Abyss
|
||||
with multiple threads, you can get arbitrary results here.
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#if HAVE_GMTIME_R
|
||||
gmtime_r(&datetime, resultP);
|
||||
#else
|
||||
*resultP = *gmtime(&datetime);
|
||||
#endif
|
||||
}
|
510
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/utf8.c
Normal file
510
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/libutil/utf8.c
Normal file
@ -0,0 +1,510 @@
|
||||
/* Copyright (C) 2001 by Eric Kidd. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE. */
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** XML-RPC UTF-8 Utilities
|
||||
**=========================================================================
|
||||
** Routines for validating, encoding and decoding UTF-8 data. We try to
|
||||
** be very, very strict about invalid UTF-8 data.
|
||||
**
|
||||
** All of the code in this file assumes that your machine represents
|
||||
** wchar_t as a 16-bit (or wider) character containing UCS-2 data. If this
|
||||
** assumption is incorrect, you may need to replace this file.
|
||||
**
|
||||
** For lots of information on Unicode and UTF-8 decoding, see:
|
||||
** http://www.cl.cam.ac.uk/~mgk25/unicode.html
|
||||
*/
|
||||
|
||||
#include "int.h"
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
#include "bool.h"
|
||||
#include "xmlrpc-c/base.h"
|
||||
|
||||
/*=========================================================================
|
||||
** Tables and Constants
|
||||
**=========================================================================
|
||||
** We use a variety of tables and constants to help decode and validate
|
||||
** UTF-8 data.
|
||||
*/
|
||||
|
||||
/* The number of bytes in a UTF-8 sequence starting with the character used
|
||||
** as the array index. A zero entry indicates an illegal initial byte.
|
||||
** This table was generated using a Perl script and information from the
|
||||
** UTF-8 standard.
|
||||
**
|
||||
** Fredrik Lundh's UTF-8 decoder Python 2.0 uses a similar table. But
|
||||
** since Python 2.0 has the icky CNRI license, I regenerated this
|
||||
** table from scratch and wrote my own decoder. */
|
||||
static unsigned char utf8_seq_length[256] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0
|
||||
};
|
||||
|
||||
/* The minimum legal character value for a UTF-8 sequence of the given
|
||||
** length. We have to check this to avoid accepting "overlong" UTF-8
|
||||
** sequences, which use more bytes than necessary to encode a given
|
||||
** character. Such sequences are commonly used by evil people to bypass
|
||||
** filters and security checks. This table is based on the UTF-8-test.txt
|
||||
** file by Markus Kuhn <mkuhn@acm.org>. */
|
||||
static uint32_t const utf8_min_char_for_length[] = {
|
||||
0, /* Length 0: Not used (meaningless) */
|
||||
0x0000, /* Length 1: Not used (special-cased) */
|
||||
0x0080, /* Length 2 */
|
||||
0x0800, /* Length 3 */
|
||||
0x00010000, /* Length 4 */
|
||||
0x00200000, /* Length 5 */
|
||||
0x04000000 /* Length 6 */
|
||||
};
|
||||
|
||||
/* This is the maximum legal 16-byte (UCS-2) character. Again, this
|
||||
** information is based on UTF-8-test.txt. */
|
||||
#define UCS2_MAX_LEGAL_CHARACTER (0xFFFD)
|
||||
|
||||
/* First and last UTF-16 surrogate characters. These are *not* legal UCS-2
|
||||
** characters--they're used to code for UCS-4 characters when using
|
||||
** UTF-16. They should never appear in decoded UTF-8 data! Again, these
|
||||
** could hypothetically be used to bypass security measures on some machines.
|
||||
** Based on UTF-8-test.txt. */
|
||||
#define UTF16_FIRST_SURROGATE (0xD800)
|
||||
#define UTF16_LAST_SURROGATE (0xDFFF)
|
||||
|
||||
/* Is the character 'c' a UTF-8 continuation character? */
|
||||
#define IS_CONTINUATION(c) (((c) & 0xC0) == 0x80)
|
||||
|
||||
#define MAX_ENCODED_BYTES (3)
|
||||
/* Maximum number of bytes needed to encode in UTF-8 a character
|
||||
in the Basic Multilingual Plane.
|
||||
*/
|
||||
|
||||
|
||||
#if HAVE_UNICODE_WCHAR
|
||||
|
||||
|
||||
static void
|
||||
decode_utf8(xmlrpc_env * const envP,
|
||||
const char * const utf8_data,
|
||||
size_t const utf8_len,
|
||||
wchar_t * const ioBuff,
|
||||
size_t * const outBuffLenP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Decode to UCS-2 (or validates as UTF-8 that can be decoded to UCS-2)
|
||||
a UTF-8 string. To validate, set ioBuff and outBuffLenP to NULL.
|
||||
To decode, allocate a sufficiently large buffer, pass it as ioBuff,
|
||||
and pass a pointer as as outBuffLenP. The data will be written to
|
||||
the buffer, and the length to outBuffLenP.
|
||||
|
||||
We assume that wchar_t holds a single UCS-2 character in native-endian
|
||||
byte ordering.
|
||||
-----------------------------------------------------------------------------*/
|
||||
size_t i, length, out_pos;
|
||||
char init, con1, con2;
|
||||
wchar_t wc;
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT_PTR_OK(utf8_data);
|
||||
XMLRPC_ASSERT((!ioBuff && !outBuffLenP) ||
|
||||
(ioBuff && outBuffLenP));
|
||||
|
||||
/* Suppress GCC warning about possibly undefined variable. */
|
||||
wc = 0;
|
||||
|
||||
i = 0;
|
||||
out_pos = 0;
|
||||
while (i < utf8_len) {
|
||||
init = utf8_data[i];
|
||||
if ((init & 0x80) == 0x00) {
|
||||
/* Convert ASCII character to wide character. */
|
||||
wc = init;
|
||||
i++;
|
||||
} else {
|
||||
/* Look up the length of this UTF-8 sequence. */
|
||||
length = utf8_seq_length[(unsigned char) init];
|
||||
|
||||
/* Check to make sure we have enough bytes to convert. */
|
||||
if (i + length > utf8_len)
|
||||
XMLRPC_FAIL(envP, XMLRPC_INVALID_UTF8_ERROR,
|
||||
"Truncated UTF-8 sequence");
|
||||
|
||||
/* Decode a multibyte UTF-8 sequence. */
|
||||
switch (length) {
|
||||
case 0:
|
||||
XMLRPC_FAIL(envP, XMLRPC_INVALID_UTF8_ERROR,
|
||||
"Invalid UTF-8 initial byte");
|
||||
|
||||
case 2:
|
||||
/* 110xxxxx 10xxxxxx */
|
||||
con1 = utf8_data[i+1];
|
||||
if (!IS_CONTINUATION(con1))
|
||||
XMLRPC_FAIL(envP, XMLRPC_INVALID_UTF8_ERROR,
|
||||
"UTF-8 sequence too short");
|
||||
wc = ((((wchar_t) (init & 0x1F)) << 6) |
|
||||
(((wchar_t) (con1 & 0x3F))));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
/* 1110xxxx 10xxxxxx 10xxxxxx */
|
||||
con1 = utf8_data[i+1];
|
||||
con2 = utf8_data[i+2];
|
||||
if (!IS_CONTINUATION(con1) || !IS_CONTINUATION(con2))
|
||||
XMLRPC_FAIL(envP, XMLRPC_INVALID_UTF8_ERROR,
|
||||
"UTF-8 sequence too short");
|
||||
wc = ((((wchar_t) (init & 0x0F)) << 12) |
|
||||
(((wchar_t) (con1 & 0x3F)) << 6) |
|
||||
(((wchar_t) (con2 & 0x3F))));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
/* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
|
||||
case 5:
|
||||
/* 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
|
||||
case 6:
|
||||
/* 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
|
||||
/* This would require more than 16 bits in UTF-16, so
|
||||
it can't be represented in UCS-2, so it's beyond
|
||||
our capability. Characters in the BMP fit in 16
|
||||
bits.
|
||||
*/
|
||||
xmlrpc_env_set_fault_formatted(
|
||||
envP, XMLRPC_INVALID_UTF8_ERROR,
|
||||
"UTF-8 string contains a character not in the "
|
||||
"Basic Multilingual Plane (first byte %08x)",
|
||||
init);
|
||||
goto cleanup;
|
||||
|
||||
default:
|
||||
XMLRPC_ASSERT("Error in UTF-8 decoder tables");
|
||||
}
|
||||
|
||||
/* Advance to the end of the sequence. */
|
||||
i += length;
|
||||
|
||||
/* Check for illegal UCS-2 characters. */
|
||||
if (wc > UCS2_MAX_LEGAL_CHARACTER)
|
||||
XMLRPC_FAIL(envP, XMLRPC_INVALID_UTF8_ERROR,
|
||||
"UCS-2 characters > U+FFFD are illegal");
|
||||
|
||||
/* Check for UTF-16 surrogates. */
|
||||
if (UTF16_FIRST_SURROGATE <= wc && wc <= UTF16_LAST_SURROGATE)
|
||||
XMLRPC_FAIL(envP, XMLRPC_INVALID_UTF8_ERROR,
|
||||
"UTF-16 surrogates may not appear in UTF-8 data");
|
||||
|
||||
/* Check for overlong sequences. */
|
||||
if ((uint32_t)wc < utf8_min_char_for_length[length])
|
||||
XMLRPC_FAIL(envP, XMLRPC_INVALID_UTF8_ERROR,
|
||||
"Overlong UTF-8 sequence not allowed");
|
||||
}
|
||||
|
||||
/* If we have a buffer, write our character to it. */
|
||||
if (ioBuff) {
|
||||
ioBuff[out_pos++] = wc;
|
||||
}
|
||||
}
|
||||
|
||||
/* Record the number of characters we found. */
|
||||
if (outBuffLenP)
|
||||
*outBuffLenP = out_pos;
|
||||
|
||||
cleanup:
|
||||
if (envP->fault_occurred) {
|
||||
if (outBuffLenP)
|
||||
*outBuffLenP = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_utf8_to_wcs(xmlrpc_env * const envP,
|
||||
const char * const utf8_data,
|
||||
size_t const utf8_len) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Decode UTF-8 string to a "wide character string". This function
|
||||
returns an xmlrpc_mem_block with an element type of wchar_t. Don't
|
||||
try to intepret the block in a bytewise fashion--it won't work in
|
||||
any useful or portable fashion.
|
||||
|
||||
For backward compatibility, we return a meaningful value even when we
|
||||
fail. We return NULL when we fail.
|
||||
-----------------------------------------------------------------------------*/
|
||||
xmlrpc_mem_block * wcsP;
|
||||
size_t wcs_length;
|
||||
|
||||
/* Allocate a memory block large enough to hold any possible output.
|
||||
We assume that each byte of the input may decode to a whcar_t.
|
||||
*/
|
||||
wcsP = XMLRPC_MEMBLOCK_NEW(wchar_t, envP, utf8_len);
|
||||
if (!envP->fault_occurred) {
|
||||
/* Decode the UTF-8 data. */
|
||||
decode_utf8(envP, utf8_data, utf8_len,
|
||||
XMLRPC_MEMBLOCK_CONTENTS(wchar_t, wcsP),
|
||||
&wcs_length);
|
||||
if (!envP->fault_occurred) {
|
||||
/* We can't have overrun our buffer. */
|
||||
XMLRPC_ASSERT(wcs_length <= utf8_len);
|
||||
|
||||
/* Correct the length of the memory block. */
|
||||
XMLRPC_MEMBLOCK_RESIZE(wchar_t, envP, wcsP, wcs_length);
|
||||
}
|
||||
if (envP->fault_occurred)
|
||||
XMLRPC_MEMBLOCK_FREE(wchar_t, wcsP);
|
||||
}
|
||||
if (envP->fault_occurred)
|
||||
return NULL;
|
||||
else
|
||||
return wcsP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_wcs_to_utf8(xmlrpc_env * const envP,
|
||||
const wchar_t * const wcs_data,
|
||||
size_t const wcs_len) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Encode a "wide character string" as UTF-8.
|
||||
|
||||
For backward compatibility, we return a meaningful value even when we
|
||||
fail. We return NULL when we fail.
|
||||
-----------------------------------------------------------------------------*/
|
||||
size_t const estimate = wcs_len * MAX_ENCODED_BYTES;
|
||||
/* Our conservative estimate of how big the output will be;
|
||||
i.e. we know it won't be larger than this. For the estimate,
|
||||
we assume that every wchar might encode to the maximum length.
|
||||
*/
|
||||
xmlrpc_mem_block * utf8P;
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT_PTR_OK(wcs_data);
|
||||
|
||||
utf8P = XMLRPC_MEMBLOCK_NEW(char, envP, estimate);
|
||||
if (!envP->fault_occurred) {
|
||||
unsigned char * const buffer =
|
||||
XMLRPC_MEMBLOCK_CONTENTS(unsigned char, utf8P);
|
||||
size_t bytesUsed;
|
||||
size_t i;
|
||||
|
||||
bytesUsed = 0;
|
||||
for (i = 0; i < wcs_len && !envP->fault_occurred; ++i) {
|
||||
wchar_t const wc = wcs_data[i];
|
||||
if (wc <= 0x007F)
|
||||
buffer[bytesUsed++] = wc & 0x7F;
|
||||
else if (wc <= 0x07FF) {
|
||||
/* 110xxxxx 10xxxxxx */
|
||||
buffer[bytesUsed++] = 0xC0 | (wc >> 6);
|
||||
buffer[bytesUsed++] = 0x80 | (wc & 0x3F);
|
||||
} else if (wc <= 0xFFFF) {
|
||||
/* 1110xxxx 10xxxxxx 10xxxxxx */
|
||||
buffer[bytesUsed++] = 0xE0 | (wc >> 12);
|
||||
buffer[bytesUsed++] = 0x80 | ((wc >> 6) & 0x3F);
|
||||
buffer[bytesUsed++] = 0x80 | (wc & 0x3F);
|
||||
} else
|
||||
xmlrpc_faultf(envP,
|
||||
"Don't know how to encode UCS-4 characters yet");
|
||||
}
|
||||
if (!envP->fault_occurred) {
|
||||
XMLRPC_ASSERT(bytesUsed <= estimate);
|
||||
|
||||
XMLRPC_MEMBLOCK_RESIZE(char, envP, utf8P, bytesUsed);
|
||||
}
|
||||
if (envP->fault_occurred)
|
||||
XMLRPC_MEMBLOCK_FREE(char, utf8P);
|
||||
}
|
||||
|
||||
if (envP->fault_occurred)
|
||||
return NULL;
|
||||
else
|
||||
return utf8P;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else /* HAVE_UNICODE_WCHAR */
|
||||
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_utf8_to_wcs(xmlrpc_env * const envP,
|
||||
const char * const utf8_data ATTR_UNUSED,
|
||||
size_t const utf8_len ATTR_UNUSED) {
|
||||
|
||||
xmlrpc_faultf(envP, "INTERNAL ERROR: xmlrpc_utf8_to_wcs() called "
|
||||
"on a system that doesn't do Unicode!");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif /* HAVE_UNICODE_WCHAR */
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_force_to_utf8(char * const buffer) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Force the contents of 'buffer' to be valid UTF-8, any way possible.
|
||||
The buffer ends with a NUL character, and the mutation does not make
|
||||
it longer.
|
||||
|
||||
The most common reason for a string that's supposed to be UTF-8 not
|
||||
to be UTF-8 is that it was supposed to be ASCII but instead
|
||||
includes garbage with the high bit on (ASCII characters always have
|
||||
the high bit off), or maybe a primitive 8-bit ASCII extension.
|
||||
Therefore, we force it to UTF-8 by replacing some bytes that have
|
||||
the high bit set with DEL (0x7F). That would leave the other
|
||||
characters meaningful.
|
||||
-----------------------------------------------------------------------------*/
|
||||
char * p;
|
||||
|
||||
for (p = &buffer[0]; *p;) {
|
||||
unsigned int const length = utf8_seq_length[(unsigned char) *p];
|
||||
|
||||
bool forceDel;
|
||||
uint32_t decoded;
|
||||
|
||||
forceDel = false;
|
||||
decoded = 0; /* suppress compiler warning; valid when !forceDel */
|
||||
|
||||
switch (length) {
|
||||
case 1:
|
||||
/* One-byte UTF-8 characters are easy. */
|
||||
decoded = *p;
|
||||
break;
|
||||
case 2:
|
||||
/* 110xxxxx 10xxxxxx */
|
||||
if (!*(p+1) || !(*p+2))
|
||||
forceDel = true;
|
||||
else if (!IS_CONTINUATION(*(p+1)))
|
||||
forceDel = true;
|
||||
else
|
||||
decoded =
|
||||
((uint32_t)(*(p+0) & 0x1F) << 6) |
|
||||
((uint32_t)(*(p+1) & 0x3F) << 0);
|
||||
break;
|
||||
case 3:
|
||||
/* 1110xxxx 10xxxxxx 10xxxxxx */
|
||||
if (!*(p+1) || !(*p+2) || !(*p+3))
|
||||
forceDel = true;
|
||||
else if (!IS_CONTINUATION(*(p+1)) || !IS_CONTINUATION(*(p+2)))
|
||||
forceDel = true;
|
||||
else
|
||||
decoded =
|
||||
((uint32_t)(*(p+0) & 0x0F) << 12) |
|
||||
((uint32_t)(*(p+1) & 0x3F) << 6) |
|
||||
((uint32_t)(*(p+2) & 0x3F) << 0);
|
||||
break;
|
||||
default:
|
||||
forceDel = true;
|
||||
}
|
||||
|
||||
if (!forceDel) {
|
||||
if (decoded > UCS2_MAX_LEGAL_CHARACTER)
|
||||
forceDel = true;
|
||||
else if (UTF16_FIRST_SURROGATE <= decoded &&
|
||||
decoded <= UTF16_LAST_SURROGATE)
|
||||
forceDel = true;
|
||||
else if (decoded < utf8_min_char_for_length[length])
|
||||
forceDel = true;
|
||||
}
|
||||
|
||||
if (forceDel) {
|
||||
/* Not a valid UTF-8 character, so replace the first byte
|
||||
with a nice simple ASCII DEL.
|
||||
*/
|
||||
*p = 0x7F;
|
||||
p += 1;
|
||||
} else
|
||||
p += length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_force_to_xml_chars(char * const buffer) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Modify 'buffer' so that it contains nothing but valid XML
|
||||
characters. The buffer ends with a NUL character, and the mutation
|
||||
does not make it longer.
|
||||
|
||||
Note that the valid characters in an XML document are all Unicode
|
||||
codepoints except the ASCII control characters, plus CR, LF, and
|
||||
Tab.
|
||||
|
||||
We change all non-XML characters to DEL (0x7F).
|
||||
|
||||
Assume input is valid UTF-8.
|
||||
-----------------------------------------------------------------------------*/
|
||||
char * p;
|
||||
|
||||
for (p = &buffer[0]; *p;) {
|
||||
unsigned int const length = utf8_seq_length[(unsigned char) *p];
|
||||
|
||||
if (length == 1) {
|
||||
if (*p < 0x20 && *p != '\r' && *p != '\n' && *p != '\t')
|
||||
/* Not valid XML. Force to DEL */
|
||||
*p = 0x7f;
|
||||
} else {
|
||||
/* We assume here that all other UTF-8 characters are
|
||||
valid XML, but it's apparently not actually true.
|
||||
*/
|
||||
}
|
||||
|
||||
{
|
||||
unsigned int i;
|
||||
/* Advance to next UTF-8 character */
|
||||
for (i = 0; i < length && *p; ++i)
|
||||
++p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_validate_utf8(xmlrpc_env * const env,
|
||||
const char * const utf8_data,
|
||||
size_t const utf8_len) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Validate that a string is valid UTF-8.
|
||||
-----------------------------------------------------------------------------*/
|
||||
#if HAVE_UNICODE_WCHAR
|
||||
decode_utf8(env, utf8_data, utf8_len, NULL, NULL);
|
||||
#else
|
||||
/* We don't have a convenient way to validate, so we just fake it and
|
||||
call it valid.
|
||||
*/
|
||||
#endif
|
||||
}
|
93
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/util/casprintf.c
Normal file
93
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/util/casprintf.c
Normal file
@ -0,0 +1,93 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "xmlrpc_config.h" /* For HAVE_ASPRINTF, __inline__ */
|
||||
#include "casprintf.h"
|
||||
|
||||
|
||||
|
||||
static __inline__ void
|
||||
simpleVasprintf(char ** const retvalP,
|
||||
const char * const fmt,
|
||||
va_list varargs) {
|
||||
/*----------------------------------------------------------------------------
|
||||
This is a poor man's implementation of vasprintf(), of GNU fame.
|
||||
-----------------------------------------------------------------------------*/
|
||||
size_t const initialSize = 4096;
|
||||
char * result;
|
||||
|
||||
result = malloc(initialSize);
|
||||
if (result != NULL) {
|
||||
size_t bytesNeeded;
|
||||
bytesNeeded = XMLRPC_VSNPRINTF(result, initialSize, fmt, varargs);
|
||||
if (bytesNeeded > initialSize) {
|
||||
free(result);
|
||||
result = malloc(bytesNeeded);
|
||||
if (result != NULL)
|
||||
XMLRPC_VSNPRINTF(result, bytesNeeded, fmt, varargs);
|
||||
} else if (bytesNeeded == initialSize) {
|
||||
if (result[initialSize-1] != '\0') {
|
||||
/* This is one of those old systems where vsnprintf()
|
||||
returns the number of bytes it used, instead of the
|
||||
number that it needed, and it in fact needed more than
|
||||
we gave it. Rather than mess with this highly unlikely
|
||||
case (old system and string > 4095 characters), we just
|
||||
treat this like an out of memory failure.
|
||||
*/
|
||||
free(result);
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
*retvalP = result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char * const strsol = "[Insufficient memory to build string]";
|
||||
|
||||
|
||||
|
||||
void
|
||||
cvasprintf(const char ** const retvalP,
|
||||
const char * const fmt,
|
||||
va_list varargs) {
|
||||
|
||||
char * string;
|
||||
|
||||
#if HAVE_ASPRINTF
|
||||
vasprintf(&string, fmt, varargs);
|
||||
#else
|
||||
simpleVasprintf(&string, fmt, varargs);
|
||||
#endif
|
||||
|
||||
if (string == NULL)
|
||||
*retvalP = strsol;
|
||||
else
|
||||
*retvalP = string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GNU_PRINTF_ATTR(2,3)
|
||||
casprintf(const char ** const retvalP, const char * const fmt, ...) {
|
||||
|
||||
va_list varargs; /* mysterious structure used by variable arg facility */
|
||||
|
||||
va_start(varargs, fmt); /* start up the mysterious variable arg facility */
|
||||
|
||||
cvasprintf(retvalP, fmt, varargs);
|
||||
|
||||
va_end(varargs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
strfree(const char * const string) {
|
||||
|
||||
if (string != strsol)
|
||||
free((void *)string);
|
||||
}
|
587
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/util/cmdline_parser.c
Normal file
587
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/util/cmdline_parser.c
Normal file
@ -0,0 +1,587 @@
|
||||
#include "xmlrpc_config.h" /* prereq for mallocvar.h -- defines __inline__ */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "bool.h"
|
||||
#include "int.h"
|
||||
#include "mallocvar.h"
|
||||
#include "casprintf.h"
|
||||
#include "getoptx.h"
|
||||
#include "string_parser.h"
|
||||
|
||||
#include "cmdline_parser.h"
|
||||
|
||||
#define MAXOPTS 100
|
||||
|
||||
struct optionDesc {
|
||||
const char * name;
|
||||
enum optiontype type;
|
||||
bool present;
|
||||
union {
|
||||
unsigned int u;
|
||||
int i;
|
||||
const char * s;
|
||||
uint64_t llu;
|
||||
double d;
|
||||
} value;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct cmdlineParserCtl {
|
||||
struct optionDesc * optionDescArray;
|
||||
unsigned int numOptions;
|
||||
const char ** argumentArray;
|
||||
unsigned int numArguments;
|
||||
};
|
||||
|
||||
|
||||
|
||||
static struct optionx *
|
||||
createLongOptsArray(struct optionDesc * const optionDescArray,
|
||||
unsigned int const numOptions) {
|
||||
|
||||
struct optionx * longopts;
|
||||
|
||||
MALLOCARRAY(longopts, numOptions+1);
|
||||
if (longopts != NULL) {
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < numOptions; ++i) {
|
||||
longopts[i].name = optionDescArray[i].name;
|
||||
/* If the option takes a value, we say it is optional even
|
||||
though it never is. That's because if we say it is
|
||||
mandatory, getopt_long_only() pretends it doesn't even
|
||||
recognize the option if the user doesn't give a value.
|
||||
We prefer to generate a meaningful error message when
|
||||
the user omits a required option value.
|
||||
*/
|
||||
longopts[i].has_arg =
|
||||
optionDescArray[i].type == OPTTYPE_FLAG ?
|
||||
no_argument : optional_argument;
|
||||
longopts[i].flag = NULL;
|
||||
longopts[i].val = i;
|
||||
}
|
||||
longopts[numOptions].name = 0;
|
||||
longopts[numOptions].has_arg = 0;
|
||||
longopts[numOptions].flag = 0;
|
||||
longopts[numOptions].val = 0;
|
||||
}
|
||||
return longopts;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseInt(enum optiontype const type,
|
||||
const char * const optarg,
|
||||
unsigned int * const valueUintP,
|
||||
int * const valueIntP,
|
||||
const char ** const errorP) {
|
||||
|
||||
if (optarg == NULL)
|
||||
casprintf(errorP, "Option requires a value");
|
||||
else if (strlen(optarg) == 0)
|
||||
casprintf(errorP, "Numeric option value is null string");
|
||||
else {
|
||||
char * tailptr;
|
||||
long const longvalue = strtol(optarg, &tailptr, 10);
|
||||
|
||||
if (*tailptr != '\0')
|
||||
casprintf(errorP, "Non-numeric value "
|
||||
"for numeric option value: '%s'", optarg);
|
||||
else if (errno == ERANGE || longvalue > INT_MAX)
|
||||
casprintf(errorP, "Numeric value out of range: %s", optarg);
|
||||
else {
|
||||
if (type == OPTTYPE_UINT) {
|
||||
if (longvalue < 0)
|
||||
casprintf(errorP, "Unsigned numeric value is "
|
||||
"negative: %ld", longvalue);
|
||||
else {
|
||||
*errorP = NULL;
|
||||
*valueUintP = (unsigned int) longvalue;
|
||||
}
|
||||
} else {
|
||||
*errorP = NULL;
|
||||
*valueIntP = (int) longvalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseBinUint(const char * const optarg,
|
||||
uint64_t * const valueP,
|
||||
const char ** const errorP) {
|
||||
|
||||
if (optarg == NULL)
|
||||
casprintf(errorP, "Option requires a value");
|
||||
else if (strlen(optarg) == 0)
|
||||
casprintf(errorP, "Numeric option value is null string");
|
||||
else {
|
||||
const char * error;
|
||||
interpretBinUint(optarg, valueP, &error);
|
||||
|
||||
if (error) {
|
||||
casprintf(errorP, "Invalid numeric option value '%s'. %s",
|
||||
optarg, error);
|
||||
strfree(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseFloat(const char * const optarg,
|
||||
double * const valueP,
|
||||
const char ** const errorP) {
|
||||
|
||||
if (optarg == NULL)
|
||||
casprintf(errorP, "Option requires a value");
|
||||
else if (strlen(optarg) == 0)
|
||||
casprintf(errorP, "Numeric option value is null string");
|
||||
else {
|
||||
char * tailptr;
|
||||
double const doublevalue = strtod(optarg, &tailptr);
|
||||
|
||||
if (*tailptr != '\0')
|
||||
casprintf(errorP, "Non-numeric value "
|
||||
"for numeric option value: '%s'", optarg);
|
||||
else if (errno == ERANGE)
|
||||
casprintf(errorP, "Numeric value out of range: %s", optarg);
|
||||
else {
|
||||
*errorP = NULL;
|
||||
*valueP = doublevalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseOptionValue(const char * const optarg,
|
||||
struct optionDesc * const optionP,
|
||||
const char ** const errorP) {
|
||||
|
||||
switch (optionP->type) {
|
||||
case OPTTYPE_FLAG:
|
||||
*errorP = NULL;
|
||||
break;
|
||||
case OPTTYPE_INT:
|
||||
case OPTTYPE_UINT:
|
||||
parseInt(optionP->type, optarg, &optionP->value.u, &optionP->value.i,
|
||||
errorP);
|
||||
break;
|
||||
case OPTTYPE_STRING:
|
||||
if (optarg == NULL)
|
||||
casprintf(errorP, "Option requires a value");
|
||||
else {
|
||||
*errorP = NULL;
|
||||
optionP->value.s = strdup(optarg);
|
||||
}
|
||||
break;
|
||||
case OPTTYPE_BINUINT:
|
||||
parseBinUint(optarg, &optionP->value.llu, errorP);
|
||||
break;
|
||||
case OPTTYPE_FLOAT:
|
||||
parseFloat(optarg, &optionP->value.d, errorP);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
processOption(struct optionDesc * const optionP,
|
||||
const char * const optarg,
|
||||
const char ** const errorP) {
|
||||
|
||||
const char * error;
|
||||
|
||||
parseOptionValue(optarg, optionP, &error);
|
||||
if (error)
|
||||
casprintf(errorP, "Error in '%s' option: %s", optionP->name, error);
|
||||
else
|
||||
optionP->present = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
extractArguments(struct cmdlineParserCtl * const cpP,
|
||||
unsigned int const argc,
|
||||
const char ** const argv) {
|
||||
|
||||
cpP->numArguments = argc - getopt_argstart();
|
||||
MALLOCARRAY(cpP->argumentArray, cpP->numArguments);
|
||||
|
||||
if (cpP->argumentArray == NULL) {
|
||||
fprintf(stderr, "Unable to allocate memory for argument array "
|
||||
"(%u arguments)\n", cpP->numArguments);
|
||||
abort();
|
||||
} else {
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < cpP->numArguments; ++i) {
|
||||
cpP->argumentArray[i] = strdup(argv[getopt_argstart() + i]);
|
||||
if (cpP->argumentArray[i] == NULL) {
|
||||
fprintf(stderr, "Unable to allocate memory for Argument %u\n",
|
||||
i);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
cmd_processOptions(cmdlineParser const cpP,
|
||||
int const argc,
|
||||
const char ** const argv,
|
||||
const char ** const errorP) {
|
||||
|
||||
struct optionx * longopts;
|
||||
|
||||
longopts = createLongOptsArray(cpP->optionDescArray, cpP->numOptions);
|
||||
|
||||
if (longopts == NULL)
|
||||
casprintf(errorP, "Unable to get memory for longopts array");
|
||||
else {
|
||||
int endOfOptions;
|
||||
unsigned int i;
|
||||
|
||||
*errorP = NULL;
|
||||
|
||||
/* Set up initial assumption: No options present */
|
||||
|
||||
for (i = 0; i < cpP->numOptions; ++i)
|
||||
cpP->optionDescArray[i].present = false;
|
||||
|
||||
endOfOptions = false; /* initial value */
|
||||
|
||||
while (!endOfOptions && !*errorP) {
|
||||
int const opterr0 = 0;
|
||||
/* Don't let getopt_long_only() print an error message */
|
||||
unsigned int longoptsIndex;
|
||||
const char * unrecognizedOption;
|
||||
const char * optarg;
|
||||
|
||||
getopt_long_onlyx(argc, (char**) argv, "", longopts,
|
||||
&longoptsIndex, opterr0,
|
||||
&endOfOptions, &optarg, &unrecognizedOption);
|
||||
|
||||
if (unrecognizedOption)
|
||||
casprintf(errorP, "Unrecognized option: '%s'",
|
||||
unrecognizedOption);
|
||||
else {
|
||||
if (!endOfOptions)
|
||||
processOption(&cpP->optionDescArray[longoptsIndex], optarg,
|
||||
errorP);
|
||||
}
|
||||
}
|
||||
if (!*errorP)
|
||||
extractArguments(cpP, argc, argv);
|
||||
|
||||
free(longopts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
cmdlineParser
|
||||
cmd_createOptionParser(void) {
|
||||
|
||||
struct cmdlineParserCtl * cpP;
|
||||
|
||||
MALLOCVAR(cpP);
|
||||
|
||||
if (cpP != NULL) {
|
||||
struct optionDesc * optionDescArray;
|
||||
|
||||
cpP->numOptions = 0;
|
||||
MALLOCARRAY(optionDescArray, MAXOPTS);
|
||||
if (optionDescArray == NULL) {
|
||||
free(cpP);
|
||||
cpP = NULL;
|
||||
} else
|
||||
cpP->optionDescArray = optionDescArray;
|
||||
}
|
||||
return cpP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
cmd_destroyOptionParser(cmdlineParser const cpP) {
|
||||
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < cpP->numOptions; ++i) {
|
||||
struct optionDesc const option = cpP->optionDescArray[i];
|
||||
if (option.type == OPTTYPE_STRING && option.present)
|
||||
strfree(option.value.s);
|
||||
strfree(option.name);
|
||||
}
|
||||
|
||||
for (i = 0; i < cpP->numArguments; ++i)
|
||||
strfree(cpP->argumentArray[i]);
|
||||
|
||||
free(cpP->optionDescArray);
|
||||
free(cpP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
cmd_defineOption(cmdlineParser const cpP,
|
||||
const char * const name,
|
||||
enum optiontype const type) {
|
||||
|
||||
if (cpP->numOptions < MAXOPTS) {
|
||||
cpP->optionDescArray[cpP->numOptions].name = strdup(name);
|
||||
cpP->optionDescArray[cpP->numOptions].type = type;
|
||||
|
||||
++cpP->numOptions;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct optionDesc *
|
||||
findOptionDesc(struct cmdlineParserCtl * const cpP,
|
||||
const char * const name) {
|
||||
|
||||
struct optionDesc * retval;
|
||||
unsigned int i;
|
||||
|
||||
retval = NULL;
|
||||
|
||||
for (i = 0; i < cpP->numOptions && !retval; ++i)
|
||||
if (strcmp(cpP->optionDescArray[i].name, name) == 0)
|
||||
retval = &cpP->optionDescArray[i];
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
cmd_optionIsPresent(cmdlineParser const cpP,
|
||||
const char * const name) {
|
||||
|
||||
struct optionDesc * const optionDescP = findOptionDesc(cpP, name);
|
||||
|
||||
bool present;
|
||||
|
||||
if (!optionDescP) {
|
||||
fprintf(stderr, "cmdlineParser called incorrectly. "
|
||||
"optionIsPresent() called for undefined option '%s'\n",
|
||||
name);
|
||||
abort();
|
||||
} else
|
||||
present = optionDescP->present;
|
||||
|
||||
return present;
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int
|
||||
cmd_getOptionValueUint(cmdlineParser const cpP,
|
||||
const char * const name) {
|
||||
|
||||
struct optionDesc * const optionDescP = findOptionDesc(cpP, name);
|
||||
|
||||
unsigned int retval;
|
||||
|
||||
if (!optionDescP) {
|
||||
fprintf(stderr, "cmdlineParser called incorrectly. "
|
||||
"cmd_getOptionValueUint() called for undefined option '%s'\n",
|
||||
name);
|
||||
abort();
|
||||
} else {
|
||||
if (optionDescP->type != OPTTYPE_UINT) {
|
||||
fprintf(stderr, "cmdlineParser called incorrectly. "
|
||||
"cmd_getOptionValueUint() called for non-unsigned integer "
|
||||
"option '%s'\n", optionDescP->name);
|
||||
abort();
|
||||
} else {
|
||||
if (optionDescP->present)
|
||||
retval = optionDescP->value.u;
|
||||
else
|
||||
retval = 0;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
cmd_getOptionValueInt(cmdlineParser const cpP,
|
||||
const char * const name) {
|
||||
|
||||
struct optionDesc * const optionDescP = findOptionDesc(cpP, name);
|
||||
|
||||
int retval;
|
||||
|
||||
if (!optionDescP) {
|
||||
fprintf(stderr, "cmdlineParser called incorrectly. "
|
||||
"cmd_getOptionValueInt() called for undefined option '%s'\n",
|
||||
name);
|
||||
abort();
|
||||
} else {
|
||||
if (optionDescP->type != OPTTYPE_INT) {
|
||||
fprintf(stderr, "cmdlineParser called incorrectly. "
|
||||
"cmd_getOptionValueInt() called for non-integer "
|
||||
"option '%s'\n", optionDescP->name);
|
||||
abort();
|
||||
} else {
|
||||
if (optionDescP->present)
|
||||
retval = optionDescP->value.i;
|
||||
else
|
||||
retval = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
cmd_getOptionValueString(cmdlineParser const cpP,
|
||||
const char * const name) {
|
||||
|
||||
struct optionDesc * const optionDescP = findOptionDesc(cpP, name);
|
||||
|
||||
const char * retval;
|
||||
|
||||
if (!optionDescP) {
|
||||
fprintf(stderr, "cmdlineParser called incorrectly. "
|
||||
"cmd_getOptionValueString() called for "
|
||||
"undefined option '%s'\n",
|
||||
name);
|
||||
abort();
|
||||
} else {
|
||||
if (optionDescP->type != OPTTYPE_STRING) {
|
||||
fprintf(stderr, "cmdlineParser called incorrectly. "
|
||||
"getOptionValueString() called for non-string "
|
||||
"option '%s'\n", optionDescP->name);
|
||||
abort();
|
||||
} else {
|
||||
if (optionDescP->present) {
|
||||
retval = strdup(optionDescP->value.s);
|
||||
if (retval == NULL) {
|
||||
fprintf(stderr,
|
||||
"out of memory in cmd_getOptionValueString()\n");
|
||||
abort();
|
||||
}
|
||||
} else
|
||||
retval = NULL;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint64_t
|
||||
cmd_getOptionValueBinUint(cmdlineParser const cpP,
|
||||
const char * const name) {
|
||||
|
||||
struct optionDesc * const optionDescP = findOptionDesc(cpP, name);
|
||||
|
||||
uint64_t retval;
|
||||
|
||||
if (!optionDescP) {
|
||||
fprintf(stderr, "cmdlineParser called incorrectly. "
|
||||
"cmd_getOptionValueUint() called for undefined option '%s'\n",
|
||||
name);
|
||||
abort();
|
||||
} else {
|
||||
if (optionDescP->type != OPTTYPE_BINUINT) {
|
||||
fprintf(stderr, "cmdlineParser called incorrectly. "
|
||||
"cmd_getOptionValueBinUint() called for "
|
||||
"non-OPTTYPE_BINUINT "
|
||||
"option '%s'\n", optionDescP->name);
|
||||
abort();
|
||||
} else {
|
||||
if (optionDescP->present)
|
||||
retval = optionDescP->value.llu;
|
||||
else
|
||||
retval = 0;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
double
|
||||
cmd_getOptionValueFloat(cmdlineParser const cpP,
|
||||
const char * const name) {
|
||||
|
||||
struct optionDesc * const optionDescP = findOptionDesc(cpP, name);
|
||||
|
||||
double retval;
|
||||
|
||||
if (!optionDescP) {
|
||||
fprintf(stderr, "cmdlineParser called incorrectly. "
|
||||
"cmd_getOptionValueInt() called for undefined option '%s'\n",
|
||||
name);
|
||||
abort();
|
||||
} else {
|
||||
if (optionDescP->type != OPTTYPE_FLOAT) {
|
||||
fprintf(stderr, "cmdlineParser called incorrectly. "
|
||||
"cmd_getOptionValueInt() called for non-float "
|
||||
"option '%s'\n", optionDescP->name);
|
||||
abort();
|
||||
} else {
|
||||
if (optionDescP->present)
|
||||
retval = optionDescP->value.d;
|
||||
else
|
||||
retval = 0.0;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int
|
||||
cmd_argumentCount(cmdlineParser const cpP) {
|
||||
|
||||
return cpP->numArguments;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *
|
||||
cmd_getArgument(cmdlineParser const cpP,
|
||||
unsigned int const argNumber) {
|
||||
|
||||
const char * retval;
|
||||
|
||||
if (argNumber >= cpP->numArguments)
|
||||
retval = NULL;
|
||||
else {
|
||||
retval = strdup(cpP->argumentArray[argNumber]);
|
||||
|
||||
if (retval == NULL) {
|
||||
fprintf(stderr,
|
||||
"out of memory in cmd_getArgument()\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "girstring.h"
|
||||
#include "casprintf.h"
|
||||
#include "cmdline_parser.h"
|
||||
|
||||
#include "cmdline_parser.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
static enum optiontype
|
||||
optTypeConvert(
|
||||
CmdlineParser::optType const arg) {
|
||||
|
||||
enum optiontype retval;
|
||||
|
||||
retval = OPTTYPE_FLAG; // defeat compiler warning
|
||||
|
||||
switch (arg) {
|
||||
case CmdlineParser::FLAG: retval = OPTTYPE_FLAG; break;
|
||||
case CmdlineParser::INT: retval = OPTTYPE_INT; break;
|
||||
case CmdlineParser::UINT: retval = OPTTYPE_UINT; break;
|
||||
case CmdlineParser::STRING: retval = OPTTYPE_STRING; break;
|
||||
case CmdlineParser::BINUINT: retval = OPTTYPE_BINUINT; break;
|
||||
case CmdlineParser::FLOAT: retval = OPTTYPE_FLOAT; break;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CmdlineParser::CmdlineParser() {
|
||||
|
||||
this->cp = cmd_createOptionParser();
|
||||
}
|
||||
|
||||
|
||||
|
||||
CmdlineParser::~CmdlineParser() {
|
||||
cmd_destroyOptionParser(this->cp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
CmdlineParser::defineOption(
|
||||
string const optionName,
|
||||
optType const optionType) {
|
||||
|
||||
cmd_defineOption(this->cp, optionName.c_str(),
|
||||
optTypeConvert(optionType));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
CmdlineParser::processOptions(
|
||||
int const argc,
|
||||
const char ** const argv) {
|
||||
|
||||
const char * error;
|
||||
|
||||
cmd_processOptions(this->cp, argc, argv, &error);
|
||||
if (error) {
|
||||
string const errorS(error);
|
||||
strfree(error);
|
||||
throw(runtime_error(errorS));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
CmdlineParser::optionIsPresent(
|
||||
string const optionName) const {
|
||||
|
||||
return (cmd_optionIsPresent(this->cp, optionName.c_str()) ? true : false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
CmdlineParser::getOptionValueInt(
|
||||
string const optionName) const {
|
||||
|
||||
return cmd_getOptionValueInt(this->cp, optionName.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int
|
||||
CmdlineParser::getOptionValueUint(
|
||||
string const optionName) const {
|
||||
|
||||
return cmd_getOptionValueUint(this->cp, optionName.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned long long
|
||||
CmdlineParser::getOptionValueBinUint(
|
||||
string const optionName) const {
|
||||
|
||||
return cmd_getOptionValueBinUint(this->cp, optionName.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
double
|
||||
CmdlineParser::getOptionValueFloat(
|
||||
string const optionName) const {
|
||||
|
||||
return cmd_getOptionValueFloat(this->cp, optionName.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
string
|
||||
CmdlineParser::getOptionValueString(
|
||||
string const optionName) const {
|
||||
|
||||
const char * const value =
|
||||
cmd_getOptionValueString(this->cp, optionName.c_str());
|
||||
|
||||
string retval;
|
||||
|
||||
if (value) {
|
||||
retval = string(value);
|
||||
strfree(value);
|
||||
} else
|
||||
retval = "";
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int
|
||||
CmdlineParser::argumentCount() const {
|
||||
|
||||
return cmd_argumentCount(this->cp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
string
|
||||
CmdlineParser::getArgument(
|
||||
unsigned int const argNumber) const {
|
||||
|
||||
const char * const value = cmd_getArgument(this->cp, argNumber);
|
||||
string const retval(value);
|
||||
strfree(value);
|
||||
return retval;
|
||||
}
|
466
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/util/getoptx.c
Normal file
466
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/util/getoptx.c
Normal file
@ -0,0 +1,466 @@
|
||||
/* This version of `getopt' appears to the caller like standard Unix getopt()
|
||||
but it behaves differently for the user, since it allows the user
|
||||
to intersperse the options with the other arguments.
|
||||
|
||||
As getopt() works, it permutes the elements of `argv' so that,
|
||||
when it is done, all the options precede everything else. Thus
|
||||
all application programs are extended to handle flexible argument order.
|
||||
|
||||
Setting the environment variable _POSIX_OPTION_ORDER disables permutation.
|
||||
Then the behavior is completely standard.
|
||||
|
||||
GNU application programs can use a third alternative mode in which
|
||||
they can distinguish the relative order of options and other arguments.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "getoptx.h"
|
||||
|
||||
/* Note that on some systems, the header files above declare variables
|
||||
for use with their native getopt facilities, and those variables have
|
||||
the same names as we'd like to use. So we use things like optargx
|
||||
instead of optarg to avoid the collision.
|
||||
*/
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
*/
|
||||
static char *optargx = 0;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to getoptx().
|
||||
|
||||
On entry to getoptx(), zero means this is the first call; initialize.
|
||||
|
||||
When getoptx() returns EOF, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optindx' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far.
|
||||
*/
|
||||
|
||||
static int optindx = 0;
|
||||
|
||||
/* The next char to be scanned in the option-element
|
||||
in which the last option character we returned was found.
|
||||
This allows us to pick up the scan where we left off.
|
||||
|
||||
If this is zero, or a null string, it means resume the scan
|
||||
by advancing to the next ARGV-element. */
|
||||
|
||||
static char *nextchar;
|
||||
|
||||
/* Callers store zero here to inhibit the error message
|
||||
for unrecognized options.
|
||||
*/
|
||||
|
||||
static int opterrx;
|
||||
|
||||
/* Index in _GETOPT_LONG_OPTIONS of the long-named option actually found.
|
||||
Only valid when a long-named option was found. */
|
||||
|
||||
static int option_index;
|
||||
|
||||
struct optionx * _getopt_long_options;
|
||||
|
||||
/* Handle permutation of arguments. */
|
||||
|
||||
/* Describe the part of ARGV that contains non-options that have
|
||||
been skipped. `first_nonopt' is the index in ARGV of the first of them;
|
||||
`last_nonopt' is the index after the last of them. */
|
||||
|
||||
static int first_nonopt;
|
||||
static int last_nonopt;
|
||||
|
||||
/* Exchange two adjacent subsequences of ARGV.
|
||||
One subsequence is elements [first_nonopt,last_nonopt)
|
||||
which contains all the non-options that have been skipped so far.
|
||||
The other is elements [last_nonopt,optindx), which contains all
|
||||
the options processed since those non-options were skipped.
|
||||
|
||||
`first_nonopt' and `last_nonopt' are relocated so that they describe
|
||||
the new indices of the non-options in ARGV after they are moved. */
|
||||
|
||||
static void
|
||||
exchange(char ** const argv) {
|
||||
unsigned int const nonopts_size =
|
||||
(last_nonopt - first_nonopt) * sizeof (char *);
|
||||
char **temp = (char **) malloc (nonopts_size);
|
||||
|
||||
if (temp == NULL)
|
||||
abort();
|
||||
|
||||
/* Interchange the two blocks of data in argv. */
|
||||
|
||||
memcpy (temp, &argv[first_nonopt], nonopts_size);
|
||||
memcpy (&argv[first_nonopt], &argv[last_nonopt],
|
||||
(optindx - last_nonopt) * sizeof (char *));
|
||||
memcpy (&argv[first_nonopt + optindx - last_nonopt], temp,
|
||||
nonopts_size);
|
||||
|
||||
/* Update records for the slots the non-options now occupy. */
|
||||
|
||||
first_nonopt += (optindx - last_nonopt);
|
||||
last_nonopt = optindx;
|
||||
|
||||
free(temp);
|
||||
}
|
||||
|
||||
/* Scan elements of ARGV (whose length is ARGC) for option characters
|
||||
given in OPTSTRING.
|
||||
|
||||
If an element of ARGV starts with '-', and is not exactly "-" or "--",
|
||||
then it is an option element. The characters of this element
|
||||
(aside from the initial '-') are option characters. If getoptx()
|
||||
is called repeatedly, it returns successively each of the option characters
|
||||
from each of the option elements.
|
||||
|
||||
If getoptx() finds another option character, it returns that character,
|
||||
updating `optindx' and `nextchar' so that the next call to getoptx() can
|
||||
resume the scan with the following option character or ARGV-element.
|
||||
|
||||
If there are no more option characters, getoptx() returns `EOF'.
|
||||
Then `optindx' is the index in ARGV of the first ARGV-element
|
||||
that is not an option. (The ARGV-elements have been permuted
|
||||
so that those that are not options now come last.)
|
||||
|
||||
OPTSTRING is a string containing the legitimate option characters.
|
||||
If an option character is seen that is not listed in OPTSTRING,
|
||||
return '?' after printing an error message. If you set `opterrx' to
|
||||
zero, the error message is suppressed but we still return '?'.
|
||||
|
||||
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
|
||||
so the following text in the same ARGV-element, or the text of the following
|
||||
ARGV-element, is returned in `optargx'. Two colons mean an option that
|
||||
wants an optional arg; if there is text in the current ARGV-element,
|
||||
it is returned in `optargx', otherwise `optargx' is set to zero.
|
||||
|
||||
If OPTSTRING starts with `-', it requests a different method of handling the
|
||||
non-option ARGV-elements. See the comments about RETURN_IN_ORDER, above.
|
||||
|
||||
Long-named options begin with `+' instead of `-'.
|
||||
Their names may be abbreviated as long as the abbreviation is unique
|
||||
or is an exact match for some defined option. If they have an
|
||||
argument, it follows the option name in the same ARGV-element, separated
|
||||
from the option name by a `=', or else the in next ARGV-element.
|
||||
getoptx() returns 0 when it finds a long-named option. */
|
||||
|
||||
static int
|
||||
getoptx(int const argc,
|
||||
char ** const argv,
|
||||
const char * const optstring) {
|
||||
|
||||
optargx = 0;
|
||||
|
||||
/* Initialize the internal data when the first call is made.
|
||||
Start processing options with ARGV-element 1 (since ARGV-element 0
|
||||
is the program name); the sequence of previously skipped
|
||||
non-option ARGV-elements is empty. */
|
||||
|
||||
if (optindx == 0)
|
||||
{
|
||||
first_nonopt = last_nonopt = optindx = 1;
|
||||
|
||||
nextchar = 0;
|
||||
|
||||
}
|
||||
|
||||
if (nextchar == 0 || *nextchar == 0)
|
||||
{
|
||||
/* If we have just processed some options following some non-options,
|
||||
exchange them so that the options come first. */
|
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optindx)
|
||||
exchange (argv);
|
||||
else if (last_nonopt != optindx)
|
||||
first_nonopt = optindx;
|
||||
|
||||
/* Now skip any additional non-options
|
||||
and extend the range of non-options previously skipped. */
|
||||
|
||||
while (optindx < argc
|
||||
&& (argv[optindx][0] != '-'|| argv[optindx][1] == 0)
|
||||
&& (argv[optindx][0] != '+'|| argv[optindx][1] == 0))
|
||||
optindx++;
|
||||
last_nonopt = optindx;
|
||||
|
||||
/* Special ARGV-element `--' means premature end of options.
|
||||
Skip it like a null option,
|
||||
then exchange with previous non-options as if it were an option,
|
||||
then skip everything else like a non-option. */
|
||||
|
||||
if (optindx != argc && !strcmp (argv[optindx], "--"))
|
||||
{
|
||||
optindx++;
|
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optindx)
|
||||
exchange (argv);
|
||||
else if (first_nonopt == last_nonopt)
|
||||
first_nonopt = optindx;
|
||||
last_nonopt = argc;
|
||||
|
||||
optindx = argc;
|
||||
}
|
||||
|
||||
/* If we have done all the ARGV-elements, stop the scan
|
||||
and back over any non-options that we skipped and permuted. */
|
||||
|
||||
if (optindx == argc)
|
||||
{
|
||||
/* Set the next-arg-index to point at the non-options
|
||||
that we previously skipped, so the caller will digest them. */
|
||||
if (first_nonopt != last_nonopt)
|
||||
optindx = first_nonopt;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* If we have come to a non-option and did not permute it,
|
||||
either stop the scan or describe it to the caller and pass
|
||||
it by.
|
||||
*/
|
||||
|
||||
if ((argv[optindx][0] != '-' || argv[optindx][1] == 0)
|
||||
&& (argv[optindx][0] != '+' || argv[optindx][1] == 0))
|
||||
{
|
||||
optargx = argv[optindx++];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* We have found another option-ARGV-element.
|
||||
Start decoding its characters. */
|
||||
|
||||
nextchar = argv[optindx] + 1;
|
||||
}
|
||||
|
||||
if ((argv[optindx][0] == '+' || (argv[optindx][0] == '-'))
|
||||
)
|
||||
{
|
||||
struct optionx *p;
|
||||
char *s = nextchar;
|
||||
int exact = 0;
|
||||
int ambig = 0;
|
||||
struct optionx * pfound;
|
||||
int indfound;
|
||||
|
||||
while (*s && *s != '=') s++;
|
||||
|
||||
indfound = 0; /* quite compiler warning */
|
||||
|
||||
/* Test all options for either exact match or abbreviated matches. */
|
||||
for (p = _getopt_long_options, option_index = 0, pfound = NULL;
|
||||
p->name;
|
||||
p++, option_index++)
|
||||
if (!strncmp (p->name, nextchar, s - nextchar))
|
||||
{
|
||||
if ((unsigned int)(s - nextchar) == strlen (p->name))
|
||||
{
|
||||
/* Exact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
exact = 1;
|
||||
break;
|
||||
}
|
||||
else if (!pfound)
|
||||
{
|
||||
/* First nonexact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
}
|
||||
else
|
||||
/* Second nonexact match found. */
|
||||
ambig = 1;
|
||||
}
|
||||
|
||||
if (ambig && !exact)
|
||||
{
|
||||
fprintf (stderr, "%s: option `%s' is ambiguous\n",
|
||||
argv[0], argv[optindx]);
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
|
||||
if (pfound)
|
||||
{
|
||||
option_index = indfound;
|
||||
optindx++;
|
||||
if (*s)
|
||||
{
|
||||
if (pfound->has_arg > 0)
|
||||
optargx = s + 1;
|
||||
else
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: option `%c%s' doesn't allow an argument\n",
|
||||
argv[0], argv[optindx - 1][0], pfound->name);
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
else if (pfound->has_arg)
|
||||
{
|
||||
if (optindx < argc)
|
||||
optargx = argv[optindx++];
|
||||
else if (pfound->has_arg != 2)
|
||||
{
|
||||
fprintf (stderr, "%s: option `%s' requires an argument\n",
|
||||
argv[0], argv[optindx - 1]);
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
if (pfound->flag)
|
||||
*(pfound->flag) = pfound->val;
|
||||
return 0;
|
||||
}
|
||||
if (argv[optindx][0] == '+' || strchr (optstring, *nextchar) == 0)
|
||||
{
|
||||
if (opterrx != 0)
|
||||
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
|
||||
argv[0], argv[optindx][0], nextchar);
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
/* Look at and handle the next option-character. */
|
||||
|
||||
{
|
||||
char c = *nextchar++;
|
||||
char *temp = strchr (optstring, c);
|
||||
|
||||
/* Increment `optindx' when we start to process its last character. */
|
||||
if (*nextchar == 0)
|
||||
optindx++;
|
||||
|
||||
if (temp == 0 || c == ':')
|
||||
{
|
||||
if (opterrx != 0)
|
||||
{
|
||||
if (c < 040 || c >= 0177)
|
||||
fprintf (stderr, "%s: unrecognized option, "
|
||||
"character code 0%o\n",
|
||||
argv[0], c);
|
||||
else
|
||||
fprintf (stderr, "%s: unrecognized option `-%c'\n",
|
||||
argv[0], c);
|
||||
}
|
||||
return '?';
|
||||
}
|
||||
if (temp[1] == ':')
|
||||
{
|
||||
if (temp[2] == ':')
|
||||
{
|
||||
/* This is an option that accepts an argument optionally. */
|
||||
if (*nextchar != 0)
|
||||
{
|
||||
optargx = nextchar;
|
||||
optindx++;
|
||||
}
|
||||
else
|
||||
optargx = 0;
|
||||
nextchar = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is an option that requires an argument. */
|
||||
if (*nextchar != 0)
|
||||
{
|
||||
optargx = nextchar;
|
||||
/* If we end this ARGV-element by taking the rest
|
||||
as an arg, we must advance to the next element
|
||||
now.
|
||||
*/
|
||||
optindx++;
|
||||
}
|
||||
else if (optindx == argc)
|
||||
{
|
||||
if (opterrx != 0)
|
||||
fprintf (stderr,
|
||||
"%s: option `-%c' requires an argument\n",
|
||||
argv[0], c);
|
||||
c = '?';
|
||||
}
|
||||
else
|
||||
/* We already incremented `optindx' once;
|
||||
increment it again when taking next ARGV-elt as
|
||||
argument.
|
||||
*/
|
||||
optargx = argv[optindx++];
|
||||
nextchar = 0;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
getopt_long_onlyx(int const argc,
|
||||
char ** const argv,
|
||||
const char * const options,
|
||||
struct optionx * const long_options,
|
||||
unsigned int * const opt_index,
|
||||
int const opterrArg,
|
||||
int * const end_of_options,
|
||||
const char ** const optarg_arg,
|
||||
const char ** const unrecognized_option) {
|
||||
|
||||
int rc;
|
||||
|
||||
opterrx = opterrArg;
|
||||
_getopt_long_options = long_options;
|
||||
rc = getoptx(argc, argv, options);
|
||||
if (rc == 0)
|
||||
*opt_index = option_index;
|
||||
|
||||
if (rc == '?')
|
||||
*unrecognized_option = argv[optindx];
|
||||
else
|
||||
*unrecognized_option = NULL;
|
||||
|
||||
if (rc < 0)
|
||||
*end_of_options = 1;
|
||||
else
|
||||
*end_of_options = 0;
|
||||
|
||||
*optarg_arg = optargx;
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
getopt_argstart(void) {
|
||||
/*----------------------------------------------------------------------------
|
||||
This is a replacement for what traditional getopt does with global
|
||||
variables.
|
||||
|
||||
You call this after getopt_long_onlyx() has returned "end of
|
||||
options"
|
||||
-----------------------------------------------------------------------------*/
|
||||
return optindx;
|
||||
}
|
||||
|
||||
|
||||
/* Getopt for GNU.
|
||||
Copyright (C) 1987, 1989 Free Software Foundation, Inc.
|
||||
|
||||
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 1, 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.
|
||||
*/
|
51
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/util/getoptx.h
Normal file
51
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/util/getoptx.h
Normal file
@ -0,0 +1,51 @@
|
||||
/* Interface to getopt_long_onlyx() */
|
||||
|
||||
|
||||
enum argreq {no_argument, required_argument, optional_argument};
|
||||
|
||||
struct optionx {
|
||||
/* This describes an option. If the field `flag' is nonzero, it
|
||||
points to a variable that is to be set to the value given in
|
||||
the field `val' when the option is found, but left unchanged if
|
||||
the option is not found.
|
||||
*/
|
||||
const char * name;
|
||||
enum argreq has_arg;
|
||||
int * flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* long_options[] is a list terminated by an element that contains
|
||||
a NULL 'name' member.
|
||||
*/
|
||||
void
|
||||
getopt_long_onlyx(int const argc,
|
||||
char ** const argv,
|
||||
const char * const options,
|
||||
struct optionx * const long_options,
|
||||
unsigned int * const opt_index,
|
||||
int const opterrArg,
|
||||
int * const end_of_options,
|
||||
const char ** const optarg_arg,
|
||||
const char ** const unrecognized_option);
|
||||
|
||||
unsigned int
|
||||
getopt_argstart(void);
|
||||
|
||||
/*
|
||||
Copyright (C) 1989 Free Software Foundation, Inc.
|
||||
|
||||
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 1, 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. */
|
||||
|
@ -0,0 +1,27 @@
|
||||
#ifndef ASSERTX_HPP_INCLUDED
|
||||
#define ASSERTX_HPP_INCLUDED
|
||||
|
||||
#include <cassert>
|
||||
|
||||
/* The compiler often warns you if you give a function formal parameter a
|
||||
name, but don't use it. But because assert() disappears when doing an
|
||||
optimized build, the compiler doesn't recognize your reference to the
|
||||
parameter in the assert() argument. To avoid the bogus warning in
|
||||
this case, we have ASSERT_ONLY_ARG(), which declares a name for a
|
||||
formal parameter for purposes of assert() only. In cases where an
|
||||
assert() would disappear, ASSERT_ONLY_ARG() disappears too.
|
||||
|
||||
E.g.
|
||||
|
||||
void foo(int const ASSERT_ONLY_ARG(arg1)) {
|
||||
|
||||
assert(arg1 > 0);
|
||||
}
|
||||
*/
|
||||
#ifdef NDEBUG
|
||||
#define ASSERT_ONLY_ARG(x)
|
||||
#else
|
||||
#define ASSERT_ONLY_ARG(x) x
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,18 @@
|
||||
/* This takes the place of C99 stdbool.h, which at least some Windows
|
||||
compilers don't have. (October 2005).
|
||||
|
||||
One must not also include <stdbool.h>, because it might cause a name
|
||||
collision.
|
||||
*/
|
||||
|
||||
#ifndef __cplusplus
|
||||
/* At least the GNU compiler defines __bool_true_false_are_defined */
|
||||
#ifndef __bool_true_false_are_defined
|
||||
#define __bool_true_false_are_defined
|
||||
typedef enum {
|
||||
false = 0,
|
||||
true = 1
|
||||
} bool;
|
||||
#endif
|
||||
#endif
|
||||
|
@ -0,0 +1,19 @@
|
||||
#ifndef C_UTIL_H_INCLUDED
|
||||
#define C_UTIL_H_INCLUDED
|
||||
|
||||
/* C language stuff. Doesn't involve any libraries that aren't part of
|
||||
the compiler.
|
||||
*/
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
||||
|
||||
/* GNU_PRINTF_ATTR lets the GNU compiler check printf-type
|
||||
calls to be sure the arguments match the format string, thus preventing
|
||||
runtime segmentation faults and incorrect messages.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define GNU_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
|
||||
#else
|
||||
#define GNU_PRINTF_ATTR(a,b)
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,29 @@
|
||||
#ifndef CASPRINTF_H_INCLUDED
|
||||
#define CASPRINTF_H_INCLUDED
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "c_util.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char * const strsol;
|
||||
|
||||
void
|
||||
cvasprintf(const char ** const retvalP,
|
||||
const char * const fmt,
|
||||
va_list varargs);
|
||||
|
||||
void GNU_PRINTF_ATTR(2,3)
|
||||
casprintf(const char ** const retvalP, const char * const fmt, ...);
|
||||
|
||||
void
|
||||
strfree(const char * const string);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,86 @@
|
||||
#ifndef CMDLINE_PARSER_H
|
||||
#define CMDLINE_PARSER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#if 0
|
||||
} /* to fake out automatic code indenters */
|
||||
#endif
|
||||
|
||||
#include "int.h"
|
||||
|
||||
/*
|
||||
|
||||
NOTE NOTE NOTE: cmd_getOptionValueString() and
|
||||
cmd_getArgument() return malloc'ed memory (and abort the program if
|
||||
out of memory). You must free it.
|
||||
|
||||
*/
|
||||
|
||||
enum optiontype {
|
||||
OPTTYPE_FLAG,
|
||||
OPTTYPE_INT,
|
||||
OPTTYPE_UINT,
|
||||
OPTTYPE_STRING,
|
||||
OPTTYPE_BINUINT,
|
||||
OPTTYPE_FLOAT
|
||||
};
|
||||
|
||||
struct cmdlineParserCtl;
|
||||
|
||||
typedef struct cmdlineParserCtl * cmdlineParser;
|
||||
|
||||
void
|
||||
cmd_processOptions(cmdlineParser const cpP,
|
||||
int const argc,
|
||||
const char ** const argv,
|
||||
const char ** const errorP);
|
||||
|
||||
cmdlineParser
|
||||
cmd_createOptionParser(void);
|
||||
|
||||
void
|
||||
cmd_destroyOptionParser(cmdlineParser const cpP);
|
||||
|
||||
void
|
||||
cmd_defineOption(cmdlineParser const cpP,
|
||||
const char * const name,
|
||||
enum optiontype const type);
|
||||
|
||||
int
|
||||
cmd_optionIsPresent(cmdlineParser const cpP,
|
||||
const char * const name);
|
||||
|
||||
int
|
||||
cmd_getOptionValueInt(cmdlineParser const cpP,
|
||||
const char * const name);
|
||||
|
||||
unsigned int
|
||||
cmd_getOptionValueUint(cmdlineParser const cpP,
|
||||
const char * const name);
|
||||
|
||||
const char *
|
||||
cmd_getOptionValueString(cmdlineParser const cpP,
|
||||
const char * const name);
|
||||
|
||||
uint64_t
|
||||
cmd_getOptionValueBinUint(cmdlineParser const cpP,
|
||||
const char * const name);
|
||||
|
||||
double
|
||||
cmd_getOptionValueFloat(cmdlineParser const cpP,
|
||||
const char * const name);
|
||||
|
||||
unsigned int
|
||||
cmd_argumentCount(cmdlineParser const cpP);
|
||||
|
||||
const char *
|
||||
cmd_getArgument(cmdlineParser const cpP,
|
||||
unsigned int const argNumber);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,59 @@
|
||||
#ifndef CMDLINE_PARSER_HPP_INCLUDED
|
||||
#define CMDLINE_PARSER_HPP_INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
struct cmdlineParserCtl;
|
||||
|
||||
class CmdlineParser {
|
||||
public:
|
||||
CmdlineParser();
|
||||
|
||||
~CmdlineParser();
|
||||
|
||||
enum optType {FLAG, INT, UINT, STRING, BINUINT, FLOAT};
|
||||
|
||||
void
|
||||
defineOption(std::string const optionName,
|
||||
optType const optionType);
|
||||
|
||||
void
|
||||
processOptions(int const argc,
|
||||
const char ** const argv);
|
||||
|
||||
bool
|
||||
optionIsPresent(std::string const optionName) const;
|
||||
|
||||
int
|
||||
getOptionValueInt(std::string const optionName) const;
|
||||
|
||||
unsigned int
|
||||
getOptionValueUint(std::string const optionName) const;
|
||||
|
||||
std::string
|
||||
getOptionValueString(std::string const optionName) const;
|
||||
|
||||
unsigned long long
|
||||
getOptionValueBinUint(std::string const optionName) const;
|
||||
|
||||
double
|
||||
getOptionValueFloat(std::string const optionName) const;
|
||||
|
||||
unsigned int
|
||||
argumentCount() const;
|
||||
|
||||
std::string
|
||||
getArgument(unsigned int const argNumber) const;
|
||||
|
||||
private:
|
||||
struct cmdlineParserCtl * cp;
|
||||
|
||||
// Make sure no one can copy this object, because if there are two
|
||||
// copies, there will be two attempts to destroy *cp.
|
||||
CmdlineParser(CmdlineParser const&) {};
|
||||
|
||||
CmdlineParser&
|
||||
operator=(CmdlineParser const&) {return *this;}
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,8 @@
|
||||
#ifndef __GIRMATH_H
|
||||
#define __GIRMATH_H
|
||||
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,51 @@
|
||||
#ifndef GIRSTRING_H_INCLUDED
|
||||
#define GIRSTRING_H_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
#include "bool.h"
|
||||
|
||||
bool
|
||||
stripcaseeq(const char * const comparand,
|
||||
const char * const comparator);
|
||||
|
||||
static __inline__ bool
|
||||
streq(const char * const comparator,
|
||||
const char * const comparand) {
|
||||
|
||||
return (strcmp(comparand, comparator) == 0);
|
||||
}
|
||||
|
||||
static __inline__ bool
|
||||
memeq(const void * const comparator,
|
||||
const void * const comparand,
|
||||
size_t const size) {
|
||||
|
||||
return (memcmp(comparator, comparand, size) == 0);
|
||||
}
|
||||
|
||||
#define MEMEQ(a,b,c) (memcmp(a, b, c) == 0)
|
||||
|
||||
#define MEMSSET(a,b) (memset(a, b, sizeof(*a)))
|
||||
|
||||
#define MEMSCPY(a,b) (memcpy(a, b, sizeof(*a)))
|
||||
|
||||
#define MEMSZERO(a) (MEMSSET(a, 0))
|
||||
|
||||
static __inline__ const char *
|
||||
sdup(const char * const input) {
|
||||
return (const char *) strdup(input);
|
||||
}
|
||||
|
||||
/* Copy string pointed by B to array A with size checking. */
|
||||
#define STRSCPY(A,B) \
|
||||
(strncpy((A), (B), sizeof(A)), *((A)+sizeof(A)-1) = '\0')
|
||||
#define STRSCMP(A,B) \
|
||||
(strncmp((A), (B), sizeof(A)))
|
||||
|
||||
/* Concatenate string B onto string in array A with size checking */
|
||||
#define STRSCAT(A,B) \
|
||||
(strncat((A), (B), sizeof(A)-strlen(A)), *((A)+sizeof(A)-1) = '\0')
|
||||
|
||||
#endif
|
@ -0,0 +1,19 @@
|
||||
#ifndef XMLRPC_INLINE_H_INCLUDED
|
||||
#define XMLRPC_INLINE_H_INCLUDED
|
||||
|
||||
/* Xmlrpc-c uses __inline__ to declare functions that should be
|
||||
compiled as inline code. Some compilers, e.g. GNU, recognize the
|
||||
__inline__ keyword.
|
||||
*/
|
||||
#ifndef __GNUC__
|
||||
#ifndef __inline__
|
||||
#ifdef __sgi
|
||||
#define __inline__ __inline
|
||||
#else
|
||||
#define __inline__
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,58 @@
|
||||
/* This takes the place of C99 inttypes.h, which at least some Windows
|
||||
compilers don't have. (October 2007).
|
||||
*/
|
||||
|
||||
/* PRId64 is the printf-style format specifier for a long long type, as in
|
||||
long long mynumber = 5;
|
||||
printf("My number is %" PRId64 ".\n", mynumber);
|
||||
|
||||
The LL/ULL macro is for 64 bit integer literals, like this:
|
||||
|
||||
long long mask= ULL(1) << 33;
|
||||
*/
|
||||
|
||||
/* 'uint' is quite convenient, but there's no simple way have it everywhere.
|
||||
Some systems have it in the base system (e.g. GNU C library has it in
|
||||
<sys/types.h>, and others (e.g. Solaris - 08.12.02) don't. Since we
|
||||
can't define it unless we know it's not defined already, and we don't
|
||||
want to burden the reader with a special Xmlrpc-c name such as xuint,
|
||||
we just use standard "unsigned int" instead.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define PRId64 "I64d"
|
||||
# define PRIu64 "I64u"
|
||||
|
||||
#ifndef int16_t
|
||||
typedef short int16_t;
|
||||
#endif
|
||||
#ifndef uint16_t
|
||||
typedef unsigned short uint16_t;
|
||||
#endif
|
||||
#ifndef int32_t
|
||||
typedef int int32_t;
|
||||
#endif
|
||||
#ifndef uint32_t
|
||||
typedef unsigned int uint32_t;
|
||||
#endif
|
||||
#ifndef int64_t
|
||||
typedef __int64 int64_t;
|
||||
#endif
|
||||
#ifndef uint64_t
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#endif
|
||||
#ifndef uint8_t
|
||||
typedef unsigned char uint8_t;
|
||||
#endif
|
||||
|
||||
/* Older Microsoft compilers don't know the standard ll/ull suffixes */
|
||||
#define LL(x) x ## i64
|
||||
#define ULL(x) x ## u64
|
||||
|
||||
#else
|
||||
/* Not Microsoft compiler */
|
||||
#include <inttypes.h>
|
||||
#define LL(x) x ## ll
|
||||
#define ULL(x) x ## ull
|
||||
#endif
|
||||
|
@ -0,0 +1,193 @@
|
||||
#ifndef LINKLIST_H_INCLUDED
|
||||
#define LINKLIST_H_INCLUDED
|
||||
|
||||
#include "inline.h"
|
||||
|
||||
struct list_head {
|
||||
/*----------------------------------------------------------------------------
|
||||
This is a header for an element of a doubly linked list, or an anchor
|
||||
for such a list.
|
||||
|
||||
itemP == NULL means it's an anchor; otherwise it's a header.
|
||||
|
||||
Initialize a list header with list_init_header(). You don't have to
|
||||
do anything to terminate a list header.
|
||||
|
||||
Initialize an anchor with list_make_emtpy(). You don't have to do anything
|
||||
to terminate a list header.
|
||||
-----------------------------------------------------------------------------*/
|
||||
struct list_head * nextP;
|
||||
/* For a header, this is the address of the list header for
|
||||
the next element in the list. If there is no next element,
|
||||
it points to the anchor. If the header is not in a list at
|
||||
all, it is NULL.
|
||||
|
||||
For an anchor, it is the address of the list header of the
|
||||
first element. If the list is empty, it points to the
|
||||
anchor itself.
|
||||
*/
|
||||
struct list_head * prevP;
|
||||
/* For a header, this is the address of the list header for
|
||||
the previous element in the list. If there is no previous element,
|
||||
it points to the anchor. If the header is not in a list at
|
||||
all, it is NULL.
|
||||
|
||||
For an anchor, it is the address of the list header of the
|
||||
last element. If the list is empty, it points to the
|
||||
anchor itself.
|
||||
*/
|
||||
void * itemP;
|
||||
/* For a header, this is the address of the list element to which it
|
||||
belongs. For an anchor, this is NULL.
|
||||
*/
|
||||
};
|
||||
|
||||
static __inline__ void
|
||||
list_init_header(struct list_head * const headerP,
|
||||
void * const itemP) {
|
||||
|
||||
headerP->prevP = NULL;
|
||||
headerP->nextP = NULL;
|
||||
headerP->itemP = itemP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ int
|
||||
list_is_linked(struct list_head * headerP) {
|
||||
return headerP->prevP != NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ int
|
||||
list_is_empty(struct list_head * const anchorP) {
|
||||
return anchorP->nextP == anchorP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ unsigned int
|
||||
list_count(struct list_head * const anchorP) {
|
||||
unsigned int count;
|
||||
|
||||
struct list_head * p;
|
||||
|
||||
for (p = anchorP->nextP, count = 0;
|
||||
p != anchorP;
|
||||
p = p->nextP, ++count);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ void
|
||||
list_make_empty(struct list_head * const anchorP) {
|
||||
anchorP->prevP = anchorP;
|
||||
anchorP->nextP = anchorP;
|
||||
anchorP->itemP = NULL;
|
||||
}
|
||||
|
||||
static __inline__ void
|
||||
list_insert_after(struct list_head * const beforeHeaderP,
|
||||
struct list_head * const newHeaderP) {
|
||||
newHeaderP->prevP = beforeHeaderP;
|
||||
newHeaderP->nextP = beforeHeaderP->nextP;
|
||||
|
||||
beforeHeaderP->nextP = newHeaderP;
|
||||
newHeaderP->nextP->prevP = newHeaderP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ void
|
||||
list_add_tail(struct list_head * const anchorP,
|
||||
struct list_head * const headerP) {
|
||||
list_insert_after(anchorP->prevP, headerP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ void
|
||||
list_add_head(struct list_head * const anchorP,
|
||||
struct list_head * const headerP) {
|
||||
list_insert_after(anchorP, headerP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ void
|
||||
list_remove(struct list_head * const headerP) {
|
||||
headerP->prevP->nextP = headerP->nextP;
|
||||
headerP->nextP->prevP = headerP->prevP;
|
||||
headerP->prevP = NULL;
|
||||
headerP->nextP = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ struct list_head *
|
||||
list_remove_head(struct list_head * const anchorP) {
|
||||
struct list_head * retval;
|
||||
|
||||
if (list_is_empty(anchorP))
|
||||
retval = NULL;
|
||||
else {
|
||||
retval = anchorP->nextP;
|
||||
list_remove(retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ struct list_head *
|
||||
list_remove_tail(struct list_head * const anchorP) {
|
||||
struct list_head * retval;
|
||||
|
||||
if (list_is_empty(anchorP))
|
||||
retval = NULL;
|
||||
else {
|
||||
retval = anchorP->prevP;
|
||||
list_remove(retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ void *
|
||||
list_foreach(struct list_head * const anchorP,
|
||||
void * functionP(struct list_head *, void *),
|
||||
void * const context) {
|
||||
|
||||
struct list_head * p;
|
||||
struct list_head * nextP;
|
||||
void * result;
|
||||
|
||||
for (p = anchorP->nextP, nextP = p->nextP, result=NULL;
|
||||
p != anchorP && result == NULL;
|
||||
p = nextP, nextP = p->nextP)
|
||||
result = (*functionP)(p, context);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ void
|
||||
list_append(struct list_head * const newAnchorP,
|
||||
struct list_head * const baseAnchorP) {
|
||||
|
||||
if (!list_is_empty(newAnchorP)) {
|
||||
baseAnchorP->prevP->nextP = newAnchorP->nextP;
|
||||
newAnchorP->nextP->prevP = baseAnchorP->prevP;
|
||||
newAnchorP->prevP->nextP = baseAnchorP;
|
||||
baseAnchorP->prevP = newAnchorP->prevP;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,111 @@
|
||||
/* These are some dynamic memory allocation facilities. They are essentially
|
||||
an extension to C, as they do allocations with a cognizance of C
|
||||
variables. You can use them to make C read more like a high level
|
||||
language.
|
||||
|
||||
Before including this, you must define an __inline__ macro if your
|
||||
compiler doesn't recognize it as a keyword.
|
||||
*/
|
||||
|
||||
#ifndef MALLOCVAR_INCLUDED
|
||||
#define MALLOCVAR_INCLUDED
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static __inline__ void
|
||||
mallocProduct(void ** const resultP,
|
||||
unsigned int const factor1,
|
||||
unsigned int const factor2) {
|
||||
/*----------------------------------------------------------------------------
|
||||
malloc a space whose size in bytes is the product of 'factor1' and
|
||||
'factor2'. But if that size cannot be represented as an unsigned int,
|
||||
return NULL without allocating anything. Also return NULL if the malloc
|
||||
fails.
|
||||
|
||||
If either factor is zero, malloc a single byte.
|
||||
|
||||
Note that malloc() actually takes a size_t size argument, so the
|
||||
proper test would be whether the size can be represented by size_t,
|
||||
not unsigned int. But there is no reliable indication available to
|
||||
us, like UINT_MAX, of what the limitations of size_t are. We
|
||||
assume size_t is at least as expressive as unsigned int and that
|
||||
nobody really needs to allocate more than 4GB of memory.
|
||||
-----------------------------------------------------------------------------*/
|
||||
if (factor1 == 0 || factor2 == 0)
|
||||
*resultP = malloc(1);
|
||||
else {
|
||||
if (UINT_MAX / factor2 < factor1)
|
||||
*resultP = NULL;
|
||||
else
|
||||
*resultP = malloc(factor1 * factor2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static __inline__ void
|
||||
reallocProduct(void ** const blockP,
|
||||
unsigned int const factor1,
|
||||
unsigned int const factor2) {
|
||||
|
||||
void * const oldBlockP = *blockP;
|
||||
|
||||
void * newBlockP;
|
||||
|
||||
if (UINT_MAX / factor2 < factor1)
|
||||
newBlockP = NULL;
|
||||
else
|
||||
newBlockP = realloc(oldBlockP, factor1 * factor2);
|
||||
|
||||
if (newBlockP)
|
||||
*blockP = newBlockP;
|
||||
else {
|
||||
free(oldBlockP);
|
||||
*blockP = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* IMPLEMENTATION NOTE: There are huge strict aliasing pitfalls here
|
||||
if you cast pointers, e.g. (void **)
|
||||
*/
|
||||
|
||||
#define MALLOCARRAY(arrayName, nElements) do { \
|
||||
void * array; \
|
||||
mallocProduct(&array, nElements, sizeof(arrayName[0])); \
|
||||
arrayName = array; \
|
||||
} while (0)
|
||||
|
||||
#define REALLOCARRAY(arrayName, nElements) do { \
|
||||
void * array = arrayName; \
|
||||
reallocProduct(&array, nElements, sizeof(arrayName[0])); \
|
||||
arrayName = array; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define MALLOCARRAY_NOFAIL(arrayName, nElements) \
|
||||
do { \
|
||||
MALLOCARRAY(arrayName, nElements); \
|
||||
if ((arrayName) == NULL) \
|
||||
abort(); \
|
||||
} while(0)
|
||||
|
||||
#define REALLOCARRAY_NOFAIL(arrayName, nElements) \
|
||||
do { \
|
||||
REALLOCARRAY(arrayName, nElements); \
|
||||
if ((arrayName) == NULL) \
|
||||
abort(); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define MALLOCVAR(varName) \
|
||||
varName = malloc(sizeof(*varName))
|
||||
|
||||
#define MALLOCVAR_NOFAIL(varName) \
|
||||
do {if ((varName = malloc(sizeof(*varName))) == NULL) abort();} while(0)
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,80 @@
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE. */
|
||||
|
||||
#ifndef PTHREADX_H_INCLUDED
|
||||
#define PTHREADX_H_INCLUDED
|
||||
|
||||
#ifndef WIN32
|
||||
# define _REENTRANT
|
||||
# include <pthread.h>
|
||||
#elif defined (WIN32)
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef HANDLE pthread_t;
|
||||
typedef CRITICAL_SECTION pthread_mutex_t;
|
||||
|
||||
#define PTHREAD_MUTEX_INITIALIZER NULL
|
||||
/* usage: pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; */
|
||||
|
||||
typedef
|
||||
struct {
|
||||
int attrs; /* currently unused. placeholder. */
|
||||
} pthread_attr_t;
|
||||
|
||||
typedef
|
||||
struct {
|
||||
int attrs; /* currently unused. placeholder. */
|
||||
} pthread_mutexattr_t;
|
||||
|
||||
/* We make pthread_func identical to a Windows thread start function
|
||||
so we can use Windows thread functions to implement these pthread
|
||||
functions directly.
|
||||
*/
|
||||
typedef unsigned (WINAPI pthread_func)(void *);
|
||||
|
||||
extern int pthread_create(pthread_t * const new_thread_ID,
|
||||
const pthread_attr_t * const attr,
|
||||
pthread_func * start_func,
|
||||
void * const arg);
|
||||
extern int pthread_cancel(pthread_t target_thread);
|
||||
extern int pthread_join(pthread_t target_thread, void **status);
|
||||
extern int pthread_detach(pthread_t target_thread);
|
||||
|
||||
extern int pthread_mutex_init(pthread_mutex_t * const mp,
|
||||
const pthread_mutexattr_t * const attr);
|
||||
extern int pthread_mutex_lock(pthread_mutex_t * const mp);
|
||||
extern int pthread_mutex_unlock(pthread_mutex_t * const mp);
|
||||
extern int pthread_mutex_destroy(pthread_mutex_t * const mp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* WIN32 */
|
||||
|
||||
#endif
|
@ -0,0 +1,67 @@
|
||||
#ifndef STDARGX_H_INCLUDED
|
||||
#define STDARGX_H_INCLUDED
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
We need a special version of va_list in order to pass around the
|
||||
variable argument heap by reference, thus allowing a subroutine to
|
||||
advance the heap's pointer.
|
||||
|
||||
On some systems (e.g. Gcc for PPC or AMD64), va_list is an array.
|
||||
That invites the scourge of array-to-pointer degeneration if you try
|
||||
to take its address. Burying it inside a struct as we do with out
|
||||
va_listx type makes it immune.
|
||||
|
||||
Example of what would happen if we used va_list instead of va_listx,
|
||||
on a system where va_list is an array:
|
||||
|
||||
void sub2(va_list * argsP) [
|
||||
...
|
||||
}
|
||||
|
||||
void sub1(va_list args) {
|
||||
sub2(&args);
|
||||
}
|
||||
|
||||
This doesn't work. '&args' is the same thing as 'args', so is
|
||||
va_list, not va_list *. The compiler will even warn you about the
|
||||
pointer type mismatch.
|
||||
|
||||
To use va_listx:
|
||||
|
||||
void sub1_va(char * format, va_list args) {
|
||||
va_listx argsx;
|
||||
init_va_listx(&argsx, args);
|
||||
sub2(format, &argsx);
|
||||
}
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
typedef struct {
|
||||
/*----------------------------------------------------------------------------
|
||||
Same thing as va_list, but in a form that works everywhere. See above.
|
||||
-----------------------------------------------------------------------------*/
|
||||
va_list v;
|
||||
} va_listx;
|
||||
|
||||
|
||||
|
||||
static __inline__ void
|
||||
init_va_listx(va_listx * const argsxP,
|
||||
va_list const args) {
|
||||
#if VA_LIST_IS_ARRAY
|
||||
/* 'args' is NOT a va_list. It is a pointer to the first element of a
|
||||
'va_list', which is the same address as a pointer to the va_list
|
||||
itself.
|
||||
*/
|
||||
memcpy(&argsxP->v, args, sizeof(argsxP->v));
|
||||
#else
|
||||
argsxP->v = args;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,31 @@
|
||||
#ifndef STRING_PARSER_H_INCLUDED
|
||||
#define STRING_PARSER_H_INCLUDED
|
||||
|
||||
#include "int.h"
|
||||
|
||||
void
|
||||
interpretUll(const char * const string,
|
||||
uint64_t * const ullP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
interpretLl(const char * const string,
|
||||
int64_t * const llP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
interpretUint(const char * const string,
|
||||
unsigned int * const uintP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
interpretInt(const char * const string,
|
||||
int * const uintP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
interpretBinUint(const char * const string,
|
||||
uint64_t * const valueP,
|
||||
const char ** const errorP);
|
||||
|
||||
#endif
|
@ -0,0 +1,14 @@
|
||||
#ifndef UNISTDX_H_INCLUDED
|
||||
#define UNISTDX_H_INCLUDED
|
||||
|
||||
/* Xmlrpc-c code #includes "unistdx.h" instead of <unistd.h> because
|
||||
<unistd.h> does not exist on WIN32.
|
||||
*/
|
||||
|
||||
#ifndef WIN32
|
||||
# include <unistd.h>
|
||||
#else
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
#endif
|
123
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/util/pthreadx_win32.c
Normal file
123
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/util/pthreadx_win32.c
Normal file
@ -0,0 +1,123 @@
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE. */
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include "pthreadx.h"
|
||||
|
||||
#include <process.h>
|
||||
|
||||
#undef PACKAGE
|
||||
#undef VERSION
|
||||
|
||||
int
|
||||
pthread_create(pthread_t * const new_thread_ID,
|
||||
const pthread_attr_t * const attr,
|
||||
pthread_func * func,
|
||||
void * const arg) {
|
||||
|
||||
HANDLE hThread;
|
||||
DWORD dwThreadID;
|
||||
|
||||
hThread = (HANDLE) _beginthreadex (
|
||||
NULL, 0, func, (LPVOID)arg, CREATE_SUSPENDED, &dwThreadID);
|
||||
|
||||
SetThreadPriority (hThread, THREAD_PRIORITY_NORMAL);
|
||||
ResumeThread (hThread);
|
||||
|
||||
*new_thread_ID = hThread;
|
||||
|
||||
return hThread ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Just kill it. */
|
||||
int
|
||||
pthread_cancel(pthread_t const target_thread) {
|
||||
|
||||
CloseHandle(target_thread);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Waits for the thread to exit before continuing. */
|
||||
int
|
||||
pthread_join(pthread_t const target_thread,
|
||||
void ** const statusP) {
|
||||
|
||||
DWORD dwResult = WaitForSingleObject(target_thread, INFINITE);
|
||||
*statusP = (void *)dwResult;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
pthread_detach(pthread_t const target_thread) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
pthread_mutex_init(pthread_mutex_t * const mp,
|
||||
const pthread_mutexattr_t * const attr) {
|
||||
|
||||
InitializeCriticalSection(mp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
pthread_mutex_lock(pthread_mutex_t * const mp) {
|
||||
|
||||
EnterCriticalSection(mp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
pthread_mutex_unlock(pthread_mutex_t * const mp) {
|
||||
|
||||
LeaveCriticalSection(mp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
pthread_mutex_destroy(pthread_mutex_t * const mp) {
|
||||
|
||||
DeleteCriticalSection(mp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
226
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/util/string_parser.c
Normal file
226
ede-bug-tools/ede-bug-report/xmlrpc-c/deps/util/string_parser.c
Normal file
@ -0,0 +1,226 @@
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "int.h"
|
||||
#include "girstring.h"
|
||||
#include "casprintf.h"
|
||||
|
||||
#include "string_parser.h"
|
||||
|
||||
static const char *
|
||||
strippedSubstring(const char * const string) {
|
||||
|
||||
const char * p;
|
||||
|
||||
for (p = &string[0]; isspace(*p); ++p);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
interpretUll(const char * const string,
|
||||
uint64_t * const ullP,
|
||||
const char ** const errorP) {
|
||||
|
||||
/* strtoull() has the same disappointing weaknesses of strtoul().
|
||||
See interpretUint().
|
||||
*/
|
||||
|
||||
const char * const strippedString = strippedSubstring(string);
|
||||
|
||||
if (strippedString[0] == '\0')
|
||||
casprintf(errorP, "Null (or all whitespace) string.");
|
||||
else if (!isdigit(strippedString[0]))
|
||||
casprintf(errorP, "First non-blank character is '%c', not a digit.",
|
||||
strippedString[0]);
|
||||
else {
|
||||
/* strtoull() does a bizarre thing where if the number is out
|
||||
of range, it returns a clamped value but tells you about it
|
||||
by setting errno = ERANGE. If it is not out of range,
|
||||
strtoull() leaves errno alone.
|
||||
*/
|
||||
char * tail;
|
||||
|
||||
errno = 0; /* So we can tell if strtoull() overflowed */
|
||||
|
||||
*ullP = strtoull(strippedString, &tail, 10);
|
||||
|
||||
if (tail[0] != '\0')
|
||||
casprintf(errorP, "Non-digit stuff in string: %s", tail);
|
||||
else if (errno == ERANGE)
|
||||
casprintf(errorP, "Number too large");
|
||||
else
|
||||
*errorP = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
interpretLl(const char * const string,
|
||||
int64_t * const llP,
|
||||
const char ** const errorP) {
|
||||
|
||||
if (string[0] == '\0')
|
||||
casprintf(errorP, "Null string.");
|
||||
else {
|
||||
/* strtoll() does a bizarre thing where if the number is out
|
||||
of range, it returns a clamped value but tells you about it
|
||||
by setting errno = ERANGE. If it is not out of range,
|
||||
strtoll() leaves errno alone.
|
||||
*/
|
||||
char * tail;
|
||||
|
||||
errno = 0; /* So we can tell if strtoll() overflowed */
|
||||
|
||||
*llP = strtoll(string, &tail, 10);
|
||||
|
||||
if (tail[0] != '\0')
|
||||
casprintf(errorP, "Non-digit stuff in string: %s", tail);
|
||||
else if (errno == ERANGE)
|
||||
casprintf(errorP, "Number too large");
|
||||
else
|
||||
*errorP = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
interpretUint(const char * const string,
|
||||
unsigned int * const uintP,
|
||||
const char ** const errorP) {
|
||||
|
||||
/* strtoul() does a lousy job of dealing with invalid numbers. A null
|
||||
string is just zero; a negative number is a large positive one; a
|
||||
positive (cf unsigned) number is accepted. strtoul is inconsistent
|
||||
in its treatment of the tail; if there is no valid number at all,
|
||||
it returns the entire string as the tail, including leading white
|
||||
space and sign, which are not themselves invalid.
|
||||
*/
|
||||
|
||||
const char * const strippedString = strippedSubstring(string);
|
||||
|
||||
if (strippedString[0] == '\0')
|
||||
casprintf(errorP, "Null (or all whitespace) string.");
|
||||
else if (!isdigit(strippedString[0]))
|
||||
casprintf(errorP, "First non-blank character is '%c', not a digit.",
|
||||
strippedString[0]);
|
||||
else {
|
||||
/* strtoul() does a bizarre thing where if the number is out
|
||||
of range, it returns a clamped value but tells you about it
|
||||
by setting errno = ERANGE. If it is not out of range,
|
||||
strtoul() leaves errno alone.
|
||||
*/
|
||||
char * tail;
|
||||
unsigned long ulongValue;
|
||||
|
||||
errno = 0; /* So we can tell if strtoul() overflowed */
|
||||
|
||||
ulongValue = strtoul(strippedString, &tail, 10);
|
||||
|
||||
if (tail[0] != '\0')
|
||||
casprintf(errorP, "Non-digit stuff in string: %s", tail);
|
||||
else if (errno == ERANGE)
|
||||
casprintf(errorP, "Number too large");
|
||||
else if (ulongValue > UINT_MAX)
|
||||
casprintf(errorP, "Number too large");
|
||||
else {
|
||||
*uintP = ulongValue;
|
||||
*errorP = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
interpretInt(const char * const string,
|
||||
int * const intP,
|
||||
const char ** const errorP) {
|
||||
|
||||
if (string[0] == '\0')
|
||||
casprintf(errorP, "Null string.");
|
||||
else {
|
||||
/* strtol() does a bizarre thing where if the number is out
|
||||
of range, it returns a clamped value but tells you about it
|
||||
by setting errno = ERANGE. If it is not out of range,
|
||||
strtol() leaves errno alone.
|
||||
*/
|
||||
char * tail;
|
||||
long longValue;
|
||||
|
||||
errno = 0; /* So we can tell if strtol() overflowed */
|
||||
|
||||
longValue = strtol(string, &tail, 10);
|
||||
|
||||
if (tail[0] != '\0')
|
||||
casprintf(errorP, "Non-digit stuff in string: %s", tail);
|
||||
else if (errno == ERANGE)
|
||||
casprintf(errorP, "Number too large");
|
||||
else if (longValue > INT_MAX)
|
||||
casprintf(errorP, "Number too large");
|
||||
else if (longValue < INT_MIN)
|
||||
casprintf(errorP, "Number too negative");
|
||||
else {
|
||||
*intP = longValue;
|
||||
*errorP = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
interpretBinUint(const char * const string,
|
||||
uint64_t * const valueP,
|
||||
const char ** const errorP) {
|
||||
|
||||
char * tailptr;
|
||||
long const mantissa_long = strtol(string, &tailptr, 10);
|
||||
|
||||
if (errno == ERANGE)
|
||||
casprintf(errorP,
|
||||
"Numeric value out of range for computation: '%s'. "
|
||||
"Try a smaller number with a K, M, G, etc. suffix.",
|
||||
string);
|
||||
else {
|
||||
int64_t const mantissa = mantissa_long;
|
||||
|
||||
int64_t argNumber;
|
||||
|
||||
*errorP = NULL; /* initial assumption */
|
||||
|
||||
if (*tailptr == '\0')
|
||||
/* There's no suffix. A pure number */
|
||||
argNumber = mantissa * 1;
|
||||
else if (stripcaseeq(tailptr, "K"))
|
||||
argNumber = mantissa * 1024;
|
||||
else if (stripcaseeq(tailptr, "M"))
|
||||
argNumber = mantissa * 1024 * 1024;
|
||||
else if (stripcaseeq(tailptr, "G"))
|
||||
argNumber = mantissa * 1024 * 1024 * 1024;
|
||||
else if (stripcaseeq(tailptr, "T"))
|
||||
argNumber = mantissa * 1024 * 1024 * 1024 * 1024;
|
||||
else if (stripcaseeq(tailptr, "P"))
|
||||
argNumber = mantissa * 1024 * 1024 * 1024 * 1024 * 1024;
|
||||
else {
|
||||
argNumber = 0; /* quiet compiler warning */
|
||||
casprintf(errorP, "Garbage suffix '%s' on number", tailptr);
|
||||
}
|
||||
if (!*errorP) {
|
||||
if (argNumber < 0)
|
||||
casprintf(errorP, "Unsigned numeric value is "
|
||||
"negative: %" PRId64, argNumber);
|
||||
else
|
||||
*valueP = (uint64_t) argNumber;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <ctype.h>
|
||||
|
||||
#include "bool.h"
|
||||
#include "girstring.h"
|
||||
|
||||
|
||||
|
||||
bool
|
||||
stripcaseeq(const char * const comparand,
|
||||
const char * const comparator) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Compare two strings, ignoring leading and trailing blanks and case.
|
||||
|
||||
Return true if the strings are identical, false otherwise.
|
||||
-----------------------------------------------------------------------------*/
|
||||
const char *p, *q, *px, *qx;
|
||||
bool equal;
|
||||
|
||||
/* Make p and q point to the first non-blank character in each string.
|
||||
If there are no non-blank characters, make them point to the terminating
|
||||
NULL.
|
||||
*/
|
||||
|
||||
p = &comparand[0];
|
||||
while (*p == ' ')
|
||||
++p;
|
||||
q = &comparator[0];
|
||||
while (*q == ' ')
|
||||
++q;
|
||||
|
||||
/* Make px and qx point to the last non-blank character in each string.
|
||||
If there are no nonblank characters (which implies the string is
|
||||
null), make them point to the terminating NULL.
|
||||
*/
|
||||
|
||||
if (*p == '\0')
|
||||
px = p;
|
||||
else {
|
||||
px = p + strlen(p) - 1;
|
||||
while (*px == ' ')
|
||||
--px;
|
||||
}
|
||||
|
||||
if (*q == '\0')
|
||||
qx = q;
|
||||
else {
|
||||
qx = q + strlen(q) - 1;
|
||||
while (*qx == ' ')
|
||||
--qx;
|
||||
}
|
||||
|
||||
equal = true; /* initial assumption */
|
||||
|
||||
/* If the stripped strings aren't the same length,
|
||||
we know they aren't equal
|
||||
*/
|
||||
if (px - p != qx - q)
|
||||
equal = false;
|
||||
|
||||
|
||||
while (p <= px) {
|
||||
if (toupper(*p) != toupper(*q))
|
||||
equal = false;
|
||||
++p; ++q;
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
|
757
ede-bug-tools/ede-bug-report/xmlrpc-c/include/xmlrpc-c/base.h
Normal file
757
ede-bug-tools/ede-bug-report/xmlrpc-c/include/xmlrpc-c/base.h
Normal file
@ -0,0 +1,757 @@
|
||||
/* Copyright and license information is at the end of the file */
|
||||
|
||||
#ifndef XMLRPC_H_INCLUDED
|
||||
#define XMLRPC_H_INCLUDED
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <xmlrpc-c/util.h>
|
||||
#include <xmlrpc-c/config.h>
|
||||
/* Defines XMLRPC_HAVE_WCHAR, XMLRPC_INT64, XMLRPC_HAVE_TIMEVAL */
|
||||
|
||||
#if XMLRPC_HAVE_WCHAR
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
#if XMLRPC_HAVE_TIMEVAL
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** Version of libxmlrpc
|
||||
**=======================================================================*/
|
||||
extern unsigned int const xmlrpc_version_major;
|
||||
extern unsigned int const xmlrpc_version_minor;
|
||||
extern unsigned int const xmlrpc_version_point;
|
||||
|
||||
/*=========================================================================
|
||||
** C types equivalent to XML-RPC types
|
||||
**=======================================================================*/
|
||||
|
||||
/* We define names for these types, because they may change from platform
|
||||
to platform.
|
||||
*/
|
||||
|
||||
typedef signed int xmlrpc_int;
|
||||
/* An integer of the type defined by XML-RPC <int>; i.e. 32 bit */
|
||||
typedef XMLRPC_INT32 xmlrpc_int32;
|
||||
/* An integer of the type defined by XML-RPC <i4>; i.e. 32 bit */
|
||||
typedef XMLRPC_INT64 xmlrpc_int64;
|
||||
/* An integer of the type defined by "XML-RPC" <i8>; i.e. 64 bit */
|
||||
typedef int xmlrpc_bool;
|
||||
/* A boolean (of the type defined by XML-RPC <boolean>, but there's
|
||||
really only one kind)
|
||||
*/
|
||||
typedef double xmlrpc_double;
|
||||
/* A double precision floating point number as defined by
|
||||
XML-RPC <float>. But the C "double" type is universally the same,
|
||||
so it's probably clearer just to use that. This typedef is here
|
||||
for mathematical completeness.
|
||||
*/
|
||||
|
||||
/* xmlrpc_socket is just for backward compatibility, in case someone decided
|
||||
to use this in user code. New code should use the native type for a
|
||||
socket (e.g. int or SOCKET). (We stopped using this because for winsock
|
||||
users, we would have to #include <winsock.h> in every file that
|
||||
#includes <xmlrpc-c/base.h> and we don't want that).
|
||||
*/
|
||||
typedef int xmlrpc_socket;
|
||||
|
||||
#define XMLRPC_INT32_MAX 0x7fffffff
|
||||
#define XMLRPC_INT32_MIN (-XMLRPC_INT32_MAX - 1)
|
||||
|
||||
#define XMLRPC_INT64_MAX 0x7fffffffffffffffll
|
||||
#define XMLRPC_INT64_MIN (-XMLRPC_INT64_MAX - 1)
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_value
|
||||
**=========================================================================
|
||||
** An XML-RPC value (of any type).
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XMLRPC_TYPE_INT = 0,
|
||||
XMLRPC_TYPE_BOOL = 1,
|
||||
XMLRPC_TYPE_DOUBLE = 2,
|
||||
XMLRPC_TYPE_DATETIME = 3,
|
||||
XMLRPC_TYPE_STRING = 4,
|
||||
XMLRPC_TYPE_BASE64 = 5,
|
||||
XMLRPC_TYPE_ARRAY = 6,
|
||||
XMLRPC_TYPE_STRUCT = 7,
|
||||
XMLRPC_TYPE_C_PTR = 8,
|
||||
XMLRPC_TYPE_NIL = 9,
|
||||
XMLRPC_TYPE_I8 = 10,
|
||||
XMLRPC_TYPE_DEAD = 0xDEAD
|
||||
} xmlrpc_type;
|
||||
|
||||
#define XMLRPC_HAVE_I8 1
|
||||
|
||||
/* These are *always* allocated on the heap. No exceptions. */
|
||||
typedef struct _xmlrpc_value xmlrpc_value;
|
||||
|
||||
const char *
|
||||
xmlrpc_type_name(xmlrpc_type const type);
|
||||
|
||||
void
|
||||
xmlrpc_abort_if_array_bad(xmlrpc_value * const arrayP);
|
||||
|
||||
#define XMLRPC_ASSERT_ARRAY_OK(val) \
|
||||
xmlrpc_abort_if_array_bad(val)
|
||||
|
||||
/* Increment the reference count of an xmlrpc_value. */
|
||||
extern void xmlrpc_INCREF (xmlrpc_value* const value);
|
||||
|
||||
/* Decrement the reference count of an xmlrpc_value. If there
|
||||
** are no more references, free it. */
|
||||
extern void xmlrpc_DECREF (xmlrpc_value* const value);
|
||||
|
||||
/* Get the type of an XML-RPC value. */
|
||||
extern xmlrpc_type xmlrpc_value_type (xmlrpc_value* const value);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_int_new(xmlrpc_env * const envP,
|
||||
int const intValue);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_i8_new(xmlrpc_env * const envP,
|
||||
xmlrpc_int64 const value);
|
||||
|
||||
void
|
||||
xmlrpc_read_int(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
int * const intValueP);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_bool_new(xmlrpc_env * const envP,
|
||||
xmlrpc_bool const boolValue);
|
||||
|
||||
void
|
||||
xmlrpc_read_bool(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
xmlrpc_bool * const boolValueP);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_double_new(xmlrpc_env * const envP,
|
||||
double const doubleValue);
|
||||
|
||||
void
|
||||
xmlrpc_read_double(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
xmlrpc_double * const doubleValueP);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_datetime_new_str(xmlrpc_env * const envP,
|
||||
const char * const value);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_datetime_new_sec(xmlrpc_env * const envP,
|
||||
time_t const value);
|
||||
|
||||
xmlrpc_value*
|
||||
xmlrpc_datetime_new_usec(xmlrpc_env * const envP,
|
||||
time_t const secs,
|
||||
unsigned int const usecs);
|
||||
|
||||
#if XMLRPC_HAVE_TIMEVAL
|
||||
xmlrpc_value *
|
||||
xmlrpc_datetime_new_timeval(xmlrpc_env * const envP,
|
||||
struct timeval const value);
|
||||
#endif
|
||||
|
||||
#if XMLRPC_HAVE_TIMESPEC
|
||||
xmlrpc_value *
|
||||
xmlrpc_datetime_new_timespec(xmlrpc_env * const envP,
|
||||
struct timespec const value);
|
||||
#endif
|
||||
|
||||
void
|
||||
xmlrpc_read_datetime_str(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_datetime_sec(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
time_t * const timeValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_datetime_usec(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
time_t * const secsP,
|
||||
unsigned int * const usecsP);
|
||||
|
||||
#if XMLRPC_HAVE_TIMEVAL
|
||||
void
|
||||
xmlrpc_read_datetime_timeval(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
struct timeval * const timeValueP);
|
||||
#endif
|
||||
|
||||
#if XMLRPC_HAVE_TIMESPEC
|
||||
void
|
||||
xmlrpc_read_datetime_timespec(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
struct timespec * const timeValueP);
|
||||
#endif
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_new(xmlrpc_env * const envP,
|
||||
const char * const stringValue);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_new_lp(xmlrpc_env * const envP,
|
||||
size_t const length,
|
||||
const char * const stringValue);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_new_va(xmlrpc_env * const envP,
|
||||
const char * const format,
|
||||
va_list args);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_new_f(xmlrpc_env * const envP,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_new_lp_cr(xmlrpc_env * const envP,
|
||||
size_t const length,
|
||||
const char * const value);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_new_cr(xmlrpc_env * const envP,
|
||||
const char * const value);
|
||||
|
||||
void
|
||||
xmlrpc_read_string(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_read_string_crlf(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_lp_crlf(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
size_t * const lengthP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_lp(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
size_t * const lengthP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
#if XMLRPC_HAVE_WCHAR
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_w_new(xmlrpc_env * const envP,
|
||||
const wchar_t * const stringValue);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_w_new_lp(xmlrpc_env * const envP,
|
||||
size_t const length,
|
||||
const wchar_t * const stringValue);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_w(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP,
|
||||
const wchar_t ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_w_crlf(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP,
|
||||
const wchar_t ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_w_lp(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP,
|
||||
size_t * const lengthP,
|
||||
const wchar_t ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_w_lp_crlf(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP,
|
||||
size_t * const lengthP,
|
||||
const wchar_t ** const stringValueP);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_w_new_lp_cr(xmlrpc_env * const envP,
|
||||
size_t const length,
|
||||
const wchar_t * const value);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_w_new_cr(xmlrpc_env * const envP,
|
||||
const wchar_t * const value);
|
||||
|
||||
#endif /* XMLRPC_HAVE_WCHAR */
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_base64_new(xmlrpc_env * const envP,
|
||||
size_t const length,
|
||||
const unsigned char * const value);
|
||||
|
||||
void
|
||||
xmlrpc_read_base64(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
size_t * const lengthP,
|
||||
const unsigned char ** const bytestringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_base64_size(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
size_t * const lengthP);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_array_new(xmlrpc_env * const envP);
|
||||
|
||||
/* Return the number of elements in an XML-RPC array.
|
||||
** Sets XMLRPC_TYPE_ERROR if 'array' is not an array. */
|
||||
int
|
||||
xmlrpc_array_size(xmlrpc_env * const env,
|
||||
const xmlrpc_value * const array);
|
||||
|
||||
/* Append an item to an XML-RPC array.
|
||||
** Sets XMLRPC_TYPE_ERROR if 'array' is not an array. */
|
||||
extern void
|
||||
xmlrpc_array_append_item (xmlrpc_env * const envP,
|
||||
xmlrpc_value * const arrayP,
|
||||
xmlrpc_value * const valueP);
|
||||
|
||||
void
|
||||
xmlrpc_array_read_item(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const arrayP,
|
||||
unsigned int const index,
|
||||
xmlrpc_value ** const valuePP);
|
||||
|
||||
/* Deprecated. Use xmlrpc_array_read_item() instead.
|
||||
|
||||
Get an item from an XML-RPC array.
|
||||
Does not increment the reference count of the returned value.
|
||||
Sets XMLRPC_TYPE_ERROR if 'array' is not an array.
|
||||
Sets XMLRPC_INDEX_ERROR if 'index' is out of bounds.
|
||||
*/
|
||||
xmlrpc_value *
|
||||
xmlrpc_array_get_item(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const arrayP,
|
||||
int const index);
|
||||
|
||||
/* Not implemented--we don't need it yet.
|
||||
extern
|
||||
int xmlrpc_array_set_item (xmlrpc_env* env,
|
||||
xmlrpc_value* array,
|
||||
int index,
|
||||
xmlrpc_value* value);
|
||||
*/
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_struct_new(xmlrpc_env * const env);
|
||||
|
||||
/* Return the number of key/value pairs in a struct.
|
||||
** Sets XMLRPC_TYPE_ERROR if 'strct' is not a struct. */
|
||||
int
|
||||
xmlrpc_struct_size (xmlrpc_env * env,
|
||||
xmlrpc_value * strct);
|
||||
|
||||
/* Returns true iff 'strct' contains 'key'.
|
||||
** Sets XMLRPC_TYPE_ERROR if 'strct' is not a struct. */
|
||||
int
|
||||
xmlrpc_struct_has_key(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const strctP,
|
||||
const char * const key);
|
||||
|
||||
/* The same as the above, but the key may contain zero bytes.
|
||||
Deprecated. xmlrpc_struct_get_value_v() is more general, and this
|
||||
case is not common enough to warrant a shortcut.
|
||||
*/
|
||||
int
|
||||
xmlrpc_struct_has_key_n(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const strctP,
|
||||
const char * const key,
|
||||
size_t const key_len);
|
||||
|
||||
#if 0
|
||||
/* Not implemented yet, but needed for completeness. */
|
||||
int
|
||||
xmlrpc_struct_has_key_v(xmlrpc_env * env,
|
||||
xmlrpc_value * strct,
|
||||
xmlrpc_value * const keyval);
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_struct_find_value(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const structP,
|
||||
const char * const key,
|
||||
xmlrpc_value ** const valuePP);
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_struct_find_value_v(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const structP,
|
||||
xmlrpc_value * const keyP,
|
||||
xmlrpc_value ** const valuePP);
|
||||
|
||||
void
|
||||
xmlrpc_struct_read_value(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const structP,
|
||||
const char * const key,
|
||||
xmlrpc_value ** const valuePP);
|
||||
|
||||
void
|
||||
xmlrpc_struct_read_value_v(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const structP,
|
||||
xmlrpc_value * const keyP,
|
||||
xmlrpc_value ** const valuePP);
|
||||
|
||||
/* The "get_value" functions are deprecated. Use the "find_value"
|
||||
and "read_value" functions instead.
|
||||
*/
|
||||
xmlrpc_value *
|
||||
xmlrpc_struct_get_value(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const strctP,
|
||||
const char * const key);
|
||||
|
||||
/* The same as above, but the key may contain zero bytes.
|
||||
Deprecated. xmlrpc_struct_get_value_v() is more general, and this
|
||||
case is not common enough to warrant a shortcut.
|
||||
*/
|
||||
xmlrpc_value *
|
||||
xmlrpc_struct_get_value_n(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const strctP,
|
||||
const char * const key,
|
||||
size_t const key_len);
|
||||
|
||||
/* Set the value associated with 'key' in 'strct' to 'value'.
|
||||
Sets XMLRPC_TYPE_ERROR if 'strct' is not a struct.
|
||||
*/
|
||||
void
|
||||
xmlrpc_struct_set_value(xmlrpc_env * const env,
|
||||
xmlrpc_value * const strct,
|
||||
const char * const key,
|
||||
xmlrpc_value * const value);
|
||||
|
||||
/* The same as above, but the key may contain zero bytes. Deprecated.
|
||||
The general way to set a structure value is xmlrpc_struct_set_value_v(),
|
||||
and this case is not common enough to deserve a shortcut.
|
||||
*/
|
||||
void
|
||||
xmlrpc_struct_set_value_n(xmlrpc_env * const env,
|
||||
xmlrpc_value * const strct,
|
||||
const char * const key,
|
||||
size_t const key_len,
|
||||
xmlrpc_value * const value);
|
||||
|
||||
/* The same as above, but the key must be an XML-RPC string.
|
||||
** Fails with XMLRPC_TYPE_ERROR if 'keyval' is not a string. */
|
||||
void
|
||||
xmlrpc_struct_set_value_v(xmlrpc_env * const env,
|
||||
xmlrpc_value * const strct,
|
||||
xmlrpc_value * const keyval,
|
||||
xmlrpc_value * const value);
|
||||
|
||||
/* Given a zero-based index, return the matching key and value. This
|
||||
** is normally used in conjunction with xmlrpc_struct_size.
|
||||
** Fails with XMLRPC_TYPE_ERROR if 'struct' is not a struct.
|
||||
** Fails with XMLRPC_INDEX_ERROR if 'index' is out of bounds. */
|
||||
|
||||
void
|
||||
xmlrpc_struct_read_member(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const structP,
|
||||
unsigned int const index,
|
||||
xmlrpc_value ** const keyvalP,
|
||||
xmlrpc_value ** const valueP);
|
||||
|
||||
/* The same as above, but does not increment the reference count of the
|
||||
two values it returns, and return NULL for both if it fails, and
|
||||
takes a signed integer for the index (but fails if it is negative).
|
||||
|
||||
Deprecated. Use xmlrpc_struct_read_member() instead.
|
||||
*/
|
||||
void
|
||||
xmlrpc_struct_get_key_and_value(xmlrpc_env * const env,
|
||||
xmlrpc_value * const strct,
|
||||
int const index,
|
||||
xmlrpc_value ** const out_keyval,
|
||||
xmlrpc_value ** const out_value);
|
||||
|
||||
void
|
||||
xmlrpc_read_cptr(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
void ** const ptrValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_nil(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP);
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_read_i8(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
xmlrpc_int64 * const intValueP);
|
||||
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_cptr_new(xmlrpc_env * const envP,
|
||||
void * const value);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_nil_new(xmlrpc_env * const envP);
|
||||
|
||||
|
||||
/* Build an xmlrpc_value from a format string. */
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_build_value(xmlrpc_env * const env,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
/* The same as the above, but using a va_list and more general */
|
||||
void
|
||||
xmlrpc_build_value_va(xmlrpc_env * const env,
|
||||
const char * const format,
|
||||
va_list const args,
|
||||
xmlrpc_value ** const valPP,
|
||||
const char ** const tailP);
|
||||
|
||||
void
|
||||
xmlrpc_decompose_value(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const value,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
void
|
||||
xmlrpc_decompose_value_va(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const value,
|
||||
const char * const format,
|
||||
va_list const args);
|
||||
|
||||
/* xmlrpc_parse_value... is the same as xmlrpc_decompose_value... except
|
||||
that it doesn't do proper memory management -- it returns xmlrpc_value's
|
||||
without incrementing the reference count and returns pointers to data
|
||||
inside an xmlrpc_value structure.
|
||||
|
||||
These are deprecated. Use xmlrpc_decompose_value... instead.
|
||||
*/
|
||||
void
|
||||
xmlrpc_parse_value(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const value,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
/* The same as the above, but using a va_list. */
|
||||
void
|
||||
xmlrpc_parse_value_va(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const value,
|
||||
const char * const format,
|
||||
va_list const args);
|
||||
|
||||
/*=========================================================================
|
||||
** Encoding XML
|
||||
**=======================================================================*/
|
||||
|
||||
typedef enum xmlrpc_dialect {
|
||||
xmlrpc_dialect_i8,
|
||||
xmlrpc_dialect_apache
|
||||
} xmlrpc_dialect;
|
||||
|
||||
void
|
||||
xmlrpc_serialize_value2(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
xmlrpc_value * const valueP,
|
||||
xmlrpc_dialect const dialect);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_value(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
xmlrpc_value * const valueP);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_params2(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
xmlrpc_dialect const dialect);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_params(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_call2(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
xmlrpc_dialect const dialect);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_call(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_response2(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
xmlrpc_value * const valueP,
|
||||
xmlrpc_dialect const dialect);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_response(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
xmlrpc_value * const valueP);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_fault(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
const xmlrpc_env * const faultP);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** Decoding XML
|
||||
**=======================================================================*/
|
||||
|
||||
/* Parse an XML-RPC call. If an error occurs, set a fault and set
|
||||
** the output variables to NULL.
|
||||
** The caller is responsible for calling free(*out_method_name) and
|
||||
** xmlrpc_DECREF(*out_param_array). */
|
||||
void
|
||||
xmlrpc_parse_call(xmlrpc_env * const envP,
|
||||
const char * const xml_data,
|
||||
size_t const xml_len,
|
||||
const char ** const out_method_name,
|
||||
xmlrpc_value ** const out_param_array);
|
||||
|
||||
void
|
||||
xmlrpc_parse_response2(xmlrpc_env * const envP,
|
||||
const char * const xmlData,
|
||||
size_t const xmlDataLen,
|
||||
xmlrpc_value ** const resultPP,
|
||||
int * const faultCodeP,
|
||||
const char ** const faultStringP);
|
||||
|
||||
|
||||
/* xmlrpc_parse_response() is for backward compatibility */
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_parse_response(xmlrpc_env * const envP,
|
||||
const char * const xmlData,
|
||||
size_t const xmlDataLen);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** XML-RPC Base64 Utilities
|
||||
**=========================================================================
|
||||
** Here are some lightweight utilities which can be used to encode and
|
||||
** decode Base64 data. These are exported mainly for testing purposes.
|
||||
*/
|
||||
|
||||
/* This routine inserts newlines every 76 characters, as required by the
|
||||
** Base64 specification. */
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_base64_encode(xmlrpc_env * env,
|
||||
unsigned char * bin_data,
|
||||
size_t bin_len);
|
||||
|
||||
/* This routine encodes everything in one line. This is needed for HTTP
|
||||
** authentication and similar tasks. */
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_base64_encode_without_newlines(xmlrpc_env * env,
|
||||
unsigned char * bin_data,
|
||||
size_t bin_len);
|
||||
|
||||
/* This decodes Base64 data with or without newlines. */
|
||||
extern xmlrpc_mem_block *
|
||||
xmlrpc_base64_decode(xmlrpc_env * const envP,
|
||||
const char * const ascii_data,
|
||||
size_t const ascii_len);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** Authorization Cookie Handling
|
||||
**=========================================================================
|
||||
** Routines to get and set values for authorizing via authorization
|
||||
** cookies. Both the client and server use HTTP_COOKIE_AUTH to store
|
||||
** the representation of the authorization value, which is actually
|
||||
** just a base64 hash of username:password. (This entire method is
|
||||
** a cookie replacement of basic authentication.)
|
||||
**/
|
||||
|
||||
extern void xmlrpc_authcookie_set(xmlrpc_env * const env,
|
||||
const char * const username,
|
||||
const char * const password);
|
||||
|
||||
char *xmlrpc_authcookie(void);
|
||||
|
||||
/*=========================================================================
|
||||
Resource Limits
|
||||
|
||||
Ideally, there would be enough resource limits to ensure that
|
||||
XML-RPC partners cannot cause libxmlrpc objects and routines to use
|
||||
more resource than is available for them (either by accident or
|
||||
malice). We have a long way to go to get there.
|
||||
|
||||
=========================================================================*/
|
||||
/* These functions are _not_ re-entrant and the limits are per-process
|
||||
(i.e. their values live in static global variables).
|
||||
*/
|
||||
|
||||
/* Limit IDs. There will be more of these as time goes on. */
|
||||
#define XMLRPC_NESTING_LIMIT_ID (0)
|
||||
#define XMLRPC_XML_SIZE_LIMIT_ID (1)
|
||||
#define XMLRPC_LAST_LIMIT_ID (XMLRPC_XML_SIZE_LIMIT_ID)
|
||||
|
||||
/* By default, deserialized data may be no more than 64 levels deep. */
|
||||
#define XMLRPC_NESTING_LIMIT_DEFAULT (64)
|
||||
|
||||
/* By default, XML data from the network may be no larger than 512K.
|
||||
** Some client and server modules may fail to enforce this properly. */
|
||||
#define XMLRPC_XML_SIZE_LIMIT_DEFAULT (512*1024)
|
||||
|
||||
/* Set a specific limit to the specified value. */
|
||||
extern void xmlrpc_limit_set (int const limit_id, size_t const value);
|
||||
|
||||
/* Get the value of a specified limit. */
|
||||
extern size_t xmlrpc_limit_get (int const limit_id);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE. */
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,198 @@
|
||||
/*============================================================================
|
||||
base_int.h
|
||||
==============================================================================
|
||||
This header file defines the interface between modules inside
|
||||
xmlrpc-c.
|
||||
|
||||
Use this in addition to xmlrpc.h, which defines the external
|
||||
interface.
|
||||
|
||||
Copyright information is at the end of the file.
|
||||
============================================================================*/
|
||||
|
||||
|
||||
#ifndef XMLRPC_C_BASE_INT_H_INCLUDED
|
||||
#define XMLRPC_C_BASE_INT_H_INCLUDED
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
#include "bool.h"
|
||||
#include "int.h"
|
||||
|
||||
#include <xmlrpc-c/base.h>
|
||||
#include <xmlrpc-c/util_int.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
struct _xmlrpc_value {
|
||||
xmlrpc_type _type;
|
||||
int _refcount;
|
||||
|
||||
/* Certain data types store their data directly in the xmlrpc_value. */
|
||||
union {
|
||||
xmlrpc_int32 i;
|
||||
xmlrpc_int64 i8;
|
||||
xmlrpc_bool b;
|
||||
double d;
|
||||
/* time_t t */
|
||||
void * c_ptr;
|
||||
} _value;
|
||||
|
||||
/* Other data types use a memory block.
|
||||
|
||||
For a string, this is the characters of the lines of the string
|
||||
in UTF-8, with lines delimited by either CR, LF, or CRLF, plus
|
||||
a NUL added to the end. The characters of the lines may be any
|
||||
character representable in UTF-8, even the ones that are not
|
||||
legal XML (XML doesn't allow ASCII control characters except
|
||||
tab, CR, LF). But note that a line can't contain CR or LF
|
||||
because that would form a line delimiter. To disambiguate:
|
||||
CRLF together is always one line delimiter.
|
||||
|
||||
This format for string is quite convenient because it is also
|
||||
the format of that part of an XML document which is the
|
||||
contents of a <string> element (except of course that for the
|
||||
non-XML characters, we have to stretch the definition of XML).
|
||||
|
||||
For base64, this is bytes of the byte string, directly.
|
||||
|
||||
For datetime, this is in the same format as the contents of
|
||||
a <dateTime.iso8601> XML element. That really ought to be changed
|
||||
to time_t some day.
|
||||
*/
|
||||
xmlrpc_mem_block _block;
|
||||
|
||||
xmlrpc_mem_block *_wcs_block;
|
||||
/* This is a copy of the string value in _block, but in UTF-16
|
||||
instead of UTF-8. This member is not always present. If NULL,
|
||||
it is not present.
|
||||
|
||||
We keep this copy for convenience. The value is totally
|
||||
redundant with _block.
|
||||
|
||||
This member is always NULL when the data type is not string.
|
||||
|
||||
This member is always NULL on a system that does not have
|
||||
Unicode wchar functions.
|
||||
*/
|
||||
};
|
||||
|
||||
#define XMLRPC_ASSERT_VALUE_OK(val) \
|
||||
XMLRPC_ASSERT((val) != NULL && (val)->_type != XMLRPC_TYPE_DEAD)
|
||||
|
||||
/* A handy type-checking routine. */
|
||||
#define XMLRPC_TYPE_CHECK(env,v,t) \
|
||||
do \
|
||||
if ((v)->_type != (t)) \
|
||||
XMLRPC_FAIL(env, XMLRPC_TYPE_ERROR, "Expected " #t); \
|
||||
while (0)
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t keyHash;
|
||||
xmlrpc_value * key;
|
||||
xmlrpc_value * value;
|
||||
} _struct_member;
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_createXmlrpcValue(xmlrpc_env * const envP,
|
||||
xmlrpc_value ** const valPP);
|
||||
|
||||
const char *
|
||||
xmlrpc_typeName(xmlrpc_type const type);
|
||||
|
||||
void
|
||||
xmlrpc_traceXml(const char * const label,
|
||||
const char * const xml,
|
||||
unsigned int const xmlLength);
|
||||
|
||||
void
|
||||
xmlrpc_destroyString(xmlrpc_value * const stringP);
|
||||
|
||||
void
|
||||
xmlrpc_destroyStruct(xmlrpc_value * const structP);
|
||||
|
||||
void
|
||||
xmlrpc_destroyArrayContents(xmlrpc_value * const arrayP);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
The following are for use by the legacy xmlrpc_parse_value(). They don't
|
||||
do proper memory management, so they aren't appropriate for general use,
|
||||
but there are old users that do xmlrpc_parse_value() and compensate for
|
||||
the memory management, so we have to continue to offer this style of
|
||||
memory management.
|
||||
|
||||
In particular, the functions that return xmlrpc_values don't increment
|
||||
the reference count, and the functions that return strings don't allocate
|
||||
new memory for them.
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
xmlrpc_read_datetime_str_old(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_old(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_lp_old(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
size_t * const lengthP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
#if XMLRPC_HAVE_WCHAR
|
||||
void
|
||||
xmlrpc_read_string_w_old(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP,
|
||||
const wchar_t ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_w_lp_old(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP,
|
||||
size_t * const lengthP,
|
||||
const wchar_t ** const stringValueP);
|
||||
#endif
|
||||
|
||||
void
|
||||
xmlrpc_read_base64_old(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
size_t * const lengthP,
|
||||
const unsigned char ** const byteStringValueP);
|
||||
|
||||
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,20 @@
|
||||
#ifndef XMLRPC_C_C_UTIL_H_INCLUDED
|
||||
#define XMLRPC_C_C_UTIL_H_INCLUDED
|
||||
|
||||
/* C language stuff. Doesn't involve any libraries that aren't part of
|
||||
the compiler.
|
||||
*/
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
||||
|
||||
/* GNU_PRINTF_ATTR lets the GNU compiler check printf-type
|
||||
calls to be sure the arguments match the format string, thus preventing
|
||||
runtime segmentation faults and incorrect messages.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define GNU_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
|
||||
#else
|
||||
#define GNU_PRINTF_ATTR(a,b)
|
||||
#endif
|
||||
|
||||
#endif
|
316
ede-bug-tools/ede-bug-report/xmlrpc-c/include/xmlrpc-c/client.h
Normal file
316
ede-bug-tools/ede-bug-report/xmlrpc-c/include/xmlrpc-c/client.h
Normal file
@ -0,0 +1,316 @@
|
||||
/*============================================================================
|
||||
xmlrpc_client.h
|
||||
==============================================================================
|
||||
This header file defines the interface between xmlrpc.c and its users,
|
||||
related to clients.
|
||||
|
||||
Copyright information is at the end of the file.
|
||||
============================================================================*/
|
||||
|
||||
#ifndef XMLRPC_CLIENT_H_INCLUDED
|
||||
#define XMLRPC_CLIENT_H_INCLUDED
|
||||
|
||||
#include <xmlrpc-c/base.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct xmlrpc_client;
|
||||
struct xmlrpc_client_transport;
|
||||
struct xmlrpc_client_transport_ops;
|
||||
#ifndef __cplusplus
|
||||
typedef struct xmlrpc_client xmlrpc_client;
|
||||
typedef struct xmlrpc_client_transport xmlrpc_client_transport;
|
||||
typedef struct xmlrpc_client_transport_ops xmlrpc_client_transport_ops;
|
||||
#endif
|
||||
|
||||
/* libxmlrpc_client typically does _not_ actually include all of the
|
||||
XML transports declared here by xmlrpc_*_transport_ops.
|
||||
|
||||
Use 'xmlrpc-c-config --features' to determine which features are
|
||||
installed.
|
||||
*/
|
||||
|
||||
/* Before Xmlrpc-c 1.13 (December 2007), we declared struct
|
||||
xmlrpc_xportparms, as a sort of "base class." The struct was never
|
||||
complete -- you just cast pointer to it it to pointers to other
|
||||
types. It turned out not to be really helpful and casts are ugly,
|
||||
so now we just use void * as a base class pointer.
|
||||
*/
|
||||
|
||||
extern struct xmlrpc_client_transport_ops xmlrpc_libwww_transport_ops;
|
||||
extern struct xmlrpc_client_transport_ops xmlrpc_wininet_transport_ops;
|
||||
extern struct xmlrpc_client_transport_ops xmlrpc_curl_transport_ops;
|
||||
|
||||
enum xmlrpc_sslversion {
|
||||
XMLRPC_SSLVERSION_DEFAULT,
|
||||
XMLRPC_SSLVERSION_TLSv1,
|
||||
XMLRPC_SSLVERSION_SSLv2,
|
||||
XMLRPC_SSLVERSION_SSLv3
|
||||
};
|
||||
|
||||
struct xmlrpc_curl_xportparms {
|
||||
/* This is designed so that zero values are always the defaults. */
|
||||
const char * network_interface;
|
||||
xmlrpc_bool no_ssl_verifypeer;
|
||||
xmlrpc_bool no_ssl_verifyhost;
|
||||
const char * user_agent;
|
||||
const char * ssl_cert;
|
||||
const char * sslcerttype;
|
||||
const char * sslcertpasswd;
|
||||
const char * sslkey;
|
||||
const char * sslkeytype;
|
||||
const char * sslkeypasswd;
|
||||
const char * sslengine;
|
||||
xmlrpc_bool sslengine_default;
|
||||
enum xmlrpc_sslversion sslversion;
|
||||
const char * cainfo;
|
||||
const char * capath;
|
||||
const char * randomfile;
|
||||
const char * egdsocket;
|
||||
const char * ssl_cipher_list;
|
||||
unsigned int timeout;
|
||||
};
|
||||
|
||||
|
||||
#define XMLRPC_CXPSIZE(mbrname) \
|
||||
XMLRPC_STRUCTSIZE(struct xmlrpc_curl_xportparms, mbrname)
|
||||
|
||||
/* XMLRPC_CXPSIZE(xyz) is analogous to XMLRPC_CPSIZE, below */
|
||||
|
||||
struct xmlrpc_wininet_xportparms {
|
||||
int allowInvalidSSLCerts;
|
||||
};
|
||||
|
||||
#define XMLRPC_WXPSIZE(mbrname) \
|
||||
XMLRPC_STRUCTSIZE(struct xmlrpc_wininet_xportparms, mbrname)
|
||||
|
||||
/* XMLRPC_WXPSIZE(xyz) is analogous to XMLRPC_CPSIZE, below */
|
||||
|
||||
struct xmlrpc_clientparms {
|
||||
/* (transport, transportparmsP, transportparm_size) and
|
||||
(transportOpsP, transportP) are mutually exclusive.
|
||||
*/
|
||||
const char * transport;
|
||||
const void * transportparmsP;
|
||||
/* This should be type "const struct ..._xportparms *" */
|
||||
size_t transportparm_size;
|
||||
|
||||
const struct xmlrpc_client_transport_ops * transportOpsP;
|
||||
xmlrpc_client_transport * transportP;
|
||||
xmlrpc_dialect dialect;
|
||||
};
|
||||
|
||||
#define XMLRPC_CPSIZE(mbrname) \
|
||||
XMLRPC_STRUCTSIZE(struct xmlrpc_clientparms, mbrname)
|
||||
|
||||
/* XMLRPC_CPSIZE(xyz) is the minimum size a struct xmlrpc_clientparms
|
||||
must be to include the 'xyz' member. This is essential to forward and
|
||||
backward compatbility, as new members will be added to the end of the
|
||||
struct in future releases. This is how the callee knows whether or
|
||||
not the caller is new enough to have supplied a certain parameter.
|
||||
*/
|
||||
|
||||
const char *
|
||||
xmlrpc_client_get_default_transport(xmlrpc_env * const env);
|
||||
|
||||
/* A callback function to handle the response to an asynchronous call.
|
||||
** If 'fault->fault_occurred' is true, then response will be NULL. All
|
||||
** arguments except 'user_data' will be deallocated internally; please do
|
||||
** not free any of them yourself.
|
||||
** WARNING: param_array may (or may not) be NULL if fault->fault_occurred
|
||||
** is true, and you set up the call using xmlrpc_client_call_asynch.
|
||||
** WARNING: If asynchronous calls are still pending when the library is
|
||||
** shut down, your handler may (or may not) be called with a fault. */
|
||||
typedef void (*xmlrpc_response_handler) (const char *server_url,
|
||||
const char *method_name,
|
||||
xmlrpc_value *param_array,
|
||||
void *user_data,
|
||||
xmlrpc_env *fault,
|
||||
xmlrpc_value *result);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
xmlrpc_server_info
|
||||
===========================================================================
|
||||
We normally refer to servers by URL. But sometimes we need to do extra
|
||||
setup for particular servers. In that case, we can create an
|
||||
xmlrpc_server_info object, configure it in various ways, and call the
|
||||
remote server.
|
||||
|
||||
(This interface is also designed to discourage further multiplication
|
||||
of xmlrpc_client_call APIs. We have enough of those already. Please
|
||||
add future options and flags using xmlrpc_server_info.)
|
||||
=========================================================================*/
|
||||
|
||||
typedef struct _xmlrpc_server_info xmlrpc_server_info;
|
||||
|
||||
/* Create a new server info record, pointing to the specified server. */
|
||||
xmlrpc_server_info *
|
||||
xmlrpc_server_info_new(xmlrpc_env * const envP,
|
||||
const char * const serverUrl);
|
||||
|
||||
/* Create a new server info record, with a copy of the old server. */
|
||||
extern xmlrpc_server_info *
|
||||
xmlrpc_server_info_copy(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const srcP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_free(xmlrpc_server_info * const serverP);
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_server_info_set_user(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const serverInfoP,
|
||||
const char * const username,
|
||||
const char * const password);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_set_basic_auth(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const serverP,
|
||||
const char * const username,
|
||||
const char * const password);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_allow_auth_basic(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_disallow_auth_basic(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_allow_auth_digest(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_disallow_auth_digest(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_allow_auth_negotiate(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_disallow_auth_negotiate(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_allow_auth_ntlm(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_disallow_auth_ntlm(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
extern unsigned int const xmlrpc_client_version_major;
|
||||
extern unsigned int const xmlrpc_client_version_minor;
|
||||
extern unsigned int const xmlrpc_client_version_point;
|
||||
|
||||
void
|
||||
xmlrpc_client_setup_global_const(xmlrpc_env * const envP);
|
||||
|
||||
void
|
||||
xmlrpc_client_teardown_global_const(void);
|
||||
|
||||
void
|
||||
xmlrpc_client_create(xmlrpc_env * const envP,
|
||||
int const flags,
|
||||
const char * const appname,
|
||||
const char * const appversion,
|
||||
const struct xmlrpc_clientparms * const clientparmsP,
|
||||
unsigned int const parmSize,
|
||||
xmlrpc_client ** const clientPP);
|
||||
|
||||
void
|
||||
xmlrpc_client_destroy(xmlrpc_client * const clientP);
|
||||
|
||||
void
|
||||
xmlrpc_client_transport_call2(
|
||||
xmlrpc_env * const envP,
|
||||
xmlrpc_client * const clientP,
|
||||
const xmlrpc_server_info * const serverP,
|
||||
xmlrpc_mem_block * const callXmlP,
|
||||
xmlrpc_mem_block ** const respXmlPP);
|
||||
|
||||
void
|
||||
xmlrpc_client_call2(xmlrpc_env * const envP,
|
||||
struct xmlrpc_client * const clientP,
|
||||
const xmlrpc_server_info * const serverInfoP,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
xmlrpc_value ** const resultPP);
|
||||
|
||||
void
|
||||
xmlrpc_client_call2f(xmlrpc_env * const envP,
|
||||
xmlrpc_client * const clientP,
|
||||
const char * const serverUrl,
|
||||
const char * const methodName,
|
||||
xmlrpc_value ** const resultPP,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
void
|
||||
xmlrpc_client_event_loop_finish(xmlrpc_client * const clientP);
|
||||
|
||||
void
|
||||
xmlrpc_client_event_loop_finish_timeout(xmlrpc_client * const clientP,
|
||||
unsigned long const milliseconds);
|
||||
|
||||
void
|
||||
xmlrpc_client_start_rpc(xmlrpc_env * const envP,
|
||||
struct xmlrpc_client * const clientP,
|
||||
xmlrpc_server_info * const serverInfoP,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const argP,
|
||||
xmlrpc_response_handler responseHandler,
|
||||
void * const userData);
|
||||
|
||||
void
|
||||
xmlrpc_client_start_rpcf(xmlrpc_env * const envP,
|
||||
xmlrpc_client * const clientP,
|
||||
const char * const serverUrl,
|
||||
const char * const methodName,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const userData,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
void
|
||||
xmlrpc_client_set_interrupt(xmlrpc_client * const clientP,
|
||||
int * const interruptP);
|
||||
|
||||
#include <xmlrpc-c/client_global.h>
|
||||
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE. */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _XMLRPC_CLIENT_H_ */
|
@ -0,0 +1,141 @@
|
||||
#ifndef CLIENT_GLOBAL_H_INCLUDED
|
||||
#define CLIENT_GLOBAL_H_INCLUDED
|
||||
|
||||
/*=========================================================================
|
||||
** Initialization and Shutdown
|
||||
**=========================================================================
|
||||
** These routines initialize and terminate the XML-RPC client. If you're
|
||||
** already using libwww on your own, you can pass
|
||||
** XMLRPC_CLIENT_SKIP_LIBWWW_INIT to avoid initializing it twice.
|
||||
*/
|
||||
|
||||
#define XMLRPC_CLIENT_NO_FLAGS (0)
|
||||
#define XMLRPC_CLIENT_SKIP_LIBWWW_INIT (1)
|
||||
|
||||
extern void
|
||||
xmlrpc_client_init(int const flags,
|
||||
const char * const appname,
|
||||
const char * const appversion);
|
||||
|
||||
void
|
||||
xmlrpc_client_init2(xmlrpc_env * const env,
|
||||
int const flags,
|
||||
const char * const appname,
|
||||
const char * const appversion,
|
||||
const struct xmlrpc_clientparms * const clientparms,
|
||||
unsigned int const parm_size);
|
||||
|
||||
extern void
|
||||
xmlrpc_client_cleanup(void);
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_client_call
|
||||
**=========================================================================
|
||||
** A synchronous XML-RPC client. Do not attempt to call any of these
|
||||
** functions from inside an asynchronous callback!
|
||||
*/
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_client_call(xmlrpc_env * const envP,
|
||||
const char * const server_url,
|
||||
const char * const method_name,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_client_call_params(xmlrpc_env * const envP,
|
||||
const char * const serverUrl,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_client_call_server(xmlrpc_env * const envP,
|
||||
const xmlrpc_server_info * const server,
|
||||
const char * const method_name,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_client_call_server_params(
|
||||
xmlrpc_env * const envP,
|
||||
const xmlrpc_server_info * const serverP,
|
||||
const char * const method_name,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
void
|
||||
xmlrpc_client_transport_call(
|
||||
xmlrpc_env * const envP,
|
||||
void * const reserved, /* for client handle */
|
||||
const xmlrpc_server_info * const serverP,
|
||||
xmlrpc_mem_block * const callXmlP,
|
||||
xmlrpc_mem_block ** const respXmlPP);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_client_call_asynch
|
||||
**=========================================================================
|
||||
** An asynchronous XML-RPC client.
|
||||
*/
|
||||
|
||||
/* Make an asynchronous XML-RPC call. We make internal copies of all
|
||||
** arguments except user_data, so you can deallocate them safely as soon
|
||||
** as you return. Errors will be passed to the callback. You will need
|
||||
** to run the event loop somehow; see below.
|
||||
** WARNING: If an error occurs while building the argument, the
|
||||
** response handler will be called with a NULL param_array. */
|
||||
void
|
||||
xmlrpc_client_call_asynch(const char * const server_url,
|
||||
const char * const method_name,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const user_data,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
/* As above, but use an xmlrpc_server_info object. The server object can be
|
||||
** safely destroyed as soon as this function returns. */
|
||||
void
|
||||
xmlrpc_client_call_server_asynch(xmlrpc_server_info * const server,
|
||||
const char * const method_name,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const user_data,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
/* As above, but the parameter list is supplied as an xmlrpc_value
|
||||
** containing an array.
|
||||
*/
|
||||
void
|
||||
xmlrpc_client_call_asynch_params(const char * const server_url,
|
||||
const char * const method_name,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const user_data,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
/* As above, but use an xmlrpc_server_info object. The server object can be
|
||||
** safely destroyed as soon as this function returns. */
|
||||
void
|
||||
xmlrpc_client_call_server_asynch_params(
|
||||
xmlrpc_server_info * const server,
|
||||
const char * const method_name,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const user_data,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
/*=========================================================================
|
||||
** Event Loop Interface
|
||||
**=========================================================================
|
||||
** These functions can be used to run the XML-RPC event loop. If you
|
||||
** don't like these, you can also run the libwww event loop directly.
|
||||
*/
|
||||
|
||||
/* Finish all outstanding asynchronous calls. Alternatively, the loop
|
||||
** will exit if someone calls xmlrpc_client_event_loop_end. */
|
||||
extern void
|
||||
xmlrpc_client_event_loop_finish_asynch(void);
|
||||
|
||||
|
||||
/* Finish all outstanding asynchronous calls. */
|
||||
extern void
|
||||
xmlrpc_client_event_loop_finish_asynch_timeout(unsigned long const milliseconds);
|
||||
|
||||
#endif
|
@ -0,0 +1,121 @@
|
||||
/*============================================================================
|
||||
xmlrpc_client_int.h
|
||||
==============================================================================
|
||||
This header file defines the interface between client modules inside
|
||||
xmlrpc-c.
|
||||
|
||||
Use this in addition to xmlrpc_client.h, which defines the external
|
||||
interface.
|
||||
|
||||
Copyright information is at the end of the file.
|
||||
============================================================================*/
|
||||
|
||||
|
||||
#ifndef XMLRPC_CLIENT_INT_H_INCLUDED
|
||||
#define XMLRPC_CLIENT_INT_H_INCLUDED
|
||||
|
||||
#include "xmlrpc-c/util.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _xmlrpc_server_info {
|
||||
const char * serverUrl;
|
||||
struct {
|
||||
bool basic;
|
||||
bool digest;
|
||||
bool gssnegotiate;
|
||||
bool ntlm;
|
||||
} allowedAuth;
|
||||
const char * userNamePw;
|
||||
/* The username/password value for HTTP, i.e. in
|
||||
"user:password" form
|
||||
|
||||
This can be NULL to indicate "none", but only if 'allowedAuth'
|
||||
doesn't allow any form of authentication.
|
||||
*/
|
||||
const char * basicAuthHdrValue;
|
||||
/* A complete value for an HTTP Authorization: header that
|
||||
requests HTTP basic authentication. This exists whether
|
||||
or not 'allowedAuth' allows basic authentication, and is
|
||||
completely redundant with 'userNamePw'. It exists mainly
|
||||
for historical reasons, and may also save some computation
|
||||
when the same xmrpc_server_info is used for multiple
|
||||
HTTP connections.
|
||||
|
||||
This is NULL exactly when 'userNamePw' is NULL.
|
||||
*/
|
||||
};
|
||||
|
||||
/*=========================================================================
|
||||
** Transport Implementation functions.
|
||||
**========================================================================= */
|
||||
#include "xmlrpc-c/transport.h"
|
||||
|
||||
/* The generalized event loop. This uses the above flags. For more details,
|
||||
** see the wrapper functions below. If you're not using the timeout, the
|
||||
** 'milliseconds' parameter will be ignored.
|
||||
** Note that ANY event loop call will return immediately if there are
|
||||
** no outstanding XML-RPC calls. */
|
||||
extern void
|
||||
xmlrpc_client_event_loop_run_general (int flags, xmlrpc_timeout milliseconds);
|
||||
|
||||
/* Run the event loop forever. The loop will exit if someone calls
|
||||
** xmlrpc_client_event_loop_end. */
|
||||
extern void
|
||||
xmlrpc_client_event_loop_run (void);
|
||||
|
||||
/* Run the event loop forever. The loop will exit if someone calls
|
||||
** xmlrpc_client_event_loop_end or the timeout expires.
|
||||
** (Note that ANY event loop call will return immediately if there are
|
||||
** no outstanding XML-RPC calls.) */
|
||||
extern void
|
||||
xmlrpc_client_event_loop_run_timeout (xmlrpc_timeout milliseconds);
|
||||
|
||||
/* End the running event loop immediately. This can also be accomplished
|
||||
** by calling the corresponding function in libwww.
|
||||
** (Note that ANY event loop call will return immediately if there are
|
||||
** no outstanding XML-RPC calls.) */
|
||||
extern void
|
||||
xmlrpc_client_event_loop_end (void);
|
||||
|
||||
|
||||
/* Return true if there are uncompleted asynchronous calls.
|
||||
** The exact value of this during a response callback is undefined. */
|
||||
extern int
|
||||
xmlrpc_client_asynch_calls_are_unfinished (void);
|
||||
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
#ifndef XMLRPC_C_CONFIG_H_INCLUDED
|
||||
#define XMLRPC_C_CONFIG_H_INCLUDED
|
||||
|
||||
/* This file, part of XML-RPC For C/C++, is meant to
|
||||
define characteristics of this particular installation
|
||||
that the other <xmlrpc-c/...> header files need in
|
||||
order to compile correctly when #included in Xmlrpc-c
|
||||
user code.
|
||||
|
||||
Those header files #include this one.
|
||||
|
||||
This file was created by a make rule.
|
||||
*/
|
||||
#define XMLRPC_HAVE_WCHAR 1
|
||||
#ifdef WIN32
|
||||
/* SOCKET is a type defined by <winsock.h>. Anyone who
|
||||
uses XMLRPC_SOCKET on a WIN32 system must #include
|
||||
<winsock.h>
|
||||
*/
|
||||
#define XMLRPC_SOCKET SOCKET
|
||||
#define XMLRPC_HAVE_TIMEVAL 0
|
||||
#define XMLRPC_HAVE_TIMESPEC 0
|
||||
#else
|
||||
#define XMLRPC_SOCKET int
|
||||
#define XMLRPC_HAVE_TIMEVAL 1
|
||||
#define XMLRPC_HAVE_TIMESPEC 1
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
/* Newer MSVC has long long, but MSVC 6 does not */
|
||||
#define XMLRPC_INT64 __int64
|
||||
#define XMLRPC_INT32 __int32
|
||||
#else
|
||||
#define XMLRPC_INT64 long long
|
||||
#define XMLRPC_INT32 int
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,19 @@
|
||||
#ifndef XMLRPC_INTTYPES_H_INCLUDED
|
||||
#define XMLRPC_INTTYPES_H_INCLUDED
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
typedef unsigned short xmlrpc_uint16_t;
|
||||
typedef unsigned int xmlrpc_uint32_t;
|
||||
typedef unsigned __int64 xmlrpc_uint64_t;
|
||||
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
|
||||
typedef uint16_t xmlrpc_uint16_t;
|
||||
typedef uint32_t xmlrpc_uint32_t;
|
||||
typedef uint64_t xmlrpc_uint64_t;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,2 @@
|
||||
#include <xmlrpc-c/base.h>
|
||||
#include <xmlrpc-c/server.h>
|
@ -0,0 +1,24 @@
|
||||
#ifndef SELECT_INT_H_INCLUDED
|
||||
#define SELECT_INT_H_INCLUDED
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
|
||||
#include "xmlrpc-c/time_int.h"
|
||||
#ifdef WIN32
|
||||
#ifndef sigset_t
|
||||
typedef int sigset_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int
|
||||
xmlrpc_pselect(int const n,
|
||||
fd_set * const readfdsP,
|
||||
fd_set * const writefdsP,
|
||||
fd_set * const exceptfdsP,
|
||||
const xmlrpc_timespec * const timeoutP,
|
||||
sigset_t * const sigmaskP);
|
||||
|
||||
#endif
|
173
ede-bug-tools/ede-bug-report/xmlrpc-c/include/xmlrpc-c/server.h
Normal file
173
ede-bug-tools/ede-bug-report/xmlrpc-c/include/xmlrpc-c/server.h
Normal file
@ -0,0 +1,173 @@
|
||||
/* Copyright and license information is at the end of the file */
|
||||
|
||||
#ifndef XMLRPC_SERVER_H_INCLUDED
|
||||
#define XMLRPC_SERVER_H_INCLUDED
|
||||
|
||||
#include <xmlrpc-c/base.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct xmlrpc_registry xmlrpc_registry;
|
||||
|
||||
typedef void
|
||||
(*xmlrpc_preinvoke_method)(xmlrpc_env * const envP,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
void * const userData);
|
||||
|
||||
typedef xmlrpc_value *
|
||||
(*xmlrpc_method1)(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
void * const serverInfo);
|
||||
|
||||
typedef xmlrpc_value *
|
||||
(*xmlrpc_method2)(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
void * const serverInfo,
|
||||
void * const callInfo);
|
||||
|
||||
typedef xmlrpc_method1 xmlrpc_method; /* backward compatibility */
|
||||
|
||||
typedef xmlrpc_value *
|
||||
(*xmlrpc_default_method)(xmlrpc_env * const envP,
|
||||
const char * const callInfoP,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
void * const serverInfo);
|
||||
|
||||
extern unsigned int const xmlrpc_server_version_major;
|
||||
extern unsigned int const xmlrpc_server_version_minor;
|
||||
extern unsigned int const xmlrpc_server_version_point;
|
||||
|
||||
xmlrpc_registry *
|
||||
xmlrpc_registry_new(xmlrpc_env * const envP);
|
||||
|
||||
void
|
||||
xmlrpc_registry_free(xmlrpc_registry * const registryP);
|
||||
|
||||
void
|
||||
xmlrpc_registry_disable_introspection(xmlrpc_registry * const registryP);
|
||||
|
||||
void
|
||||
xmlrpc_registry_add_method(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
const char * const host,
|
||||
const char * const methodName,
|
||||
xmlrpc_method const method,
|
||||
void * const serverInfo);
|
||||
|
||||
void
|
||||
xmlrpc_registry_add_method_w_doc(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
const char * const host,
|
||||
const char * const methodName,
|
||||
xmlrpc_method const method,
|
||||
void * const serverInfo,
|
||||
const char * const signatureString,
|
||||
const char * const help);
|
||||
|
||||
void
|
||||
xmlrpc_registry_add_method2(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
const char * const methodName,
|
||||
xmlrpc_method2 method,
|
||||
const char * const signatureString,
|
||||
const char * const help,
|
||||
void * const serverInfo);
|
||||
|
||||
struct xmlrpc_method_info3 {
|
||||
const char * methodName;
|
||||
xmlrpc_method2 methodFunction;
|
||||
void * serverInfo;
|
||||
size_t stackSize;
|
||||
const char * signatureString;
|
||||
const char * help;
|
||||
};
|
||||
|
||||
void
|
||||
xmlrpc_registry_add_method3(
|
||||
xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
const struct xmlrpc_method_info3 * const infoP);
|
||||
|
||||
void
|
||||
xmlrpc_registry_set_default_method(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
xmlrpc_default_method const handler,
|
||||
void * const userData);
|
||||
|
||||
void
|
||||
xmlrpc_registry_set_preinvoke_method(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
xmlrpc_preinvoke_method const method,
|
||||
void * const userData);
|
||||
|
||||
|
||||
typedef void xmlrpc_server_shutdown_fn(xmlrpc_env * const envP,
|
||||
void * const context,
|
||||
const char * const comment,
|
||||
void * const callInfo);
|
||||
|
||||
void
|
||||
xmlrpc_registry_set_shutdown(xmlrpc_registry * const registryP,
|
||||
xmlrpc_server_shutdown_fn * const shutdownFn,
|
||||
void * const context);
|
||||
|
||||
void
|
||||
xmlrpc_registry_set_dialect(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
xmlrpc_dialect const dialect);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Lower interface -- services to be used by an HTTP request handler
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
xmlrpc_registry_process_call2(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
const char * const xmlData,
|
||||
size_t const xmlLen,
|
||||
void * const callInfo,
|
||||
xmlrpc_mem_block ** const outputPP);
|
||||
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_registry_process_call(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
const char * const host,
|
||||
const char * const xmlData,
|
||||
size_t const xmlLen);
|
||||
|
||||
size_t
|
||||
xmlrpc_registry_max_stackSize(xmlrpc_registry * const registryP);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE. */
|
||||
#endif
|
@ -0,0 +1,49 @@
|
||||
/* Interface header file for libxmlrpc_server_cgi.
|
||||
|
||||
By Bryan Henderson, 05.04.27. Contributed to the public domain.
|
||||
*/
|
||||
|
||||
#ifndef XMLRPC_CGI_H_INCLUDED
|
||||
#define XMLRPC_CGI_H_INCLUDED
|
||||
|
||||
#include <xmlrpc-c/server.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_server_cgi_process_call(xmlrpc_registry * const registryP);
|
||||
|
||||
#define XMLRPC_CGI_NO_FLAGS (0)
|
||||
|
||||
extern void
|
||||
xmlrpc_cgi_init (int flags);
|
||||
|
||||
extern xmlrpc_registry *
|
||||
xmlrpc_cgi_registry (void);
|
||||
|
||||
void
|
||||
xmlrpc_cgi_add_method(const char * const method_name,
|
||||
xmlrpc_method const method,
|
||||
void * const user_data);
|
||||
|
||||
void
|
||||
xmlrpc_cgi_add_method_w_doc(const char * const method_name,
|
||||
xmlrpc_method const method,
|
||||
void * const user_data,
|
||||
const char * const signature,
|
||||
const char * const help);
|
||||
extern void
|
||||
xmlrpc_cgi_process_call (void);
|
||||
|
||||
extern void
|
||||
xmlrpc_cgi_cleanup (void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
@ -0,0 +1,95 @@
|
||||
/* Copyright (C) 2005 by Steven A. Bone, sbone@pobox.com. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE. */
|
||||
|
||||
/* COMPILATION NOTE:
|
||||
Note that the Platform SDK headers and
|
||||
link libraries for Windows XP SP2 or newer are required to compile
|
||||
xmlrpc-c for this module. If you are not using this server, it is
|
||||
safe to exclude the xmlrpc_server_w32httpsys.c file from the xmlrpc
|
||||
project and these dependencies will not be required. You can get the
|
||||
latest platform SDK at
|
||||
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
|
||||
Be sure after installation to choose the program to "register the PSDK
|
||||
directories with Visual Studio" so the newer headers are found.
|
||||
*/
|
||||
|
||||
#ifndef _XMLRPC_SERVER_HTTPSYS_H_
|
||||
#define _XMLRPC_SERVER_HTTPSYS_H_ 1
|
||||
|
||||
#include "transport_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*=========================================================================
|
||||
** XML-RPC Server (based on HTTP.SYS)
|
||||
**=========================================================================
|
||||
** A simple XML-RPC server based on the "built-in" Windows web server,
|
||||
** HTTP.SYS. This is provided by Microsoft in Windows XP SP2 and
|
||||
** Windows Server 2003. If errors occur during server setup, the server
|
||||
** will exit. In general, if you want to use this API, you do not really
|
||||
** need to be familiar with the HTTP.SYS API.
|
||||
*/
|
||||
|
||||
typedef void (*authorization_function)(
|
||||
xmlrpc_env * envP,
|
||||
char * userid,
|
||||
char * password);
|
||||
|
||||
typedef struct {
|
||||
xmlrpc_registry * registryP;
|
||||
unsigned int portNum;
|
||||
unsigned int useSSL;
|
||||
/* useSSL, 0 = no SSL, 1 = use SSL */
|
||||
unsigned int logLevel;
|
||||
/* logLevel, 0 = none, 1 = file, 2 = file+OutputDebugString() */
|
||||
const char * logFile;
|
||||
/* logFile, NULL or filename */
|
||||
authorization_function authfn;
|
||||
} xmlrpc_server_httpsys_parms;
|
||||
|
||||
#define XMLRPC_HSSIZE(MBRNAME) \
|
||||
XMLRPC_STRUCTSIZE(xmlrpc_server_httpsys_parms, MBRNAME)
|
||||
|
||||
/* XMLRPC_HSSIZE(xyz) is the minimum size a struct xmlrpc_server_httpsys_parms
|
||||
must be to include the 'xyz' member. This is essential for forward and
|
||||
backward compatbility, as new members will be added to the end of the
|
||||
struct in future releases. This is how the callee knows whether or
|
||||
not the caller is new enough to have supplied a certain parameter.
|
||||
*/
|
||||
|
||||
void
|
||||
xmlrpc_server_httpsys(
|
||||
xmlrpc_env * const envP,
|
||||
const xmlrpc_server_httpsys_parms * const parmsP,
|
||||
unsigned int const parm_size
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
@ -0,0 +1,7 @@
|
||||
#ifndef SLEEP_INT_H_INCLUDED
|
||||
#define SLEEP_INT_H_INCLUDED
|
||||
|
||||
void
|
||||
xmlrpc_millisecond_sleep(unsigned int const milliseconds);
|
||||
|
||||
#endif
|
@ -0,0 +1,113 @@
|
||||
#ifndef XMLRPC_C_STRING_INT_H_INCLUDED
|
||||
#define XMLRPC_C_STRING_INT_H_INCLUDED
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
#include "c_util.h"
|
||||
#include "bool.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char * const xmlrpc_strsol;
|
||||
|
||||
void
|
||||
xmlrpc_vasprintf(const char ** const retvalP,
|
||||
const char * const fmt,
|
||||
va_list varargs);
|
||||
|
||||
void GNU_PRINTF_ATTR(2,3)
|
||||
xmlrpc_asprintf(const char ** const retvalP, const char * const fmt, ...);
|
||||
|
||||
const char *
|
||||
xmlrpc_strdupnull(const char * const string);
|
||||
|
||||
void
|
||||
xmlrpc_strfree(const char * const string);
|
||||
|
||||
void
|
||||
xmlrpc_strfreenull(const char * const string);
|
||||
|
||||
static __inline__ bool
|
||||
xmlrpc_streq(const char * const a,
|
||||
const char * const b) {
|
||||
return (strcmp(a, b) == 0);
|
||||
}
|
||||
|
||||
static __inline__ bool
|
||||
xmlrpc_memeq(const void * const a,
|
||||
const void * const b,
|
||||
size_t const size) {
|
||||
|
||||
return (memcmp(a, b, size) == 0);
|
||||
}
|
||||
|
||||
/* strcasecmp doesn't exist on some systems without _BSD_SOURCE, so
|
||||
xmlrpc_strcaseeq() can't either.
|
||||
*/
|
||||
#ifdef _BSD_SOURCE
|
||||
|
||||
static __inline__ bool
|
||||
xmlrpc_strcaseeq(const char * const a,
|
||||
const char * const b) {
|
||||
#if HAVE_STRCASECMP
|
||||
return (strcasecmp(a, b) == 0);
|
||||
#elif HAVE__STRICMP
|
||||
return (_stricmp(a, b) == 0);
|
||||
#elif HAVE_STRICMP
|
||||
return (stricmp(a, b) == 0);
|
||||
#else
|
||||
#error "This platform has no known case-independent string compare fn"
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline__ bool
|
||||
xmlrpc_strneq(const char * const a,
|
||||
const char * const b,
|
||||
size_t const len) {
|
||||
return (strncmp(a, b, len) == 0);
|
||||
}
|
||||
|
||||
const char *
|
||||
xmlrpc_makePrintable(const char * const input);
|
||||
|
||||
const char *
|
||||
xmlrpc_makePrintable_lp(const char * const input,
|
||||
size_t const inputLength);
|
||||
|
||||
const char *
|
||||
xmlrpc_makePrintableChar(char const input);
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
/* Standard string functions with destination array size checking */
|
||||
/*----------------------------------------------------------------*/
|
||||
#define STRSCPY(A,B) \
|
||||
(strncpy((A), (B), sizeof(A)), *((A)+sizeof(A)-1) = '\0')
|
||||
#define STRSCMP(A,B) \
|
||||
(strncmp((A), (B), sizeof(A)))
|
||||
#define STRSCAT(A,B) \
|
||||
(strncat((A), (B), sizeof(A)-strlen(A)), *((A)+sizeof(A)-1) = '\0')
|
||||
|
||||
/* We could do this, but it works only in GNU C
|
||||
#define SSPRINTF(TARGET, REST...) \
|
||||
(snprintf(TARGET, sizeof(TARGET) , ## REST))
|
||||
|
||||
Or this, but it works only in C99 compilers, which leaves out MSVC
|
||||
before 2005 and can't handle the zero variable argument case except
|
||||
by an MSVC extension:
|
||||
|
||||
#define SSPRINTF(TARGET, ...) \
|
||||
(snprintf(TARGET, sizeof(TARGET) , __VA_ARGS__))
|
||||
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,35 @@
|
||||
#ifndef TIME_H_INCLUDED
|
||||
#define TIME_H_INCLUDED
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
#include "xmlrpc-c/util.h"
|
||||
#include "int.h"
|
||||
|
||||
#if HAVE_TIMESPEC
|
||||
typedef struct timespec xmlrpc_timespec;
|
||||
#else
|
||||
typedef struct {
|
||||
uint32_t tv_sec;
|
||||
uint32_t tv_nsec;
|
||||
} xmlrpc_timespec;
|
||||
#endif
|
||||
|
||||
void
|
||||
xmlrpc_gettimeofday(xmlrpc_timespec * const todP);
|
||||
|
||||
void
|
||||
xmlrpc_timegm(const struct tm * const brokenTime,
|
||||
time_t * const timeValueP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
xmlrpc_localtime(time_t const datetime,
|
||||
struct tm * const tmP);
|
||||
|
||||
void
|
||||
xmlrpc_gmtime(time_t const datetime,
|
||||
struct tm * const resultP);
|
||||
|
||||
#endif
|
@ -0,0 +1,86 @@
|
||||
/* Copyright information is at the end of the file */
|
||||
#ifndef XMLRPC_TRANSPORT_H_INCLUDED
|
||||
#define XMLRPC_TRANSPORT_H_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <xmlrpc-c/util.h>
|
||||
#include <xmlrpc-c/client.h>
|
||||
|
||||
struct xmlrpc_call_info;
|
||||
|
||||
struct xmlrpc_client_transport;
|
||||
|
||||
/*=========================================================================
|
||||
** Transport function type declarations.
|
||||
**=========================================================================
|
||||
*/
|
||||
typedef void (*xmlrpc_transport_setup)(xmlrpc_env * const envP);
|
||||
|
||||
typedef void (*xmlrpc_transport_teardown)(void);
|
||||
|
||||
typedef void (*xmlrpc_transport_create)(
|
||||
xmlrpc_env * const envP,
|
||||
int const flags,
|
||||
const char * const appname,
|
||||
const char * const appversion,
|
||||
const void * const transportparmsP,
|
||||
size_t const transportparm_size,
|
||||
struct xmlrpc_client_transport ** const handlePP);
|
||||
|
||||
typedef void (*xmlrpc_transport_destroy)(
|
||||
struct xmlrpc_client_transport * const clientTransportP);
|
||||
|
||||
typedef void (*xmlrpc_transport_asynch_complete)(
|
||||
struct xmlrpc_call_info * const callInfoP,
|
||||
xmlrpc_mem_block * const responseXmlP,
|
||||
xmlrpc_env const env);
|
||||
|
||||
typedef void (*xmlrpc_transport_send_request)(
|
||||
xmlrpc_env * const envP,
|
||||
struct xmlrpc_client_transport * const clientTransportP,
|
||||
const xmlrpc_server_info * const serverP,
|
||||
xmlrpc_mem_block * const xmlP,
|
||||
xmlrpc_transport_asynch_complete complete,
|
||||
struct xmlrpc_call_info * const callInfoP);
|
||||
|
||||
typedef void (*xmlrpc_transport_call)(
|
||||
xmlrpc_env * const envP,
|
||||
struct xmlrpc_client_transport * const clientTransportP,
|
||||
const xmlrpc_server_info * const serverP,
|
||||
xmlrpc_mem_block * const xmlP,
|
||||
xmlrpc_mem_block ** const responsePP);
|
||||
|
||||
typedef enum {timeout_no, timeout_yes} xmlrpc_timeoutType;
|
||||
|
||||
typedef unsigned long xmlrpc_timeout;
|
||||
/* A timeout in milliseconds. */
|
||||
|
||||
typedef void (*xmlrpc_transport_finish_asynch)(
|
||||
struct xmlrpc_client_transport * const clientTransportP,
|
||||
xmlrpc_timeoutType const timeoutType,
|
||||
xmlrpc_timeout const timeout);
|
||||
|
||||
typedef void (*xmlrpc_transport_set_interrupt)(
|
||||
struct xmlrpc_client_transport * const clientTransportP,
|
||||
int * const interruptP);
|
||||
|
||||
struct xmlrpc_client_transport_ops {
|
||||
|
||||
xmlrpc_transport_setup setup_global_const;
|
||||
xmlrpc_transport_teardown teardown_global_const;
|
||||
xmlrpc_transport_create create;
|
||||
xmlrpc_transport_destroy destroy;
|
||||
xmlrpc_transport_send_request send_request;
|
||||
xmlrpc_transport_call call;
|
||||
xmlrpc_transport_finish_asynch finish_asynch;
|
||||
xmlrpc_transport_set_interrupt set_interrupt;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
328
ede-bug-tools/ede-bug-report/xmlrpc-c/include/xmlrpc-c/util.h
Normal file
328
ede-bug-tools/ede-bug-report/xmlrpc-c/include/xmlrpc-c/util.h
Normal file
@ -0,0 +1,328 @@
|
||||
/*=============================================================================
|
||||
xmlrpc-c/util.h
|
||||
===============================================================================
|
||||
|
||||
This is the interface to the libxmlrpc_util library, which contains
|
||||
utility routines that have nothing to do with XML-RPC. The library
|
||||
exists because other Xmlrpc-c libraries use the utilities.
|
||||
|
||||
By Bryan Henderson, San Jose, CA 05.09.21.
|
||||
|
||||
Contributed to the public domain by its author.
|
||||
=============================================================================*/
|
||||
|
||||
#ifndef XMLRPC_C_UTIL_H_INCLUDED
|
||||
#define XMLRPC_C_UTIL_H_INCLUDED
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <xmlrpc-c/config.h> /* Defines XMLRPC_HAVE_WCHAR */
|
||||
#include <xmlrpc-c/c_util.h> /* for GNU_PRINTF_ATTR */
|
||||
|
||||
#if XMLRPC_HAVE_WCHAR
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** C struct size computations
|
||||
**=======================================================================*/
|
||||
|
||||
/* Use XMLRPC_STRUCT_MEMBER_SIZE() to determine how big a structure is
|
||||
up to and including a specified member. E.g. if you have
|
||||
struct mystruct {int red; int green; int blue};, then
|
||||
XMLRPC_STRUCT_MEMBER_SIZE(mystruct, green) is (8).
|
||||
*/
|
||||
|
||||
#define _XMLRPC_STRUCT_MEMBER_OFFSET(TYPE, MBRNAME) \
|
||||
((size_t)(char*)&((TYPE *)0)->MBRNAME)
|
||||
#define _XMLRPC_STRUCT_MEMBER_SIZE(TYPE, MBRNAME) \
|
||||
sizeof(((TYPE *)0)->MBRNAME)
|
||||
#define XMLRPC_STRUCTSIZE(TYPE, MBRNAME) \
|
||||
(_XMLRPC_STRUCT_MEMBER_OFFSET(TYPE, MBRNAME) + \
|
||||
_XMLRPC_STRUCT_MEMBER_SIZE(TYPE, MBRNAME))
|
||||
|
||||
/*=========================================================================
|
||||
** Assertions and Debugging
|
||||
**=========================================================================
|
||||
** Note that an assertion is _not_ a directive to check a condition and
|
||||
** crash if it isn't true. It is an assertion that the condition _is_
|
||||
** true. This assertion helps people to read the code. The program
|
||||
** may also check the assertion as it runs, and if it conflicts with reality,
|
||||
** recognize that the program is incorrect and abort it. In practice,
|
||||
** it does this checking when the program was compiled without the NDEBUG
|
||||
** macro defined.
|
||||
*/
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
#define XMLRPC_ASSERT(cond) \
|
||||
do \
|
||||
if (!(cond)) \
|
||||
xmlrpc_assertion_failed(__FILE__, __LINE__); \
|
||||
while (0)
|
||||
|
||||
#else
|
||||
#define XMLRPC_ASSERT(cond) while (0) {}
|
||||
#endif
|
||||
|
||||
void
|
||||
xmlrpc_assertion_failed(const char * const fileName,
|
||||
int const lineNumber);
|
||||
|
||||
/* Validate a pointer. */
|
||||
#define XMLRPC_ASSERT_PTR_OK(ptr) \
|
||||
XMLRPC_ASSERT((ptr) != NULL)
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_env
|
||||
**=========================================================================
|
||||
** XML-RPC represents runtime errors as <fault> elements. These contain
|
||||
** <faultCode> and <faultString> elements.
|
||||
**
|
||||
** Since we need as much thread-safety as possible, we borrow an idea from
|
||||
** CORBA--we store exception information in an "environment" object.
|
||||
** You'll pass this to many different functions, and it will get filled
|
||||
** out appropriately.
|
||||
**
|
||||
** For example:
|
||||
**
|
||||
** xmlrpc_env env;
|
||||
**
|
||||
** xmlrpc_env_init(&env);
|
||||
**
|
||||
** xmlrpc_do_something(&env);
|
||||
** if (env.fault_occurred)
|
||||
** report_error_appropriately();
|
||||
**
|
||||
** xmlrpc_env_clean(&env);
|
||||
*/
|
||||
|
||||
#define XMLRPC_INTERNAL_ERROR (-500)
|
||||
#define XMLRPC_TYPE_ERROR (-501)
|
||||
#define XMLRPC_INDEX_ERROR (-502)
|
||||
#define XMLRPC_PARSE_ERROR (-503)
|
||||
#define XMLRPC_NETWORK_ERROR (-504)
|
||||
#define XMLRPC_TIMEOUT_ERROR (-505)
|
||||
#define XMLRPC_NO_SUCH_METHOD_ERROR (-506)
|
||||
#define XMLRPC_REQUEST_REFUSED_ERROR (-507)
|
||||
#define XMLRPC_INTROSPECTION_DISABLED_ERROR (-508)
|
||||
#define XMLRPC_LIMIT_EXCEEDED_ERROR (-509)
|
||||
#define XMLRPC_INVALID_UTF8_ERROR (-510)
|
||||
|
||||
typedef struct _xmlrpc_env {
|
||||
int fault_occurred;
|
||||
int fault_code;
|
||||
char * fault_string;
|
||||
} xmlrpc_env;
|
||||
|
||||
/* Initialize and destroy the contents of the provided xmlrpc_env object.
|
||||
** These functions will never fail. */
|
||||
void xmlrpc_env_init (xmlrpc_env* env);
|
||||
void xmlrpc_env_clean (xmlrpc_env* const env);
|
||||
|
||||
/* Fill out an xmlrpc_fault with the specified values, and set the
|
||||
** fault_occurred flag. This function will make a private copy of 'string',
|
||||
** so you retain responsibility for your copy. */
|
||||
void
|
||||
xmlrpc_env_set_fault(xmlrpc_env * const env,
|
||||
int const faultCode,
|
||||
const char * const faultDescription);
|
||||
|
||||
/* The same as the above, but using varargs */
|
||||
void
|
||||
xmlrpc_set_fault_formatted_v(xmlrpc_env * const envP,
|
||||
int const code,
|
||||
const char * const format,
|
||||
va_list const args);
|
||||
|
||||
/* The same as the above, but using a printf-style format string. */
|
||||
void
|
||||
xmlrpc_env_set_fault_formatted(xmlrpc_env * const envP,
|
||||
int const code,
|
||||
const char * const format,
|
||||
...) GNU_PRINTF_ATTR(3,4);
|
||||
|
||||
/* This one infers XMLRPC_INTERNAL_ERROR and has a shorter name.
|
||||
So a call takes up less source code space.
|
||||
*/
|
||||
void
|
||||
xmlrpc_faultf(xmlrpc_env * const envP,
|
||||
const char * const format,
|
||||
...) GNU_PRINTF_ATTR(2,3);
|
||||
|
||||
/* A simple debugging assertion. */
|
||||
#define XMLRPC_ASSERT_ENV_OK(envP) \
|
||||
XMLRPC_ASSERT((envP) != NULL && \
|
||||
(envP->fault_string == NULL) && \
|
||||
!(envP)->fault_occurred)
|
||||
|
||||
/* This version must *not* interpret 'str' as a format string, to avoid
|
||||
** several evil attacks. */
|
||||
#define XMLRPC_FAIL(env,code,str) \
|
||||
do { xmlrpc_env_set_fault((env),(code),(str)); goto cleanup; } while (0)
|
||||
|
||||
#define XMLRPC_FAIL1(env,code,str,arg1) \
|
||||
do { \
|
||||
xmlrpc_env_set_fault_formatted((env),(code),(str),(arg1)); \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
#define XMLRPC_FAIL2(env,code,str,arg1,arg2) \
|
||||
do { \
|
||||
xmlrpc_env_set_fault_formatted((env),(code),(str),(arg1),(arg2)); \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
#define XMLRPC_FAIL3(env,code,str,arg1,arg2,arg3) \
|
||||
do { \
|
||||
xmlrpc_env_set_fault_formatted((env),(code), \
|
||||
(str),(arg1),(arg2),(arg3)); \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
#if defined(__GNUC__)
|
||||
#define XMLRPC_FAILF( env, code, fmt, ... ) \
|
||||
do { \
|
||||
xmlrpc_env_set_fault_formatted((env), (code), (fmt), \
|
||||
##__VA_ARGS__ ); \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define XMLRPC_FAIL_IF_NULL(ptr,env,code,str) \
|
||||
do { \
|
||||
if ((ptr) == NULL) \
|
||||
XMLRPC_FAIL((env),(code),(str)); \
|
||||
} while (0)
|
||||
|
||||
#define XMLRPC_FAIL_IF_FAULT(env) \
|
||||
do { if ((env)->fault_occurred) goto cleanup; } while (0)
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_mem_block
|
||||
**=========================================================================
|
||||
** A resizable chunk of memory. This is mostly used internally, but it is
|
||||
** also used by the public API in a few places.
|
||||
** The struct fields are private!
|
||||
*/
|
||||
|
||||
typedef struct _xmlrpc_mem_block {
|
||||
size_t _size;
|
||||
size_t _allocated;
|
||||
void* _block;
|
||||
} xmlrpc_mem_block;
|
||||
|
||||
/* Allocate a new xmlrpc_mem_block. */
|
||||
xmlrpc_mem_block* xmlrpc_mem_block_new (xmlrpc_env* const env, size_t const size);
|
||||
|
||||
/* Destroy an existing xmlrpc_mem_block, and everything it contains. */
|
||||
void xmlrpc_mem_block_free (xmlrpc_mem_block* const block);
|
||||
|
||||
/* Initialize the contents of the provided xmlrpc_mem_block. */
|
||||
void xmlrpc_mem_block_init
|
||||
(xmlrpc_env* const env, xmlrpc_mem_block* const block, size_t const size);
|
||||
|
||||
/* Deallocate the contents of the provided xmlrpc_mem_block, but not the
|
||||
** block itself. */
|
||||
void xmlrpc_mem_block_clean (xmlrpc_mem_block* const block);
|
||||
|
||||
/* Get the size and contents of the xmlrpc_mem_block. */
|
||||
size_t
|
||||
xmlrpc_mem_block_size(const xmlrpc_mem_block * const block);
|
||||
|
||||
void *
|
||||
xmlrpc_mem_block_contents(const xmlrpc_mem_block * const block);
|
||||
|
||||
/* Resize an xmlrpc_mem_block, preserving as much of the contents as
|
||||
** possible. */
|
||||
void xmlrpc_mem_block_resize
|
||||
(xmlrpc_env* const env, xmlrpc_mem_block* const block, size_t const size);
|
||||
|
||||
/* Append data to an existing xmlrpc_mem_block. */
|
||||
void xmlrpc_mem_block_append
|
||||
(xmlrpc_env* const env, xmlrpc_mem_block* const block, const void * const data, size_t const len);
|
||||
|
||||
#define XMLRPC_MEMBLOCK_NEW(type,env,size) \
|
||||
xmlrpc_mem_block_new((env), sizeof(type) * (size))
|
||||
#define XMLRPC_MEMBLOCK_FREE(type,block) \
|
||||
xmlrpc_mem_block_free(block)
|
||||
#define XMLRPC_MEMBLOCK_INIT(type,env,block,size) \
|
||||
xmlrpc_mem_block_init((env), (block), sizeof(type) * (size))
|
||||
#define XMLRPC_MEMBLOCK_CLEAN(type,block) \
|
||||
xmlrpc_mem_block_clean(block)
|
||||
#define XMLRPC_MEMBLOCK_SIZE(type,block) \
|
||||
(xmlrpc_mem_block_size(block) / sizeof(type))
|
||||
#define XMLRPC_MEMBLOCK_CONTENTS(type,block) \
|
||||
((type*) xmlrpc_mem_block_contents(block))
|
||||
#define XMLRPC_MEMBLOCK_RESIZE(type,env,block,size) \
|
||||
xmlrpc_mem_block_resize(env, block, sizeof(type) * (size))
|
||||
#define XMLRPC_MEMBLOCK_APPEND(type,env,block,data,size) \
|
||||
xmlrpc_mem_block_append(env, block, data, sizeof(type) * (size))
|
||||
|
||||
/* Here are some backward compatibility definitions. These longer names
|
||||
used to be the only ones and typed memory blocks were considered
|
||||
special.
|
||||
*/
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_NEW(type,env,size) \
|
||||
XMLRPC_MEMBLOCK_NEW(type,env,size)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_FREE(type,block) \
|
||||
XMLRPC_MEMBLOCK_FREE(type,block)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_INIT(type,env,block,size) \
|
||||
XMLRPC_MEMBLOCK_INIT(type,env,block,size)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_CLEAN(type,block) \
|
||||
XMLRPC_MEMBLOCK_CLEAN(type,block)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_SIZE(type,block) \
|
||||
XMLRPC_MEMBLOCK_SIZE(type,block)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_CONTENTS(type,block) \
|
||||
XMLRPC_MEMBLOCK_CONTENTS(type,block)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_RESIZE(type,env,block,size) \
|
||||
XMLRPC_MEMBLOCK_RESIZE(type,env,block,size)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_APPEND(type,env,block,data,size) \
|
||||
XMLRPC_MEMBLOCK_APPEND(type,env,block,data,size)
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** UTF-8 Encoding and Decoding
|
||||
**=======================================================================*/
|
||||
|
||||
void
|
||||
xmlrpc_validate_utf8(xmlrpc_env * const envP,
|
||||
const char * const utf8Data,
|
||||
size_t const utf8Len);
|
||||
|
||||
/* Decode a UTF-8 string. */
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_utf8_to_wcs(xmlrpc_env * const envP,
|
||||
const char * const utf8_data,
|
||||
size_t const utf8_len);
|
||||
|
||||
/* Encode a UTF-8 string. */
|
||||
|
||||
#if XMLRPC_HAVE_WCHAR
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_wcs_to_utf8(xmlrpc_env * const envP,
|
||||
const wchar_t * const wcsData,
|
||||
size_t const wcsLen);
|
||||
#endif
|
||||
|
||||
void
|
||||
xmlrpc_force_to_utf8(char * const buffer);
|
||||
|
||||
void
|
||||
xmlrpc_force_to_xml_chars(char * const buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,13 @@
|
||||
#ifndef XMLRPC_C_UTIL_INT_H_INCLUDED
|
||||
#define XMLRPC_C_UTIL_INT_H_INCLUDED
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
/* When we deallocate a pointer in a struct, we often replace it with
|
||||
** this and throw in a few assertions here and there. */
|
||||
#define XMLRPC_BAD_POINTER ((void*) 0xDEADBEEF)
|
||||
|
||||
#endif
|
@ -0,0 +1,97 @@
|
||||
/* Copyright and license information is at the end of the file */
|
||||
|
||||
#ifndef XMLRPC_XMLPARSER_H_INCLUDED
|
||||
#define XMLRPC_XMLPARSER_H_INCLUDED
|
||||
|
||||
/*=========================================================================
|
||||
** Abstract XML Parser Interface
|
||||
**=========================================================================
|
||||
** This file provides an abstract interface to the XML parser. For now,
|
||||
** this interface is implemented by expat, but feel free to change it
|
||||
** if necessary.
|
||||
*/
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xml_element
|
||||
**=========================================================================
|
||||
** This data structure represents an XML element. We provide no more API
|
||||
** than we'll need in xmlrpc_parse.c.
|
||||
**
|
||||
** The pointers returned by the various accessor methods belong to the
|
||||
** xml_element structure. Do not free them, and do not use them after
|
||||
** the xml_element has been destroyed.
|
||||
*/
|
||||
|
||||
/* You'll need to finish defining struct _xml_element elsewhere. */
|
||||
typedef struct _xml_element xml_element;
|
||||
|
||||
/* Destroy an xml_element. */
|
||||
void xml_element_free (xml_element * const elem);
|
||||
|
||||
/* Return a pointer to the element's name. Do not free this pointer!
|
||||
** This pointer should point to standard ASCII or UTF-8 data. */
|
||||
const char *
|
||||
xml_element_name(const xml_element * const elemP);
|
||||
|
||||
/* Return the xml_element's CDATA. Do not free this pointer!
|
||||
** This pointer should point to standard ASCII or UTF-8 data.
|
||||
** The implementation is allowed to concatenate all the CDATA in the
|
||||
** element regardless of child elements. Alternatively, if there are
|
||||
** any child elements, the implementation is allowed to dispose
|
||||
** of whitespace characters.
|
||||
** The value returned by xml_element_cdata should be '\0'-terminated
|
||||
** (although it may contain other '\0' characters internally).
|
||||
** xml_element_cdata_size should not include the final '\0'. */
|
||||
size_t xml_element_cdata_size (xml_element *elem);
|
||||
char *xml_element_cdata (xml_element *elem);
|
||||
|
||||
/* Return the xml_element's child elements. Do not free this pointer! */
|
||||
size_t
|
||||
xml_element_children_size(const xml_element * const elemP);
|
||||
|
||||
xml_element **
|
||||
xml_element_children(const xml_element * const elemP);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xml_parse
|
||||
**=========================================================================
|
||||
** Parse a chunk of XML data and return the top-level element. If this
|
||||
** routine fails, it will return NULL and set up the env appropriately.
|
||||
** You are responsible for calling xml_element_free on the returned pointer.
|
||||
*/
|
||||
|
||||
void
|
||||
xml_parse(xmlrpc_env * const envP,
|
||||
const char * const xmlData,
|
||||
size_t const xmlDataLen,
|
||||
xml_element ** const resultPP);
|
||||
|
||||
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE. */
|
||||
|
||||
#endif
|
234
ede-bug-tools/ede-bug-report/xmlrpc-c/src/double.c
Normal file
234
ede-bug-tools/ede-bug-report/xmlrpc-c/src/double.c
Normal file
@ -0,0 +1,234 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "xmlrpc-c/util.h"
|
||||
#include "xmlrpc-c/util_int.h"
|
||||
|
||||
#include "double.h"
|
||||
|
||||
typedef struct {
|
||||
char * bytes;
|
||||
char * next;
|
||||
char * end;
|
||||
} buffer;
|
||||
|
||||
|
||||
static void
|
||||
bufferInit(buffer * const bufferP) {
|
||||
|
||||
unsigned int const initialSize = 64;
|
||||
|
||||
bufferP->bytes = malloc(initialSize);
|
||||
|
||||
if (bufferP->bytes) {
|
||||
bufferP->next = bufferP->bytes;
|
||||
bufferP->end = bufferP->bytes + initialSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
bufferConcat(buffer * const bufferP,
|
||||
char const newChar) {
|
||||
|
||||
if (bufferP->bytes) {
|
||||
if (bufferP->next >= bufferP->end) {
|
||||
unsigned int const oldSize = bufferP->end - bufferP->bytes;
|
||||
unsigned int const newSize = oldSize + 64;
|
||||
bufferP->bytes = realloc(bufferP->bytes, newSize);
|
||||
bufferP->next = bufferP->bytes + oldSize;
|
||||
bufferP->end = bufferP->bytes + newSize;
|
||||
}
|
||||
|
||||
if (bufferP->bytes)
|
||||
*(bufferP->next++) = newChar;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static char
|
||||
digitChar(unsigned int const digitValue) {
|
||||
|
||||
assert(digitValue < 10);
|
||||
|
||||
return '0' + digitValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static unsigned int
|
||||
leadDigit(double const arg,
|
||||
double const precision) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Assuming 'arg' has one digit before the decimal point (which may be zero),
|
||||
return that digit.
|
||||
|
||||
We assume the precision of 'arg' is plus or minus 'precision', and bias our
|
||||
estimation of the first digit up. We do that bias in order to bias toward
|
||||
shorter decimal ciphers: It's cleaner to consider 2.9999999 to be 3 than to
|
||||
consider 3 to be 2.999999.
|
||||
-----------------------------------------------------------------------------*/
|
||||
return MIN(9, (unsigned int)(arg + precision));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
floatWhole(double const value,
|
||||
buffer * const formattedP,
|
||||
double * const formattedAmountP,
|
||||
double * const precisionP) {
|
||||
|
||||
if (value < 1.0) {
|
||||
/* No digits to add to the whole part */
|
||||
*formattedAmountP = 0;
|
||||
*precisionP = DBL_EPSILON;
|
||||
} else {
|
||||
double nonLeastAmount;
|
||||
double nonLeastPrecision;
|
||||
unsigned int leastValue;
|
||||
|
||||
/* Add all digits but the least significant to *formattedP */
|
||||
|
||||
floatWhole(value/10.0, formattedP, &nonLeastAmount,
|
||||
&nonLeastPrecision);
|
||||
|
||||
/* Add the least significant digit to *formattedP */
|
||||
|
||||
if (nonLeastPrecision > 0.1) {
|
||||
/* We're down in the noise now; no point in showing any more
|
||||
significant digits (and we couldn't if we wanted to, because
|
||||
nonLeastPrecision * 10 might be more than 10 less than
|
||||
'value').
|
||||
*/
|
||||
leastValue = 0;
|
||||
} else
|
||||
leastValue = leadDigit(value - nonLeastAmount * 10,
|
||||
nonLeastPrecision * 10);
|
||||
|
||||
bufferConcat(formattedP, digitChar(leastValue));
|
||||
|
||||
*formattedAmountP = nonLeastAmount * 10 + leastValue;
|
||||
*precisionP = nonLeastPrecision * 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
floatFractionPart(double const value,
|
||||
double const wholePrecision,
|
||||
buffer * const formattedP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Serialize the part that comes after the decimal point, assuming there
|
||||
is something (nonzero) before the decimal point that uses up all but
|
||||
'wholePrecision' of the available precision.
|
||||
-----------------------------------------------------------------------------*/
|
||||
double precision;
|
||||
double d;
|
||||
|
||||
assert(value < 1.0);
|
||||
|
||||
for (d = value, precision = wholePrecision;
|
||||
d > precision;
|
||||
precision *= 10) {
|
||||
|
||||
unsigned int digitValue;
|
||||
|
||||
d *= 10;
|
||||
digitValue = leadDigit(d, precision);
|
||||
|
||||
d -= digitValue;
|
||||
|
||||
assert(d < 1.0);
|
||||
|
||||
bufferConcat(formattedP, digitChar(digitValue));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
floatFraction(double const value,
|
||||
buffer * const formattedP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Serialize the part that comes after the decimal point, assuming there
|
||||
is nothing before the decimal point.
|
||||
-----------------------------------------------------------------------------*/
|
||||
double precision;
|
||||
double d;
|
||||
|
||||
assert(0.0 < value && value < 1.0);
|
||||
|
||||
/* Do the leading zeroes, which eat no precision */
|
||||
|
||||
for (d = value * 10; d < 1.0; d *= 10)
|
||||
bufferConcat(formattedP, '0');
|
||||
|
||||
/* Now the significant digits */
|
||||
|
||||
precision = DBL_EPSILON;
|
||||
|
||||
while (d > precision) {
|
||||
unsigned int const digitValue = leadDigit(d, precision);
|
||||
|
||||
bufferConcat(formattedP, digitChar(digitValue));
|
||||
|
||||
d -= digitValue;
|
||||
|
||||
assert(d < 1.0);
|
||||
|
||||
d *= 10;
|
||||
precision *= 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_formatFloat(xmlrpc_env * const envP,
|
||||
double const value,
|
||||
const char ** const formattedP) {
|
||||
|
||||
double absvalue;
|
||||
buffer formatted;
|
||||
|
||||
bufferInit(&formatted);
|
||||
|
||||
if (value < 0.0) {
|
||||
bufferConcat(&formatted, '-');
|
||||
absvalue = - value;
|
||||
} else
|
||||
absvalue = value;
|
||||
|
||||
if (absvalue >= 1.0) {
|
||||
double wholePart, fractionPart;
|
||||
double wholePrecision;
|
||||
|
||||
floatWhole(absvalue, &formatted, &wholePart, &wholePrecision);
|
||||
|
||||
fractionPart = absvalue - wholePart;
|
||||
|
||||
if (fractionPart > wholePrecision) {
|
||||
bufferConcat(&formatted, '.');
|
||||
|
||||
floatFractionPart(fractionPart, wholePrecision, &formatted);
|
||||
}
|
||||
} else {
|
||||
bufferConcat(&formatted, '0');
|
||||
|
||||
if (absvalue > 0.0) {
|
||||
bufferConcat(&formatted, '.');
|
||||
floatFraction(absvalue, &formatted);
|
||||
}
|
||||
}
|
||||
bufferConcat(&formatted, '\0');
|
||||
|
||||
if (formatted.bytes == NULL)
|
||||
xmlrpc_faultf(envP, "Couldn't allocate memory to format %g", value);
|
||||
else
|
||||
*formattedP = formatted.bytes;
|
||||
}
|
11
ede-bug-tools/ede-bug-report/xmlrpc-c/src/double.h
Normal file
11
ede-bug-tools/ede-bug-report/xmlrpc-c/src/double.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef DOUBLE_H_INCLUDED
|
||||
#define DOUBLE_H_INCLUDED
|
||||
|
||||
#include "xmlrpc-c/util.h"
|
||||
|
||||
void
|
||||
xmlrpc_formatFloat(xmlrpc_env * const envP,
|
||||
double const value,
|
||||
const char ** const formattedP);
|
||||
|
||||
#endif
|
757
ede-bug-tools/ede-bug-report/xmlrpc-c/src/parse_value.c
Normal file
757
ede-bug-tools/ede-bug-report/xmlrpc-c/src/parse_value.c
Normal file
@ -0,0 +1,757 @@
|
||||
#include "xmlrpc_config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "bool.h"
|
||||
|
||||
#include "xmlrpc-c/base.h"
|
||||
#include "xmlrpc-c/base_int.h"
|
||||
#include "xmlrpc-c/string_int.h"
|
||||
#include "xmlrpc-c/util.h"
|
||||
#include "xmlrpc-c/xmlparser.h"
|
||||
|
||||
#include "parse_value.h"
|
||||
|
||||
|
||||
|
||||
static void
|
||||
setParseFault(xmlrpc_env * const envP,
|
||||
const char * const format,
|
||||
...) {
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
xmlrpc_set_fault_formatted_v(envP, XMLRPC_PARSE_ERROR, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseArrayDataChild(xmlrpc_env * const envP,
|
||||
xml_element * const childP,
|
||||
unsigned int const maxRecursion,
|
||||
xmlrpc_value * const arrayP) {
|
||||
|
||||
const char * const elemName = xml_element_name(childP);
|
||||
|
||||
if (!xmlrpc_streq(elemName, "value"))
|
||||
setParseFault(envP, "<data> element has <%s> child. "
|
||||
"Only <value> makes sense.", elemName);
|
||||
else {
|
||||
xmlrpc_value * itemP;
|
||||
|
||||
xmlrpc_parseValue(envP, maxRecursion-1, childP, &itemP);
|
||||
|
||||
if (!envP->fault_occurred) {
|
||||
xmlrpc_array_append_item(envP, arrayP, itemP);
|
||||
|
||||
xmlrpc_DECREF(itemP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseArray(xmlrpc_env * const envP,
|
||||
unsigned int const maxRecursion,
|
||||
xml_element * const arrayElemP,
|
||||
xmlrpc_value ** const arrayPP) {
|
||||
|
||||
xmlrpc_value * arrayP;
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT(arrayElemP != NULL);
|
||||
|
||||
arrayP = xmlrpc_array_new(envP);
|
||||
if (!envP->fault_occurred) {
|
||||
unsigned int const childCount = xml_element_children_size(arrayElemP);
|
||||
|
||||
if (childCount != 1)
|
||||
setParseFault(envP,
|
||||
"<array> element has %u children. Only one <data> "
|
||||
"makes sense.", childCount);
|
||||
else {
|
||||
xml_element * const dataElemP =
|
||||
xml_element_children(arrayElemP)[0];
|
||||
const char * const elemName = xml_element_name(dataElemP);
|
||||
|
||||
if (!xmlrpc_streq(elemName, "data"))
|
||||
setParseFault(envP,
|
||||
"<array> element has <%s> child. Only <data> "
|
||||
"makes sense.", elemName);
|
||||
else {
|
||||
xml_element ** const values = xml_element_children(dataElemP);
|
||||
unsigned int const size = xml_element_children_size(dataElemP);
|
||||
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < size && !envP->fault_occurred; ++i)
|
||||
parseArrayDataChild(envP, values[i], maxRecursion, arrayP);
|
||||
}
|
||||
}
|
||||
if (envP->fault_occurred)
|
||||
xmlrpc_DECREF(arrayP);
|
||||
else
|
||||
*arrayPP = arrayP;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseName(xmlrpc_env * const envP,
|
||||
xml_element * const nameElemP,
|
||||
xmlrpc_value ** const valuePP) {
|
||||
|
||||
unsigned int const childCount = xml_element_children_size(nameElemP);
|
||||
|
||||
if (childCount > 0)
|
||||
setParseFault(envP, "<name> element has %u children. "
|
||||
"Should have none.", childCount);
|
||||
else {
|
||||
const char * const cdata = xml_element_cdata(nameElemP);
|
||||
size_t const cdataSize = xml_element_cdata_size(nameElemP);
|
||||
|
||||
*valuePP = xmlrpc_string_new_lp(envP, cdataSize, cdata);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
getNameChild(xmlrpc_env * const envP,
|
||||
xml_element * const parentP,
|
||||
xml_element * * const childPP) {
|
||||
|
||||
xml_element ** const children = xml_element_children(parentP);
|
||||
size_t const childCount = xml_element_children_size(parentP);
|
||||
|
||||
xml_element * childP;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0, childP = NULL; i < childCount && !childP; ++i) {
|
||||
if (xmlrpc_streq(xml_element_name(children[i]), "name"))
|
||||
childP = children[i];
|
||||
}
|
||||
if (!childP)
|
||||
xmlrpc_env_set_fault(envP, XMLRPC_PARSE_ERROR,
|
||||
"<member> has no <name> child");
|
||||
else
|
||||
*childPP = childP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
getValueChild(xmlrpc_env * const envP,
|
||||
xml_element * const parentP,
|
||||
xml_element * * const childPP) {
|
||||
|
||||
xml_element ** const children = xml_element_children(parentP);
|
||||
size_t const childCount = xml_element_children_size(parentP);
|
||||
|
||||
xml_element * childP;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0, childP = NULL; i < childCount && !childP; ++i) {
|
||||
if (xmlrpc_streq(xml_element_name(children[i]), "value"))
|
||||
childP = children[i];
|
||||
}
|
||||
if (!childP)
|
||||
xmlrpc_env_set_fault(envP, XMLRPC_PARSE_ERROR,
|
||||
"<member> has no <value> child");
|
||||
else
|
||||
*childPP = childP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseMember(xmlrpc_env * const envP,
|
||||
xml_element * const memberP,
|
||||
unsigned int const maxRecursion,
|
||||
xmlrpc_value ** const keyPP,
|
||||
xmlrpc_value ** const valuePP) {
|
||||
|
||||
unsigned int const childCount = xml_element_children_size(memberP);
|
||||
|
||||
if (childCount != 2)
|
||||
setParseFault(envP,
|
||||
"<member> element has %u children. Only one <name> and "
|
||||
"one <value> make sense.", childCount);
|
||||
else {
|
||||
xml_element * nameElemP;
|
||||
|
||||
getNameChild(envP, memberP, &nameElemP);
|
||||
|
||||
if (!envP->fault_occurred) {
|
||||
parseName(envP, nameElemP, keyPP);
|
||||
|
||||
if (!envP->fault_occurred) {
|
||||
xml_element * valueElemP;
|
||||
|
||||
getValueChild(envP, memberP, &valueElemP);
|
||||
|
||||
if (!envP->fault_occurred)
|
||||
xmlrpc_parseValue(envP, maxRecursion-1, valueElemP,
|
||||
valuePP);
|
||||
|
||||
if (envP->fault_occurred)
|
||||
xmlrpc_DECREF(*keyPP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseStruct(xmlrpc_env * const envP,
|
||||
unsigned int const maxRecursion,
|
||||
xml_element * const elemP,
|
||||
xmlrpc_value ** const structPP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Parse the <struct> element 'elemP'.
|
||||
-----------------------------------------------------------------------------*/
|
||||
xmlrpc_value * structP;
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT(elemP != NULL);
|
||||
|
||||
structP = xmlrpc_struct_new(envP);
|
||||
if (!envP->fault_occurred) {
|
||||
/* Iterate over our children, extracting key/value pairs. */
|
||||
|
||||
xml_element ** const members = xml_element_children(elemP);
|
||||
unsigned int const size = xml_element_children_size(elemP);
|
||||
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < size && !envP->fault_occurred; ++i) {
|
||||
const char * const elemName = xml_element_name(members[i]);
|
||||
|
||||
if (!xmlrpc_streq(elemName, "member"))
|
||||
setParseFault(envP, "<%s> element found where only <member> "
|
||||
"makes sense", elemName);
|
||||
else {
|
||||
xmlrpc_value * keyP;
|
||||
xmlrpc_value * valueP;
|
||||
|
||||
parseMember(envP, members[i], maxRecursion, &keyP, &valueP);
|
||||
|
||||
if (!envP->fault_occurred) {
|
||||
xmlrpc_struct_set_value_v(envP, structP, keyP, valueP);
|
||||
|
||||
xmlrpc_DECREF(keyP);
|
||||
xmlrpc_DECREF(valueP);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (envP->fault_occurred)
|
||||
xmlrpc_DECREF(structP);
|
||||
else
|
||||
*structPP = structP;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseInt(xmlrpc_env * const envP,
|
||||
const char * const str,
|
||||
xmlrpc_value ** const valuePP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Parse the content of a <int> XML-RPC XML element, e.g. "34".
|
||||
|
||||
'str' is that content.
|
||||
-----------------------------------------------------------------------------*/
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT_PTR_OK(str);
|
||||
|
||||
if (str[0] == '\0')
|
||||
setParseFault(envP, "<int> XML element content is empty");
|
||||
else if (isspace(str[0]))
|
||||
setParseFault(envP, "<int> content '%s' starts with white space",
|
||||
str);
|
||||
else {
|
||||
long i;
|
||||
char * tail;
|
||||
|
||||
errno = 0;
|
||||
i = strtol(str, &tail, 10);
|
||||
|
||||
/* Look for ERANGE. */
|
||||
if (errno == ERANGE)
|
||||
setParseFault(envP, "<int> XML element value '%s' represents a "
|
||||
"number beyond the range that "
|
||||
"XML-RPC allows (%d - %d)", str,
|
||||
XMLRPC_INT32_MIN, XMLRPC_INT32_MAX);
|
||||
else if (errno != 0)
|
||||
setParseFault(envP, "unexpected error parsing <int> XML element "
|
||||
"value '%s'. strtol() failed with errno %d (%s)",
|
||||
str, errno, strerror(errno));
|
||||
else {
|
||||
/* Look for out-of-range errors which didn't produce ERANGE. */
|
||||
if (i < XMLRPC_INT32_MIN)
|
||||
setParseFault(envP,
|
||||
"<int> value %d is below the range allowed "
|
||||
"by XML-RPC (minimum is %d)",
|
||||
i, XMLRPC_INT32_MIN);
|
||||
else if (i > XMLRPC_INT32_MAX)
|
||||
setParseFault(envP,
|
||||
"<int> value %d is above the range allowed "
|
||||
"by XML-RPC (maximum is %d)",
|
||||
i, XMLRPC_INT32_MAX);
|
||||
else {
|
||||
if (tail[0] != '\0')
|
||||
setParseFault(envP,
|
||||
"<int> value '%s' contains non-numerical "
|
||||
"junk: '%s'", str, tail);
|
||||
else
|
||||
*valuePP = xmlrpc_int_new(envP, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseBoolean(xmlrpc_env * const envP,
|
||||
const char * const str,
|
||||
xmlrpc_value ** const valuePP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Parse the content of a <boolean> XML-RPC XML element, e.g. "1".
|
||||
|
||||
'str' is that content.
|
||||
-----------------------------------------------------------------------------*/
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT_PTR_OK(str);
|
||||
|
||||
if (xmlrpc_streq(str, "0") || xmlrpc_streq(str, "1"))
|
||||
*valuePP = xmlrpc_bool_new(envP, xmlrpc_streq(str, "1") ? 1 : 0);
|
||||
else
|
||||
setParseFault(envP, "<boolean> XML element content must be either "
|
||||
"'0' or '1' according to XML-RPC. This one has '%s'",
|
||||
str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
scanAndValidateDoubleString(xmlrpc_env * const envP,
|
||||
const char * const string,
|
||||
const char ** const mantissaP,
|
||||
const char ** const mantissaEndP,
|
||||
const char ** const fractionP,
|
||||
const char ** const fractionEndP) {
|
||||
|
||||
const char * mantissa;
|
||||
const char * dp;
|
||||
const char * p;
|
||||
|
||||
if (string[0] == '-' || string[0] == '+')
|
||||
mantissa = &string[1];
|
||||
else
|
||||
mantissa = &string[0];
|
||||
|
||||
for (p = mantissa, dp = NULL; *p; ++p) {
|
||||
char const c = *p;
|
||||
if (c == '.') {
|
||||
if (dp) {
|
||||
setParseFault(envP, "Two decimal points");
|
||||
return;
|
||||
} else
|
||||
dp = p;
|
||||
} else if (c < '0' || c > '9') {
|
||||
setParseFault(envP, "Garbage (not sign, digit, or period) "
|
||||
"starting at '%s'", p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
*mantissaP = mantissa;
|
||||
if (dp) {
|
||||
*mantissaEndP = dp;
|
||||
*fractionP = dp+1;
|
||||
*fractionEndP = p;
|
||||
} else {
|
||||
*mantissaEndP = p;
|
||||
*fractionP = p;
|
||||
*fractionEndP = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool
|
||||
isInfinite(double const value) {
|
||||
|
||||
return value > DBL_MAX;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseDoubleString(xmlrpc_env * const envP,
|
||||
const char * const string,
|
||||
double * const valueP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Turn e.g. "4.3" into 4.3 .
|
||||
-----------------------------------------------------------------------------*/
|
||||
/* strtod() is no good for this because it is designed for human
|
||||
interfaces; it parses according to locale. As a practical
|
||||
matter that sometimes means that it does not recognize "." as a
|
||||
decimal point. In XML-RPC, "." is a decimal point.
|
||||
|
||||
Design note: in my experiments, using strtod() was 10 times
|
||||
slower than using this function.
|
||||
*/
|
||||
const char * mantissa;
|
||||
const char * mantissaEnd;
|
||||
const char * fraction;
|
||||
const char * fractionEnd;
|
||||
|
||||
scanAndValidateDoubleString(envP, string, &mantissa, &mantissaEnd,
|
||||
&fraction, &fractionEnd);
|
||||
|
||||
if (!envP->fault_occurred) {
|
||||
double accum;
|
||||
|
||||
accum = 0.0;
|
||||
|
||||
if (mantissa == mantissaEnd && fraction == fractionEnd) {
|
||||
setParseFault(envP, "No digits");
|
||||
return;
|
||||
}
|
||||
{
|
||||
/* Add in the whole part */
|
||||
const char * p;
|
||||
|
||||
for (p = mantissa; p < mantissaEnd; ++p) {
|
||||
accum *= 10;
|
||||
accum += (*p - '0');
|
||||
}
|
||||
}
|
||||
{
|
||||
/* Add in the fractional part */
|
||||
double significance;
|
||||
const char * p;
|
||||
for (significance = 0.1, p = fraction;
|
||||
p < fractionEnd;
|
||||
++p, significance *= 0.1) {
|
||||
|
||||
accum += (*p - '0') * significance;
|
||||
}
|
||||
}
|
||||
if (isInfinite(accum))
|
||||
setParseFault(envP, "Value exceeds the size allowed by XML-RPC");
|
||||
else
|
||||
*valueP = string[0] == '-' ? (- accum) : accum;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseDoubleStringStrtod(const char * const str,
|
||||
bool * const failedP,
|
||||
double * const valueP) {
|
||||
|
||||
if (strlen(str) == 0) {
|
||||
/* strtod() happily interprets empty string as 0.0. We don't think
|
||||
the user will appreciate that XML-RPC extension.
|
||||
*/
|
||||
*failedP = true;
|
||||
} else {
|
||||
char * tail;
|
||||
|
||||
errno = 0;
|
||||
|
||||
*valueP = strtod(str, &tail);
|
||||
|
||||
if (errno != 0)
|
||||
*failedP = true;
|
||||
else {
|
||||
if (tail[0] != '\0')
|
||||
*failedP = true;
|
||||
else
|
||||
*failedP = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseDouble(xmlrpc_env * const envP,
|
||||
const char * const str,
|
||||
xmlrpc_value ** const valuePP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Parse the content of a <double> XML-RPC XML element, e.g. "34.5".
|
||||
|
||||
'str' is that content.
|
||||
-----------------------------------------------------------------------------*/
|
||||
xmlrpc_env parseEnv;
|
||||
double valueDouble;
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT_PTR_OK(str);
|
||||
|
||||
xmlrpc_env_init(&parseEnv);
|
||||
|
||||
parseDoubleString(&parseEnv, str, &valueDouble);
|
||||
|
||||
if (parseEnv.fault_occurred) {
|
||||
/* As an alternative, try a strtod() parsing. strtod()
|
||||
accepts other forms, e.g. "3.4E6"; "3,4"; " 3.4". These
|
||||
are not permitted by XML-RPC, but an almost-XML-RPC partner
|
||||
might use one. In fact, for many years, Xmlrpc-c generated
|
||||
such alternatives (by mistake).
|
||||
*/
|
||||
bool failed;
|
||||
parseDoubleStringStrtod(str, &failed, &valueDouble);
|
||||
if (failed)
|
||||
setParseFault(envP, "<double> element value '%s' is not a valid "
|
||||
"floating point number. %s",
|
||||
str, parseEnv.fault_string);
|
||||
}
|
||||
|
||||
if (!envP->fault_occurred)
|
||||
*valuePP = xmlrpc_double_new(envP, valueDouble);
|
||||
|
||||
xmlrpc_env_clean(&parseEnv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseBase64(xmlrpc_env * const envP,
|
||||
const char * const str,
|
||||
size_t const strLength,
|
||||
xmlrpc_value ** const valuePP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Parse the content of a <base64> XML-RPC XML element, e.g. "FD32YY".
|
||||
|
||||
'str' is that content.
|
||||
-----------------------------------------------------------------------------*/
|
||||
xmlrpc_mem_block * decoded;
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT_PTR_OK(str);
|
||||
|
||||
decoded = xmlrpc_base64_decode(envP, str, strLength);
|
||||
if (!envP->fault_occurred) {
|
||||
unsigned char * const bytes =
|
||||
XMLRPC_MEMBLOCK_CONTENTS(unsigned char, decoded);
|
||||
size_t const byteCount =
|
||||
XMLRPC_MEMBLOCK_SIZE(unsigned char, decoded);
|
||||
|
||||
*valuePP = xmlrpc_base64_new(envP, byteCount, bytes);
|
||||
|
||||
XMLRPC_MEMBLOCK_FREE(unsigned char, decoded);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseI8(xmlrpc_env * const envP,
|
||||
const char * const str,
|
||||
xmlrpc_value ** const valuePP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Parse the content of a <i8> XML-RPC XML element, e.g. "34".
|
||||
|
||||
'str' is that content.
|
||||
-----------------------------------------------------------------------------*/
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT_PTR_OK(str);
|
||||
|
||||
if (str[0] == '\0')
|
||||
setParseFault(envP, "<i8> XML element content is empty");
|
||||
else if (isspace(str[0]))
|
||||
setParseFault(envP,
|
||||
"<i8> content '%s' starts with white space", str);
|
||||
else {
|
||||
xmlrpc_int64 i;
|
||||
char * tail;
|
||||
|
||||
errno = 0;
|
||||
i = strtoll(str, &tail, 10);
|
||||
|
||||
if (errno == ERANGE)
|
||||
setParseFault(envP, "<i8> XML element value '%s' represents a "
|
||||
"number beyond the range that "
|
||||
"XML-RPC allows (%d - %d)", str,
|
||||
XMLRPC_INT64_MIN, XMLRPC_INT64_MAX);
|
||||
else if (errno != 0)
|
||||
setParseFault(envP, "unexpected error parsing <i8> XML element "
|
||||
"value '%s'. strtoll() failed with errno %d (%s)",
|
||||
str, errno, strerror(errno));
|
||||
else {
|
||||
/* Look for out-of-range errors which didn't produce ERANGE. */
|
||||
if (i < XMLRPC_INT64_MIN)
|
||||
setParseFault(envP, "<i8> value %d is below the range allowed "
|
||||
"by XML-RPC (minimum is %d)",
|
||||
i, XMLRPC_INT64_MIN);
|
||||
else if (i > XMLRPC_INT64_MAX)
|
||||
setParseFault(envP, "<i8> value %d is above the range allowed "
|
||||
"by XML-RPC (maximum is %d)",
|
||||
i, XMLRPC_INT64_MAX);
|
||||
else {
|
||||
if (tail[0] != '\0')
|
||||
setParseFault(envP,
|
||||
"<i8> value '%s' contains non-numerical "
|
||||
"junk: '%s'", str, tail);
|
||||
else
|
||||
*valuePP = xmlrpc_i8_new(envP, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseSimpleValueCdata(xmlrpc_env * const envP,
|
||||
const char * const elementName,
|
||||
const char * const cdata,
|
||||
size_t const cdataLength,
|
||||
xmlrpc_value ** const valuePP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Parse an XML element is supposedly a data type element such as
|
||||
<string>. Its name is 'elementName', and it has no children, but
|
||||
contains cdata 'cdata', which is 'dataLength' characters long.
|
||||
-----------------------------------------------------------------------------*/
|
||||
/* We need to straighten out the whole character set / encoding thing
|
||||
some day. What is 'cdata', and what should it be? Does it have
|
||||
embedded NUL? Some of the code here assumes it doesn't. Is it
|
||||
text?
|
||||
|
||||
The <string> parser assumes it's UTF 8 with embedded NULs.
|
||||
But the <int> parser will get terribly confused if there are any
|
||||
UTF-8 multibyte sequences or NUL characters. So will most of the
|
||||
others.
|
||||
|
||||
The "ex:XXX" element names are what the Apache XML-RPC facility
|
||||
uses: http://ws.apache.org/xmlrpc/types.html. (Technically, it
|
||||
isn't "ex" but an arbitrary prefix that identifies a namespace
|
||||
declared earlier in the XML document -- this is an XML thing.
|
||||
But we aren't nearly sophisticated enough to use real XML
|
||||
namespaces, so we exploit the fact that XML-RPC actually uses
|
||||
"ex").
|
||||
|
||||
"i1" and "i2" are just from my imagination.
|
||||
*/
|
||||
|
||||
if (xmlrpc_streq(elementName, "int") ||
|
||||
xmlrpc_streq(elementName, "i4") ||
|
||||
xmlrpc_streq(elementName, "i1") ||
|
||||
xmlrpc_streq(elementName, "i2") ||
|
||||
xmlrpc_streq(elementName, "ex:i1") ||
|
||||
xmlrpc_streq(elementName, "ex:i2"))
|
||||
parseInt(envP, cdata, valuePP);
|
||||
else if (xmlrpc_streq(elementName, "boolean"))
|
||||
parseBoolean(envP, cdata, valuePP);
|
||||
else if (xmlrpc_streq(elementName, "double"))
|
||||
parseDouble(envP, cdata, valuePP);
|
||||
else if (xmlrpc_streq(elementName, "dateTime.iso8601"))
|
||||
*valuePP = xmlrpc_datetime_new_str(envP, cdata);
|
||||
else if (xmlrpc_streq(elementName, "string"))
|
||||
*valuePP = xmlrpc_string_new_lp(envP, cdataLength, cdata);
|
||||
else if (xmlrpc_streq(elementName, "base64"))
|
||||
parseBase64(envP, cdata, cdataLength, valuePP);
|
||||
else if (xmlrpc_streq(elementName, "nil") ||
|
||||
xmlrpc_streq(elementName, "ex:nil"))
|
||||
*valuePP = xmlrpc_nil_new(envP);
|
||||
else if (xmlrpc_streq(elementName, "i8") ||
|
||||
xmlrpc_streq(elementName, "ex:i8"))
|
||||
parseI8(envP, cdata, valuePP);
|
||||
else
|
||||
setParseFault(envP, "Unknown value type -- XML element is named "
|
||||
"<%s>", elementName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
parseSimpleValue(xmlrpc_env * const envP,
|
||||
xml_element * const elemP,
|
||||
xmlrpc_value ** const valuePP) {
|
||||
|
||||
unsigned int const childCount = xml_element_children_size(elemP);
|
||||
|
||||
if (childCount > 0)
|
||||
setParseFault(envP, "The child of a <value> element "
|
||||
"is neither <array> nor <struct>, "
|
||||
"but has %u child elements of its own.",
|
||||
childCount);
|
||||
else {
|
||||
const char * const elemName = xml_element_name(elemP);
|
||||
const char * const cdata = xml_element_cdata(elemP);
|
||||
size_t const cdataSize = xml_element_cdata_size(elemP);
|
||||
|
||||
parseSimpleValueCdata(envP, elemName, cdata, cdataSize, valuePP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_parseValue(xmlrpc_env * const envP,
|
||||
unsigned int const maxRecursion,
|
||||
xml_element * const elemP,
|
||||
xmlrpc_value ** const valuePP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Compute the xmlrpc_value represented by the XML <value> element 'elem'.
|
||||
Return that xmlrpc_value.
|
||||
|
||||
We call convert_array() and convert_struct(), which may ultimately
|
||||
call us recursively. Don't recurse any more than 'maxRecursion'
|
||||
times.
|
||||
-----------------------------------------------------------------------------*/
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT(elemP != NULL);
|
||||
|
||||
/* Assume we'll need to recurse, make sure we're allowed */
|
||||
if (maxRecursion < 1)
|
||||
xmlrpc_env_set_fault(envP, XMLRPC_PARSE_ERROR,
|
||||
"Nested data structure too deep.");
|
||||
else {
|
||||
if (!xmlrpc_streq(xml_element_name(elemP), "value"))
|
||||
setParseFault(envP,
|
||||
"<%s> element where <value> expected",
|
||||
xml_element_name(elemP));
|
||||
else {
|
||||
unsigned int const childCount = xml_element_children_size(elemP);
|
||||
|
||||
if (childCount == 0) {
|
||||
/* We have no type element, so treat the value as a string. */
|
||||
char * const cdata = xml_element_cdata(elemP);
|
||||
size_t const cdata_size = xml_element_cdata_size(elemP);
|
||||
*valuePP = xmlrpc_string_new_lp(envP, cdata_size, cdata);
|
||||
} else if (childCount > 1)
|
||||
setParseFault(envP, "<value> has %u child elements. "
|
||||
"Only zero or one make sense.", childCount);
|
||||
else {
|
||||
/* We should have a type tag inside our value tag. */
|
||||
xml_element * const childP = xml_element_children(elemP)[0];
|
||||
const char * const childName = xml_element_name(childP);
|
||||
|
||||
if (xmlrpc_streq(childName, "struct"))
|
||||
parseStruct(envP, maxRecursion, childP, valuePP);
|
||||
else if (xmlrpc_streq(childName, "array"))
|
||||
parseArray(envP, maxRecursion, childP, valuePP);
|
||||
else
|
||||
parseSimpleValue(envP, childP, valuePP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
ede-bug-tools/ede-bug-report/xmlrpc-c/src/parse_value.h
Normal file
13
ede-bug-tools/ede-bug-report/xmlrpc-c/src/parse_value.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef PARSE_VALUE_H_INCLUDED
|
||||
#define PARSE_VALUE_H_INCLUDED
|
||||
|
||||
#include "xmlrpc-c/base.h"
|
||||
#include "xmlrpc-c/xmlparser.h"
|
||||
|
||||
void
|
||||
xmlrpc_parseValue(xmlrpc_env * const envP,
|
||||
unsigned int const maxRecursion,
|
||||
xml_element * const elemP,
|
||||
xmlrpc_value ** const valuePP);
|
||||
|
||||
#endif
|
31
ede-bug-tools/ede-bug-report/xmlrpc-c/src/resource.c
Normal file
31
ede-bug-tools/ede-bug-report/xmlrpc-c/src/resource.c
Normal file
@ -0,0 +1,31 @@
|
||||
#include "xmlrpc_config.h"
|
||||
|
||||
#include "xmlrpc-c/base.h"
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** Resource Limits
|
||||
**=========================================================================
|
||||
*/
|
||||
|
||||
static size_t limits[XMLRPC_LAST_LIMIT_ID + 1] = {
|
||||
XMLRPC_NESTING_LIMIT_DEFAULT,
|
||||
XMLRPC_XML_SIZE_LIMIT_DEFAULT
|
||||
};
|
||||
|
||||
void
|
||||
xmlrpc_limit_set (int const limit_id,
|
||||
size_t const value) {
|
||||
|
||||
XMLRPC_ASSERT(0 <= limit_id && limit_id <= XMLRPC_LAST_LIMIT_ID);
|
||||
limits[limit_id] = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t
|
||||
xmlrpc_limit_get(int const limit_id) {
|
||||
|
||||
XMLRPC_ASSERT(0 <= limit_id && limit_id <= XMLRPC_LAST_LIMIT_ID);
|
||||
return limits[limit_id];
|
||||
}
|
62
ede-bug-tools/ede-bug-report/xmlrpc-c/src/trace.c
Normal file
62
ede-bug-tools/ede-bug-report/xmlrpc-c/src/trace.c
Normal file
@ -0,0 +1,62 @@
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "xmlrpc-c/base_int.h"
|
||||
#include "xmlrpc-c/string_int.h"
|
||||
|
||||
|
||||
static size_t
|
||||
nextLineSize(const char * const string,
|
||||
size_t const startPos,
|
||||
size_t const stringSize) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Return the length of the line that starts at offset 'startPos' in the
|
||||
string 'string', which is 'stringSize' characters long.
|
||||
|
||||
'string' in not NUL-terminated.
|
||||
|
||||
A line begins at beginning of string or after a newline character and
|
||||
runs through the next newline character or end of string. The line
|
||||
includes the newline character at the end, if any.
|
||||
-----------------------------------------------------------------------------*/
|
||||
size_t i;
|
||||
|
||||
for (i = startPos; i < stringSize && string[i] != '\n'; ++i);
|
||||
|
||||
if (i < stringSize)
|
||||
++i; /* Include the newline */
|
||||
|
||||
return i - startPos;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_traceXml(const char * const label,
|
||||
const char * const xml,
|
||||
unsigned int const xmlLength) {
|
||||
|
||||
if (getenv("XMLRPC_TRACE_XML")) {
|
||||
size_t cursor; /* Index into xml[] */
|
||||
|
||||
fprintf(stderr, "%s:\n\n", label);
|
||||
|
||||
for (cursor = 0; cursor < xmlLength; ) {
|
||||
/* Print one line of XML */
|
||||
|
||||
size_t const lineSize = nextLineSize(xml, cursor, xmlLength);
|
||||
const char * const xmlPrintableLine =
|
||||
xmlrpc_makePrintable_lp(&xml[cursor], lineSize);
|
||||
|
||||
fprintf(stderr, "%s\n", xmlPrintableLine);
|
||||
|
||||
cursor += lineSize;
|
||||
|
||||
xmlrpc_strfree(xmlPrintableLine);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
|
7
ede-bug-tools/ede-bug-report/xmlrpc-c/src/version.c
Normal file
7
ede-bug-tools/ede-bug-report/xmlrpc-c/src/version.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include "version.h"
|
||||
|
||||
#include "xmlrpc-c/base.h"
|
||||
|
||||
unsigned int const xmlrpc_version_major = XMLRPC_VERSION_MAJOR;
|
||||
unsigned int const xmlrpc_version_minor = XMLRPC_VERSION_MINOR;
|
||||
unsigned int const xmlrpc_version_point = XMLRPC_VERSION_POINT;
|
227
ede-bug-tools/ede-bug-report/xmlrpc-c/src/xmlrpc_array.c
Normal file
227
ede-bug-tools/ede-bug-report/xmlrpc-c/src/xmlrpc_array.c
Normal file
@ -0,0 +1,227 @@
|
||||
/* Copyright information is at the end of the file */
|
||||
|
||||
/*=========================================================================
|
||||
** XML-RPC Array Functions
|
||||
**=========================================================================
|
||||
*/
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "xmlrpc-c/util.h"
|
||||
#include "xmlrpc-c/base.h"
|
||||
#include "xmlrpc-c/base_int.h"
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_abort_if_array_bad(xmlrpc_value * const arrayP) {
|
||||
|
||||
if (arrayP == NULL)
|
||||
abort();
|
||||
else if (arrayP->_type != XMLRPC_TYPE_ARRAY)
|
||||
abort();
|
||||
else {
|
||||
unsigned int const arraySize =
|
||||
XMLRPC_MEMBLOCK_SIZE(xmlrpc_value*, &arrayP->_block);
|
||||
xmlrpc_value ** const contents =
|
||||
XMLRPC_MEMBLOCK_CONTENTS(xmlrpc_value*, &arrayP->_block);
|
||||
|
||||
if (contents == NULL)
|
||||
abort();
|
||||
else {
|
||||
unsigned int index;
|
||||
|
||||
for (index = 0; index < arraySize; ++index) {
|
||||
xmlrpc_value * const itemP = contents[index];
|
||||
if (itemP == NULL)
|
||||
abort();
|
||||
else if (itemP->_refcount < 1)
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_destroyArrayContents(xmlrpc_value * const arrayP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Dispose of the contents of an array (but not the array value itself).
|
||||
The value is not valid after this.
|
||||
-----------------------------------------------------------------------------*/
|
||||
unsigned int const arraySize =
|
||||
XMLRPC_MEMBLOCK_SIZE(xmlrpc_value*, &arrayP->_block);
|
||||
xmlrpc_value ** const contents =
|
||||
XMLRPC_MEMBLOCK_CONTENTS(xmlrpc_value*, &arrayP->_block);
|
||||
|
||||
unsigned int index;
|
||||
|
||||
XMLRPC_ASSERT_ARRAY_OK(arrayP);
|
||||
|
||||
/* Release our reference to each item in the array */
|
||||
for (index = 0; index < arraySize; ++index) {
|
||||
xmlrpc_value * const itemP = contents[index];
|
||||
xmlrpc_DECREF(itemP);
|
||||
}
|
||||
XMLRPC_MEMBLOCK_CLEAN(xmlrpc_value *, &arrayP->_block);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
xmlrpc_array_size(xmlrpc_env * const env,
|
||||
const xmlrpc_value * const array) {
|
||||
|
||||
int retval;
|
||||
|
||||
/* Suppress a compiler warning about uninitialized variables. */
|
||||
retval = 0;
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(env);
|
||||
XMLRPC_ASSERT_VALUE_OK(array);
|
||||
XMLRPC_TYPE_CHECK(env, array, XMLRPC_TYPE_ARRAY);
|
||||
|
||||
retval = XMLRPC_TYPED_MEM_BLOCK_SIZE(xmlrpc_value*, &array->_block);
|
||||
|
||||
cleanup:
|
||||
if (env->fault_occurred)
|
||||
return -1;
|
||||
else
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_array_append_item(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const arrayP,
|
||||
xmlrpc_value * const valueP) {
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT_VALUE_OK(arrayP);
|
||||
|
||||
if (xmlrpc_value_type(arrayP) != XMLRPC_TYPE_ARRAY)
|
||||
xmlrpc_env_set_fault_formatted(
|
||||
envP, XMLRPC_TYPE_ERROR, "Value is not an array");
|
||||
else {
|
||||
size_t const size =
|
||||
XMLRPC_MEMBLOCK_SIZE(xmlrpc_value *, &arrayP->_block);
|
||||
|
||||
XMLRPC_MEMBLOCK_RESIZE(xmlrpc_value *, envP, &arrayP->_block, size+1);
|
||||
|
||||
if (!envP->fault_occurred) {
|
||||
xmlrpc_value ** const contents =
|
||||
XMLRPC_MEMBLOCK_CONTENTS(xmlrpc_value*, &arrayP->_block);
|
||||
xmlrpc_INCREF(valueP);
|
||||
contents[size] = valueP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_array_read_item(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const arrayP,
|
||||
unsigned int const index,
|
||||
xmlrpc_value ** const valuePP) {
|
||||
|
||||
XMLRPC_ASSERT_ENV_OK(envP);
|
||||
XMLRPC_ASSERT_VALUE_OK(arrayP);
|
||||
XMLRPC_ASSERT_PTR_OK(valuePP);
|
||||
|
||||
if (arrayP->_type != XMLRPC_TYPE_ARRAY)
|
||||
xmlrpc_env_set_fault_formatted(
|
||||
envP, XMLRPC_TYPE_ERROR, "Attempt to read array item from "
|
||||
"a value that is not an array");
|
||||
else {
|
||||
xmlrpc_value ** const contents =
|
||||
XMLRPC_MEMBLOCK_CONTENTS(xmlrpc_value *, &arrayP->_block);
|
||||
size_t const size =
|
||||
XMLRPC_MEMBLOCK_SIZE(xmlrpc_value *, &arrayP->_block);
|
||||
|
||||
if (index >= size)
|
||||
xmlrpc_env_set_fault_formatted(
|
||||
envP, XMLRPC_INDEX_ERROR, "Array index %u is beyond end "
|
||||
"of %u-item array", index, (unsigned int)size);
|
||||
else {
|
||||
*valuePP = contents[index];
|
||||
xmlrpc_INCREF(*valuePP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_array_get_item(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const arrayP,
|
||||
int const index) {
|
||||
|
||||
xmlrpc_value * valueP;
|
||||
|
||||
if (index < 0)
|
||||
xmlrpc_env_set_fault_formatted(
|
||||
envP, XMLRPC_INDEX_ERROR, "Index %d is negative.", index);
|
||||
else {
|
||||
xmlrpc_array_read_item(envP, arrayP, index, &valueP);
|
||||
|
||||
if (!envP->fault_occurred)
|
||||
xmlrpc_DECREF(valueP);
|
||||
}
|
||||
if (envP->fault_occurred)
|
||||
valueP = NULL;
|
||||
|
||||
return valueP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_array_new(xmlrpc_env * const envP) {
|
||||
/*----------------------------------------------------------------------------
|
||||
Create an empty array xmlrpc_value.
|
||||
-----------------------------------------------------------------------------*/
|
||||
xmlrpc_value * arrayP;
|
||||
|
||||
xmlrpc_createXmlrpcValue(envP, &arrayP);
|
||||
if (!envP->fault_occurred) {
|
||||
arrayP->_type = XMLRPC_TYPE_ARRAY;
|
||||
XMLRPC_MEMBLOCK_INIT(xmlrpc_value*, envP, &arrayP->_block, 0);
|
||||
if (envP->fault_occurred)
|
||||
free(arrayP);
|
||||
}
|
||||
return arrayP;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
** Copyright (C) 2001 by Eric Kidd. All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
** SUCH DAMAGE. */
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user