Skip to content

Commit

Permalink
Changed char * type variables to xmlChar * type
Browse files Browse the repository at this point in the history
  • Loading branch information
abozhinov444 committed Oct 24, 2019
1 parent 8487db9 commit 5895388
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 39 deletions.
7 changes: 4 additions & 3 deletions firehose.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <libxml/parser.h>
#include <libxml/tree.h>

#include "qdl.h"
#include "ufs.h"
#include "sparse.h"
#include "util.h"

static void xml_setpropf(xmlNode *node, const char *attr, const char *fmt, ...)
{
Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@
*/
#include <errno.h>
#include <string.h>
#include <libxml/parser.h>
#include <libxml/tree.h>

#include "patch.h"
#include "qdl.h"

#include "util.h"

static struct patch *patches;
static struct patch *patches_last;

Expand Down Expand Up @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions patch.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#ifndef __PATCH_H__
#define __PATCH_H__

#include <libxml/tree.h>

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;
};
Expand Down
19 changes: 9 additions & 10 deletions program.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <libxml/parser.h>
#include <libxml/tree.h>

#include "program.h"
#include "qdl.h"

#include "util.h"

static struct program *programes;
static struct program *programes_last;

Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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")) {
Expand Down
7 changes: 4 additions & 3 deletions program.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#ifndef __PROGRAM_H__
#define __PROGRAM_H__

#include <libxml/tree.h>
#include <stdbool.h>
#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;
};
Expand Down
3 changes: 1 addition & 2 deletions qdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <libxml/parser.h>
#include <libxml/tree.h>

#include "qdl.h"
#include "patch.h"
#include "ufs.h"
#include "util.h"

#define MAX_USBFS_BULK_SIZE (16*1024)

Expand Down
4 changes: 0 additions & 4 deletions qdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "patch.h"
#include "program.h"
#include <libxml/tree.h>

struct qdl_device;

Expand All @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions sahara.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include <unistd.h>
#include "qdl.h"

#include "util.h"

struct sahara_pkt {
uint32_t cmd;
uint32_t length;
Expand Down
5 changes: 1 addition & 4 deletions ufs.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@
#include <string.h>
#include <unistd.h>

#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xpath.h>

#include "ufs.h"
#include "qdl.h"
#include "patch.h"
#include "util.h"

struct ufs_common *ufs_common_p;
struct ufs_epilogue *ufs_epilogue_p;
Expand Down
5 changes: 4 additions & 1 deletion ufs.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
#ifndef __UFS_H__
#define __UFS_H__

#include <libxml/tree.h>
#include <stdbool.h>

struct qdl_device;
Expand Down Expand Up @@ -55,7 +57,7 @@ struct ufs_body {
unsigned bLogicalBlockSize;
unsigned bProvisioningType;
unsigned wContextCapabilities;
const char *desc;
xmlChar *desc;

struct ufs_body *next;
};
Expand All @@ -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),
Expand Down
8 changes: 4 additions & 4 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <libxml/parser.h>
#include <libxml/tree.h>

#include "util.h"

#define MIN(x, y) ((x) < (y) ? (x) : (y))

Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down
10 changes: 10 additions & 0 deletions util.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef __UTIL_H__
#define __UTIL_H__

#include <libxml/tree.h>

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

0 comments on commit 5895388

Please sign in to comment.