/************************************************/ /* */ /* File : ./tclconv.c */ /* Description : tcl command interpreter */ /* */ /* Command : conv */ /* Comment : Convert various formats */ /* */ /* Note : This file was created from a tl file. */ /* Do not modify by hand. */ /* */ /* Created : Mon 12. May 1997 12:32:00 */ /* */ /************************************************/ #include <tcl.h> #include <stdlib.h> #include <tlforms.h> #include <tlstable.h> #include "./tclconv.h" #include "./userconv.h" /* find name in STable */ int findhash_conv(char *name, void *STable) { int nr,result; char *tmpstr; result = STableFind(STable,name,(void * *) &nr); if (result==ST_OK) return nr; /* found case sensitive */ /* search for case insensitive */ tmpstr = ST2insensitive( name ); result = STableFind(STable,tmpstr,(void * *) &nr); free(tmpstr); if (result==ST_OK) return nr; /* found case insensitive */ return -1; /* not found */ } /* define set/iset hash tables */ void *hash_conv_set_0; /* initialize set/iset hash tables */ void Init_hash_conv_set( void ) { int *setnrs; setnrs = (int *) malloc(3*sizeof(int)); /* init hash_conv_set_0 */ hash_conv_set_0 = STableNew(211,0); /* case insensitive */ setnrs[0] = 1; STableAdd(hash_conv_set_0,"left",(void *) &(setnrs[0])); setnrs[1] = 2; STableAdd(hash_conv_set_0,"right",(void *) &(setnrs[1])); setnrs[2] = 3; STableAdd(hash_conv_set_0,"center",(void *) &(setnrs[2])); return; } int Tcl_conv_000(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_001(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_002(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_003(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_004(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_005(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_006(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_007(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_008(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_009(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_010(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_011(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_012(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_013(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_014(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); int Tcl_conv_015(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]); /* Symbol Table of Tcl_conv_0 */ void *hash_conv_0; void Init_hash_conv_000( void ); void Init_hash_conv_001( void ); void Init_hash_conv_002( void ); void Init_hash_conv_003( void ); void Init_hash_conv_004( void ); void Init_hash_conv_005( void ); void Init_hash_conv_006( void ); void Init_hash_conv_007( void ); void Init_hash_conv_008( void ); void Init_hash_conv_009( void ); void Init_hash_conv_010( void ); void Init_hash_conv_011( void ); void Init_hash_conv_012( void ); void Init_hash_conv_013( void ); void Init_hash_conv_014( void ); void Init_hash_conv_015( void ); /* initialize hash_conv_0 */ void Init_hash_conv_0( void ) { hash_conv_0 = STableNew(211,1); /* create case sensitive hash */ /* case sensitive */ STableAdd(hash_conv_0, "\001expand\001", (void *) 0); /* case sensitive */ STableAdd(hash_conv_0, "\001nat2nat\001", (void *) 1); /* case sensitive */ STableAdd(hash_conv_0, "\001nat2hex\001", (void *) 2); /* case sensitive */ STableAdd(hash_conv_0, "\001nat2octal\001", (void *) 3); /* case sensitive */ STableAdd(hash_conv_0, "\001nat2binary\001", (void *) 4); /* case sensitive */ STableAdd(hash_conv_0, "\001nat2compact\001", (void *) 5); /* case sensitive */ STableAdd(hash_conv_0, "\001hex2nat\001", (void *) 6); /* case sensitive */ STableAdd(hash_conv_0, "\001binary2nat\001", (void *) 7); /* case sensitive */ STableAdd(hash_conv_0, "\001octal2nat\001", (void *) 8); /* case sensitive */ STableAdd(hash_conv_0, "\001compact2nat\001", (void *) 9); /* case sensitive */ STableAdd(hash_conv_0, "\001bool2bool\001", (void *) 10); /* case sensitive */ STableAdd(hash_conv_0, "\001bool2nbool\001", (void *) 11); /* case sensitive */ STableAdd(hash_conv_0, "\001bool2cbool\001", (void *) 12); /* case sensitive */ STableAdd(hash_conv_0, "\001real2real\001", (void *) 13); /* case sensitive */ STableAdd(hash_conv_0, "\001real2freal\001", (void *) 14); /* case sensitive */ STableAdd(hash_conv_0, "\001real2breal\001", (void *) 15); Init_hash_conv_000(); Init_hash_conv_001(); Init_hash_conv_002(); Init_hash_conv_003(); Init_hash_conv_004(); Init_hash_conv_005(); Init_hash_conv_006(); Init_hash_conv_007(); Init_hash_conv_008(); Init_hash_conv_009(); Init_hash_conv_010(); Init_hash_conv_011(); Init_hash_conv_012(); Init_hash_conv_013(); Init_hash_conv_014(); Init_hash_conv_015(); return; } /* select: conv */ int Tcl_conv_0(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { int i; if (argc==0) { /* command name expected */ Tcl_SetResult(interp,"conv: Command name expected.",TCL_VOLATILE); return TCL_ERROR; } /* search for next command name */ i = findhash_conv(argv[0],hash_conv_0); switch( i ) { /* select appropriate funcion */ case 0: return Tcl_conv_000(cdata, interp, argc-1, &(argv[1])); break; case 1: return Tcl_conv_001(cdata, interp, argc-1, &(argv[1])); break; case 2: return Tcl_conv_002(cdata, interp, argc-1, &(argv[1])); break; case 3: return Tcl_conv_003(cdata, interp, argc-1, &(argv[1])); break; case 4: return Tcl_conv_004(cdata, interp, argc-1, &(argv[1])); break; case 5: return Tcl_conv_005(cdata, interp, argc-1, &(argv[1])); break; case 6: return Tcl_conv_006(cdata, interp, argc-1, &(argv[1])); break; case 7: return Tcl_conv_007(cdata, interp, argc-1, &(argv[1])); break; case 8: return Tcl_conv_008(cdata, interp, argc-1, &(argv[1])); break; case 9: return Tcl_conv_009(cdata, interp, argc-1, &(argv[1])); break; case 10: return Tcl_conv_010(cdata, interp, argc-1, &(argv[1])); break; case 11: return Tcl_conv_011(cdata, interp, argc-1, &(argv[1])); break; case 12: return Tcl_conv_012(cdata, interp, argc-1, &(argv[1])); break; case 13: return Tcl_conv_013(cdata, interp, argc-1, &(argv[1])); break; case 14: return Tcl_conv_014(cdata, interp, argc-1, &(argv[1])); break; case 15: return Tcl_conv_015(cdata, interp, argc-1, &(argv[1])); break; default: /* error */ Tcl_SetResult(interp,"conv: Invalid command name.",TCL_VOLATILE); return TCL_ERROR; break; } } /* end Tcl_conv_0 */ /* Symbol Table of Tcl_conv_000 */ void *hash_conv_000; /* initialize hash_conv_000 */ void Init_hash_conv_000( void ) { hash_conv_000 = STableNew(211,1); /* create case sensitive hash */ /* case sensitive */ STableAdd(hash_conv_000, "\001format\001", (void *) 0); /* case sensitive */ STableAdd(hash_conv_000, "\001fillchar\001", (void *) 1); return; } /* data: conv expand */ int Tcl_conv_000(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_expand data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=2) && ((argc&1)==0) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv expand: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=NULL; data.length=0; data.format.str=NULL; data.format_present=0; data.fillchar=0; data.fillchar_present=0; data.result=NULL; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* string */ int invarlen; invarlen = strlen(argv[curarg]); data.indata = (char *) malloc(invarlen+1); strcpy(data.indata,argv[curarg]); comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2nat(argv[curarg],&( data.length )); if (result!=TLF_OK) { char errorstr[75]; sprintf(errorstr,"conv expand arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } /* option */ while ((comresult==TCL_OK) && (curarg<(argc-1))) /* no indent */ { /* read 2 by 2 */ int i; if (argv[curarg][0]=='-') i = findhash_conv((argv[curarg]+sizeof(char)),hash_conv_000); else i=-1; /* error */ curarg++; switch( i ) { /* select appropriate option */ case 0: /* format */ /* free previous data */ if (data.format.str!=NULL) /*dispose set/iset*/ free(data.format.str); /* convert data */ { /* set/iset */ int *iwitc; if (STableFind(hash_conv_set_0,argv[curarg],(void **) &iwitc)==ST_OK) { data.format.nr=*iwitc; data.format.str = (char *) malloc(strlen(argv[curarg])+1); strcpy(data.format.str,argv[curarg]); comresult = TCL_OK; } else { char errorstr[75]; sprintf(errorstr,"conv expand arg %i: Invalid type. (set)",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } } data.format_present = 1; break; case 1: /* fillchar */ /* free previous data */ ; /* convert data */ { /* char */ if ((argv[curarg][0]!=0) && (argv[curarg][1]==0)) { data.fillchar=argv[curarg][0]; comresult = TCL_OK; } else { char errorstr[75]; sprintf(errorstr,"conv expand arg %i: Invalid type. (char)",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } } data.fillchar_present = 1; break; default: /* error */ { char errorstr[75]; sprintf(errorstr,"conv expand arg %i: Invalid option.",curarg); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } break; } /* end switch */ curarg++; } /* end option while */ if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = fexpand(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+75); sprintf(errorstr,"conv expand: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[75]; sprintf(errorstr,"conv expand: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* string */ Tcl_DStringAppend(&( tclstr ),data.result,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ if (data.indata!=NULL) /*dispose string*/ free(data.indata); ; if (data.format.str!=NULL) /*dispose set/iset*/ free(data.format.str); ; if (data.result!=NULL) /*dispose string*/ free(data.result); if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_000 */ /* Symbol Table of Tcl_conv_001 */ void *hash_conv_001; /* initialize hash_conv_001 */ void Init_hash_conv_001( void ) { hash_conv_001 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv nat2nat */ int Tcl_conv_001(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_nat2nat data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv nat2nat: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0; data.result=0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2nat(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[76]; sprintf(errorstr,"conv nat2nat arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = fnat2nat(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+76); sprintf(errorstr,"conv nat2nat: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[76]; sprintf(errorstr,"conv nat2nat: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* natural */ char outstr[32]; nat2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_001 */ /* Symbol Table of Tcl_conv_002 */ void *hash_conv_002; /* initialize hash_conv_002 */ void Init_hash_conv_002( void ) { hash_conv_002 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv nat2hex */ int Tcl_conv_002(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_nat2hex data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv nat2hex: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0; data.result=0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2nat(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[76]; sprintf(errorstr,"conv nat2hex arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = fnat2hex(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+76); sprintf(errorstr,"conv nat2hex: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[76]; sprintf(errorstr,"conv nat2hex: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* hex */ char outstr[32]; hex2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_002 */ /* Symbol Table of Tcl_conv_003 */ void *hash_conv_003; /* initialize hash_conv_003 */ void Init_hash_conv_003( void ) { hash_conv_003 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv nat2octal */ int Tcl_conv_003(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_nat2octal data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv nat2octal: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0; data.result=0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2nat(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[78]; sprintf(errorstr,"conv nat2octal arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = fnat2octal(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+78); sprintf(errorstr,"conv nat2octal: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[78]; sprintf(errorstr,"conv nat2octal: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* octal */ char outstr[32]; octal2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_003 */ /* Symbol Table of Tcl_conv_004 */ void *hash_conv_004; /* initialize hash_conv_004 */ void Init_hash_conv_004( void ) { hash_conv_004 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv nat2binary */ int Tcl_conv_004(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_nat2binary data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv nat2binary: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0; data.result=0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2nat(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[79]; sprintf(errorstr,"conv nat2binary arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = fnat2binary(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+79); sprintf(errorstr,"conv nat2binary: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[79]; sprintf(errorstr,"conv nat2binary: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* binary */ char outstr[72]; binary2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_004 */ /* Symbol Table of Tcl_conv_005 */ void *hash_conv_005; /* initialize hash_conv_005 */ void Init_hash_conv_005( void ) { hash_conv_005 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv nat2compact */ int Tcl_conv_005(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_nat2compact data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv nat2compact: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0; data.result=0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2nat(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[80]; sprintf(errorstr,"conv nat2compact arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = fnat2compact(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+80); sprintf(errorstr,"conv nat2compact: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[80]; sprintf(errorstr,"conv nat2compact: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* compact */ char outstr[16]; compact2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_005 */ /* Symbol Table of Tcl_conv_006 */ void *hash_conv_006; /* initialize hash_conv_006 */ void Init_hash_conv_006( void ) { hash_conv_006 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv hex2nat */ int Tcl_conv_006(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_hex2nat data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv hex2nat: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0; data.result=0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2hex(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[76]; sprintf(errorstr,"conv hex2nat arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = fhex2nat(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+76); sprintf(errorstr,"conv hex2nat: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[76]; sprintf(errorstr,"conv hex2nat: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* natural */ char outstr[32]; nat2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_006 */ /* Symbol Table of Tcl_conv_007 */ void *hash_conv_007; /* initialize hash_conv_007 */ void Init_hash_conv_007( void ) { hash_conv_007 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv binary2nat */ int Tcl_conv_007(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_binary2nat data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv binary2nat: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0; data.result=0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2binary(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[79]; sprintf(errorstr,"conv binary2nat arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = fbinary2nat(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+79); sprintf(errorstr,"conv binary2nat: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[79]; sprintf(errorstr,"conv binary2nat: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* natural */ char outstr[32]; nat2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_007 */ /* Symbol Table of Tcl_conv_008 */ void *hash_conv_008; /* initialize hash_conv_008 */ void Init_hash_conv_008( void ) { hash_conv_008 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv octal2nat */ int Tcl_conv_008(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_octal2nat data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv octal2nat: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0; data.result=0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2octal(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[78]; sprintf(errorstr,"conv octal2nat arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = foctal2nat(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+78); sprintf(errorstr,"conv octal2nat: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[78]; sprintf(errorstr,"conv octal2nat: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* natural */ char outstr[32]; nat2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_008 */ /* Symbol Table of Tcl_conv_009 */ void *hash_conv_009; /* initialize hash_conv_009 */ void Init_hash_conv_009( void ) { hash_conv_009 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv compact2nat */ int Tcl_conv_009(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_compact2nat data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv compact2nat: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0; data.result=0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2compact(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[80]; sprintf(errorstr,"conv compact2nat arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = fcompact2nat(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+80); sprintf(errorstr,"conv compact2nat: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[80]; sprintf(errorstr,"conv compact2nat: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* natural */ char outstr[32]; nat2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_009 */ /* Symbol Table of Tcl_conv_010 */ void *hash_conv_010; /* initialize hash_conv_010 */ void Init_hash_conv_010( void ) { hash_conv_010 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv bool2bool */ int Tcl_conv_010(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_bool2bool data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv bool2bool: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0; data.result=0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2bool(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[78]; sprintf(errorstr,"conv bool2bool arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = fbool2bool(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+78); sprintf(errorstr,"conv bool2bool: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[78]; sprintf(errorstr,"conv bool2bool: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* boolean */ char outstr[8]; bool2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_010 */ /* Symbol Table of Tcl_conv_011 */ void *hash_conv_011; /* initialize hash_conv_011 */ void Init_hash_conv_011( void ) { hash_conv_011 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv bool2nbool */ int Tcl_conv_011(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_bool2nbool data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv bool2nbool: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0; data.result=0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2bool(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[79]; sprintf(errorstr,"conv bool2nbool arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = fbool2nbool(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+79); sprintf(errorstr,"conv bool2nbool: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[79]; sprintf(errorstr,"conv bool2nbool: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* nboolean */ char outstr[4]; nbool2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_011 */ /* Symbol Table of Tcl_conv_012 */ void *hash_conv_012; /* initialize hash_conv_012 */ void Init_hash_conv_012( void ) { hash_conv_012 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv bool2cbool */ int Tcl_conv_012(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_bool2cbool data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv bool2cbool: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0; data.result=0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2bool(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[79]; sprintf(errorstr,"conv bool2cbool arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = fbool2cbool(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+79); sprintf(errorstr,"conv bool2cbool: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[79]; sprintf(errorstr,"conv bool2cbool: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* cboolean */ char outstr[4]; cbool2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_012 */ /* Symbol Table of Tcl_conv_013 */ void *hash_conv_013; /* initialize hash_conv_013 */ void Init_hash_conv_013( void ) { hash_conv_013 = STableNew(211,1); /* create case sensitive hash */ /* case sensitive */ STableAdd(hash_conv_013, "\001maxfract\001", (void *) 0); return; } /* data: conv real2real */ int Tcl_conv_013(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_real2real data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && ((argc&1)==1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv real2real: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0.0; data.maxfract=0; data.maxfract_present=0; data.result=NULL; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2real(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[78]; sprintf(errorstr,"conv real2real arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } /* option */ while ((comresult==TCL_OK) && (curarg<(argc-1))) /* no indent */ { /* read 2 by 2 */ int i; if (argv[curarg][0]=='-') i = findhash_conv((argv[curarg]+sizeof(char)),hash_conv_013); else i=-1; /* error */ curarg++; switch( i ) { /* select appropriate option */ case 0: /* maxfract */ /* free previous data */ ; /* convert data */ { /* a simple type */ int result; result = str2nat(argv[curarg],&( data.maxfract )); if (result!=TLF_OK) { char errorstr[78]; sprintf(errorstr,"conv real2real arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } data.maxfract_present = 1; break; default: /* error */ { char errorstr[78]; sprintf(errorstr,"conv real2real arg %i: Invalid option.",curarg); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } break; } /* end switch */ curarg++; } /* end option while */ if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = freal2real(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+78); sprintf(errorstr,"conv real2real: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[78]; sprintf(errorstr,"conv real2real: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* string */ Tcl_DStringAppend(&( tclstr ),data.result,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.result!=NULL) /*dispose string*/ free(data.result); if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_013 */ /* Symbol Table of Tcl_conv_014 */ void *hash_conv_014; /* initialize hash_conv_014 */ void Init_hash_conv_014( void ) { hash_conv_014 = STableNew(211,1); /* create case sensitive hash */ /* case sensitive */ STableAdd(hash_conv_014, "\001maxint\001", (void *) 0); /* case sensitive */ STableAdd(hash_conv_014, "\001maxfract\001", (void *) 1); return; } /* data: conv real2freal */ int Tcl_conv_014(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_real2freal data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && ((argc&1)==1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv real2freal: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0.0; data.maxint=0; data.maxint_present=0; data.maxfract=0; data.maxfract_present=0; data.result=NULL; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2real(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[79]; sprintf(errorstr,"conv real2freal arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } /* option */ while ((comresult==TCL_OK) && (curarg<(argc-1))) /* no indent */ { /* read 2 by 2 */ int i; if (argv[curarg][0]=='-') i = findhash_conv((argv[curarg]+sizeof(char)),hash_conv_014); else i=-1; /* error */ curarg++; switch( i ) { /* select appropriate option */ case 0: /* maxint */ /* free previous data */ ; /* convert data */ { /* a simple type */ int result; result = str2nat(argv[curarg],&( data.maxint )); if (result!=TLF_OK) { char errorstr[79]; sprintf(errorstr,"conv real2freal arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } data.maxint_present = 1; break; case 1: /* maxfract */ /* free previous data */ ; /* convert data */ { /* a simple type */ int result; result = str2nat(argv[curarg],&( data.maxfract )); if (result!=TLF_OK) { char errorstr[79]; sprintf(errorstr,"conv real2freal arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } data.maxfract_present = 1; break; default: /* error */ { char errorstr[79]; sprintf(errorstr,"conv real2freal arg %i: Invalid option.",curarg); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } break; } /* end switch */ curarg++; } /* end option while */ if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = freal2freal(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+79); sprintf(errorstr,"conv real2freal: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[79]; sprintf(errorstr,"conv real2freal: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* string */ Tcl_DStringAppend(&( tclstr ),data.result,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; ; if (data.result!=NULL) /*dispose string*/ free(data.result); if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_014 */ /* Symbol Table of Tcl_conv_015 */ void *hash_conv_015; /* initialize hash_conv_015 */ void Init_hash_conv_015( void ) { hash_conv_015 = STableNew(211,1); /* create case sensitive hash */ return; } /* data: conv real2breal */ int Tcl_conv_015(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { t_real2breal data; /* data structure */ int comresult; /* Used by type conversion */ int curarg; /* current argument read */ if ( (argc>=1) && (argc<=1) ) comresult = TCL_OK; else { Tcl_SetResult(interp,"conv real2breal: Invalid argument number.",TCL_VOLATILE); comresult = TCL_ERROR; return TCL_ERROR; } /* initialise data */ data.indata=0.0; data.result=0.0; data.errorstr=NULL; curarg = 0; /* start with the first argument */ /* params */ if (comresult==TCL_OK) /* no indent */ { { /* a simple type */ int result; result = str2real(argv[curarg],&( data.indata )); if (result!=TLF_OK) { char errorstr[79]; sprintf(errorstr,"conv real2breal arg %i: Invalid type.",curarg+1); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else comresult = TCL_OK; } curarg++; } if (comresult==TCL_OK) /* no indent */ { /* call user function */ int result; result = freal2breal(&data); if (result !=TL_OK) if (data.errorstr!=NULL) { /* error in user function */ char *errorstr; errorstr = (char *) malloc(strlen(data.errorstr)+79); sprintf(errorstr,"conv real2breal: Func. error (%i) %s.",result,data.errorstr); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; free(errorstr); } else /* no errorstr */ { char errorstr[79]; sprintf(errorstr,"conv real2breal: Func. error (%i).",result); Tcl_SetResult(interp,errorstr,TCL_VOLATILE); comresult = TCL_ERROR; } else /* no error */ { /* convert data */ Tcl_DString tclstr; Tcl_DStringInit(&tclstr); { /* breal */ char outstr[160]; breal2str(data.result,outstr); Tcl_DStringAppend(&( tclstr ),outstr,-1); comresult = TCL_OK; } if (comresult==TCL_OK) Tcl_DStringResult(interp,&tclstr); /* save result */ else Tcl_DStringFree(&tclstr); /* error, free structure */ } } /* dispose data */ ; ; if (data.errorstr!=NULL) free(data.errorstr); return comresult; } /* end Tcl_conv_015 */ int Tcl_conv_main(ClientData cdata, Tcl_Interp *interp, int argc, char *argv[]) { /* skip first word */ return Tcl_conv_0(cdata, interp, argc-1, &(argv[1])); } /* tcl interpreter for command conv */ int tl_conv_Tcl_Init(Tcl_Interp *interp) { Tcl_CreateCommand(interp, "conv", Tcl_conv_main, NULL, NULL); Init_hash_conv_0(); Init_hash_conv_set(); return TCL_OK; }