Skip to content

Commit

Permalink
Constify data tables where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
jblache committed Mar 23, 2010
1 parent a963271 commit ae3db0e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
32 changes: 16 additions & 16 deletions src/db.c
Expand Up @@ -60,7 +60,7 @@ struct col_type_map {
* - the order of the columns in the files table * - the order of the columns in the files table
* - the type and name of the fields in struct media_file_info * - the type and name of the fields in struct media_file_info
*/ */
static struct col_type_map mfi_cols_map[] = static const struct col_type_map mfi_cols_map[] =
{ {
{ mfi_offsetof(id), DB_TYPE_INT }, { mfi_offsetof(id), DB_TYPE_INT },
{ mfi_offsetof(path), DB_TYPE_STRING }, { mfi_offsetof(path), DB_TYPE_STRING },
Expand Down Expand Up @@ -117,7 +117,7 @@ static struct col_type_map mfi_cols_map[] =
* - the order of the columns in the playlists table * - the order of the columns in the playlists table
* - the type and name of the fields in struct playlist_info * - the type and name of the fields in struct playlist_info
*/ */
static struct col_type_map pli_cols_map[] = static const struct col_type_map pli_cols_map[] =
{ {
{ pli_offsetof(id), DB_TYPE_INT }, { pli_offsetof(id), DB_TYPE_INT },
{ pli_offsetof(title), DB_TYPE_STRING }, { pli_offsetof(title), DB_TYPE_STRING },
Expand All @@ -136,7 +136,7 @@ static struct col_type_map pli_cols_map[] =
* - the order of the columns in the files table * - the order of the columns in the files table
* - the name of the fields in struct db_media_file_info * - the name of the fields in struct db_media_file_info
*/ */
static ssize_t dbmfi_cols_map[] = static const ssize_t dbmfi_cols_map[] =
{ {
dbmfi_offsetof(id), dbmfi_offsetof(id),
dbmfi_offsetof(path), dbmfi_offsetof(path),
Expand Down Expand Up @@ -193,7 +193,7 @@ static ssize_t dbmfi_cols_map[] =
* - the order of the columns in the playlists table * - the order of the columns in the playlists table
* - the name of the fields in struct playlist_info * - the name of the fields in struct playlist_info
*/ */
static ssize_t dbpli_cols_map[] = static const ssize_t dbpli_cols_map[] =
{ {
dbpli_offsetof(id), dbpli_offsetof(id),
dbpli_offsetof(title), dbpli_offsetof(title),
Expand All @@ -212,7 +212,7 @@ static ssize_t dbpli_cols_map[] =
* - the order of fields in the Q_GROUPS query * - the order of fields in the Q_GROUPS query
* - the name of the fields in struct group_info * - the name of the fields in struct group_info
*/ */
static ssize_t dbgri_cols_map[] = static const ssize_t dbgri_cols_map[] =
{ {
dbgri_offsetof(itemcount), dbgri_offsetof(itemcount),
dbgri_offsetof(id), dbgri_offsetof(id),
Expand All @@ -225,7 +225,7 @@ static ssize_t dbgri_cols_map[] =
* - the order of the columns in the inotify table * - the order of the columns in the inotify table
* - the name and type of the fields in struct watch_info * - the name and type of the fields in struct watch_info
*/ */
static struct col_type_map wi_cols_map[] = static const struct col_type_map wi_cols_map[] =
{ {
{ wi_offsetof(wd), DB_TYPE_INT }, { wi_offsetof(wd), DB_TYPE_INT },
{ wi_offsetof(cookie), DB_TYPE_INT }, { wi_offsetof(cookie), DB_TYPE_INT },
Expand Down Expand Up @@ -3540,7 +3540,7 @@ struct db_init_query {
char *desc; char *desc;
}; };


static struct db_init_query db_init_queries[] = static const struct db_init_query db_init_queries[] =
{ {
{ T_ADMIN, "create table admin" }, { T_ADMIN, "create table admin" },
{ T_FILES, "create table files" }, { T_FILES, "create table files" },
Expand Down Expand Up @@ -3591,7 +3591,7 @@ db_create_tables(void)
} }


static int static int
db_generic_upgrade(struct db_init_query *queries, int nqueries) db_generic_upgrade(const struct db_init_query *queries, int nqueries)
{ {
char *errmsg; char *errmsg;
int i; int i;
Expand Down Expand Up @@ -3631,7 +3631,7 @@ db_generic_upgrade(struct db_init_query *queries, int nqueries)
#define U_V2_SCVER \ #define U_V2_SCVER \
"UPDATE admin SET value = '2' WHERE key = 'schema_version';" "UPDATE admin SET value = '2' WHERE key = 'schema_version';"


static struct db_init_query db_upgrade_v2_queries[] = static const struct db_init_query db_upgrade_v2_queries[] =
{ {
{ U_V2_FILES, "upgrade table files" }, { U_V2_FILES, "upgrade table files" },
{ U_V2_RESCAN, "force library rescan" }, { U_V2_RESCAN, "force library rescan" },
Expand All @@ -3646,7 +3646,7 @@ static struct db_init_query db_upgrade_v2_queries[] =
#define U_V3_SCVER \ #define U_V3_SCVER \
"UPDATE admin SET value = '3' WHERE key = 'schema_version';" "UPDATE admin SET value = '3' WHERE key = 'schema_version';"


static struct db_init_query db_upgrade_v3_queries[] = static const struct db_init_query db_upgrade_v3_queries[] =
{ {
{ U_V3_FILES, "upgrade table files" }, { U_V3_FILES, "upgrade table files" },
{ U_V3_SCVER, "set schema_version to 3" }, { U_V3_SCVER, "set schema_version to 3" },
Expand Down Expand Up @@ -3675,7 +3675,7 @@ static struct db_init_query db_upgrade_v3_queries[] =
#define U_V4_SCVER \ #define U_V4_SCVER \
"UPDATE admin SET value = '4' WHERE key = 'schema_version';" "UPDATE admin SET value = '4' WHERE key = 'schema_version';"


static struct db_init_query db_upgrade_v4_queries[] = static const struct db_init_query db_upgrade_v4_queries[] =
{ {
{ U_V4_PLAYLISTS, "upgrade table playlists" }, { U_V4_PLAYLISTS, "upgrade table playlists" },
{ U_V4_PL1, "update playlist 1" }, { U_V4_PL1, "update playlist 1" },
Expand All @@ -3696,7 +3696,7 @@ static struct db_init_query db_upgrade_v4_queries[] =
#define U_V5_SCVER \ #define U_V5_SCVER \
"UPDATE admin SET value = '5' WHERE key = 'schema_version';" "UPDATE admin SET value = '5' WHERE key = 'schema_version';"


static struct db_init_query db_upgrade_v5_queries[] = static const struct db_init_query db_upgrade_v5_queries[] =
{ {
{ U_V5_FIXPL, "fix 'Movies' smart playlist" }, { U_V5_FIXPL, "fix 'Movies' smart playlist" },
{ U_V5_RESCAN, "force library rescan" }, { U_V5_RESCAN, "force library rescan" },
Expand All @@ -3718,7 +3718,7 @@ static struct db_init_query db_upgrade_v5_queries[] =
#define U_V6_SCVER \ #define U_V6_SCVER \
"UPDATE admin SET value = '6' WHERE key = 'schema_version';" "UPDATE admin SET value = '6' WHERE key = 'schema_version';"


static struct db_init_query db_upgrade_v6_queries[] = static const struct db_init_query db_upgrade_v6_queries[] =
{ {
{ U_V6_PAIRINGS, "create pairings table" }, { U_V6_PAIRINGS, "create pairings table" },
{ U_V6_PAIRINGGUID, "create pairing guid index" }, { U_V6_PAIRINGGUID, "create pairing guid index" },
Expand All @@ -3736,7 +3736,7 @@ static struct db_init_query db_upgrade_v6_queries[] =
#define U_V7_SCVER \ #define U_V7_SCVER \
"UPDATE admin SET value = '7' WHERE key = 'schema_version';" "UPDATE admin SET value = '7' WHERE key = 'schema_version';"


static struct db_init_query db_upgrade_v7_queries[] = static const struct db_init_query db_upgrade_v7_queries[] =
{ {
{ U_V7_FILES, "upgrade table files" }, { U_V7_FILES, "upgrade table files" },
{ U_V7_RESCAN, "force library rescan" }, { U_V7_RESCAN, "force library rescan" },
Expand Down Expand Up @@ -3769,7 +3769,7 @@ static struct db_init_query db_upgrade_v7_queries[] =
#define U_V8_SCVER \ #define U_V8_SCVER \
"UPDATE admin SET value = '8' WHERE key = 'schema_version';" "UPDATE admin SET value = '8' WHERE key = 'schema_version';"


static struct db_init_query db_upgrade_v8_queries[] = static const struct db_init_query db_upgrade_v8_queries[] =
{ {
{ U_V8_GROUPS, "create groups table" }, { U_V8_GROUPS, "create groups table" },
{ U_V8_TRG1, "create trigger update_groups_new_file" }, { U_V8_TRG1, "create trigger update_groups_new_file" },
Expand All @@ -3792,7 +3792,7 @@ static struct db_init_query db_upgrade_v8_queries[] =
#define U_V9_SCVER \ #define U_V9_SCVER \
"UPDATE admin SET value = '9' WHERE key = 'schema_version';" "UPDATE admin SET value = '9' WHERE key = 'schema_version';"


static struct db_init_query db_upgrade_v9_queries[] = static const struct db_init_query db_upgrade_v9_queries[] =
{ {
{ U_V9_INOTIFY1, "drop table inotify" }, { U_V9_INOTIFY1, "drop table inotify" },
{ U_V9_INOTIFY2, "create new table inotify" }, { U_V9_INOTIFY2, "create new table inotify" },
Expand Down
12 changes: 6 additions & 6 deletions src/filescanner_ffmpeg.c
Expand Up @@ -56,7 +56,7 @@ struct metadata_map {
}; };


/* Lookup is case-insensitive, first occurrence takes precedence */ /* Lookup is case-insensitive, first occurrence takes precedence */
static struct metadata_map md_map_generic[] = static const struct metadata_map md_map_generic[] =
{ {
{ "title", 0, mfi_offsetof(title) }, { "title", 0, mfi_offsetof(title) },
{ "artist", 0, mfi_offsetof(artist) }, { "artist", 0, mfi_offsetof(artist) },
Expand All @@ -82,7 +82,7 @@ static struct metadata_map md_map_generic[] =
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };


static struct metadata_map md_map_tv[] = static const struct metadata_map md_map_tv[] =
{ {
{ "stik", 1, mfi_offsetof(media_kind) }, { "stik", 1, mfi_offsetof(media_kind) },
{ "show", 0, mfi_offsetof(tv_series_name) }, { "show", 0, mfi_offsetof(tv_series_name) },
Expand All @@ -103,7 +103,7 @@ static struct metadata_map md_map_tv[] =
* the changes listed above will be generally available. The more entries in the * the changes listed above will be generally available. The more entries in the
* map, the slower the filescanner gets. * map, the slower the filescanner gets.
*/ */
static struct metadata_map md_map_id3[] = static const struct metadata_map md_map_id3[] =
{ {
{ "TT2", 0, mfi_offsetof(title) }, /* ID3v2.2 */ { "TT2", 0, mfi_offsetof(title) }, /* ID3v2.2 */
{ "TIT2", 0, mfi_offsetof(title) }, /* ID3v2.3 */ { "TIT2", 0, mfi_offsetof(title) }, /* ID3v2.3 */
Expand All @@ -130,7 +130,7 @@ static struct metadata_map md_map_id3[] =




static int static int
extract_metadata_core(struct media_file_info *mfi, AVMetadata *md, struct metadata_map *md_map) extract_metadata_core(struct media_file_info *mfi, AVMetadata *md, const struct metadata_map *md_map)
{ {
AVMetadataTag *mdt; AVMetadataTag *mdt;
char **strval; char **strval;
Expand Down Expand Up @@ -196,7 +196,7 @@ extract_metadata_core(struct media_file_info *mfi, AVMetadata *md, struct metada
} }


static int static int
extract_metadata(struct media_file_info *mfi, AVMetadata *md, struct metadata_map *extra_md_map) extract_metadata(struct media_file_info *mfi, AVMetadata *md, const struct metadata_map *extra_md_map)
{ {
int mdcount; int mdcount;
int extra; int extra;
Expand All @@ -221,7 +221,7 @@ int
scan_metadata_ffmpeg(char *file, struct media_file_info *mfi) scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)
{ {
AVFormatContext *ctx; AVFormatContext *ctx;
struct metadata_map *extra_md_map; const struct metadata_map *extra_md_map;
enum CodecID codec_id; enum CodecID codec_id;
enum CodecID video_codec_id; enum CodecID video_codec_id;
enum CodecID audio_codec_id; enum CodecID audio_codec_id;
Expand Down
2 changes: 1 addition & 1 deletion src/httpd.c
Expand Up @@ -99,7 +99,7 @@ struct stream_ctx {
}; };




static struct content_type_map ext2ctype[] = static const struct content_type_map ext2ctype[] =
{ {
{ ".html", "text/html; charset=utf-8" }, { ".html", "text/html; charset=utf-8" },
{ ".xml", "text/xml; charset=utf-8" }, { ".xml", "text/xml; charset=utf-8" },
Expand Down
4 changes: 2 additions & 2 deletions src/httpd_rsp.c
Expand Up @@ -68,7 +68,7 @@ struct uri_map {
void (*handler)(struct evhttp_request *req, char **uri, struct evkeyvalq *query); void (*handler)(struct evhttp_request *req, char **uri, struct evkeyvalq *query);
}; };


static struct field_map pl_fields[] = static const struct field_map pl_fields[] =
{ {
{ "id", dbpli_offsetof(id), F_ALWAYS }, { "id", dbpli_offsetof(id), F_ALWAYS },
{ "title", dbpli_offsetof(title), F_FULL | F_BROWSE | F_DETAILED }, { "title", dbpli_offsetof(title), F_FULL | F_BROWSE | F_DETAILED },
Expand All @@ -81,7 +81,7 @@ static struct field_map pl_fields[] =
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };


static struct field_map rsp_fields[] = static const struct field_map rsp_fields[] =
{ {
{ "id", dbmfi_offsetof(id), F_ALWAYS }, { "id", dbmfi_offsetof(id), F_ALWAYS },
{ "path", dbmfi_offsetof(path), F_DETAILED }, { "path", dbmfi_offsetof(path), F_DETAILED },
Expand Down

0 comments on commit ae3db0e

Please sign in to comment.