// Get the requested index from the stack and verify it being a proper Device // returns -1 if it is not a valid device (either no device, or already NULL) // SOFT ERROR UpnpDevice_Handle getdevice(lua_State *L, int idx) { // TODO: implement properly, as soft error!! return checkdevice(L, idx); }
void VerifyPlotParameters( int num_param, char **param_names, int opID ) { int i, j, k; int found = FALSE, syntax = TRUE, halt_flag = FALSE, /* file_found = TRUE, */ split_str_count; int param_count; char **params; char **split_str = NULL, **split_str1 = NULL; char *sep_char = "="; char *temp_str; char orig_char = ';', rep_char = ','; FILE *fp; /* char *contour_params[] = {"ymin","ymax","count","interval","list","colour","thickness","style"}; char *shaded_params[] = {"ymin","ymax","count","interval","list","colour_min","colour_max","colortable","step_freq"}; char *grfill_params[] = {"ymin","ymax","count","interval","list","colour_min","colour_max","colortable","resolution"}; */ for ( i = 0; i < num_param; ++i ) { split_str_count = 0; found = FALSE; syntax = TRUE; split_str_count = StringSplitWithSeperator( param_names[i], sep_char, &split_str ); if( DBG ) fprintf( stderr, "Verifying params!\n"); if( split_str_count > 1 ) { if( opID == CONTOUR ) { param_count = contour_param_count; params = contour_params; } else if( opID == SHADED ) { param_count = shaded_param_count; params = shaded_params; } else if( opID == GRFILL ) { param_count = grfill_param_count; params = grfill_params; } for ( j = 0; j < param_count; ++j ) { if( !strcmp( split_str[0], params[j] ) ) { found = TRUE; if( !strcmp( split_str[0],"colour" ) || !strcmp( split_str[0],"style" ) || !strcmp( split_str[0],"colour_min" ) || !strcmp( split_str[0],"colour_max" ) || !strcmp( split_str[0],"RGB" ) || !strcmp( split_str[0],"colour_triad" )|| !strcmp( split_str[0],"device") || !strcmp( split_str[0],"file_split" ) ) { if( IsNumeric( split_str[1] ) ) syntax = FALSE; else { if( !strcmp( split_str[0],"RGB" ) || !strcmp( split_str[0],"file_split") ) { temp_str = strdup( split_str[1] ); StrToUpperCase( temp_str ); if( strcmp( temp_str,"TRUE" ) && strcmp( temp_str,"FALSE" ) ) syntax = FALSE; else { if( !strcmp( split_str[0],"RGB" ) ) { if( !strcmp( temp_str,"TRUE" ) ) isRGB = TRUE; else isRGB = FALSE; } else if( !strcmp( split_str[0],"file_split" ) ) { if( !strcmp( temp_str,"TRUE" ) ) FILE_SPLIT = TRUE; else FILE_SPLIT = FALSE; } } } else if( !strcmp( split_str[0],"style" ) ) { if( checkstyle( split_str[1] ) ) syntax = FALSE; } else if( !strcmp( split_str[0],"colour" ) || !strcmp( split_str[0],"colour_min" ) || !strcmp( split_str[0],"colour_max" ) ) { if( checkcolour( split_str[1] ) ) syntax = FALSE; else { if( !strcmp( split_str[0],"colour" ) ) { temp_str = strdup( split_str[1] ); if( !isRGB ) StrToLowerCase( temp_str ); else { StrToUpperCase( temp_str ); StrReplaceChar( temp_str, orig_char, rep_char ); /* replace ';' in RGB format to ',' */ } COLOUR = temp_str; if( DBG ) fprintf(stderr,"COLOUR %s\n",COLOUR ); } if( !strcmp( split_str[0],"colour_min" ) ) { temp_str = strdup( split_str[1] ); if( !isRGB ) StrToLowerCase( temp_str ); else { StrToUpperCase( temp_str ); StrReplaceChar( temp_str, orig_char, rep_char ); /* replace ';' in RGB format to ',' */ } COLOUR_MIN = temp_str; if( DBG ) fprintf(stderr,"COLOUR %s\n",COLOUR_MIN ); } if( !strcmp( split_str[0],"colour_max" ) ) { temp_str = strdup( split_str[1] ); if( !isRGB ) StrToLowerCase( temp_str ); else { StrToUpperCase( temp_str ); StrReplaceChar( temp_str, orig_char, rep_char ); /* replace ';' in RGB format to ',' */ } COLOUR_MAX = temp_str; if( DBG ) fprintf(stderr,"COLOUR %s\n",COLOUR_MAX ); } } } else if( !strcmp( split_str[0],"device" ) ) { if( checkdevice( split_str[1] ) ) syntax = FALSE; } else if( !strcmp( split_str[0],"colour_triad" ) ) { temp_str = strdup( split_str[1] ); StrToUpperCase( temp_str ); if( strcmp( temp_str,"CW" ) && strcmp( temp_str,"ACW" ) ) syntax = FALSE; else { if( DBG ) fprintf( stderr, "TRIAD check %s!\n",temp_str); if( !strcmp( temp_str,"CW" ) ) COLOUR_TRIAD = "clockwise"; else COLOUR_TRIAD = "anti_clockwise"; } } } } if( !strcmp( split_str[0],"min" ) || !strcmp( split_str[0],"max" ) || !strcmp( split_str[0],"count" ) || !strcmp( split_str[0],"interval" ) || !strcmp( split_str[0],"thickness" ) || !strcmp( split_str[0],"resolution" ) || !strcmp( split_str[0],"step_freq" ) ) { if( !IsNumeric( split_str[1] ) ) syntax = FALSE; else { if( !strcmp( split_str[0],"min" ) ) { YMIN = atof( split_str[1] ); } if( !strcmp( split_str[0],"max" ) ) { YMAX = atof( split_str[1] ); } if( !strcmp( split_str[0],"count" ) ) { COUNT = atoi( split_str[1] ); } if( !strcmp( split_str[0],"interval" ) ) { INTERVAL = atof( split_str[1] ); } if( !strcmp( split_str[0],"thickness" ) ) { THICKNESS = atoi( split_str[1] ); } if( !strcmp( split_str[0],"resolution" ) ) { RESOLUTION = atoi( split_str[1] ); } if( !strcmp( split_str[0],"step_freq" ) ) { STEP_FREQ = atoi( split_str[1] ); } } } if( !strcmp( split_str[0],"colourtable" ) ) { if( ( fp = fopen( split_str[1],"r") ) == NULL ) { fprintf( stderr,"Input Color Table File not found in specified path '%s'\n", split_str[1] ); halt_flag = TRUE; } else { ReadColourTable ( split_str[1] ); } } if( !strcmp( split_str[0],"list" ) ) { sep_char = ";"; split_str_count = StringSplitWithSeperator( split_str[1], sep_char, &split_str1 ); if( !split_str_count ) { syntax = FALSE; } else { for( k = 0; k < split_str_count; k++ ) { if( !IsNumeric( split_str1[k] ) ) syntax = FALSE; } if( syntax == TRUE ) { NUM_LEVELS = split_str_count; LEV_LIST = (double*) malloc( sizeof( double ) * split_str_count ); for( k = 0; k < split_str_count; k++ ) { LEV_LIST[k] = atof( split_str1[k] ); } free( split_str1 ); } } } sep_char = "="; } /*** if( !strcmp( split_str[0], params[j] ) ) ***/ } /*** Loop over param count ***/ } /*** ( split_str_count > 1 ) ***/ else { syntax = FALSE; } if( found == FALSE ) { halt_flag = TRUE; fprintf( stderr,"Invalid parameter '%s'\n", param_names[i] ); } if( found == TRUE && syntax == FALSE ) { halt_flag = TRUE; fprintf( stderr,"Invalid parameter specification '%s'\n", param_names[i] ); } if( split_str ) free( split_str ); } /*** Loop over params ****/ if( halt_flag == TRUE ) { exit(0); } }