]>
Dogcows Code - chaz/openbox/blob - obcl/process.c
eb7cafd2ac3b8480addb1bee8e2c55e99a9ffc83
3 static void cl_proc_intern_handler(CLNode
*node
)
6 g_warning("Unhandled node %s on line %d\n",
7 CL_ID(node
), CL_LINE(node
));
10 static CLProcHandler
*default_handler(void)
12 static CLProcHandler
*ph
= 0;
14 ph
= cl_proc_handler_new_func(cl_proc_intern_handler
);
18 CLProcHandler
*cl_proc_handler_new_func(CLProcFunc f
)
20 CLProcHandler
*cph
= g_new(CLProcHandler
,1);
21 cph
->type
= CLPROC_FUNC
;
26 CLProcHandler
*cl_proc_handler_new_proc(CLProc
*cp
)
28 CLProcHandler
*cph
= g_new(CLProcHandler
,1);
29 cph
->type
= CLPROC_PROC
;
34 CLProc
*cl_proc_new(void)
36 CLProc
*ret
= g_new(CLProc
,1);
37 ret
->table
= g_hash_table_new(g_str_hash
,g_str_equal
);
38 ret
->default_h
= default_handler();
42 void cl_proc_free(CLProc
*proc
)
47 void cl_proc_add_handler(CLProc
*proc
, gchar
*str
,
48 CLProcHandler
*handler
)
50 g_assert(proc
!= NULL
);
51 g_hash_table_replace(proc
->table
, str
, handler
);
54 void cl_proc_add_handler_func(CLProc
*proc
, gchar
*str
,
59 g_assert(proc
!= NULL
);
60 ph
= cl_proc_handler_new_func(func
);
61 cl_proc_add_handler(proc
, str
, ph
);
64 void cl_proc_add_handler_proc(CLProc
*proc
, gchar
*str
,
69 g_assert(proc
!= NULL
);
70 ph
= cl_proc_handler_new_proc(hproc
);
71 cl_proc_add_handler(proc
, str
, ph
);
74 void cl_proc_set_default(CLProc
*proc
, CLProcHandler
*ph
)
76 g_assert(proc
!= NULL
);
80 void cl_proc_register_keywords(CLProc
*proc
, ...)
83 g_assert(proc
!= NULL
);
87 gchar
*k
= va_arg(args
, gchar
*);
90 if (g_hash_table_lookup(proc
->table
, k
) != NULL
)
91 g_hash_table_insert(proc
->table
, k
, default_handler());
96 void cl_process(GList
*tree
, CLProc
*proc
)
99 CLProcHandler
*handler
;
101 g_assert(proc
!= NULL
);
105 for (lst
= tree
; lst
!= NULL
; lst
= lst
->next
) {
106 CL_ASSERT_NODE(lst
->data
);
107 handler
= g_hash_table_lookup(proc
->table
, CL_ID(lst
->data
));
109 handler
= default_handler();
110 if (handler
->type
== CLPROC_FUNC
)
111 handler
->u
.func(CL_NODE(lst
->data
));
113 cl_process(CL_BLOCK(lst
->data
), handler
->u
.proc
);
This page took 0.038054 seconds and 4 git commands to generate.