Blame


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