// Copyright (c) 2014 David J. Shultz // This software is covered by the GPL. #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "lib/discid.h" #include #include 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