int
tdSensor( protocol, protocolLen, model, modelLen, id, dataTypes )
SV * protocol
int protocolLen
SV * model
int modelLen
int & id
int & dataTypes
CODE:
{
STRLEN n_a;
(void) SvPV_force( protocol, n_a );
(void) SvPV_force( model, n_a );
SvGROW( protocol, protocolLen );
SvGROW( model, modelLen );
}
RETVAL = tdSensor(
SvPV(protocol), protocolLen, SvPV(model), modelLen, &id, &data
+Types );
SvCUR_set( protocol, strlen(SvPV(protocol)) );
SvCUR_set( model, strlen(SvPV(model)) );
OUTPUT:
RETVAL
id
dataTypes
But much simpler (and less likely to be buggy) than even that is:
int
_tdSensor( protocol, protocolLen, model, modelLen, id, dataTypes )
char * protocol
int protocolLen
char * model
int modelLen
int & id
int & dataTypes
CODE:
RETVAL = tdSensor( protocol, protocolLen, model, modelLen, &id, &d
+ataTypes );
OUTPUT:
RETVAL
id
dataTypes
Plus
sub tdSensor {
my( $protocolLen, $modelLen ) = @_;
$protcolLen ||= 1024;
$modelLen ||= 1024;
my $protocol = '\0' x $protcolLen;
my $model = '\0' x $modelLen;
my $id = 0;
my $dataTypes = 0;
my $ret = _tdSensor(
$protocol, $protocolLen, $model, $modelLen, $id, $dataTypes );
s/\0.*//
for $protocol, $model;
return( $ret, $protocol, $model, $id, $dataTypes );
}
Which has the significant advantage of making it much easier to improve the interface without having to futz with the super finicky XS part of the code.
|