]> git.ipfire.org Git - thirdparty/git.git/blame - bundle-uri.h
Merge branch 'jk/avoid-redef-system-functions-2.30'
[thirdparty/git.git] / bundle-uri.h
CommitLineData
53a50892
DS
1#ifndef BUNDLE_URI_H
2#define BUNDLE_URI_H
3
0634f717
DS
4#include "hashmap.h"
5#include "strbuf.h"
6
53a50892 7struct repository;
0634f717
DS
8struct 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 */
16struct 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;
c23f5921
DS
31
32 /**
33 * If the bundle has been downloaded, then 'file' is a
34 * filename storing its contents. Otherwise, 'file' is
35 * NULL.
36 */
37 char *file;
38
39 /**
40 * If the bundle has been unbundled successfully, then
41 * this boolean is true.
42 */
43 unsigned unbundled:1;
0634f717
DS
44};
45
46#define REMOTE_BUNDLE_INFO_INIT { 0 }
47
48enum bundle_list_mode {
49 BUNDLE_MODE_NONE = 0,
50 BUNDLE_MODE_ALL,
51 BUNDLE_MODE_ANY
52};
53
54/**
55 * A bundle_list contains an unordered set of remote_bundle_info structs,
56 * as well as information about the bundle listing, such as version and
57 * mode.
58 */
59struct bundle_list {
60 int version;
61 enum bundle_list_mode mode;
62 struct hashmap bundles;
63};
64
65void init_bundle_list(struct bundle_list *list);
66void clear_bundle_list(struct bundle_list *list);
67
68typedef int (*bundle_iterator)(struct remote_bundle_info *bundle,
69 void *data);
70
71int for_all_bundles_in_list(struct bundle_list *list,
72 bundle_iterator iter,
73 void *data);
53a50892 74
d796cedb
ÆAB
75struct FILE;
76void print_bundle_list(FILE *fp, struct bundle_list *list);
77
738e5245
DS
78/**
79 * A bundle URI may point to a bundle list where the key=value
80 * pairs are provided in config file format. This method is
81 * exposed publicly for testing purposes.
82 */
83int bundle_uri_parse_config_format(const char *uri,
84 const char *filename,
85 struct bundle_list *list);
86
53a50892
DS
87/**
88 * Fetch data from the given 'uri' and unbundle the bundle data found
89 * based on that information.
90 *
91 * Returns non-zero if no bundle information is found at the given 'uri'.
92 */
93int fetch_bundle_uri(struct repository *r, const char *uri);
94
9424e373
ÆAB
95/**
96 * General API for {transport,connect}.c etc.
97 */
98
99/**
100 * Parse a "key=value" packet line from the bundle-uri verb.
101 *
102 * Returns 0 on success and non-zero on error.
103 */
104int bundle_uri_parse_line(struct bundle_list *list,
105 const char *line);
106
53a50892 107#endif