~strahinja/poe

ref: v1.4.6 poe/util.h -rw-r--r-- 2.0 KiB
113f5f2bСтрахиња Радић Fix wrapping on save 9 months ago
                                                                                
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
#include <bits/stdint-uintn.h>
#include <sys/types.h>
#define ABS(a)	  ((a < 0) ? (-a) : (a))
#define LEN(x)	  (sizeof(x) / sizeof(x[0]))
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a < b) ? a : b)

enum {
	ERR_UNKNOWN_KEY,
	ERR_EXIT_KEY,
	ERR_DLG_OPEN,
	ERR_DLG_OPEN_QUIT,
	ERR_EMPTY_FILE,
	ERR_CANT_ALLOC,
	ERR_CANT_SAVE,
	ERR_CANT_MOVE,
	ERR_ILLEGAL_ON_FIRST,
	ERR_NO_PLURAL_FORMS
};

#define MAXBUFLINE  4096
#define MAXDATEBUF  80
#define MAXFLAGSBUF (4 + 1)
#define MAXMSGLINE  1024
#define MSGDELTA    1024
#define MAXPATH	    1024
/* maximum chars for UTF-8 representations of Unicode chars, per Unicode char */
#define UTF8REPMAX 6

size_t u8_string_to_unicode(uint32_t* us, const char* s, const size_t max);
size_t unicode_string_to_u8(char* s, const uint32_t* us, const size_t max);
size_t u32_match_msgid_ending(const uint32_t* msgid, uint32_t* msgstr,
	size_t max);
size_t u32_count_chars(const uint32_t* s, const uint32_t ch);
size_t u32_count_strings(const uint32_t* haystack, const uint32_t* needle);
size_t u32_encode_tabs(uint32_t* s, size_t max);
size_t u32_decode_tabs(uint32_t* s, size_t max);
size_t u32_strlen(const uint32_t* s);
uint32_t* u32_strstr(uint32_t* haystack, const uint32_t* needle);
uint32_t* u32_strchr(uint32_t* haystack, const uint32_t needle);
size_t u32_strcpy(uint32_t* to, const uint32_t* from);
size_t u32_strncpy(uint32_t* to, const uint32_t* from, size_t max);
size_t u32_strncat(uint32_t* to, const uint32_t* from, size_t max);
size_t u32_u8_strncpy(uint32_t* to, const char* from, size_t max);
size_t u8_u32_strncpy(char* to, const uint32_t* from, size_t max);
size_t u32_lines_in_string(const uint32_t* s, const int include_eol,
	const size_t wrap);
size_t u32_next_line(const uint32_t* s, const uint32_t** sptr,
	const int include_eol, const size_t wrap);
int u32_is_word_boundary(const uint32_t ch, const int strictly_whitespace);
int starts_with(const char* s, const char* with);
int u32_starts_with(const uint32_t* s, const uint32_t* with);
const char* u8_basename(const char* path);
void poe_log(const char* msg, ...);