-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththc.h
115 lines (80 loc) · 2.25 KB
/
thc.h
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifndef THC_H
#define THC_H
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#define THC_VERSION "1.0"
#define UNUSED(x) (x=x)
extern const char *source_file;
struct attr {
const char *key;
const char *val;
};
struct list {
void *data;
struct list *next;
};
struct list* list_cons(void* data, struct list *list);
enum node_type { TEXT, TAG };
struct tag_node {
const char *name;
struct list *attrs;
struct list *children;
};
struct node {
char type;
union {
struct tag_node tag;
const char *text;
} data;
};
void print_tree(struct node *tree, int depth);
struct html_builder {
struct list *stack;
struct node *top_node;
struct list **last_node;
};
int html_builder_init(struct html_builder *builder,
const char *name,
...);
void enter_tag(struct html_builder *builder,
const char *name,
...);
void leave_tag(struct html_builder *builder);
void append_tag(struct html_builder *builder,
const char *name,
...);
void insert_text(struct html_builder *builder,
const char* text);
void insert_texts(struct html_builder *builder,
...);
int pagemain(int argc, char** argv);
extern char* website_pagename;
void webpage_start(struct html_builder *builder,
const char* page_name,
const char* title);
void webpage_end(struct html_builder *builder);
void webpage_youtubeembed(struct html_builder *builder,
const char* watchid,
const int width,
const int height);
char *youtube_url(char *watchid);
#define TAGENTER(...) enter_tag(builder,__VA_ARGS__,NULL);
#define TAG(args,body) TAGENTER args { body } leave_tag(builder);
#define TEXT(...) insert_texts(builder,__VA_ARGS__,NULL);
struct term {
char *term;
char *abbr;
char *translation;
};
size_t term_size(struct term *term);
struct dictionary {
struct dictionary *this;
size_t num_terms;
struct term *terms;
};
int write_dictionary(const char *path, struct dictionary *dict);
struct dictionary* read_dictionary(const char *path);
void strappend(char *dest, const char *s);
char* printbf(const char *s, ...);
#endif