Commit 1bc33397 authored by Jonathan Beck's avatar Jonathan Beck

Fix build for MSVC9.

parent a129688a
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
#include <plist/Node.h> #include <plist/Node.h>
#include <ctime> #include <ctime>
#ifdef _MSC_VER
#include <Winsock2.h>
#endif
namespace PList namespace PList
{ {
......
...@@ -28,6 +28,11 @@ ...@@ -28,6 +28,11 @@
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef _MSC_VER
#pragma warning(disable:4996)
#endif
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
FILE *iplist = NULL; FILE *iplist = NULL;
......
...@@ -58,7 +58,7 @@ Array::Array(PList::Array& a) : Structure() ...@@ -58,7 +58,7 @@ Array::Array(PList::Array& a) : Structure()
Array& Array::operator=(PList::Array& a) Array& Array::operator=(PList::Array& a)
{ {
plist_free(_node); plist_free(_node);
for (int it = 0; it < _array.size(); it++) for (unsigned int it = 0; it < _array.size(); it++)
{ {
delete _array.at(it); delete _array.at(it);
} }
...@@ -72,11 +72,12 @@ Array& Array::operator=(PList::Array& a) ...@@ -72,11 +72,12 @@ Array& Array::operator=(PList::Array& a)
plist_t subnode = plist_array_get_item(_node, i); plist_t subnode = plist_array_get_item(_node, i);
_array.push_back( Utils::FromPlist(subnode, this) ); _array.push_back( Utils::FromPlist(subnode, this) );
} }
return *this;
} }
Array::~Array() Array::~Array()
{ {
for (int it = 0; it < _array.size(); it++) for (unsigned int it = 0; it < _array.size(); it++)
{ {
delete (_array.at(it)); delete (_array.at(it));
} }
......
...@@ -41,6 +41,7 @@ Boolean& Boolean::operator=(PList::Boolean& b) ...@@ -41,6 +41,7 @@ Boolean& Boolean::operator=(PList::Boolean& b)
{ {
plist_free(_node); plist_free(_node);
_node = plist_copy(b.GetPlist()); _node = plist_copy(b.GetPlist());
return *this;
} }
Boolean::Boolean(bool b) : Node(PLIST_BOOLEAN) Boolean::Boolean(bool b) : Node(PLIST_BOOLEAN)
...@@ -66,7 +67,7 @@ bool Boolean::GetValue() ...@@ -66,7 +67,7 @@ bool Boolean::GetValue()
{ {
uint8_t b = 0; uint8_t b = 0;
plist_get_bool_val(_node, &b); plist_get_bool_val(_node, &b);
return b; return b != 0 ;
} }
}; };
...@@ -42,6 +42,7 @@ Data& Data::operator=(PList::Data& b) ...@@ -42,6 +42,7 @@ Data& Data::operator=(PList::Data& b)
{ {
plist_free(_node); plist_free(_node);
_node = plist_copy(b.GetPlist()); _node = plist_copy(b.GetPlist());
return *this;
} }
Data::Data(const std::vector<char>& buff) : Node(PLIST_DATA) Data::Data(const std::vector<char>& buff) : Node(PLIST_DATA)
......
...@@ -42,6 +42,7 @@ Date& Date::operator=(PList::Date& d) ...@@ -42,6 +42,7 @@ Date& Date::operator=(PList::Date& d)
{ {
plist_free(_node); plist_free(_node);
_node = plist_copy(d.GetPlist()); _node = plist_copy(d.GetPlist());
return *this;
} }
Date::Date(timeval t) : Node(PLIST_DATE) Date::Date(timeval t) : Node(PLIST_DATE)
......
...@@ -104,6 +104,7 @@ Dictionary& Dictionary::operator=(PList::Dictionary& d) ...@@ -104,6 +104,7 @@ Dictionary& Dictionary::operator=(PList::Dictionary& d)
plist_dict_next_item(_node, it, NULL, &subnode); plist_dict_next_item(_node, it, NULL, &subnode);
} }
free(it); free(it);
return *this;
} }
Dictionary::~Dictionary() Dictionary::~Dictionary()
......
...@@ -41,6 +41,7 @@ Integer& Integer::operator=(PList::Integer& i) ...@@ -41,6 +41,7 @@ Integer& Integer::operator=(PList::Integer& i)
{ {
plist_free(_node); plist_free(_node);
_node = plist_copy(i.GetPlist()); _node = plist_copy(i.GetPlist());
return *this;
} }
Integer::Integer(uint64_t i) : Node(PLIST_UINT) Integer::Integer(uint64_t i) : Node(PLIST_UINT)
......
...@@ -79,8 +79,9 @@ plist_type Node::GetType() ...@@ -79,8 +79,9 @@ plist_type Node::GetType()
{ {
if (_node) if (_node)
{ {
return plist_get_node_type(_node); return plist_get_node_type(_node);
} }
return PLIST_NONE;
} }
plist_t Node::GetPlist() plist_t Node::GetPlist()
......
...@@ -41,6 +41,7 @@ Real& Real::operator=(PList::Real& d) ...@@ -41,6 +41,7 @@ Real& Real::operator=(PList::Real& d)
{ {
plist_free(_node); plist_free(_node);
_node = plist_copy(d.GetPlist()); _node = plist_copy(d.GetPlist());
return *this;
} }
Real::Real(double d) : Node(PLIST_REAL) Real::Real(double d) : Node(PLIST_REAL)
......
...@@ -41,6 +41,7 @@ String& String::operator=(PList::String& s) ...@@ -41,6 +41,7 @@ String& String::operator=(PList::String& s)
{ {
plist_free(_node); plist_free(_node);
_node = plist_copy(s.GetPlist()); _node = plist_copy(s.GetPlist());
return *this;
} }
String::String(const std::string& s) : Node(PLIST_STRING) String::String(const std::string& s) : Node(PLIST_STRING)
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <libxml/tree.h> #include <libxml/encoding.h>
#include <plist/plist.h> #include <plist/plist.h>
#include "plist.h" #include "plist.h"
......
...@@ -64,8 +64,9 @@ static void plist_free_data(plist_data_t data) ...@@ -64,8 +64,9 @@ static void plist_free_data(plist_data_t data)
static void plist_free_node(GNode * node, gpointer none) static void plist_free_node(GNode * node, gpointer none)
{ {
plist_data_t data = NULL;
g_node_unlink(node); g_node_unlink(node);
plist_data_t data = plist_get_data(node); data = plist_get_data(node);
plist_free_data(data); plist_free_data(data);
node->data = NULL; node->data = NULL;
g_node_children_foreach(node, G_TRAVERSE_ALL, plist_free_node, NULL); g_node_children_foreach(node, G_TRAVERSE_ALL, plist_free_node, NULL);
...@@ -161,6 +162,7 @@ void plist_free(plist_t plist) ...@@ -161,6 +162,7 @@ void plist_free(plist_t plist)
static void plist_copy_node(GNode * node, gpointer parent_node_ptr) static void plist_copy_node(GNode * node, gpointer parent_node_ptr)
{ {
plist_type node_type = PLIST_NONE;
plist_t newnode = NULL; plist_t newnode = NULL;
plist_data_t data = plist_get_data(node); plist_data_t data = plist_get_data(node);
plist_data_t newdata = plist_new_plist_data(); plist_data_t newdata = plist_new_plist_data();
...@@ -169,7 +171,7 @@ static void plist_copy_node(GNode * node, gpointer parent_node_ptr) ...@@ -169,7 +171,7 @@ static void plist_copy_node(GNode * node, gpointer parent_node_ptr)
memcpy(newdata, data, sizeof(struct plist_data_s)); memcpy(newdata, data, sizeof(struct plist_data_s));
plist_type node_type = plist_get_node_type(node); node_type = plist_get_node_type(node);
if (node_type == PLIST_DATA || node_type == PLIST_STRING || node_type == PLIST_KEY) { if (node_type == PLIST_DATA || node_type == PLIST_STRING || node_type == PLIST_KEY) {
switch (node_type) { switch (node_type) {
case PLIST_DATA: case PLIST_DATA:
...@@ -225,6 +227,7 @@ uint32_t plist_array_get_item_index(plist_t node) ...@@ -225,6 +227,7 @@ uint32_t plist_array_get_item_index(plist_t node)
if (PLIST_ARRAY == plist_get_node_type(father)) { if (PLIST_ARRAY == plist_get_node_type(father)) {
return g_node_child_position(father, node); return g_node_child_position(father, node);
} }
return 0;
} }
void plist_array_set_item(plist_t node, plist_t item, uint32_t n) void plist_array_set_item(plist_t node, plist_t item, uint32_t n)
...@@ -330,8 +333,8 @@ plist_t plist_dict_get_item(plist_t node, const char* key) ...@@ -330,8 +333,8 @@ plist_t plist_dict_get_item(plist_t node, const char* key)
current; current;
current = (plist_t)g_node_next_sibling(g_node_next_sibling(current))) { current = (plist_t)g_node_next_sibling(g_node_next_sibling(current))) {
assert( PLIST_KEY == plist_get_node_type(current) );
plist_data_t data = plist_get_data(current); plist_data_t data = plist_get_data(current);
assert( PLIST_KEY == plist_get_node_type(current) );
if (data && !strcmp(key, data->strval)) { if (data && !strcmp(key, data->strval)) {
ret = (plist_t)g_node_next_sibling(current); ret = (plist_t)g_node_next_sibling(current);
...@@ -623,7 +626,7 @@ char plist_compare_node_value(plist_t node_l, plist_t node_r) ...@@ -623,7 +626,7 @@ char plist_compare_node_value(plist_t node_l, plist_t node_r)
return plist_data_compare(node_l, node_r); return plist_data_compare(node_l, node_r);
} }
static plist_t plist_set_element_val(plist_t node, plist_type type, const void *value, uint64_t length) static void plist_set_element_val(plist_t node, plist_type type, const void *value, uint64_t length)
{ {
//free previous allocated buffer //free previous allocated buffer
plist_data_t data = plist_get_data(node); plist_data_t data = plist_get_data(node);
......
...@@ -29,6 +29,11 @@ ...@@ -29,6 +29,11 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <glib.h> #include <glib.h>
#ifdef _MSC_VER
#pragma warning(disable:4996)
#pragma warning(disable:4244)
#endif
struct plist_data_s { struct plist_data_s {
union { union {
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef _MSC_VER
#pragma warning(disable:4996)
#endif
char compare_plist(plist_t node_l, plist_t node_r) char compare_plist(plist_t node_l, plist_t node_r)
{ {
plist_t cur_l = NULL; plist_t cur_l = NULL;
......
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef _MSC_VER
#pragma warning(disable:4996)
#endif
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
FILE *iplist = NULL; FILE *iplist = NULL;
...@@ -40,7 +45,6 @@ int main(int argc, char *argv[]) ...@@ -40,7 +45,6 @@ int main(int argc, char *argv[])
int size_out = 0; int size_out = 0;
int size_out2 = 0; int size_out2 = 0;
char *file_in = NULL; char *file_in = NULL;
char *file_out[512];
struct stat *filestats = (struct stat *) malloc(sizeof(struct stat)); struct stat *filestats = (struct stat *) malloc(sizeof(struct stat));
if (argc!= 2) { if (argc!= 2) {
printf("Wrong input\n"); printf("Wrong input\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment