Commit 6710f4bf authored by Jonathan Beck's avatar Jonathan Beck

Format sources to ANSI style using AStyle (astyle --style=ansi).

parent fed25735
...@@ -30,7 +30,7 @@ namespace PList ...@@ -30,7 +30,7 @@ namespace PList
class Array : public Structure class Array : public Structure
{ {
public : public :
Array(Node* parent = NULL); Array(Node* parent = NULL);
Array(plist_t node, Node* parent = NULL); Array(plist_t node, Node* parent = NULL);
Array(Array& a); Array(Array& a);
...@@ -45,7 +45,7 @@ class Array : public Structure ...@@ -45,7 +45,7 @@ class Array : public Structure
void Remove(Node* node); void Remove(Node* node);
void Remove(unsigned int pos); void Remove(unsigned int pos);
private : private :
std::vector<Node*> _array; std::vector<Node*> _array;
}; };
......
...@@ -29,7 +29,7 @@ namespace PList ...@@ -29,7 +29,7 @@ namespace PList
class Boolean : public Node class Boolean : public Node
{ {
public : public :
Boolean(Node* parent = NULL); Boolean(Node* parent = NULL);
Boolean(plist_t node, Node* parent = NULL); Boolean(plist_t node, Node* parent = NULL);
Boolean(Boolean& b); Boolean(Boolean& b);
......
...@@ -30,7 +30,7 @@ namespace PList ...@@ -30,7 +30,7 @@ namespace PList
class Data : public Node class Data : public Node
{ {
public : public :
Data(Node* parent = NULL); Data(Node* parent = NULL);
Data(plist_t node, Node* parent = NULL); Data(plist_t node, Node* parent = NULL);
Data(Data& d); Data(Data& d);
......
...@@ -34,7 +34,7 @@ namespace PList ...@@ -34,7 +34,7 @@ namespace PList
class Date : public Node class Date : public Node
{ {
public : public :
Date(Node* parent = NULL); Date(Node* parent = NULL);
Date(plist_t node, Node* parent = NULL); Date(plist_t node, Node* parent = NULL);
Date(Date& d); Date(Date& d);
......
...@@ -31,7 +31,7 @@ namespace PList ...@@ -31,7 +31,7 @@ namespace PList
class Dictionary : public Structure class Dictionary : public Structure
{ {
public : public :
Dictionary(Node* parent = NULL); Dictionary(Node* parent = NULL);
Dictionary(plist_t node, Node* parent = NULL); Dictionary(plist_t node, Node* parent = NULL);
Dictionary(Dictionary& d); Dictionary(Dictionary& d);
...@@ -50,7 +50,7 @@ class Dictionary : public Structure ...@@ -50,7 +50,7 @@ class Dictionary : public Structure
void Remove(Node* node); void Remove(Node* node);
void Remove(const std::string& key); void Remove(const std::string& key);
private : private :
std::map<std::string,Node*> _map; std::map<std::string,Node*> _map;
......
...@@ -29,7 +29,7 @@ namespace PList ...@@ -29,7 +29,7 @@ namespace PList
class Integer : public Node class Integer : public Node
{ {
public : public :
Integer(Node* parent = NULL); Integer(Node* parent = NULL);
Integer(plist_t node, Node* parent = NULL); Integer(plist_t node, Node* parent = NULL);
Integer(Integer& i); Integer(Integer& i);
......
...@@ -29,7 +29,7 @@ namespace PList ...@@ -29,7 +29,7 @@ namespace PList
class Node class Node
{ {
public : public :
virtual ~Node(); virtual ~Node();
virtual Node* Clone() = 0; virtual Node* Clone() = 0;
...@@ -39,7 +39,7 @@ class Node ...@@ -39,7 +39,7 @@ class Node
plist_type GetType(); plist_type GetType();
plist_t GetPlist(); plist_t GetPlist();
protected: protected:
Node(Node* parent = NULL); Node(Node* parent = NULL);
Node(plist_t node, Node* parent = NULL); Node(plist_t node, Node* parent = NULL);
Node(plist_type type, Node* parent = NULL); Node(plist_type type, Node* parent = NULL);
......
...@@ -29,7 +29,7 @@ namespace PList ...@@ -29,7 +29,7 @@ namespace PList
class Real : public Node class Real : public Node
{ {
public : public :
Real(Node* parent = NULL); Real(Node* parent = NULL);
Real(plist_t node, Node* parent = NULL); Real(plist_t node, Node* parent = NULL);
Real(Real& d); Real(Real& d);
......
...@@ -30,7 +30,7 @@ namespace PList ...@@ -30,7 +30,7 @@ namespace PList
class String : public Node class String : public Node
{ {
public : public :
String(Node* parent = NULL); String(Node* parent = NULL);
String(plist_t node, Node* parent = NULL); String(plist_t node, Node* parent = NULL);
String(String& s); String(String& s);
......
...@@ -31,7 +31,7 @@ namespace PList ...@@ -31,7 +31,7 @@ namespace PList
class Structure : public Node class Structure : public Node
{ {
public : public :
virtual ~Structure(); virtual ~Structure();
uint32_t GetSize(); uint32_t GetSize();
...@@ -41,11 +41,11 @@ class Structure : public Node ...@@ -41,11 +41,11 @@ class Structure : public Node
virtual void Remove(Node* node) = 0; virtual void Remove(Node* node) = 0;
protected: protected:
Structure(Node* parent = NULL); Structure(Node* parent = NULL);
Structure(plist_type type, Node* parent = NULL); Structure(plist_type type, Node* parent = NULL);
private: private:
Structure(Structure& s); Structure(Structure& s);
Structure& operator=(const Structure& s); Structure& operator=(const Structure& s);
}; };
......
...@@ -27,17 +27,17 @@ ...@@ -27,17 +27,17 @@
namespace PList namespace PList
{ {
class Utils class Utils
{ {
public: public:
static Node* FromPlist(plist_t node, Node* parent = NULL); static Node* FromPlist(plist_t node, Node* parent = NULL);
static Structure* FromXml(const std::string& xml); static Structure* FromXml(const std::string& xml);
static Structure* FromBin(const std::vector<char>& bin); static Structure* FromBin(const std::vector<char>& bin);
private: private:
Utils(); Utils();
~Utils(); ~Utils();
}; };
}; };
#endif // PLIST__UTILS_H #endif // PLIST__UTILS_H
This diff is collapsed.
...@@ -43,7 +43,8 @@ int main(int argc, char *argv[]) ...@@ -43,7 +43,8 @@ int main(int argc, char *argv[])
struct stat *filestats = (struct stat *) malloc(sizeof(struct stat)); struct stat *filestats = (struct stat *) malloc(sizeof(struct stat));
Options *options = parse_arguments(argc, argv); Options *options = parse_arguments(argc, argv);
if (!options) { if (!options)
{
print_usage(); print_usage();
free(filestats); free(filestats);
return 0; return 0;
...@@ -61,10 +62,13 @@ int main(int argc, char *argv[]) ...@@ -61,10 +62,13 @@ int main(int argc, char *argv[])
//convert one format to another //convert one format to another
if (memcmp(plist_entire, "bplist00", 8) == 0) { if (memcmp(plist_entire, "bplist00", 8) == 0)
{
plist_from_bin(plist_entire, filestats->st_size, &root_node); plist_from_bin(plist_entire, filestats->st_size, &root_node);
plist_to_xml(root_node, &plist_out, &size); plist_to_xml(root_node, &plist_out, &size);
} else { }
else
{
plist_from_xml(plist_entire, filestats->st_size, &root_node); plist_from_xml(plist_entire, filestats->st_size, &root_node);
plist_to_bin(root_node, &plist_out, &size); plist_to_bin(root_node, &plist_out, &size);
} }
...@@ -72,8 +76,10 @@ int main(int argc, char *argv[]) ...@@ -72,8 +76,10 @@ int main(int argc, char *argv[])
free(plist_entire); free(plist_entire);
free(filestats); free(filestats);
if (plist_out) { if (plist_out)
if (options->out_file != NULL) { {
if (options->out_file != NULL)
{
FILE *oplist = fopen(options->out_file, "wb"); FILE *oplist = fopen(options->out_file, "wb");
if (!oplist) if (!oplist)
return 1; return 1;
...@@ -85,7 +91,8 @@ int main(int argc, char *argv[]) ...@@ -85,7 +91,8 @@ int main(int argc, char *argv[])
fwrite(plist_out, size, sizeof(char), stdout); fwrite(plist_out, size, sizeof(char), stdout);
free(plist_out); free(plist_out);
} else }
else
printf("ERROR\n"); printf("ERROR\n");
free(options); free(options);
...@@ -99,9 +106,12 @@ Options *parse_arguments(int argc, char *argv[]) ...@@ -99,9 +106,12 @@ Options *parse_arguments(int argc, char *argv[])
Options *options = (Options *) malloc(sizeof(Options)); Options *options = (Options *) malloc(sizeof(Options));
memset(options, 0, sizeof(Options)); memset(options, 0, sizeof(Options));
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++)
if (!strcmp(argv[i], "--infile") || !strcmp(argv[i], "-i")) { {
if ((i + 1) == argc) { if (!strcmp(argv[i], "--infile") || !strcmp(argv[i], "-i"))
{
if ((i + 1) == argc)
{
free(options); free(options);
return NULL; return NULL;
} }
...@@ -110,8 +120,10 @@ Options *parse_arguments(int argc, char *argv[]) ...@@ -110,8 +120,10 @@ Options *parse_arguments(int argc, char *argv[])
continue; continue;
} }
if (!strcmp(argv[i], "--outfile") || !strcmp(argv[i], "-o")) { if (!strcmp(argv[i], "--outfile") || !strcmp(argv[i], "-o"))
if ((i + 1) == argc) { {
if ((i + 1) == argc)
{
free(options); free(options);
return NULL; return NULL;
} }
...@@ -120,17 +132,20 @@ Options *parse_arguments(int argc, char *argv[]) ...@@ -120,17 +132,20 @@ Options *parse_arguments(int argc, char *argv[])
continue; continue;
} }
if (!strcmp(argv[i], "--debug") || !strcmp(argv[i], "-d") || !strcmp(argv[i], "-v")) { if (!strcmp(argv[i], "--debug") || !strcmp(argv[i], "-d") || !strcmp(argv[i], "-v"))
{
options->debug = 1; options->debug = 1;
} }
if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) { if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
{
free(options); free(options);
return NULL; return NULL;
} }
} }
if (!options->in_file /*|| !options->out_file */ ) { if (!options->in_file /*|| !options->out_file */ )
{
free(options); free(options);
return NULL; return NULL;
} }
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
typedef struct _options { typedef struct _options
{
char *in_file, *out_file; char *in_file, *out_file;
uint8_t debug, in_fmt, out_fmt; uint8_t debug, in_fmt, out_fmt;
} Options; } Options;
......
...@@ -37,7 +37,8 @@ Node::Node(plist_type type, Node* parent) : _parent(parent) ...@@ -37,7 +37,8 @@ Node::Node(plist_type type, Node* parent) : _parent(parent)
{ {
_node = NULL; _node = NULL;
switch(type) { switch (type)
{
case PLIST_BOOLEAN: case PLIST_BOOLEAN:
_node = plist_new_bool(0); _node = plist_new_bool(0);
break; break;
......
...@@ -38,7 +38,7 @@ Node* Utils::FromPlist(plist_t node, Node* parent) ...@@ -38,7 +38,7 @@ Node* Utils::FromPlist(plist_t node, Node* parent)
if (node) if (node)
{ {
plist_type type = plist_get_node_type(node); plist_type type = plist_get_node_type(node);
switch(type) switch (type)
{ {
case PLIST_DICT: case PLIST_DICT:
ret = new Dictionary(node, parent); ret = new Dictionary(node, parent);
......
This diff is collapsed.
This diff is collapsed.
...@@ -35,8 +35,10 @@ ...@@ -35,8 +35,10 @@
#endif #endif
struct plist_data_s { struct plist_data_s
union { {
union
{
char boolval; char boolval;
uint64_t intval; uint64_t intval;
double realval; double realval;
......
...@@ -72,7 +72,8 @@ static gchar *format_string(const char *buf, int cols, int depth) ...@@ -72,7 +72,8 @@ static gchar *format_string(const char *buf, int cols, int depth)
assert(depth >= 0); assert(depth >= 0);
// Inserts new lines and tabs at appropriate locations // Inserts new lines and tabs at appropriate locations
for (i = 0; i < nlines; i++) { for (i = 0; i < nlines; i++)
{
new_buf[i * colw] = '\n'; new_buf[i * colw] = '\n';
for (j = 0; j < depth; j++) for (j = 0; j < depth; j++)
new_buf[i * colw + 1 + j] = '\t'; new_buf[i * colw + 1 + j] = '\t';
...@@ -90,7 +91,8 @@ static gchar *format_string(const char *buf, int cols, int depth) ...@@ -90,7 +91,8 @@ static gchar *format_string(const char *buf, int cols, int depth)
struct xml_node { struct xml_node
{
xmlNodePtr xml; xmlNodePtr xml;
uint32_t depth; uint32_t depth;
}; };
...@@ -134,7 +136,8 @@ static void node_to_xml(GNode * node, gpointer xml_struct) ...@@ -134,7 +136,8 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
xstruct = (struct xml_node *) xml_struct; xstruct = (struct xml_node *) xml_struct;
node_data = plist_get_data(node); node_data = plist_get_data(node);
switch (node_data->type) { switch (node_data->type)
{
case PLIST_BOOLEAN: case PLIST_BOOLEAN:
{ {
if (node_data->boolval) if (node_data->boolval)
...@@ -166,7 +169,8 @@ static void node_to_xml(GNode * node, gpointer xml_struct) ...@@ -166,7 +169,8 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
case PLIST_DATA: case PLIST_DATA:
tag = XPLIST_DATA; tag = XPLIST_DATA;
if (node_data->length) { if (node_data->length)
{
valtmp = g_base64_encode(node_data->buff, node_data->length); valtmp = g_base64_encode(node_data->buff, node_data->length);
val = format_string(valtmp, 60, xstruct->depth); val = format_string(valtmp, 60, xstruct->depth);
g_free(valtmp); g_free(valtmp);
...@@ -188,7 +192,8 @@ static void node_to_xml(GNode * node, gpointer xml_struct) ...@@ -188,7 +192,8 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
break; break;
} }
for (i = 0; i < xstruct->depth; i++) { for (i = 0; i < xstruct->depth; i++)
{
xmlNodeAddContent(xstruct->xml, BAD_CAST("\t")); xmlNodeAddContent(xstruct->xml, BAD_CAST("\t"));
} }
child_node = xmlNewChild(xstruct->xml, NULL, tag, BAD_CAST(val)); child_node = xmlNewChild(xstruct->xml, NULL, tag, BAD_CAST(val));
...@@ -199,14 +204,17 @@ static void node_to_xml(GNode * node, gpointer xml_struct) ...@@ -199,14 +204,17 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
if (node_data->type == PLIST_ARRAY || node_data->type == PLIST_DICT) if (node_data->type == PLIST_ARRAY || node_data->type == PLIST_DICT)
xmlNodeAddContent(child_node, BAD_CAST("\n")); xmlNodeAddContent(child_node, BAD_CAST("\n"));
if (isStruct) { if (isStruct)
{
struct xml_node child = { child_node, xstruct->depth + 1 }; struct xml_node child = { child_node, xstruct->depth + 1 };
g_node_children_foreach(node, G_TRAVERSE_ALL, node_to_xml, &child); g_node_children_foreach(node, G_TRAVERSE_ALL, node_to_xml, &child);
} }
//fix indent for structured types //fix indent for structured types
if (node_data->type == PLIST_ARRAY || node_data->type == PLIST_DICT) { if (node_data->type == PLIST_ARRAY || node_data->type == PLIST_DICT)
{
for (i = 0; i < xstruct->depth; i++) { for (i = 0; i < xstruct->depth; i++)
{
xmlNodeAddContent(child_node, BAD_CAST("\t")); xmlNodeAddContent(child_node, BAD_CAST("\t"));
} }
} }
...@@ -227,7 +235,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node) ...@@ -227,7 +235,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
if (!xml_node) if (!xml_node)
return; return;
for (node = xml_node->children; node; node = node->next) { for (node = xml_node->children; node; node = node->next)
{
while (node && !xmlStrcmp(node->name, XPLIST_TEXT)) while (node && !xmlStrcmp(node->name, XPLIST_TEXT))
node = node->next; node = node->next;
...@@ -241,21 +250,24 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node) ...@@ -241,21 +250,24 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
else else
*plist_node = subnode; *plist_node = subnode;
if (!xmlStrcmp(node->name, XPLIST_TRUE)) { if (!xmlStrcmp(node->name, XPLIST_TRUE))
{
data->boolval = TRUE; data->boolval = TRUE;
data->type = PLIST_BOOLEAN; data->type = PLIST_BOOLEAN;
data->length = 1; data->length = 1;
continue; continue;
} }
if (!xmlStrcmp(node->name, XPLIST_FALSE)) { if (!xmlStrcmp(node->name, XPLIST_FALSE))
{
data->boolval = FALSE; data->boolval = FALSE;
data->type = PLIST_BOOLEAN; data->type = PLIST_BOOLEAN;
data->length = 1; data->length = 1;
continue; continue;
} }
if (!xmlStrcmp(node->name, XPLIST_INT)) { if (!xmlStrcmp(node->name, XPLIST_INT))
{
xmlChar *strval = xmlNodeGetContent(node); xmlChar *strval = xmlNodeGetContent(node);
data->intval = g_ascii_strtoull((char *) strval, NULL, 0); data->intval = g_ascii_strtoull((char *) strval, NULL, 0);
data->type = PLIST_UINT; data->type = PLIST_UINT;
...@@ -264,7 +276,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node) ...@@ -264,7 +276,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue; continue;
} }
if (!xmlStrcmp(node->name, XPLIST_REAL)) { if (!xmlStrcmp(node->name, XPLIST_REAL))
{
xmlChar *strval = xmlNodeGetContent(node); xmlChar *strval = xmlNodeGetContent(node);
data->realval = atof((char *) strval); data->realval = atof((char *) strval);
data->type = PLIST_REAL; data->type = PLIST_REAL;
...@@ -273,7 +286,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node) ...@@ -273,7 +286,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue; continue;
} }
if (!xmlStrcmp(node->name, XPLIST_DATE)) { if (!xmlStrcmp(node->name, XPLIST_DATE))
{
xmlChar *strval = xmlNodeGetContent(node); xmlChar *strval = xmlNodeGetContent(node);
g_time_val_from_iso8601((char *) strval, &data->timeval); g_time_val_from_iso8601((char *) strval, &data->timeval);
data->type = PLIST_DATE; data->type = PLIST_DATE;
...@@ -282,12 +296,14 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node) ...@@ -282,12 +296,14 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue; continue;
} }
if (!xmlStrcmp(node->name, XPLIST_STRING)) { if (!xmlStrcmp(node->name, XPLIST_STRING))
{
xmlChar *strval = xmlNodeGetContent(node); xmlChar *strval = xmlNodeGetContent(node);
len = strlen((char *) strval); len = strlen((char *) strval);
type = xmlDetectCharEncoding(strval, len); type = xmlDetectCharEncoding(strval, len);
if (XML_CHAR_ENCODING_UTF8 == type || XML_CHAR_ENCODING_ASCII == type || XML_CHAR_ENCODING_NONE == type) { if (XML_CHAR_ENCODING_UTF8 == type || XML_CHAR_ENCODING_ASCII == type || XML_CHAR_ENCODING_NONE == type)
{
data->strval = strdup((char *) strval); data->strval = strdup((char *) strval);
data->type = PLIST_STRING; data->type = PLIST_STRING;
data->length = strlen(data->strval); data->length = strlen(data->strval);
...@@ -296,7 +312,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node) ...@@ -296,7 +312,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue; continue;
} }
if (!xmlStrcmp(node->name, XPLIST_KEY)) { if (!xmlStrcmp(node->name, XPLIST_KEY))
{
xmlChar *strval = xmlNodeGetContent(node); xmlChar *strval = xmlNodeGetContent(node);
data->strval = strdup((char *) strval); data->strval = strdup((char *) strval);
data->type = PLIST_KEY; data->type = PLIST_KEY;
...@@ -305,7 +322,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node) ...@@ -305,7 +322,8 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue; continue;
} }
if (!xmlStrcmp(node->name, XPLIST_DATA)) { if (!xmlStrcmp(node->name, XPLIST_DATA))
{
xmlChar *strval = xmlNodeGetContent(node); xmlChar *strval = xmlNodeGetContent(node);
gsize size = 0; gsize size = 0;
guchar *dec = g_base64_decode((char *) strval, &size); guchar *dec = g_base64_decode((char *) strval, &size);
...@@ -318,13 +336,15 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node) ...@@ -318,13 +336,15 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
continue; continue;
} }
if (!xmlStrcmp(node->name, XPLIST_ARRAY)) { if (!xmlStrcmp(node->name, XPLIST_ARRAY))
{
data->type = PLIST_ARRAY; data->type = PLIST_ARRAY;
xml_to_node(node, &subnode); xml_to_node(node, &subnode);
continue; continue;
} }
if (!xmlStrcmp(node->name, XPLIST_DICT)) { if (!xmlStrcmp(node->name, XPLIST_DICT))
{
data->type = PLIST_DICT; data->type = PLIST_DICT;
xml_to_node(node, &subnode); xml_to_node(node, &subnode);
continue; continue;
......
...@@ -46,7 +46,8 @@ char compare_plist(plist_t node_l, plist_t node_r) ...@@ -46,7 +46,8 @@ char compare_plist(plist_t node_l, plist_t node_r)
if ( !cur_l && !cur_r ) if ( !cur_l && !cur_r )
return plist_compare_node_value( node_l, node_r ); return plist_compare_node_value( node_l, node_r );
while(cur_l && cur_r && res) { while (cur_l && cur_r && res)
{
if (!(res = compare_plist(cur_l, cur_r))) if (!(res = compare_plist(cur_l, cur_r)))
return res; return res;
...@@ -77,7 +78,8 @@ int main(int argc, char *argv[]) ...@@ -77,7 +78,8 @@ int main(int argc, char *argv[])
struct stat *filestats1 = (struct stat *) malloc(sizeof(struct stat)); struct stat *filestats1 = (struct stat *) malloc(sizeof(struct stat));
struct stat *filestats2 = (struct stat *) malloc(sizeof(struct stat)); struct stat *filestats2 = (struct stat *) malloc(sizeof(struct stat));
if (argc!= 3) { if (argc!= 3)
{
printf("Wrong input\n"); printf("Wrong input\n");
return 1; return 1;
} }
...@@ -89,7 +91,8 @@ int main(int argc, char *argv[]) ...@@ -89,7 +91,8 @@ int main(int argc, char *argv[])
iplist1 = fopen(file_in1, "rb"); iplist1 = fopen(file_in1, "rb");
iplist2 = fopen(file_in2, "rb"); iplist2 = fopen(file_in2, "rb");
if (!iplist1 || !iplist2) { if (!iplist1 || !iplist2)
{
printf("File does not exists\n"); printf("File does not exists\n");
return 2; return 2;
} }
...@@ -119,7 +122,8 @@ int main(int argc, char *argv[]) ...@@ -119,7 +122,8 @@ int main(int argc, char *argv[])
else else
plist_from_xml(plist_2, size_in2, &root_node2); plist_from_xml(plist_2, size_in2, &root_node2);
if (!root_node1 || !root_node2) { if (!root_node1 || !root_node2)
{
printf("PList parsing failed\n"); printf("PList parsing failed\n");
return 3; return 3;
} }
......
...@@ -46,7 +46,8 @@ int main(int argc, char *argv[]) ...@@ -46,7 +46,8 @@ int main(int argc, char *argv[])
int size_out2 = 0; int size_out2 = 0;
char *file_in = NULL; char *file_in = NULL;
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");
return 1; return 1;
} }
...@@ -55,7 +56,8 @@ int main(int argc, char *argv[]) ...@@ -55,7 +56,8 @@ int main(int argc, char *argv[])
//read input file //read input file
iplist = fopen(file_in, "rb"); iplist = fopen(file_in, "rb");
if (!iplist) { if (!iplist)
{
printf("File does not exists\n"); printf("File does not exists\n");
return 2; return 2;
} }
...@@ -69,7 +71,8 @@ int main(int argc, char *argv[]) ...@@ -69,7 +71,8 @@ int main(int argc, char *argv[])
//convert one format to another //convert one format to another
plist_from_xml(plist_xml, size_in, &root_node1); plist_from_xml(plist_xml, size_in, &root_node1);
if (!root_node1) { if (!root_node1)
{
printf("PList XML parsing failed\n"); printf("PList XML parsing failed\n");
return 3; return 3;
} }
...@@ -77,7 +80,8 @@ int main(int argc, char *argv[]) ...@@ -77,7 +80,8 @@ int main(int argc, char *argv[])
printf("PList XML parsing succeeded\n"); printf("PList XML parsing succeeded\n");
plist_to_bin(root_node1, &plist_bin, &size_out); plist_to_bin(root_node1, &plist_bin, &size_out);
if (!plist_bin) { if (!plist_bin)
{
printf("PList BIN writing failed\n"); printf("PList BIN writing failed\n");
return 4; return 4;
} }
...@@ -85,7 +89,8 @@ int main(int argc, char *argv[]) ...@@ -85,7 +89,8 @@ int main(int argc, char *argv[])
printf("PList BIN writing succeeded\n"); printf("PList BIN writing succeeded\n");
plist_from_bin(plist_bin, size_out, &root_node2); plist_from_bin(plist_bin, size_out, &root_node2);
if (!root_node2) { if (!root_node2)
{
printf("PList BIN parsing failed\n"); printf("PList BIN parsing failed\n");
return 5; return 5;
} }
...@@ -93,14 +98,16 @@ int main(int argc, char *argv[]) ...@@ -93,14 +98,16 @@ int main(int argc, char *argv[])
printf("PList BIN parsing succeeded\n"); printf("PList BIN parsing succeeded\n");
plist_to_xml(root_node2, &plist_xml2, &size_out2); plist_to_xml(root_node2, &plist_xml2, &size_out2);
if (!plist_xml2) { if (!plist_xml2)
{
printf("PList XML writing failed\n"); printf("PList XML writing failed\n");
return 8; return 8;
} }
else else
printf("PList XML writing succeeded\n"); printf("PList XML writing succeeded\n");
if (plist_xml2) { if (plist_xml2)
{
FILE *oplist = NULL; FILE *oplist = NULL;
char file_out[512]; char file_out[512];
sprintf(file_out, "%s.out", file_in); sprintf(file_out, "%s.out", file_in);
...@@ -116,7 +123,8 @@ int main(int argc, char *argv[]) ...@@ -116,7 +123,8 @@ int main(int argc, char *argv[])
free(plist_xml2); free(plist_xml2);
free(filestats); free(filestats);
if (size_in != size_out2) { if (size_in != size_out2)
{
printf("Size of input and output is different\n"); printf("Size of input and output is different\n");
printf("Input size : %i\n", size_in); printf("Input size : %i\n", size_in);
printf("Output size : %i\n", size_out2); printf("Output size : %i\n", size_out2);
......
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