]>
Dogcows Code - chaz/openbox/blob - openbox/parse.c
3 static GHashTable
*reg
= NULL
;
10 void destshit(gpointer key
) { g_free(key
); }
14 reg
= g_hash_table_new_full(g_str_hash
, g_str_equal
, destshit
, destshit
);
20 g_hash_table_destroy(reg
);
23 void parse_reg_section(char *section
, ParseFunc func
, AssignParseFunc afunc
)
25 if (g_hash_table_lookup(reg
, section
) != NULL
)
26 g_warning("duplicate request for section '%s' in the rc file",
29 struct Functions
*f
= g_new(struct Functions
, 1);
32 g_hash_table_insert(reg
, g_ascii_strdown(section
, -1), f
);
36 void parse_free_token(ParseToken
*token
)
40 switch (token
->type
) {
42 g_free(token
->data
.string
);
44 case TOKEN_IDENTIFIER
:
45 g_free(token
->data
.identifier
);
48 for (it
= token
->data
.list
; it
; it
= it
->next
) {
49 parse_free_token(it
->data
);
52 g_list_free(token
->data
.list
);
65 void parse_set_section(char *section
)
67 funcs
= g_hash_table_lookup(reg
, section
);
70 void parse_token(ParseToken
*token
)
73 if (funcs
->func
!= NULL
)
75 else if (token
->type
!= TOKEN_NEWLINE
)
76 yyerror("syntax error");
80 void parse_assign(char *name
, ParseToken
*value
)
83 if (funcs
->afunc
!= NULL
)
84 funcs
->afunc(name
, value
);
86 yyerror("syntax error");
This page took 0.0366 seconds and 5 git commands to generate.