summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/gethostbyname.c10
-rw-r--r--src/bin/realpath.c10
2 files changed, 19 insertions, 1 deletions
diff --git a/src/bin/gethostbyname.c b/src/bin/gethostbyname.c
index 646bf0a..b670b1e 100644
--- a/src/bin/gethostbyname.c
+++ b/src/bin/gethostbyname.c
@@ -1,10 +1,18 @@
#include <stdio.h>
#include <netdb.h>
+#include <arpa/inet.h>
int main(int argc,char *argv[]) {
int i;
if(argc < 2) return 1;
- struct hostent *he=gethostbyname(argv[1]);
+ char *addr;
+ struct in_addr saddr;
+ if(inet_aton(argv[1],&saddr))
+ addr=inet_ntoa(saddr);
+ else
+ addr=argv[1];
+ struct hostent *he=gethostbyname(addr);
+
for(i=0;he->h_addr_list[i];i++) {
printf("%u.%u.%u.%u\n",
(unsigned char)he->h_addr_list[i][0],
diff --git a/src/bin/realpath.c b/src/bin/realpath.c
new file mode 100644
index 0000000..e47f020
--- /dev/null
+++ b/src/bin/realpath.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <sys/param.h>
+#include <stdlib.h>
+
+int main(int argc,char *argv[]) {
+ char path[MAXPATHLEN+1];
+ if(!realpath(argv[1],path)) return 1;
+ puts(path);
+ return 0;
+}