Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
d4e1f0ee
Commit
d4e1f0ee
authored
15 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Created getHostNameByAddr() - simplified wrapper for gethostbyaddr().
parent
7d6c74dd
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xpdev/netwrap.c
+24
-2
24 additions, 2 deletions
src/xpdev/netwrap.c
src/xpdev/netwrap.h
+2
-1
2 additions, 1 deletion
src/xpdev/netwrap.h
with
26 additions
and
3 deletions
src/xpdev/netwrap.c
+
24
−
2
View file @
d4e1f0ee
...
...
@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 200
5
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 200
9
Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
...
...
@@ -37,6 +37,7 @@
#include
"genwrap.h"
/* truncsp */
#include
"netwrap.h"
/* verify prototypes */
#include
"sockwrap.h"
#include
<stdlib.h>
/* malloc() */
#include
<ctype.h>
/* isspace() */
...
...
@@ -96,6 +97,25 @@ str_list_t getNameServerList(void)
#endif
}
const
char
*
getHostNameByAddr
(
const
char
*
str
)
{
HOSTENT
*
h
;
uint32_t
ip
;
#ifdef _WIN32
WSADATA
wsaData
;
WSAStartup
(
MAKEWORD
(
2
,
2
),
&
wsaData
);
#endif
if
((
ip
=
inet_addr
(
str
))
==
INADDR_NONE
)
return
str
;
if
((
h
=
gethostbyaddr
((
char
*
)
&
ip
,
sizeof
(
ip
),
AF_INET
))
==
NULL
)
return
NULL
;
WSACleanup
();
return
h
->
h_name
;
}
/* In case we want to DLL-export getNameServerList in the future */
void
freeNameServerList
(
str_list_t
list
)
{
...
...
@@ -103,7 +123,7 @@ void freeNameServerList(str_list_t list)
}
#if NETWRAP_TEST
int
main
(
void
)
int
main
(
int
argc
,
char
**
argv
)
{
size_t
i
;
str_list_t
list
;
...
...
@@ -114,6 +134,8 @@ int main(void)
freeNameServerList
(
list
);
}
if
(
argc
>
1
)
printf
(
"%s
\n
"
,
getHostNameByAddr
(
argv
[
1
]));
return
0
;
}
#endif
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/netwrap.h
+
2
−
1
View file @
d4e1f0ee
...
...
@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 200
8
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 200
9
Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
...
...
@@ -47,6 +47,7 @@
extern
"C"
{
#endif
const
char
*
getHostNameByAddr
(
const
char
*
);
str_list_t
getNameServerList
(
void
);
void
freeNameServerList
(
str_list_t
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment