-- remove BongoArray and replace it with GArray
-- StrictCompile antispam and fix all the accompanying warnings
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <bongothreadpool.h>
|
||||
#include <connio.h>
|
||||
#include <bongomanagee.h>
|
||||
#include <glib.h>
|
||||
|
||||
/* FIXME: need to tweak these */
|
||||
#define BONGO_QUEUE_AGENT_DEFAULT_STACK_SIZE (80 * 1024)
|
||||
@@ -183,7 +184,7 @@ void BongoAgentShutdownFunc (BongoJsonRpcServer *server,
|
||||
BongoJsonRpc *rpc,
|
||||
int requestId,
|
||||
const char *method,
|
||||
BongoArray *args,
|
||||
GArray *args,
|
||||
void *userData);
|
||||
|
||||
#ifndef _NO_BONGO_GLOBALS
|
||||
|
||||
+6
-5
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <xpl.h>
|
||||
#include <bongojson.h>
|
||||
#include <glib.h>
|
||||
|
||||
XPL_BEGIN_C_LINKAGE
|
||||
|
||||
@@ -230,7 +231,7 @@ BongoHashtable *BongoCalObjectGetTimezones(BongoCalObject *cal);
|
||||
void BongoCalObjectResolveSystemTimezones(BongoCalObject *cal);
|
||||
void BongoCalObjectStripSystemTimezones(BongoCalObject *cal);
|
||||
|
||||
BongoArray *BongoCalObjectGetInstances(BongoCalObject *cal);
|
||||
GArray *BongoCalObjectGetInstances(BongoCalObject *cal);
|
||||
|
||||
BOOL BongoCalObjectIsSingle(BongoCalObject *cal);
|
||||
BongoCalInstance *BongoCalObjectGetSingleInstance(BongoCalObject *cal);
|
||||
@@ -246,7 +247,7 @@ BOOL BongoCalObjectCollect(BongoCalObject *cal,
|
||||
BongoCalTime end,
|
||||
BongoCalTimezone *tz,
|
||||
BOOL generate,
|
||||
BongoArray *instances);
|
||||
GArray *instances);
|
||||
|
||||
/* Return the primary occurrence of a cal object */
|
||||
BongoCalOccurrence BongoCalObjectPrimaryOccurrence(BongoCalObject *cal,
|
||||
@@ -335,8 +336,8 @@ BOOL BongoCalInstanceCrosses(BongoCalInstance *instance,
|
||||
BongoCalTime end);
|
||||
|
||||
BongoJsonObject *BongoCalOccurrenceToJson(BongoCalOccurrence occ, BongoCalTimezone *tz);
|
||||
BongoArray *BongoCalOccurrencesToJson(BongoArray *occs, BongoCalTimezone *tz);
|
||||
void BongoCalOccurrencesSort(BongoArray *occs);
|
||||
GArray *BongoCalOccurrencesToJson(GArray *occs, BongoCalTimezone *tz);
|
||||
void BongoCalOccurrencesSort(GArray *occs);
|
||||
|
||||
/*** BongoCalTimezone ***/
|
||||
|
||||
@@ -419,7 +420,7 @@ BongoCalType BongoCalTypeFromJson(BongoJsonObject *object);
|
||||
|
||||
/* Split a json calendar object into a json array of calendar objects
|
||||
* with one uid per object. Destroys the original object */
|
||||
BongoArray *BongoCalSplit(BongoJsonObject *obj);
|
||||
GArray *BongoCalSplit(BongoJsonObject *obj);
|
||||
|
||||
/* Merge a json calendar object into another one. Destroys src */
|
||||
BongoJsonResult BongoCalMerge(BongoJsonObject *dest, BongoJsonObject *src);
|
||||
|
||||
+17
-16
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <xpl.h>
|
||||
#include <bongoutil.h>
|
||||
#include <glib.h>
|
||||
|
||||
XPL_BEGIN_C_LINKAGE
|
||||
|
||||
@@ -64,7 +65,7 @@ struct _BongoJsonNode {
|
||||
|
||||
union {
|
||||
BongoJsonObject *objectVal;
|
||||
BongoArray *arrayVal;
|
||||
GArray *arrayVal;
|
||||
BOOL boolVal;
|
||||
double doubleVal;
|
||||
int intVal;
|
||||
@@ -79,7 +80,7 @@ typedef void (*BongoJsonParserFreeFunc)(void *parserData);
|
||||
|
||||
BongoJsonNode *BongoJsonNodeNewNull(void);
|
||||
BongoJsonNode *BongoJsonNodeNewObject(BongoJsonObject *val);
|
||||
BongoJsonNode *BongoJsonNodeNewArray(BongoArray *val);
|
||||
BongoJsonNode *BongoJsonNodeNewArray(GArray *val);
|
||||
BongoJsonNode *BongoJsonNodeNewBool(BOOL val);
|
||||
BongoJsonNode *BongoJsonNodeNewDouble(double val);
|
||||
BongoJsonNode *BongoJsonNodeNewInt(int val);
|
||||
@@ -105,7 +106,7 @@ void BongoJsonNodeFreeSteal(BongoJsonNode *node);
|
||||
|
||||
#define BongoJsonArrayNew(count) BongoArrayNew(sizeof(BongoJsonNode*), count);
|
||||
|
||||
void BongoJsonArrayAppend(BongoArray *array, BongoJsonNode *node);
|
||||
void BongoJsonArrayAppend(GArray *array, BongoJsonNode *node);
|
||||
|
||||
#define BongoJsonArrayAppendObject(a, v) BongoJsonArrayAppend((a), BongoJsonNodeNewObject(v))
|
||||
#define BongoJsonArrayAppendArray(a, v) BongoJsonArrayAppend((a), BongoJsonNodeNewArray(v))
|
||||
@@ -115,16 +116,16 @@ void BongoJsonArrayAppend(BongoArray *array, BongoJsonNode *node);
|
||||
#define BongoJsonArrayAppendString(a, v) BongoJsonArrayAppend((a), BongoJsonNodeNewString(v))
|
||||
#define BongoJsonArrayAppendStringGive(a, v) BongoJsonArrayAppend((a), BongoJsonNodeNewStringGive(v))
|
||||
|
||||
void BongoJsonArrayToStringBuilder(BongoArray *array, BongoStringBuilder *sb);
|
||||
char *BongoJsonArrayToString(BongoArray *array);
|
||||
void BongoJsonArrayToStringBuilder(GArray *array, BongoStringBuilder *sb);
|
||||
char *BongoJsonArrayToString(GArray *array);
|
||||
|
||||
void BongoJsonArrayRemove(BongoArray *array, int i);
|
||||
void BongoJsonArrayRemoveSteal(BongoArray *array, int i);
|
||||
void BongoJsonArrayRemove(GArray *array, int i);
|
||||
void BongoJsonArrayRemoveSteal(GArray *array, int i);
|
||||
|
||||
#define BongoJsonArrayGet(a, i) BongoArrayIndex((a), BongoJsonNode*, (i))
|
||||
#define BongoJsonArrayGet(a, i) g_array_index((a), BongoJsonNode*, (i))
|
||||
|
||||
#define DEF_ARRAY_GET(ctype, etype, name) \
|
||||
static __inline BongoJsonResult BongoJsonArrayGet##name(BongoArray *array, int i, ctype *val) \
|
||||
static __inline BongoJsonResult BongoJsonArrayGet##name(GArray *array, int i, ctype *val) \
|
||||
{ \
|
||||
BongoJsonNode *node = BongoJsonArrayGet(array, i); \
|
||||
if (node->type == etype) { \
|
||||
@@ -136,7 +137,7 @@ void BongoJsonArrayRemoveSteal(BongoArray *array, int i);
|
||||
}
|
||||
|
||||
DEF_ARRAY_GET(BongoJsonObject *, BONGO_JSON_OBJECT, Object);
|
||||
DEF_ARRAY_GET(BongoArray *, BONGO_JSON_ARRAY, Array);
|
||||
DEF_ARRAY_GET(GArray *, BONGO_JSON_ARRAY, Array);
|
||||
DEF_ARRAY_GET(BOOL, BONGO_JSON_BOOL, Bool);
|
||||
DEF_ARRAY_GET(double, BONGO_JSON_DOUBLE, Double);
|
||||
DEF_ARRAY_GET(int, BONGO_JSON_INT, Int);
|
||||
@@ -144,9 +145,9 @@ DEF_ARRAY_GET(const char *, BONGO_JSON_STRING, String);
|
||||
|
||||
#undef DEF_ARRAY_GET
|
||||
|
||||
BongoArray *BongoJsonArrayDup(BongoArray *array);
|
||||
GArray *BongoJsonArrayDup(GArray *array);
|
||||
|
||||
void BongoJsonArrayFree(BongoArray *array);
|
||||
void BongoJsonArrayFree(GArray *array);
|
||||
|
||||
/*** BongoJsonObject ***/
|
||||
|
||||
@@ -172,7 +173,7 @@ BOOL BongoJsonObjectIterNext(BongoJsonObject *obj, BongoJsonObjectIter *iter);
|
||||
BongoJsonResult BongoJsonObjectGet(BongoJsonObject *obj, const char *key, BongoJsonNode **node);
|
||||
|
||||
BongoJsonResult BongoJsonObjectGetObject(BongoJsonObject *obj, const char *key, BongoJsonObject **val);
|
||||
BongoJsonResult BongoJsonObjectGetArray(BongoJsonObject *obj, const char *key, BongoArray **val);
|
||||
BongoJsonResult BongoJsonObjectGetArray(BongoJsonObject *obj, const char *key, GArray **val);
|
||||
BongoJsonResult BongoJsonObjectGetBool(BongoJsonObject *obj, const char *key, BOOL *val);
|
||||
BongoJsonResult BongoJsonObjectGetDouble(BongoJsonObject *obj, const char *key, double *val);
|
||||
BongoJsonResult BongoJsonObjectGetInt(BongoJsonObject *obj, const char *key, int *val);
|
||||
@@ -181,7 +182,7 @@ BongoJsonResult BongoJsonObjectGetString(BongoJsonObject *obj, const char *key,
|
||||
BongoJsonResult BongoJsonObjectPut(BongoJsonObject *obj, const char *key, BongoJsonNode *node);
|
||||
BongoJsonResult BongoJsonObjectPutNull(BongoJsonObject *obj, const char *key);
|
||||
BongoJsonResult BongoJsonObjectPutObject(BongoJsonObject *obj, const char *key, BongoJsonObject *val);
|
||||
BongoJsonResult BongoJsonObjectPutArray(BongoJsonObject *obj, const char *key, BongoArray *val);
|
||||
BongoJsonResult BongoJsonObjectPutArray(BongoJsonObject *obj, const char *key, GArray *val);
|
||||
BongoJsonResult BongoJsonObjectPutBool(BongoJsonObject *obj, const char *key, BOOL val);
|
||||
BongoJsonResult BongoJsonObjectPutDouble(BongoJsonObject *obj, const char *key, double val);
|
||||
BongoJsonResult BongoJsonObjectPutInt(BongoJsonObject *obj, const char *key, int val);
|
||||
@@ -217,7 +218,7 @@ BongoJsonResult BongoJsonParserReadNode(BongoJsonParser *parser, BongoJsonNode *
|
||||
BongoJsonNode *BongoJsonJPath(BongoJsonNode *root, const char *path);
|
||||
|
||||
BongoJsonResult BongoJsonJPathGetObject(BongoJsonNode *n, const char *path, BongoJsonObject **val);
|
||||
BongoJsonResult BongoJsonJPathGetArray(BongoJsonNode *n, const char *path, BongoArray **val);
|
||||
BongoJsonResult BongoJsonJPathGetArray(BongoJsonNode *n, const char *path, GArray **val);
|
||||
BongoJsonResult BongoJsonJPathGetBool(BongoJsonNode *n, const char *path, BOOL *val);
|
||||
BongoJsonResult BongoJsonJPathGetInt(BongoJsonNode *n, const char *path, int *val);
|
||||
BongoJsonResult BongoJsonJPathGetString(BongoJsonNode *n, const char *path, char **val);
|
||||
@@ -249,7 +250,7 @@ BongoJsonResult BongoJsonObjectResolve(BongoJsonObject *obj, const char *path, B
|
||||
}
|
||||
|
||||
DEF_TYPED_RESOLVER(BongoJsonObject *, BONGO_JSON_OBJECT, Object);
|
||||
DEF_TYPED_RESOLVER(BongoArray *, BONGO_JSON_ARRAY, Array);
|
||||
DEF_TYPED_RESOLVER(GArray *, BONGO_JSON_ARRAY, Array);
|
||||
DEF_TYPED_RESOLVER(BOOL, BONGO_JSON_BOOL, Bool);
|
||||
DEF_TYPED_RESOLVER(double, BONGO_JSON_DOUBLE, Double);
|
||||
DEF_TYPED_RESOLVER(int, BONGO_JSON_INT, Int);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <xpl.h>
|
||||
#include <bongojson.h>
|
||||
#include <connio.h>
|
||||
#include <glib.h>
|
||||
|
||||
typedef struct _BongoJsonRpc BongoJsonRpc;
|
||||
typedef struct _BongoJsonRpcServer BongoJsonRpcServer;
|
||||
@@ -34,7 +35,7 @@ typedef void (*BongoJsonRpcMethodFunc) (BongoJsonRpcServer *server,
|
||||
BongoJsonRpc *rpc,
|
||||
int requestId,
|
||||
const char *method,
|
||||
BongoArray *params,
|
||||
GArray *params,
|
||||
void *userData);
|
||||
|
||||
typedef BOOL (*BongoJsonRpcConnectionFunc) (BongoJsonRpcServer *server,
|
||||
@@ -66,7 +67,7 @@ void BongoJsonRpcFree (BongoJsonRpc *rpc);
|
||||
|
||||
BongoJsonObject *BongoJsonRpcRequest (BongoJsonRpc *rpc,
|
||||
const char *method,
|
||||
BongoArray *params);
|
||||
GArray *params);
|
||||
|
||||
/* === Server Side === */
|
||||
BongoJsonRpcServer *BongoJsonRpcServerNew (Connection *listener);
|
||||
|
||||
+3
-2
@@ -348,7 +348,8 @@ BongoSList *BongoSListDelete(BongoSList *list, void *data, BOOL deep);
|
||||
/** end lists.c **/
|
||||
|
||||
/** begin array.c **/
|
||||
|
||||
typedef int (*ArrayCompareFunc)(const void *, const void *);
|
||||
#if 0
|
||||
typedef struct _BongoArray BongoArray;
|
||||
|
||||
struct _BongoArray {
|
||||
@@ -358,7 +359,6 @@ struct _BongoArray {
|
||||
unsigned int elemSize;
|
||||
};
|
||||
|
||||
typedef int (*ArrayCompareFunc)(const void *, const void *);
|
||||
|
||||
int BongoArrayInit(BongoArray *array,
|
||||
unsigned int elementSize, unsigned int numElements);
|
||||
@@ -381,6 +381,7 @@ int BongoArrayFindUnsorted(BongoArray *array, void *needle, ArrayCompareFunc com
|
||||
|
||||
|
||||
#define BongoArrayCount(arrayptr) ((arrayptr)->len)
|
||||
#endif
|
||||
|
||||
/** end array.c **/
|
||||
|
||||
|
||||
+3
-3
@@ -131,7 +131,7 @@ BOOL NMAPInitialize();
|
||||
void NMAPSetEncryption(bongo_ssl_context *context);
|
||||
bongo_ssl_context *NMAPSSLContextAlloc(void);
|
||||
|
||||
int NMAPSendCommand(Connection *conn, const unsigned char *command, size_t length);
|
||||
int NMAPSendCommand(Connection *conn, const char *command, size_t length);
|
||||
int NMAPSendCommandF(Connection *conn, const char *format, ...) XPL_PRINTF(2, 3);
|
||||
|
||||
int NMAPReadResponse(Connection *conn, unsigned char *response, size_t length, BOOL check);
|
||||
@@ -143,7 +143,7 @@ int NMAPRunCommandF(Connection *conn, char *response, size_t length, const char
|
||||
|
||||
/* Configuration function for agents etc. */
|
||||
BOOL
|
||||
NMAPReadConfigFile(const unsigned char *file, unsigned char **output);
|
||||
NMAPReadConfigFile(const char *file, char **output);
|
||||
|
||||
int NMAPReadCrLf(Connection *conn);
|
||||
int NMAPReadPropertyValueLength(Connection *conn, const char *propertyName, size_t *propertyValueLen);
|
||||
@@ -169,7 +169,7 @@ BongoCalObject *NMAPGetEvents(Connection *conn, const char *calendar, BongoCalTi
|
||||
BOOL NMAPAddEvent(Connection *conn, BongoCalObject *cal, const char *calendar, char *uid, int uidLen);
|
||||
|
||||
/* NMAPReadAnswer and NMAPReadAnswerLine are deprecated in favor of NMAPReadResponse and NMAPReadResponseLine */
|
||||
int NMAPReadAnswer(Connection *conn, unsigned char *response, size_t length, BOOL checkForResult);
|
||||
int NMAPReadAnswer(Connection *conn, char *response, size_t length, BOOL checkForResult);
|
||||
int NMAPReadAnswerLine(Connection *conn, unsigned char *response, size_t length, BOOL checkForResult);
|
||||
|
||||
Connection *NMAPConnect(unsigned char *address, struct sockaddr_in *addr);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
StrictCompile()
|
||||
|
||||
add_executable(bongoantispam
|
||||
antispam.c
|
||||
spamd.c
|
||||
|
||||
@@ -78,19 +78,15 @@ static __inline int
|
||||
ProcessConnection(void *clientp, Connection *conn)
|
||||
{
|
||||
ASpamClient *client = clientp;
|
||||
unsigned char *envelopeLine;
|
||||
char *envelopeLine;
|
||||
BOOL hasFlags = FALSE;
|
||||
unsigned long msgFlags = 0;
|
||||
int ccode;
|
||||
|
||||
int length;
|
||||
unsigned long source = 0;
|
||||
unsigned char *ptr;
|
||||
char *ptr;
|
||||
char *ptr2;
|
||||
unsigned char *cur;
|
||||
unsigned char *line;
|
||||
char *senderUserName = NULL;
|
||||
unsigned char qID[16];
|
||||
BOOL copy;
|
||||
BOOL blocked = FALSE;
|
||||
|
||||
@@ -129,7 +125,7 @@ ProcessConnection(void *clientp, Connection *conn)
|
||||
BONGO_ENVELOPE_NEXT(envelopeLine);
|
||||
}
|
||||
|
||||
blocked = SpamdCheck(&ASpam.spamd, client, client->qID, hasFlags, msgFlags, source, senderUserName);
|
||||
blocked = SpamdCheck(&ASpam.spamd, client, client->qID, hasFlags, msgFlags);
|
||||
|
||||
done:
|
||||
|
||||
@@ -152,7 +148,7 @@ done:
|
||||
|
||||
static BOOL
|
||||
ReadConfiguration(void) {
|
||||
unsigned char *pconfig;
|
||||
char *pconfig;
|
||||
BOOL retcode = FALSE;
|
||||
BongoJsonNode *node;
|
||||
|
||||
@@ -165,13 +161,17 @@ ReadConfiguration(void) {
|
||||
printf("manager: couldn't read config from store\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (! ReadBongoConfiguration(GlobalConfig, "global")) {
|
||||
Log(LOG_ERROR, "Unable to read Global configration from the store.");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (BongoJsonParseString(pconfig, &node) != BONGO_JSON_OK) {
|
||||
printf("manager: couldn't parse JSON config\n");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
SpamdReadConfiguration(&ASpam.spamd, node);
|
||||
SpamdReadConfiguration(&ASpam.spamd);
|
||||
|
||||
retcode = TRUE;
|
||||
finish:
|
||||
@@ -237,7 +237,7 @@ SignalHandler(int sigtype)
|
||||
XplServiceCode(SignalHandler)
|
||||
|
||||
static void
|
||||
AntispamServer(void *ignored) {
|
||||
AntispamServer() {
|
||||
int minThreads, maxThreads, minSleep;
|
||||
|
||||
BongoQueueAgentGetThreadPoolParameters(&ASpam.agent, &minThreads, &maxThreads, &minSleep);
|
||||
@@ -257,7 +257,7 @@ AntispamServer(void *ignored) {
|
||||
}
|
||||
|
||||
int
|
||||
XplServiceMain(int argc, char *argv[])
|
||||
XplServiceMain()
|
||||
{
|
||||
int ccode;
|
||||
int startupOpts;
|
||||
|
||||
@@ -69,19 +69,19 @@ typedef struct {
|
||||
|
||||
Connection *conn;
|
||||
|
||||
unsigned int envelopeLength;
|
||||
unsigned int messageLength;
|
||||
unsigned int envelopeLines;
|
||||
int envelopeLength;
|
||||
int messageLength;
|
||||
int envelopeLines;
|
||||
|
||||
char qID[16]; /* holds the queueID */
|
||||
unsigned char *envelope;
|
||||
unsigned char line[CONN_BUFSIZE + 1];
|
||||
char *envelope;
|
||||
char line[CONN_BUFSIZE + 1];
|
||||
unsigned char command[CONN_BUFSIZE + 1];
|
||||
} ASpamClient;
|
||||
|
||||
typedef struct {
|
||||
AddressPool hosts;
|
||||
BongoArray *hostlist;
|
||||
GArray *hostlist;
|
||||
BOOL enabled;
|
||||
unsigned long connectionTimeout;
|
||||
} SpamdConfig;
|
||||
@@ -119,8 +119,6 @@ typedef struct _ASpamGlobals {
|
||||
|
||||
Connection *conn;
|
||||
|
||||
void *pool;
|
||||
|
||||
time_t sleepTime;
|
||||
|
||||
unsigned long queue;
|
||||
@@ -160,9 +158,9 @@ typedef struct _ASpamGlobals {
|
||||
extern ASpamGlobals ASpam;
|
||||
|
||||
/* spamd.c */
|
||||
BOOL SpamdCheck(SpamdConfig *spamd, ASpamClient *client, const char *queueID, BOOL hasFlags, unsigned long msgFlags, unsigned long senderIp, char *senderUserName);
|
||||
BOOL SpamdCheck(SpamdConfig *spamd, ASpamClient *client, const char *queueID, BOOL hasFlags, unsigned long msgFlags);
|
||||
void SpamdShutdown(SpamdConfig *spamd);
|
||||
void SpamdStartup(SpamdConfig *spamd);
|
||||
BOOL SpamdReadConfiguration(SpamdConfig *spamd, BongoJsonNode *node);
|
||||
BOOL SpamdReadConfiguration(SpamdConfig *spamd);
|
||||
|
||||
#endif /* _ANTISPAM_H */
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
/** \file spamd.c Code used by the anti-spam agent to use the spamd engine.
|
||||
*/
|
||||
#define _NO_BONGO_GLOBALS
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -53,7 +54,6 @@
|
||||
* \param queueID Queue-unique id of the message currently being processed. NMAP provides this in the callback.
|
||||
* \param hasFlags To be documented
|
||||
* \param msgFlags To be documented
|
||||
* \param senderIp IP address of the sending party
|
||||
* \param senderUserName Username of the sending party (FIXME - check this)
|
||||
* \return True if infected.
|
||||
*
|
||||
@@ -63,7 +63,7 @@
|
||||
/* #define VERBOSE_SPAMD */
|
||||
BOOL
|
||||
SpamdCheck(SpamdConfig *spamd, ASpamClient *client, const char *queueID, BOOL hasFlags,
|
||||
unsigned long msgFlags, unsigned long senderIp, char *senderUserName)
|
||||
unsigned long msgFlags)
|
||||
{
|
||||
int ccode;
|
||||
BOOL infected;
|
||||
@@ -267,7 +267,7 @@ this is commented out until we determine how we'd want to do this sort of thing,
|
||||
}
|
||||
|
||||
static void
|
||||
ParseHost(char *buffer, char **host, unsigned short *port, unsigned long *weight)
|
||||
ParseHost(char *buffer, char **host, int *port, int *weight)
|
||||
{
|
||||
char *portPtr;
|
||||
char *weightPtr;
|
||||
@@ -330,9 +330,8 @@ static BongoConfigItem SpamdConfigSchema[] = {
|
||||
};
|
||||
|
||||
BOOL
|
||||
SpamdReadConfiguration(SpamdConfig *spamd, BongoJsonNode *node)
|
||||
SpamdReadConfiguration(SpamdConfig *spamd)
|
||||
{
|
||||
const char *tempHost;
|
||||
unsigned int i;
|
||||
|
||||
memset(spamd, 0, sizeof(SpamdConfig));
|
||||
@@ -344,8 +343,8 @@ SpamdReadConfiguration(SpamdConfig *spamd, BongoJsonNode *node)
|
||||
if (!ReadBongoConfiguration(SpamdConfigSchema, "antispam"))
|
||||
return FALSE;
|
||||
|
||||
for (i=0; i < BongoArrayCount(ASpam.spamd.hostlist); i++) {
|
||||
char *hostitem = &BongoArrayIndex(ASpam.spamd.hostlist, char*, i);
|
||||
for (i=0; i < ASpam.spamd.hostlist->len; i++) {
|
||||
char *hostitem = g_array_index(ASpam.spamd.hostlist, char*, i);
|
||||
char *lHost = MemStrdup(hostitem);
|
||||
char *host;
|
||||
int port, weight;
|
||||
|
||||
@@ -419,8 +419,8 @@ ReadConfiguration(void) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i=0; i < BongoArrayCount(AVirus.clamd.hostlist); i++) {
|
||||
char *hostitem = BongoArrayIndex(AVirus.clamd.hostlist, char*, i);
|
||||
for (i=0; i < AVirus.clamd.hostlist->len; i++) {
|
||||
char *hostitem = g_array_index(AVirus.clamd.hostlist, char*, i);
|
||||
char *lHost = MemStrdup(hostitem);
|
||||
char *host;
|
||||
int port, weight;
|
||||
|
||||
@@ -116,7 +116,7 @@ typedef struct _AVirusGlobals {
|
||||
|
||||
struct {
|
||||
AddressPool hosts;
|
||||
BongoArray *hostlist;
|
||||
GArray *hostlist;
|
||||
BOOL enabled;
|
||||
unsigned long connectionTimeout;
|
||||
} clamd;
|
||||
|
||||
@@ -431,7 +431,7 @@ MessageDetailsFree(MessageDetail *messageDetail)
|
||||
}
|
||||
|
||||
if (messageDetail->mimeInfo) {
|
||||
BongoArrayFree(messageDetail->mimeInfo, TRUE);
|
||||
g_array_free(messageDetail->mimeInfo, TRUE);
|
||||
messageDetail->mimeInfo = NULL;
|
||||
}
|
||||
}
|
||||
@@ -946,7 +946,7 @@ FetchFlagResponderBodyStructure(void *param1, void *param2, void *param3)
|
||||
|
||||
if (ccode != -1) {
|
||||
do {
|
||||
char *mime_string = BongoArrayIndex(FetchRequest->messageDetail.mimeInfo,
|
||||
char *mime_string = g_array_index(FetchRequest->messageDetail.mimeInfo,
|
||||
char *, mimeResponseLine);
|
||||
switch(atol(mime_string)) {
|
||||
case 2002: {
|
||||
@@ -1280,7 +1280,7 @@ FetchFlagResponderBodyStructure(void *param1, void *param2, void *param3)
|
||||
}
|
||||
|
||||
mimeResponseLine++;
|
||||
if (mimeResponseLine < BongoArrayCount(FetchRequest->messageDetail.mimeInfo)) {
|
||||
if (mimeResponseLine < FetchRequest->messageDetail.mimeInfo->len) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1704,7 +1704,7 @@ FetchFlagResponderBodyHeaderFields(void *param1, void *param2, void *param3)
|
||||
}
|
||||
|
||||
__inline static BOOL
|
||||
HasPart(BongoArray *mimeInfo, BodyPartRequestStruct *request)
|
||||
HasPart(GArray *mimeInfo, BodyPartRequestStruct *request)
|
||||
{
|
||||
unsigned char type[MIME_TYPE_LEN+1];
|
||||
unsigned char dummy[MIME_NAME_LEN+1];
|
||||
@@ -1720,7 +1720,7 @@ HasPart(BongoArray *mimeInfo, BodyPartRequestStruct *request)
|
||||
unsigned long matchDepthPart = 0;
|
||||
|
||||
do {
|
||||
char *mime_string = BongoArrayIndex(mimeInfo, char *, mimeResponseLine);
|
||||
char *mime_string = g_array_index(mimeInfo, char *, mimeResponseLine);
|
||||
switch (atol(mime_string)) {
|
||||
case 2002: {
|
||||
ParseMIMEDLine(mime_string + 5,
|
||||
@@ -1808,7 +1808,7 @@ HasPart(BongoArray *mimeInfo, BodyPartRequestStruct *request)
|
||||
}
|
||||
|
||||
mimeResponseLine++;
|
||||
if (mimeResponseLine < BongoArrayCount(mimeInfo)) {
|
||||
if (mimeResponseLine < mimeInfo->len) {
|
||||
if (depthChange == 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -3015,12 +3015,12 @@ GetMimeInfo(ImapSession *session, FetchStruct *FetchRequest)
|
||||
long ccode;
|
||||
|
||||
if (FetchRequest->messageDetail.mimeInfo == NULL) {
|
||||
FetchRequest->messageDetail.mimeInfo = BongoArrayNew(sizeof(char *), 0);
|
||||
FetchRequest->messageDetail.mimeInfo = g_array_new(FALSE, FALSE, sizeof(char *));
|
||||
if (! FetchRequest->messageDetail.mimeInfo) {
|
||||
return(STATUS_MEMORY_ERROR);
|
||||
}
|
||||
} else {
|
||||
BongoArrayFree(FetchRequest->messageDetail.mimeInfo, TRUE);
|
||||
g_array_free(FetchRequest->messageDetail.mimeInfo, TRUE);
|
||||
}
|
||||
|
||||
if (NMAPSendCommandF(session->store.conn, "MIME %llx\r\n", FetchRequest->message->guid) != -1) {
|
||||
@@ -3033,7 +3033,7 @@ GetMimeInfo(ImapSession *session, FetchStruct *FetchRequest)
|
||||
entry = MemMalloc(len);
|
||||
memcpy(entry, session->store.response, len);
|
||||
|
||||
BongoArrayAppendValue(FetchRequest->messageDetail.mimeInfo, entry);
|
||||
g_array_append_val(FetchRequest->messageDetail.mimeInfo, entry);
|
||||
ccode = NMAPReadResponse(session->store.conn, session->store.response, sizeof(session->store.response), FALSE);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
unsigned long sequenceNumber;
|
||||
unsigned char *header;
|
||||
BongoArray *mimeInfo;
|
||||
GArray *mimeInfo;
|
||||
} MessageDetail;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -180,7 +180,7 @@ ReadConfiguration (BOOL *recover)
|
||||
Conf.defaultSequentialWorkers = Conf.maxSequentialWorkers;
|
||||
}
|
||||
|
||||
BongoArraySort(Conf.trustedHosts, (ArrayCompareFunc)strcmp);
|
||||
g_array_sort(Conf.trustedHosts, (ArrayCompareFunc)strcmp);
|
||||
|
||||
if (Conf.b_bounceReturn) {
|
||||
Conf.bounceHandling |= BOUNCE_RETURN;
|
||||
@@ -195,11 +195,11 @@ ReadConfiguration (BOOL *recover)
|
||||
}
|
||||
|
||||
/* sort the hostedDomains to make searching later faster. */
|
||||
BongoArraySort(Conf.domains, (ArrayCompareFunc)hostedSortFunc);
|
||||
g_array_sort(Conf.domains, (ArrayCompareFunc)hostedSortFunc);
|
||||
|
||||
/* now let's iterate over the domains and read in any aliasing information for those domains */
|
||||
{
|
||||
Conf.aliasList = BongoArrayNew(sizeof(struct _AliasStruct), Conf.domains->len);
|
||||
Conf.aliasList = g_array_sized_new(FALSE, FALSE, sizeof(struct _AliasStruct), Conf.domains->len);
|
||||
|
||||
unsigned int x;
|
||||
for(x=0;x<Conf.domains->len;x++) {
|
||||
@@ -208,7 +208,7 @@ ReadConfiguration (BOOL *recover)
|
||||
BongoJsonNode *node;
|
||||
struct _AliasStruct a;
|
||||
|
||||
a.original = MemStrdup(BongoArrayIndex(Conf.domains, unsigned char *, x));
|
||||
a.original = MemStrdup(g_array_index(Conf.domains, unsigned char *, x));
|
||||
a.to = NULL;
|
||||
a.aliases = NULL;
|
||||
a.mapping_type = 0;
|
||||
@@ -225,7 +225,7 @@ ReadConfiguration (BOOL *recover)
|
||||
if (BongoJsonJPathGetObject(node, "o:aliases/o", &obj) == BONGO_JSON_OK) {
|
||||
BongoJsonObjectIter iter;
|
||||
|
||||
a.aliases = BongoArrayNew(sizeof(struct _AliasStruct), 1);
|
||||
a.aliases = g_array_new(FALSE, FALSE, sizeof(struct _AliasStruct));
|
||||
|
||||
BongoJsonObjectIterFirst(obj, &iter);
|
||||
while (iter.key) {
|
||||
@@ -239,21 +239,21 @@ ReadConfiguration (BOOL *recover)
|
||||
b.aliases = NULL;
|
||||
b.mapping_type = 0;
|
||||
|
||||
BongoArrayAppendValue(a.aliases, b);
|
||||
g_array_append_val(a.aliases, b);
|
||||
|
||||
BongoJsonObjectIterNext(obj, &iter);
|
||||
}
|
||||
BongoArraySort(a.aliases, (ArrayCompareFunc)aliasCmpFunc);
|
||||
g_array_sort(a.aliases, (ArrayCompareFunc)aliasCmpFunc);
|
||||
}
|
||||
BongoJsonNodeFree(node);
|
||||
}
|
||||
}
|
||||
|
||||
BongoArrayAppendValue(Conf.aliasList, a);
|
||||
g_array_append_val(Conf.aliasList, a);
|
||||
}
|
||||
|
||||
/* sort the list for speed later */
|
||||
BongoArraySort(Conf.aliasList, (ArrayCompareFunc)aliasCmpFunc);
|
||||
g_array_sort(Conf.aliasList, (ArrayCompareFunc)aliasCmpFunc);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ typedef struct _QueueConfiguration {
|
||||
char *quotaMessage;
|
||||
|
||||
/* Trusted hosts */
|
||||
BongoArray *trustedHosts;
|
||||
GArray *trustedHosts;
|
||||
|
||||
/* Paths */
|
||||
char spoolPath[XPL_MAX_PATH + 1];
|
||||
@@ -101,17 +101,17 @@ typedef struct _QueueConfiguration {
|
||||
unsigned long lastRead;
|
||||
|
||||
/* aliasing system */
|
||||
BongoArray *hostedDomains;
|
||||
BongoArray *aliasList;
|
||||
GArray *hostedDomains;
|
||||
GArray *aliasList;
|
||||
|
||||
BongoArray *domains;
|
||||
GArray *domains;
|
||||
} QueueConfiguration;
|
||||
|
||||
struct _AliasStruct{
|
||||
unsigned char* original;
|
||||
unsigned char* to;
|
||||
unsigned int mapping_type;
|
||||
BongoArray *aliases;
|
||||
GArray *aliases;
|
||||
};
|
||||
|
||||
typedef struct _AliasStruct AliasStruct;
|
||||
|
||||
@@ -92,4 +92,5 @@ QDBDump(unsigned char *domain)
|
||||
void
|
||||
QDBSummarizeQueue(void)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-25
@@ -313,36 +313,36 @@ AddPushAgent(QueueClient *client,
|
||||
|
||||
/* first look through the list to find the right queue */
|
||||
tempQueue.queue = queue;
|
||||
ItemIndex = BongoArrayFindSorted(Queue.PushClients.queues, &p_tempQueue, FindQueue);
|
||||
ItemIndex = GArrayFindSorted(Queue.PushClients.queues, &p_tempQueue, FindQueue);
|
||||
if (ItemIndex < 0) {
|
||||
/* there is no queue item in the array yet. we need to initialize one */
|
||||
CurrentQueue = MemNew0(QueueList, 1);
|
||||
CurrentQueue->queue = queue;
|
||||
CurrentQueue->pools = BongoArrayNew(sizeof(QueuePoolList *), 1);
|
||||
BongoArrayAppendValue(Queue.PushClients.queues, CurrentQueue);
|
||||
CurrentQueue->pools = g_array_new(FALSE, FALSE, sizeof(QueuePoolList *));
|
||||
g_array_append_val(Queue.PushClients.queues, CurrentQueue);
|
||||
} else {
|
||||
CurrentQueue = BongoArrayIndex(Queue.PushClients.queues, QueueList *, ItemIndex);
|
||||
CurrentQueue = g_array_index(Queue.PushClients.queues, QueueList *, ItemIndex);
|
||||
}
|
||||
|
||||
/* CurrentQueue should be set now */
|
||||
strncpy(tempPool.identifier, identifier, 100);
|
||||
ItemIndex = BongoArrayFindSorted(CurrentQueue->pools, &p_tempPool, FindPool);
|
||||
ItemIndex = GArrayFindSorted(CurrentQueue->pools, &p_tempPool, FindPool);
|
||||
if (ItemIndex < 0) {
|
||||
/* there is no pool already. we need to initialize one */
|
||||
CurrentPool = MemNew0(QueuePoolList, 1);
|
||||
strncpy(CurrentPool->identifier, identifier, 100);
|
||||
ConnAddressPoolStartup(&CurrentPool->pool, 5, 60);
|
||||
BongoArrayAppendValue(CurrentQueue->pools, CurrentPool);
|
||||
g_array_append_val(CurrentQueue->pools, CurrentPool);
|
||||
} else {
|
||||
CurrentPool = BongoArrayIndex(CurrentQueue->pools, QueuePoolList *, ItemIndex);
|
||||
CurrentPool = g_array_index(CurrentQueue->pools, QueuePoolList *, ItemIndex);
|
||||
}
|
||||
|
||||
/* CurrentPool should be set now */
|
||||
ConnAddressPoolAddHost(&CurrentPool->pool, address, htons(port), 1); /* the protocol doesn't support passing a weight so weight everything equally */
|
||||
|
||||
/* resort both arrays */
|
||||
BongoArraySort(CurrentQueue->pools, FindPool);
|
||||
BongoArraySort(Queue.PushClients.queues, FindQueue);
|
||||
g_array_sort(CurrentQueue->pools, FindPool);
|
||||
g_array_sort(Queue.PushClients.queues, FindQueue);
|
||||
|
||||
XplMutexUnlock(Queue.PushClients.lock);
|
||||
return 0;
|
||||
@@ -355,16 +355,16 @@ RemoveAllPushAgents(void)
|
||||
QueuePoolList *CurrentPool;
|
||||
|
||||
XplMutexLock(Queue.PushClients.lock);
|
||||
while (BongoArrayCount(Queue.PushClients.queues)) {
|
||||
CurrentQueue = BongoArrayIndex(Queue.PushClients.queues, QueueList *, 0);
|
||||
while (BongoArrayCount(CurrentQueue->pools)) {
|
||||
CurrentPool = BongoArrayIndex(CurrentQueue->pools, QueuePoolList *, 0);
|
||||
while (Queue.PushClients.queues->len) {
|
||||
CurrentQueue = g_array_index(Queue.PushClients.queues, QueueList *, 0);
|
||||
while (CurrentQueue->pools->len) {
|
||||
CurrentPool = g_array_index(CurrentQueue->pools, QueuePoolList *, 0);
|
||||
ConnAddressPoolShutdown(&(CurrentPool->pool));
|
||||
BongoArrayRemove(CurrentQueue->pools, 0);
|
||||
g_array_remove_index_fast(CurrentQueue->pools, 0);
|
||||
MemFree(CurrentPool);
|
||||
}
|
||||
MemFree(CurrentQueue);
|
||||
BongoArrayRemove(Queue.PushClients.queues, 0);
|
||||
g_array_remove_index_fast(Queue.PushClients.queues, 0);
|
||||
}
|
||||
|
||||
XplMutexUnlock(Queue.PushClients.lock);
|
||||
@@ -1432,11 +1432,11 @@ StartOver:
|
||||
|
||||
/* i want to get the current queue and iterate over its pools if there are any */
|
||||
tempQueue.queue = queue;
|
||||
ItemIndex = BongoArrayFindSorted(Queue.PushClients.queues, &p_tempQueue, FindQueue);
|
||||
ItemIndex = GArrayFindSorted(Queue.PushClients.queues, &p_tempQueue, FindQueue);
|
||||
if (ItemIndex >= 0) {
|
||||
QueueList *CurrentQueue = BongoArrayIndex(Queue.PushClients.queues, QueueList *, ItemIndex);
|
||||
for (iter_p=0; iter_p < BongoArrayCount(CurrentQueue->pools); iter_p++) {
|
||||
QueuePoolList *CurrentPool = BongoArrayIndex(CurrentQueue->pools, QueuePoolList *, iter_p);
|
||||
QueueList *CurrentQueue = g_array_index(Queue.PushClients.queues, QueueList *, ItemIndex);
|
||||
for (iter_p=0; iter_p < CurrentQueue->pools->len; iter_p++) {
|
||||
QueuePoolList *CurrentPool = g_array_index(CurrentQueue->pools, QueuePoolList *, iter_p);
|
||||
|
||||
sprintf(path, "%s/c%s.%03d", Conf.spoolPath, entry, queue);
|
||||
stat(path, &sb);
|
||||
@@ -1552,8 +1552,8 @@ StartOver:
|
||||
* and take the next item in the array!! */
|
||||
if (ItemIndex >= 0) {
|
||||
/* i can safely cast the int here to an unsigned as i know that it is positive */
|
||||
if ((unsigned int)++ItemIndex < BongoArrayCount(Queue.PushClients.queues)) {
|
||||
CurrentQueue = BongoArrayIndex(Queue.PushClients.queues, QueueList *, ItemIndex);
|
||||
if ((unsigned int)++ItemIndex < Queue.PushClients.queues->len) {
|
||||
CurrentQueue = g_array_index(Queue.PushClients.queues, QueueList *, ItemIndex);
|
||||
i = CurrentQueue->queue;
|
||||
} else {
|
||||
/* there are no more agents, we can just jump straight to Q_OUTGOING */
|
||||
@@ -1565,8 +1565,8 @@ StartOver:
|
||||
* way of finding this out without looping over the whole array */
|
||||
i = Q_OUTGOING;
|
||||
/* i can safely cast here as ItemIndex is never going to be less than 0 */
|
||||
for (ItemIndex=0;(unsigned int)ItemIndex<BongoArrayCount(Queue.PushClients.queues);ItemIndex++) {
|
||||
CurrentQueue = BongoArrayIndex(Queue.PushClients.queues, QueueList *, ItemIndex);
|
||||
for (ItemIndex=0;(unsigned int)ItemIndex<Queue.PushClients.queues->len;ItemIndex++) {
|
||||
CurrentQueue = g_array_index(Queue.PushClients.queues, QueueList *, ItemIndex);
|
||||
if (CurrentQueue->queue > queue) {
|
||||
i = CurrentQueue->queue;
|
||||
break;
|
||||
@@ -2501,7 +2501,7 @@ QueueInit(void)
|
||||
Queue.queueID = time(NULL) & ((1 << 28) - 1);
|
||||
|
||||
XplMutexInit(Queue.PushClients.lock);
|
||||
Queue.PushClients.queues = BongoArrayNew(sizeof(QueueList *), 1);
|
||||
Queue.PushClients.queues = g_array_new(FALSE, FALSE, sizeof(QueueList *));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2519,7 +2519,7 @@ QueueShutdown(void)
|
||||
XplMutexDestroy(Queue.queueIDLock);
|
||||
|
||||
XplMutexDestroy(Queue.PushClients.lock);
|
||||
BongoArrayDestroy(Queue.PushClients.queues, TRUE);
|
||||
g_array_free(Queue.PushClients.queues, TRUE);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -42,7 +42,7 @@ typedef struct _QueuePushClient {
|
||||
typedef struct _QueueList {
|
||||
int queue;
|
||||
|
||||
BongoArray *pools;
|
||||
GArray *pools;
|
||||
} QueueList;
|
||||
|
||||
typedef struct _QueuePoolList {
|
||||
@@ -64,7 +64,7 @@ typedef struct _Queue {
|
||||
struct {
|
||||
XplMutex lock;
|
||||
|
||||
BongoArray *queues;
|
||||
GArray *queues;
|
||||
} PushClients;
|
||||
|
||||
/* Worker threads */
|
||||
|
||||
@@ -158,18 +158,18 @@ BOOL aliasing(char *addr, int *cnt, unsigned char *buffer) {
|
||||
}
|
||||
|
||||
/* if i get here, i've got a domain name that i can look up in the alias system */
|
||||
i = BongoArrayFindSorted(Conf.aliasList, domain, (ArrayCompareFunc)aliasFindFunc);
|
||||
i = GArrayFindSorted(Conf.aliasList, domain, (ArrayCompareFunc)aliasFindFunc);
|
||||
if (i > -1) {
|
||||
char new_addr[1000]; /* FIXME: seems a bit large */
|
||||
AliasStruct a;
|
||||
|
||||
new_addr[0] = '\0';
|
||||
a = BongoArrayIndex(Conf.aliasList, AliasStruct, i);
|
||||
a = g_array_index(Conf.aliasList, AliasStruct, i);
|
||||
|
||||
/* user aliases should take precedence over domain aliases. check for one of those first */
|
||||
if (a.aliases && a.aliases->len && ((i = BongoArrayFindSorted(a.aliases, local, (ArrayCompareFunc)aliasFindFunc)) > -1)) {
|
||||
if (a.aliases && a.aliases->len && ((i = GArrayFindSorted(a.aliases, local, (ArrayCompareFunc)aliasFindFunc)) > -1)) {
|
||||
AliasStruct b;
|
||||
b = BongoArrayIndex(a.aliases, AliasStruct, i);
|
||||
b = g_array_index(a.aliases, AliasStruct, i);
|
||||
result = aliasing(b.to, cnt, buffer);
|
||||
} else if (a.to && a.to[0] != '\0') {
|
||||
/* there are no user aliasess is there a domain alias? */
|
||||
@@ -258,7 +258,7 @@ int CommandDomainLocation(void *param) {
|
||||
unsigned char *domain = client->buffer + 16;
|
||||
|
||||
/* now search for it */
|
||||
int idx = BongoArrayFindSorted(Conf.hostedDomains, domain, (ArrayCompareFunc)hostedFindFunc);
|
||||
int idx = GArrayFindSorted(Conf.hostedDomains, domain, (ArrayCompareFunc)hostedFindFunc);
|
||||
if (idx > -1) {
|
||||
ConnWriteF(client->conn, MSG1000LOCAL"\r\n", domain);
|
||||
} else {
|
||||
@@ -428,7 +428,7 @@ CheckTrustedHost(QueueClient *client)
|
||||
if (Conf.trustedHosts) {
|
||||
/* TODO: this can be optimized a little bit */
|
||||
XplRWReadLockAcquire(&Conf.lock);
|
||||
i = BongoArrayFindSorted(Conf.trustedHosts, inet_ntoa(client->conn->socketAddress.sin_addr), (ArrayCompareFunc)hostedFindFunc);
|
||||
i = GArrayFindSorted(Conf.trustedHosts, inet_ntoa(client->conn->socketAddress.sin_addr), (ArrayCompareFunc)hostedFindFunc);
|
||||
XplRWReadLockRelease(&Conf.lock);
|
||||
}
|
||||
return (i > -1);
|
||||
|
||||
+14
-14
@@ -45,11 +45,11 @@ GetMimeStructure(RulesClient *c)
|
||||
if (c->MimeStructure) {
|
||||
return Result;
|
||||
}
|
||||
c->MimeStructure = BongoArrayNew(sizeof(char *), 1);
|
||||
c->MimeStructure = g_array_new(FALSE, FALSE, sizeof(char *));
|
||||
if ((Result = NMAPSendCommandF(c->conn, "QMIME %s\r\n", c->qID)) != -1) {
|
||||
while ((Result = NMAPReadAnswer(c->conn, c->line, CONN_BUFSIZE, FALSE)) == 2002) {
|
||||
dup = MemStrdup(c->line);
|
||||
BongoArrayAppendValue(c->MimeStructure, dup);
|
||||
g_array_append_val(c->MimeStructure, dup);
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
@@ -278,8 +278,8 @@ ProcessRules(RulesClient *client)
|
||||
case RULE_COND_BODY_NOT: {
|
||||
GetMimeStructure(client);
|
||||
|
||||
for (used = 0; used < BongoArrayCount(client->MimeStructure); used++) {
|
||||
ptr = BongoArrayIndex(client->MimeStructure, char *, used);
|
||||
for (used = 0; used < client->MimeStructure->len; used++) {
|
||||
ptr = g_array_index(client->MimeStructure, char *, used);
|
||||
|
||||
if ((XplStrNCaseCmp(ptr, "2002-text ", 10) == 0)
|
||||
|| (XplStrNCaseCmp(ptr, "2002 text ", 10) == 0)) {
|
||||
@@ -357,8 +357,8 @@ ProcessRules(RulesClient *client)
|
||||
GetMimeStructure(client);
|
||||
//GET_MIME_STRUCTURE(client, ccode);
|
||||
|
||||
for (used = 0; used < BongoArrayCount(client->MimeStructure); used++) {
|
||||
ptr = BongoArrayIndex(client->MimeStructure, char *, used);
|
||||
for (used = 0; used < client->MimeStructure->len; used++) {
|
||||
ptr = g_array_index(client->MimeStructure, char *, used);
|
||||
|
||||
if (XplStrNCaseCmp(ptr + 5, condition->string[0], condition->length[0]) == 0) {
|
||||
result = TRUE;
|
||||
@@ -378,8 +378,8 @@ ProcessRules(RulesClient *client)
|
||||
//GET_MIME_STRUCTURE(client, ccode);
|
||||
|
||||
result = TRUE;
|
||||
for (used = 0; used < BongoArrayCount(client->MimeStructure); used++) {
|
||||
ptr = BongoArrayIndex(client->MimeStructure, char *, used);
|
||||
for (used = 0; used < client->MimeStructure->len; used++) {
|
||||
ptr = g_array_index(client->MimeStructure, char *, used);
|
||||
|
||||
if (XplStrNCaseCmp(ptr + 5, condition->string[0], condition->length[0]) == 0) {
|
||||
result = FALSE;
|
||||
@@ -618,10 +618,10 @@ ParseRules(RulesClient *client)
|
||||
BongoRule *rule = NULL;
|
||||
|
||||
/* sort the array by rule id... */
|
||||
BongoArraySort(client->RulesStrings, CompareRuleID);
|
||||
g_array_sort(client->RulesStrings, CompareRuleID);
|
||||
|
||||
for (used = 0; used < BongoArrayCount(client->RulesStrings); used++) {
|
||||
cur = BongoArrayIndex(client->RulesStrings, unsigned char *, used);
|
||||
for (used = 0; used < client->RulesStrings->len; used++) {
|
||||
cur = g_array_index(client->RulesStrings, unsigned char *, used);
|
||||
ptr = cur;
|
||||
limit = cur + strlen(cur);
|
||||
|
||||
@@ -1032,10 +1032,10 @@ RulesCleanupInformation(RulesClient *client)
|
||||
}
|
||||
|
||||
if (client->MimeStructure) {
|
||||
for(x=0;x<BongoArrayCount(client->MimeStructure);x++) {
|
||||
MemFree(BongoArrayIndex(client->MimeStructure, char *, x));
|
||||
for(x=0;x<client->MimeStructure->len;x++) {
|
||||
MemFree(g_array_index(client->MimeStructure, char *, x));
|
||||
}
|
||||
BongoArrayFree(client->MimeStructure, TRUE);
|
||||
g_array_free(client->MimeStructure, TRUE);
|
||||
client->MimeStructure = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,8 +94,8 @@ typedef struct {
|
||||
BongoConfigItem rulesConfig[2];
|
||||
BongoConfigItem UserConfig[2];
|
||||
|
||||
BongoArray *RulesStrings;
|
||||
BongoArray *MimeStructure;
|
||||
GArray *RulesStrings;
|
||||
GArray *MimeStructure;
|
||||
|
||||
struct {
|
||||
BongoRule *head;
|
||||
|
||||
@@ -471,7 +471,7 @@ ProcessEntry(void *clientp, Connection *conn)
|
||||
{
|
||||
int ccode;
|
||||
char *envelopeLine;
|
||||
BongoArray *Recipients;
|
||||
GArray *Recipients;
|
||||
RecipStruct CurrentRecip;
|
||||
SMTPClient *Queue = clientp;
|
||||
unsigned int startLocation, Length;
|
||||
@@ -494,7 +494,7 @@ ProcessEntry(void *clientp, Connection *conn)
|
||||
}
|
||||
|
||||
/* array of all the recipients and their information */
|
||||
Recipients = BongoArrayNew(sizeof(RecipStruct), Queue->envelopeLines);
|
||||
Recipients = g_array_sized_new(FALSE, FALSE, sizeof(RecipStruct), Queue->envelopeLines);
|
||||
|
||||
/* parse the envelope lines. since i could be changing the recipients later in the flow
|
||||
* i need to write out all lines as i go */
|
||||
@@ -565,7 +565,7 @@ ProcessEntry(void *clientp, Connection *conn)
|
||||
CurrentRecip.localPart = NULL;
|
||||
}
|
||||
|
||||
BongoArrayAppendValue(Recipients, CurrentRecip);
|
||||
g_array_append_val(Recipients, CurrentRecip);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -581,7 +581,7 @@ ProcessEntry(void *clientp, Connection *conn)
|
||||
}
|
||||
|
||||
/* now that we've got all recipients and locations, let's sort them to use connections more efficiently */
|
||||
BongoArraySort(Recipients, (ArrayCompareFunc)RecipientCompare);
|
||||
g_array_sort(Recipients, (ArrayCompareFunc)RecipientCompare);
|
||||
|
||||
/* now i can skip over any duplicates an do lookups once per remote domain */
|
||||
for(startLocation=0;startLocation<Recipients->len;startLocation++) {
|
||||
@@ -589,12 +589,12 @@ ProcessEntry(void *clientp, Connection *conn)
|
||||
RecipStruct NextRecip;
|
||||
unsigned char *lft;
|
||||
|
||||
CurrentRecip = BongoArrayIndex(Recipients, RecipStruct, startLocation);
|
||||
CurrentRecip = g_array_index(Recipients, RecipStruct, startLocation);
|
||||
lft = CurrentRecip.SortField;
|
||||
Length=startLocation+1;
|
||||
while (Length < Recipients->len) {
|
||||
/* skip over duplicates */
|
||||
NextRecip = BongoArrayIndex(Recipients, RecipStruct, Length);
|
||||
NextRecip = g_array_index(Recipients, RecipStruct, Length);
|
||||
if (strcasecmp(NextRecip.SortField, lft) != 0) {
|
||||
startLocation = Length-1; /* i'm going to inc at the end of the loop... */
|
||||
break;
|
||||
@@ -650,7 +650,7 @@ ProcessEntry(void *clientp, Connection *conn)
|
||||
}
|
||||
|
||||
if (Recipients) {
|
||||
BongoArrayFree(Recipients, TRUE);
|
||||
g_array_free(Recipients, TRUE);
|
||||
}
|
||||
/* The caller will call the free function specified on agent init
|
||||
* which will free the queue struct. the caller will then free the
|
||||
|
||||
@@ -637,7 +637,7 @@ StoreObjectIterQueryBuilderPropResult(StoreClient *client,
|
||||
// start value below "col_id + 9" depends on how many columns
|
||||
// we pull back in our initial query; careful :)
|
||||
for (col_id = 0, result_id = 0; col_id < properties; col_id++) {
|
||||
const StorePropInfo const *prop = BongoArrayIndex(builder->properties,
|
||||
const StorePropInfo const *prop = g_array_index(builder->properties,
|
||||
StorePropInfo *, col_id);
|
||||
|
||||
// ignore properties we don't want output;
|
||||
@@ -686,8 +686,8 @@ StoreObjectIterQueryBuilder(StoreClient *client, QueryBuilder *builder, BOOL sho
|
||||
if (ret == NULL) goto abort;
|
||||
|
||||
// bind in any variables we need
|
||||
for (i = 0; i < BongoArrayCount(builder->parameters); i++) {
|
||||
QueryBuilder_Param *p = BongoArrayIndex((builder->parameters),
|
||||
for (i = 0; i < builder->parameters->len; i++) {
|
||||
QueryBuilder_Param *p = g_array_index((builder->parameters),
|
||||
QueryBuilder_Param *, i);
|
||||
|
||||
switch (p->type) {
|
||||
@@ -705,7 +705,7 @@ StoreObjectIterQueryBuilder(StoreClient *client, QueryBuilder *builder, BOOL sho
|
||||
}
|
||||
}
|
||||
|
||||
properties = BongoArrayCount(builder->properties);
|
||||
properties = builder->properties->len;
|
||||
|
||||
while ((status = MsgSQLResults(client->storedb, &stmt)) > 0) {
|
||||
int ccode;
|
||||
|
||||
@@ -29,9 +29,9 @@ QueryBuilderStart(QueryBuilder *builder)
|
||||
builder->order_direction = ORDER_NONE;
|
||||
builder->output_mode = MODE_COLLECTIONS;
|
||||
|
||||
builder->properties = BongoArrayNew(sizeof(StorePropInfo *), 20);
|
||||
builder->links = BongoArrayNew(sizeof(ExtraLink *), 10);
|
||||
builder->parameters = BongoArrayNew(sizeof(QueryBuilder_Param *), 10);
|
||||
builder->properties = g_array_sized_new(FALSE, FALSE, sizeof(StorePropInfo *), 20);
|
||||
builder->links = g_array_sized_new(FALSE, FALSE, sizeof(ExtraLink *), 10);
|
||||
builder->parameters = g_array_sized_new(FALSE, FALSE, sizeof(QueryBuilder_Param *), 10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -52,25 +52,25 @@ QueryBuilderFinish(QueryBuilder *builder)
|
||||
QueryParserFinish(&builder->external_parser);
|
||||
|
||||
/* free all the properties */
|
||||
for(x=0;x<BongoArrayCount(builder->properties);x++) {
|
||||
newprop = BongoArrayIndex(builder->properties, StorePropInfo *, x);
|
||||
for(x=0;x<builder->properties->len;x++) {
|
||||
newprop = g_array_index(builder->properties, StorePropInfo *, x);
|
||||
MemFree(newprop);
|
||||
}
|
||||
BongoArrayFree(builder->properties, TRUE);
|
||||
g_array_free(builder->properties, TRUE);
|
||||
|
||||
/* free all the links */
|
||||
for(x=0;x<BongoArrayCount(builder->links);x++) {
|
||||
link = BongoArrayIndex(builder->links, ExtraLink *, x);
|
||||
for(x=0;x<builder->links->len;x++) {
|
||||
link = g_array_index(builder->links, ExtraLink *, x);
|
||||
MemFree(link);
|
||||
}
|
||||
BongoArrayFree(builder->links, TRUE);
|
||||
g_array_free(builder->links, TRUE);
|
||||
|
||||
/* free all the parameters */
|
||||
for(x=0;x<BongoArrayCount(builder->parameters);x++) {
|
||||
param = BongoArrayIndex(builder->parameters, QueryBuilder_Param *, x);
|
||||
for(x=0;x<builder->parameters->len;x++) {
|
||||
param = g_array_index(builder->parameters, QueryBuilder_Param *, x);
|
||||
MemFree(param);
|
||||
}
|
||||
BongoArrayFree(builder->parameters, TRUE);
|
||||
g_array_free(builder->parameters, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,7 +186,7 @@ QueryBuilderAddParam(QueryBuilder *builder, int position,
|
||||
return -1;
|
||||
}
|
||||
|
||||
BongoArrayAppendValues(builder->parameters, &p, 1);
|
||||
g_array_append_val(builder->parameters, p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -209,8 +209,8 @@ QueryBuilderAddProperty(QueryBuilder *builder, char const *property, BOOL output
|
||||
StorePropInfo *newprop;
|
||||
unsigned int i;
|
||||
|
||||
for (i=0; i < BongoArrayCount(builder->properties); i++) {
|
||||
StorePropInfo *prop = BongoArrayIndex(builder->properties, StorePropInfo *, i);
|
||||
for (i=0; i < builder->properties->len; i++) {
|
||||
StorePropInfo *prop = g_array_index(builder->properties, StorePropInfo *, i);
|
||||
|
||||
if (strcmp(prop->name, property) == 0) {
|
||||
// we already have this property
|
||||
@@ -222,12 +222,12 @@ QueryBuilderAddProperty(QueryBuilder *builder, char const *property, BOOL output
|
||||
newprop = MemNew0(StorePropInfo, 1);
|
||||
newprop->type = 0;
|
||||
newprop->name = (char *)property;
|
||||
newprop->index = BongoArrayCount(builder->properties);
|
||||
newprop->index = builder->properties->len;
|
||||
|
||||
StorePropertyFixup(newprop);
|
||||
|
||||
newprop->output = output;
|
||||
BongoArrayAppendValues(builder->properties, &newprop, 1);
|
||||
g_array_append_val(builder->properties, newprop);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -267,10 +267,10 @@ QueryBuilderFindExpressionProps(QueryBuilder *builder, struct expression *exp)
|
||||
link->join_column = "related_guid";
|
||||
link->test_column = "doc_guid";
|
||||
}
|
||||
link->pos = BongoArrayCount(builder->links);
|
||||
link->pos = builder->links->len;
|
||||
|
||||
// add the new link to our list of links
|
||||
BongoArrayAppendValues(builder->links, &link, 1);
|
||||
g_array_append_val(builder->links, link);
|
||||
exp->exp1 = link; // FIXME: [linkhack] very hacky :(
|
||||
return 0;
|
||||
}
|
||||
@@ -342,8 +342,8 @@ QueryBuilderCreateSQL(QueryBuilder *builder, char **output)
|
||||
BongoStringBuilderAppend(&b, "SELECT so.guid, so.collection_guid, so.imap_uid, so.filename, so.type, so.flags, so.size, so.time_created, so.time_modified");
|
||||
|
||||
// extra columns for additional properties
|
||||
for (i=0; i < BongoArrayCount(builder->properties); i++) {
|
||||
StorePropInfo *prop = BongoArrayIndex(builder->properties, StorePropInfo *, i);
|
||||
for (i=0; i < builder->properties->len; i++) {
|
||||
StorePropInfo *prop = g_array_index(builder->properties, StorePropInfo *, i);
|
||||
// only add those columns which we want returned.
|
||||
BongoStringBuilderAppend(&b, ", ");
|
||||
QueryBuilderPropertyToColumn(builder, &b, prop);
|
||||
@@ -355,14 +355,14 @@ QueryBuilderCreateSQL(QueryBuilder *builder, char **output)
|
||||
if (builder->linkin_conversations) {
|
||||
BongoStringBuilderAppend(&b, " INNER JOIN conversation c ON so.guid=c.guid");
|
||||
}
|
||||
for (i=0; i < BongoArrayCount(builder->links); i++) {
|
||||
ExtraLink *link = BongoArrayIndex(builder->links, ExtraLink *, i);
|
||||
for (i=0; i < builder->links->len; i++) {
|
||||
ExtraLink *link = g_array_index(builder->links, ExtraLink *, i);
|
||||
BongoStringBuilderAppendF(&b,
|
||||
" INNER JOIN links link_%d ON so.guid=link_%d.%s",
|
||||
i, i, link->join_column);
|
||||
}
|
||||
for (i=0; i < BongoArrayCount(builder->properties); i++) {
|
||||
StorePropInfo *prop = BongoArrayIndex(builder->properties, StorePropInfo *, i);
|
||||
for (i=0; i < builder->properties->len; i++) {
|
||||
StorePropInfo *prop = g_array_index(builder->properties, StorePropInfo *, i);
|
||||
// only add those columns which we want returned.
|
||||
if ((prop->table_name == NULL) && (prop->column == NULL)) {
|
||||
// FIXME. Both following queries should use bound parameters really.
|
||||
@@ -378,7 +378,7 @@ QueryBuilderCreateSQL(QueryBuilder *builder, char **output)
|
||||
}
|
||||
}
|
||||
|
||||
if (builder->int_query || builder->ext_query || (BongoArrayCount(builder->properties) > 0))
|
||||
if (builder->int_query || builder->ext_query || (builder->properties->len > 0))
|
||||
BongoStringBuilderAppend(&b, " WHERE ");
|
||||
|
||||
// add in any constraints specified on the various columns
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define QUERY_BUILDER_H
|
||||
|
||||
#include "query-parser.h"
|
||||
#include <glib.h>
|
||||
|
||||
typedef enum {
|
||||
ORDER_NONE,
|
||||
@@ -41,15 +42,15 @@ typedef struct {
|
||||
BOOL linkin_conversations; // whether or not we want to access conv. data
|
||||
|
||||
// properties we reference in the queries
|
||||
BongoArray *properties; // what their names are
|
||||
GArray *properties; // what their names are
|
||||
|
||||
// links we reference in the queries
|
||||
BongoArray *links; // linked documents to find
|
||||
GArray *links; // linked documents to find
|
||||
|
||||
// internal query - something setup by the Bongo store as part of a command
|
||||
char const *int_query;
|
||||
struct parser_state internal_parser;
|
||||
BongoArray *parameters;
|
||||
GArray *parameters;
|
||||
|
||||
// external query - additional constraints defined by the client
|
||||
char const *ext_query;
|
||||
|
||||
@@ -669,7 +669,8 @@ int
|
||||
CollectionLockPoolInit(StoreClient *client, CollectionLockPool *pool)
|
||||
{
|
||||
pool->client = client;
|
||||
return BongoArrayInit(&pool->colls, sizeof(colldatum), 8);
|
||||
pool->colls = g_array_sized_new(FALSE, FALSE, sizeof(colldatum), 8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -678,13 +679,13 @@ CollectionLockPoolDestroy(CollectionLockPool *pool)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < pool->colls.len; i++) {
|
||||
colldatum coll = BongoArrayIndex(&pool->colls, colldatum, i);
|
||||
for (i = 0; i < pool->colls->len; i++) {
|
||||
colldatum coll = g_array_index(pool->colls, colldatum, i);
|
||||
|
||||
StoreReleaseCollectionLock(pool->client, &coll.lock);
|
||||
}
|
||||
|
||||
BongoArrayDestroy(&pool->colls, TRUE);
|
||||
g_array_free(pool->colls, TRUE);
|
||||
}
|
||||
|
||||
|
||||
@@ -694,8 +695,8 @@ CollectionLockPoolGet(CollectionLockPool *pool, uint64_t guid)
|
||||
colldatum coll;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < pool->colls.len; i++) {
|
||||
colldatum coll = BongoArrayIndex(&pool->colls, colldatum, i);
|
||||
for (i = 0; i < pool->colls->len; i++) {
|
||||
colldatum coll = g_array_index(pool->colls, colldatum, i);
|
||||
|
||||
if (guid == coll.guid) {
|
||||
return coll.lock;
|
||||
@@ -706,7 +707,7 @@ CollectionLockPoolGet(CollectionLockPool *pool, uint64_t guid)
|
||||
return NULL;
|
||||
}
|
||||
coll.guid = guid;
|
||||
BongoArrayAppendValue(&pool->colls, coll);
|
||||
g_array_append_val(pool->colls, coll);
|
||||
return coll.lock;
|
||||
}
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ CCode StoreReleaseCollectionLock(StoreClient *client, NLockStruct **lock);
|
||||
|
||||
typedef struct {
|
||||
StoreClient *client;
|
||||
BongoArray colls;
|
||||
GArray *colls;
|
||||
} CollectionLockPool;
|
||||
|
||||
int CollectionLockPoolInit(StoreClient *client, CollectionLockPool *pool);
|
||||
@@ -349,7 +349,7 @@ void CollectionLockPoolDestroy(CollectionLockPool *pool);
|
||||
NLockStruct *CollectionLockPoolGet(CollectionLockPool *pool, uint64_t coll);
|
||||
|
||||
|
||||
typedef BongoArray WatchEventList;
|
||||
typedef GArray WatchEventList;
|
||||
|
||||
int WatchEventListInit(WatchEventList *events);
|
||||
void WatchEventListDestroy(WatchEventList *events);
|
||||
|
||||
@@ -70,7 +70,7 @@ GetInstallParameters(void){
|
||||
|
||||
/* this is a little messy here due to the way the array works */
|
||||
if (!config.domains) {
|
||||
config.domains = BongoJsonNodeNewArray(BongoArrayNew(sizeof(char *), 1));
|
||||
config.domains = BongoJsonNodeNewArray(g_array_new(FALSE, FALSE, sizeof(char *)));
|
||||
while (1) {
|
||||
char *tmp = NULL;
|
||||
BongoJsonNode *domain;
|
||||
@@ -108,7 +108,7 @@ SetStoreConfigurationModifications(StoreClient *client) {
|
||||
BongoJsonNode *current;
|
||||
char *content;
|
||||
unsigned int x;
|
||||
BongoArray *domains, *oldDomains;
|
||||
GArray *domains, *oldDomains;
|
||||
|
||||
/* node is what is in the store. it should basically be any defaults */
|
||||
/* pull out the domain array so that i can replace it with the new list of domains */
|
||||
@@ -580,7 +580,7 @@ main(int argc, char *argv[]) {
|
||||
} else if (!strcmp(arg, "--domain")) {
|
||||
next_arg++;
|
||||
if (!config.domains) {
|
||||
config.domains = BongoJsonNodeNewArray(BongoArrayNew(sizeof(char *), 1));
|
||||
config.domains = BongoJsonNodeNewArray(g_array_new(FALSE, FALSE, sizeof(char *)));
|
||||
}
|
||||
BongoJsonArrayAppendString(BongoJsonNodeAsArray(config.domains), MemStrdup(argv[next_arg]));
|
||||
} else {
|
||||
|
||||
+11
-11
@@ -51,7 +51,7 @@ typedef struct {
|
||||
BOOL crashy;
|
||||
} BongoAgent;
|
||||
|
||||
static BongoArray *AllAgents;
|
||||
static GArray *AllAgents;
|
||||
static pid_t LeaderPID = 0;
|
||||
static pid_t SlapdPID = 0;
|
||||
static BOOL Exiting = FALSE;
|
||||
@@ -65,7 +65,7 @@ FindAgentByPid(pid_t pid)
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < AllAgents->len; i++) {
|
||||
BongoAgent *agent = &BongoArrayIndex(AllAgents, BongoAgent, i);
|
||||
BongoAgent *agent = &g_array_index(AllAgents, BongoAgent, i);
|
||||
if (agent->pid == pid) {
|
||||
return agent;
|
||||
}
|
||||
@@ -77,13 +77,13 @@ FindAgentByPid(pid_t pid)
|
||||
static BOOL
|
||||
SetupAgentList(void)
|
||||
{
|
||||
AllAgents = BongoArrayNew(sizeof(BongoAgent), 1);
|
||||
AllAgents = g_array_new(FALSE, FALSE, sizeof(BongoAgent));
|
||||
|
||||
BongoAgent store = {{0,} };
|
||||
store.spec.program = "bongostore";
|
||||
store.spec.priority = 0;
|
||||
store.enabled = TRUE;
|
||||
BongoArrayAppendValue(AllAgents, store);
|
||||
g_array_append_val(AllAgents, store);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ AgentsStillRunning(void)
|
||||
int ret = 0;
|
||||
|
||||
for (i = 0; i < AllAgents->len; i++) {
|
||||
BongoAgent *agent = &BongoArrayIndex(AllAgents, BongoAgent, i);
|
||||
BongoAgent *agent = &g_array_index(AllAgents, BongoAgent, i);
|
||||
if (agent->pid != 0) {
|
||||
ret++;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ BlameAgents(void)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < AllAgents->len; i++) {
|
||||
BongoAgent *agent = &BongoArrayIndex(AllAgents, BongoAgent, i);
|
||||
BongoAgent *agent = &g_array_index(AllAgents, BongoAgent, i);
|
||||
if (agent->pid != 0) {
|
||||
fprintf(stderr, "%s ", agent->spec.program);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ WaitingForCallbacks(void)
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < AllAgents->len; i++) {
|
||||
BongoAgent *agent = &BongoArrayIndex(AllAgents, BongoAgent, i);
|
||||
BongoAgent *agent = &g_array_index(AllAgents, BongoAgent, i);
|
||||
if (agent->waitingForCallback) {
|
||||
return TRUE;
|
||||
}
|
||||
@@ -237,7 +237,7 @@ ResetCrashiness(void)
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < AllAgents->len; i++) {
|
||||
BongoAgent *agent = &BongoArrayIndex(AllAgents, BongoAgent, i);
|
||||
BongoAgent *agent = &g_array_index(AllAgents, BongoAgent, i);
|
||||
agent->crashy = FALSE;
|
||||
agent->lastCrash = 0;
|
||||
agent->numCrashes = 0;
|
||||
@@ -283,7 +283,7 @@ StartAgentsWithPriority(int priority, BOOL onlyCrashed, BOOL printMessage)
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < AllAgents->len; i++) {
|
||||
BongoAgent *agent = &BongoArrayIndex(AllAgents, BongoAgent, i);
|
||||
BongoAgent *agent = &g_array_index(AllAgents, BongoAgent, i);
|
||||
if (agent->enabled
|
||||
&& agent->spec.priority == priority
|
||||
&& agent->pid == 0
|
||||
@@ -306,7 +306,7 @@ LoadAgentConfiguration()
|
||||
BOOL retcode = FALSE;
|
||||
BongoJsonNode *node;
|
||||
BongoJsonResult res;
|
||||
BongoArray *agentlist;
|
||||
GArray *agentlist;
|
||||
unsigned int i;
|
||||
|
||||
if (! NMAPReadConfigFile("manager", &config) || (config == NULL)) {
|
||||
@@ -332,7 +332,7 @@ LoadAgentConfiguration()
|
||||
BongoJsonJPathGetInt(anode, "o:pri/i", &agent.spec.priority);
|
||||
BongoJsonJPathGetString(anode, "o:name/s", &agent.spec.program);
|
||||
|
||||
BongoArrayAppendValue(AllAgents, agent);
|
||||
g_array_append_val(AllAgents, agent);
|
||||
HighestPriority = max(HighestPriority, agent.spec.priority);
|
||||
}
|
||||
retcode = TRUE;
|
||||
|
||||
+10
-186
@@ -1,171 +1,18 @@
|
||||
/****************************************************************************
|
||||
* <Novell-copyright>
|
||||
* Copyright (c) 2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of version 2 of the GNU General Public License
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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, contact Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail, you
|
||||
* may find current contact information at www.novell.com.
|
||||
* </Novell-copyright>
|
||||
****************************************************************************/
|
||||
|
||||
#include <config.h>
|
||||
#include <xpl.h>
|
||||
#include <glib.h>
|
||||
#include <bongoutil.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
/* TODO: the old function had a char *. should this be more generic somehow? */
|
||||
int
|
||||
BongoArrayInit(BongoArray *array, unsigned int elementSize, unsigned int initialSize)
|
||||
{
|
||||
if (!array) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (initialSize > 0) {
|
||||
array->data = MemMalloc(initialSize * elementSize);
|
||||
if (!array->data) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
array->size = initialSize;
|
||||
array->elemSize = elementSize;
|
||||
array->len = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
BongoArrayDestroy(BongoArray *array, BOOL freeSegment)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
if (!array) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (freeSegment) {
|
||||
MemFree(array->data);
|
||||
ret = NULL;
|
||||
} else {
|
||||
ret = array->data;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
BongoArray *
|
||||
BongoArrayNew(unsigned int elementSize, unsigned int initialSize)
|
||||
{
|
||||
BongoArray *array;
|
||||
|
||||
array = MemNew0(BongoArray, 1);
|
||||
|
||||
if (array) {
|
||||
if (BongoArrayInit(array, elementSize, initialSize)) {
|
||||
MemFree(array);
|
||||
array = NULL;
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
BongoArrayFree(BongoArray *array, BOOL freeSegment)
|
||||
{
|
||||
if (!array) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *ret = BongoArrayDestroy(array, freeSegment);
|
||||
|
||||
MemFree(array);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
BongoArrayExpand(BongoArray *array, unsigned int newLen)
|
||||
{
|
||||
unsigned int newSize;
|
||||
|
||||
if (!array) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (array->size >= newLen) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (array->size == 0) {
|
||||
newSize = 10;
|
||||
} else {
|
||||
newSize = array->size * 2;
|
||||
}
|
||||
|
||||
while (newSize < newLen) {
|
||||
newSize *= 2;
|
||||
}
|
||||
|
||||
array->data = MemRealloc(array->data, newSize * array->elemSize);
|
||||
array->size = newSize;
|
||||
}
|
||||
|
||||
void
|
||||
BongoArrayAppendValues(BongoArray *array, const void *data, unsigned int len)
|
||||
{
|
||||
if (!array) {
|
||||
return;
|
||||
}
|
||||
|
||||
BongoArrayExpand(array, array->len + len);
|
||||
|
||||
memcpy((char*)array->data + (array->elemSize * array->len), data, (array->elemSize * len));
|
||||
|
||||
array->len += len;
|
||||
}
|
||||
|
||||
void
|
||||
BongoArrayRemove(BongoArray *array, unsigned int i)
|
||||
{
|
||||
if (!array) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (i >= array->len) {
|
||||
return;
|
||||
}
|
||||
|
||||
memmove((char *)array->data + (i * array->elemSize),
|
||||
(char*)array->data + ((i + 1) * array->elemSize),
|
||||
(array->elemSize * (array->len - i)));
|
||||
array->len--;
|
||||
}
|
||||
|
||||
int
|
||||
BongoArrayFindUnsorted(BongoArray *array, void *needle, ArrayCompareFunc compare)
|
||||
GArrayFindUnsorted(GArray *array, void *needle, ArrayCompareFunc compare)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (!array) {
|
||||
if (!array || !compare) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < array->len; i++) {
|
||||
if (!compare(needle, (char*)array->data + (i * array->elemSize))) {
|
||||
if (!compare(needle, g_array_index(array, char *, i))) {
|
||||
return (int)i;
|
||||
}
|
||||
}
|
||||
@@ -173,44 +20,21 @@ BongoArrayFindUnsorted(BongoArray *array, void *needle, ArrayCompareFunc compare
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* TODO: the old function had a char *. should this be more generic somehow? */
|
||||
int
|
||||
BongoArrayFindSorted(BongoArray *array, void *needle, ArrayCompareFunc compare)
|
||||
GArrayFindSorted(GArray *array, void *needle, ArrayCompareFunc compare)
|
||||
{
|
||||
void *data;
|
||||
|
||||
if (!array) {
|
||||
if (!array || !compare) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
data = bsearch(needle, array->data, array->len, array->elemSize, compare);
|
||||
data = bsearch(needle, array->data, array->len, sizeof(char *), compare);
|
||||
|
||||
if (data) {
|
||||
return ((char*)data - (char*)array->data) / array->elemSize;
|
||||
return ((char*)data - (char*)array->data) / sizeof(char *);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BongoArraySetLength(BongoArray *array, unsigned int len)
|
||||
{
|
||||
if (!array) {
|
||||
return;
|
||||
}
|
||||
|
||||
BongoArrayExpand(array, len);
|
||||
|
||||
array->len = len;
|
||||
}
|
||||
|
||||
void
|
||||
BongoArraySort(BongoArray *array, ArrayCompareFunc compare)
|
||||
{
|
||||
if (!array) {
|
||||
return;
|
||||
}
|
||||
|
||||
qsort(array->data, array->len, array->elemSize, compare);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ BongoCalInstanceFree(BongoCalInstance *inst, BOOL freeJson)
|
||||
|
||||
#if 0
|
||||
static void
|
||||
FreeInstanceArray(BongoArray *instances, BOOL freeJson)
|
||||
FreeInstanceArray(GArray *instances, BOOL freeJson)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@@ -99,10 +99,10 @@ FreeInstanceArray(BongoArray *instances, BOOL freeJson)
|
||||
}
|
||||
|
||||
for (i = 0; i < instances->len; i++) {
|
||||
BongoCalInstanceFree(BongoArrayIndex(instances, BongoCalInstance*, i), freeJson);
|
||||
BongoCalInstanceFree(g_array_index(instances, BongoCalInstance*, i), freeJson);
|
||||
}
|
||||
|
||||
BongoArrayFree(instances, TRUE);
|
||||
g_array_free(instances, TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -293,7 +293,7 @@ GetWeekday(const char *name)
|
||||
}
|
||||
|
||||
static BongoList *
|
||||
IntArrayToList(BongoArray *array, int min, int max)
|
||||
IntArrayToList(GArray *array, int min, int max)
|
||||
{
|
||||
BongoList *ret = NULL;
|
||||
unsigned int i;
|
||||
@@ -311,7 +311,7 @@ IntArrayToList(BongoArray *array, int min, int max)
|
||||
}
|
||||
|
||||
static BongoList *
|
||||
DayArrayToList(BongoArray *array)
|
||||
DayArrayToList(GArray *array)
|
||||
{
|
||||
BongoList *ret = NULL;
|
||||
unsigned int i;
|
||||
@@ -339,7 +339,7 @@ DayArrayToList(BongoArray *array)
|
||||
static BOOL
|
||||
ReadRecur(BongoCalInstance *inst, BongoJsonObject *obj, BongoCalRule *recur)
|
||||
{
|
||||
BongoArray *arrayVal;
|
||||
GArray *arrayVal;
|
||||
const char *stringVal;
|
||||
int intVal;
|
||||
BongoJsonObject *jsonValue;
|
||||
@@ -573,7 +573,7 @@ CacheUtcOffset(BongoCalInstance *inst, const char *id, BOOL *haveCache, int *cac
|
||||
static void
|
||||
CacheRDates(BongoCalInstance *inst, const char *key, BongoSList **dates)
|
||||
{
|
||||
BongoArray *array;
|
||||
GArray *array;
|
||||
unsigned int i;
|
||||
|
||||
if (*dates) {
|
||||
@@ -616,7 +616,7 @@ CacheRDates(BongoCalInstance *inst, const char *key, BongoSList **dates)
|
||||
static void
|
||||
CacheRRules(BongoCalInstance *inst, const char *key, BongoSList **rules)
|
||||
{
|
||||
BongoArray *array;
|
||||
GArray *array;
|
||||
unsigned int i;
|
||||
|
||||
if (*rules) {
|
||||
@@ -969,22 +969,22 @@ BongoCalInstanceGetInstance(BongoCalInstance *inst,
|
||||
inst->exceptionsSorted = TRUE;
|
||||
}
|
||||
|
||||
i = BongoArrayFindSorted(inst->exceptions, &recurid, FindRecurId);
|
||||
i = GArrayFindSorted(inst->exceptions, &recurid, FindRecurId);
|
||||
if (i != -1) {
|
||||
*instOut = BongoArrayIndex(inst->exceptions, BongoCalInstance *, i);
|
||||
*instOut = g_array_index(inst->exceptions, BongoCalInstance *, i);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (inst->generated && allowGenerated) {
|
||||
if (!inst->generatedSorted) {
|
||||
BongoArraySort(inst->generated, CompareRecurId);
|
||||
g_array_sort(inst->generated, CompareRecurId);
|
||||
inst->generatedSorted = TRUE;
|
||||
}
|
||||
|
||||
i = BongoArrayFindSorted(inst->generated, &recurid, FindRecurId);
|
||||
i = GArrayFindSorted(inst->generated, &recurid, FindRecurId);
|
||||
if (i != -1) {
|
||||
*instOut = BongoArrayIndex(inst->generated, BongoCalInstance *, i);
|
||||
*instOut = g_array_index(inst->generated, BongoCalInstance *, i);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -998,12 +998,12 @@ AddGeneratedInstance(BongoCalInstance *inst,
|
||||
BongoCalInstance *child,
|
||||
BOOL isGenerated)
|
||||
{
|
||||
BongoArray *array;
|
||||
GArray *array;
|
||||
|
||||
/* Requires "generated" to be created first */
|
||||
|
||||
if (BongoJsonObjectGetArray(inst->json, "generated", &array) != BONGO_JSON_OK) {
|
||||
array = BongoArrayNew(sizeof(BongoJsonNode*), 15);
|
||||
array = g_array_sized_new(FALSE, FALSE, sizeof(BongoJsonNode *), 15);
|
||||
BongoJsonObjectPutArray(inst->json, "generated", array);
|
||||
}
|
||||
|
||||
@@ -1011,10 +1011,10 @@ AddGeneratedInstance(BongoCalInstance *inst,
|
||||
BongoJsonArrayAppendObject(array, child->json);
|
||||
|
||||
if (!inst->generated) {
|
||||
inst->generated = BongoArrayNew(sizeof(BongoCalInstance*), 16);
|
||||
inst->generated = g_array_sized_new(FALSE, FALSE, sizeof(BongoCalInstance *), 16);
|
||||
}
|
||||
|
||||
BongoArrayAppendValue(inst->generated, child);
|
||||
g_array_append_val(inst->generated, child);
|
||||
inst->generatedSorted = FALSE;
|
||||
}
|
||||
}
|
||||
@@ -1061,9 +1061,9 @@ CompareOccs(const void *voida, const void *voidb)
|
||||
}
|
||||
|
||||
void
|
||||
BongoCalOccurrencesSort(BongoArray *occurrences)
|
||||
BongoCalOccurrencesSort(GArray *occurrences)
|
||||
{
|
||||
BongoArraySort(occurrences, CompareOccs);
|
||||
g_array_sort(occurrences, CompareOccs);
|
||||
}
|
||||
|
||||
BongoJsonObject *
|
||||
@@ -1119,18 +1119,18 @@ BongoCalOccurrenceToJson(BongoCalOccurrence occ, BongoCalTimezone *tz)
|
||||
return obj;
|
||||
}
|
||||
|
||||
BongoArray *
|
||||
BongoCalOccurrencesToJson(BongoArray *occs, BongoCalTimezone *tz)
|
||||
GArray *
|
||||
BongoCalOccurrencesToJson(GArray *occs, BongoCalTimezone *tz)
|
||||
{
|
||||
BongoArray *jsonArray;
|
||||
GArray *jsonArray;
|
||||
unsigned int i;
|
||||
|
||||
jsonArray = BongoArrayNew(sizeof(BongoJsonNode *), 16);
|
||||
jsonArray = g_array_sized_new(FALSE, FALSE, sizeof(BongoJsonNode *), 16);
|
||||
|
||||
for (i = 0; i < occs->len; i++) {
|
||||
BongoJsonObject *obj;
|
||||
|
||||
obj = BongoCalOccurrenceToJson(BongoArrayIndex(occs, BongoCalOccurrence, i), tz);
|
||||
obj = BongoCalOccurrenceToJson(g_array_index(occs, BongoCalOccurrence, i), tz);
|
||||
|
||||
if (obj) {
|
||||
BongoJsonArrayAppendObject(jsonArray, obj);
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
BongoCalObject *cal;
|
||||
BongoArray *occs;
|
||||
GArray *occs;
|
||||
} CollectData;
|
||||
|
||||
static MethodName methodNames[] = {
|
||||
@@ -104,7 +104,7 @@ FindInstanceById(const void *voida, const void *voidb)
|
||||
static void
|
||||
FindInstances(BongoCalObject *cal)
|
||||
{
|
||||
BongoArray *components;
|
||||
GArray *components;
|
||||
unsigned int i;
|
||||
|
||||
if (BongoJsonObjectGetArray(cal->json, "components", &components) != BONGO_JSON_OK) {
|
||||
@@ -126,12 +126,12 @@ FindInstances(BongoCalObject *cal)
|
||||
BongoHashtablePut(cal->timezones, (char*)BongoCalTimezoneGetTzid(tz), tz);
|
||||
} else {
|
||||
BongoCalInstance *inst = BongoCalInstanceNew(cal, object);
|
||||
BongoArrayAppendValue(cal->instances, inst);
|
||||
g_array_append_val(cal->instances, inst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BongoArraySort(cal->instances, CompareInstancesId);
|
||||
g_array_sort(cal->instances, CompareInstancesId);
|
||||
cal->instancesSorted = TRUE;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ NewCalJson(void)
|
||||
BongoJsonObject *json;
|
||||
|
||||
json = BongoJsonObjectNew();
|
||||
BongoArray *array = BongoArrayNew(sizeof(BongoJsonNode*), 1);
|
||||
GArray *array = g_array_new(FALSE, FALSE, sizeof(BongoJsonNode *));
|
||||
|
||||
if (json && array &&
|
||||
AddValueObject(json, "version", "2.0") &&
|
||||
@@ -179,7 +179,7 @@ NewCalJson(void)
|
||||
return json;
|
||||
} else {
|
||||
if (array) {
|
||||
BongoArrayFree(array, TRUE);
|
||||
g_array_free(array, TRUE);
|
||||
}
|
||||
|
||||
if (json) {
|
||||
@@ -203,7 +203,7 @@ BongoCalObjectNew(BongoJsonObject *json)
|
||||
|
||||
cal->json = json;
|
||||
|
||||
cal->instances = BongoArrayNew(sizeof(BongoCalInstance *), 10);
|
||||
cal->instances = g_array_sized_new(FALSE, FALSE, sizeof(BongoCalInstance *), 10);
|
||||
cal->timezones = BongoHashtableCreateFull(15,
|
||||
(HashFunction)BongoStringHash,
|
||||
(CompareFunction)strcmp,
|
||||
@@ -297,10 +297,10 @@ BongoCalObjectFree(BongoCalObject *cal, BOOL freeJson)
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < cal->instances->len; i++) {
|
||||
BongoCalInstanceFree(BongoArrayIndex(cal->instances, BongoCalInstance *, i), FALSE);
|
||||
BongoCalInstanceFree(g_array_index(cal->instances, BongoCalInstance *, i), FALSE);
|
||||
}
|
||||
|
||||
BongoArrayFree(cal->instances, TRUE);
|
||||
g_array_free(cal->instances, TRUE);
|
||||
|
||||
if (freeJson) {
|
||||
BongoJsonObjectFree(cal->json);
|
||||
@@ -379,7 +379,7 @@ BongoCalObjectGetUid(BongoCalObject *cal)
|
||||
{
|
||||
|
||||
if (cal->instances->len > 0) {
|
||||
return BongoCalInstanceGetUid(BongoArrayIndex(cal->instances, BongoCalInstance *, 0));
|
||||
return BongoCalInstanceGetUid(g_array_index(cal->instances, BongoCalInstance *, 0));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -389,7 +389,7 @@ BongoCalObjectGetStamp(BongoCalObject *cal)
|
||||
{
|
||||
|
||||
if (cal->instances->len > 0) {
|
||||
return BongoCalInstanceGetStamp(BongoArrayIndex(cal->instances, BongoCalInstance *, 0));
|
||||
return BongoCalInstanceGetStamp(g_array_index(cal->instances, BongoCalInstance *, 0));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -404,7 +404,7 @@ BongoCalObjectGetStart(BongoCalObject *cal)
|
||||
start = BongoCalTimeEmpty();
|
||||
|
||||
for (i = 0; i < cal->instances->len; i++) {
|
||||
BongoCalInstance *inst = BongoArrayIndex(cal->instances, BongoCalInstance *, i);
|
||||
BongoCalInstance *inst = g_array_index(cal->instances, BongoCalInstance *, i);
|
||||
BongoCalTime instStart;
|
||||
|
||||
instStart = BongoCalInstanceGetStart(inst);
|
||||
@@ -428,7 +428,7 @@ BongoCalObjectGetEnd(BongoCalObject *cal)
|
||||
end = BongoCalTimeEmpty();
|
||||
|
||||
for (i = 0; i < cal->instances->len; i++) {
|
||||
BongoCalInstance *inst = BongoArrayIndex(cal->instances, BongoCalInstance *, i);
|
||||
BongoCalInstance *inst = g_array_index(cal->instances, BongoCalInstance *, i);
|
||||
BongoCalTime instEnd;
|
||||
char buffer[1024];
|
||||
|
||||
@@ -452,7 +452,7 @@ BongoCalObjectGetSummary(BongoCalObject *cal)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return BongoCalInstanceGetSummary(BongoArrayIndex(cal->instances, BongoCalInstance *, 0));
|
||||
return BongoCalInstanceGetSummary(g_array_index(cal->instances, BongoCalInstance *, 0));
|
||||
}
|
||||
|
||||
const char *
|
||||
@@ -462,7 +462,7 @@ BongoCalObjectGetLocation(BongoCalObject *cal)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return BongoCalInstanceGetLocation(BongoArrayIndex(cal->instances, BongoCalInstance *, 0));
|
||||
return BongoCalInstanceGetLocation(g_array_index(cal->instances, BongoCalInstance *, 0));
|
||||
}
|
||||
|
||||
const char *
|
||||
@@ -472,7 +472,7 @@ BongoCalObjectGetDescription(BongoCalObject *cal)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return BongoCalInstanceGetDescription(BongoArrayIndex(cal->instances, BongoCalInstance *, 0));
|
||||
return BongoCalInstanceGetDescription(g_array_index(cal->instances, BongoCalInstance *, 0));
|
||||
}
|
||||
|
||||
BongoCalTimezone *
|
||||
@@ -497,7 +497,7 @@ BongoCalObjectGetTimezones(BongoCalObject *cal)
|
||||
}
|
||||
|
||||
static void
|
||||
AddTimezone(BongoCalObject *cal, BongoArray *components, BongoCalTime t)
|
||||
AddTimezone(BongoCalObject *cal, GArray *components, BongoCalTime t)
|
||||
{
|
||||
if (t.tz && t.tz->type == BONGO_CAL_TIMEZONE_SYSTEM) {
|
||||
BongoCalTimezone *newTz;
|
||||
@@ -511,7 +511,7 @@ AddTimezone(BongoCalObject *cal, BongoArray *components, BongoCalTime t)
|
||||
}
|
||||
|
||||
static void
|
||||
AddTimezones(BongoCalObject *cal, BongoArray *components, BongoCalInstance *inst)
|
||||
AddTimezones(BongoCalObject *cal, GArray *components, BongoCalInstance *inst)
|
||||
{
|
||||
AddTimezone(cal, components, BongoCalInstanceGetStart(inst));
|
||||
AddTimezone(cal, components, BongoCalInstanceGetEnd(inst));
|
||||
@@ -522,14 +522,14 @@ void
|
||||
BongoCalObjectResolveSystemTimezones(BongoCalObject *cal)
|
||||
{
|
||||
unsigned int i;
|
||||
BongoArray *components;
|
||||
GArray *components;
|
||||
|
||||
if (BongoJsonObjectGetArray(cal->json, "components", &components) != BONGO_JSON_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < cal->instances->len; i++) {
|
||||
BongoCalInstance *inst = BongoArrayIndex(cal->instances, BongoCalInstance *, i);
|
||||
BongoCalInstance *inst = g_array_index(cal->instances, BongoCalInstance *, i);
|
||||
|
||||
AddTimezones(cal, components, inst);
|
||||
}
|
||||
@@ -541,7 +541,7 @@ BongoCalObjectStripSystemTimezones(BongoCalObject *cal)
|
||||
BongoHashtableIter iter;
|
||||
BongoSList *remove = NULL;
|
||||
BongoSList *l;
|
||||
BongoArray *components;
|
||||
GArray *components;
|
||||
|
||||
if (BongoJsonObjectGetArray(cal->json, "components", &components) != BONGO_JSON_OK) {
|
||||
return;
|
||||
@@ -588,16 +588,16 @@ BongoCalObjectGetInstance(BongoCalObject *cal, const char *uid, BongoCalTime rec
|
||||
IdSearchData data;
|
||||
|
||||
if (!cal->instancesSorted) {
|
||||
BongoArraySort(cal->instances, CompareInstancesId);
|
||||
g_array_sort(cal->instances, CompareInstancesId);
|
||||
cal->instancesSorted = TRUE;
|
||||
}
|
||||
|
||||
data.uid = uid;
|
||||
data.recurid = recurid;
|
||||
|
||||
i = BongoArrayFindSorted(cal->instances, &data, FindInstanceById);
|
||||
i = GArrayFindSorted(cal->instances, &data, FindInstanceById);
|
||||
if (i != -1) {
|
||||
return BongoArrayIndex(cal->instances, BongoCalInstance *, i);
|
||||
return g_array_index(cal->instances, BongoCalInstance *, i);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -636,7 +636,7 @@ ExpandCb(BongoCalInstance *inst,
|
||||
occ.generated = TRUE;
|
||||
occ.instance = inst;
|
||||
|
||||
BongoArrayAppendValue(data->occs, occ);
|
||||
g_array_append_val(data->occs, occ);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -660,7 +660,7 @@ BongoCalObjectPrimaryOccurrence(BongoCalObject *cal,
|
||||
multiple occurrances there. */
|
||||
BongoCalInstance *instance;
|
||||
|
||||
instance = BongoArrayIndex(cal->instances, BongoCalInstance *, 0);
|
||||
instance = g_array_index(cal->instances, BongoCalInstance *, 0);
|
||||
|
||||
return BongoCalInstanceGetOccurrence(instance);
|
||||
} else {
|
||||
@@ -679,7 +679,7 @@ BongoCalObjectCollect(BongoCalObject *cal,
|
||||
BongoCalTime end,
|
||||
BongoCalTimezone *defaultTz,
|
||||
BOOL includeGenerated,
|
||||
BongoArray *occurrences)
|
||||
GArray *occurrences)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int lenBefore;
|
||||
@@ -691,7 +691,7 @@ BongoCalObjectCollect(BongoCalObject *cal,
|
||||
BongoCalInstance *instance;
|
||||
CollectData data;
|
||||
|
||||
instance = BongoArrayIndex(cal->instances, BongoCalInstance *, i);
|
||||
instance = g_array_index(cal->instances, BongoCalInstance *, i);
|
||||
|
||||
add = TRUE;
|
||||
|
||||
@@ -720,14 +720,14 @@ BongoCalObjectCollect(BongoCalObject *cal,
|
||||
|
||||
occ = BongoCalInstanceGetOccurrence(instance);
|
||||
|
||||
BongoArrayAppendValue(occurrences, occ);
|
||||
g_array_append_val(occurrences, occ);
|
||||
}
|
||||
}
|
||||
|
||||
return (occurrences->len > lenBefore);
|
||||
}
|
||||
|
||||
BongoArray *
|
||||
GArray *
|
||||
BongoCalObjectGetInstances(BongoCalObject *cal)
|
||||
{
|
||||
return cal->instances;
|
||||
@@ -745,7 +745,7 @@ BongoCalObjectGetSingleInstance(BongoCalObject *cal)
|
||||
{
|
||||
/* FIXME: wrong */
|
||||
if (cal->instances->len == 1) {
|
||||
return BongoArrayIndex(cal->instances, BongoCalInstance *, 0);
|
||||
return g_array_index(cal->instances, BongoCalInstance *, 0);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
@@ -760,7 +760,7 @@ BongoCalObjectLocalizeTimes(BongoCalObject *cal,
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < cal->instances->len; i++) {
|
||||
BongoCalInstance *inst = BongoArrayIndex(cal->instances, BongoCalInstance *, i);
|
||||
BongoCalInstance *inst = g_array_index(cal->instances, BongoCalInstance *, i);
|
||||
BongoCalInstanceLocalizeTimes(inst, tz, attribute);
|
||||
}
|
||||
}
|
||||
@@ -770,10 +770,10 @@ BOOL
|
||||
BongoCalObjectAddInstance(BongoCalObject *cal,
|
||||
BongoCalInstance *inst)
|
||||
{
|
||||
BongoArray *components;
|
||||
GArray *components;
|
||||
|
||||
if (BongoJsonObjectGetArray(cal->json, "components", &components) != BONGO_JSON_OK) {
|
||||
components = BongoArrayNew(sizeof(BongoJsonNode*), 1);
|
||||
components = g_array_new(FALSE, FALSE, sizeof(BongoJsonNode *));
|
||||
if (BongoJsonObjectPutArray(cal->json, "components", components) != BONGO_JSON_OK) {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -781,7 +781,7 @@ BongoCalObjectAddInstance(BongoCalObject *cal,
|
||||
|
||||
inst->cal = cal;
|
||||
BongoJsonArrayAppendObject(components, inst->json);
|
||||
BongoArrayAppendValue(cal->instances, inst);
|
||||
g_array_append_val(cal->instances, inst);
|
||||
|
||||
cal->instancesSorted = FALSE;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
struct _BongoCalObject {
|
||||
BongoJsonObject *json;
|
||||
|
||||
BongoArray *instances;
|
||||
GArray *instances;
|
||||
BOOL instancesSorted;
|
||||
BongoHashtable *timezones;
|
||||
|
||||
@@ -88,7 +88,7 @@ struct _BongoCalTimezone {
|
||||
int offset;
|
||||
|
||||
/* System and json-backed timezones */
|
||||
BongoArray *changes;
|
||||
GArray *changes;
|
||||
|
||||
/* Json-backed timezones */
|
||||
BongoCalObject *cal;
|
||||
|
||||
+258
-260
File diff suppressed because it is too large
Load Diff
@@ -97,7 +97,7 @@ BongoCalTimezoneNewJsonForSystem(BongoCalObject *cal, const char *tzid)
|
||||
FILE *tzfile;
|
||||
BongoJsonNode *tzNode;
|
||||
BongoJsonObject *tzObj;
|
||||
BongoArray *components;
|
||||
GArray *components;
|
||||
|
||||
if (!tzid || strncmp(tzid, "/bongo/", strlen("/bongo/")) != 0) {
|
||||
return NULL;
|
||||
@@ -174,7 +174,7 @@ BongoCalTimezoneFree(BongoCalTimezone *tz, BOOL freeJson)
|
||||
}
|
||||
|
||||
if (tz->changes) {
|
||||
BongoArrayFree(tz->changes, TRUE);
|
||||
g_array_free(tz->changes, TRUE);
|
||||
}
|
||||
|
||||
MemFree(tz);
|
||||
@@ -322,7 +322,7 @@ AddOccurrence(BongoCalTimezone *tz,
|
||||
change.second = occ.start.second;
|
||||
|
||||
change = AdjustChange(change, 0, 0, 0, change.prevUtcOffset);
|
||||
BongoArrayAppendValue(tz->changes, change);
|
||||
g_array_append_val(tz->changes, change);
|
||||
|
||||
if (updateBounds) {
|
||||
uint64_t startTime = BongoCalTimeAsUint64(occ.start);
|
||||
@@ -339,17 +339,17 @@ AddOccurrence(BongoCalTimezone *tz,
|
||||
static void
|
||||
ReadChanges(BongoCalTimezone *tz)
|
||||
{
|
||||
BongoArray *changes;
|
||||
GArray *changes;
|
||||
|
||||
if (tz->type != BONGO_CAL_TIMEZONE_JSON) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tz->changes) {
|
||||
BongoArrayFree(tz->changes, TRUE);
|
||||
g_array_free(tz->changes, TRUE);
|
||||
}
|
||||
|
||||
tz->changes = BongoArrayNew(sizeof(TimezoneChange), 32);
|
||||
tz->changes = g_array_sized_new(FALSE, FALSE, sizeof(TimezoneChange), 32);
|
||||
|
||||
if (BongoJsonObjectGetArray(tz->json, "changes", &changes) == BONGO_JSON_OK) {
|
||||
unsigned int i;
|
||||
@@ -367,7 +367,7 @@ ReadChanges(BongoCalTimezone *tz)
|
||||
}
|
||||
}
|
||||
|
||||
BongoArraySort(tz->changes, CompareChange);
|
||||
g_array_sort(tz->changes, CompareChange);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
@@ -402,7 +402,7 @@ TimezoneCb(const char *tzid, void *data)
|
||||
void
|
||||
BongoCalTimezoneExpand(BongoCalTimezone *tz, BongoCalTime start, BongoCalTime end)
|
||||
{
|
||||
BongoArray *changes;
|
||||
GArray *changes;
|
||||
uint64_t startt;
|
||||
uint64_t endt;
|
||||
|
||||
@@ -418,10 +418,10 @@ BongoCalTimezoneExpand(BongoCalTimezone *tz, BongoCalTime start, BongoCalTime en
|
||||
}
|
||||
|
||||
if (tz->changes) {
|
||||
BongoArrayFree(tz->changes, TRUE);
|
||||
g_array_free(tz->changes, TRUE);
|
||||
}
|
||||
|
||||
tz->changes = BongoArrayNew(sizeof(TimezoneChange), 32);
|
||||
tz->changes = g_array_sized_new(FALSE, FALSE, sizeof(TimezoneChange), 32);
|
||||
|
||||
if (BongoJsonObjectGetArray(tz->json, "changes", &changes) == BONGO_JSON_OK) {
|
||||
unsigned int i;
|
||||
@@ -450,7 +450,7 @@ BongoCalTimezoneExpand(BongoCalTimezone *tz, BongoCalTime start, BongoCalTime en
|
||||
}
|
||||
}
|
||||
|
||||
BongoArraySort(tz->changes, CompareChange);
|
||||
g_array_sort(tz->changes, CompareChange);
|
||||
|
||||
tz->changesStart = startt;
|
||||
tz->changesEnd = endt;
|
||||
@@ -483,7 +483,7 @@ FindNearbyChange(BongoCalTimezone *tz, TimezoneChange *change)
|
||||
while (lower < upper) {
|
||||
middle = (lower + upper) / 2;
|
||||
|
||||
zoneChange = &BongoArrayIndex(tz->changes, TimezoneChange, middle);
|
||||
zoneChange = &g_array_index(tz->changes, TimezoneChange, middle);
|
||||
|
||||
cmp = CompareChange(change, zoneChange);
|
||||
|
||||
@@ -541,7 +541,7 @@ BongoCalTimezoneGetUtcOffset(BongoCalTimezone *tz,
|
||||
assert((unsigned int)changeNum < tz->changes->len);
|
||||
|
||||
/* Now move backwards or forwards to find the tz change that applies */
|
||||
zoneChange = &BongoArrayIndex(tz->changes, TimezoneChange, changeNum);
|
||||
zoneChange = &g_array_index(tz->changes, TimezoneChange, changeNum);
|
||||
|
||||
step = 1;
|
||||
changeNumToUse = -1;
|
||||
@@ -599,7 +599,7 @@ BongoCalTimezoneGetUtcOffset(BongoCalTimezone *tz,
|
||||
break;
|
||||
}
|
||||
|
||||
zoneChange = &BongoArrayIndex(tz->changes, TimezoneChange, changeNum);
|
||||
zoneChange = &g_array_index(tz->changes, TimezoneChange, changeNum);
|
||||
}
|
||||
|
||||
/* If we didn't find a change to use, then we have a bug! */
|
||||
@@ -607,7 +607,7 @@ BongoCalTimezoneGetUtcOffset(BongoCalTimezone *tz,
|
||||
|
||||
/* Now we just need to check if the time is in the overlapped region of
|
||||
time when clocks go back. */
|
||||
zoneChange = &BongoArrayIndex(tz->changes, TimezoneChange, changeNumToUse);
|
||||
zoneChange = &g_array_index(tz->changes, TimezoneChange, changeNumToUse);
|
||||
|
||||
utcOffsetChange = zoneChange->utcOffset - zoneChange->prevUtcOffset;
|
||||
if (utcOffsetChange < 0 && changeNumToUse > 0) {
|
||||
@@ -619,7 +619,7 @@ BongoCalTimezoneGetUtcOffset(BongoCalTimezone *tz,
|
||||
either the current zone_change or the previous one. If the
|
||||
time has the is_daylight field set we use the matching change,
|
||||
else we use the change with standard time. */
|
||||
prevZoneChange = &BongoArrayIndex(tz->changes, TimezoneChange, changeNumToUse - 1);
|
||||
prevZoneChange = &g_array_index(tz->changes, TimezoneChange, changeNumToUse - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -679,16 +679,18 @@ UnpackString(FILE *from, char **str)
|
||||
}
|
||||
|
||||
static BOOL
|
||||
PackArray(FILE *to, BongoArray *array)
|
||||
PackArray(FILE *to, GArray *array)
|
||||
{
|
||||
int elemSize = (sizeof(array->data) / array->len);
|
||||
|
||||
if (fwrite(&array->len, sizeof(unsigned int), 1, to) != 1) {
|
||||
return FALSE;
|
||||
}
|
||||
if (fwrite(&array->elemSize, sizeof(unsigned int), 1, to) != 1) {
|
||||
if (fwrite(&elemSize, sizeof(unsigned int), 1, to) != 1) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (fwrite(array->data, array->elemSize, array->len, to) != array->len) {
|
||||
if (fwrite(array->data, elemSize, array->len, to) != array->len) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -696,7 +698,7 @@ PackArray(FILE *to, BongoArray *array)
|
||||
}
|
||||
|
||||
static BOOL
|
||||
UnpackArray(FILE *from, BongoArray **array, unsigned int expectedElemSize)
|
||||
UnpackArray(FILE *from, GArray **array, unsigned int expectedElemSize)
|
||||
{
|
||||
unsigned int len;
|
||||
unsigned int elemSize;
|
||||
@@ -721,10 +723,8 @@ UnpackArray(FILE *from, BongoArray **array, unsigned int expectedElemSize)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*array = MemMalloc(sizeof(BongoArray));
|
||||
(*array)->len = (*array)->size = len;
|
||||
(*array)->elemSize = elemSize;
|
||||
(*array)->data = data;
|
||||
*array = g_array_new(FALSE, FALSE, elemSize);
|
||||
g_array_append_vals(*array, data, len);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -765,7 +765,7 @@ BongoCalTimezoneUnpack(FILE *from)
|
||||
char *tzid;
|
||||
uint64_t changesStart;
|
||||
uint64_t changesEnd;
|
||||
BongoArray *changes;
|
||||
GArray *changes;
|
||||
|
||||
if (fgetc(from) != PACK_MAGIC) {
|
||||
return NULL;
|
||||
|
||||
+31
-31
@@ -675,14 +675,14 @@ JsonRecurPropertyToIcalInt(char *key, BongoJsonNode *value, BongoStringBuilder *
|
||||
static void
|
||||
IcalRecurPropertyToJsonKeywordArray(char *key, char *value, BongoJsonObject *obj)
|
||||
{
|
||||
BongoArray *array;
|
||||
GArray *array;
|
||||
char *dup;
|
||||
char *split[100];
|
||||
int n;
|
||||
int i;
|
||||
|
||||
dup = MemStrdup(value);
|
||||
array = BongoArrayNew(sizeof(BongoJsonNode*), 10);
|
||||
array = g_array_sized_new(FALSE, FALSE, sizeof(BongoJsonNode*), 10);
|
||||
|
||||
do {
|
||||
n = BongoStringSplit(value, ',', split, 100);
|
||||
@@ -700,7 +700,7 @@ IcalRecurPropertyToJsonKeywordArray(char *key, char *value, BongoJsonObject *obj
|
||||
static void
|
||||
JsonRecurPropertyToIcalKeywordArray(char *key, BongoJsonNode *value, BongoStringBuilder *sb)
|
||||
{
|
||||
BongoArray *array;
|
||||
GArray *array;
|
||||
char *dup;
|
||||
BOOL first = TRUE;
|
||||
|
||||
@@ -729,14 +729,14 @@ JsonRecurPropertyToIcalKeywordArray(char *key, BongoJsonNode *value, BongoString
|
||||
static void
|
||||
IcalRecurPropertyToJsonIntArray(char *key, char *value, BongoJsonObject *obj)
|
||||
{
|
||||
BongoArray *array;
|
||||
GArray *array;
|
||||
char *dup;
|
||||
char *split[100];
|
||||
int n;
|
||||
int i;
|
||||
|
||||
dup = MemStrdup(value);
|
||||
array = BongoArrayNew(sizeof(BongoJsonNode*), 10);
|
||||
array = g_array_sized_new(FALSE, FALSE, sizeof(BongoJsonNode*), 10);
|
||||
|
||||
do {
|
||||
n = BongoStringSplit(value, ',', split, 100);
|
||||
@@ -753,7 +753,7 @@ IcalRecurPropertyToJsonIntArray(char *key, char *value, BongoJsonObject *obj)
|
||||
static void
|
||||
JsonRecurPropertyToIcalIntArray(char *key, BongoJsonNode *value, BongoStringBuilder *sb)
|
||||
{
|
||||
BongoArray *array;
|
||||
GArray *array;
|
||||
BOOL first = TRUE;
|
||||
|
||||
array = BongoJsonNodeAsArray(value);
|
||||
@@ -1063,7 +1063,7 @@ FindComponentTypeForIcal(icalcomponent *comp)
|
||||
static ComponentType *
|
||||
FindComponentTypeForJson(BongoJsonObject *obj)
|
||||
{
|
||||
BongoArray *children;
|
||||
GArray *children;
|
||||
|
||||
/* A toplevel/vcalendar json component will have a "components" child */
|
||||
if (BongoJsonObjectGetArray(obj, "components", &children) == BONGO_JSON_OK) {
|
||||
@@ -1099,13 +1099,13 @@ AddIcalSinglePropertyToJson(BongoJsonObject *obj, const char *name, icalproperty
|
||||
static void
|
||||
AddIcalMultiPropertyToJson(BongoJsonObject *obj, const char *name, icalproperty *prop)
|
||||
{
|
||||
BongoArray *array;
|
||||
GArray *array;
|
||||
BongoJsonObject *jsonProp;
|
||||
|
||||
assert(name != NULL);
|
||||
|
||||
if (BongoJsonObjectGetArray(obj, name, &array) != BONGO_JSON_OK) {
|
||||
array = BongoArrayNew(sizeof(BongoJsonNode*), 10);
|
||||
array = g_array_sized_new(FALSE, FALSE, sizeof(BongoJsonNode*), 10);
|
||||
BongoJsonObjectPutArray(obj, name, array);
|
||||
}
|
||||
|
||||
@@ -1147,7 +1147,7 @@ IcalComponentToJsonWithType(ComponentType *componentType, icalcomponent *compone
|
||||
child;
|
||||
child = icalcomponent_get_next_component(component, ICAL_ANY_COMPONENT)) {
|
||||
BongoJsonObject *childObj;
|
||||
BongoArray *children;
|
||||
GArray *children;
|
||||
char *childAttribute;
|
||||
icalcomponent_kind childType;
|
||||
|
||||
@@ -1174,7 +1174,7 @@ IcalComponentToJsonWithType(ComponentType *componentType, icalcomponent *compone
|
||||
}
|
||||
|
||||
if (BongoJsonObjectGetArray(obj, childAttribute, &children) != BONGO_JSON_OK) {
|
||||
children = BongoArrayNew(sizeof(BongoJsonNode*), 2);
|
||||
children = g_array_sized_new(FALSE, FALSE, sizeof(BongoJsonNode*), 2);
|
||||
BongoJsonObjectPutArray(obj, childAttribute, children);
|
||||
}
|
||||
|
||||
@@ -1222,7 +1222,7 @@ AddJsonValueToIcal(icalcomponent *comp, const char *propertyName, PropertyType *
|
||||
}
|
||||
|
||||
static void
|
||||
JsonComponentArrayToIcal(BongoArray *array, icalcomponent *parent, BOOL recurse)
|
||||
JsonComponentArrayToIcal(GArray *array, icalcomponent *parent, BOOL recurse)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@@ -1266,7 +1266,7 @@ JsonComponentToIcalWithType(ComponentType *componentType, BongoJsonObject *obj,
|
||||
iter.key);
|
||||
|
||||
if (node->type == BONGO_JSON_ARRAY) {
|
||||
BongoArray *array = BongoJsonNodeAsArray(node);
|
||||
GArray *array = BongoJsonNodeAsArray(node);
|
||||
if (!XplStrCaseCmp(iter.key, "alarms")
|
||||
|| !XplStrCaseCmp(iter.key, "changes")
|
||||
|| !XplStrCaseCmp(iter.key, "components")
|
||||
@@ -1340,13 +1340,13 @@ BongoCalIcalToJson(icalcomponent *comp)
|
||||
{
|
||||
BongoJsonObject *calObj;
|
||||
icalcomponent *child;
|
||||
BongoArray *components;
|
||||
GArray *components;
|
||||
|
||||
DPRINT("converting component: %s\n", icalcomponent_as_ical_string(comp));
|
||||
|
||||
calObj = BongoIcalComponentToJson(comp, FALSE);
|
||||
|
||||
components = BongoArrayNew(sizeof(BongoJsonNode *), 10);
|
||||
components = g_array_sized_new(FALSE, FALSE, sizeof(BongoJsonNode *), 10);
|
||||
|
||||
for (child = icalcomponent_get_first_component (comp, ICAL_ANY_COMPONENT);
|
||||
child;
|
||||
@@ -1363,7 +1363,7 @@ BongoCalIcalToJson(icalcomponent *comp)
|
||||
}
|
||||
|
||||
static BongoHashtable *
|
||||
GetTimezones(BongoArray *components)
|
||||
GetTimezones(GArray *components)
|
||||
{
|
||||
BongoHashtable *timezones;
|
||||
unsigned int i;
|
||||
@@ -1394,7 +1394,7 @@ GetTimezones(BongoArray *components)
|
||||
|
||||
if (BongoJsonObjectResolveString(object, "tzid/value", &tzid) == BONGO_JSON_OK) {
|
||||
BongoHashtablePut(timezones, (char*)tzid, objectNode);
|
||||
BongoArrayIndex(components, BongoJsonNode*, i) = NULL;
|
||||
g_array_index(components, BongoJsonNode *, i) = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1403,7 +1403,7 @@ GetTimezones(BongoArray *components)
|
||||
}
|
||||
|
||||
static BOOL
|
||||
HasTimezone(BongoArray *components, const char *tzid)
|
||||
HasTimezone(GArray *components, const char *tzid)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < components->len; i++) {
|
||||
@@ -1422,7 +1422,7 @@ HasTimezone(BongoArray *components, const char *tzid)
|
||||
|
||||
|
||||
static void
|
||||
AddTimezones(BongoArray *newComponents,
|
||||
AddTimezones(GArray *newComponents,
|
||||
BongoHashtable *tzs,
|
||||
BongoJsonObject *component)
|
||||
{
|
||||
@@ -1452,13 +1452,13 @@ AddTimezones(BongoArray *newComponents,
|
||||
}
|
||||
}
|
||||
|
||||
BongoArray *
|
||||
GArray *
|
||||
BongoCalSplit(BongoJsonObject *obj)
|
||||
{
|
||||
BongoJsonNode *componentsNode;
|
||||
BongoArray *components;
|
||||
GArray *components;
|
||||
unsigned i;
|
||||
BongoArray *ret;
|
||||
GArray *ret;
|
||||
BongoHashtable *tzs;
|
||||
BongoHashtable *newObjs;
|
||||
|
||||
@@ -1480,12 +1480,12 @@ BongoCalSplit(BongoJsonObject *obj)
|
||||
/* What's left is a bare object with toplevel object attributes
|
||||
* and timezones. We'll dup this for each new object. */
|
||||
|
||||
ret = BongoArrayNew(sizeof (BongoJsonNode *), components->len);
|
||||
ret = g_array_sized_new(FALSE, FALSE, sizeof (BongoJsonNode *), components->len);
|
||||
|
||||
for(i = 0; i < components->len; i++) {
|
||||
BongoJsonObject *newObj;
|
||||
BongoJsonNode *componentNode;
|
||||
BongoArray *newComponents;
|
||||
GArray *newComponents;
|
||||
const char *uid;
|
||||
const char *type;
|
||||
|
||||
@@ -1516,7 +1516,7 @@ BongoCalSplit(BongoJsonObject *obj)
|
||||
if (uid) {
|
||||
BongoHashtablePut(newObjs, (void*)uid, newObj);
|
||||
}
|
||||
newComponents = BongoArrayNew(sizeof(BongoJsonNode*), 1);
|
||||
newComponents = g_array_new(FALSE, FALSE, sizeof(BongoJsonNode*));
|
||||
BongoJsonObjectPutArray(newObj, "components", newComponents);
|
||||
}
|
||||
|
||||
@@ -1536,8 +1536,8 @@ BongoCalSplit(BongoJsonObject *obj)
|
||||
BongoHashtableDelete(tzs);
|
||||
BongoHashtableDelete(newObjs);
|
||||
|
||||
/* Use BongoArrayFree to prevent freeing the reparented nodes */
|
||||
BongoArrayFree(components, TRUE);
|
||||
/* Use g_array_free to prevent freeing the reparented nodes */
|
||||
g_array_free(components, TRUE);
|
||||
BongoJsonObjectFree(obj);
|
||||
|
||||
return ret;
|
||||
@@ -1547,8 +1547,8 @@ static BongoJsonResult
|
||||
MergeObjectComponents(BongoJsonObject *dest, BongoJsonObject *src)
|
||||
{
|
||||
BongoJsonNode *srcComponentsNode;
|
||||
BongoArray *srcComponents;
|
||||
BongoArray *destComponents;
|
||||
GArray *srcComponents;
|
||||
GArray *destComponents;
|
||||
BongoJsonResult res;
|
||||
unsigned int i;
|
||||
|
||||
@@ -1590,8 +1590,8 @@ MergeObjectComponents(BongoJsonObject *dest, BongoJsonObject *src)
|
||||
* array ourselves */
|
||||
BongoJsonNodeFreeSteal(srcComponentsNode);
|
||||
|
||||
/* Use BongoArrayFree to prevent freeing the reparented nodes */
|
||||
BongoArrayFree(srcComponents, TRUE);
|
||||
/* Use g_array_free to prevent freeing the reparented nodes */
|
||||
g_array_free(srcComponents, TRUE);
|
||||
|
||||
return BONGO_JSON_OK;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ static void
|
||||
HandleRequest (BongoJsonRpcServer *server, BongoJsonRpc *rpc, BongoJsonObject *request)
|
||||
{
|
||||
const char *method;
|
||||
BongoArray *params;
|
||||
GArray *params;
|
||||
int requestId;
|
||||
MethodHandler *handler;
|
||||
|
||||
|
||||
+20
-21
@@ -26,7 +26,7 @@
|
||||
|
||||
#define PRETTY_JSON 1
|
||||
|
||||
static void BongoJsonArrayToStringBuilderInternal(BongoArray *array, BongoStringBuilder *sb, int depth);
|
||||
static void BongoJsonArrayToStringBuilderInternal(GArray *array, BongoStringBuilder *sb, int depth);
|
||||
static void BongoJsonObjectToStringBuilderInternal(BongoJsonObject *object, BongoStringBuilder *sb, int depth);
|
||||
|
||||
BongoJsonNode *
|
||||
@@ -116,7 +116,7 @@ BongoJsonJPathGetObject(BongoJsonNode *n, const char *path, BongoJsonObject **va
|
||||
}
|
||||
|
||||
BongoJsonResult
|
||||
BongoJsonJPathGetArray(BongoJsonNode *n, const char *path, BongoArray **val) {
|
||||
BongoJsonJPathGetArray(BongoJsonNode *n, const char *path, GArray **val) {
|
||||
BongoJsonNode *result = BongoJsonJPath(n, path);
|
||||
if (!result) return BONGO_JSON_NOT_FOUND;
|
||||
if (result->type == BONGO_JSON_ARRAY) {
|
||||
@@ -201,7 +201,7 @@ BongoJsonNodeNewObject(BongoJsonObject *val)
|
||||
}
|
||||
|
||||
BongoJsonNode *
|
||||
BongoJsonNodeNewArray(BongoArray *val)
|
||||
BongoJsonNodeNewArray(GArray *val)
|
||||
{
|
||||
BongoJsonNode *node = MemMalloc0(sizeof(BongoJsonNode));
|
||||
node->type = BONGO_JSON_ARRAY;
|
||||
@@ -446,13 +446,13 @@ BongoJsonNodeResolve(BongoJsonNode *node, const char *path, BongoJsonNode **out)
|
||||
|
||||
/*** BongoJsonArray **/
|
||||
|
||||
BongoArray *
|
||||
BongoJsonArrayDup(BongoArray *old)
|
||||
GArray *
|
||||
BongoJsonArrayDup(GArray *old)
|
||||
{
|
||||
BongoArray *array;
|
||||
GArray *array;
|
||||
unsigned int i;
|
||||
|
||||
array = BongoArrayNew(sizeof(BongoJsonNode*), old->len);
|
||||
array = g_array_sized_new(FALSE, FALSE, sizeof(BongoJsonNode*), old->len);
|
||||
|
||||
for (i = 0; i < old->len; i++) {
|
||||
BongoJsonNode *node;
|
||||
@@ -465,30 +465,29 @@ BongoJsonArrayDup(BongoArray *old)
|
||||
|
||||
|
||||
void
|
||||
BongoJsonArrayAppend(BongoArray *array, BongoJsonNode *node)
|
||||
BongoJsonArrayAppend(GArray *array, BongoJsonNode *node)
|
||||
{
|
||||
BongoArrayAppendValue(array, node);
|
||||
g_array_append_val(array, node);
|
||||
}
|
||||
|
||||
void
|
||||
BongoJsonArrayRemove(BongoArray *array, int i)
|
||||
BongoJsonArrayRemove(GArray *array, int i)
|
||||
{
|
||||
BongoJsonNode *node;
|
||||
|
||||
node = BongoJsonArrayGet(array, i);
|
||||
BongoArrayRemove(array, i);
|
||||
g_array_remove_index(array, i);
|
||||
BongoJsonNodeFree(node);
|
||||
}
|
||||
|
||||
void
|
||||
BongoJsonArrayRemoveSteal(BongoArray *array, int i)
|
||||
BongoJsonArrayRemoveSteal(GArray *array, int i)
|
||||
{
|
||||
BongoArrayRemove(array, i);
|
||||
|
||||
g_array_remove_index(array, i);
|
||||
}
|
||||
|
||||
char *
|
||||
BongoJsonArrayToString(BongoArray *array)
|
||||
BongoJsonArrayToString(GArray *array)
|
||||
{
|
||||
BongoStringBuilder sb;
|
||||
|
||||
@@ -499,7 +498,7 @@ BongoJsonArrayToString(BongoArray *array)
|
||||
}
|
||||
|
||||
static void
|
||||
BongoJsonArrayToStringBuilderInternal(BongoArray *array, BongoStringBuilder *sb, int depth)
|
||||
BongoJsonArrayToStringBuilderInternal(GArray *array, BongoStringBuilder *sb, int depth)
|
||||
{
|
||||
unsigned int i;
|
||||
BOOL first;
|
||||
@@ -521,13 +520,13 @@ BongoJsonArrayToStringBuilderInternal(BongoArray *array, BongoStringBuilder *sb,
|
||||
}
|
||||
|
||||
void
|
||||
BongoJsonArrayToStringBuilder(BongoArray *array, BongoStringBuilder *sb)
|
||||
BongoJsonArrayToStringBuilder(GArray *array, BongoStringBuilder *sb)
|
||||
{
|
||||
BongoJsonArrayToStringBuilderInternal(array, sb, 0);
|
||||
}
|
||||
|
||||
void
|
||||
BongoJsonArrayFree(BongoArray *array)
|
||||
BongoJsonArrayFree(GArray *array)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@@ -538,7 +537,7 @@ BongoJsonArrayFree(BongoArray *array)
|
||||
BongoJsonNodeFree(node);
|
||||
}
|
||||
|
||||
BongoArrayFree(array, TRUE);
|
||||
g_array_free(array, TRUE);
|
||||
}
|
||||
|
||||
|
||||
@@ -692,7 +691,7 @@ BongoJsonObjectGetObject(BongoJsonObject *obj, const char *key, BongoJsonObject
|
||||
}
|
||||
|
||||
BongoJsonResult
|
||||
BongoJsonObjectGetArray(BongoJsonObject *obj, const char *key, BongoArray **val)
|
||||
BongoJsonObjectGetArray(BongoJsonObject *obj, const char *key, GArray **val)
|
||||
{
|
||||
BongoJsonNode *node;
|
||||
BongoJsonResult res;
|
||||
@@ -839,7 +838,7 @@ BongoJsonObjectPutObject(BongoJsonObject *obj, const char *key, BongoJsonObject
|
||||
}
|
||||
|
||||
BongoJsonResult
|
||||
BongoJsonObjectPutArray(BongoJsonObject *obj, const char *key, BongoArray *val)
|
||||
BongoJsonObjectPutArray(BongoJsonObject *obj, const char *key, GArray *val)
|
||||
{
|
||||
BongoJsonNode *node;
|
||||
|
||||
|
||||
@@ -381,14 +381,14 @@ static BongoJsonNode *
|
||||
BongoJsonParserNextArrayNode(BongoJsonParser *t)
|
||||
{
|
||||
BongoJsonNode *ret;
|
||||
BongoArray *array;
|
||||
GArray *array;
|
||||
|
||||
if (BongoJsonParserNextClean(t) != '[') {
|
||||
BongoJsonParserError(t, BONGO_JSON_UNEXPECTED_CHAR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
array = BongoArrayNew(sizeof(BongoJsonNode *), 15);
|
||||
array = g_array_sized_new(FALSE, FALSE, sizeof(BongoJsonNode *), 15);
|
||||
ret = BongoJsonNodeNewArray(array);
|
||||
|
||||
if (BongoJsonParserNextClean(t) == ']') {
|
||||
@@ -405,7 +405,7 @@ BongoJsonParserNextArrayNode(BongoJsonParser *t)
|
||||
goto done;
|
||||
}
|
||||
|
||||
BongoArrayAppendValue(array, nextNode);
|
||||
g_array_append_val(array, nextNode);
|
||||
|
||||
switch(BongoJsonParserNextClean(t)) {
|
||||
case '0' :
|
||||
|
||||
@@ -212,11 +212,11 @@ ReadCalendar(Connection *conn, const char *calendar)
|
||||
int ccode;
|
||||
char buffer[CONN_BUFSIZE + 1];
|
||||
BongoHashtable *guids;
|
||||
BongoArray oldDuplicates;
|
||||
GArray *oldDuplicates;
|
||||
unsigned int i;
|
||||
char *guid;
|
||||
|
||||
BongoArrayInit(&oldDuplicates, sizeof (char *), 8);
|
||||
oldDuplicates = g_array_sized_new(FALSE, FALSE, sizeof(char *), 8);
|
||||
|
||||
guids = BongoHashtableCreateFull(16,
|
||||
(HashFunction)BongoStringHash,
|
||||
@@ -242,7 +242,7 @@ ReadCalendar(Connection *conn, const char *calendar)
|
||||
if (oldData) {
|
||||
/*fprintf (stderr, "Found duplicate of ical uid %s in guid %s\n", buffer, guid);*/
|
||||
uid = MemStrdup(guid);
|
||||
BongoArrayAppendValue(&oldDuplicates, uid);
|
||||
g_array_append_val(oldDuplicates, uid);
|
||||
uid = NULL;
|
||||
} else {
|
||||
uid = MemStrdup(buffer);
|
||||
@@ -270,8 +270,8 @@ ReadCalendar(Connection *conn, const char *calendar)
|
||||
ccode = NMAPReadAnswer(conn, buffer, CONN_BUFSIZE, TRUE);
|
||||
}
|
||||
|
||||
for (i = 0; i < BongoArrayCount(&oldDuplicates); i++) {
|
||||
guid = BongoArrayIndex (&oldDuplicates, char *, i);
|
||||
for (i = 0; i < oldDuplicates->len; i++) {
|
||||
guid = g_array_index(oldDuplicates, char *, i);
|
||||
|
||||
if (ccode == 1000) {
|
||||
NMAPSendCommandF(conn, "UNLINK /calendars/%s %s\r\n", calendar, guid);
|
||||
@@ -280,7 +280,7 @@ ReadCalendar(Connection *conn, const char *calendar)
|
||||
|
||||
MemFree(guid);
|
||||
}
|
||||
BongoArrayDestroy(&oldDuplicates, TRUE);
|
||||
g_array_free(oldDuplicates, TRUE);
|
||||
|
||||
if (ccode == 1000) {
|
||||
return guids;
|
||||
@@ -311,7 +311,7 @@ RemoveGuidForeach (void *key, void *value, void *data)
|
||||
}
|
||||
|
||||
static int
|
||||
ImportJson(BongoArray *objects,
|
||||
ImportJson(GArray *objects,
|
||||
const char *user,
|
||||
const char *calendarName,
|
||||
const char *icsName,
|
||||
@@ -423,7 +423,7 @@ MsgImportIcs(FILE *fh,
|
||||
icalcomponent *component;
|
||||
BongoJsonObject *obj;
|
||||
BongoCalObject *cal;
|
||||
BongoArray *objects;
|
||||
GArray *objects;
|
||||
int ret;
|
||||
const char *icsName;
|
||||
char *icsNameDup = NULL;
|
||||
|
||||
+17
-17
@@ -57,11 +57,11 @@ BongoAgentHandleSignal(BongoAgent *agent,
|
||||
snprintf(path, XPL_MAX_PATH, "%s/guru-meditation-%d", XPL_DEFAULT_WORK_DIR, (int)time(NULL));
|
||||
boomfile = open(path, O_CREAT | O_WRONLY);
|
||||
if (boomfile != -1) {
|
||||
void * const buffer[buff_size];
|
||||
void * buffer[buff_size];
|
||||
int buff_used;
|
||||
|
||||
buff_used = backtrace(&buffer, buff_size);
|
||||
backtrace_symbols_fd(&buffer, buff_used, boomfile);
|
||||
buff_used = backtrace(buffer, buff_size);
|
||||
backtrace_symbols_fd(buffer, buff_used, boomfile);
|
||||
close(boomfile);
|
||||
}
|
||||
XplExit(-1);
|
||||
@@ -109,14 +109,14 @@ FreeBongoConfiguration(BongoConfigItem *config) {
|
||||
case BONGO_JSON_ARRAY: {
|
||||
BongoConfigItem *sub = config->destination;
|
||||
/* sub->destination here is the address of a pointer to an array */
|
||||
BongoArray **output = (BongoArray **)sub->destination;
|
||||
GArray **output = (GArray **)sub->destination;
|
||||
if (sub->type == BONGO_JSON_STRING) {
|
||||
int x;
|
||||
for(x=0;x<BongoArrayCount(*output);x++) {
|
||||
MemFree(BongoArrayIndex(*output, char *, x));
|
||||
for(x=0;x<(*output)->len;x++) {
|
||||
MemFree(g_array_index(*output, char *, x));
|
||||
}
|
||||
}
|
||||
BongoArrayFree(*output, TRUE);
|
||||
g_array_free(*output, TRUE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -165,21 +165,21 @@ SetBongoConfigItem(BongoConfigItem *schema, BongoJsonNode *node) {
|
||||
break;
|
||||
case BONGO_JSON_ARRAY: {
|
||||
BongoConfigItem *subschema = (BongoConfigItem *)schema->destination;
|
||||
BongoArray **output = (BongoArray **)subschema->destination;
|
||||
BongoArray *data, *result = NULL;
|
||||
GArray **output = (GArray **)subschema->destination;
|
||||
GArray *data, *result = NULL;
|
||||
int size;
|
||||
|
||||
data = BongoJsonNodeAsArray(node);
|
||||
size = BongoArrayCount(data);
|
||||
size = data->len;
|
||||
|
||||
switch (subschema->type) {
|
||||
case BONGO_JSON_BOOL: {
|
||||
BOOL dest;
|
||||
int i;
|
||||
result = BongoArrayNew(sizeof(BOOL), size);
|
||||
result = g_array_sized_new(FALSE, FALSE, sizeof(BOOL), size);
|
||||
for(i = 0; i < size; i++) {
|
||||
if (BongoJsonArrayGetBool(data, i, &dest) == BONGO_JSON_OK) {
|
||||
BongoArrayAppendValue(result, dest);
|
||||
g_array_append_val(result, dest);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -188,10 +188,10 @@ SetBongoConfigItem(BongoConfigItem *schema, BongoJsonNode *node) {
|
||||
break;
|
||||
case BONGO_JSON_INT: {
|
||||
int dest, i;
|
||||
result = BongoArrayNew(sizeof(int), size);
|
||||
result = g_array_sized_new(FALSE, FALSE, sizeof(int), size);
|
||||
for(i = 0; i < size; i++) {
|
||||
if (BongoJsonArrayGetInt(data, i, &dest) == BONGO_JSON_OK) {
|
||||
BongoArrayAppendValue(result, dest);
|
||||
g_array_append_val(result, dest);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -202,11 +202,11 @@ SetBongoConfigItem(BongoConfigItem *schema, BongoJsonNode *node) {
|
||||
const char *dest;
|
||||
int i;
|
||||
char *newstr;
|
||||
result = BongoArrayNew(sizeof(char *), size);
|
||||
result = g_array_sized_new(FALSE, FALSE, sizeof(char *), size);
|
||||
for (i=0; i<size; i++) {
|
||||
if (BongoJsonArrayGetString(data, i, &dest) == BONGO_JSON_OK) {
|
||||
newstr = MemStrdup(dest);
|
||||
BongoArrayAppendValue(result, newstr);
|
||||
g_array_append_val(result, newstr);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -766,7 +766,7 @@ BongoAgentShutdownFunc (BongoJsonRpcServer *server,
|
||||
BongoJsonRpc *rpc,
|
||||
int requestId,
|
||||
const char *method,
|
||||
BongoArray *args,
|
||||
GArray *args,
|
||||
void *userData)
|
||||
{
|
||||
kill (getpid (), SIGTERM);
|
||||
|
||||
@@ -51,7 +51,7 @@ struct {
|
||||
};
|
||||
|
||||
int
|
||||
NMAPSendCommand(Connection *conn, const unsigned char *command, size_t length)
|
||||
NMAPSendCommand(Connection *conn, const char *command, size_t length)
|
||||
{
|
||||
int written;
|
||||
|
||||
@@ -1219,12 +1219,12 @@ NMAPRunCommandF(Connection *conn, char *response, size_t length, const char *for
|
||||
* that; -1 otherwise.
|
||||
*/
|
||||
int
|
||||
NMAPReadAnswer(Connection *conn, unsigned char *response, size_t length, BOOL checkForResult)
|
||||
NMAPReadAnswer(Connection *conn, char *response, size_t length, BOOL checkForResult)
|
||||
{
|
||||
int len;
|
||||
int result = -1;
|
||||
size_t count;
|
||||
unsigned char *cur;
|
||||
char *cur;
|
||||
|
||||
len = ConnReadAnswer(conn, response, length);
|
||||
if (len > 0) {
|
||||
@@ -1246,7 +1246,7 @@ NMAPReadAnswer(Connection *conn, unsigned char *response, size_t length, BOOL ch
|
||||
}
|
||||
|
||||
BOOL
|
||||
NMAPReadConfigFile(const unsigned char *file, unsigned char **output)
|
||||
NMAPReadConfigFile(const char *file, char **output)
|
||||
{
|
||||
Connection *conn;
|
||||
char buffer[CONN_BUFSIZE + 1];
|
||||
|
||||
@@ -111,7 +111,7 @@ cal_Collect(PyObject *self, PyObject *args)
|
||||
{
|
||||
JsonObject *json;
|
||||
BongoCalObject *cal;
|
||||
BongoArray *occs;
|
||||
GArray *occs;
|
||||
PyObject *dtstart;
|
||||
PyObject *dtend;
|
||||
const char *tzid;
|
||||
@@ -140,12 +140,12 @@ cal_Collect(PyObject *self, PyObject *args)
|
||||
|
||||
cal = BongoCalObjectNew(json->obj);
|
||||
|
||||
occs = BongoArrayNew(sizeof(BongoCalOccurrence), 16);
|
||||
occs = g_array_sized_new(FALSE, FALSE, sizeof(BongoCalOccurrence), 16);
|
||||
if (BongoCalObjectCollect(cal, start, end, NULL, TRUE, occs)) {
|
||||
JsonArray *ret;
|
||||
BongoArray *occsJson;
|
||||
GArray *occsJson;
|
||||
occsJson = BongoCalOccurrencesToJson(occs, BongoCalObjectGetTimezone(cal, tzid));
|
||||
BongoArrayFree(occs, TRUE);
|
||||
g_array_free(occs, TRUE);
|
||||
|
||||
ret = PyObject_New(JsonArray, &JsonArrayType);
|
||||
ret->array = occsJson;
|
||||
@@ -153,7 +153,7 @@ cal_Collect(PyObject *self, PyObject *args)
|
||||
|
||||
return (PyObject*)ret;
|
||||
} else {
|
||||
BongoArrayFree(occs, TRUE);
|
||||
g_array_free(occs, TRUE);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
@@ -161,15 +161,15 @@ JsonPyToNode(PyObject *obj)
|
||||
node = BongoJsonNodeNewString(PyString_AsString(utf8));
|
||||
Py_DECREF(utf8);
|
||||
} else if (PyList_Check(obj)) {
|
||||
BongoArray *array;
|
||||
GArray *array;
|
||||
int len = PyList_Size(obj);
|
||||
int i;
|
||||
|
||||
array = BongoArrayNew(sizeof(BongoJsonNode*), len);
|
||||
array = g_array_sized_new(FALSE, FALSE, sizeof(BongoJsonNode*), len);
|
||||
|
||||
for (i=0; i<len; i++) {
|
||||
BongoJsonNode *item = JsonPyToNode(PyList_GetItem(obj, i));
|
||||
BongoArrayAppendValue(array, item);
|
||||
g_array_append_val(array, item);
|
||||
}
|
||||
|
||||
node = BongoJsonNodeNewArray(array);
|
||||
@@ -230,7 +230,7 @@ JsonObjectToPyNative(BongoJsonObject *obj)
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
JsonArrayToPyNative(BongoArray *array)
|
||||
JsonArrayToPyNative(GArray *array)
|
||||
{
|
||||
PyObject *ret;
|
||||
unsigned int i;
|
||||
@@ -331,7 +331,7 @@ int
|
||||
JsonArray_init(JsonArray *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
self->own = TRUE;
|
||||
self->array = BongoArrayNew(sizeof(BongoJsonNode*), 16);
|
||||
self->array = g_array_sized_new(FALSE, FALSE, sizeof(BongoJsonNode*), 16);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
BOOL own;
|
||||
BongoArray *array;
|
||||
GArray *array;
|
||||
} JsonArray;
|
||||
|
||||
/* Object protocol */
|
||||
|
||||
Reference in New Issue
Block a user