summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2018-02-22 16:40:20 -0800
committerVito Caputo <vcaputo@pengaru.com>2018-02-22 16:40:20 -0800
commitdde6c5e93e26f6706cd04745928ae9ad5dddfc9f (patch)
treee382a61e4af0016637efc14a05d5aa39d091e303
parent7608e85f127faf0e09b1f935654baf57b59f717f (diff)
fb,settings,drm_fb,sd_fb: const settings_t readers
The fb_ops entrypoints and their descendants are purely readers of the settings, so constify their settings_t instances and the operative functions which only read settings.
-rw-r--r--src/drm_fb.c4
-rw-r--r--src/fb.h4
-rw-r--r--src/sdl_fb.c4
-rw-r--r--src/settings.c6
-rw-r--r--src/settings.h6
5 files changed, 12 insertions, 12 deletions
diff --git a/src/drm_fb.c b/src/drm_fb.c
index 855fce1..6599d9d 100644
--- a/src/drm_fb.c
+++ b/src/drm_fb.c
@@ -262,7 +262,7 @@ static setting_desc_t * mode_desc_generator(void *setup_context)
/* setup is called repeatedly as settings is constructed, until 0 is returned. */
/* a negative value is returned on error */
/* positive value indicates another setting is needed, described in next_setting */
-int drm_fb_setup(settings_t *settings, setting_desc_t **next_setting)
+int drm_fb_setup(const settings_t *settings, setting_desc_t **next_setting)
{
drm_fb_setup_t context = {};
setting_desc_generator_t generators[] = {
@@ -314,7 +314,7 @@ static drmModeModeInfo * lookup_mode(drmModeConnector *connector, const char *mo
/* prepare the drm context for use with the supplied settings */
-void * drm_fb_init(settings_t *settings)
+void * drm_fb_init(const settings_t *settings)
{
drm_fb_t *c;
const char *dev;
diff --git a/src/fb.h b/src/fb.h
index 3f313b2..7743b82 100644
--- a/src/fb.h
+++ b/src/fb.h
@@ -30,8 +30,8 @@ typedef struct fb_page_t {
/* Supply this struct to fb_new() with the appropriate context */
typedef struct fb_ops_t {
- int (*setup)(settings_t *settings, setting_desc_t **next);
- void * (*init)(settings_t *settings);
+ int (*setup)(const settings_t *settings, setting_desc_t **next);
+ void * (*init)(const settings_t *settings);
void (*shutdown)(void *context);
int (*acquire)(void *context, void *page);
void (*release)(void *context);
diff --git a/src/sdl_fb.c b/src/sdl_fb.c
index 7047f4a..52cf556 100644
--- a/src/sdl_fb.c
+++ b/src/sdl_fb.c
@@ -21,14 +21,14 @@ struct sdl_fb_page_t {
};
-int sdl_fb_setup(settings_t *settings, setting_desc_t **next_setting)
+int sdl_fb_setup(const settings_t *settings, setting_desc_t **next_setting)
{
/* TODO: window size? fullscreen? vsync? etc. */
return 0;
}
-void * sdl_fb_init(settings_t *settings)
+void * sdl_fb_init(const settings_t *settings)
{
sdl_fb_t *c;
diff --git a/src/settings.c b/src/settings.c
index e958b43..7d87811 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -115,7 +115,7 @@ void settings_free(settings_t *settings)
/* find key= in settings, return dup of value side or NULL if missing */
-const char * settings_get_value(settings_t *settings, const char *key)
+const char * settings_get_value(const settings_t *settings, const char *key)
{
int i;
@@ -132,7 +132,7 @@ const char * settings_get_value(settings_t *settings, const char *key)
/* return positional key from settings */
-const char * settings_get_key(settings_t *settings, unsigned pos)
+const char * settings_get_key(const settings_t *settings, unsigned pos)
{
assert(settings);
@@ -160,7 +160,7 @@ int settings_add_value(settings_t *settings, const char *key, const char *value)
/* returns 0 when input settings are complete */
/* returns 1 when input settings are incomplete, storing the next setting's description needed in *next_setting */
/* returns -errno on error */
-int settings_apply_desc_generators(settings_t *settings, const setting_desc_generator_t generators[], unsigned n_generators, void *setup_context, setting_desc_t **next_setting)
+int settings_apply_desc_generators(const settings_t *settings, const setting_desc_generator_t generators[], unsigned n_generators, void *setup_context, setting_desc_t **next_setting)
{
unsigned i;
setting_desc_t *next;
diff --git a/src/settings.h b/src/settings.h
index 6334faa..fe35b19 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -24,11 +24,11 @@ typedef struct settings_t settings_t;
settings_t * settings_new(const char *settings);
void settings_free(settings_t *settings);
-const char * settings_get_value(settings_t *settings, const char *key);
-const char * settings_get_key(settings_t *settings, unsigned pos);
+const char * settings_get_value(const settings_t *settings, const char *key);
+const char * settings_get_key(const settings_t *settings, unsigned pos);
int settings_add_value(settings_t *settings, const char *key, const char *value);
char * settings_as_arg(const settings_t *settings);
-int settings_apply_desc_generators(settings_t *settings, const setting_desc_generator_t generators[], unsigned n_generators, void *setup_context, setting_desc_t **next_setting);
+int settings_apply_desc_generators(const settings_t *settings, const setting_desc_generator_t generators[], unsigned n_generators, void *setup_context, setting_desc_t **next_setting);
setting_desc_t * setting_desc_new(const char *name, const char *key, const char *regex, const char *preferred, const char *values[], const char *annotations[]);
void setting_desc_free(setting_desc_t *desc);
© All Rights Reserved