diff options
| author | grunfink <grunfink@comam.es> | 2025-04-27 05:14:09 +0200 |
|---|---|---|
| committer | grunfink <grunfink@comam.es> | 2025-04-27 05:14:09 +0200 |
| commit | ae9afd47e7b9df111312bb4a6243fdc05101dd55 (patch) | |
| tree | dbf4af7765386786e49f9be780e5856e20135cdd /utils.c | |
| parent | 169c5c8c070c527e7462e6ac86b916e94649c1ac (diff) | |
Replaced tabs with spaces.
Diffstat (limited to 'utils.c')
| -rw-r--r-- | utils.c | 62 |
1 files changed, 31 insertions, 31 deletions
@@ -914,58 +914,58 @@ void import_csv(snac *user) } static const struct { - const char *proto; - unsigned short default_port; + const char *proto; + unsigned short default_port; } FALLBACK_PORTS[] = { - /* caution: https > http, smpts > smtp */ - {"https", 443}, - {"http", 80}, + /* caution: https > http, smpts > smtp */ + {"https", 443}, + {"http", 80}, {"smtps", 465}, - {"smtp", 25} + {"smtp", 25} }; int parse_port(const char *url, const char **errstr) { - const char *col, *rcol; - int tmp, ret = -1; + const char *col, *rcol; + int tmp, ret = -1; if (errstr) - *errstr = NULL; + *errstr = NULL; - if (!(col = strchr(url, ':'))) { + if (!(col = strchr(url, ':'))) { if (errstr) - *errstr = "bad url"; + *errstr = "bad url"; - return -1; - } - - for (size_t i = 0; i < sizeof(FALLBACK_PORTS) / sizeof(*FALLBACK_PORTS); ++i) { - if (memcmp(url, FALLBACK_PORTS[i].proto, strlen(FALLBACK_PORTS[i].proto)) == 0) { - ret = FALLBACK_PORTS[i].default_port; - break; - } - } + return -1; + } + + for (size_t i = 0; i < sizeof(FALLBACK_PORTS) / sizeof(*FALLBACK_PORTS); ++i) { + if (memcmp(url, FALLBACK_PORTS[i].proto, strlen(FALLBACK_PORTS[i].proto)) == 0) { + ret = FALLBACK_PORTS[i].default_port; + break; + } + } - if (!(rcol = strchr(col + 1, ':'))) - rcol = col; + if (!(rcol = strchr(col + 1, ':'))) + rcol = col; - if (rcol) { - tmp = atoi(rcol + 1); + if (rcol) { + tmp = atoi(rcol + 1); if (tmp == 0) { - if (ret != -1) + if (ret != -1) return ret; - + if (errstr) *errstr = strerror(errno); return -1; } - - return tmp; - } + + return tmp; + } if (errstr) - *errstr = "unknown protocol"; + *errstr = "unknown protocol"; - return -1; + return -1; } |