From e610c72a772656ef2c0a730348fccb28b130795c Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Wed, 11 Sep 2002 17:41:07 +0000 Subject: - more programming guidelines in public xine header - make most char pointers const in public api - simpler get_spu_lang / get_audio_lang signature CVS patchset: 2651 CVS date: 2002/09/11 17:41:07 --- src/xine-engine/configfile.c | 55 ++++++++++++++++------------- src/xine-engine/configfile.h | 48 ++++++++++++------------- src/xine-engine/load_plugins.c | 15 ++++---- src/xine-engine/xine.c | 76 +++++++++++++--------------------------- src/xine-engine/xine_interface.c | 36 +++++++++---------- src/xine-engine/xine_internal.h | 8 +++-- 6 files changed, 110 insertions(+), 128 deletions(-) (limited to 'src') diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 907860ca9..9d34b108b 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: configfile.c,v 1.29 2002/09/10 14:06:33 jcdutton Exp $ + * $Id: configfile.c,v 1.30 2002/09/11 17:41:08 guenter Exp $ * * config object (was: file) management - implementation * @@ -46,7 +46,7 @@ * internal utility functions */ -static char *copy_string (char *str) { +static char *copy_string (const char *str) { char *cpy; int len; @@ -60,7 +60,7 @@ static char *copy_string (char *str) { return cpy; } -static cfg_entry_t *xine_config_add (config_values_t *this, char *key) { +static cfg_entry_t *xine_config_add (config_values_t *this, const char *key) { cfg_entry_t *entry; @@ -92,7 +92,7 @@ static cfg_entry_t *xine_config_add (config_values_t *this, char *key) { * external interface */ -static cfg_entry_t *_xine_config_lookup_entry (config_values_t *this, char *key) { +static cfg_entry_t *_xine_config_lookup_entry (config_values_t *this, const char *key) { cfg_entry_t *entry; entry = this->first; @@ -105,9 +105,10 @@ static cfg_entry_t *_xine_config_lookup_entry (config_values_t *this, char *key) static char *_xine_config_register_string (config_values_t *this, - char *key, char *def_value, - char *description, - char *help, + const char *key, + const char *def_value, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data) { @@ -168,9 +169,9 @@ static char *_xine_config_register_string (config_values_t *this, } static int _xine_config_register_num (config_values_t *this, - char *key, int def_value, - char *description, - char *help, + const char *key, int def_value, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data) { @@ -223,9 +224,10 @@ static int _xine_config_register_num (config_values_t *this, } static int _xine_config_register_bool (config_values_t *this, - char *key, int def_value, - char *description, - char *help, + const char *key, + int def_value, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data) { @@ -278,10 +280,11 @@ static int _xine_config_register_bool (config_values_t *this, } static int _xine_config_register_range (config_values_t *this, - char *key, int def_value, + const char *key, + int def_value, int min, int max, - char *description, - char *help, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data) { @@ -333,7 +336,7 @@ static int _xine_config_register_range (config_values_t *this, return entry->num_value; } -static int xine_config_parse_enum (char *str, char **values) { +static int xine_config_parse_enum (const char *str, char **values) { char **value; int i; @@ -365,10 +368,11 @@ static int xine_config_parse_enum (char *str, char **values) { } static int _xine_config_register_enum (config_values_t *this, - char *key, int def_value, + const char *key, + int def_value, char **values, - char *description, - char *help, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data) { @@ -442,7 +446,7 @@ static void xine_config_shallow_copy(xine_cfg_entry_t *dest, cfg_entry_t *src) } static void xine_config_update_num (config_values_t *this, - char *key, int value) { + const char *key, int value) { cfg_entry_t *entry; @@ -480,7 +484,8 @@ static void xine_config_update_num (config_values_t *this, } static void xine_config_update_string (config_values_t *this, - char *key, char *value) { + const char *key, + const char *value) { cfg_entry_t *entry; @@ -521,7 +526,7 @@ static void xine_config_update_string (config_values_t *this, /* * load/save config data from/to afile (e.g. $HOME/.xine/config) */ -void xine_load_config (xine_p xine_ro, char *filename) { +void xine_load_config (xine_p xine_ro, const char *filename) { config_values_t *this = xine_ro->config; FILE *f_config; @@ -580,7 +585,7 @@ void xine_load_config (xine_p xine_ro, char *filename) { } } -void xine_save_config (xine_p xine_ro, char *filename) { +void xine_save_config (xine_p xine_ro, const char *filename) { config_values_t *this = xine_ro->config; FILE *f_config; @@ -696,7 +701,7 @@ static void xine_config_dispose (config_values_t *this) { static void xine_config_unregister_cb (config_values_t *this, - char *key) { + const char *key) { cfg_entry_t *entry; diff --git a/src/xine-engine/configfile.h b/src/xine-engine/configfile.h index e2c17f1b6..d19c70648 100644 --- a/src/xine-engine/configfile.h +++ b/src/xine-engine/configfile.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: configfile.h,v 1.14 2002/09/09 19:24:48 f1rmb Exp $ + * $Id: configfile.h,v 1.15 2002/09/11 17:41:08 guenter Exp $ * * config file management * @@ -65,8 +65,8 @@ struct cfg_entry_s { char **enum_values; /* help info for the user */ - char *description; - char *help; + const char *description; + const char *help; /* user experience level */ int exp_level; @@ -99,60 +99,60 @@ struct config_values_s { */ char* (*register_string) (config_values_t *this, - char *key, - char *def_value, - char *description, - char *help, + const char *key, + const char *def_value, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data); int (*register_range) (config_values_t *this, - char *key, + const char *key, int def_value, int min, int max, - char *description, - char *help, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data); int (*register_enum) (config_values_t *this, - char *key, + const char *key, int def_value, char **values, - char *description, - char *help, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data); int (*register_num) (config_values_t *this, - char *key, + const char *key, int def_value, - char *description, - char *help, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data); int (*register_bool) (config_values_t *this, - char *key, + const char *key, int def_value, - char *description, - char *help, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data); /* convenience function to update range, enum, num and bool values */ - void (*update_num) (config_values_t *this, char *key, int value); + void (*update_num) (config_values_t *this, const char *key, int value); /* convenience function to update string values */ - void (*update_string) (config_values_t *this, char *key, char *value); + void (*update_string) (config_values_t *this, const char *key, const char *value); /* small utility function for enum handling */ - int (*parse_enum) (char *str, char **values); + int (*parse_enum) (const char *str, char **values); /* * lookup config entries @@ -161,12 +161,12 @@ struct config_values_s { * and you changed the value of this item */ - cfg_entry_t* (*lookup_entry) (config_values_t *this, char *key); + cfg_entry_t* (*lookup_entry) (config_values_t *this, const char *key); /* * unregister callback function */ - void (*unregister_callback) (config_values_t *this, char *key); + void (*unregister_callback) (config_values_t *this, const char *key); /* * config values are stored here: diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 5bada58fb..993328f37 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: load_plugins.c,v 1.90 2002/09/09 20:41:51 uid86226 Exp $ + * $Id: load_plugins.c,v 1.91 2002/09/11 17:41:08 guenter Exp $ * * * Load input/demux/audio_out/video_out/codec plugins @@ -597,7 +597,7 @@ const char *const *xine_get_browsable_input_plugin_ids(xine_p this) { return (_xine_get_featured_input_plugin_ids(this, INPUT_CAP_GET_DIR)); } -const char *xine_get_input_plugin_description(xine_p this, char *plugin_id) { +const char *xine_get_input_plugin_description(xine_p this, const char *plugin_id) { plugin_catalog_t *catalog; plugin_node_t *node; @@ -623,7 +623,7 @@ const char *xine_get_input_plugin_description(xine_p this, char *plugin_id) { */ xine_vo_driver_p xine_open_video_driver (xine_p this_ro, - char *id, + const char *id, int visual_type, void *visual) { xine_t *this = (xine_t *)this_ro; @@ -716,7 +716,7 @@ const char *const *xine_list_video_output_plugins (xine_p this) { return catalog->ids; } -xine_ao_driver_p xine_open_audio_driver (xine_p this_ro, char *id, +xine_ao_driver_p xine_open_audio_driver (xine_p this_ro, const char *id, void *data) { xine_t *this = (xine_t *)this_ro; @@ -758,7 +758,8 @@ xine_ao_driver_p xine_open_audio_driver (xine_p this_ro, char *id, * get autoplay mrl list from input plugin */ -const char *const *xine_get_autoplay_mrls (xine_p this, char *plugin_id, int *num_mrls) { +const char *const *xine_get_autoplay_mrls (xine_p this, const char *plugin_id, + int *num_mrls) { plugin_catalog_t *catalog; plugin_node_t *node; @@ -787,8 +788,8 @@ const char *const *xine_get_autoplay_mrls (xine_p this, char *plugin_id, int *nu /* * input plugin mrl browser support */ -const xine_mrl_t *const *xine_get_browse_mrls (xine_p this, char *plugin_id, - char *start_mrl, int *num_mrls) { +const xine_mrl_t *const *xine_get_browse_mrls (xine_p this, const char *plugin_id, + const char *start_mrl, int *num_mrls) { plugin_catalog_t *catalog; plugin_node_t *node; diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 5ef16ffcc..ea58bfc7a 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine.c,v 1.155 2002/09/10 14:07:21 mroi Exp $ + * $Id: xine.c,v 1.156 2002/09/11 17:41:08 guenter Exp $ * * top-level xine functions * @@ -363,7 +363,7 @@ static int find_demuxer(xine_t *this) { return 0; } -int xine_open_internal (xine_t *this, char *mrl) { +int xine_open_internal (xine_t *this, const char *mrl) { printf ("xine_open: mrl '%s'\n", mrl); @@ -467,7 +467,7 @@ int xine_open_internal (xine_t *this, char *mrl) { this->cur_demuxer_plugin->get_identifier()); } -#warning ?? limited length ??? + /* FIXME: ?? limited length ??? */ strncpy (this->cur_mrl, mrl, 1024); printf ("xine: xine_open done.\n"); @@ -528,7 +528,7 @@ int xine_play_internal (xine_t *this, int start_pos, int start_time) { return 1; } -int xine_open (xine_p this_ro, char *mrl) { +int xine_open (xine_p this_ro, const char *mrl) { xine_t *this = (xine_t *)this_ro; int ret; @@ -992,60 +992,34 @@ int xine_get_current_frame (xine_p this_ro, int *width, int *height, return 1; } -int xine_get_spu_lang (xine_p this_ro, int channel, char *str) { +const char * xine_get_spu_lang (xine_p this_ro, int channel) { xine_t *this = (xine_t *)this_ro; - switch (this->spu_channel_user) { - case -2: - sprintf (str, "off"); - break; - case -1: - if (this->cur_input_plugin) { - if (this->cur_input_plugin->get_capabilities (this->cur_input_plugin) & INPUT_CAP_SPULANG) { - this->cur_input_plugin->get_optional_data (this->cur_input_plugin, this->str, - INPUT_OPTIONAL_DATA_SPULANG); - sprintf (str, "*(%s)", this->str); - return 1; - } - } - if (this->spu_channel_auto == -1) - sprintf (str, "*(off)"); - else - sprintf (str, "*(%3d)", this->spu_channel_auto); - break; - default: - sprintf (str, "%3d", this->spu_channel_user); - } - return 0; + if (this->cur_input_plugin) { + if (this->cur_input_plugin->get_capabilities (this->cur_input_plugin) & INPUT_CAP_SPULANG) { + this->cur_input_plugin->get_optional_data (this->cur_input_plugin, + this->spu_lang, + INPUT_OPTIONAL_DATA_SPULANG); + return this->spu_lang; + } + } + + return NULL; } -int xine_get_audio_lang (xine_p this_ro, int channel, char *str) { +const char* xine_get_audio_lang (xine_p this_ro, int channel) { xine_t *this = (xine_t *)this_ro; - switch (this->audio_channel_user) { - case -2: - sprintf (str, "off"); - break; - case -1: - if (this->cur_input_plugin) { - if (this->cur_input_plugin->get_capabilities (this->cur_input_plugin) & INPUT_CAP_AUDIOLANG) { - this->cur_input_plugin->get_optional_data (this->cur_input_plugin, this->str, - INPUT_OPTIONAL_DATA_AUDIOLANG); - - sprintf (str, "*(%s)", this->str); + if (this->cur_input_plugin) { + if (this->cur_input_plugin->get_capabilities (this->cur_input_plugin) & INPUT_CAP_AUDIOLANG) { + this->cur_input_plugin->get_optional_data (this->cur_input_plugin, + this->audio_lang, + INPUT_OPTIONAL_DATA_AUDIOLANG); + return this->audio_lang; + } + } - return 1; - } - } - if (this->audio_channel_auto == -1) - sprintf (str, "*(off)"); - else - sprintf (str, "*(%3d)", this->audio_channel_auto); - break; - default: - sprintf (str, "%3d", this->audio_channel_user); - } - return 0; + return NULL; } int xine_get_spu_channel (xine_t *this) { diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c index ae52dc031..66e141dbe 100644 --- a/src/xine-engine/xine_interface.c +++ b/src/xine-engine/xine_interface.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_interface.c,v 1.9 2002/09/10 10:40:22 mroi Exp $ + * $Id: xine_interface.c,v 1.10 2002/09/11 17:41:08 guenter Exp $ * * convenience/abstraction layer, functions to implement * libxine's public interface @@ -75,10 +75,10 @@ int xine_check_version(int major, int minor, int sub) { */ const char* xine_config_register_string (xine_p self, - char *key, - char *def_value, - char *description, - char *help, + const char *key, + const char *def_value, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data) { @@ -95,11 +95,11 @@ const char* xine_config_register_string (xine_p self, } int xine_config_register_range (xine_p self, - char *key, + const char *key, int def_value, int min, int max, - char *description, - char *help, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data) { @@ -111,11 +111,11 @@ int xine_config_register_range (xine_p self, int xine_config_register_enum (xine_p self, - char *key, + const char *key, int def_value, char **values, - char *description, - char *help, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data) { @@ -127,10 +127,10 @@ int xine_config_register_enum (xine_p self, int xine_config_register_num (xine_p self, - char *key, + const char *key, int def_value, - char *description, - char *help, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data) { @@ -142,10 +142,10 @@ int xine_config_register_num (xine_p self, int xine_config_register_bool (xine_p self, - char *key, + const char *key, int def_value, - char *description, - char *help, + const char *description, + const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data) { @@ -223,7 +223,7 @@ xine_cfg_entry_t *xine_config_get_next_entry (xine_p this) { * search for a config entry by key */ -xine_cfg_entry_t *xine_config_lookup_entry (xine_p this, char *key) { +xine_cfg_entry_t *xine_config_lookup_entry (xine_p this, const char *key) { config_values_t *config = this->config; diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 4dce3aa88..189a04191 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_internal.h,v 1.97 2002/09/09 19:24:48 f1rmb Exp $ + * $Id: xine_internal.h,v 1.98 2002/09/11 17:41:08 guenter Exp $ * */ @@ -221,8 +221,10 @@ struct xine_s { void *event_listener_user_data[XINE_MAX_EVENT_LISTENERS]; uint16_t num_event_listeners; - /* scratch string buffer */ + /* scratch string buffers */ char str[1024]; + char spu_lang[80]; + char audio_lang[80]; /* log output that may be presented to the user */ scratch_buffer_t *log_buffers[XINE_LOG_NUM]; @@ -244,7 +246,7 @@ struct xine_s { * private function prototypes: */ -int xine_open_internal (xine_t *this, char *mrl); +int xine_open_internal (xine_t *this, const char *mrl); int xine_play_internal (xine_t *this, int start_pos, int start_time); void xine_stop_internal (xine_t *this); -- cgit v1.2.3