Subject: | Patch to compile with MSVC & Mingw |
ActiveState perl v5.8.7 built for MSWin32-x86-multi-thread
Binary build 813
-------
Alexandr Ciornii, http://chorny.net
Subject: | FQDN.xs |
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
/* gethostname */
#if !defined(_MSC_VER) && !defined(__MINGW32_VERSION)
#include <unistd.h>
#endif
/* inet_ntoa */
#include <sys/socket.h>
#if !defined(_MSC_VER) && !defined(__MINGW32_VERSION)
#include <netinet/in.h>
#endif
#include <arpa/inet.h>
/* from /usr/include/arpa/nameser.h */
#define NS_MAXDNAME 1025 /* maximum domain name */
#include "c_includes/alt_inet_aton.c"
MODULE = Sys::Hostname::FQDN PACKAGE = Sys::Hostname::FQDN
PROTOTYPES: DISABLE
void
usually_short()
PREINIT:
SV * out;
char local_name[NS_MAXDNAME];
PPCODE:
if (gethostname(local_name,NS_MAXDNAME) != 0) {
ST(0) = &PL_sv_undef;
}
else {
out = sv_newmortal();
out = newSVpv(local_name,0);
ST(0) = out;
}
XSRETURN(1);
void
inet_ntoa(netaddr)
SV * netaddr
PREINIT:
STRLEN len;
SV * out;
union {
struct in_addr * inadr;
char * addr;
} naddr;
PPCODE:
naddr.addr = (unsigned char *)(SvPV(netaddr, len));
out = sv_newmortal();
out = newSVpv(inet_ntoa(*naddr.inadr),0);
ST(0) = out;
XSRETURN(1);
void
inet_aton(dotquad)
SV * dotquad
PREINIT:
SV * out;
STRLEN len;
unsigned char * dq;
union {
struct in_addr * inadr;
char * addr;
} naddr;
struct in_addr myaddr;
PPCODE:
dq = (unsigned char *)(SvPV(dotquad, len));
inet_aton(dq,&myaddr);
out = sv_newmortal();
out = newSVpv((u_char *)&myaddr.s_addr,4);
ST(0) = out;
XSRETURN(1);
Subject: | FQDN.xs.patch |
--- FQDN.xs.dist Sun Sep 21 02:04:59 2003
+++ FQDN.xs Tue Sep 12 15:02:19 2006
@@ -3,11 +3,15 @@
#include "XSUB.h"
/* gethostname */
+#if !defined(_MSC_VER) && !defined(__MINGW32_VERSION)
#include <unistd.h>
+#endif
/* inet_ntoa */
#include <sys/socket.h>
+#if !defined(_MSC_VER) && !defined(__MINGW32_VERSION)
#include <netinet/in.h>
+#endif
#include <arpa/inet.h>
/* from /usr/include/arpa/nameser.h */