/* ### ghmm environment ### setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/project/algorithmics/lib:/home/schliep/local/lib:/package/gcc-3.2/linux/lib setenv PATH ${PATH}:/project/algorithmics/bin # Python, if needed setenv PYTHONPATH /project/algorithmics/lib/python2.3/site-packages ### Compilation and linking ### gcc -I/package/R/R-1.8.1/linux/lib/R/include -I/usr/local/include -I/project/algorithmics/include -D__NO_MATH_INLINES -mieee-fp -fPIC -g -O2 -c GHMM_and_R.c -o GHMM_and_R.o gcc -shared -L/usr/local/lib -L/project/algorithmics/lib -o GHMM_and_R.so GHMM_and_R.o -lghmm ### in R load library ### dyn.load("GHMM_and_R.so") ### in R define and call a wrapper function ### ga <- function(s,n) .C("access", as.character(s), as.integer(n)) ga("two_modules.smo", 2) */ #include #include #include #include #include #include #include void access(const char **strp, int *smo_number) { int idx = 0; FILE* fp; smodel** ref_mo; smodel mo; if( strp[0][0] != '\0' ) { Rprintf( "Char:%s: \n", strp[0] ); } else { Rprintf( "Empty String \n" ); } if( (fp = fopen("test_out", "w")) == NULL ) { Rprintf( "Can't write test_out\n" ); } if( ref_mo = smodel_read( strp[0], smo_number ) ) { mo = *ref_mo[idx]; if( mo.N != 0 ) Rprintf( "moN:%d: \n", mo.N); Rprintf( "%s\t%d\n", "Show me the index: ", idx ); if( ref_mo[idx] != NULL ) { smodel_print( fp, ref_mo[idx] ); } idx++; } fclose(fp); }