1 module git2.transport; 2 3 import git2.indexer; 4 import git2.net; 5 import git2.util; 6 import git2.types; 7 8 extern (C): 9 10 version (GIT_SSH) 11 { 12 static assert(0, "dlibgit does not support SSH yet."); 13 // import ssh2; 14 } 15 16 enum git_credtype_t { 17 GIT_CREDTYPE_USERPASS_PLAINTEXT = 1, 18 GIT_CREDTYPE_SSH_KEYFILE_PASSPHRASE = 2, 19 GIT_CREDTYPE_SSH_PUBLICKEY = 3, 20 } 21 mixin _ExportEnumMembers!git_credtype_t; 22 23 struct git_cred { 24 git_credtype_t credtype; 25 void function(git_cred *cred) free; 26 }; 27 28 struct git_cred_userpass_plaintext { 29 git_cred parent; 30 char *username; 31 char *password; 32 }; 33 34 version (GIT_SSH) 35 { 36 static assert(0, "dlibgit does not support SSH yet."); 37 // typedef LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC((*git_cred_sign_callback)); 38 39 struct git_cred_ssh_keyfile_passphrase { 40 git_cred parent; 41 char *publickey; 42 char *privatekey; 43 char *passphrase; 44 }; 45 46 struct git_cred_ssh_publickey { 47 git_cred parent; 48 char *publickey; 49 size_t publickey_len; 50 void *sign_callback; 51 void *sign_data; 52 }; 53 } 54 55 int git_cred_userpass_plaintext_new( 56 git_cred **out_, 57 const(char)* username, 58 const(char)* password); 59 60 version (GIT_SSH) 61 { 62 static assert(0, "dlibgit does not support SSH yet."); 63 // typedef LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC((*git_cred_sign_callback)); 64 65 int git_cred_ssh_keyfile_passphrase_new( 66 git_cred **out_, 67 const(char)* publickey, 68 const(char)* privatekey, 69 const(char)* passphrase); 70 71 int git_cred_ssh_publickey_new( 72 git_cred **out_, 73 const(char)* publickey, 74 size_t publickey_len, 75 git_cred_sign_callback, 76 void *sign_data); 77 } 78 79 alias git_cred_acquire_cb = int function( 80 git_cred **cred, 81 const(char)* url, 82 const(char)* username_from_url, 83 uint allowed_types, 84 void *payload); 85 86 enum git_transport_flags_t { 87 GIT_TRANSPORTFLAGS_NONE = 0, 88 GIT_TRANSPORTFLAGS_NO_CHECK_CERT = 1 89 } 90 mixin _ExportEnumMembers!git_transport_flags_t; 91 92 alias git_transport_message_cb = void function(const(char)* str, int len, void *data); 93 94 struct git_transport 95 { 96 uint version_ = GIT_TRANSPORT_VERSION; 97 98 int function(git_transport *transport, 99 git_transport_message_cb progress_cb, 100 git_transport_message_cb error_cb, 101 void *payload) set_callbacks; 102 int function(git_transport *transport, 103 const(char)* url, 104 git_cred_acquire_cb cred_acquire_cb, 105 void *cred_acquire_payload, 106 int direction, 107 int flags) connect; 108 int function(git_transport *transport, 109 git_headlist_cb list_cb, 110 void *payload) ls; 111 int function(git_transport *transport, git_push *push) push; 112 int function(git_transport *transport, 113 git_repository *repo, 114 const(git_remote_head**) refs_, 115 size_t count) negotiate_fetch; 116 int function(git_transport *transport, 117 git_repository *repo, 118 git_transfer_progress *stats, 119 git_transfer_progress_callback progress_cb, 120 void *progress_payload) download_pack; 121 int function(git_transport *transport) is_connected; 122 int function(git_transport *transport, int *flags) read_flags; 123 void function(git_transport *transport) cancel; 124 int function(git_transport *transport) close; 125 void function(git_transport *transport) free; 126 } 127 128 enum GIT_TRANSPORT_VERSION = 1; 129 enum git_transport GIT_TRANSPORT_INIT = { GIT_TRANSPORT_VERSION }; 130 131 int git_transport_new(git_transport **out_, git_remote *owner, const(char)* url); 132 133 alias git_transport_cb = int function(git_transport **out_, git_remote *owner, void *param); 134 135 int git_transport_dummy( 136 git_transport **out_, 137 git_remote *owner, 138 /* NULL */ void *payload); 139 int git_transport_local( 140 git_transport **out_, 141 git_remote *owner, 142 /* NULL */ void *payload); 143 int git_transport_smart( 144 git_transport **out_, 145 git_remote *owner, 146 /* (git_smart_subtransport_definition *) */ void *payload); 147 enum git_smart_service_t { 148 GIT_SERVICE_UPLOADPACK_LS = 1, 149 GIT_SERVICE_UPLOADPACK = 2, 150 GIT_SERVICE_RECEIVEPACK_LS = 3, 151 GIT_SERVICE_RECEIVEPACK = 4, 152 } 153 mixin _ExportEnumMembers!git_smart_service_t; 154 155 struct git_smart_subtransport_stream { 156 git_smart_subtransport *subtransport; 157 158 int function( 159 git_smart_subtransport_stream *stream, 160 char *buffer, 161 size_t buf_size, 162 size_t *bytes_read) read; 163 int function( 164 git_smart_subtransport_stream *stream, 165 const(char)* buffer, 166 size_t len) write; 167 void function( 168 git_smart_subtransport_stream *stream) free; 169 } 170 171 struct git_smart_subtransport { 172 int function( 173 git_smart_subtransport_stream **out_, 174 git_smart_subtransport *transport, 175 const(char)* url, 176 git_smart_service_t action) action; 177 int function(git_smart_subtransport *transport) close; 178 void function(git_smart_subtransport *transport) free; 179 } 180 181 alias git_smart_subtransport_cb = int function( 182 git_smart_subtransport **out_, 183 git_transport* owner); 184 185 struct git_smart_subtransport_definition { 186 git_smart_subtransport_cb callback; 187 uint rpc; 188 } 189 190 int git_smart_subtransport_http( 191 git_smart_subtransport **out_, 192 git_transport* owner); 193 int git_smart_subtransport_git( 194 git_smart_subtransport **out_, 195 git_transport* owner); 196 int git_smart_subtransport_ssh( 197 git_smart_subtransport **out_, 198 git_transport* owner);