Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
798e4d53
Commit
798e4d53
authored
Jun 22, 2012
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
amigaos: Cleanup
parent
2ae052d1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
140 deletions
+125
-140
include/git2/errors.h
+1
-39
src/netops.c
+4
-96
src/posix.c
+92
-1
src/posix.h
+28
-4
No files found.
include/git2/errors.h
View file @
798e4d53
...
...
@@ -17,44 +17,6 @@
*/
GIT_BEGIN_DECL
#ifdef GIT_OLD_ERRORS
enum
{
GIT_SUCCESS
=
0
,
GIT_ERROR
=
-
1
,
GIT_ENOTOID
=
-
2
,
GIT_ENOTFOUND
=
-
3
,
GIT_ENOMEM
=
-
4
,
GIT_EOSERR
=
-
5
,
GIT_EOBJTYPE
=
-
6
,
GIT_ENOTAREPO
=
-
7
,
GIT_EINVALIDTYPE
=
-
8
,
GIT_EMISSINGOBJDATA
=
-
9
,
GIT_EPACKCORRUPTED
=
-
10
,
GIT_EFLOCKFAIL
=
-
11
,
GIT_EZLIB
=
-
12
,
GIT_EBUSY
=
-
13
,
GIT_EBAREINDEX
=
-
14
,
GIT_EINVALIDREFNAME
=
-
15
,
GIT_EREFCORRUPTED
=
-
16
,
GIT_ETOONESTEDSYMREF
=
-
17
,
GIT_EPACKEDREFSCORRUPTED
=
-
18
,
GIT_EINVALIDPATH
=
-
19
,
GIT_EREVWALKOVER
=
-
20
,
GIT_EINVALIDREFSTATE
=
-
21
,
GIT_ENOTIMPLEMENTED
=
-
22
,
GIT_EEXISTS
=
-
23
,
GIT_EOVERFLOW
=
-
24
,
GIT_ENOTNUM
=
-
25
,
GIT_ESTREAM
=
-
26
,
GIT_EINVALIDARGS
=
-
27
,
GIT_EOBJCORRUPTED
=
-
28
,
GIT_EAMBIGUOUS
=
-
29
,
GIT_EPASSTHROUGH
=
-
30
,
GIT_ENOMATCH
=
-
31
,
GIT_ESHORTBUFFER
=
-
32
,
};
#else
/** Generic return codes */
enum
{
GIT_OK
=
0
,
...
...
@@ -67,13 +29,13 @@ enum {
GIT_PASSTHROUGH
=
-
30
,
GIT_REVWALKOVER
=
-
31
,
};
#endif
typedef
struct
{
char
*
message
;
int
klass
;
}
git_error
;
/** Error classes */
typedef
enum
{
GITERR_NOMEMORY
,
GITERR_OS
,
...
...
src/netops.c
View file @
798e4d53
...
...
@@ -32,99 +32,6 @@
#include "buffer.h"
#include "transport.h"
#ifdef NO_ADDRINFO
struct
addrinfo
{
struct
hostent
*
ai_hostent
;
struct
servent
*
ai_servent
;
struct
sockaddr_in
ai_addr_in
;
struct
sockaddr
*
ai_addr
;
size_t
ai_addrlen
;
int
ai_family
;
int
ai_socktype
;
int
ai_protocol
;
long
ai_port
;
struct
addrinfo
*
ai_next
;
};
static
int
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
;
}
static
void
freeaddrinfo
(
struct
addrinfo
*
info
)
{
struct
addrinfo
*
p
,
*
next
;
p
=
info
;
while
(
p
!=
NULL
)
{
next
=
p
->
ai_next
;
free
(
p
);
p
=
next
;
}
}
static
const
char
*
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
#ifdef GIT_WIN32
static
void
net_set_error
(
const
char
*
str
)
{
...
...
@@ -477,8 +384,9 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
hints
.
ai_socktype
=
SOCK_STREAM
;
hints
.
ai_family
=
AF_UNSPEC
;
if
((
ret
=
getaddrinfo
(
host
,
port
,
&
hints
,
&
info
))
<
0
)
{
giterr_set
(
GITERR_NET
,
"Failed to resolve address for %s: %s"
,
host
,
gai_strerror
(
ret
));
if
((
ret
=
p_getaddrinfo
(
host
,
port
,
&
hints
,
&
info
))
<
0
)
{
giterr_set
(
GITERR_NET
,
"Failed to resolve address for %s: %s"
,
host
,
p_gai_strerror
(
ret
));
return
-
1
;
}
...
...
@@ -505,7 +413,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
}
t
->
socket
=
s
;
freeaddrinfo
(
info
);
p_
freeaddrinfo
(
info
);
if
(
t
->
encrypt
&&
ssl_setup
(
t
,
host
)
<
0
)
return
-
1
;
...
...
src/posix.c
View file @
798e4d53
...
...
@@ -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
)
{
...
...
src/posix.h
View file @
798e4d53
...
...
@@ -83,16 +83,40 @@ extern int p_gettimeofday(struct timeval *tv, struct timezone *tz);
# include "unix/posix.h"
#endif
#ifndef NO_READDIR_R
#define p_readdir_r(d,e,r) readdir_r(d,e,r)
#else
#include <dirent.h>
#ifdef NO_READDIR_R
# include <dirent.h>
GIT_INLINE
(
int
)
p_readdir_r
(
DIR
*
dirp
,
struct
dirent
*
entry
,
struct
dirent
**
result
)
{
GIT_UNUSED
(
entry
);
*
result
=
readdir
(
dirp
);
return
0
;
}
#else
/* NO_READDIR_R */
# define p_readdir_r(d,e,r) readdir_r(d,e,r)
#endif
#ifdef NO_ADDRINFO
struct
addrinfo
{
struct
hostent
*
ai_hostent
;
struct
servent
*
ai_servent
;
struct
sockaddr_in
ai_addr_in
;
struct
sockaddr
*
ai_addr
;
size_t
ai_addrlen
;
int
ai_family
;
int
ai_socktype
;
int
ai_protocol
;
long
ai_port
;
struct
addrinfo
*
ai_next
;
};
extern
int
p_getaddrinfo
(
const
char
*
host
,
const
char
*
port
,
struct
addrinfo
*
hints
,
struct
addrinfo
**
info
);
extern
void
p_freeaddrinfo
(
struct
addrinfo
*
info
);
extern
const
char
*
p_gai_strerror
(
int
ret
);
#else
# define p_getaddrinfo(a, b, c, d) getaddrinfo(a, b, c, d)
# define p_freeaddrinfo(a) freeaddrinfo(a)
# define p_gai_strerror(c) gai_strerror(c)
#endif
/* NO_ADDRINFO */
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment