96 lines
1.6 KiB
C
Raw Normal View History

2009-04-30 14:25:52 +02:00
#ifndef __MISC_H__
#define __MISC_H__
#include <stdint.h>
2014-09-27 22:59:19 +02:00
#include <time.h>
2010-09-18 17:15:41 +02:00
struct onekeyval {
char *name;
char *value;
struct onekeyval *next;
struct onekeyval *sort;
2010-09-18 17:15:41 +02:00
};
struct keyval {
struct onekeyval *head;
struct onekeyval *tail;
};
2009-04-30 14:25:52 +02:00
int
safe_atoi32(const char *str, int32_t *val);
2009-04-30 14:25:52 +02:00
2010-02-08 14:58:14 +01:00
int
safe_atou32(const char *str, uint32_t *val);
2010-05-05 19:03:53 +02:00
int
safe_hextou32(const char *str, uint32_t *val);
2009-04-30 14:25:52 +02:00
int
safe_atoi64(const char *str, int64_t *val);
2010-01-10 12:09:29 +01:00
2010-02-08 14:58:14 +01:00
int
safe_atou64(const char *str, uint64_t *val);
2010-04-04 18:07:32 +02:00
int
safe_hextou64(const char *str, uint64_t *val);
2010-09-18 17:15:41 +02:00
/* Key/value functions */
struct keyval *
keyval_alloc(void);
2010-09-18 17:15:41 +02:00
int
keyval_add(struct keyval *kv, const char *name, const char *value);
int
keyval_add_size(struct keyval *kv, const char *name, const char *value, size_t size);
void
keyval_remove(struct keyval *kv, const char *name);
const char *
keyval_get(struct keyval *kv, const char *name);
void
keyval_clear(struct keyval *kv);
void
keyval_sort(struct keyval *kv);
2010-09-18 17:15:41 +02:00
char *
m_realpath(const char *pathname);
char *
unicode_fixup_string(char *str, const char *fromcode);
char *
trimwhitespace(const char *str);
uint32_t
djb_hash(const void *data, size_t len);
2009-05-01 20:56:22 +02:00
char *
b64_decode(const char *b64);
2010-04-12 18:22:38 +02:00
char *
2016-07-29 19:53:56 +02:00
b64_encode(const uint8_t *in, size_t len);
2010-04-12 18:22:38 +02:00
uint64_t
murmur_hash64(const void *key, int len, uint32_t seed);
2014-09-27 22:59:19 +02:00
/* Timer function for platforms without hi-res timers */
int
clock_gettime_with_res(clockid_t clock_id, struct timespec *tp, struct timespec *res);
struct timespec
timespec_add(struct timespec time1, struct timespec time2);
int
timespec_cmp(struct timespec time1, struct timespec time2);
2009-04-30 14:25:52 +02:00
#endif /* !__MISC_H__ */