summaryrefslogtreecommitdiffstats
path: root/perl-install/c/stuff.xs.pl
diff options
context:
space:
mode:
authorNicolas Planel <nplanel@mandriva.com>2004-08-17 08:34:41 +0000
committerNicolas Planel <nplanel@mandriva.com>2004-08-17 08:34:41 +0000
commit1e650ba962e5a27817c440d82ebf5af62445266c (patch)
tree9ea4c7d8aa9531015223e1c8a9ab4dd1306622e6 /perl-install/c/stuff.xs.pl
parent336a0bf9555e157a8840c88e1a08614fb52499fc (diff)
downloaddrakx-backup-do-not-use-1e650ba962e5a27817c440d82ebf5af62445266c.tar
drakx-backup-do-not-use-1e650ba962e5a27817c440d82ebf5af62445266c.tar.gz
drakx-backup-do-not-use-1e650ba962e5a27817c440d82ebf5af62445266c.tar.bz2
drakx-backup-do-not-use-1e650ba962e5a27817c440d82ebf5af62445266c.tar.xz
drakx-backup-do-not-use-1e650ba962e5a27817c440d82ebf5af62445266c.zip
revert my last bad commit
Diffstat (limited to 'perl-install/c/stuff.xs.pl')
-rw-r--r--perl-install/c/stuff.xs.pl109
1 files changed, 102 insertions, 7 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl
index dc2ceafb7..fb3dd4292 100644
--- a/perl-install/c/stuff.xs.pl
+++ b/perl-install/c/stuff.xs.pl
@@ -23,6 +23,8 @@ print '
#include <sys/stat.h>
#include <sys/utsname.h>
#include <sys/mount.h>
+#undef __USE_MISC
+#include <linux/wireless.h>
#include <linux/keyboard.h>
#include <linux/kd.h>
#include <linux/hdreg.h>
@@ -31,6 +33,7 @@ print '
#include <linux/cdrom.h>
#include <linux/loop.h>
#include <linux/blkpg.h>
+#include <linux/iso_fs.h>
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
@@ -49,6 +52,7 @@ typedef __uint8_t u8;
#include <ext2fs/ext2fs.h>
// for UPS on USB:
+# define HID_MAX_USAGES 1024
#include <linux/hiddev.h>
#include <libldetect.h>
@@ -69,11 +73,11 @@ char *promRootName();
';
-$ENV{C_DRAKX} && $Config{archname} =~ /i.86/ and print '
+$Config{archname} =~ /i.86/ and print '
char *pcmcia_probe(void);
';
-$ENV{C_RPM} and print '
+print '
#undef Fflush
#undef Mkdir
#undef Stat
@@ -91,7 +95,7 @@ void rpmError_callback(void) {
';
-$ENV{C_DRAKX} and print '
+print '
void log_message(const char * s, ...) {
va_list args;
@@ -144,11 +148,17 @@ SV * iconv_(char* s, char* from_charset, char* to_charset) {
return newSVpv(retval, 0);
}
+int length_of_space_padded(char *str, int len) {
+ while (len >= 0 && str[len-1] == \' \')
+ --len;
+ return len;
+}
+
MODULE = c::stuff PACKAGE = c::stuff
';
-$ENV{C_DRAKX} && $Config{archname} =~ /i.86/ and print '
+$Config{archname} =~ /i.86/ and print '
char *
pcmcia_probe()
';
@@ -219,6 +229,23 @@ is_ext3(device_name)
OUTPUT:
RETVAL
+char *
+get_ext2_label(device_name)
+ char * device_name
+ CODE:
+ {
+ ext2_filsys fs;
+ int retval = ext2fs_open (device_name, 0, 0, 0, unix_io_manager, &fs);
+ if (retval) {
+ RETVAL = 0;
+ } else {
+ RETVAL = fs->super->s_volume_name;
+ ext2fs_close(fs);
+ }
+ }
+ OUTPUT:
+ RETVAL
+
void
setlocale()
CODE:
@@ -401,13 +428,68 @@ hasNetDevice(device)
int s = socket(AF_INET, SOCK_DGRAM, 0);
if (s == -1) { RETVAL = 0; return; }
- strcpy(req.ifr_name, device);
+ strncpy(req.ifr_name, device, IFNAMSIZ);
RETVAL = ioctl(s, SIOCGIFFLAGS, &req) == 0;
close(s);
OUTPUT:
RETVAL
+
+int
+isNetDeviceWirelessAware(device)
+ char * device
+ CODE:
+ struct iwreq ifr;
+
+ int s = socket(AF_INET, SOCK_DGRAM, 0);
+
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, device, IFNAMSIZ);
+ RETVAL = ioctl(s, SIOCGIWNAME, &ifr) != -1;
+ close(s);
+ OUTPUT:
+ RETVAL
+
+
+void
+get_netdevices()
+ PPCODE:
+ struct ifconf ifc;
+ struct ifreq *ifr;
+ int i;
+ int numreqs = 10;
+
+ int s = socket(AF_INET, SOCK_DGRAM, 0);
+
+ ifc.ifc_buf = NULL;
+ for (;;) {
+ ifc.ifc_len = sizeof(struct ifreq) * numreqs;
+ ifc.ifc_buf = realloc(ifc.ifc_buf, ifc.ifc_len);
+
+ if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
+ perror("SIOCGIFCONF");
+ return;
+ }
+ if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) {
+ /* assume it overflowed and try again */
+ numreqs += 10;
+ continue;
+ }
+ break;
+ }
+ if (ifc.ifc_len) {
+ ifr = ifc.ifc_req;
+ EXTEND(sp, ifc.ifc_len);
+ for (i=0; i < ifc.ifc_len; i+= sizeof(struct ifreq)) {
+ PUSHs(sv_2mortal(newSVpv(ifr->ifr_name, 0)));
+ ifr++;
+ }
+ }
+
+ close(s);
+
+
char*
getNetDriver(char* device)
ALIAS:
@@ -418,7 +500,7 @@ getNetDriver(char* device)
int s = socket(AF_INET, SOCK_DGRAM, 0);
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)-1);
+ strncpy(ifr.ifr_name, device, IFNAMSIZ);
drvinfo.cmd = ETHTOOL_GDRVINFO;
ifr.ifr_data = (caddr_t) &drvinfo;
@@ -626,9 +708,22 @@ standard_charset()
OUTPUT:
RETVAL
+void
+get_iso_volume_ids(int fd)
+ INIT:
+ struct iso_primary_descriptor voldesc;
+ PPCODE:
+ lseek(fd, 16 * ISOFS_BLOCK_SIZE, SEEK_SET);
+ if (read(fd, &voldesc, sizeof(struct iso_primary_descriptor)) == sizeof(struct iso_primary_descriptor)) {
+ if (voldesc.type[0] == ISO_VD_PRIMARY && !strncmp(voldesc.id, ISO_STANDARD_ID, sizeof(voldesc.id))) {
+ XPUSHs(sv_2mortal(newSVpv(voldesc.volume_id, length_of_space_padded(voldesc.volume_id, sizeof(voldesc.volume_id)))));
+ XPUSHs(sv_2mortal(newSVpv(voldesc.application_id, length_of_space_padded(voldesc.application_id, sizeof(voldesc.application_id)))));
+ }
+ }
+
';
-$ENV{C_RPM} and print '
+print '
const char *
rpmErrorString()