Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b9ab1590
Commit
b9ab1590
authored
Jun 24, 2001
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Emulate inet_{pton,ntop} on systems that don't provide it.
parent
530f9901
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
3 deletions
+47
-3
Modules/socketmodule.c
Modules/socketmodule.c
+41
-0
config.h.in
config.h.in
+3
-0
configure
configure
+2
-2
configure.in
configure.in
+1
-1
No files found.
Modules/socketmodule.c
View file @
b9ab1590
...
@@ -208,6 +208,11 @@ Socket methods:
...
@@ -208,6 +208,11 @@ Socket methods:
in those files, though, which will never compile on Windows. */
in those files, though, which will never compile on Windows. */
#ifndef MS_WINDOWS
#ifndef MS_WINDOWS
#ifndef HAVE_INET_PTON
int
inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
);
char
*
inet_ntop
(
int
af
,
void
*
src
,
char
*
dst
,
socklen_t
size
);
#endif
/* I know this is a bad practice, but it is the easiest... */
/* I know this is a bad practice, but it is the easiest... */
#ifndef HAVE_GETADDRINFO
#ifndef HAVE_GETADDRINFO
#include "getaddrinfo.c"
#include "getaddrinfo.c"
...
@@ -2943,3 +2948,39 @@ init_socket(void)
...
@@ -2943,3 +2948,39 @@ init_socket(void)
gethostbyname_lock
=
PyThread_allocate_lock
();
gethostbyname_lock
=
PyThread_allocate_lock
();
#endif
#endif
}
}
/* Simplistic emulation code for inet_pton that only works for IPv4 */
#ifndef HAVE_INET_PTON
int
my_inet_pton
(
int
af
,
char
*
src
,
void
*
dst
)
{
if
(
af
==
AF_INET
){
long
packed_addr
;
#ifdef USE_GUSI1
packed_addr
=
(
long
)
inet_addr
(
src
).
s_addr
;
#else
packed_addr
=
inet_addr
(
src
);
#endif
if
(
packed_addr
==
INADDR_NONE
)
return
0
;
memcpy
(
dst
,
&
packed_addr
,
4
);
return
1
;
}
/* Should set errno to EAFNOSUPPORT */
return
-
1
;
}
char
*
my_inet_ntop
(
int
af
,
void
*
src
,
char
*
dst
,
socklen_t
size
)
{
if
(
af
==
AF_INET
)
{
struct
in_addr
packed_addr
;
if
(
size
<
16
)
/* Should set errno to ENOSPC. */
return
NULL
;
memcpy
(
&
packed_addr
,
src
,
sizeof
(
packed_addr
));
return
strncpy
(
dst
,
inet_ntoa
(
packed_addr
),
size
);
}
/* Should set errno to EAFNOSUPPORT */
return
NULL
;
}
#endif
config.h.in
View file @
b9ab1590
...
@@ -392,6 +392,9 @@
...
@@ -392,6 +392,9 @@
/* Define if you have the hypot function. */
/* Define if you have the hypot function. */
#undef HAVE_HYPOT
#undef HAVE_HYPOT
/* Define if you have the inet_pton function. */
#undef HAVE_INET_PTON
/* Define if you have the kill function. */
/* Define if you have the kill function. */
#undef HAVE_KILL
#undef HAVE_KILL
...
...
configure
View file @
b9ab1590
#! /bin/sh
#! /bin/sh
# From configure.in Revision: 1.2
19
# From configure.in Revision: 1.2
20
# Guess values for system-dependent variables and create Makefiles.
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf version 2.13
# Generated automatically using autoconf version 2.13
...
@@ -4480,7 +4480,7 @@ echo "$ac_t""$DYNLOADFILE" 1>&6
...
@@ -4480,7 +4480,7 @@ echo "$ac_t""$DYNLOADFILE" 1>&6
for
ac_func
in
alarm
chown
clock confstr ctermid ctermid_r execv
\
for
ac_func
in
alarm
chown
clock confstr ctermid ctermid_r execv
\
flock fork fsync fdatasync fpathconf ftime ftruncate
\
flock fork fsync fdatasync fpathconf ftime ftruncate
\
getgroups getlogin getpeername getpid getpwent getwd
\
getgroups getlogin getpeername getpid getpwent getwd
\
kill link
lstat
mkfifo
mktime mremap
\
inet_pton
kill link
lstat
mkfifo
mktime mremap
\
nice
pathconf pause plock poll pthread_init
\
nice
pathconf pause plock poll pthread_init
\
putenv
readlink
\
putenv
readlink
\
select
setegid seteuid setgid
\
select
setegid seteuid setgid
\
...
...
configure.in
View file @
b9ab1590
...
@@ -1162,7 +1162,7 @@ AC_MSG_RESULT($DYNLOADFILE)
...
@@ -1162,7 +1162,7 @@ AC_MSG_RESULT($DYNLOADFILE)
AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
flock fork fsync fdatasync fpathconf ftime ftruncate \
flock fork fsync fdatasync fpathconf ftime ftruncate \
getgroups getlogin getpeername getpid getpwent getwd \
getgroups getlogin getpeername getpid getpwent getwd \
kill link lstat mkfifo mktime mremap \
inet_pton
kill link lstat mkfifo mktime mremap \
nice pathconf pause plock poll pthread_init \
nice pathconf pause plock poll pthread_init \
putenv readlink \
putenv readlink \
select setegid seteuid setgid \
select setegid seteuid setgid \
...
...
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