Concord - C Discord API library
A Discord API wrapper library written in C
cog-utils.h
Go to the documentation of this file.
1#ifndef COG_UTILS_H
2#define COG_UTILS_H
3
4#include <stdio.h>
5#include <stdint.h>
6#include "attributes.h"
7
8#ifdef __cplusplus
9extern "C" {
10#endif /* __cplusplus */
11
19char *cog_load_whole_file_fp(FILE *fp, size_t *len);
29char *cog_load_whole_file(const char filename[], size_t *len);
30
36long cog_timezone(void);
37
48int cog_iso8601_to_unix_ms(const char str[], size_t len, uint64_t *p_value);
49
58int cog_unix_ms_to_iso8601(char str[], size_t len, const uint64_t value);
59
69int cog_strtou64(char *str, size_t len, uint64_t *p_value);
70
79int cog_u64tostr(char *str, size_t len, uint64_t *p_value);
80
90size_t cog_strndup(const char src[], size_t len, char **p_dest);
91
101size_t cog_asprintf(char **strp, const char fmt[], ...) PRINTF_LIKE(2, 3);
102
109int cog_sleep_ms(const long tms);
110
117int cog_sleep_us(const long tms);
118
124uint64_t cog_timestamp_ms(void);
125
131uint64_t cog_timestamp_us(void);
132
133#ifdef __cplusplus
134}
135#endif /* __cplusplus */
136
137#endif /* COG_UTILS_H */
#define PRINTF_LIKE(a, b)
Definition: attributes.h:4
int cog_u64tostr(char *str, size_t len, uint64_t *p_value)
Convert uint64_t to a numerical string.
int cog_sleep_ms(const long tms)
Sleep for amount of milliseconds.
long cog_timezone(void)
Get the difference between UTC and the latest local standard time, in seconds.
char * cog_load_whole_file_fp(FILE *fp, size_t *len)
Load file contents into a string.
int cog_iso8601_to_unix_ms(const char str[], size_t len, uint64_t *p_value)
Convert a iso8601 string to a unix timestamp (milliseconds)
int cog_unix_ms_to_iso8601(char str[], size_t len, const uint64_t value)
Convert a unix timestamp (milliseconds) to a iso8601 string.
char * cog_load_whole_file(const char filename[], size_t *len)
Load file contents into a string.
int cog_strtou64(char *str, size_t len, uint64_t *p_value)
Convert a numerical string to uint64_t
size_t cog_asprintf(char **strp, const char fmt[],...)
Copies at most len bytes of src to *p_dest.
size_t cog_strndup(const char src[], size_t len, char **p_dest)
Copies at most len bytes of src to *p_dest.
uint64_t cog_timestamp_us(void)
Get the current timestamp in microseconds.
uint64_t cog_timestamp_ms(void)
Get the current timestamp in milliseconds.
int cog_sleep_us(const long tms)
Sleep for amount of microseconds.