1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Applied coding style to src/config/

This commit is contained in:
James Booth 2015-10-25 22:23:38 +00:00
parent ea899aabee
commit 5863292094
6 changed files with 57 additions and 55 deletions

View File

@ -66,11 +66,11 @@ gint log_maxsize = 0;
static Autocomplete boolean_choice_ac; static Autocomplete boolean_choice_ac;
static void _save_prefs(void); static void _save_prefs(void);
static gchar * _get_preferences_file(void); static gchar* _get_preferences_file(void);
static const char * _get_group(preference_t pref); static const char* _get_group(preference_t pref);
static const char * _get_key(preference_t pref); static const char* _get_key(preference_t pref);
static gboolean _get_default_boolean(preference_t pref); static gboolean _get_default_boolean(preference_t pref);
static char * _get_default_string(preference_t pref); static char* _get_default_string(preference_t pref);
void void
prefs_load(void) prefs_load(void)
@ -142,8 +142,8 @@ prefs_close(void)
prefs = NULL; prefs = NULL;
} }
char * char*
prefs_autocomplete_boolean_choice(const char * const prefix) prefs_autocomplete_boolean_choice(const char *const prefix)
{ {
return autocomplete_complete(boolean_choice_ac, prefix, TRUE); return autocomplete_complete(boolean_choice_ac, prefix, TRUE);
} }
@ -177,7 +177,7 @@ prefs_set_boolean(preference_t pref, gboolean value)
_save_prefs(); _save_prefs();
} }
char * char*
prefs_get_string(preference_t pref) prefs_get_string(preference_t pref)
{ {
const char *group = _get_group(pref); const char *group = _get_group(pref);
@ -263,7 +263,8 @@ prefs_set_max_log_size(gint value)
_save_prefs(); _save_prefs();
} }
gint prefs_get_inpblock(void) gint
prefs_get_inpblock(void)
{ {
int val = g_key_file_get_integer(prefs, PREF_GROUP_UI, "inpblock", NULL); int val = g_key_file_get_integer(prefs, PREF_GROUP_UI, "inpblock", NULL);
if (val == 0) { if (val == 0) {
@ -273,7 +274,8 @@ gint prefs_get_inpblock(void)
} }
} }
void prefs_set_inpblock(gint value) void
prefs_set_inpblock(gint value)
{ {
g_key_file_set_integer(prefs, PREF_GROUP_UI, "inpblock", value); g_key_file_set_integer(prefs, PREF_GROUP_UI, "inpblock", value);
_save_prefs(); _save_prefs();
@ -444,7 +446,7 @@ prefs_set_pgp_char(char ch)
} }
gboolean gboolean
prefs_add_alias(const char * const name, const char * const value) prefs_add_alias(const char *const name, const char *const value)
{ {
if (g_key_file_has_key(prefs, PREF_GROUP_ALIAS, name, NULL)) { if (g_key_file_has_key(prefs, PREF_GROUP_ALIAS, name, NULL)) {
return FALSE; return FALSE;
@ -455,15 +457,15 @@ prefs_add_alias(const char * const name, const char * const value)
} }
} }
char * char*
prefs_get_alias(const char * const name) prefs_get_alias(const char *const name)
{ {
return g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL); return g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL);
} }
gboolean gboolean
prefs_remove_alias(const char * const name) prefs_remove_alias(const char *const name)
{ {
if (!g_key_file_has_key(prefs, PREF_GROUP_ALIAS, name, NULL)) { if (!g_key_file_has_key(prefs, PREF_GROUP_ALIAS, name, NULL)) {
return FALSE; return FALSE;
@ -483,7 +485,7 @@ _alias_cmp(gconstpointer *p1, gconstpointer *p2)
return strcmp(alias1->name, alias2->name); return strcmp(alias1->name, alias2->name);
} }
GList * GList*
prefs_get_aliases(void) prefs_get_aliases(void)
{ {
if (!g_key_file_has_group(prefs, PREF_GROUP_ALIAS)) { if (!g_key_file_has_group(prefs, PREF_GROUP_ALIAS)) {
@ -545,7 +547,7 @@ _save_prefs(void)
g_string_free(base_str, TRUE); g_string_free(base_str, TRUE);
} }
static gchar * static gchar*
_get_preferences_file(void) _get_preferences_file(void)
{ {
gchar *xdg_config = xdg_get_config_home(); gchar *xdg_config = xdg_get_config_home();
@ -561,7 +563,7 @@ _get_preferences_file(void)
// get the preference group for a specific preference // get the preference group for a specific preference
// for example the PREF_BEEP setting ("beep" in .profrc, see _get_key) belongs // for example the PREF_BEEP setting ("beep" in .profrc, see _get_key) belongs
// to the [ui] section. // to the [ui] section.
static const char * static const char*
_get_group(preference_t pref) _get_group(preference_t pref)
{ {
switch (pref) switch (pref)
@ -648,7 +650,7 @@ _get_group(preference_t pref)
// get the key used in .profrc for the preference // get the key used in .profrc for the preference
// for example the PREF_AUTOAWAY_MODE maps to "autoaway.mode" in .profrc // for example the PREF_AUTOAWAY_MODE maps to "autoaway.mode" in .profrc
static const char * static const char*
_get_key(preference_t pref) _get_key(preference_t pref)
{ {
switch (pref) switch (pref)
@ -833,7 +835,7 @@ _get_default_boolean(preference_t pref)
// the default setting for a string type preference // the default setting for a string type preference
// if it is not specified in .profrc // if it is not specified in .profrc
static char * static char*
_get_default_string(preference_t pref) _get_default_string(preference_t pref)
{ {
switch (pref) switch (pref)

View File

@ -124,9 +124,9 @@ typedef struct prof_alias_t {
void prefs_load(void); void prefs_load(void);
void prefs_close(void); void prefs_close(void);
char * prefs_find_login(char *prefix); char* prefs_find_login(char *prefix);
void prefs_reset_login_search(void); void prefs_reset_login_search(void);
char * prefs_autocomplete_boolean_choice(const char * const prefix); char* prefs_autocomplete_boolean_choice(const char *const prefix);
void prefs_reset_boolean_choice(void); void prefs_reset_boolean_choice(void);
gint prefs_get_gone(void); gint prefs_get_gone(void);
@ -162,15 +162,15 @@ void prefs_set_pgp_char(char ch);
void prefs_add_login(const char *jid); void prefs_add_login(const char *jid);
gboolean prefs_add_alias(const char * const name, const char * const value); gboolean prefs_add_alias(const char *const name, const char *const value);
gboolean prefs_remove_alias(const char * const name); gboolean prefs_remove_alias(const char *const name);
char* prefs_get_alias(const char * const name); char* prefs_get_alias(const char *const name);
GList* prefs_get_aliases(void); GList* prefs_get_aliases(void);
void prefs_free_aliases(GList *aliases); void prefs_free_aliases(GList *aliases);
gboolean prefs_get_boolean(preference_t pref); gboolean prefs_get_boolean(preference_t pref);
void prefs_set_boolean(preference_t pref, gboolean value); void prefs_set_boolean(preference_t pref, gboolean value);
char * prefs_get_string(preference_t pref); char* prefs_get_string(preference_t pref);
void prefs_free_string(char *pref); void prefs_free_string(char *pref);
void prefs_set_string(preference_t pref, char *value); void prefs_set_string(preference_t pref, char *value);

View File

@ -124,17 +124,17 @@ static struct colours_t {
NCURSES_COLOR_T receiptsent; NCURSES_COLOR_T receiptsent;
} colour_prefs; } colour_prefs;
static NCURSES_COLOR_T _lookup_colour(const char * const colour); static NCURSES_COLOR_T _lookup_colour(const char *const colour);
static void _set_colour(gchar *val, NCURSES_COLOR_T *pref, NCURSES_COLOR_T def, theme_item_t theme_item); static void _set_colour(gchar *val, NCURSES_COLOR_T *pref, NCURSES_COLOR_T def, theme_item_t theme_item);
static void _load_colours(void); static void _load_colours(void);
static void _load_preferences(void); static void _load_preferences(void);
static gchar * _get_themes_dir(void); static gchar* _get_themes_dir(void);
void _theme_list_dir(const gchar * const dir, GSList **result); void _theme_list_dir(const gchar *const dir, GSList **result);
static GString * _theme_find(const char * const theme_name); static GString* _theme_find(const char *const theme_name);
static gboolean _theme_load_file(const char * const theme_name); static gboolean _theme_load_file(const char *const theme_name);
void void
theme_init(const char * const theme_name) theme_init(const char *const theme_name)
{ {
if (!_theme_load_file(theme_name) && !_theme_load_file("default")) { if (!_theme_load_file(theme_name) && !_theme_load_file("default")) {
log_error("Theme initialisation failed"); log_error("Theme initialisation failed");
@ -144,7 +144,7 @@ theme_init(const char * const theme_name)
} }
gboolean gboolean
theme_load(const char * const theme_name) theme_load(const char *const theme_name)
{ {
if (_theme_load_file(theme_name)) { if (_theme_load_file(theme_name)) {
_load_colours(); _load_colours();
@ -156,7 +156,7 @@ theme_load(const char * const theme_name)
} }
static gboolean static gboolean
_theme_load_file(const char * const theme_name) _theme_load_file(const char *const theme_name)
{ {
// use default theme // use default theme
if (theme_name == NULL || strcmp(theme_name, "default") == 0) { if (theme_name == NULL || strcmp(theme_name, "default") == 0) {
@ -189,7 +189,7 @@ _theme_load_file(const char * const theme_name)
return TRUE; return TRUE;
} }
GSList * GSList*
theme_list(void) theme_list(void)
{ {
GSList *result = NULL; GSList *result = NULL;
@ -300,7 +300,7 @@ theme_init_colours(void)
} }
static NCURSES_COLOR_T static NCURSES_COLOR_T
_lookup_colour(const char * const colour) _lookup_colour(const char *const colour)
{ {
int i; int i;
for (i = 0; i < num_colours; i++) { for (i = 0; i < num_colours; i++) {
@ -489,7 +489,7 @@ _load_preferences(void)
} }
} }
static gchar * static gchar*
_get_themes_dir(void) _get_themes_dir(void)
{ {
gchar *xdg_config = xdg_get_config_home(); gchar *xdg_config = xdg_get_config_home();
@ -500,7 +500,7 @@ _get_themes_dir(void)
} }
void void
_theme_list_dir(const gchar * const dir, GSList **result) _theme_list_dir(const gchar *const dir, GSList **result)
{ {
GDir *themes = g_dir_open(dir, 0, NULL); GDir *themes = g_dir_open(dir, 0, NULL);
if (themes) { if (themes) {
@ -513,8 +513,8 @@ _theme_list_dir(const gchar * const dir, GSList **result)
} }
} }
static GString * static GString*
_theme_find(const char * const theme_name) _theme_find(const char *const theme_name)
{ {
GString *path = NULL; GString *path = NULL;
gchar *themes_dir = _get_themes_dir(); gchar *themes_dir = _get_themes_dir();
@ -546,7 +546,7 @@ _theme_find(const char * const theme_name)
} }
theme_item_t theme_item_t
theme_main_presence_attrs(const char * const presence) theme_main_presence_attrs(const char *const presence)
{ {
if (g_strcmp0(presence, "online") == 0) { if (g_strcmp0(presence, "online") == 0) {
return THEME_ONLINE; return THEME_ONLINE;

View File

@ -105,12 +105,12 @@ typedef enum {
THEME_MAGENTA_BOLD THEME_MAGENTA_BOLD
} theme_item_t; } theme_item_t;
void theme_init(const char * const theme_name); void theme_init(const char *const theme_name);
void theme_init_colours(void); void theme_init_colours(void);
gboolean theme_load(const char * const theme_name); gboolean theme_load(const char *const theme_name);
GSList* theme_list(void); GSList* theme_list(void);
void theme_close(void); void theme_close(void);
int theme_attrs(theme_item_t attrs); int theme_attrs(theme_item_t attrs);
theme_item_t theme_main_presence_attrs(const char * const presence); theme_item_t theme_main_presence_attrs(const char *const presence);
#endif #endif

View File

@ -76,7 +76,7 @@ tlscerts_init(void)
} }
gboolean gboolean
tlscerts_exists(const char * const fingerprint) tlscerts_exists(const char *const fingerprint)
{ {
return g_key_file_has_group(tlscerts, fingerprint); return g_key_file_has_group(tlscerts, fingerprint);
} }
@ -110,8 +110,8 @@ tlscerts_list(void)
} }
TLSCertificate* TLSCertificate*
tlscerts_new(const char * const fingerprint, const char * const domain, const char * const organisation, tlscerts_new(const char *const fingerprint, const char *const domain, const char *const organisation,
const char * const email, const char * const notbefore, const char * const notafter) const char *const email, const char *const notbefore, const char *const notafter)
{ {
TLSCertificate *cert = malloc(sizeof(TLSCertificate)); TLSCertificate *cert = malloc(sizeof(TLSCertificate));
if (fingerprint) { if (fingerprint) {
@ -181,7 +181,7 @@ tlscerts_add(TLSCertificate *cert)
} }
gboolean gboolean
tlscerts_revoke(const char * const fingerprint) tlscerts_revoke(const char *const fingerprint)
{ {
gboolean result = g_key_file_remove_group(tlscerts, fingerprint, NULL); gboolean result = g_key_file_remove_group(tlscerts, fingerprint, NULL);
if (result) { if (result) {
@ -193,8 +193,8 @@ tlscerts_revoke(const char * const fingerprint)
return result; return result;
} }
char * char*
tlscerts_complete(const char * const prefix) tlscerts_complete(const char *const prefix)
{ {
return autocomplete_complete(certs_ac, prefix, TRUE); return autocomplete_complete(certs_ac, prefix, TRUE);
} }
@ -226,7 +226,7 @@ tlscerts_close(void)
autocomplete_free(certs_ac); autocomplete_free(certs_ac);
} }
static gchar * static gchar*
_get_tlscerts_file(void) _get_tlscerts_file(void)
{ {
gchar *xdg_data = xdg_get_data_home(); gchar *xdg_data = xdg_get_data_home();

View File

@ -46,21 +46,21 @@ typedef struct tls_cert_t {
void tlscerts_init(void); void tlscerts_init(void);
TLSCertificate *tlscerts_new(const char * const fingerprint, const char * const domain, TLSCertificate* tlscerts_new(const char *const fingerprint, const char *const domain,
const char * const organisation, const char * const email, const char *const organisation, const char *const email,
const char * const notbefore, const char * const notafter); const char *const notbefore, const char *const notafter);
gboolean tlscerts_exists(const char * const fingerprint); gboolean tlscerts_exists(const char *const fingerprint);
void tlscerts_add(TLSCertificate *cert); void tlscerts_add(TLSCertificate *cert);
gboolean tlscerts_revoke(const char * const fingerprint); gboolean tlscerts_revoke(const char *const fingerprint);
void tlscerts_free(TLSCertificate *cert); void tlscerts_free(TLSCertificate *cert);
GList* tlscerts_list(void); GList* tlscerts_list(void);
char* tlscerts_complete(const char * const prefix); char* tlscerts_complete(const char *const prefix);
void tlscerts_reset_ac(void); void tlscerts_reset_ac(void);