From 3f6b64304a8a11f0505e91681384327696983928 Mon Sep 17 00:00:00 2001 From: Epoch Qwert Date: Fri, 9 Jan 2015 19:25:02 -0600 Subject: XuntilY.awk is actually a shell script, but mostly written in awk to make XuntilY easier to use for people without Perl gopherd.sh... I don't remember the change. music.c is to practice reading music. sockip is to get the IP of the listening socket, like if ran from inetd --- src/libexec/sockip.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/libexec/sockip.c (limited to 'src/libexec') diff --git a/src/libexec/sockip.c b/src/libexec/sockip.c new file mode 100644 index 0000000..542a88d --- /dev/null +++ b/src/libexec/sockip.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +int main(int argc,char *argv[]) { + struct sockaddr_in6 sa6; + unsigned int sl=sizeof(sa6); + char h[NI_MAXHOST], s[NI_MAXSERV]; + if(getsockname(0,(struct sockaddr *)&sa6,&sl) == -1) return 1; + if(getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),s,sizeof(s),NI_NUMERICHOST|NI_NUMERICSERV)) return 2; + puts(h); + puts(s); + return 0; +} -- cgit v1.2.3