/* * Created by yuuta on 3/19/23. */ #include "utils.h" #include #include #include #include uint32_t tg_url_get_index(const char *url) { char *tok = strrchr(url, '/'); if (!tok) { return 0; } char *endptr; uintmax_t unum = strtoumax(tok + 1, &endptr, 10); if (strcmp(endptr, "") != 0 || (unum == UINTMAX_MAX && errno == ERANGE)) { return 0; } if (unum > UINT32_MAX) { return 0; } return (uint32_t) unum; }