1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
// Copyright (c) 2014 David J. Shultz <dshultz@cpan.org>
// This software is covered by the GPL.
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "lib/discid.h"
#include <stdio.h>
#include <stdlib.h>
static int
not_here(char *s)
{
croak("%s not implemented on this architecture", s);
return -1;
}
static double
constant(char *name, int len, int arg)
{
errno = EINVAL;
return 0;
}
MODULE = Net::FreeDB PACKAGE = Net::FreeDB
double
constant(sv,arg)
PREINIT:
STRLEN len;
INPUT:
SV * sv
char * s = SvPV(sv, len);
int arg
CODE:
RETVAL = constant(s,len,arg);
OUTPUT:
RETVAL
char*
xs_discid(int driveNo)
INIT:
char id[30];
CODE:
sprintf(id, "%08x", discid(driveNo));
RETVAL = id;
OUTPUT:
RETVAL
SV*
xs_discinfo(int driveNo)
INIT:
int i;
char id[30];
struct discdata data;
HV* hash = newHV();
AV* tracks = newAV();
PPCODE:
data = get_disc_id(driveNo);
for (i = 0; i < (data.num_of_trks); i++) {
av_push(tracks, newSVnv(data.track_offsets[i]));
}
sprintf(id, "%08x", (unsigned int)data.discid);
hv_store(hash, "ID", 2, newSVpv(id, 0), 0);
hv_store(hash, "NUM_TRKS", 8, newSVnv(data.num_of_trks), 0);
hv_store(hash, "TRACKS", 6, newRV_inc((SV*)tracks), 0);
hv_store(hash, "SECONDS", 7, newSVnv(data.seconds), 0);
XPUSHs(newRV((SV*)hash));
int
getNumDrives()
INIT:
int numDrives;
CODE:
initTool();
numDrives = getNumDrives();
RETVAL = numDrives;
OUTPUT:
RETVAL
|