]> git.ipfire.org Git - thirdparty/git.git/blob - bundle-uri.h
bundle-uri: parse bundle list in config format
[thirdparty/git.git] / bundle-uri.h
1 #ifndef BUNDLE_URI_H
2 #define BUNDLE_URI_H
3
4 #include "hashmap.h"
5 #include "strbuf.h"
6
7 struct repository;
8 struct string_list;
9
10 /**
11 * The remote_bundle_info struct contains information for a single bundle
12 * URI. This may be initialized simply by a given URI or might have
13 * additional metadata associated with it if the bundle was advertised by
14 * a bundle list.
15 */
16 struct remote_bundle_info {
17 struct hashmap_entry ent;
18
19 /**
20 * The 'id' is a name given to the bundle for reference
21 * by other bundle infos.
22 */
23 char *id;
24
25 /**
26 * The 'uri' is the location of the remote bundle so
27 * it can be downloaded on-demand. This will be NULL
28 * if there was no table of contents.
29 */
30 char *uri;
31 };
32
33 #define REMOTE_BUNDLE_INFO_INIT { 0 }
34
35 enum bundle_list_mode {
36 BUNDLE_MODE_NONE = 0,
37 BUNDLE_MODE_ALL,
38 BUNDLE_MODE_ANY
39 };
40
41 /**
42 * A bundle_list contains an unordered set of remote_bundle_info structs,
43 * as well as information about the bundle listing, such as version and
44 * mode.
45 */
46 struct bundle_list {
47 int version;
48 enum bundle_list_mode mode;
49 struct hashmap bundles;
50 };
51
52 void init_bundle_list(struct bundle_list *list);
53 void clear_bundle_list(struct bundle_list *list);
54
55 typedef int (*bundle_iterator)(struct remote_bundle_info *bundle,
56 void *data);
57
58 int for_all_bundles_in_list(struct bundle_list *list,
59 bundle_iterator iter,
60 void *data);
61
62 struct FILE;
63 void print_bundle_list(FILE *fp, struct bundle_list *list);
64
65 /**
66 * A bundle URI may point to a bundle list where the key=value
67 * pairs are provided in config file format. This method is
68 * exposed publicly for testing purposes.
69 */
70 int bundle_uri_parse_config_format(const char *uri,
71 const char *filename,
72 struct bundle_list *list);
73
74 /**
75 * Fetch data from the given 'uri' and unbundle the bundle data found
76 * based on that information.
77 *
78 * Returns non-zero if no bundle information is found at the given 'uri'.
79 */
80 int fetch_bundle_uri(struct repository *r, const char *uri);
81
82 /**
83 * General API for {transport,connect}.c etc.
84 */
85
86 /**
87 * Parse a "key=value" packet line from the bundle-uri verb.
88 *
89 * Returns 0 on success and non-zero on error.
90 */
91 int bundle_uri_parse_line(struct bundle_list *list,
92 const char *line);
93
94 #endif