/*--------------------------------------------------------------------------*/ void C2F(mget) (int *fd, double *res, int *n, char *type, int *ierr) { int nc, swap2; FILE *fa; nc = (int)strlen(type); *ierr = 0; if (nc == 0) { sciprint(_("%s: Wrong size for input argument #%d: Non-empty string expected.\n"), "mput", 4, type); *ierr = 2; return; } fa = GetFileOpenedInScilab(*fd); if (fa) { swap2 = GetSwapStatus(*fd); mget2(fa, swap2, res, *n, type, ierr); if (*ierr > 0) { sciprint(_("%s: Wrong value for input argument #%d: Format not recognized.\n"), "mget", 4); } } else { sciprint(_("%s: No input file associated to logical unit %d.\n"), "mget", *fd); *ierr = 3; } }
/*--------------------------------------------------------------------------*/ double *GetSwapsUsed(int *sizeArrayReturned) { double *ArraySwapUsed = NULL; int i = 0, j = 0; *sizeArrayReturned = GetNumberOfIdsUsed(); ArraySwapUsed = (double*)MALLOC(sizeof(double)*(*sizeArrayReturned)); if (ArraySwapUsed == NULL) { *sizeArrayReturned = 0; return NULL; } j = 0; for (i = 0; i < GetMaximumFileOpenedInScilab(); i++) { if (GetFileTypeOpenedInScilab(i) != 0) { ArraySwapUsed[j] = (double)GetSwapStatus(i); j++; } } return ArraySwapUsed; }
/*--------------------------------------------------------------------------*/ void C2F(getfileinfo)(int *fd, FILE *fa, int *swap2, int *type, int *mode, char *filename, int *lf, int *ierr) { char *filenamefromfd = NULL; if (*fd<0 || *fd>=GetMaximumFileOpenedInScilab() ) { *ierr=1; return; } if ( GetFileTypeOpenedInScilab(*fd) == 0 ) { *ierr=2; return; } fa = GetFileOpenedInScilab(*fd); *swap2 = GetSwapStatus(*fd); *type = GetFileTypeOpenedInScilab(*fd); *mode = GetFileModeOpenedInScilab(*fd); filenamefromfd = GetFileNameOpenedInScilab(*fd); if (filenamefromfd) strcpy(filename,GetFileNameOpenedInScilab(*fd)); else strcpy(filename,""); *lf=(int)strlen(filename); *ierr=0; }
/*--------------------------------------------------------------------------*/ void C2F(mput) (int *fd, double *res, int *n, char *type, int *ierr) { int nc = 0,swap2 = 0; FILE *fa = NULL; *ierr = 0; if ((nc = (int)strlen(type)) == 0) { if ( getWarningMode() ) sciprint(_("%s: Wrong size for input argument #%d ('%s'): Non-empty string expected.\n"),"mput",4,type); *ierr = 2; return; } if ( *fd == -1 && GetFileOpenedInScilab(*fd) == NULL ) { sciprint(_("%s: No File opened in Scilab.\n") , "mput" ) ; *ierr = 3 ; return ; } if ((fa = GetFileOpenedInScilab(*fd)) !=NULL) { swap2 = GetSwapStatus(*fd); mput2(fa,swap2,res,*n,type,ierr); if (*ierr > 0) { if ( getWarningMode() ) { sciprint(_("%s: Wrong value for input argument #%d ('%s'): Format not recognized.\n"),"mput",4,type); } } } else { if ( getWarningMode() ) { sciprint(_("%s: Error while opening, reading or writing '%s'.\n"),"mput", GetFileNameOpenedInScilab(*fd)); } *ierr=3; } }
/*--------------------------------------------------------------------------*/ void C2F(mgetnc) (int *fd, void *res, int *n1, char *type, int *ierr) { char c1, c2; int i, items, n = *n1; FILE *fa; *ierr = 0; if ((fa = GetFileOpenedInScilab(*fd)) == NULL) { sciprint(_("%s: No input file associated to logical unit %d.\n"), "mget", *fd); *ierr = 3; return; } swap = GetSwapStatus(*fd); /* Safe version for optional type modifiers */ c1 = (type[0] && type[1]) ? type[1] : ' '; c2 = (type[0] && type[1] && type[2]) ? type[2] : ' '; switch (type[0]) { case 'i': MGET_GEN_NC(int, c1); break; case 'l': MGET_GEN_NC(long long, c1); break; case 's': MGET_GEN_NC(short, c1); break; case 'c': MGET_CHAR_NC(char); break; case 'd': MGET_GEN_NC(double, c1); break; case 'f': MGET_GEN_NC(float, c1); break; case 'u': switch (c1) { case 'i': MGET_GEN_NC(unsigned int, c2); break; case 'l': MGET_GEN_NC(unsigned long long, c2); break; case 's': MGET_GEN_NC(unsigned short, c2); break; case ' ': MGET_GEN_NC(unsigned int, ' '); break; case 'c': MGET_CHAR_NC(unsigned char); break; default: *ierr = 1; return; } break; default: *ierr = 1; return; } if (items != n) { *ierr = -(items) - 1; /** sciprint("Read %d out of\n",items,n); **/ } return; }