removed trailing spaces ([[:space:]]+$)
This commit is contained in:
@@ -30,7 +30,7 @@ struct private_auth_controller_t {
|
||||
* public functions
|
||||
*/
|
||||
auth_controller_t public;
|
||||
|
||||
|
||||
/**
|
||||
* manager instance
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ static void login(private_auth_controller_t *this, request_t *request)
|
||||
static void check(private_auth_controller_t *this, request_t *request)
|
||||
{
|
||||
char *username, *password;
|
||||
|
||||
|
||||
username = request->get_query_data(request, "username");
|
||||
password = request->get_query_data(request, "password");
|
||||
if (username && password &&
|
||||
@@ -87,11 +87,11 @@ static void handle(private_auth_controller_t *this,
|
||||
{
|
||||
return login(this, request);
|
||||
}
|
||||
else if (streq(action, "check"))
|
||||
else if (streq(action, "check"))
|
||||
{
|
||||
return check(this, request);
|
||||
}
|
||||
else if (streq(action, "logout"))
|
||||
else if (streq(action, "logout"))
|
||||
{
|
||||
return logout(this, request);
|
||||
}
|
||||
@@ -117,9 +117,9 @@ controller_t *auth_controller_create(context_t *context, void *param)
|
||||
this->public.controller.get_name = (char*(*)(controller_t*))get_name;
|
||||
this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle;
|
||||
this->public.controller.destroy = (void(*)(controller_t*))destroy;
|
||||
|
||||
|
||||
this->manager = (manager_t*)context;
|
||||
|
||||
|
||||
return &this->public.controller;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ struct private_config_controller_t {
|
||||
* public functions
|
||||
*/
|
||||
config_controller_t public;
|
||||
|
||||
|
||||
/**
|
||||
* manager instance
|
||||
*/
|
||||
@@ -54,7 +54,7 @@ static void process_peerconfig(private_config_controller_t *this,
|
||||
{
|
||||
if (streq(name, "name"))
|
||||
{
|
||||
config = value;
|
||||
config = value;
|
||||
}
|
||||
else if (streq(name, "ikeconfig"))
|
||||
{
|
||||
@@ -80,7 +80,7 @@ static void process_peerconfig(private_config_controller_t *this,
|
||||
if (streq(name, "childconfig"))
|
||||
{
|
||||
int num = 0;
|
||||
|
||||
|
||||
e2 = xml->children(xml);
|
||||
while (e2->enumerate(e2, &xml, &name, &value))
|
||||
{
|
||||
@@ -199,9 +199,9 @@ controller_t *config_controller_create(context_t *context, void *param)
|
||||
this->public.controller.get_name = (char*(*)(controller_t*))get_name;
|
||||
this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle;
|
||||
this->public.controller.destroy = (void(*)(controller_t*))destroy;
|
||||
|
||||
|
||||
this->manager = (manager_t*)context;
|
||||
|
||||
|
||||
return &this->public.controller;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ struct private_control_controller_t {
|
||||
* public functions
|
||||
*/
|
||||
control_controller_t public;
|
||||
|
||||
|
||||
/**
|
||||
* manager instance
|
||||
*/
|
||||
@@ -50,7 +50,7 @@ static void handle_result(private_control_controller_t *this, request_t *r,
|
||||
xml_t *xml;
|
||||
char *name, *value;
|
||||
int num = 0;
|
||||
|
||||
|
||||
if (e)
|
||||
{
|
||||
while (e->enumerate(e, &xml, &name, &value))
|
||||
@@ -113,7 +113,7 @@ static void terminate(private_control_controller_t *this, request_t *r,
|
||||
{
|
||||
gateway_t *gateway;
|
||||
enumerator_t *e;
|
||||
|
||||
|
||||
r->setf(r, "title=Terminate %s SA %d", ike ? "IKE" : "CHILD", id);
|
||||
gateway = this->manager->select_gateway(this->manager, 0);
|
||||
e = gateway->terminate(gateway, ike, id);
|
||||
@@ -145,7 +145,7 @@ static void handle(private_control_controller_t *this,
|
||||
if (action)
|
||||
{
|
||||
u_int32_t id;
|
||||
|
||||
|
||||
if (streq(action, "terminateike"))
|
||||
{
|
||||
if (str && (id = atoi(str)))
|
||||
@@ -196,9 +196,9 @@ controller_t *control_controller_create(context_t *context, void *param)
|
||||
this->public.controller.get_name = (char*(*)(controller_t*))get_name;
|
||||
this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle;
|
||||
this->public.controller.destroy = (void(*)(controller_t*))destroy;
|
||||
|
||||
|
||||
this->manager = (manager_t*)context;
|
||||
|
||||
|
||||
return &this->public.controller;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@ struct private_gateway_controller_t {
|
||||
* public functions
|
||||
*/
|
||||
gateway_controller_t public;
|
||||
|
||||
|
||||
/**
|
||||
* manager instance
|
||||
*/
|
||||
manager_t *manager;
|
||||
|
||||
|
||||
};
|
||||
|
||||
static void list(private_gateway_controller_t *this, request_t *request)
|
||||
@@ -44,7 +44,7 @@ static void list(private_gateway_controller_t *this, request_t *request)
|
||||
enumerator_t *enumerator;
|
||||
char *name, *address;
|
||||
int id, port;
|
||||
|
||||
|
||||
enumerator = this->manager->create_gateway_enumerator(this->manager);
|
||||
while (enumerator->enumerate(enumerator, &id, &name, &port, &address))
|
||||
{
|
||||
@@ -69,7 +69,7 @@ static void list(private_gateway_controller_t *this, request_t *request)
|
||||
static void _select(private_gateway_controller_t *this, request_t *request)
|
||||
{
|
||||
char *id;
|
||||
|
||||
|
||||
id = request->get_query_data(request, "gateway");
|
||||
if (id)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ static void handle(private_gateway_controller_t *this,
|
||||
{
|
||||
return list(this, request);
|
||||
}
|
||||
else if (streq(action, "select"))
|
||||
else if (streq(action, "select"))
|
||||
{
|
||||
return _select(this, request);
|
||||
}
|
||||
@@ -133,9 +133,9 @@ controller_t *gateway_controller_create(context_t *context, void *param)
|
||||
this->public.controller.get_name = (char*(*)(controller_t*))get_name;
|
||||
this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle;
|
||||
this->public.controller.destroy = (void(*)(controller_t*))destroy;
|
||||
|
||||
|
||||
this->manager = (manager_t*)context;
|
||||
|
||||
|
||||
return &this->public.controller;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ struct private_ikesa_controller_t {
|
||||
* public functions
|
||||
*/
|
||||
ikesa_controller_t public;
|
||||
|
||||
|
||||
/**
|
||||
* manager instance
|
||||
*/
|
||||
@@ -50,7 +50,7 @@ static void process_childsa(private_ikesa_controller_t *this, char *id,
|
||||
enumerator_t *e1, *e2;
|
||||
char *name, *value, *reqid = "", *section = "";
|
||||
int num = 0;
|
||||
|
||||
|
||||
while (e->enumerate(e, &xml, &name, &value))
|
||||
{
|
||||
if (streq(name, "reqid"))
|
||||
@@ -106,7 +106,7 @@ static void process_ikesa(private_ikesa_controller_t *this,
|
||||
{
|
||||
if (streq(name, "id"))
|
||||
{
|
||||
id = value;
|
||||
id = value;
|
||||
}
|
||||
else if (streq(name, "local") || streq(name, "remote"))
|
||||
{
|
||||
@@ -223,9 +223,9 @@ controller_t *ikesa_controller_create(context_t *context, void *param)
|
||||
this->public.controller.get_name = (char*(*)(controller_t*))get_name;
|
||||
this->public.controller.handle = (void(*)(controller_t*,request_t*,char*,char*,char*,char*,char*))handle;
|
||||
this->public.controller.destroy = (void(*)(controller_t*))destroy;
|
||||
|
||||
|
||||
this->manager = (manager_t*)context;
|
||||
|
||||
|
||||
return &this->public.controller;
|
||||
}
|
||||
|
||||
|
||||
+19
-19
@@ -35,22 +35,22 @@ struct private_gateway_t {
|
||||
* public functions
|
||||
*/
|
||||
gateway_t public;
|
||||
|
||||
|
||||
/**
|
||||
* name of the gateway
|
||||
*/
|
||||
char *name;
|
||||
|
||||
|
||||
/**
|
||||
* host to connect using tcp
|
||||
*/
|
||||
host_t *host;
|
||||
|
||||
|
||||
/**
|
||||
* socket file descriptor, > 0 if connected
|
||||
*/
|
||||
int fd;
|
||||
|
||||
|
||||
/**
|
||||
* unique id assigned to each xml message
|
||||
*/
|
||||
@@ -83,7 +83,7 @@ static bool connect_(private_gateway_t *this)
|
||||
addr = (struct sockaddr*)&unix_addr;
|
||||
len = sizeof(unix_addr);
|
||||
}
|
||||
|
||||
|
||||
this->fd = socket(family, SOCK_STREAM, 0);
|
||||
if (this->fd < 0)
|
||||
{
|
||||
@@ -115,7 +115,7 @@ static char* request(private_gateway_t *this, char *xml, ...)
|
||||
char buf[8096];
|
||||
ssize_t len;
|
||||
va_list args;
|
||||
|
||||
|
||||
va_start(args, xml);
|
||||
len = vsnprintf(buf, sizeof(buf), xml, args);
|
||||
va_end(args);
|
||||
@@ -153,7 +153,7 @@ static enumerator_t* query_ikesalist(private_gateway_t *this)
|
||||
char *str, *name, *value;
|
||||
xml_t *xml;
|
||||
enumerator_t *e1, *e2, *e3, *e4 = NULL;
|
||||
|
||||
|
||||
str = request(this, "<message type=\"request\" id=\"%d\">"
|
||||
"<query>"
|
||||
"<ikesalist/>"
|
||||
@@ -168,7 +168,7 @@ static enumerator_t* query_ikesalist(private_gateway_t *this)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
e1 = xml->children(xml);
|
||||
free(str);
|
||||
while (e1->enumerate(e1, &xml, &name, &value))
|
||||
@@ -202,7 +202,7 @@ static enumerator_t* query_ikesalist(private_gateway_t *this)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of gateway_t.query_configlist.
|
||||
*/
|
||||
@@ -211,7 +211,7 @@ static enumerator_t* query_configlist(private_gateway_t *this)
|
||||
char *str, *name, *value;
|
||||
xml_t *xml;
|
||||
enumerator_t *e1, *e2, *e3, *e4 = NULL;
|
||||
|
||||
|
||||
str = request(this, "<message type=\"request\" id=\"%d\">"
|
||||
"<query>"
|
||||
"<configlist/>"
|
||||
@@ -226,7 +226,7 @@ static enumerator_t* query_configlist(private_gateway_t *this)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
e1 = xml->children(xml);
|
||||
free(str);
|
||||
while (e1->enumerate(e1, &xml, &name, &value))
|
||||
@@ -308,7 +308,7 @@ static enumerator_t* read_result(private_gateway_t *this, char *res)
|
||||
static enumerator_t* initiate(private_gateway_t *this, bool ike, char *name)
|
||||
{
|
||||
char *str, *kind;
|
||||
|
||||
|
||||
if (ike)
|
||||
{
|
||||
kind = "ike";
|
||||
@@ -331,7 +331,7 @@ static enumerator_t* initiate(private_gateway_t *this, bool ike, char *name)
|
||||
static enumerator_t* terminate(private_gateway_t *this, bool ike, u_int32_t id)
|
||||
{
|
||||
char *str, *kind;
|
||||
|
||||
|
||||
if (ike)
|
||||
{
|
||||
kind = "ike";
|
||||
@@ -368,19 +368,19 @@ static void destroy(private_gateway_t *this)
|
||||
static private_gateway_t *gateway_create(char *name)
|
||||
{
|
||||
private_gateway_t *this = malloc_thing(private_gateway_t);
|
||||
|
||||
|
||||
this->public.request = (char*(*)(gateway_t*, char *xml))request;
|
||||
this->public.query_ikesalist = (enumerator_t*(*)(gateway_t*))query_ikesalist;
|
||||
this->public.query_configlist = (enumerator_t*(*)(gateway_t*))query_configlist;
|
||||
this->public.initiate = (enumerator_t*(*)(gateway_t*, bool ike, char *name))initiate;
|
||||
this->public.terminate = (enumerator_t*(*)(gateway_t*, bool ike, u_int32_t id))terminate;
|
||||
this->public.destroy = (void(*)(gateway_t*))destroy;
|
||||
|
||||
|
||||
this->name = strdup(name);
|
||||
this->host = NULL;
|
||||
this->fd = -1;
|
||||
this->xmlid = 1;
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -390,9 +390,9 @@ static private_gateway_t *gateway_create(char *name)
|
||||
gateway_t *gateway_create_tcp(char *name, host_t *host)
|
||||
{
|
||||
private_gateway_t *this = gateway_create(name);
|
||||
|
||||
|
||||
this->host = host;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ gateway_t *gateway_create_tcp(char *name, host_t *host)
|
||||
gateway_t *gateway_create_unix(char *name)
|
||||
{
|
||||
private_gateway_t *this = gateway_create(name);
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ typedef struct gateway_t gateway_t;
|
||||
* A connection to a gateway.
|
||||
*/
|
||||
struct gateway_t {
|
||||
|
||||
|
||||
/**
|
||||
* Send an XML request to the gateway.
|
||||
*
|
||||
@@ -38,21 +38,21 @@ struct gateway_t {
|
||||
* @return allocated xml response string
|
||||
*/
|
||||
char* (*request)(gateway_t *this, char *xml);
|
||||
|
||||
|
||||
/**
|
||||
* Query the list of IKE_SAs and all its children.
|
||||
*
|
||||
* @return enumerator over ikesa XML elements
|
||||
*/
|
||||
enumerator_t* (*query_ikesalist)(gateway_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Query the list of peer configs and its subconfigs.
|
||||
*
|
||||
* @return enumerator over peerconfig XML elements
|
||||
*/
|
||||
enumerator_t* (*query_configlist)(gateway_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Terminate an IKE or a CHILD SA.
|
||||
*
|
||||
@@ -61,7 +61,7 @@ struct gateway_t {
|
||||
* @return enumerator over control response XML children
|
||||
*/
|
||||
enumerator_t* (*terminate)(gateway_t *this, bool ike, u_int32_t id);
|
||||
|
||||
|
||||
/**
|
||||
* Initiate an IKE or a CHILD SA.
|
||||
*
|
||||
@@ -70,7 +70,7 @@ struct gateway_t {
|
||||
* @return enumerator over control response XML children
|
||||
*/
|
||||
enumerator_t* (*initiate)(gateway_t *this, bool ike, char *name);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a gateway instance.
|
||||
*/
|
||||
|
||||
+7
-7
@@ -40,7 +40,7 @@ int main (int arc, char *argv[])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
socket = lib->settings->get_str(lib->settings, "manager.socket", NULL);
|
||||
debug = lib->settings->get_bool(lib->settings, "manager.debug", FALSE);
|
||||
timeout = lib->settings->get_time(lib->settings, "manager.timeout", 900);
|
||||
@@ -51,13 +51,13 @@ int main (int arc, char *argv[])
|
||||
DBG1("database URI undefined, set manager.database in strongswan.conf");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
storage = storage_create(database);
|
||||
if (storage == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
dispatcher = dispatcher_create(socket, debug, timeout,
|
||||
(context_constructor_t)manager_create, storage);
|
||||
dispatcher->add_controller(dispatcher, ikesa_controller_create, NULL);
|
||||
@@ -65,14 +65,14 @@ int main (int arc, char *argv[])
|
||||
dispatcher->add_controller(dispatcher, auth_controller_create, NULL);
|
||||
dispatcher->add_controller(dispatcher, control_controller_create, NULL);
|
||||
dispatcher->add_controller(dispatcher, config_controller_create, NULL);
|
||||
|
||||
|
||||
dispatcher->run(dispatcher, threads);
|
||||
|
||||
|
||||
dispatcher->waitsignal(dispatcher);
|
||||
|
||||
|
||||
dispatcher->destroy(dispatcher);
|
||||
storage->destroy(storage);
|
||||
|
||||
|
||||
library_deinit();
|
||||
|
||||
return 0;
|
||||
|
||||
+10
-10
@@ -30,23 +30,23 @@ struct private_manager_t {
|
||||
* public functions
|
||||
*/
|
||||
manager_t public;
|
||||
|
||||
|
||||
/**
|
||||
* underlying storage database
|
||||
*/
|
||||
storage_t *store;
|
||||
|
||||
|
||||
/**
|
||||
* user id, if we are logged in
|
||||
*/
|
||||
int user;
|
||||
|
||||
|
||||
/**
|
||||
* selected gateway
|
||||
*/
|
||||
gateway_t *gateway;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation of manager_t.create_gateway_enumerator.
|
||||
*/
|
||||
@@ -66,10 +66,10 @@ static gateway_t* select_gateway(private_manager_t *this, int select_id)
|
||||
int id, port;
|
||||
char *name, *address;
|
||||
host_t *host;
|
||||
|
||||
|
||||
if (this->gateway) this->gateway->destroy(this->gateway);
|
||||
this->gateway = NULL;
|
||||
|
||||
|
||||
enumerator = this->store->create_gateway_enumerator(this->store, this->user);
|
||||
while (enumerator->enumerate(enumerator, &id, &name, &port, &address))
|
||||
{
|
||||
@@ -143,18 +143,18 @@ static void destroy(private_manager_t *this)
|
||||
manager_t *manager_create(storage_t *storage)
|
||||
{
|
||||
private_manager_t *this = malloc_thing(private_manager_t);
|
||||
|
||||
|
||||
this->public.login = (bool(*)(manager_t*, char *username, char *password))login;
|
||||
this->public.logged_in = (bool(*)(manager_t*))logged_in;
|
||||
this->public.logout = (void(*)(manager_t*))logout;
|
||||
this->public.create_gateway_enumerator = (enumerator_t*(*)(manager_t*))create_gateway_enumerator;
|
||||
this->public.select_gateway = (gateway_t*(*)(manager_t*, int id))select_gateway;
|
||||
this->public.context.destroy = (void(*)(context_t*))destroy;
|
||||
|
||||
|
||||
this->user = 0;
|
||||
this->store = storage;
|
||||
this->gateway = NULL;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ struct manager_t {
|
||||
* implements context_t interface
|
||||
*/
|
||||
context_t context;
|
||||
|
||||
|
||||
/**
|
||||
* Create an iterator over all configured gateways.
|
||||
*
|
||||
@@ -54,7 +54,7 @@ struct manager_t {
|
||||
* @return enumerator
|
||||
*/
|
||||
enumerator_t* (*create_gateway_enumerator)(manager_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Select a gateway.
|
||||
*
|
||||
@@ -65,7 +65,7 @@ struct manager_t {
|
||||
* @return selected gateway, or NULL
|
||||
*/
|
||||
gateway_t* (*select_gateway)(manager_t *this, int id);
|
||||
|
||||
|
||||
/**
|
||||
* Try to log in.
|
||||
*
|
||||
@@ -74,14 +74,14 @@ struct manager_t {
|
||||
* @return TRUE if login successful
|
||||
*/
|
||||
bool (*login)(manager_t *this, char *username, char *password);
|
||||
|
||||
|
||||
/**
|
||||
* Check if user logged in.
|
||||
*
|
||||
* @return TRUE if logged in
|
||||
*/
|
||||
bool (*logged_in)(manager_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Log out.
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ struct private_storage_t {
|
||||
* public functions
|
||||
*/
|
||||
storage_t public;
|
||||
|
||||
|
||||
/**
|
||||
* database connection
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ static int login(private_storage_t *this, char *username, char *password)
|
||||
size_t username_len, password_len;
|
||||
int uid = 0;
|
||||
enumerator_t *enumerator;
|
||||
|
||||
|
||||
/* hash = SHA1( username | password ) */
|
||||
hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
|
||||
if (hasher == NULL)
|
||||
@@ -63,8 +63,8 @@ static int login(private_storage_t *this, char *username, char *password)
|
||||
hasher->get_hash(hasher, data, hash.ptr);
|
||||
hasher->destroy(hasher);
|
||||
hex_str = chunk_to_hex(hash, NULL, FALSE);
|
||||
|
||||
enumerator = this->db->query(this->db,
|
||||
|
||||
enumerator = this->db->query(this->db,
|
||||
"SELECT oid FROM users WHERE username = ? AND password = ?;",
|
||||
DB_TEXT, username, DB_TEXT, hex_str.ptr,
|
||||
DB_INT);
|
||||
@@ -83,8 +83,8 @@ static int login(private_storage_t *this, char *username, char *password)
|
||||
static enumerator_t* create_gateway_enumerator(private_storage_t *this, int user)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
|
||||
enumerator = this->db->query(this->db,
|
||||
|
||||
enumerator = this->db->query(this->db,
|
||||
"SELECT gateways.oid AS gid, name, port, address FROM "
|
||||
"gateways, user_gateway AS ug ON gid = ug.gateway WHERE ug.user = ?;",
|
||||
DB_INT, user,
|
||||
@@ -111,11 +111,11 @@ static void destroy(private_storage_t *this)
|
||||
storage_t *storage_create(char *uri)
|
||||
{
|
||||
private_storage_t *this = malloc_thing(private_storage_t);
|
||||
|
||||
|
||||
this->public.login = (int(*)(storage_t*, char *username, char *password))login;
|
||||
this->public.create_gateway_enumerator = (enumerator_t*(*)(storage_t*,int))create_gateway_enumerator;
|
||||
this->public.destroy = (void(*)(storage_t*))destroy;
|
||||
|
||||
|
||||
this->db = lib->db->create(lib->db, uri);
|
||||
if (this->db == NULL)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ struct storage_t {
|
||||
* @return user ID if login good, 0 otherwise
|
||||
*/
|
||||
int (*login)(storage_t *this, char *username, char *password);
|
||||
|
||||
|
||||
/**
|
||||
* Create an iterator over the gateways.
|
||||
*
|
||||
@@ -49,7 +49,7 @@ struct storage_t {
|
||||
* @param user user Id
|
||||
* @return enumerator
|
||||
*/
|
||||
enumerator_t* (*create_gateway_enumerator)(storage_t *this, int user);
|
||||
enumerator_t* (*create_gateway_enumerator)(storage_t *this, int user);
|
||||
|
||||
/**
|
||||
* Destroy a storage instance.
|
||||
|
||||
+10
-10
@@ -32,22 +32,22 @@ struct private_xml_t {
|
||||
* public functions
|
||||
*/
|
||||
xml_t public;
|
||||
|
||||
|
||||
/**
|
||||
* root node of this xml (part)
|
||||
*/
|
||||
xmlNode *node;
|
||||
|
||||
|
||||
/**
|
||||
* document, only for root xml_t
|
||||
*/
|
||||
xmlDoc *doc;
|
||||
|
||||
|
||||
/**
|
||||
* Root xml_t*
|
||||
*/
|
||||
private_xml_t *root;
|
||||
|
||||
|
||||
/**
|
||||
* number of enumerator instances
|
||||
*/
|
||||
@@ -79,10 +79,10 @@ static bool child_enumerate(child_enum_t *e, private_xml_t **child,
|
||||
if (e->node)
|
||||
{
|
||||
xmlNode *text;
|
||||
|
||||
|
||||
text = e->node->children;
|
||||
*value = NULL;
|
||||
|
||||
|
||||
while (text && text->type != XML_TEXT_NODE)
|
||||
{
|
||||
text = text->next;
|
||||
@@ -109,7 +109,7 @@ static char* get_attribute(private_xml_t *this, char *name)
|
||||
}
|
||||
|
||||
/**
|
||||
* destroy enumerator, and complete tree if this was the last enumerator
|
||||
* destroy enumerator, and complete tree if this was the last enumerator
|
||||
*/
|
||||
static void child_destroy(child_enum_t *this)
|
||||
{
|
||||
@@ -145,10 +145,10 @@ static enumerator_t* children(private_xml_t *this)
|
||||
xml_t *xml_create(char *xml)
|
||||
{
|
||||
private_xml_t *this = malloc_thing(private_xml_t);
|
||||
|
||||
|
||||
this->public.get_attribute = (char*(*)(xml_t*,char*))get_attribute;
|
||||
this->public.children = (enumerator_t*(*)(xml_t*))children;
|
||||
|
||||
|
||||
this->doc = xmlReadMemory(xml, strlen(xml), NULL, NULL, 0);
|
||||
if (this->doc == NULL)
|
||||
{
|
||||
@@ -158,7 +158,7 @@ xml_t *xml_create(char *xml)
|
||||
this->node = xmlDocGetRootElement(this->doc);
|
||||
this->root = this;
|
||||
this->enums = 0;
|
||||
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ struct xml_t {
|
||||
* @return enumerator over (xml_t* child, char *name, char *value)
|
||||
*/
|
||||
enumerator_t* (*children)(xml_t *this);
|
||||
|
||||
|
||||
/**
|
||||
* Get an attribute value by its name.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user