Bio-SCF
view release on metacpan or search on metacpan
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <io_lib/scf.h>
#include <io_lib/mFILE.h>
#define SV_SETUV(A) { ret_val = newSViv(1); sv_setuv(ret_val, (A)); }
#ifdef __cplusplus
}
#endif
MODULE = Bio::SCF PACKAGE = Bio::SCF
SV *
get_scf_pointer(file_name)
char *file_name
CODE:
Scf *scf_data = NULL; /* internal representation of data from scf file */
struct stat *file_stat;
SV *ret_val; /* SV which content scf data */
int i;
/* checking for existance of file and its permissions */
if( file_name == NULL ) croak("readScf(...) : file_name is NULL");
file_stat = malloc(sizeof(struct stat));
i = stat(file_name, file_stat);
if( i == -1 ){
switch(errno){
case ENOENT :
croak("get_scf_pointer(...) : file %s doesn't exist\n", file_name);
break;
case EACCES :
croak("get_scf_pointer(...) : permission denied on file %s\n", file_name);
break;
case ENAMETOOLONG :
croak("get_scf_pointer(...) : file name %s too long\n", file_name);
break;
default :
croak("get_scf_pointer(...) : unable to get stat on file %s, errno %d\n", file_name, errno);
break;
}
}
free(file_stat);
/* Reading SCF file, into internal structure */
if ( (scf_data = read_scf(file_name)) == NULL )
croak("get_scf_pointer(...) : failed on read_scf(%s)\n", file_name);
ret_val = newSViv((int)scf_data);
RETVAL = ret_val;
OUTPUT:
RETVAL
SV *
get_scf_fpointer(file_handle)
FILE *file_handle
CODE:
Scf *scf_data = NULL; /* internal representation of data read from scf file */
SV *ret_val; /* SV which content scf data */
mFILE *mf;
/* we don't need to check existance of file and its permissions becouse we operate
here with already opened file handle */
if( file_handle == NULL ) croak("get_scf_fpointer(...) : file_handle is NULL");
/* Reading SCF file, into internal structure */
mf = mfreopen(NULL,"r",file_handle);
if (mf == NULL)
croak("get_scf_fpointer(...) : failed on mfreopen(...)\n");
if ( (scf_data = mfread_scf(mf)) == NULL )
croak("get_scf_fpointer(...) : failed on fread_scf(...)\n");
ret_val = newSViv((int)scf_data);
RETVAL = ret_val;
OUTPUT:
RETVAL
void
scf_free(scf_pointer)
int scf_pointer
CODE:
scf_deallocate((Scf *)scf_pointer);
SV *
get_comments(scf_pointer)
int scf_pointer
CODE:
Scf *scf_data = (Scf *)scf_pointer;
( run in 2.266 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )