aboutsummaryrefslogtreecommitdiffstats
path: root/libcmap.h
blob: e849ffb73853e165b33d6ecd6c994f0da34e92eb (plain) (blame)
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
/* See LICENSE file for copyright and license details. */
#ifndef LIBCMAP_H
#define LIBCMAP_H

#include <stddef.h>
#include <stdint.h>

#if defined(__GNUC__)
# define LIBCMAP_PURE_ __attribute__((__pure__))
# define LIBCMAP_CONST_ __attribute__((__const__))
#else
# define LIBCMAP_PURE_
# define LIBCMAP_CONST_
#endif


struct libcmap_range {
	uint32_t first;
	uint32_t last;
};

struct libcmap_block {
	const char *name;
	struct libcmap_range range;
};

struct libcmap_script {
	const char *name;
	const struct libcmap_range *ranges;
	size_t nranges;
};


extern const struct libcmap_script libcmap_no_block;
extern const struct libcmap_block *const libcmap_block_list;
extern const size_t libcmap_block_list_size;

extern const struct libcmap_script *const libcmap_script_list;
extern const size_t libcmap_script_list_size;


int libcmap_find_in_no_block(uint32_t codepoint, size_t *offset_out, size_t *subrange_out);
const struct libcmap_block *libcmap_find_block(uint32_t codepoint, size_t *offset_out);
const struct libcmap_script *libcmap_find_script(uint32_t codepoint, size_t *offset_out, size_t *subrange_out);

int libcmap_sprint_range(char *buf, const struct libcmap_range *range, const char *endash);
int libcmap_snprint_range(char *buf, size_t bufsize, const struct libcmap_range *range, const char *endash);


#undef LIBCMAP_PURE_
#undef LIBCMAP_CONST_
#endif