* General API for {transport,connect}.c etc. */
| 978 | * General API for {transport,connect}.c etc. |
| 979 | */ |
| 980 | int bundle_uri_parse_line(struct bundle_list *list, const char *line) |
| 981 | { |
| 982 | int result; |
| 983 | const char *equals; |
| 984 | struct strbuf key = STRBUF_INIT; |
| 985 | |
| 986 | if (!strlen(line)) |
| 987 | return error(_("bundle-uri: got an empty line")); |
| 988 | |
| 989 | equals = strchr(line, '='); |
| 990 | |
| 991 | if (!equals) |
| 992 | return error(_("bundle-uri: line is not of the form 'key=value'")); |
| 993 | if (line == equals || !*(equals + 1)) |
| 994 | return error(_("bundle-uri: line has empty key or value")); |
| 995 | |
| 996 | strbuf_add(&key, line, equals - line); |
| 997 | result = bundle_list_update(key.buf, equals + 1, list); |
| 998 | strbuf_release(&key); |
| 999 | |
| 1000 | return result; |
| 1001 | } |