1#include "core/aqm_platform.h"
15int aqm_mkdir_p(
const char *path) {
16 if (!path || !path[0])
19 if (_mkdir(path) != 0) {
20 DWORD err = GetLastError();
21 if (err != ERROR_ALREADY_EXISTS)
26 if (mkdir(path, 0755) != 0) {
34void aqm_sleep_seconds(
unsigned seconds) {
36 Sleep((DWORD)seconds * 1000U);
42void aqm_flush_stdin(
void) {
44 while ((c = getchar()) !=
'\n' && c != EOF)
48int aqm_parse_int(
const char *input,
int *out) {
54 long value = strtol(input, &endptr, 10);
55 if (endptr == input || errno != 0)
57 while (*endptr !=
'\0' && isspace((
unsigned char)*endptr))
61 if (value < INT_MIN || value > INT_MAX)
67int aqm_parse_float(
const char *input,
float *out) {
73 float value = strtof(input, &endptr);
74 if (endptr == input || errno != 0)
76 while (*endptr !=
'\0' && isspace((
unsigned char)*endptr))
84void aqm_trim_crlf(
char *s) {
88 while (n > 0 && (s[n - 1] ==
'\n' || s[n - 1] ==
'\r' || isspace((
unsigned char)s[n - 1]))) {