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

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

parent fed25735
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLIST__ARRAY_H
......@@ -30,23 +30,23 @@ namespace PList
class Array : public Structure
{
public :
Array(Node* parent = NULL);
Array(plist_t node, Node* parent = NULL);
Array(Array& a);
Array& operator=(Array& a);
virtual ~Array();
Node* Clone();
Node* operator[](unsigned int index);
void Append(Node* node);
void Insert(Node* node, unsigned int pos);
void Remove(Node* node);
void Remove(unsigned int pos);
private :
std::vector<Node*> _array;
public :
Array(Node* parent = NULL);
Array(plist_t node, Node* parent = NULL);
Array(Array& a);
Array& operator=(Array& a);
virtual ~Array();
Node* Clone();
Node* operator[](unsigned int index);
void Append(Node* node);
void Insert(Node* node, unsigned int pos);
void Remove(Node* node);
void Remove(unsigned int pos);
private :
std::vector<Node*> _array;
};
};
......
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLIST__BOOLEAN_H
......@@ -29,18 +29,18 @@ namespace PList
class Boolean : public Node
{
public :
Boolean(Node* parent = NULL);
Boolean(plist_t node, Node* parent = NULL);
Boolean(Boolean& b);
Boolean& operator=(Boolean& b);
Boolean(bool b);
virtual ~Boolean();
Node* Clone();
void SetValue(bool b);
bool GetValue();
public :
Boolean(Node* parent = NULL);
Boolean(plist_t node, Node* parent = NULL);
Boolean(Boolean& b);
Boolean& operator=(Boolean& b);
Boolean(bool b);
virtual ~Boolean();
Node* Clone();
void SetValue(bool b);
bool GetValue();
};
};
......
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLIST__DATA_H
......@@ -30,18 +30,18 @@ namespace PList
class Data : public Node
{
public :
Data(Node* parent = NULL);
Data(plist_t node, Node* parent = NULL);
Data(Data& d);
Data& operator=(Data& d);
Data(const std::vector<char>& buff);
virtual ~Data();
Node* Clone();
void SetValue(const std::vector<char>& buff);
std::vector<char> GetValue();
public :
Data(Node* parent = NULL);
Data(plist_t node, Node* parent = NULL);
Data(Data& d);
Data& operator=(Data& d);
Data(const std::vector<char>& buff);
virtual ~Data();
Node* Clone();
void SetValue(const std::vector<char>& buff);
std::vector<char> GetValue();
};
};
......
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLIST__DATE_H
......@@ -34,18 +34,18 @@ namespace PList
class Date : public Node
{
public :
Date(Node* parent = NULL);
Date(plist_t node, Node* parent = NULL);
Date(Date& d);
Date& operator=(Date& d);
Date(timeval t);
virtual ~Date();
Node* Clone();
void SetValue(timeval t);
timeval GetValue();
public :
Date(Node* parent = NULL);
Date(plist_t node, Node* parent = NULL);
Date(Date& d);
Date& operator=(Date& d);
Date(timeval t);
virtual ~Date();
Node* Clone();
void SetValue(timeval t);
timeval GetValue();
};
};
......
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLIST__DICTIONARY_H
......@@ -31,27 +31,27 @@ namespace PList
class Dictionary : public Structure
{
public :
Dictionary(Node* parent = NULL);
Dictionary(plist_t node, Node* parent = NULL);
Dictionary(Dictionary& d);
Dictionary& operator=(Dictionary& d);
virtual ~Dictionary();
Node* Clone();
typedef std::map<std::string,Node*>::iterator iterator;
Node* operator[](const std::string& key);
iterator Begin();
iterator End();
iterator Find(const std::string& key);
iterator Insert(const std::string& key, Node* node);
void Remove(Node* node);
void Remove(const std::string& key);
private :
std::map<std::string,Node*> _map;
public :
Dictionary(Node* parent = NULL);
Dictionary(plist_t node, Node* parent = NULL);
Dictionary(Dictionary& d);
Dictionary& operator=(Dictionary& d);
virtual ~Dictionary();
Node* Clone();
typedef std::map<std::string,Node*>::iterator iterator;
Node* operator[](const std::string& key);
iterator Begin();
iterator End();
iterator Find(const std::string& key);
iterator Insert(const std::string& key, Node* node);
void Remove(Node* node);
void Remove(const std::string& key);
private :
std::map<std::string,Node*> _map;
};
......
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLIST__INTEGER_H
......@@ -29,18 +29,18 @@ namespace PList
class Integer : public Node
{
public :
Integer(Node* parent = NULL);
Integer(plist_t node, Node* parent = NULL);
Integer(Integer& i);
Integer& operator=(Integer& i);
Integer(uint64_t i);
virtual ~Integer();
Node* Clone();
void SetValue(uint64_t i);
uint64_t GetValue();
public :
Integer(Node* parent = NULL);
Integer(plist_t node, Node* parent = NULL);
Integer(Integer& i);
Integer& operator=(Integer& i);
Integer(uint64_t i);
virtual ~Integer();
Node* Clone();
void SetValue(uint64_t i);
uint64_t GetValue();
};
};
......
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLIST__NODE_H
......@@ -29,22 +29,22 @@ namespace PList
class Node
{
public :
virtual ~Node();
virtual Node* Clone() = 0;
Node * GetParent();
void SetParent(Node* parent);
plist_type GetType();
plist_t GetPlist();
protected:
Node(Node* parent = NULL);
Node(plist_t node, Node* parent = NULL);
Node(plist_type type, Node* parent = NULL);
plist_t _node;
Node* _parent;
public :
virtual ~Node();
virtual Node* Clone() = 0;
Node * GetParent();
void SetParent(Node* parent);
plist_type GetType();
plist_t GetPlist();
protected:
Node(Node* parent = NULL);
Node(plist_t node, Node* parent = NULL);
Node(plist_type type, Node* parent = NULL);
plist_t _node;
Node* _parent;
};
};
......
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLIST__REAL_H
......@@ -29,18 +29,18 @@ namespace PList
class Real : public Node
{
public :
Real(Node* parent = NULL);
Real(plist_t node, Node* parent = NULL);
Real(Real& d);
Real& operator=(Real& d);
Real(double d);
virtual ~Real();
Node* Clone();
void SetValue(double d);
double GetValue();
public :
Real(Node* parent = NULL);
Real(plist_t node, Node* parent = NULL);
Real(Real& d);
Real& operator=(Real& d);
Real(double d);
virtual ~Real();
Node* Clone();
void SetValue(double d);
double GetValue();
};
};
......
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLIST__STRING_H
......@@ -30,18 +30,18 @@ namespace PList
class String : public Node
{
public :
String(Node* parent = NULL);
String(plist_t node, Node* parent = NULL);
String(String& s);
String& operator=(String& s);
String(const std::string& s);
virtual ~String();
Node* Clone();
void SetValue(const std::string& s);
std::string GetValue();
public :
String(Node* parent = NULL);
String(plist_t node, Node* parent = NULL);
String(String& s);
String& operator=(String& s);
String(const std::string& s);
virtual ~String();
Node* Clone();
void SetValue(const std::string& s);
std::string GetValue();
};
};
......
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLIST__STRUCTURE_H
......@@ -31,23 +31,23 @@ namespace PList
class Structure : public Node
{
public :
virtual ~Structure();
public :
virtual ~Structure();
uint32_t GetSize();
uint32_t GetSize();
std::string ToXml();
std::vector<char> ToBin();
std::string ToXml();
std::vector<char> ToBin();
virtual void Remove(Node* node) = 0;
virtual void Remove(Node* node) = 0;
protected:
Structure(Node* parent = NULL);
Structure(plist_type type, Node* parent = NULL);
protected:
Structure(Node* parent = NULL);
Structure(plist_type type, Node* parent = NULL);
private:
Structure(Structure& s);
Structure& operator=(const Structure& s);
private:
Structure(Structure& s);
Structure& operator=(const Structure& s);
};
};
......
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLIST__UTILS_H
......@@ -27,17 +27,17 @@
namespace PList
{
class Utils
{
public:
static Node* FromPlist(plist_t node, Node* parent = NULL);
static Structure* FromXml(const std::string& xml);
static Structure* FromBin(const std::vector<char>& bin);
class Utils
{
public:
static Node* FromPlist(plist_t node, Node* parent = NULL);
static Structure* FromXml(const std::string& xml);
static Structure* FromBin(const std::vector<char>& bin);
private:
Utils();
~Utils();
};
private:
Utils();
~Utils();
};
};
#endif // PLIST__UTILS_H
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef LIBPLISTXX_H
......
This diff is collapsed.
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
......@@ -35,114 +35,129 @@
int main(int argc, char *argv[])
{
FILE *iplist = NULL;
plist_t root_node = NULL;
char *plist_out = NULL;
int size = 0;
char *plist_entire = NULL;
struct stat *filestats = (struct stat *) malloc(sizeof(struct stat));
Options *options = parse_arguments(argc, argv);
if (!options) {
print_usage();
free(filestats);
return 0;
}
//read input file
iplist = fopen(options->in_file, "rb");
if (!iplist)
return 1;
stat(options->in_file, filestats);
plist_entire = (char *) malloc(sizeof(char) * (filestats->st_size + 1));
fread(plist_entire, sizeof(char), filestats->st_size, iplist);
fclose(iplist);
//convert one format to another
if (memcmp(plist_entire, "bplist00", 8) == 0) {
plist_from_bin(plist_entire, filestats->st_size, &root_node);
plist_to_xml(root_node, &plist_out, &size);
} else {
plist_from_xml(plist_entire, filestats->st_size, &root_node);
plist_to_bin(root_node, &plist_out, &size);
}
plist_free(root_node);
free(plist_entire);
free(filestats);
if (plist_out) {
if (options->out_file != NULL) {
FILE *oplist = fopen(options->out_file, "wb");
if (!oplist)
return 1;
fwrite(plist_out, size, sizeof(char), oplist);
fclose(oplist);
}
//if no output file specified, write to stdout
else
fwrite(plist_out, size, sizeof(char), stdout);
free(plist_out);
} else
printf("ERROR\n");
free(options);
return 0;
FILE *iplist = NULL;
plist_t root_node = NULL;
char *plist_out = NULL;
int size = 0;
char *plist_entire = NULL;
struct stat *filestats = (struct stat *) malloc(sizeof(struct stat));
Options *options = parse_arguments(argc, argv);
if (!options)
{
print_usage();
free(filestats);
return 0;
}
//read input file
iplist = fopen(options->in_file, "rb");
if (!iplist)
return 1;
stat(options->in_file, filestats);
plist_entire = (char *) malloc(sizeof(char) * (filestats->st_size + 1));
fread(plist_entire, sizeof(char), filestats->st_size, iplist);
fclose(iplist);
//convert one format to another
if (memcmp(plist_entire, "bplist00", 8) == 0)
{
plist_from_bin(plist_entire, filestats->st_size, &root_node);
plist_to_xml(root_node, &plist_out, &size);
}
else
{
plist_from_xml(plist_entire, filestats->st_size, &root_node);
plist_to_bin(root_node, &plist_out, &size);
}
plist_free(root_node);
free(plist_entire);
free(filestats);
if (plist_out)
{
if (options->out_file != NULL)
{
FILE *oplist = fopen(options->out_file, "wb");
if (!oplist)
return 1;
fwrite(plist_out, size, sizeof(char), oplist);
fclose(oplist);
}
//if no output file specified, write to stdout
else
fwrite(plist_out, size, sizeof(char), stdout);
free(plist_out);
}
else
printf("ERROR\n");
free(options);
return 0;
}
Options *parse_arguments(int argc, char *argv[])
{
int i = 0;
Options *options = (Options *) malloc(sizeof(Options));
memset(options, 0, sizeof(Options));
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--infile") || !strcmp(argv[i], "-i")) {
if ((i + 1) == argc) {
free(options);
return NULL;
}
options->in_file = argv[i + 1];
i++;
continue;
}
if (!strcmp(argv[i], "--outfile") || !strcmp(argv[i], "-o")) {
if ((i + 1) == argc) {
free(options);
return NULL;
}
options->out_file = argv[i + 1];
i++;
continue;
}
if (!strcmp(argv[i], "--debug") || !strcmp(argv[i], "-d") || !strcmp(argv[i], "-v")) {
options->debug = 1;
}
if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
free(options);
return NULL;
}
}
if (!options->in_file /*|| !options->out_file */ ) {
free(options);
return NULL;
}
return options;
int i = 0;
Options *options = (Options *) malloc(sizeof(Options));
memset(options, 0, sizeof(Options));
for (i = 1; i < argc; i++)
{
if (!strcmp(argv[i], "--infile") || !strcmp(argv[i], "-i"))
{
if ((i + 1) == argc)
{
free(options);
return NULL;
}
options->in_file = argv[i + 1];
i++;
continue;
}
if (!strcmp(argv[i], "--outfile") || !strcmp(argv[i], "-o"))
{
if ((i + 1) == argc)
{
free(options);
return NULL;
}
options->out_file = argv[i + 1];
i++;
continue;
}
if (!strcmp(argv[i], "--debug") || !strcmp(argv[i], "-d") || !strcmp(argv[i], "-v"))
{
options->debug = 1;
}
if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
{
free(options);
return NULL;
}
}
if (!options->in_file /*|| !options->out_file */ )
{
free(options);
return NULL;
}
return options;
}
void print_usage()
{
printf("Usage: plistutil -i|--infile in_file.plist -o|--outfile out_file.plist [--debug]\n");
printf("\n");
printf("\t-i or --infile: The file to read in.\n");
printf("\t-o or --outfile: The file to convert to.\n");
printf("\t-d, -v or --debug: Provide extended debug information.\n\n");
printf("Usage: plistutil -i|--infile in_file.plist -o|--outfile out_file.plist [--debug]\n");
printf("\n");
printf("\t-i or --infile: The file to read in.\n");
printf("\t-o or --outfile: The file to convert to.\n");
printf("\t-d, -v or --debug: Provide extended debug information.\n\n");
}
......@@ -8,20 +8,21 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* 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 {
char *in_file, *out_file;
uint8_t debug, in_fmt, out_fmt;
typedef struct _options
{
char *in_file, *out_file;
uint8_t debug, in_fmt, out_fmt;
} Options;
Options *parse_arguments(int argc, char *argv[]);
......
......@@ -7,15 +7,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
......@@ -37,7 +37,7 @@ Array::Array(plist_t node, Node* parent) : Structure(parent)
for (uint32_t i = 0; i < size; i++)
{
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) );
}
}
......@@ -50,7 +50,7 @@ Array::Array(PList::Array& a) : Structure()
for (uint32_t i = 0; i < size; i++)
{
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) );
}
}
......@@ -60,7 +60,7 @@ Array& Array::operator=(PList::Array& a)
plist_free(_node);
for (unsigned int it = 0; it < _array.size(); it++)
{
delete _array.at(it);
delete _array.at(it);
}
_array.clear();
......@@ -69,7 +69,7 @@ Array& Array::operator=(PList::Array& a)
for (uint32_t i = 0; i < size; i++)
{
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) );
}
return *this;
......@@ -77,11 +77,11 @@ Array& Array::operator=(PList::Array& a)
Array::~Array()
{
for (unsigned int it = 0; it < _array.size(); it++)
{
delete (_array.at(it));
}
_array.clear();
for (unsigned int it = 0; it < _array.size(); it++)
{
delete (_array.at(it));
}
_array.clear();
}
Node* Array::Clone()
......@@ -98,10 +98,10 @@ void Array::Append(Node* node)
{
if (node)
{
Node* clone = node->Clone();
Node* clone = node->Clone();
clone->SetParent(this);
plist_array_append_item(_node, clone->GetPlist());
_array.push_back(clone);
plist_array_append_item(_node, clone->GetPlist());
_array.push_back(clone);
}
}
......@@ -109,12 +109,12 @@ void Array::Insert(Node* node, unsigned int pos)
{
if (node)
{
Node* clone = node->Clone();
Node* clone = node->Clone();
clone->SetParent(this);
plist_array_insert_item(_node, clone->GetPlist(), pos);
std::vector<Node*>::iterator it = _array.begin();
it += pos;
_array.insert(it, clone);
plist_array_insert_item(_node, clone->GetPlist(), pos);
std::vector<Node*>::iterator it = _array.begin();
it += pos;
_array.insert(it, clone);
}
}
......@@ -122,12 +122,12 @@ void Array::Remove(Node* node)
{
if (node)
{
uint32_t pos = plist_array_get_item_index(node->GetPlist());
plist_array_remove_item(_node, pos);
std::vector<Node*>::iterator it = _array.begin();
it += pos;
_array.erase(it);
delete node;
uint32_t pos = plist_array_get_item_index(node->GetPlist());
plist_array_remove_item(_node, pos);
std::vector<Node*>::iterator it = _array.begin();
it += pos;
_array.erase(it);
delete node;
}
}
......
......@@ -7,15 +7,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
......
......@@ -7,15 +7,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
......
......@@ -7,15 +7,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
......
......@@ -7,15 +7,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
......@@ -41,11 +41,11 @@ Dictionary::Dictionary(plist_t node, Node* parent) : Structure(parent)
while (subnode)
{
_map[std::string(key)] = Utils::FromPlist(subnode, this);
subnode = NULL;
free(key);
key = NULL;
plist_dict_next_item(_node, it, &key, &subnode);
subnode = NULL;
free(key);
key = NULL;
plist_dict_next_item(_node, it, &key, &subnode);
}
free(it);
}
......@@ -54,8 +54,8 @@ Dictionary::Dictionary(PList::Dictionary& d) : Structure()
{
for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++)
{
plist_free(it->second->GetPlist());
delete it->second;
plist_free(it->second->GetPlist());
delete it->second;
}
_map.clear();
......@@ -69,11 +69,11 @@ Dictionary::Dictionary(PList::Dictionary& d) : Structure()
while (subnode)
{
_map[std::string(key)] = Utils::FromPlist(subnode, this);
subnode = NULL;
free(key);
key = NULL;
plist_dict_next_item(_node, it, NULL, &subnode);
subnode = NULL;
free(key);
key = NULL;
plist_dict_next_item(_node, it, NULL, &subnode);
}
free(it);
}
......@@ -82,8 +82,8 @@ Dictionary& Dictionary::operator=(PList::Dictionary& d)
{
for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++)
{
plist_free(it->second->GetPlist());
delete it->second;
plist_free(it->second->GetPlist());
delete it->second;
}
_map.clear();
......@@ -97,11 +97,11 @@ Dictionary& Dictionary::operator=(PList::Dictionary& d)
while (subnode)
{
_map[std::string(key)] = Utils::FromPlist(subnode, this);
subnode = NULL;
free(key);
key = NULL;
plist_dict_next_item(_node, it, NULL, &subnode);
subnode = NULL;
free(key);
key = NULL;
plist_dict_next_item(_node, it, NULL, &subnode);
}
free(it);
return *this;
......@@ -111,8 +111,8 @@ Dictionary::~Dictionary()
{
for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++)
{
plist_free(it->second->GetPlist());
delete it->second;
plist_free(it->second->GetPlist());
delete it->second;
}
_map.clear();
}
......@@ -146,12 +146,12 @@ Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node)
{
if (node)
{
Node* clone = node->Clone();
Node* clone = node->Clone();
clone->SetParent(this);
plist_dict_insert_item(_node, key.c_str(), clone->GetPlist());
delete _map[key];
_map[key] = clone;
return _map.find(key);
plist_dict_insert_item(_node, key.c_str(), clone->GetPlist());
delete _map[key];
_map[key] = clone;
return _map.find(key);
}
return iterator(NULL);
}
......@@ -160,21 +160,21 @@ void Dictionary::Remove(Node* node)
{
if (node)
{
char* key = NULL;
plist_dict_get_item_key(node->GetPlist(), &key);
plist_dict_remove_item(_node, key);
std::string skey = key;
free(key);
_map.erase(skey);
delete node;
char* key = NULL;
plist_dict_get_item_key(node->GetPlist(), &key);
plist_dict_remove_item(_node, key);
std::string skey = key;
free(key);
_map.erase(skey);
delete node;
}
}
void Dictionary::Remove(const std::string& key)
{
plist_dict_remove_item(_node, key.c_str());
delete _map[key];
_map.erase(key);
plist_dict_remove_item(_node, key.c_str());
delete _map[key];
_map.erase(key);
}
};
......@@ -7,15 +7,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
......
......@@ -7,15 +7,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
......@@ -36,36 +36,37 @@ Node::Node(plist_t node, Node* parent) : _node(node), _parent(parent)
Node::Node(plist_type type, Node* parent) : _parent(parent)
{
_node = NULL;
switch(type) {
case PLIST_BOOLEAN:
_node = plist_new_bool(0);
break;
case PLIST_UINT:
_node = plist_new_uint(0);
break;
case PLIST_REAL:
_node = plist_new_real(0.);
break;
case PLIST_STRING:
_node = plist_new_string("");
break;
case PLIST_DATA:
_node = plist_new_data(NULL,0);
break;
case PLIST_DATE:
_node = plist_new_date(0,0);
break;
case PLIST_ARRAY:
_node = plist_new_array();
break;
case PLIST_DICT:
_node = plist_new_dict();
break;
case PLIST_KEY:
case PLIST_NONE:
default:
break;
switch (type)
{
case PLIST_BOOLEAN:
_node = plist_new_bool(0);
break;
case PLIST_UINT:
_node = plist_new_uint(0);
break;
case PLIST_REAL:
_node = plist_new_real(0.);
break;
case PLIST_STRING:
_node = plist_new_string("");
break;
case PLIST_DATA:
_node = plist_new_data(NULL,0);
break;
case PLIST_DATE:
_node = plist_new_date(0,0);
break;
case PLIST_ARRAY:
_node = plist_new_array();
break;
case PLIST_DICT:
_node = plist_new_dict();
break;
case PLIST_KEY:
case PLIST_NONE:
default:
break;
}
}
......@@ -80,7 +81,7 @@ plist_type Node::GetType()
{
if (_node)
{
return plist_get_node_type(_node);
return plist_get_node_type(_node);
}
return PLIST_NONE;
}
......
......@@ -7,15 +7,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
......
......@@ -7,15 +7,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
......
......@@ -7,15 +7,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
......@@ -41,11 +41,11 @@ uint32_t Structure::GetSize()
plist_type type = plist_get_node_type(_node);
if (type == PLIST_ARRAY)
{
size = plist_array_get_size(_node);
size = plist_array_get_size(_node);
}
else if (type == PLIST_DICT)
{
size = plist_dict_get_size(_node);
size = plist_dict_get_size(_node);
}
return size;
}
......
......@@ -7,15 +7,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
......@@ -38,36 +38,36 @@ Node* Utils::FromPlist(plist_t node, Node* parent)
if (node)
{
plist_type type = plist_get_node_type(node);
switch(type)
{
case PLIST_DICT:
ret = new Dictionary(node, parent);
break;
case PLIST_ARRAY:
ret = new Array(node, parent);
break;
case PLIST_BOOLEAN:
ret = new Boolean(node, parent);
break;
case PLIST_UINT:
ret = new Integer(node, parent);
break;
case PLIST_REAL:
ret = new Real(node, parent);
break;
case PLIST_STRING:
ret = new String(node, parent);
break;
case PLIST_DATE:
ret = new Date(node, parent);
break;
case PLIST_DATA:
ret = new Data(node, parent);
break;
default:
plist_free(node);
break;
}
switch (type)
{
case PLIST_DICT:
ret = new Dictionary(node, parent);
break;
case PLIST_ARRAY:
ret = new Array(node, parent);
break;
case PLIST_BOOLEAN:
ret = new Boolean(node, parent);
break;
case PLIST_UINT:
ret = new Integer(node, parent);
break;
case PLIST_REAL:
ret = new Real(node, parent);
break;
case PLIST_STRING:
ret = new String(node, parent);
break;
case PLIST_DATE:
ret = new Date(node, parent);
break;
case PLIST_DATA:
ret = new Data(node, parent);
break;
default:
plist_free(node);
break;
}
}
return ret;
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLIST_H
......@@ -35,17 +35,19 @@
#endif
struct plist_data_s {
union {
char boolval;
uint64_t intval;
double realval;
char *strval;
uint8_t *buff;
GTimeVal timeval;
};
uint64_t length;
plist_type type;
struct plist_data_s
{
union
{
char boolval;
uint64_t intval;
double realval;
char *strval;
uint8_t *buff;
GTimeVal timeval;
};
uint64_t length;
plist_type type;
};
typedef struct plist_data_s *plist_data_t;
......
This diff is collapsed.
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
......@@ -33,110 +33,114 @@
char compare_plist(plist_t node_l, plist_t node_r)
{
plist_t cur_l = NULL;
plist_t cur_r = NULL;
int res = 1;
plist_t cur_l = NULL;
plist_t cur_r = NULL;
int res = 1;
cur_l = plist_get_first_child(node_l);
cur_r = plist_get_first_child(node_r);
cur_l = plist_get_first_child(node_l);
cur_r = plist_get_first_child(node_r);
if ( (!cur_l && cur_r) || (cur_l && !cur_r))
return 0;
if ( (!cur_l && cur_r) || (cur_l && !cur_r))
return 0;
if ( !cur_l && !cur_r )
return plist_compare_node_value( node_l, node_r );
if ( !cur_l && !cur_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)))
return res;
if (!(res = compare_plist(cur_l, cur_r)))
return res;
cur_l = plist_get_next_sibling(cur_l);
cur_r = plist_get_next_sibling(cur_r);
if ( (!cur_l && cur_r) || (cur_l && !cur_r))
return 0;
}
cur_l = plist_get_next_sibling(cur_l);
cur_r = plist_get_next_sibling(cur_r);
if ( (!cur_l && cur_r) || (cur_l && !cur_r))
return 0;
}
return res;
return res;
}
int main(int argc, char *argv[])
{
FILE *iplist1 = NULL;
FILE *iplist2 = NULL;
plist_t root_node1 = NULL;
plist_t root_node2 = NULL;
char *plist_1 = NULL;
char *plist_2 = NULL;
int size_in1 = 0;
int size_in2 = 0;
char *file_in1 = NULL;
char *file_in2 = NULL;
int res = 0;
struct stat *filestats1 = (struct stat *) malloc(sizeof(struct stat));
struct stat *filestats2 = (struct stat *) malloc(sizeof(struct stat));
if (argc!= 3) {
printf("Wrong input\n");
return 1;
}
file_in1 = argv[1];
file_in2 = argv[2];
//read input file
iplist1 = fopen(file_in1, "rb");
iplist2 = fopen(file_in2, "rb");
if (!iplist1 || !iplist2) {
printf("File does not exists\n");
return 2;
}
stat(file_in1, filestats1);
stat(file_in2, filestats2);
size_in1 = filestats1->st_size;
size_in2 = filestats2->st_size;
plist_1 = (char *) malloc(sizeof(char) * (size_in1 + 1));
plist_2 = (char *) malloc(sizeof(char) * (size_in2 + 1));
fread(plist_1, sizeof(char), size_in1, iplist1);
fread(plist_2, sizeof(char), size_in2, iplist2);
fclose(iplist1);
fclose(iplist2);
if (memcmp(plist_1, "bplist00", 8) == 0)
plist_from_bin(plist_1, size_in1, &root_node1);
else
plist_from_xml(plist_1, size_in1, &root_node1);
if (memcmp(plist_2, "bplist00", 8) == 0)
plist_from_bin(plist_2, size_in2, &root_node2);
else
plist_from_xml(plist_2, size_in2, &root_node2);
if (!root_node1 || !root_node2) {
printf("PList parsing failed\n");
return 3;
}
else
printf("PList parsing succeeded\n");
res = compare_plist(root_node1, root_node2);
plist_free(root_node1);
plist_free(root_node2);
free(plist_1);
free(plist_2);
free(filestats1);
free(filestats2);
return !res;
FILE *iplist1 = NULL;
FILE *iplist2 = NULL;
plist_t root_node1 = NULL;
plist_t root_node2 = NULL;
char *plist_1 = NULL;
char *plist_2 = NULL;
int size_in1 = 0;
int size_in2 = 0;
char *file_in1 = NULL;
char *file_in2 = NULL;
int res = 0;
struct stat *filestats1 = (struct stat *) malloc(sizeof(struct stat));
struct stat *filestats2 = (struct stat *) malloc(sizeof(struct stat));
if (argc!= 3)
{
printf("Wrong input\n");
return 1;
}
file_in1 = argv[1];
file_in2 = argv[2];
//read input file
iplist1 = fopen(file_in1, "rb");
iplist2 = fopen(file_in2, "rb");
if (!iplist1 || !iplist2)
{
printf("File does not exists\n");
return 2;
}
stat(file_in1, filestats1);
stat(file_in2, filestats2);
size_in1 = filestats1->st_size;
size_in2 = filestats2->st_size;
plist_1 = (char *) malloc(sizeof(char) * (size_in1 + 1));
plist_2 = (char *) malloc(sizeof(char) * (size_in2 + 1));
fread(plist_1, sizeof(char), size_in1, iplist1);
fread(plist_2, sizeof(char), size_in2, iplist2);
fclose(iplist1);
fclose(iplist2);
if (memcmp(plist_1, "bplist00", 8) == 0)
plist_from_bin(plist_1, size_in1, &root_node1);
else
plist_from_xml(plist_1, size_in1, &root_node1);
if (memcmp(plist_2, "bplist00", 8) == 0)
plist_from_bin(plist_2, size_in2, &root_node2);
else
plist_from_xml(plist_2, size_in2, &root_node2);
if (!root_node1 || !root_node2)
{
printf("PList parsing failed\n");
return 3;
}
else
printf("PList parsing succeeded\n");
res = compare_plist(root_node1, root_node2);
plist_free(root_node1);
plist_free(root_node2);
free(plist_1);
free(plist_2);
free(filestats1);
free(filestats2);
return !res;
}
......@@ -8,15 +8,15 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library 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
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
......@@ -34,95 +34,103 @@
int main(int argc, char *argv[])
{
FILE *iplist = NULL;
FILE *oplist = NULL;
plist_t root_node1 = NULL;
plist_t root_node2 = NULL;
char *plist_xml = NULL;
char *plist_xml2 = NULL;
char *plist_bin = NULL;
int size_in = 0;
int size_out = 0;
int size_out2 = 0;
char *file_in = NULL;
struct stat *filestats = (struct stat *) malloc(sizeof(struct stat));
if (argc!= 2) {
printf("Wrong input\n");
return 1;
}
file_in = argv[1];
//read input file
iplist = fopen(file_in, "rb");
if (!iplist) {
printf("File does not exists\n");
return 2;
}
printf("File %s is open\n", file_in);
stat(file_in, filestats);
size_in = filestats->st_size;
plist_xml = (char *) malloc(sizeof(char) * (size_in + 1));
fread(plist_xml, sizeof(char), size_in, iplist);
fclose(iplist);
//convert one format to another
plist_from_xml(plist_xml, size_in, &root_node1);
if (!root_node1) {
printf("PList XML parsing failed\n");
return 3;
}
else
printf("PList XML parsing succeeded\n");
plist_to_bin(root_node1, &plist_bin, &size_out);
if (!plist_bin) {
printf("PList BIN writing failed\n");
return 4;
}
else
printf("PList BIN writing succeeded\n");
plist_from_bin(plist_bin, size_out, &root_node2);
if (!root_node2) {
printf("PList BIN parsing failed\n");
return 5;
}
else
printf("PList BIN parsing succeeded\n");
plist_to_xml(root_node2, &plist_xml2, &size_out2);
if (!plist_xml2) {
printf("PList XML writing failed\n");
return 8;
}
else
printf("PList XML writing succeeded\n");
if (plist_xml2) {
FILE *oplist = NULL;
char file_out[512];
sprintf(file_out, "%s.out", file_in);
oplist = fopen(file_out, "wb");
fwrite(plist_xml2, size_out2, sizeof(char), oplist);
fclose(oplist);
}
plist_free(root_node1);
plist_free(root_node2);
free(plist_bin);
free(plist_xml);
free(plist_xml2);
free(filestats);
if (size_in != size_out2) {
printf("Size of input and output is different\n");
printf("Input size : %i\n", size_in);
printf("Output size : %i\n", size_out2);
}
//success
return 0;
FILE *iplist = NULL;
FILE *oplist = NULL;
plist_t root_node1 = NULL;
plist_t root_node2 = NULL;
char *plist_xml = NULL;
char *plist_xml2 = NULL;
char *plist_bin = NULL;
int size_in = 0;
int size_out = 0;
int size_out2 = 0;
char *file_in = NULL;
struct stat *filestats = (struct stat *) malloc(sizeof(struct stat));
if (argc!= 2)
{
printf("Wrong input\n");
return 1;
}
file_in = argv[1];
//read input file
iplist = fopen(file_in, "rb");
if (!iplist)
{
printf("File does not exists\n");
return 2;
}
printf("File %s is open\n", file_in);
stat(file_in, filestats);
size_in = filestats->st_size;
plist_xml = (char *) malloc(sizeof(char) * (size_in + 1));
fread(plist_xml, sizeof(char), size_in, iplist);
fclose(iplist);
//convert one format to another
plist_from_xml(plist_xml, size_in, &root_node1);
if (!root_node1)
{
printf("PList XML parsing failed\n");
return 3;
}
else
printf("PList XML parsing succeeded\n");
plist_to_bin(root_node1, &plist_bin, &size_out);
if (!plist_bin)
{
printf("PList BIN writing failed\n");
return 4;
}
else
printf("PList BIN writing succeeded\n");
plist_from_bin(plist_bin, size_out, &root_node2);
if (!root_node2)
{
printf("PList BIN parsing failed\n");
return 5;
}
else
printf("PList BIN parsing succeeded\n");
plist_to_xml(root_node2, &plist_xml2, &size_out2);
if (!plist_xml2)
{
printf("PList XML writing failed\n");
return 8;
}
else
printf("PList XML writing succeeded\n");
if (plist_xml2)
{
FILE *oplist = NULL;
char file_out[512];
sprintf(file_out, "%s.out", file_in);
oplist = fopen(file_out, "wb");
fwrite(plist_xml2, size_out2, sizeof(char), oplist);
fclose(oplist);
}
plist_free(root_node1);
plist_free(root_node2);
free(plist_bin);
free(plist_xml);
free(plist_xml2);
free(filestats);
if (size_in != size_out2)
{
printf("Size of input and output is different\n");
printf("Input size : %i\n", size_in);
printf("Output size : %i\n", size_out2);
}
//success
return 0;
}
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