Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2012-06-22 23:25:17 +0400
committerVicent Marti <tanoku@gmail.com>2012-06-22 23:25:17 +0400
commit798e4d53dcd2f5340782083130c0fb5227d596ac (patch)
tree8728939b3b0635833c36de2b0805e77464e50c28 /src/posix.c
parent2ae052d1b1574d1a4de402c91ebb98f061c997d4 (diff)
amigaos: Cleanup
Diffstat (limited to 'src/posix.c')
-rw-r--r--src/posix.c93
1 files changed, 92 insertions, 1 deletions
diff --git a/src/posix.c b/src/posix.c
index a9a6af984..985221dd5 100644
--- a/src/posix.c
+++ b/src/posix.c
@@ -12,6 +12,97 @@
#ifndef GIT_WIN32
+#ifdef NO_ADDRINFO
+int p_getaddrinfo(
+ const char *host,
+ const char *port,
+ struct addrinfo *hints,
+ struct addrinfo **info)
+{
+ GIT_UNUSED(hints);
+
+ struct addrinfo *ainfo, *ai;
+ int p = 0;
+
+ if ((ainfo = malloc(sizeof(struct addrinfo))) == NULL)
+ return -1;
+
+ if ((ainfo->ai_hostent = gethostbyname(host)) == NULL)
+ return -2;
+
+ ainfo->ai_servent = getservbyname(port, 0);
+
+ if (ainfo->ai_servent)
+ ainfo->ai_port = ainfo->ai_servent->s_port;
+ else
+ ainfo->ai_port = atol(port);
+
+ memcpy(&ainfo->ai_addr_in.sin_addr,
+ ainfo->ai_hostent->h_addr_list[0],
+ ainfo->ai_hostent->h_length);
+
+ ainfo->ai_protocol = 0;
+ ainfo->ai_socktype = hints->ai_socktype;
+ ainfo->ai_family = ainfo->ai_hostent->h_addrtype;
+ ainfo->ai_addr_in.sin_family = ainfo->ai_family;
+ ainfo->ai_addr_in.sin_port = ainfo->ai_port;
+ ainfo->ai_addr = (struct addrinfo *)&ainfo->ai_addr_in;
+ ainfo->ai_addrlen = sizeof(struct sockaddr_in);
+
+ *info = ainfo;
+
+ if (ainfo->ai_hostent->h_addr_list[1] == NULL) {
+ ainfo->ai_next = NULL;
+ return 0;
+ }
+
+ ai = ainfo;
+
+ for (p = 1; ainfo->ai_hostent->h_addr_list[p] != NULL; p++) {
+ ai->ai_next = malloc(sizeof(struct addrinfo));
+ memcpy(&ai->ai_next, ainfo, sizeof(struct addrinfo));
+ memcpy(&ai->ai_next->ai_addr_in.sin_addr,
+ ainfo->ai_hostent->h_addr_list[p],
+ ainfo->ai_hostent->h_length);
+ ai->ai_next->ai_addr = (struct addrinfo *)&ai->ai_next->ai_addr_in;
+ ai = ai->ai_next;
+ }
+
+ ai->ai_next = NULL;
+ return 0;
+}
+
+void p_freeaddrinfo(struct addrinfo *info)
+{
+ struct addrinfo *p, *next;
+
+ p = info;
+
+ while(p != NULL) {
+ next = p->ai_next;
+ free(p);
+ p = next;
+ }
+}
+
+const char *p_gai_strerror(int ret)
+{
+ switch(ret) {
+ case -1:
+ return "Out of memory";
+ break;
+
+ case -2:
+ return "Address lookup failed";
+ break;
+
+ default:
+ return "Unknown error";
+ break;
+ }
+}
+#endif /* NO_ADDRINFO */
+
int p_open(const char *path, int flags, ...)
{
mode_t mode = 0;
@@ -63,7 +154,7 @@ int p_rename(const char *from, const char *to)
return -1;
}
-#endif
+#endif /* GIT_WIN32 */
int p_read(git_file fd, void *buf, size_t cnt)
{