Skip Menu |

This queue is for tickets about the Net-Libdnet CPAN distribution.

Report information
The Basics
Id: 45697
Status: resolved
Priority: 0/
Queue: Net-Libdnet

People
Owner: gomor [...] cpan.org
Requestors: Zoltan.Banai [...] morganstanley.com
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.91
Fixed in: (no value)



Subject: Support for old C (Sun Studio / MS VC) compilers
When using older compilers (Sun Studio before SunOS 5.10 or MSVC7/8) build fails if the code contains declarations outside of file scope or the start of compound statement. (allowed in C99) The attached patch against Libdnet.xs allows the code to be compiled with these compilers.
Subject: Libdnet.patch
--- Net-Libdnet-0.91/Libdnet.xs 2008-12-06 18:06:25.035161187 +0100 +++ /ms/dev/perl5/Net-Libdnet/0.91/src/distro/Libdnet.xs 2009-04-30 13:45:37.000000000 +0200 @@ -853,10 +853,13 @@ dnet_intf_get(handle, entry) IntfHandle *handle SV *entry - INIT: + PREINIT: char buf[1024]; - IntfEntry *intfEntry = (IntfEntry *)buf; - IntfEntry *intfEntryPtr = NULL; + IntfEntry *intfEntry; + IntfEntry *intfEntryPtr; + INIT: + intfEntry = (IntfEntry *)buf; + intfEntryPtr = NULL; memset(buf, 0, sizeof(buf)); intfEntryPtr = intf_sv2c(entry, intfEntry); intfEntry->intf_len = sizeof(buf); @@ -870,14 +873,17 @@ dnet_intf_get_src(handle, src) IntfHandle *handle SV *src - INIT: + PREINIT: char buf[1024]; - IntfEntry *intfEntry = (IntfEntry *)buf; - memset(buf, 0, sizeof(buf)); + IntfEntry *intfEntry; struct addr aSrc; + int ret; + INIT: + intfEntry = (IntfEntry *)buf; + memset(buf, 0, sizeof(buf)); intfEntry->intf_len = sizeof(buf); memset(&aSrc, 0, sizeof(struct addr)); - int ret = addr_aton(SvPV(src, PL_na), &aSrc); + ret = addr_aton(SvPV(src, PL_na), &aSrc); CODE: if (! ret && intf_get_src(handle, intfEntry, &aSrc) == -1) { XSRETURN_UNDEF; @@ -890,14 +896,17 @@ dnet_intf_get_dst(handle, dst) IntfHandle *handle SV *dst - INIT: + PREINIT: char buf[1024]; - IntfEntry *intfEntry = (IntfEntry *)buf; struct addr aDst; + int ret; + IntfEntry *intfEntry; + INIT: + intfEntry = (IntfEntry *)buf; memset(buf, 0, sizeof(buf)); intfEntry->intf_len = sizeof(buf); memset(&aDst, 0, sizeof(struct addr)); - int ret = addr_aton(SvPV(dst, PL_na), &aDst); + ret = addr_aton(SvPV(dst, PL_na), &aDst); CODE: if (! ret && intf_get_dst(handle, intfEntry, &aDst) == -1) { XSRETURN_UNDEF; @@ -910,9 +919,11 @@ dnet_intf_set(handle, entry) IntfHandle *handle SV *entry - INIT: - IntfEntry *intfEntryPtr = NULL; + PREINIT: + IntfEntry *intfEntryPtr; IntfEntry intfEntry; + INIT: + intfEntryPtr = NULL; intfEntryPtr = intf_sv2c(entry, &intfEntry); CODE: if (intf_set(handle, &intfEntry) == -1) { XSRETURN_UNDEF; } @@ -953,9 +964,11 @@ dnet_arp_add(handle, entry) ArpHandle *handle SV *entry - INIT: - ArpEntry *arpEntryPtr = NULL; + PREINIT: ArpEntry arpEntry; + ArpEntry *arpEntryPtr; + INIT: + arpEntryPtr = NULL; arpEntryPtr = arp_sv2c(entry, &arpEntry); CODE: RETVAL = arp_add(handle, arpEntryPtr); @@ -968,9 +981,11 @@ dnet_arp_delete(handle, entry) ArpHandle *handle SV *entry - INIT: - ArpEntry *arpEntryPtr = NULL; + PREINIT: ArpEntry arpEntry; + ArpEntry *arpEntryPtr; + INIT: + arpEntryPtr = NULL; arpEntryPtr = arp_sv2c(entry, &arpEntry); CODE: RETVAL = arp_delete(handle, arpEntryPtr); @@ -983,9 +998,11 @@ dnet_arp_get(handle, entry) ArpHandle *handle SV *entry - INIT: - ArpEntry *arpEntryPtr = NULL; + PREINIT: + ArpEntry *arpEntryPtr; ArpEntry arpEntry; + INIT: + arpEntryPtr = NULL; arpEntryPtr = arp_sv2c(entry, &arpEntry); CODE: if (arp_get(handle, arpEntryPtr) == -1) { XSRETURN_UNDEF; } @@ -1026,9 +1043,11 @@ dnet_route_add(handle, entry) RouteHandle *handle SV *entry - INIT: - RouteEntry *routeEntryPtr = NULL; + PREINIT: RouteEntry routeEntry; + RouteEntry *routeEntryPtr; + INIT: + routeEntryPtr = NULL; routeEntryPtr = route_sv2c(entry, &routeEntry); CODE: RETVAL = route_add(handle, routeEntryPtr); @@ -1041,9 +1060,11 @@ dnet_route_delete(handle, entry) RouteHandle *handle SV *entry - INIT: - RouteEntry *routeEntryPtr = NULL; + PREINIT: RouteEntry routeEntry; + RouteEntry *routeEntryPtr; + INIT: + routeEntryPtr = NULL; routeEntryPtr = route_sv2c(entry, &routeEntry); CODE: RETVAL = route_delete(handle, routeEntryPtr); @@ -1056,9 +1077,11 @@ dnet_route_get(handle, entry) RouteHandle *handle SV *entry - INIT: - RouteEntry *routeEntryPtr = NULL; + PREINIT: RouteEntry routeEntry; + RouteEntry *routeEntryPtr; + INIT: + routeEntryPtr = NULL; routeEntryPtr = route_sv2c(entry, &routeEntry); CODE: if (route_get(handle, routeEntryPtr) == -1) { XSRETURN_UNDEF; } @@ -1100,9 +1123,11 @@ dnet_fw_add(handle, rule) FwHandle *handle SV *rule - INIT: - FwRule *fwRulePtr = NULL; + PREINIT: FwRule fwRule; + FwRule *fwRulePtr; + INIT: + fwRulePtr = NULL; fwRulePtr = fw_sv2c(rule, &fwRule); CODE: RETVAL = fw_add(handle, fwRulePtr); @@ -1115,9 +1140,11 @@ dnet_fw_delete(handle, rule) FwHandle *handle SV *rule - INIT: - FwRule *fwRulePtr = NULL; + PREINIT: FwRule fwRule; + FwRule *fwRulePtr; + INIT: + fwRulePtr = NULL; fwRulePtr = fw_sv2c(rule, &fwRule); CODE: RETVAL = fw_delete(handle, fwRulePtr); @@ -1198,9 +1225,10 @@ dnet_tun_recv(handle, size) TunHandle *handle int size - INIT: + PREINIT: int read; unsigned char buf[size+1]; + INIT: memset(buf, 0, size+1); CODE: if ((read = tun_recv(handle, buf, size)) > 0) { @@ -1229,9 +1257,10 @@ SV * dnet_eth_get(handle) EthHandle *handle - INIT: + PREINIT: char *addr; EthAddr a; + INIT: memset(&a, 0, sizeof(EthAddr)); CODE: if (eth_get(handle, &a) == -1) { XSRETURN_UNDEF; }
In version 0.92