Compares if str has a specific path prefix. This differs from a regular prefix in two ways. First of all there may be multiple slashes separating the path elements, and secondly, if a prefix is matched that has to be en entire path element. For instance /a/prefix matches /a/prefix/foo/bar, but not /a/prefixfoo/bar. */
| 211 | path element. For instance /a/prefix matches /a/prefix/foo/bar, |
| 212 | but not /a/prefixfoo/bar. */ |
| 213 | bool |
| 214 | has_path_prefix (const char *str, |
| 215 | const char *prefix) |
| 216 | { |
| 217 | while (true) |
| 218 | { |
| 219 | /* Skip consecutive slashes to reach next path |
| 220 | element */ |
| 221 | while (*str == '/') |
| 222 | str++; |
| 223 | while (*prefix == '/') |
| 224 | prefix++; |
| 225 | |
| 226 | /* No more prefix path elements? Done! */ |
| 227 | if (*prefix == 0) |
| 228 | return true; |
| 229 | |
| 230 | /* Compare path element */ |
| 231 | while (*prefix != 0 && *prefix != '/') |
| 232 | { |
| 233 | if (*str != *prefix) |
| 234 | return false; |
| 235 | str++; |
| 236 | prefix++; |
| 237 | } |
| 238 | |
| 239 | /* Matched prefix path element, |
| 240 | must be entire str path element */ |
| 241 | if (*str != '/' && *str != 0) |
| 242 | return false; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | bool |
| 247 | path_equal (const char *path1, |
no outgoing calls