summaryrefslogtreecommitdiff
path: root/src/pkt.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-06-16 02:17:49 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2011-06-26 20:43:44 +0200
commitfd6790210f646a61c750058261d29f6a68485e67 (patch)
tree8e364cf2fd46bb9280f596155869081b82ea626e /src/pkt.c
parentcbf742ac4e7daccae10fd60d0651242c49663bd3 (diff)
downloadlibgit2-fd6790210f646a61c750058261d29f6a68485e67.tar.gz
Move git_pkt_{gen_proto,send_request} to transport_git.c
This is where they really belong. Remvoe the prefix and make them static. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/pkt.c')
-rw-r--r--src/pkt.c58
1 files changed, 0 insertions, 58 deletions
diff --git a/src/pkt.c b/src/pkt.c
index 403850b08..eb51fe98a 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -201,64 +201,6 @@ void git_pkt_free(git_pkt *pkt)
free(pkt);
}
-/*
- * Create a git procol request.
- *
- * For example: 0035git-upload-pack /libgit2/libgit2\0host=github.com\0
- *
- * TODO: the command should not be hard-coded
- */
-int git_pkt_gen_proto(char **out, int *outlen, const char *cmd, const char *url)
-{
- char *delim, *repo, *ptr;
- char default_command[] = "git-upload-pack";
- char host[] = "host=";
- int len;
-
- delim = strchr(url, '/');
- if (delim == NULL)
- return git__throw(GIT_EOBJCORRUPTED, "Failed to create proto-request: malformed URL");
-
- repo = delim;
-
- delim = strchr(url, ':');
- if (delim == NULL)
- delim = strchr(url, '/');
-
- if (cmd == NULL)
- cmd = default_command;
-
- len = 4 + strlen(cmd) + 1 + strlen(repo) + 1 + STRLEN(host) + (delim - url) + 2;
-
- *out = git__malloc(len);
- if (*out == NULL)
- return GIT_ENOMEM;
-
- *outlen = len - 1;
- ptr = *out;
- memset(ptr, 0x0, len);
- /* We expect the return value to be > len - 1 so don't bother checking it */
- snprintf(ptr, len -1, "%04x%s %s%c%s%s", len - 1, cmd, repo, 0, host, url);
-
- return GIT_SUCCESS;
-}
-
-int git_pkt_send_request(int s, const char *cmd, const char *url)
-{
- int error, len;
- char *msg = NULL;
-
- error = git_pkt_gen_proto(&msg, &len, cmd, url);
- if (error < GIT_SUCCESS)
- goto cleanup;
-
- error = gitno_send(s, msg, len, 0);
-
-cleanup:
- free(msg);
- return error;
-}
-
int git_pkt_send_flush(int s)
{
char flush[] = "0000";