1 #ifndef OSCAM_STRING_H_
2 #define OSCAM_STRING_H_
4 bool cs_malloc(void *result
, size_t size
) MUST_CHECK_RESULT
;
5 bool cs_realloc(void *result
, size_t size
) MUST_CHECK_RESULT
;
6 char *cs_strdup(const char *str
);
7 size_t cs_strlen(const char *c
);
8 void cs_strncpy(char *destination
, const char *source
, size_t num
);
9 bool cs_strncat(char *destination
, char *source
, size_t destination_size
);
10 char *strtolower(char *txt
);
11 char *strtoupper(char *txt
);
12 char *trim(char *txt
);
13 char *trim2(char *txt
);
14 char *remove_white_chars(char *txt
);
15 bool streq(const char *s1
, const char *s2
);
17 char *cs_hexdump(int32_t m
, const uint8_t *buf
, int32_t n
, char *target
, int32_t len
);
18 bool gethexval_within_range(char c
);
19 int32_t gethexval(char c
);
20 int32_t cs_atob(uint8_t *buf
, char *asc
, int32_t n
);
21 uint32_t cs_atoi(char *asc
, int32_t l
, int32_t val_on_err
);
22 int32_t byte_atob(char *asc
);
23 int32_t word_atob(char *asc
);
24 int32_t dyn_word_atob(char *asc
);
25 int32_t key_atob_l(char *asc
, uint8_t *bin
, int32_t l
);
26 uint32_t b2i(int32_t n
, const uint8_t *b
);
27 uint64_t b2ll(int32_t n
, const uint8_t *b
);
28 uint8_t *i2b_buf(int32_t n
, uint32_t i
, uint8_t *b
);
29 uint8_t *ull2b_buf(uint64_t i
, uint8_t *b
);
30 uint32_t a2i(char *asc
, int32_t bytes
);
31 int32_t boundary(int32_t exp
, int32_t n
);
32 int32_t array_has_nonzero_byte(uint8_t *value
, int32_t length
);
34 void get_random_bytes_init(void);
35 void get_random_bytes(uint8_t *dst
, uint32_t dst_len
);
37 uint32_t crc32(uint32_t crc
, const uint8_t *buf
, uint32_t len
);
38 uint16_t ccitt_crc(uint8_t *data
, size_t length
, uint16_t seed
, uint16_t final
);
39 uint32_t ccitt32_crc(uint8_t *data
, size_t len
);
40 uint32_t jhash(const char *key
, size_t len
);
42 char to_hex(char code
);
43 void char_to_hex(const uint8_t *p_array
, uint32_t p_array_len
, uint8_t *result
);
45 #define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
46 void base64_encode(const char *in
, size_t inlen
, char *out
, size_t outlen
);
47 size_t b64encode(const char *in
, size_t inlen
, char **out
);
49 void b64prepare(void);
50 int32_t b64decode(uint8_t *result
);
52 #ifdef READ_SDT_CHARSETS
53 size_t ISO6937toUTF8(const uint8_t **inbuf
, size_t *inbytesleft
, uint8_t **outbuf
, size_t *outbytesleft
);
54 size_t ISO8859toUTF8(int8_t iso_table_number
, const uint8_t **inbuf
, size_t *inbytesleft
, uint8_t **outbuf
, size_t *outbytesleft
);
56 size_t UnicodetoUTF8(const uint8_t **inbuf
, size_t *inbytesleft
, uint8_t **outbuf
, size_t *outbytesleft
);