GetCommandArg.c File Reference

#include <string.h>
#include "GetCommandArg.h"
#include "GetProperty.h"
#include "DefaultCommandArg.h"
#include "CurrentObjectsManagement.h"

Include dependency graph for GetCommandArg.c:

Go to the source code of this file.

Functions

int get_style_arg (char *fname, int pos, int n1, rhs_opts opts[], int **style)
int get_rect_arg (char *fname, int pos, rhs_opts opts[], double **rect)
int get_strf_arg (char *fname, int pos, rhs_opts opts[], char **strf)
int get_legend_arg (char *fname, int pos, rhs_opts opts[], char **legend)
int get_labels_arg (char *fname, int pos, rhs_opts opts[], char **labels)
int get_nax_arg (int pos, rhs_opts opts[], int **nax, BOOL *flagNax)
int get_zminmax_arg (char *fname, int pos, rhs_opts opts[], double **zminmax)
int get_colminmax_arg (char *fname, int pos, rhs_opts opts[], int **colminmax)
int get_colout_arg (char *fname, int pos, rhs_opts opts[], int **colout)
int get_with_mesh_arg (char *fname, int pos, rhs_opts opts[], BOOL *withMesh)
int get_logflags_arg (char *fname, int pos, rhs_opts opts[], char **logFlags)
int get_optional_double_arg (char *fname, int pos, char *name, double **value, int sz, rhs_opts opts[])
int get_optional_int_arg (char *fname, int pos, char *name, int **value, int sz, rhs_opts opts[])

Variables

static char logFlagsCpy [3]


Function Documentation

int get_colminmax_arg ( char *  fname,
int  pos,
rhs_opts  opts[],
int **  colminmax 
)

Definition at line 362 of file GetCommandArg.c.

References CheckLength, FindOpt, FirstOpt, getDefColMinMax(), GetRhsVar, istk, l, m, n, setDefColMinMax(), and VarType.

00363 {
00364   int m,n,l,first_opt=FirstOpt(),kopt;
00365 
00366   if (pos < first_opt) 
00367     {
00368       if (VarType(pos)) 
00369         {
00370           GetRhsVar(pos, "i", &m, &n, &l);
00371           CheckLength(pos,m*n,2);
00372           *colminmax=istk(l);
00373         }
00374       else
00375         {
00377     int zeros[2] = { 0, 0 } ;
00378     setDefColMinMax( zeros ) ;
00379           *colminmax = getDefColMinMax() ;
00380         }
00381     }
00382   else if ((kopt=FindOpt("colminmax",opts))) 
00383     {
00384       GetRhsVar(kopt, "i", &m, &n, &l);
00385       CheckLength(kopt,m*n,2);
00386       *colminmax=istk(l);
00387     }
00388   else 
00389     {
00391       int zeros[2] = { 0, 0 } ;
00392       setDefColMinMax( zeros ) ;
00393       *colminmax = getDefColMinMax() ;
00394     } 
00395   return 1;
00396 }

Here is the call graph for this function:

int get_colout_arg ( char *  fname,
int  pos,
rhs_opts  opts[],
int **  colout 
)

Definition at line 399 of file GetCommandArg.c.

References CheckLength, FindOpt, FirstOpt, getDefColOut(), GetRhsVar, istk, l, m, n, setDefColOut(), and VarType.

00400 {
00401   int m,n,l,first_opt=FirstOpt(),kopt;
00402 
00403   if (pos < first_opt) 
00404     {
00405       if (VarType(pos)) 
00406         {
00407           GetRhsVar(pos, "i", &m, &n, &l);
00408           CheckLength(pos,m*n,2);
00409           *colout = istk(l);
00410         }
00411       else
00412         {
00414     int newDefCO[2] = { -1, -1 } ;
00415     setDefColOut( newDefCO ) ;
00416           *colout = getDefColOut() ;
00417         }
00418     }
00419   else if ((kopt=FindOpt("colout",opts))) 
00420     {
00421       GetRhsVar(kopt, "i", &m, &n, &l);
00422       CheckLength(kopt,m*n,2);
00423       *colout=istk(l);
00424     }
00425   else 
00426     {
00428       int newDefCO[2] = { -1, -1 } ;
00429       setDefColOut( newDefCO ) ;
00430       *colout = getDefColOut() ;
00431     } 
00432   return 1;
00433 }

Here is the call graph for this function:

int get_labels_arg ( char *  fname,
int  pos,
rhs_opts  opts[],
char **  labels 
)

retrieve the labels from the command line and store them into Legend

Definition at line 226 of file GetCommandArg.c.

References cstk, FindOpt, FirstOpt, getDefLegend(), GetRhsVar, l, m, n, NULL, sciGetCurrentSubWin(), sciGetLegendDefined(), and VarType.

00227 {
00228   int m,n,l,first_opt=FirstOpt(),kopt;
00229 
00230   if (pos < first_opt) 
00231   { 
00232     if (VarType(pos)) {
00233       GetRhsVar(pos, "c", &m, &n, &l);
00234       *labels = cstk(l); 
00235     }
00236     else
00237     {
00238 
00239       /* jb silvy 03/2006 */
00240       /* do not change the legend if one already exists */
00241       sciPointObj * pSubWin = sciGetCurrentSubWin() ;
00242       if ( sciGetLegendDefined( pSubWin ) )
00243       {
00244         *labels = NULL ;
00245       }
00246       else
00247       {
00248         *labels = getDefLegend() ;
00249       }
00250     }
00251   }
00252   else if ((kopt=FindOpt("leg",opts)))
00253   {
00254     GetRhsVar(kopt, "c", &m, &n, &l);
00255     *labels = cstk(l); 
00256   }
00257   else
00258   {
00259 
00260     /* jb silvy 03/2006 */
00261     /* do not change the legend if one already exists */
00262     sciPointObj * pSubWin = sciGetCurrentSubWin() ;
00263     if ( sciGetLegendDefined( pSubWin ) )
00264     {
00265       *labels = NULL ;
00266     }
00267     else
00268     {
00269       *labels = getDefLegend() ;
00270     }
00271   }
00272   return 1;
00273 }

Here is the call graph for this function:

int get_legend_arg ( char *  fname,
int  pos,
rhs_opts  opts[],
char **  legend 
)

Definition at line 197 of file GetCommandArg.c.

References cstk, FindOpt, FirstOpt, getDefLegend(), GetRhsVar, l, m, n, and VarType.

00198 {
00199   int m,n,l,first_opt=FirstOpt(),kopt;
00200 
00201   if (pos < first_opt) 
00202     { 
00203       if (VarType(pos)) {
00204         GetRhsVar(pos, "c", &m, &n, &l);
00205         *legend = cstk(l); 
00206       }
00207       else
00208         {
00209           *legend = getDefLegend() ;
00210         }
00211     }
00212   else if ((kopt=FindOpt("leg",opts))) {
00213     GetRhsVar(kopt, "c", &m, &n, &l);
00214     *legend = cstk(l); 
00215   }
00216   else
00217     {
00218       *legend = getDefLegend() ;
00219     }
00220   return 1;
00221 }

Here is the call graph for this function:

int get_logflags_arg ( char *  fname,
int  pos,
rhs_opts  opts[],
char **  logFlags 
)

Definition at line 470 of file GetCommandArg.c.

References cstk, Err, Error, FindOpt, FirstOpt, getDefLogFlags(), GetRhsVar, l, logFlagsCpy, m, n, and VarType.

00471 {
00472   int m,n,l,first_opt=FirstOpt(),kopt;
00473   
00474   if (pos < first_opt) /* regular argument  */
00475   { 
00476     if (VarType(pos))
00477     {
00478             GetRhsVar(pos, "c", &m, &n, &l);
00479             if ((m * n != 2)&&(m * n != 3))
00480       {
00481               Scierror(999,"%s: logflag has wrong size (%d), expected 2 or 3\r\n",fname,m*n);
00482               return 0;
00483             }
00484             if (m * n == 2)
00485       {
00486               if ((*cstk(l)!='l'&&*cstk(l)!='n')||(*cstk(l+1)!='l'&&*cstk(l+1)!='n'))
00487         {
00488                 Err=pos;
00489                 Error(116);
00490                 return 0;
00491               }
00492               logFlagsCpy[0]='g';
00493         logFlagsCpy[1]=*cstk(l);
00494         logFlagsCpy[2]=*cstk(l+1) ;
00495         *logFlags = logFlagsCpy ;
00496       }
00497             else 
00498       {
00499               if (((*cstk(l)!='g')&&(*cstk(l)!='e')&&(*cstk(l)!='o')) || 
00500                   (*cstk(l+1)!='l'&&*cstk(l+1)!='n') || 
00501                   (*cstk(l+2)!='l'&&*cstk(l+2)!='n'))
00502         {
00503                 Err=pos;
00504                 Error(116);
00505                 return 0;
00506               }
00507         *logFlags = cstk(l) ;  
00508       }
00509       
00510     }
00511     else /* zero type argument --> default value */
00512           {
00513       *logFlags = getDefLogFlags() ;
00514           }
00515   }
00516   else if ((kopt=FindOpt("logflag",opts)))
00517   { /* named argument: style=value */
00518     GetRhsVar(kopt,"c", &m, &n, &l);
00519     if ((m * n != 2)&&(m * n != 3))
00520     {
00521       Scierror(999,"%s: logflag has wrong size (%d), expected 2 or 3\r\n",fname,m * n);
00522       return 0;
00523     }
00524     if (m * n == 2)
00525     {
00526       if ((*cstk(l)!='l'&&*cstk(l)!='n')||(*cstk(l+1)!='l'&&*cstk(l+1)!='n'))
00527       {
00528               Err=kopt;
00529               Error(116);
00530               return 0;
00531       }
00532       logFlagsCpy[0]='g';
00533       logFlagsCpy[1]=*cstk(l);
00534       logFlagsCpy[2]=*cstk(l+1) ;
00535       *logFlags = logFlagsCpy ;
00536     }
00537     else
00538     {
00539       if (((*cstk(l)!='g')&&(*cstk(l)!='e')&&(*cstk(l)!='o')) || 
00540                  (*cstk(l+1)!='l'&&*cstk(l+1)!='n') || 
00541                  (*cstk(l+2)!='l'&&*cstk(l+2)!='n'))
00542       {
00543               Err=kopt;
00544               Error(116);
00545               return 0;
00546       }
00547       
00548       *logFlags = cstk(l) ;
00549     }
00550   }
00551   else /* unspecified argument --> default value */
00552   {
00553     *logFlags = getDefLogFlags() ;
00554   }
00555   return 1;
00556 }

Here is the call graph for this function:

int get_nax_arg ( int  pos,
rhs_opts  opts[],
int **  nax,
BOOL *  flagNax 
)

Definition at line 276 of file GetCommandArg.c.

References CheckLength, FALSE, FindOpt, FirstOpt, getDefNax(), GetRhsVar, i, istk, l, m, Max, n, TRUE, and VarType.

00277 {
00278   int i,m,n,l,first_opt=FirstOpt(),kopt;
00279 
00280   if (pos < first_opt)
00281   {
00282     if (VarType(pos))
00283     {
00284       GetRhsVar(pos, "i", &m, &n, &l);
00285       CheckLength(pos,m*n,4);
00286       for (i = 0 ; i < 4; ++i)
00287       {
00288         *istk(l+i) = Max((integer) *istk(l+i),0); /*POLPOTH09042001*/
00289       }
00290       *nax=istk(l);
00291       *flagNax = TRUE;
00292     }
00293     else  
00294     {
00295             *nax = getDefNax() ;
00296             *flagNax = FALSE;
00297     }
00298   }
00299   else if ((kopt=FindOpt("nax",opts)))
00300   {
00301     GetRhsVar(kopt, "i", &m, &n, &l);
00302     CheckLength(kopt,m*n,4);
00303     for (i = 0 ; i < 4; ++i)
00304     {
00305       *istk(l+i) = Max((integer) *istk(l+i),0); /*POLPOTH09042001*/
00306     }
00307     *nax=istk(l);
00308     *flagNax = TRUE;
00309   }
00310   else 
00311   {
00312     *nax = getDefNax() ;
00313     *flagNax = FALSE;
00314   } 
00315   return 1;
00316 }

Here is the call graph for this function:

int get_optional_double_arg ( char *  fname,
int  pos,
char *  name,
double **  value,
int  sz,
rhs_opts  opts[] 
)

Definition at line 558 of file GetCommandArg.c.

References CheckLength, FindOpt, FirstOpt, GetRhsVar, l, m, n, stk, and VarType.

00564 {
00565   int m,n,l,first_opt=FirstOpt(),kopt;
00566 
00567   if (pos < first_opt) 
00568     { 
00569       if (VarType(pos)) {
00570         GetRhsVar(pos, "d", &m, &n, &l);
00571         CheckLength(pos,m*n,sz)
00572           *value = stk(l);
00573       }
00574     }
00575   else if ((kopt=FindOpt(name,opts))) {
00576     GetRhsVar(kopt,"d", &m, &n, &l);
00577     CheckLength(kopt,m*n,sz)
00578       *value = stk(l);
00579   }
00580   return 1;
00581 }

int get_optional_int_arg ( char *  fname,
int  pos,
char *  name,
int **  value,
int  sz,
rhs_opts  opts[] 
)

Definition at line 583 of file GetCommandArg.c.

References CheckLength, FindOpt, FirstOpt, GetRhsVar, istk, l, m, n, and VarType.

00589 {
00590   int m,n,l,first_opt=FirstOpt(),kopt;
00591 
00592   if (pos < first_opt) 
00593     { 
00594       if (VarType(pos)) {
00595         GetRhsVar(pos, "i", &m, &n, &l);
00596         CheckLength(pos,m*n,sz)
00597           *value = istk(l);
00598       }
00599     }
00600   else if ((kopt=FindOpt(name,opts))) {
00601     GetRhsVar(kopt,"i", &m, &n, &l);
00602     CheckLength(kopt,m*n,sz)
00603       *value = istk(l);
00604   }
00605   return 1;
00606 }

int get_rect_arg ( char *  fname,
int  pos,
rhs_opts  opts[],
double **  rect 
)

Definition at line 99 of file GetCommandArg.c.

References FindOpt, finite(), FirstOpt, getDefRect(), GetRhsVar, i, l, m, n, setDefRect(), stk, and VarType.

00100 {
00101   int m,n,l,first_opt=FirstOpt(),kopt,i;
00102 
00103   if (pos < first_opt) 
00104     { 
00105       if (VarType(pos)) {
00106         GetRhsVar(pos, "d", &m, &n, &l);
00107         if (m * n != 4) { 
00108           Scierror(999,"%s: rect has wrong size (%d), 4 expected \r\n",fname,m*n); 
00109           return 0;
00110         }
00111         *rect = stk(l);
00112         
00113         for(i=0;i<4;i++)
00114           if(finite((*rect)[i]) == 0){
00115             Scierror(999,"%s: rect has Nan or Inf values, 4 finite values expected \r\n",fname,m*n); 
00116             return 0;
00117           }
00118       }
00119       else 
00120         {
00122     double zeros[4] = { 0.0, 0.0, 0.0, 0.0 } ;
00123     setDefRect( zeros ) ;
00124           *rect = getDefRect() ;
00125         }
00126     }
00127   else if ((kopt=FindOpt("rect",opts))) {/* named argument: rect=value */
00128     GetRhsVar(kopt, "d", &m, &n, &l);
00129     if (m * n != 4) { 
00130       Scierror(999,"%s: rect has wrong size (%d), 4 expected \r\n",fname,m*n); 
00131       return 0;
00132     }
00133     *rect = stk(l);
00134     
00135     for(i=0;i<4;i++)
00136       if(finite((*rect)[i]) == 0){
00137         Scierror(999,"%s: rect has Nan or Inf values, 4 finite values expected \r\n",fname,m*n); 
00138         return 0;
00139       }
00140   }
00141   else
00142     {
00144       double zeros[4] = { 0.0, 0.0, 0.0, 0.0 } ;
00145       setDefRect( zeros ) ;
00146             *rect = getDefRect() ;
00147     }
00148     
00149   return 1;
00150 }

Here is the call graph for this function:

int get_strf_arg ( char *  fname,
int  pos,
rhs_opts  opts[],
char **  strf 
)

Definition at line 152 of file GetCommandArg.c.

References cstk, FindOpt, FirstOpt, getDefStrf(), GetRhsVar, l, m, n, reinitDefStrf(), reinitDefStrfN(), and VarType.

00153 {
00154   int m,n,l,first_opt=FirstOpt(),kopt;
00155 
00156   if (pos < first_opt)
00157   { 
00158     if (VarType(pos))
00159     {
00160             GetRhsVar(pos, "c", &m, &n, &l);
00161             if ( m * n != 3 )
00162       { 
00163               Scierror(999,"%s: strf has wrong size (%d), 3 expected \r\n",fname,m*n); 
00164               return 0;
00165             }
00166           *strf = cstk(l); 
00167     }
00168     else
00169           {
00170             /* def value can be changed */
00171       reinitDefStrf() ;
00172       *strf = getDefStrf() ;
00173           }
00174   }
00175   else if ((kopt=FindOpt("strf",opts)))
00176   {
00177     GetRhsVar(kopt, "c", &m, &n, &l);
00178     if (m * n != 3)
00179     { 
00180       Scierror(999,"%s: strf has wrong size (%d), 3 expected \r\n",fname,m*n); 
00181       return 0;
00182     }
00183     *strf = cstk(l); 
00184   }
00185   else
00186   {
00187     /* def value can be changed */
00188       
00189     reinitDefStrfN() ;
00190     *strf = getDefStrf() ;
00191    
00192   }
00193   return 1;
00194 }

Here is the call graph for this function:

int get_style_arg ( char *  fname,
int  pos,
int  n1,
rhs_opts  opts[],
int **  style 
)

Definition at line 20 of file GetCommandArg.c.

References CreateVar, FindOpt, FirstOpt, GetRhsVar, i, istk, ix, l, m, Max, n, Nbvars, Rhs, and VarType.

00021 {
00022   int m,n,l,first_opt=FirstOpt(),kopt,un=1,ix,i,l1;
00023 
00024   Nbvars = Max(Nbvars,Rhs);
00025 
00026 
00027   if ( pos < first_opt ) /* regular argument  */
00028   { 
00029     if (VarType(pos))
00030     {
00031             GetRhsVar(pos, "i", &m, &n, &l);
00032             if (m * n < n1)
00033       {
00034               Scierror(999,"%s: style is too small (%d < %d)\r\n",fname,m*n,n1);
00035               return 0;
00036             }
00037             if ( n1 == 1 && m * n == 1 )
00038       {
00039               ix = 2;
00040               CreateVar(Nbvars+1,"i",&un,&ix,&l1);
00041               *istk(l1)=*istk(l);
00042               *istk(l1+1)=1;
00043               l=l1;
00044             }
00045             *style = istk(l);
00046     }
00047     else /* zero type argument --> default value */
00048           {
00049             ix = Max(n1,2);
00050             CreateVar(Nbvars+1,"i",&un,&ix,&l);
00051             for ( i = 0 ; i < n1 ; ++i )
00052       {
00053         *istk(l + i) = i+1 ;
00054       }
00055             if (n1 == 1)
00056       {
00057         *istk(l + 1) = 1 ;
00058       }
00059             *style = istk(l);
00060           }
00061   }
00062   else if ((kopt=FindOpt("style",opts)))
00063   { /* named argument: style=value */
00064     GetRhsVar(kopt, "i", &m, &n, &l);
00065     if (m * n < n1)
00066     {
00067       Scierror(999,"%s: style is too small (%d < %d)\r\n",fname,m*n,n1);
00068       return 0;
00069     }
00070     if (n1==1&&m*n==1)
00071     {
00072       ix = 2;
00073       CreateVar(Nbvars+1,"i",&un,&ix,&l1);
00074       *istk(l1)=*istk(l);
00075       *istk(l1+1)=1;
00076       l=l1;
00077     }
00078     *style = istk(l);
00079   }
00080   else /* unspecified argument --> default value */
00081   {
00082     ix = Max(n1,2);
00083     CreateVar(Nbvars+1,"i",&un,&ix,&l);
00084     for (i = 0 ; i < n1 ; ++i)
00085     {
00086       *istk(l + i) = i+1;
00087     }
00088     if (n1 == 1)
00089     {
00090       *istk(l +1) = 1;
00091     }
00092     *style = istk(l);
00093   }
00094   return 1;
00095 }

int get_with_mesh_arg ( char *  fname,
int  pos,
rhs_opts  opts[],
BOOL *  withMesh 
)

Definition at line 435 of file GetCommandArg.c.

References CheckLength, FALSE, FindOpt, FirstOpt, getDefWithMesh(), GetRhsVar, istk, l, m, n, setDefWithMesh(), and VarType.

00436 {
00437   int m,n,l,first_opt=FirstOpt(),kopt;
00438 
00439   if (pos < first_opt) 
00440     {
00441       if (VarType(pos)) 
00442         {
00443           GetRhsVar(pos, "b", &m, &n, &l);
00444           CheckLength(pos,m*n,1);
00445           *withMesh = *(istk(l));
00446         }
00447       else
00448         {
00450           setDefWithMesh( FALSE );
00451           *withMesh = getDefWithMesh() ;
00452         }
00453     }
00454   else if ((kopt=FindOpt("mesh",opts))) 
00455     {
00456       GetRhsVar(kopt, "b", &m, &n, &l);
00457       CheckLength(kopt,m*n,1);
00458       *withMesh = *(istk(l));
00459     }
00460   else 
00461     {
00463       setDefWithMesh( FALSE );
00464       *withMesh = getDefWithMesh() ;
00465     } 
00466   return 1;
00467 }

Here is the call graph for this function:

int get_zminmax_arg ( char *  fname,
int  pos,
rhs_opts  opts[],
double **  zminmax 
)

Definition at line 320 of file GetCommandArg.c.

References FindOpt, FirstOpt, getDefZminMax(), GetRhsVar, l, m, n, setDefZminMax(), stk, and VarType.

00321 {
00322   int m,n,l,first_opt=FirstOpt(),kopt;
00323 
00324   if (pos < first_opt) 
00325     { 
00326       if (VarType(pos)) {
00327         GetRhsVar(pos, "d", &m, &n, &l);
00328         if (m * n != 2) { 
00329           Scierror(999,"%s: zminmax has wrong size (%d), 2 expected \r\n",fname,m*n); 
00330           return 0;
00331         }
00332         *zminmax = stk(l); 
00333       }
00334       else 
00335         {
00337     double zeros[2] = { 0.0, 0.0 } ;
00338     setDefZminMax( zeros ) ;
00339           *zminmax = getDefZminMax() ;
00340         }
00341     }
00342   else if ((kopt=FindOpt("zminmax",opts))) {/* named argument: rect=value */
00343     GetRhsVar(kopt, "d", &m, &n, &l);
00344     if (m * n != 2) { 
00345       Scierror(999,"%s: zminmax has wrong size (%d), 2 expected \r\n",fname,m*n); 
00346       return 0;
00347     }
00348     *zminmax = stk(l); 
00349   }
00350   else
00351     {
00353       double zeros[2] = { 0.0, 0.0 } ;
00354       setDefZminMax( zeros ) ;
00355       *zminmax = getDefZminMax() ;
00356     }
00357     
00358   return 1;
00359 }

Here is the call graph for this function:


Variable Documentation

char logFlagsCpy[3] [static]

Definition at line 15 of file GetCommandArg.c.

Referenced by get_logflags_arg().


Generated on Sun Mar 4 15:41:58 2007 for Scilab [trunk] by  doxygen 1.5.1