178 |
/* Check if the host comes with a port spec, if so, chop it */ |
/* Check if the host comes with a port spec, if so, chop it */ |
179 |
colon = strchr (rest, ':'); |
colon = strchr (rest, ':'); |
180 |
if (colon){ |
if (colon){ |
|
*port = atoi (colon+1); |
|
|
|
|
|
if (*port <= 0 || *port >= 65536) |
|
|
*port = 21; |
|
181 |
*colon = 0; |
*colon = 0; |
182 |
|
if (sscanf(colon+1, "%d", port)==1) { |
183 |
|
if (*port <= 0 || *port >= 65536) |
184 |
|
*port = default_port; |
185 |
|
} else { |
186 |
|
while(1) { |
187 |
|
colon++; |
188 |
|
switch(*colon) { |
189 |
|
case 'C': *port = 1; |
190 |
|
break; |
191 |
|
case 'r': *port = 2; |
192 |
|
break; |
193 |
|
case 0: goto done; |
194 |
|
} |
195 |
|
} |
196 |
|
} |
197 |
} |
} |
198 |
|
done: |
199 |
*host = strdup (rest); |
*host = strdup (rest); |
200 |
|
|
201 |
free (pcopy); |
free (pcopy); |