]> Dogcows Code - chaz/openbox/blob - obcl/obcl.c
move the move/resize functionality into moveresize.c, for use with the netwm atoms...
[chaz/openbox] / obcl / obcl.c
1 #include "obcl.h"
2
3 void cl_tree_free(GList *tree)
4 {
5 CLNode *tmp;
6
7 if (!tree) return;
8
9 for (; tree; tree = tree->next) {
10 tmp = (CLNode*)tree->data;
11 switch(tmp->type) {
12 case CL_ID:
13 case CL_STR:
14 g_free(tmp->u.str);
15 break;
16 case CL_LIST:
17 case CL_BLOCK:
18 case CL_LISTBLOCK:
19 g_free(tmp->u.lb.id);
20 cl_tree_free(tmp->u.lb.list);
21 cl_tree_free(tmp->u.lb.block);
22 break;
23 default:
24 break;
25 }
26 g_free(tmp);
27 }
28 g_list_free(tree);
29 }
30
31 GList *cl_parse(gchar *file)
32 {
33 FILE *fh = fopen(file, "r");
34 GList *ret = NULL;
35
36 if (fh) {
37 ret = cl_parse_fh(fh);
38 fclose(fh);
39 } else {
40 perror(file);
41 }
42
43 return ret;
44 }
45
46 void cl_tree_print(GList *tree, int depth)
47 {
48 CLNode *tmp;
49 int tmpd = depth;
50
51 for (; tree; tree = tree->next) {
52 tmp = (CLNode*)tree->data;
53
54 while (tmpd-- > 0)
55 printf(" ");
56 tmpd = depth;
57
58 switch(tmp->type) {
59 case CL_ID:
60 printf("[ID] '%s'\n", tmp->u.str);
61 break;
62 case CL_STR:
63 printf("[STR] '%s'\n", tmp->u.str);
64 break;
65 case CL_NUM:
66 printf("[NUM] %.2f\n", tmp->u.num);
67 break;
68 case CL_LIST:
69 printf("[LIST] '%s'\n", tmp->u.lb.id);
70 cl_tree_print(tmp->u.lb.list, depth+2);
71 break;
72 case CL_BLOCK:
73 printf("[BLOCK] '%s'\n", tmp->u.lb.id);
74 cl_tree_print(tmp->u.lb.block, depth+2);
75 break;
76 case CL_LISTBLOCK:
77 printf("[LISTBLOCK] %s\n", tmp->u.lb.id);
78 cl_tree_print(tmp->u.lb.list, depth+2);
79 printf("\n");
80 cl_tree_print(tmp->u.lb.block, depth+2);
81 break;
82 }
83 }
84 }
This page took 0.042506 seconds and 4 git commands to generate.