From: Sven Wegener Date: Sat, 31 Jan 2015 19:16:44 +0000 (+0100) Subject: filebundle: constify X-Git-Tag: v4.2.1~1547 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=960c362f6f8d1fc9c40ec60c3a76707c0b4b87c9;p=thirdparty%2Ftvheadend.git filebundle: constify Signed-off-by: Sven Wegener --- diff --git a/src/filebundle.c b/src/filebundle.c index 5e800a855..628c4d3cf 100644 --- a/src/filebundle.c +++ b/src/filebundle.c @@ -43,7 +43,7 @@ struct filebundle_dir } d; struct { const filebundle_entry_t *root; - filebundle_entry_t *cur; + const filebundle_entry_t *cur; } b; }; }; @@ -142,7 +142,7 @@ fb_dir *fb_opendir ( const char *path ) char *tmp1, *tmp2, *tmp3 = NULL; tmp1 = strdup(path); tmp2 = strtok_r(tmp1, "/", &tmp3); - filebundle_entry_t *fb = filebundle_root; + const filebundle_entry_t *fb = filebundle_root; while (fb && tmp2) { if (fb->type == FB_DIR && !strcmp(fb->name, tmp2)) { tmp2 = strtok_r(NULL, "/", &tmp3); diff --git a/src/filebundle.h b/src/filebundle.h index 006323434..77b6edfa4 100644 --- a/src/filebundle.h +++ b/src/filebundle.h @@ -44,11 +44,11 @@ typedef struct filebundle_entry { enum filebundle_type type; const char *name; - struct filebundle_entry *next; + const struct filebundle_entry *next; union { struct { size_t count; - struct filebundle_entry *child; + const struct filebundle_entry *child; } d; struct { const uint8_t *data; @@ -78,7 +78,7 @@ typedef struct filebundle_dir fb_dir; typedef struct filebundle_file fb_file; /* Root of bundle */ -extern filebundle_entry_t *filebundle_root; +extern const filebundle_entry_t * const filebundle_root; /* Miscellaneous */ int fb_stat ( const char *path, struct filebundle_stat *st ); diff --git a/support/mkbundle b/support/mkbundle index 00057095c..1d41d0149 100755 --- a/support/mkbundle +++ b/support/mkbundle @@ -102,7 +102,7 @@ def output_file ( path, name, idx, next = -1 ): outf.write('\n') outf.write('};\n') - outf.write('static filebundle_entry_t filebundle_entry_%06d = {\n' % idx) + outf.write('static const filebundle_entry_t filebundle_entry_%06d = {\n' % idx) outf.write(' .type = FB_FILE,\n') outf.write(' .name = "%s",\n' % name) outf.write(' .next = %s,\n' % n) @@ -120,7 +120,7 @@ def output_dir ( path, name, idx, child, count, next = -1 ): if next >= 0: n = '&filebundle_entry_%06d' % next outf.write('/* DIR: %s %s %d %d %d %d */\n' \ % (path, name, idx, child, count, next)) - outf.write('static filebundle_entry_t filebundle_entry_%06d = {\n' % idx) + outf.write('static const filebundle_entry_t filebundle_entry_%06d = {\n' % idx) outf.write(' .type = FB_DIR,\n') outf.write(' .name = "%s",\n' % name) outf.write(' .next = %s,\n' % n) @@ -172,4 +172,4 @@ outf.write('\n') idx = add_entry(ents) # Output top link -outf.write('filebundle_entry_t *filebundle_root = &filebundle_entry_%06d;\n' % idx) +outf.write('const filebundle_entry_t * const filebundle_root = &filebundle_entry_%06d;\n' % idx)