38 const char *message = reason;
42 char *endofflags = strstr(m,
"]");
45 if (m[0] ==
'[' && endofflags)
47 message = strstr(reason,
"]") + 1;
50 const char *token = strtok(m,
"[,");
53 if (!strncmp(token,
"backoff ", strlen(
"backoff ")))
57 msg(
D_PUSH,
"invalid AUTH_FAIL,TEMP flag: %s", token);
61 else if (!strncmp(token,
"advance ", strlen(
"advance ")))
63 token += strlen(
"advance ");
64 if (!strcmp(token,
"no"))
68 else if (!strcmp(token,
"remote"))
73 else if (!strcmp(token,
"addr"))
83 token = strtok(NULL,
"[,");
89 if (!message || message[0] !=
':')
106 long long i = strtoll(str, &endptr, 10);
108 if (i < INT_MIN || (positive && i < 0) || *endptr !=
'\0' || i > INT_MAX)
122 long long i = strtoll(str, &endptr, 10);
124 if (i < 0 || *endptr !=
'\0' || i > INT_MAX)
126 msg(msglevel,
"Cannot parse argument '%s' as non-negative integer",
138 long long i = strtoll(str, &endptr, 10);
140 if (i < INT_MIN || *endptr !=
'\0' || i > INT_MAX)
142 msg(msglevel,
"Cannot parse argument '%s' as integer", str);
char * string_alloc(const char *str, struct gc_arena *gc)
static void gc_free(struct gc_arena *a)
static struct gc_arena gc_new(void)
int positive_atoi(const char *str, int msglevel)
Converts a str to a positive number if the string represents a postive integer number.
int atoi_warn(const char *str, int msglevel)
Converts a str to an integer if the string can be represented as an integer number.
const char * parse_auth_failed_temp(struct options *o, const char *reason)
bool valid_integer(const char *str, bool positive)
Checks if the string is a valid integer by checking if it can be converted to an integer.
Garbage collection arena used to keep track of dynamically allocated memory.