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 /*
28 * Attempt to parse a URI into the following parts:
29 * A protocol scheme, hostname, port number (as a string), path on server,
30 * and a repository name. If the URI lacks some of this information return
31 * default values where applicable.
32 * The results of this function must be passed to other functions below.
33 * The caller should dispose of the returned values with free(3).
34 */
35 const struct got_error *got_fetch_parse_uri(char **, char **, char **,
36 char **, char **, const char *);
38 /*
39 * Attempt to open a connection to a server using the provided protocol
40 * scheme, hostname port number (as a string) and server-side path.
41 * A verbosity level can be specified; it currently controls the amount
42 * of -v options passed to ssh(1). If the level is -1 ssh(1) will be run
43 * with the -q option.
44 * If successful return an open file descriptor for the connection which can
45 * be passed to other functions below, and must be disposed of with close(2).
46 */
47 const struct got_error *got_fetch_connect(int *, const char *, const char *,
48 const char *, const char *, int);
50 /* A callback function which gets invoked with progress information to print. */
51 typedef const struct got_error *(*got_fetch_progress_cb)(void *,
52 const char *, off_t, int, int, int, int);
54 /*
55 * Attempt to fetch a packfile from a server. This pack file will contain
56 * objects which that are not yet contained in the provided repository.
57 * Return the hash of the packfile (in form of an object ID) and lists of
58 * references and symbolic references learned from the server.
59 */
60 const struct got_error *got_fetch_pack(struct got_object_id **,
61 struct got_pathlist_head *, struct got_pathlist_head *, const char *,
62 int, struct got_repository *, got_fetch_progress_cb, void *);