Blob


1 /*
2 * Copyright (c) 2018, 2019 Ori Bernstein <ori@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 /* IANA assigned */
18 #define GOT_DEFAULT_GIT_PORT 9418
19 #define GOT_DEFAULT_GIT_PORT_STR "9418"
21 #ifndef GOT_FETCH_PATH_SSH
22 #define GOT_FETCH_PATH_SSH "/usr/bin/ssh"
23 #endif
25 #define GOT_FETCH_DEFAULT_REMOTE_NAME "origin"
27 #define GOT_FETCH_PKTMAX 65536
29 /*
30 * Attempt to parse a URI into the following parts:
31 * A protocol scheme, hostname, port number (as a string), path on server,
32 * and a repository name. If the URI lacks some of this information return
33 * default values where applicable.
34 * The results of this function must be passed to other functions below.
35 * The caller should dispose of the returned values with free(3).
36 */
37 const struct got_error *got_fetch_parse_uri(char **, char **, char **,
38 char **, char **, const char *);
40 /*
41 * Attempt to open a connection to a server using the provided protocol
42 * scheme, hostname port number (as a string) and server-side path.
43 * A verbosity level can be specified; it currently controls the amount
44 * of -v options passed to ssh(1). If the level is -1 ssh(1) will be run
45 * with the -q option.
46 * If successful return an open file descriptor for the connection which can
47 * be passed to other functions below, and must be disposed of with close(2).
48 */
49 const struct got_error *got_fetch_connect(int *, const char *, const char *,
50 const char *, const char *, int);
52 /* A callback function which gets invoked with progress information to print. */
53 typedef const struct got_error *(*got_fetch_progress_cb)(void *,
54 const char *, off_t, int, int, int, int);
56 /*
57 * Attempt to fetch a packfile from a server. This pack file will contain
58 * objects which that are not yet contained in the provided repository.
59 * Return the hash of the packfile (in form of an object ID) and lists of
60 * references and symbolic references learned from the server.
61 */
62 const struct got_error *got_fetch_pack(struct got_object_id **,
63 struct got_pathlist_head *, struct got_pathlist_head *, const char *,
64 int, struct got_repository *, got_fetch_progress_cb, void *);