]> git.proxmox.com Git - libgit2.git/blob - src/pkt.h
Merge pull request #392 from sschuberth/development
[libgit2.git] / src / pkt.h
1 /*
2 * Copyright (C) 2009-2011 the libgit2 contributors
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7
8 #ifndef INCLUDE_pkt_h__
9 #define INCLUDE_pkt_h__
10
11 #include "common.h"
12 #include "transport.h"
13 #include "git2/net.h"
14
15 enum git_pkt_type {
16 GIT_PKT_CMD,
17 GIT_PKT_FLUSH,
18 GIT_PKT_REF,
19 GIT_PKT_HAVE,
20 GIT_PKT_ACK,
21 GIT_PKT_NAK,
22 GIT_PKT_PACK,
23 };
24
25 /* Used for multi-ack */
26 enum git_ack_status {
27 GIT_ACK_NONE,
28 GIT_ACK_CONTINUE,
29 GIT_ACK_COMMON,
30 GIT_ACK_READY
31 };
32
33 /* This would be a flush pkt */
34 typedef struct {
35 enum git_pkt_type type;
36 } git_pkt;
37
38 struct git_pkt_cmd {
39 enum git_pkt_type type;
40 char *cmd;
41 char *path;
42 char *host;
43 };
44
45 /* This is a pkt-line with some info in it */
46 typedef struct {
47 enum git_pkt_type type;
48 git_remote_head head;
49 char *capabilities;
50 } git_pkt_ref;
51
52 /* Useful later */
53 typedef struct {
54 enum git_pkt_type type;
55 git_oid oid;
56 enum git_ack_status status;
57 } git_pkt_ack;
58
59 int git_pkt_parse_line(git_pkt **head, const char *line, const char **out, size_t len);
60 int git_pkt_send_flush(int s);
61 int git_pkt_send_done(int s);
62 int git_pkt_send_wants(git_headarray *refs, git_transport_caps *caps, int fd);
63 int git_pkt_send_have(git_oid *oid, int fd);
64 void git_pkt_free(git_pkt *pkt);
65
66 #endif