summaryrefslogtreecommitdiff
path: root/examples/example-10.c
blob: fe080a8dd3ed4c7ccd1daf87f5348df6467e1246 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* vim: set ts=8 sw=8 noexpandtab: */

#include <stdio.h>
#include <stdlib.h>
#include <ccss/ccss.h>
#include <glib.h>
#include "config.h"

static char const _css_1[] = "		\
	a { 				\
		bar: 1;			\
	}				\
";

static char const _css_2[] = "		\
	a { 				\
		baz: 2;			\
	}				\
	b { 				\
		frob: 3;		\
	}				\
";

int
main (int	  argc,
      char	**argv)
{
	ccss_grammar_t		*grammar;
	ccss_stylesheet_t	*stylesheet;
	unsigned int		 descriptor;

	grammar = ccss_grammar_create_css ();
	stylesheet = ccss_grammar_create_stylesheet (grammar);
	ccss_grammar_destroy (grammar);

	g_debug ("Empty stylesheet");
	ccss_stylesheet_dump (stylesheet);

	descriptor = ccss_stylesheet_add_from_buffer (stylesheet,
						      _css_1, sizeof (_css_1),
						      CCSS_STYLESHEET_AUTHOR,
						      NULL);
	g_debug ("With buffer 1 ('%d')", descriptor);
	ccss_stylesheet_dump (stylesheet);

	descriptor = ccss_stylesheet_add_from_buffer (stylesheet,
						      _css_2, sizeof (_css_2),
						      CCSS_STYLESHEET_AUTHOR,
						      NULL);
	g_debug ("With buffer 2 ('%d')", descriptor);
	ccss_stylesheet_dump (stylesheet);

	ccss_stylesheet_unload (stylesheet, descriptor);
	g_debug ("Back to just buffer 1");
	ccss_stylesheet_dump (stylesheet);

	ccss_stylesheet_destroy (stylesheet);

	return EXIT_SUCCESS;
}