Look for a HOST specification of the form "HOST:PATH", "HOST::PATH", or * "rsync://HOST:PORT/PATH". If found, *host_ptr will be set to some allocated * memory with the HOST. If a daemon-accessing spec was specified, the value * of *port_ptr will contain a non-0 port number, otherwise it will be set to * 0. The return value is a pointer to the PATH. Note that the HOST spec can * be an IPv6
| 3128 | * be an IPv6 literal address enclosed in '[' and ']' (such as "[::1]" or |
| 3129 | * "[::ffff:127.0.0.1]") which is returned without the '[' and ']'. */ |
| 3130 | char *check_for_hostspec(char *s, char **host_ptr, int *port_ptr) |
| 3131 | { |
| 3132 | char *path; |
| 3133 | |
| 3134 | if (port_ptr && strncasecmp(URL_PREFIX, s, strlen(URL_PREFIX)) == 0) { |
| 3135 | *host_ptr = parse_hostspec(s + strlen(URL_PREFIX), &path, port_ptr); |
| 3136 | if (*host_ptr) { |
| 3137 | if (!*port_ptr) |
| 3138 | *port_ptr = -1; /* -1 indicates they want the default */ |
| 3139 | return path; |
| 3140 | } |
| 3141 | } |
| 3142 | |
| 3143 | *host_ptr = parse_hostspec(s, &path, NULL); |
| 3144 | if (!*host_ptr) |
| 3145 | return NULL; |
| 3146 | |
| 3147 | if (*path == ':') { |
| 3148 | if (port_ptr && !*port_ptr) |
| 3149 | *port_ptr = -1; |
| 3150 | return path + 1; |
| 3151 | } |
| 3152 | if (port_ptr) |
| 3153 | *port_ptr = 0; |
| 3154 | |
| 3155 | return path; |
| 3156 | } |
no test coverage detected