Annotation of loncom/homework/caparesponse/capa.i, revision 1.7
1.1 albertel 1: %module capa
2: %{
3:
4: %}
1.3 albertel 5:
1.7 ! raeburn 6: %typemap(in) char** reterror (char* cvalue) {
1.3 albertel 7: SV* tempsv;
1.5 albertel 8: int len;
1.7 ! raeburn 9: if (!SvROK($input)) {
1.3 albertel 10: croak("expected a reference\n");
11: }
1.7 ! raeburn 12: tempsv = SvRV($input);
1.3 albertel 13: if ((!SvPOK(tempsv))) {
14: croak("expected a double reference\n");
15: }
1.4 albertel 16: cvalue = SvPV(tempsv,len);
1.7 ! raeburn 17: $1 = &cvalue;
1.3 albertel 18: }
19:
1.7 ! raeburn 20: %typemap(argout) char ** reterror {
1.3 albertel 21: SV *tempsv;
22: tempsv = SvRV($arg);
1.7 ! raeburn 23: if (($1!=NULL) && (*$1!=NULL)) {
! 24: sv_setpv(tempsv, *$1);
! 25: free(*$1);
1.3 albertel 26: }
27: }
1.6 albertel 28:
1.7 ! raeburn 29: %typemap(in) double* scaled {
1.6 albertel 30: double *temp;
1.7 ! raeburn 31: if (!SvROK($input)) {
1.6 albertel 32: croak("expected a reference\n");
33: }
34: SV* tempsv;
1.7 ! raeburn 35: tempsv = SvRV($input);
1.6 albertel 36: if (!SvPOK(tempsv) && !SvIOK(tempsv) && !SvNOK(tempsv)) {
37: croak("expected a single reference to a scalar\n");
38: }
39: temp = malloc(sizeof(double));
40: *temp = SvNV(tempsv);
1.7 ! raeburn 41: $1 = temp;
1.6 albertel 42: }
43:
1.7 ! raeburn 44: %typemap(argout) double* scaled {
1.6 albertel 45: SV *tempsv;
46: tempsv = SvRV($arg);
1.7 ! raeburn 47: sv_setnv(tempsv, *$1);
! 48: free($1);
1.6 albertel 49: }
50:
51:
1.1 albertel 52: extern int caparesponse_capa_check_answer(char *response,char *correct,
53: int type,int tol_type,double tolerance,
54: int sig_lbound,int sig_ubound,
55: char *ans_fmt, char *unit_str,
1.2 albertel 56: int calc, char *id_list, char *pts_list,
1.3 albertel 57: char *rndseed, char** reterror);
1.6 albertel 58:
59: extern int caparesponse_get_real_response(char* unit_str, char* answer,
60: double* scaled);
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>