From 589538806bdb226ae79c68b5710f186555e6d195 Mon Sep 17 00:00:00 2001 From: Atanas Bozhinov Date: Wed, 23 Oct 2019 12:18:30 +0300 Subject: [PATCH] Changed char * type variables to xmlChar * type --- firehose.c | 7 ++++--- patch.c | 7 +++---- patch.h | 10 ++++++---- program.c | 19 +++++++++---------- program.h | 7 ++++--- qdl.c | 3 +-- qdl.h | 4 ---- sahara.c | 2 ++ ufs.c | 5 +---- ufs.h | 5 ++++- util.c | 8 ++++---- util.h | 10 ++++++++++ 12 files changed, 48 insertions(+), 39 deletions(-) create mode 100644 util.h diff --git a/firehose.c b/firehose.c index 95985c7..cf0b6af 100644 --- a/firehose.c +++ b/firehose.c @@ -46,11 +46,11 @@ #include #include #include -#include -#include + #include "qdl.h" #include "ufs.h" #include "sparse.h" +#include "util.h" static void xml_setpropf(xmlNode *node, const char *attr, const char *fmt, ...) { @@ -153,7 +153,8 @@ static int firehose_read(struct qdl_device *qdl, int wait, int (*response_parser for (node = nodes; node; node = node->next) { if (xmlStrcmp(node->name, (xmlChar*)"log") == 0) { firehose_response_log(node); - } else if (xmlStrcmp(node->name, (xmlChar*)"response") == 0) { + } + else if (xmlStrcmp(node->name, (xmlChar*)"response") == 0) { if (!response_parser) fprintf(stderr, "received response with no parser\n"); else diff --git a/patch.c b/patch.c index 5e2815e..445bc99 100644 --- a/patch.c +++ b/patch.c @@ -30,12 +30,11 @@ */ #include #include -#include -#include #include "patch.h" #include "qdl.h" - +#include "util.h" + static struct patch *patches; static struct patch *patches_last; @@ -102,7 +101,7 @@ int patch_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, s int ret; for (patch = patches; patch; patch = patch->next) { - if (strcmp(patch->filename, "DISK")) + if (xmlStrcmp(patch->filename, (const xmlChar *)"DISK")) continue; ret = apply(qdl, patch); diff --git a/patch.h b/patch.h index baade86..108ec2f 100644 --- a/patch.h +++ b/patch.h @@ -1,17 +1,19 @@ #ifndef __PATCH_H__ #define __PATCH_H__ +#include + struct qdl_device; struct patch { unsigned sector_size; unsigned byte_offset; - const char *filename; + xmlChar *filename; unsigned partition; unsigned size_in_bytes; - const char *start_sector; - const char *value; - const char *what; + xmlChar *start_sector; + xmlChar *value; + xmlChar *what; struct patch *next; }; diff --git a/program.c b/program.c index 72764c5..9704f61 100644 --- a/program.c +++ b/program.c @@ -32,12 +32,11 @@ #include #include #include -#include -#include #include "program.h" #include "qdl.h" - +#include "util.h" + static struct program *programes; static struct program *programes_last; @@ -48,7 +47,7 @@ int program_load(const char *program_file) xmlNode *root; xmlDoc *doc; int errors; - const char *sparse_val; + xmlChar *sparse_val; doc = xmlReadFile(program_file, NULL, 0); if (!doc) { @@ -86,11 +85,11 @@ int program_load(const char *program_file) sparse_val = attr_as_string(node, "sparse", &errors); if (!errors) { - if (!strcmp(sparse_val, "true")) + if (!xmlStrcmp(sparse_val, (const xmlChar *)"true")) program->is_sparse = true; else program->is_sparse = false; - free((char *)sparse_val); + xmlFree(sparse_val); } if (programes) { @@ -111,7 +110,7 @@ int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, const char *incdir) { struct program *program; - const char *filename; + char *filename; char tmp[PATH_MAX]; int ret; int fd; @@ -120,7 +119,7 @@ int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, if (!program->filename) continue; - filename = program->filename; + filename = (char *)program->filename; if (incdir) { snprintf(tmp, PATH_MAX, "%s/%s", incdir, filename); if (access(tmp, F_OK) != -1) @@ -156,11 +155,11 @@ int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, int program_find_bootable_partition(void) { struct program *program; - const char *label; + char *label; int part = -ENOENT; for (program = programes; program; program = program->next) { - label = program->label; + label = (char *)program->label; if (!strcmp(label, "xbl") || !strcmp(label, "xbl_a") || !strcmp(label, "sbl1")) { diff --git a/program.h b/program.h index 90b7f94..be81853 100644 --- a/program.h +++ b/program.h @@ -1,18 +1,19 @@ #ifndef __PROGRAM_H__ #define __PROGRAM_H__ +#include #include #include "qdl.h" struct program { unsigned sector_size; unsigned file_offset; - const char *filename; - const char *label; + xmlChar *filename; + xmlChar *label; unsigned num_sectors; unsigned partition; bool is_sparse; - const char *start_sector; + xmlChar *start_sector; struct program *next; }; diff --git a/qdl.c b/qdl.c index 47debd9..c8ebf7b 100644 --- a/qdl.c +++ b/qdl.c @@ -49,12 +49,11 @@ #include #include #include -#include -#include #include "qdl.h" #include "patch.h" #include "ufs.h" +#include "util.h" #define MAX_USBFS_BULK_SIZE (16*1024) diff --git a/qdl.h b/qdl.h index 624e6c0..6a82dd8 100644 --- a/qdl.h +++ b/qdl.h @@ -5,7 +5,6 @@ #include "patch.h" #include "program.h" -#include struct qdl_device; @@ -14,9 +13,6 @@ int qdl_write(struct qdl_device *qdl, const void *buf, size_t len, bool eot); int firehose_run(struct qdl_device *qdl, const char *incdir, const char *storage); int sahara_run(struct qdl_device *qdl, char *prog_mbn); -void print_hex_dump(const char *prefix, const void *buf, size_t len); -unsigned attr_as_unsigned(xmlNode *node, const char *attr, int *errors); -const char *attr_as_string(xmlNode *node, const char *attr, int *errors); extern bool qdl_debug; diff --git a/sahara.c b/sahara.c index 676ac1c..1e0234a 100644 --- a/sahara.c +++ b/sahara.c @@ -46,6 +46,8 @@ #include #include "qdl.h" +#include "util.h" + struct sahara_pkt { uint32_t cmd; uint32_t length; diff --git a/ufs.c b/ufs.c index 1302219..a65a9fb 100644 --- a/ufs.c +++ b/ufs.c @@ -33,13 +33,10 @@ #include #include -#include -#include -#include - #include "ufs.h" #include "qdl.h" #include "patch.h" +#include "util.h" struct ufs_common *ufs_common_p; struct ufs_epilogue *ufs_epilogue_p; diff --git a/ufs.h b/ufs.h index d9b6358..776dbe2 100644 --- a/ufs.h +++ b/ufs.h @@ -28,6 +28,8 @@ */ #ifndef __UFS_H__ #define __UFS_H__ + +#include #include struct qdl_device; @@ -55,7 +57,7 @@ struct ufs_body { unsigned bLogicalBlockSize; unsigned bProvisioningType; unsigned wContextCapabilities; - const char *desc; + xmlChar *desc; struct ufs_body *next; }; @@ -66,6 +68,7 @@ struct ufs_epilogue { }; int ufs_load(const char *ufs_file, bool finalize_provisioning); +void ufs_unload(void); int ufs_provisioning_execute(struct qdl_device *qdl, int (*apply_ufs_common)(struct qdl_device *qdl, struct ufs_common *ufs), int (*apply_ufs_body)(struct qdl_device *qdl, struct ufs_body *ufs), diff --git a/util.c b/util.c index 3a297e8..0d3721d 100644 --- a/util.c +++ b/util.c @@ -32,8 +32,8 @@ #include #include #include -#include -#include + +#include "util.h" #define MIN(x, y) ((x) < (y) ? (x) : (y)) @@ -81,7 +81,7 @@ void print_hex_dump(const char *prefix, const void *buf, size_t len) } } -unsigned attr_as_unsigned(xmlNode *node, const char *attr, int *errors) +unsigned int attr_as_unsigned(xmlNode *node, const char *attr, int *errors) { xmlChar *value; @@ -94,7 +94,7 @@ unsigned attr_as_unsigned(xmlNode *node, const char *attr, int *errors) return (unsigned int) strtoul((char*)value, NULL, 10); } -const char *attr_as_string(xmlNode *node, const char *attr, int *errors) +xmlChar *attr_as_string(xmlNode *node, const char *attr, int *errors) { xmlChar *value; diff --git a/util.h b/util.h new file mode 100644 index 0000000..0e2f9f2 --- /dev/null +++ b/util.h @@ -0,0 +1,10 @@ +#ifndef __UTIL_H__ +#define __UTIL_H__ + +#include + +void print_hex_dump(const char *prefix, const void *buf, size_t len); +unsigned int attr_as_unsigned(xmlNode *node, const char *attr, int *errors); +xmlChar *attr_as_string(xmlNode *node, const char *attr, int *errors); + +#endif \ No newline at end of file