#define PTR_C_INT(var, fun) { .ptr.i = (int*)&(var), .type = TYPE_INT, .dump = 0, .writeable = 0, .func = fun }
#define PTR_C_FLOAT(var, fun) { .ptr.f = &(var), .type = TYPE_FLOAT, .dump = 0, .writeable = 0, .func = fun }
-const struct {
+const struct var_name_to_ptr_t {
const char *name;
uzbl_cmdprop cp;
} var_name_to_ptr[] = {
{ "NAME", PTR_C_STR(uzbl.state.instance_name, NULL)},
{ NULL, {.ptr.s = NULL, .type = TYPE_INT, .dump = 0, .writeable = 0, .func = NULL}}
-}, *n2v_p = var_name_to_ptr;
+};
const struct {
/* construct a hash from the var_name_to_ptr array for quick access */
void
make_var_to_name_hash() {
+ struct var_name_to_ptr_t *n2v_p = &var_name_to_ptr;
uzbl.comm.proto_var = g_hash_table_new(g_str_hash, g_str_equal);
while(n2v_p->name) {
g_hash_table_insert(uzbl.comm.proto_var, n2v_p->name, (gpointer) &n2v_p->cp);
}
/* --- UTILITY FUNCTIONS --- */
-enum {EXP_ERR, EXP_SIMPLE_VAR, EXP_BRACED_VAR, EXP_EXPR, EXP_JS, EXP_ESCAPE};
-guint
+enum exp_type {EXP_ERR, EXP_SIMPLE_VAR, EXP_BRACED_VAR, EXP_EXPR, EXP_JS, EXP_ESCAPE};
+enum exp_type
get_exp_type(const gchar *s) {
/* variables */
if(*(s+1) == '(')
gchar *
expand(const char *s, guint recurse) {
uzbl_cmdprop *c;
- guint etype;
+ enum exp_type etype;
char *end_simple_var = "^°!\"§$%&/()=?'`'+~*'#-.:,;@<>| \\{}[]¹²³¼½";
char *ret = NULL;
char *vend = NULL;
}
GArray*
-read_file_by_line (gchar *path) {
+read_file_by_line (const gchar *path) {
GIOChannel *chan = NULL;
gchar *readbuf = NULL;
gsize len;
return TRUE;
}
-WebKitWebView*
+/*@null@*/ WebKitWebView*
create_web_view_cb (WebKitWebView *web_view, WebKitWebFrame *frame, gpointer user_data) {
(void) web_view;
(void) frame;
#undef VIEWFUNC
/* -- command to callback/function map for things we cannot attach to any signals */
-struct {char *key; CommandInfo value;} cmdlist[] =
+struct {const char *key; CommandInfo value;} cmdlist[] =
{ /* key function no_split */
{ "back", {view_go_back, 0} },
{ "forward", {view_go_forward, 0} },
return result;
}
-gchar**
+/*@null@*/ gchar**
split_quoted(const gchar* src, const gboolean unquote) {
/* split on unquoted space, return array of strings;
remove a layer of quotes and backslashes if unquote */
set_proxy_url() {
SoupURI *suri;
- if(*uzbl.net.proxy_url == ' '
- || uzbl.net.proxy_url == NULL) {
+ if(uzbl.net.proxy_url == NULL || *uzbl.net.proxy_url == ' ') {
soup_session_remove_feature_by_type(uzbl.net.soup_session,
(GType) SOUP_SESSION_PROXY_URI);
}
}
gboolean
-set_var_value(gchar *name, gchar *val) {
+set_var_value(const gchar *name, gchar *val) {
uzbl_cmdprop *c = NULL;
char *endp = NULL;
char *buf = NULL;
}
}
-gchar*
+/*@null@*/ gchar*
build_stream_name(int type, const gchar* dir) {
State *s = &uzbl.state;
gchar *str = NULL;
return TRUE;
}
-gchar*
+/*@null@*/ gchar*
init_fifo(gchar *dir) { /* return dir or, on error, free dir and return NULL */
if (uzbl.comm.fifo_path) { /* get rid of the old fifo if one exists */
if (unlink(uzbl.comm.fifo_path) == -1)
return TRUE;
}
-gchar*
+/*@null@*/ gchar*
init_socket(gchar *dir) { /* return dir or, on error, free dir and return NULL */
if (uzbl.comm.socket_path) { /* remove an existing socket should one exist */
if (unlink(uzbl.comm.socket_path) == -1)
g_strfreev(parts);
}
-gchar*
+/*@null@*/ gchar*
get_xdg_var (XDG_Var xdg) {
const gchar* actual_value = getenv (xdg.environmental);
const gchar* home = getenv ("HOME");
return return_value;
}
-gchar*
-find_xdg_file (int xdg_type, char* filename) {
+/*@null@*/ gchar*
+find_xdg_file (int xdg_type, const char* filename) {
/* xdg_type = 0 => config
xdg_type = 1 => data
xdg_type = 2 => cache*/
if (file_exists (temporary_file)) {
return temporary_file;
} else {
+ g_free(temporary_file);
return NULL;
}
}