aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar Robert Manea <gotmor@gmail.com>2009-07-24 13:37:48 +0200
committerGravatar Robert Manea <gotmor@gmail.com>2009-07-24 13:37:48 +0200
commit65e3e3ea23dbc494758521367e7c111a3ebb27d0 (patch)
tree4acdc1bc65cd43743af65ed0b8ea3e8a8b73463e /uzbl.c
parentf7016761d895933ba23531e0c2faecf207de8fc5 (diff)
added custom vars, currently somewhat broken
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/uzbl.c b/uzbl.c
index cc5f125..8959c77 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -81,7 +81,7 @@ GOptionEntry entries[] =
};
/* associate command names to their properties */
-typedef const struct {
+typedef struct {
/* TODO: Make this ambiguous void **ptr into a union { char *char_p; int *int_p; float *float_p; } val;
the PTR() macro is kind of preventing this change at the moment. */
void **ptr;
@@ -1702,6 +1702,7 @@ set_var_value(gchar *name, gchar *val) {
uzbl_cmdprop *c = NULL;
char *endp = NULL;
char *buf = NULL;
+ char *invalid_chars = "^°!\"§$%&/()=?'`'+~*'#-.:,;@<>| \\{}[]¹²³¼½";
if( (c = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) {
if(!c->writeable) return FALSE;
@@ -1725,6 +1726,23 @@ set_var_value(gchar *name, gchar *val) {
/* invoke a command specific function */
if(c->func) c->func();
+ } else {
+ /* check wether name violates our naming scheme */
+ if(strpbrk(name, invalid_chars)) {
+ if (uzbl.state.verbose)
+ printf("Invalid variable name\n");
+ return FALSE;
+ }
+
+ /* custom vars */
+ c = malloc(sizeof(uzbl_cmdprop));
+ c->type = TYPE_STR;
+ c->dump = 0;
+ c->func = NULL;
+ buf = expand(val, 0);
+ *c->ptr = buf;
+ g_hash_table_insert(uzbl.comm.proto_var,
+ g_strdup(name), (gpointer) c);
}
return TRUE;
}
@@ -2606,7 +2624,7 @@ dump_config() {
}
void
-retreive_geometry() {
+retrieve_geometry() {
int w, h, x, y;
GString *buf = g_string_new("");