commit ae9afd4

grunfink  ·  2025-04-27 03:14:09 +0000 UTC
parent 169c5c8
Replaced tabs with spaces.
1 files changed,  +34, -34
+34, -34
 1@@ -914,58 +914,58 @@ void import_csv(snac *user)
 2 }
 3 
 4 static const struct {
 5-	const char *proto;
 6-	unsigned short default_port;
 7+    const char *proto;
 8+    unsigned short default_port;
 9 } FALLBACK_PORTS[] = {
10-	/* caution: https > http, smpts > smtp */
11-	{"https", 443},
12-	{"http",  80},
13+    /* caution: https > http, smpts > smtp */
14+    {"https", 443},
15+    {"http",  80},
16     {"smtps", 465},
17-	{"smtp", 25}
18+    {"smtp", 25}
19 };
20 
21 int parse_port(const char *url, const char **errstr)
22 {
23-	const char *col, *rcol;
24-	int tmp, ret = -1;
25+    const char *col, *rcol;
26+    int tmp, ret = -1;
27 
28     if (errstr)
29-	    *errstr = NULL;
30+        *errstr = NULL;
31 
32-	if (!(col = strchr(url, ':'))) {
33+    if (!(col = strchr(url, ':'))) {
34         if (errstr)
35-		    *errstr = "bad url";
36-
37-		return -1;
38-	}
39-	
40-	for (size_t i = 0; i < sizeof(FALLBACK_PORTS) / sizeof(*FALLBACK_PORTS); ++i) {
41-		if (memcmp(url, FALLBACK_PORTS[i].proto, strlen(FALLBACK_PORTS[i].proto)) == 0) {
42-			ret = FALLBACK_PORTS[i].default_port;
43-			break;
44-		}
45-	}
46-
47-	if (!(rcol = strchr(col + 1, ':')))
48-		rcol = col;
49-
50-	if (rcol) {
51-		tmp = atoi(rcol + 1);
52+            *errstr = "bad url";
53+
54+        return -1;
55+    }
56+
57+    for (size_t i = 0; i < sizeof(FALLBACK_PORTS) / sizeof(*FALLBACK_PORTS); ++i) {
58+        if (memcmp(url, FALLBACK_PORTS[i].proto, strlen(FALLBACK_PORTS[i].proto)) == 0) {
59+            ret = FALLBACK_PORTS[i].default_port;
60+            break;
61+        }
62+    }
63+
64+    if (!(rcol = strchr(col + 1, ':')))
65+        rcol = col;
66+
67+    if (rcol) {
68+        tmp = atoi(rcol + 1);
69         if (tmp == 0) {
70-            if (ret != -1) 
71+            if (ret != -1)
72                 return ret;
73-            
74+
75             if (errstr)
76                 *errstr = strerror(errno);
77 
78             return -1;
79         }
80-		
81-		return tmp;
82-	}
83+
84+        return tmp;
85+    }
86 
87     if (errstr)
88-	    *errstr = "unknown protocol";
89+        *errstr = "unknown protocol";
90 
91-	return -1;
92+    return -1;
93 }