diff options
| -rw-r--r-- | include/plist/Date.h | 4 | ||||
| -rw-r--r-- | plutil/plutil.c | 5 | ||||
| -rw-r--r-- | src/Array.cpp | 5 | ||||
| -rw-r--r-- | src/Boolean.cpp | 3 | ||||
| -rw-r--r-- | src/Data.cpp | 1 | ||||
| -rw-r--r-- | src/Date.cpp | 1 | ||||
| -rw-r--r-- | src/Dictionary.cpp | 1 | ||||
| -rw-r--r-- | src/Integer.cpp | 1 | ||||
| -rw-r--r-- | src/Node.cpp | 3 | ||||
| -rw-r--r-- | src/Real.cpp | 1 | ||||
| -rw-r--r-- | src/String.cpp | 1 | ||||
| -rw-r--r-- | src/bplist.c | 2 | ||||
| -rw-r--r-- | src/plist.c | 11 | ||||
| -rw-r--r-- | src/plist.h | 5 | ||||
| -rw-r--r-- | test/plist_cmp.c | 4 | ||||
| -rw-r--r-- | test/plist_test.c | 6 |
16 files changed, 44 insertions, 10 deletions
diff --git a/include/plist/Date.h b/include/plist/Date.h index 22565ef..9c092ea 100644 --- a/include/plist/Date.h +++ b/include/plist/Date.h | |||
| @@ -25,6 +25,10 @@ | |||
| 25 | #include <plist/Node.h> | 25 | #include <plist/Node.h> |
| 26 | #include <ctime> | 26 | #include <ctime> |
| 27 | 27 | ||
| 28 | #ifdef _MSC_VER | ||
| 29 | #include <Winsock2.h> | ||
| 30 | #endif | ||
| 31 | |||
| 28 | namespace PList | 32 | namespace PList |
| 29 | { | 33 | { |
| 30 | 34 | ||
diff --git a/plutil/plutil.c b/plutil/plutil.c index 8c2245c..75cd3f1 100644 --- a/plutil/plutil.c +++ b/plutil/plutil.c | |||
| @@ -28,6 +28,11 @@ | |||
| 28 | #include <string.h> | 28 | #include <string.h> |
| 29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
| 30 | 30 | ||
| 31 | #ifdef _MSC_VER | ||
| 32 | #pragma warning(disable:4996) | ||
| 33 | #endif | ||
| 34 | |||
| 35 | |||
| 31 | int main(int argc, char *argv[]) | 36 | int main(int argc, char *argv[]) |
| 32 | { | 37 | { |
| 33 | FILE *iplist = NULL; | 38 | FILE *iplist = NULL; |
diff --git a/src/Array.cpp b/src/Array.cpp index 7c8272c..dbb1239 100644 --- a/src/Array.cpp +++ b/src/Array.cpp | |||
| @@ -58,7 +58,7 @@ Array::Array(PList::Array& a) : Structure() | |||
| 58 | Array& Array::operator=(PList::Array& a) | 58 | Array& Array::operator=(PList::Array& a) |
| 59 | { | 59 | { |
| 60 | plist_free(_node); | 60 | plist_free(_node); |
| 61 | for (int it = 0; it < _array.size(); it++) | 61 | for (unsigned int it = 0; it < _array.size(); it++) |
| 62 | { | 62 | { |
| 63 | delete _array.at(it); | 63 | delete _array.at(it); |
| 64 | } | 64 | } |
| @@ -72,11 +72,12 @@ Array& Array::operator=(PList::Array& a) | |||
| 72 | plist_t subnode = plist_array_get_item(_node, i); | 72 | plist_t subnode = plist_array_get_item(_node, i); |
| 73 | _array.push_back( Utils::FromPlist(subnode, this) ); | 73 | _array.push_back( Utils::FromPlist(subnode, this) ); |
| 74 | } | 74 | } |
| 75 | return *this; | ||
| 75 | } | 76 | } |
| 76 | 77 | ||
| 77 | Array::~Array() | 78 | Array::~Array() |
| 78 | { | 79 | { |
| 79 | for (int it = 0; it < _array.size(); it++) | 80 | for (unsigned int it = 0; it < _array.size(); it++) |
| 80 | { | 81 | { |
| 81 | delete (_array.at(it)); | 82 | delete (_array.at(it)); |
| 82 | } | 83 | } |
diff --git a/src/Boolean.cpp b/src/Boolean.cpp index 3b20f45..dfa96ca 100644 --- a/src/Boolean.cpp +++ b/src/Boolean.cpp | |||
| @@ -41,6 +41,7 @@ Boolean& Boolean::operator=(PList::Boolean& b) | |||
| 41 | { | 41 | { |
| 42 | plist_free(_node); | 42 | plist_free(_node); |
| 43 | _node = plist_copy(b.GetPlist()); | 43 | _node = plist_copy(b.GetPlist()); |
| 44 | return *this; | ||
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | Boolean::Boolean(bool b) : Node(PLIST_BOOLEAN) | 47 | Boolean::Boolean(bool b) : Node(PLIST_BOOLEAN) |
| @@ -66,7 +67,7 @@ bool Boolean::GetValue() | |||
| 66 | { | 67 | { |
| 67 | uint8_t b = 0; | 68 | uint8_t b = 0; |
| 68 | plist_get_bool_val(_node, &b); | 69 | plist_get_bool_val(_node, &b); |
| 69 | return b; | 70 | return b != 0 ; |
| 70 | } | 71 | } |
| 71 | 72 | ||
| 72 | }; | 73 | }; |
diff --git a/src/Data.cpp b/src/Data.cpp index a171c03..02ce983 100644 --- a/src/Data.cpp +++ b/src/Data.cpp | |||
| @@ -42,6 +42,7 @@ Data& Data::operator=(PList::Data& b) | |||
| 42 | { | 42 | { |
| 43 | plist_free(_node); | 43 | plist_free(_node); |
| 44 | _node = plist_copy(b.GetPlist()); | 44 | _node = plist_copy(b.GetPlist()); |
| 45 | return *this; | ||
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | Data::Data(const std::vector<char>& buff) : Node(PLIST_DATA) | 48 | Data::Data(const std::vector<char>& buff) : Node(PLIST_DATA) |
diff --git a/src/Date.cpp b/src/Date.cpp index 6321c84..cb817d9 100644 --- a/src/Date.cpp +++ b/src/Date.cpp | |||
| @@ -42,6 +42,7 @@ Date& Date::operator=(PList::Date& d) | |||
| 42 | { | 42 | { |
| 43 | plist_free(_node); | 43 | plist_free(_node); |
| 44 | _node = plist_copy(d.GetPlist()); | 44 | _node = plist_copy(d.GetPlist()); |
| 45 | return *this; | ||
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | Date::Date(timeval t) : Node(PLIST_DATE) | 48 | Date::Date(timeval t) : Node(PLIST_DATE) |
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp index 2c56c89..72307f1 100644 --- a/src/Dictionary.cpp +++ b/src/Dictionary.cpp | |||
| @@ -104,6 +104,7 @@ Dictionary& Dictionary::operator=(PList::Dictionary& d) | |||
| 104 | plist_dict_next_item(_node, it, NULL, &subnode); | 104 | plist_dict_next_item(_node, it, NULL, &subnode); |
| 105 | } | 105 | } |
| 106 | free(it); | 106 | free(it); |
| 107 | return *this; | ||
| 107 | } | 108 | } |
| 108 | 109 | ||
| 109 | Dictionary::~Dictionary() | 110 | Dictionary::~Dictionary() |
diff --git a/src/Integer.cpp b/src/Integer.cpp index 9cf6619..4c8a825 100644 --- a/src/Integer.cpp +++ b/src/Integer.cpp | |||
| @@ -41,6 +41,7 @@ Integer& Integer::operator=(PList::Integer& i) | |||
| 41 | { | 41 | { |
| 42 | plist_free(_node); | 42 | plist_free(_node); |
| 43 | _node = plist_copy(i.GetPlist()); | 43 | _node = plist_copy(i.GetPlist()); |
| 44 | return *this; | ||
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | Integer::Integer(uint64_t i) : Node(PLIST_UINT) | 47 | Integer::Integer(uint64_t i) : Node(PLIST_UINT) |
diff --git a/src/Node.cpp b/src/Node.cpp index 4497bb1..e513862 100644 --- a/src/Node.cpp +++ b/src/Node.cpp | |||
| @@ -79,8 +79,9 @@ plist_type Node::GetType() | |||
| 79 | { | 79 | { |
| 80 | if (_node) | 80 | if (_node) |
| 81 | { | 81 | { |
| 82 | return plist_get_node_type(_node); | 82 | return plist_get_node_type(_node); |
| 83 | } | 83 | } |
| 84 | return PLIST_NONE; | ||
| 84 | } | 85 | } |
| 85 | 86 | ||
| 86 | plist_t Node::GetPlist() | 87 | plist_t Node::GetPlist() |
diff --git a/src/Real.cpp b/src/Real.cpp index a877b40..512c44e 100644 --- a/src/Real.cpp +++ b/src/Real.cpp | |||
| @@ -41,6 +41,7 @@ Real& Real::operator=(PList::Real& d) | |||
| 41 | { | 41 | { |
| 42 | plist_free(_node); | 42 | plist_free(_node); |
| 43 | _node = plist_copy(d.GetPlist()); | 43 | _node = plist_copy(d.GetPlist()); |
| 44 | return *this; | ||
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | Real::Real(double d) : Node(PLIST_REAL) | 47 | Real::Real(double d) : Node(PLIST_REAL) |
diff --git a/src/String.cpp b/src/String.cpp index e6cceaa..3ae158e 100644 --- a/src/String.cpp +++ b/src/String.cpp | |||
| @@ -41,6 +41,7 @@ String& String::operator=(PList::String& s) | |||
| 41 | { | 41 | { |
| 42 | plist_free(_node); | 42 | plist_free(_node); |
| 43 | _node = plist_copy(s.GetPlist()); | 43 | _node = plist_copy(s.GetPlist()); |
| 44 | return *this; | ||
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | String::String(const std::string& s) : Node(PLIST_STRING) | 47 | String::String(const std::string& s) : Node(PLIST_STRING) |
diff --git a/src/bplist.c b/src/bplist.c index cd7fe9b..6e3007a 100644 --- a/src/bplist.c +++ b/src/bplist.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | #include <stdio.h> | 24 | #include <stdio.h> |
| 25 | #include <string.h> | 25 | #include <string.h> |
| 26 | 26 | ||
| 27 | #include <libxml/tree.h> | 27 | #include <libxml/encoding.h> |
| 28 | 28 | ||
| 29 | #include <plist/plist.h> | 29 | #include <plist/plist.h> |
| 30 | #include "plist.h" | 30 | #include "plist.h" |
diff --git a/src/plist.c b/src/plist.c index 95b9593..30be007 100644 --- a/src/plist.c +++ b/src/plist.c | |||
| @@ -64,8 +64,9 @@ static void plist_free_data(plist_data_t data) | |||
| 64 | 64 | ||
| 65 | static void plist_free_node(GNode * node, gpointer none) | 65 | static void plist_free_node(GNode * node, gpointer none) |
| 66 | { | 66 | { |
| 67 | plist_data_t data = NULL; | ||
| 67 | g_node_unlink(node); | 68 | g_node_unlink(node); |
| 68 | plist_data_t data = plist_get_data(node); | 69 | data = plist_get_data(node); |
| 69 | plist_free_data(data); | 70 | plist_free_data(data); |
| 70 | node->data = NULL; | 71 | node->data = NULL; |
| 71 | g_node_children_foreach(node, G_TRAVERSE_ALL, plist_free_node, NULL); | 72 | g_node_children_foreach(node, G_TRAVERSE_ALL, plist_free_node, NULL); |
| @@ -161,6 +162,7 @@ void plist_free(plist_t plist) | |||
| 161 | 162 | ||
| 162 | static void plist_copy_node(GNode * node, gpointer parent_node_ptr) | 163 | static void plist_copy_node(GNode * node, gpointer parent_node_ptr) |
| 163 | { | 164 | { |
| 165 | plist_type node_type = PLIST_NONE; | ||
| 164 | plist_t newnode = NULL; | 166 | plist_t newnode = NULL; |
| 165 | plist_data_t data = plist_get_data(node); | 167 | plist_data_t data = plist_get_data(node); |
| 166 | plist_data_t newdata = plist_new_plist_data(); | 168 | plist_data_t newdata = plist_new_plist_data(); |
| @@ -169,7 +171,7 @@ static void plist_copy_node(GNode * node, gpointer parent_node_ptr) | |||
| 169 | 171 | ||
| 170 | memcpy(newdata, data, sizeof(struct plist_data_s)); | 172 | memcpy(newdata, data, sizeof(struct plist_data_s)); |
| 171 | 173 | ||
| 172 | plist_type node_type = plist_get_node_type(node); | 174 | node_type = plist_get_node_type(node); |
| 173 | if (node_type == PLIST_DATA || node_type == PLIST_STRING || node_type == PLIST_KEY) { | 175 | if (node_type == PLIST_DATA || node_type == PLIST_STRING || node_type == PLIST_KEY) { |
| 174 | switch (node_type) { | 176 | switch (node_type) { |
| 175 | case PLIST_DATA: | 177 | case PLIST_DATA: |
| @@ -225,6 +227,7 @@ uint32_t plist_array_get_item_index(plist_t node) | |||
| 225 | if (PLIST_ARRAY == plist_get_node_type(father)) { | 227 | if (PLIST_ARRAY == plist_get_node_type(father)) { |
| 226 | return g_node_child_position(father, node); | 228 | return g_node_child_position(father, node); |
| 227 | } | 229 | } |
| 230 | return 0; | ||
| 228 | } | 231 | } |
| 229 | 232 | ||
| 230 | void plist_array_set_item(plist_t node, plist_t item, uint32_t n) | 233 | 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 | current; | 333 | current; |
| 331 | current = (plist_t)g_node_next_sibling(g_node_next_sibling(current))) { | 334 | current = (plist_t)g_node_next_sibling(g_node_next_sibling(current))) { |
| 332 | 335 | ||
| 333 | assert( PLIST_KEY == plist_get_node_type(current) ); | ||
| 334 | plist_data_t data = plist_get_data(current); | 336 | plist_data_t data = plist_get_data(current); |
| 337 | assert( PLIST_KEY == plist_get_node_type(current) ); | ||
| 335 | 338 | ||
| 336 | if (data && !strcmp(key, data->strval)) { | 339 | if (data && !strcmp(key, data->strval)) { |
| 337 | ret = (plist_t)g_node_next_sibling(current); | 340 | 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 | return plist_data_compare(node_l, node_r); | 626 | return plist_data_compare(node_l, node_r); |
| 624 | } | 627 | } |
| 625 | 628 | ||
| 626 | static plist_t plist_set_element_val(plist_t node, plist_type type, const void *value, uint64_t length) | 629 | static void plist_set_element_val(plist_t node, plist_type type, const void *value, uint64_t length) |
| 627 | { | 630 | { |
| 628 | //free previous allocated buffer | 631 | //free previous allocated buffer |
| 629 | plist_data_t data = plist_get_data(node); | 632 | plist_data_t data = plist_get_data(node); |
diff --git a/src/plist.h b/src/plist.h index 723ed87..b642d74 100644 --- a/src/plist.h +++ b/src/plist.h | |||
| @@ -29,6 +29,11 @@ | |||
| 29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
| 30 | #include <glib.h> | 30 | #include <glib.h> |
| 31 | 31 | ||
| 32 | #ifdef _MSC_VER | ||
| 33 | #pragma warning(disable:4996) | ||
| 34 | #pragma warning(disable:4244) | ||
| 35 | #endif | ||
| 36 | |||
| 32 | 37 | ||
| 33 | struct plist_data_s { | 38 | struct plist_data_s { |
| 34 | union { | 39 | union { |
diff --git a/test/plist_cmp.c b/test/plist_cmp.c index 1a66119..386264a 100644 --- a/test/plist_cmp.c +++ b/test/plist_cmp.c | |||
| @@ -27,6 +27,10 @@ | |||
| 27 | #include <string.h> | 27 | #include <string.h> |
| 28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
| 29 | 29 | ||
| 30 | #ifdef _MSC_VER | ||
| 31 | #pragma warning(disable:4996) | ||
| 32 | #endif | ||
| 33 | |||
| 30 | char compare_plist(plist_t node_l, plist_t node_r) | 34 | char compare_plist(plist_t node_l, plist_t node_r) |
| 31 | { | 35 | { |
| 32 | plist_t cur_l = NULL; | 36 | plist_t cur_l = NULL; |
diff --git a/test/plist_test.c b/test/plist_test.c index a4dd714..069701e 100644 --- a/test/plist_test.c +++ b/test/plist_test.c | |||
| @@ -27,6 +27,11 @@ | |||
| 27 | #include <string.h> | 27 | #include <string.h> |
| 28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
| 29 | 29 | ||
| 30 | #ifdef _MSC_VER | ||
| 31 | #pragma warning(disable:4996) | ||
| 32 | #endif | ||
| 33 | |||
| 34 | |||
| 30 | int main(int argc, char *argv[]) | 35 | int main(int argc, char *argv[]) |
| 31 | { | 36 | { |
| 32 | FILE *iplist = NULL; | 37 | FILE *iplist = NULL; |
| @@ -40,7 +45,6 @@ int main(int argc, char *argv[]) | |||
| 40 | int size_out = 0; | 45 | int size_out = 0; |
| 41 | int size_out2 = 0; | 46 | int size_out2 = 0; |
| 42 | char *file_in = NULL; | 47 | char *file_in = NULL; |
| 43 | char *file_out[512]; | ||
| 44 | struct stat *filestats = (struct stat *) malloc(sizeof(struct stat)); | 48 | struct stat *filestats = (struct stat *) malloc(sizeof(struct stat)); |
| 45 | if (argc!= 2) { | 49 | if (argc!= 2) { |
| 46 | printf("Wrong input\n"); | 50 | printf("Wrong input\n"); |
