mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Applied coding style to src/tools/
This commit is contained in:
parent
39d183fe23
commit
0017098400
@ -46,7 +46,7 @@ struct autocomplete_t {
|
|||||||
gchar *search_str;
|
gchar *search_str;
|
||||||
};
|
};
|
||||||
|
|
||||||
static gchar * _search_from(Autocomplete ac, GSList *curr, gboolean quote);
|
static gchar* _search_from(Autocomplete ac, GSList *curr, gboolean quote);
|
||||||
|
|
||||||
Autocomplete
|
Autocomplete
|
||||||
autocomplete_new(void)
|
autocomplete_new(void)
|
||||||
@ -118,7 +118,7 @@ autocomplete_add(Autocomplete ac, const char *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
autocomplete_remove(Autocomplete ac, const char * const item)
|
autocomplete_remove(Autocomplete ac, const char *const item)
|
||||||
{
|
{
|
||||||
if (ac) {
|
if (ac) {
|
||||||
GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
|
GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
|
||||||
@ -139,7 +139,7 @@ autocomplete_remove(Autocomplete ac, const char * const item)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSList *
|
GSList*
|
||||||
autocomplete_create_list(Autocomplete ac)
|
autocomplete_create_list(Autocomplete ac)
|
||||||
{
|
{
|
||||||
GSList *copy = NULL;
|
GSList *copy = NULL;
|
||||||
@ -168,7 +168,7 @@ autocomplete_contains(Autocomplete ac, const char *value)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar*
|
||||||
autocomplete_complete(Autocomplete ac, const gchar *search_str, gboolean quote)
|
autocomplete_complete(Autocomplete ac, const gchar *search_str, gboolean quote)
|
||||||
{
|
{
|
||||||
gchar *found = NULL;
|
gchar *found = NULL;
|
||||||
@ -215,8 +215,8 @@ autocomplete_complete(Autocomplete ac, const gchar *search_str, gboolean quote)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char*
|
||||||
autocomplete_param_with_func(const char * const input, char *command, autocomplete_func func)
|
autocomplete_param_with_func(const char *const input, char *command, autocomplete_func func)
|
||||||
{
|
{
|
||||||
GString *auto_msg = NULL;
|
GString *auto_msg = NULL;
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
@ -246,8 +246,8 @@ autocomplete_param_with_func(const char * const input, char *command, autocomple
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char*
|
||||||
autocomplete_param_with_ac(const char * const input, char *command, Autocomplete ac, gboolean quote)
|
autocomplete_param_with_ac(const char *const input, char *command, Autocomplete ac, gboolean quote)
|
||||||
{
|
{
|
||||||
GString *auto_msg = NULL;
|
GString *auto_msg = NULL;
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
@ -277,8 +277,8 @@ autocomplete_param_with_ac(const char * const input, char *command, Autocomplete
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char*
|
||||||
autocomplete_param_no_with_func(const char * const input, char *command, int arg_number, autocomplete_func func)
|
autocomplete_param_no_with_func(const char *const input, char *command, int arg_number, autocomplete_func func)
|
||||||
{
|
{
|
||||||
if (strncmp(input, command, strlen(command)) == 0 && (strlen(input) > strlen(command))) {
|
if (strncmp(input, command, strlen(command)) == 0 && (strlen(input) > strlen(command))) {
|
||||||
GString *result_str = NULL;
|
GString *result_str = NULL;
|
||||||
@ -309,7 +309,7 @@ autocomplete_param_no_with_func(const char * const input, char *command, int arg
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar*
|
||||||
_search_from(Autocomplete ac, GSList *curr, gboolean quote)
|
_search_from(Autocomplete ac, GSList *curr, gboolean quote)
|
||||||
{
|
{
|
||||||
while(curr) {
|
while(curr) {
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
typedef char*(*autocomplete_func)(const char * const);
|
typedef char* (*autocomplete_func)(const char *const);
|
||||||
typedef struct autocomplete_t *Autocomplete;
|
typedef struct autocomplete_t *Autocomplete;
|
||||||
|
|
||||||
// allocate new autocompleter with no items
|
// allocate new autocompleter with no items
|
||||||
@ -50,21 +50,21 @@ void autocomplete_clear(Autocomplete ac);
|
|||||||
void autocomplete_free(Autocomplete ac);
|
void autocomplete_free(Autocomplete ac);
|
||||||
|
|
||||||
void autocomplete_add(Autocomplete ac, const char *item);
|
void autocomplete_add(Autocomplete ac, const char *item);
|
||||||
void autocomplete_remove(Autocomplete ac, const char * const item);
|
void autocomplete_remove(Autocomplete ac, const char *const item);
|
||||||
|
|
||||||
// find the next item prefixed with search string
|
// find the next item prefixed with search string
|
||||||
gchar * autocomplete_complete(Autocomplete ac, const gchar *search_str, gboolean quote);
|
gchar* autocomplete_complete(Autocomplete ac, const gchar *search_str, gboolean quote);
|
||||||
|
|
||||||
GSList * autocomplete_create_list(Autocomplete ac);
|
GSList* autocomplete_create_list(Autocomplete ac);
|
||||||
gint autocomplete_length(Autocomplete ac);
|
gint autocomplete_length(Autocomplete ac);
|
||||||
|
|
||||||
char * autocomplete_param_with_func(const char * const input, char *command,
|
char* autocomplete_param_with_func(const char *const input, char *command,
|
||||||
autocomplete_func func);
|
autocomplete_func func);
|
||||||
|
|
||||||
char * autocomplete_param_with_ac(const char * const input, char *command,
|
char* autocomplete_param_with_ac(const char *const input, char *command,
|
||||||
Autocomplete ac, gboolean quote);
|
Autocomplete ac, gboolean quote);
|
||||||
|
|
||||||
char * autocomplete_param_no_with_func(const char * const input, char *command,
|
char* autocomplete_param_no_with_func(const char *const input, char *command,
|
||||||
int arg_number, autocomplete_func func);
|
int arg_number, autocomplete_func func);
|
||||||
|
|
||||||
void autocomplete_reset(Autocomplete ac);
|
void autocomplete_reset(Autocomplete ac);
|
||||||
|
@ -61,8 +61,8 @@
|
|||||||
* { "arg1", "arg2", NULL }
|
* { "arg1", "arg2", NULL }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
gchar **
|
gchar**
|
||||||
parse_args(const char * const inp, int min, int max, gboolean *result)
|
parse_args(const char *const inp, int min, int max, gboolean *result)
|
||||||
{
|
{
|
||||||
if (inp == NULL) {
|
if (inp == NULL) {
|
||||||
*result = FALSE;
|
*result = FALSE;
|
||||||
@ -195,8 +195,8 @@ parse_args(const char * const inp, int min, int max, gboolean *result)
|
|||||||
* { "arg1", "arg2", "some free text", NULL }
|
* { "arg1", "arg2", "some free text", NULL }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
gchar **
|
gchar**
|
||||||
parse_args_with_freetext(const char * const inp, int min, int max, gboolean *result)
|
parse_args_with_freetext(const char *const inp, int min, int max, gboolean *result)
|
||||||
{
|
{
|
||||||
if (inp == NULL) {
|
if (inp == NULL) {
|
||||||
*result = FALSE;
|
*result = FALSE;
|
||||||
@ -316,7 +316,7 @@ parse_args_with_freetext(const char * const inp, int min, int max, gboolean *res
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
count_tokens(const char * const string)
|
count_tokens(const char *const string)
|
||||||
{
|
{
|
||||||
int length = g_utf8_strlen(string, -1);
|
int length = g_utf8_strlen(string, -1);
|
||||||
gboolean in_quotes = FALSE;
|
gboolean in_quotes = FALSE;
|
||||||
@ -346,8 +346,8 @@ count_tokens(const char * const string)
|
|||||||
return num_tokens;
|
return num_tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char*
|
||||||
get_start(const char * const string, int tokens)
|
get_start(const char *const string, int tokens)
|
||||||
{
|
{
|
||||||
GString *result = g_string_new("");
|
GString *result = g_string_new("");
|
||||||
int length = g_utf8_strlen(string, -1);
|
int length = g_utf8_strlen(string, -1);
|
||||||
@ -388,7 +388,7 @@ get_start(const char * const string, int tokens)
|
|||||||
return result_str;
|
return result_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
GHashTable *
|
GHashTable*
|
||||||
parse_options(gchar **args, gchar **opt_keys, gboolean *res)
|
parse_options(gchar **args, gchar **opt_keys, gboolean *res)
|
||||||
{
|
{
|
||||||
GList *keys = NULL;
|
GList *keys = NULL;
|
||||||
|
@ -37,11 +37,11 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
gchar** parse_args(const char * const inp, int min, int max, gboolean *result);
|
gchar** parse_args(const char *const inp, int min, int max, gboolean *result);
|
||||||
gchar** parse_args_with_freetext(const char * const inp, int min, int max, gboolean *result);
|
gchar** parse_args_with_freetext(const char *const inp, int min, int max, gboolean *result);
|
||||||
int count_tokens(const char * const string);
|
int count_tokens(const char *const string);
|
||||||
char* get_start(const char * const string, int tokens);
|
char* get_start(const char *const string, int tokens);
|
||||||
GHashTable* parse_options(gchar **args, gchar **keys, gboolean *res);
|
GHashTable* parse_options(gchar **args, gchar **keys, gboolean *res);
|
||||||
void options_destroy(GHashTable *options);
|
void options_destroy(GHashTable *options);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,7 +54,7 @@ tinyurl_valid(char *url)
|
|||||||
g_str_has_prefix(url, "https://"));
|
g_str_has_prefix(url, "https://"));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char*
|
||||||
tinyurl_get(char *url)
|
tinyurl_get(char *url)
|
||||||
{
|
{
|
||||||
GString *full_url = g_string_new("http://tinyurl.com/api-create.php?url=");
|
GString *full_url = g_string_new("http://tinyurl.com/api-create.php?url=");
|
||||||
|
@ -38,6 +38,6 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
gboolean tinyurl_valid(char *url);
|
gboolean tinyurl_valid(char *url);
|
||||||
char * tinyurl_get(char *url);
|
char* tinyurl_get(char *url);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user