101 #ifdef HAVE_CRT_EXTERNS_H 105 #include <crt_externs.h> 112 static int GetOptarg(
char **,
int *,
char ***,
int * );
113 static void Help(
void );
114 static void Syntax(
void );
245 "Turns on invisible options" 254 "Print out this message" 263 "Print out the PLplot library version number" 272 "Be more verbose than usual" 281 "Print debugging info (implies -verbose)" 290 "Enable driver-specific hack(s)" 317 "X server to contact" 326 "Plots per page in x" 335 "Plots per page in y" 344 "Window size/position specified as in X, e.g., 400x300, 400x300-100+200, +100-200, etc." 353 "Window size/position specified as in X, e.g., 400x300, 400x300-100+200, +100-200, etc." 362 "Relative coordinates [0-1] of window into plot" 371 "Margin space in relative coordinates (0 to 0.5, def 0)" 380 "Page aspect ratio (def: same as output device)" 389 "Page justification in x (-0.5 to 0.5, def 0)" 398 "Page justification in y (-0.5 to 0.5, def 0)" 407 "Plot orientation (0,1,2,3=landscape,portrait,seascape,upside-down)" 416 "Allow aspect ratio to adjust to orientation swaps" 425 "Sets portrait mode (both orientation and aspect ratio)" 434 "Sets pen width (0 <= width)" 443 "Background color (FF0000=opaque red, 0000FF_0.1=blue with alpha of 0.1)" 452 "Number of colors to allocate in cmap 0 (upper bound)" 461 "Number of colors to allocate in cmap 1 (upper bound)" 470 "Create a family of output files" 478 "-fsiz size[kKmMgG]",
479 "Output family file size (e.g. -fsiz 0.5G, def MB)" 488 "First family member number on output" 497 "Increment between family members" 506 "Family member number minimum field width" 515 "Don't use pixmaps in X-based drivers" 524 "Double buffer X window output" 533 "No pause between pages" 542 "bytes sent before flushing output" 551 "Main window name of PLplot server (tk driver)" 560 "Invoked name of PLplot server (tk driver)" 569 "Name of PLplot container window (tk driver)" 578 "Additional directory(s) to autoload (tk driver)" 587 "file for plserver (tk driver)" 596 "Resolution, in dots per inch (e.g. -dpi 360x360)" 605 "Sets compression level in supporting devices" 614 "Initializes color table 0 from a cmap0.pal format file in one of standard PLplot paths." 623 "Initializes color table 1 from a cmap1.pal format file in one of standard PLplot paths." 632 "Use locale environment (e.g., LC_ALL, LC_NUMERIC, or LANG) to set LC_NUMERIC locale (which affects decimal point separator)." 641 "For the case where the boundary of the filled region is self-intersecting, use the even-odd fill rule rather than the default nonzero fill rule." 649 "-drvopt option[=value][,option[=value]]*",
650 "Driver specific options" 658 "-mfo PLplot metafile name",
659 "Write the plot to the specified PLplot metafile" 667 "-mfi PLplot metafile name",
668 "Read the specified PLplot metafile" 682 "All parameters must be white-space delimited. Some options are driver",
683 "dependent. Please see the PLplot reference document for more detail.",
716 #define PL_MAX_OPT_TABLES 10 742 int mode = 0,
argc = 2, status;
745 argv[0] = (
char *) opt;
746 argv[1] = (
char *) opt_arg;
757 fprintf( stderr,
"plsetopt: Unrecognized option %s\n", opt );
787 if ( ( tab->
handler != NULL ) ||
789 ( tab->
var != NULL ) ||
790 ( tab->
mode != 0 ) ||
791 ( tab->
syntax != NULL ) ||
792 ( tab->
desc != NULL ) )
794 plabort(
"plMergeOpts: input table improperly terminated" );
802 plabort(
"plMergeOpts: max tables limit exceeded, table not merged" );
858 char **argsave, **argend;
859 int i, myargc, myargcsave, status = 0;
872 myargc = ( *p_argc );
873 argend =
argv + myargc;
897 for (; myargc > 0; --myargc, ++
argv )
900 if ( *
argv == NULL || *
argv[0] ==
'\0' )
907 for ( i =
tables - 1; i >= 0; i-- )
929 for (; myargc > 0; --myargc, ++
argv )
932 if ( *
argv == NULL || *
argv[0] ==
'\0' )
936 for ( i =
tables - 1; i >= 0; i-- )
964 fprintf( stderr,
"\nBad command line option \"%s\"\n",
argv[0] );
972 else if ( status == 1 )
978 fprintf( stderr,
"\nBad command line option \"%s\"\n",
argv[0] );
986 else if ( status == 2 )
998 for ( i = 0; i < myargc; i++ )
999 *argsave++ = *
argv++;
1001 if ( argsave < argend )
1004 #ifdef HAVE_NSGETARGC 1012 *_NSGetArgc() = *p_argc;
1036 ParseOpt(
int *p_myargc,
char ***p_argv,
int *p_argc,
char ***p_argsave,
1046 opt = ( *p_argv )[0];
1050 for ( tab = option_table; tab->
opt; tab++ )
1059 if ( *opt == *tab->
opt && !strcmp( opt, tab->
opt ) )
1066 ( *( *p_argsave )++ ) = ( **p_argv );
1073 return (
ProcessOpt( opt, tab, p_myargc, p_argv, p_argc ) );
1100 char *opt_arg = NULL;
1106 if ( tab->
mode & need_arg )
1108 if (
GetOptarg( &opt_arg, p_myargc, p_argv, p_argc ) )
1114 switch ( tab->
mode & 0xFF00 )
1123 "ProcessOpt: no handler specified for option %s\n",
1132 (
char *) malloc( (
size_t) ( 1 + strlen( opt_arg ) ) *
sizeof (
char ) );
1135 plabort(
"ProcessOpt: out of memory" );
1138 strcpy( copy, opt_arg );
1140 free( (
void *) copy );
1152 if ( tab->
var == NULL )
1155 "ProcessOpt: no variable specified for option %s\n",
1159 *(
int *) tab->
var = 1;
1166 if ( tab->
var == NULL )
1169 "ProcessOpt: no variable specified for option %s\n",
1173 *(
int *) tab->
var = atoi( opt_arg );
1180 if ( tab->
var == NULL )
1183 "ProcessOpt: no variable specified for option %s\n",
1187 *(
PLFLT *) tab->
var = atof( opt_arg );
1194 *(
char **) tab->
var = opt_arg;
1202 "ProcessOpt: invalid processing mode for option %s\n",
1225 GetOptarg(
char **popt_arg,
int *p_myargc,
char ***p_argv,
int *p_argc )
1231 if ( ( *p_myargc ) <= 0 )
1237 if ( ( *p_argv )[0][0] ==
'-' && isalpha( ( *p_argv )[0][1] ) )
1248 *popt_arg = ( *p_argv )[0];
1254 fprintf( stderr,
"Argument missing for %s option.\n", ( *p_argv )[0] );
1274 if ( program_string != NULL )
1277 if ( usage_string != NULL )
1278 usage = usage_string;
1291 if (
usage == NULL )
1292 fprintf( stderr,
"\nUsage:\n %s [options]\n",
program );
1294 fputs(
usage, stderr );
1298 fprintf( stderr,
"\n\nType %s -h for a full description.\n\n",
1317 for ( i =
tables - 1; i >= 0; i-- )
1324 fputs(
"\nUser options:", stderr );
1337 if ( tab->
syntax == NULL )
1340 len = 3 + (int) strlen( tab->
syntax );
1341 if ( col + len > 79 )
1343 fprintf( stderr,
"\n " );
1346 fprintf( stderr,
" [%s]", tab->
syntax );
1349 fprintf( stderr,
"\n" );
1366 FILE *outfile = stderr;
1370 if ( getenv(
"PAGER" ) != NULL )
1371 pager = (FILE *) popen(
"$PAGER",
"w" );
1372 if ( pager == NULL )
1373 pager = (FILE *) popen(
"more",
"w" );
1374 if ( pager != NULL )
1380 if (
usage == NULL )
1381 fprintf( outfile,
"\nUsage:\n %s [options]\n",
program );
1383 fputs(
usage, outfile );
1387 for ( i =
tables - 1; i >= 0; i-- )
1394 fputs(
"\nUser options:\n", outfile );
1406 if ( tab->
desc == NULL )
1410 fprintf( outfile,
" * %-20s %s\n", tab->
syntax, tab->
desc );
1412 fprintf( outfile,
" %-20s %s\n", tab->
syntax, tab->
desc );
1419 putc(
'\n', outfile );
1422 fputs( *note, outfile );
1423 putc(
'\n', outfile );
1429 if ( pager != NULL )
1452 memset( msg,
'\0',
sizeof ( msg ) );
1460 t = acc_opt; fl = 0;
1463 if ( strcmp( drvp->
option, t->
opt ) == 0 )
1471 fprintf( stderr,
"plParseDrvOpts: %s %s\n", t->
opt, *(
char **) t->
var_ptr );
1476 if ( sscanf( drvp->
value,
"%d", (
int *) t->
var_ptr ) != 1 )
1478 snprintf( msg,
sizeof ( msg ) - 1,
"Incorrect argument to '%s' option", drvp->
option );
1482 fprintf( stderr,
"plParseDrvOpts: %s %d\n", t->
opt, *(
int *) t->
var_ptr );
1487 if ( sscanf( drvp->
value,
"%f", (
float *) t->
var_ptr ) != 1 )
1489 snprintf( msg,
sizeof ( msg ) - 1,
"Incorrect argument to '%s' option", drvp->
option );
1493 fprintf( stderr,
"plParseDrvOpts: %s %f\n", t->
opt, *(
float *) t->
var_ptr );
1503 snprintf( msg,
sizeof ( msg ) - 1,
"Option '%s' not recognized.\n\nRecognized options for this driver are:\n", drvp->
option );
1509 while ( ( drvp = drvp->
next ) )
1532 fprintf( stderr,
"%s:\t%s\n", t->
opt, t->
hlp_msg );
1556 free( drvpl->
value );
1561 }
while ( drvp != NULL );
1615 fprintf( stderr,
"PLplot library version: %s\n",
PLPLOT_VERSION );
1848 plsc->freeaspect = 1;
1906 width = atof( opt_arg );
1909 fprintf( stderr,
"?invalid width\n" );
1915 plsc->widthlock = 1;
1942 char *color_field, *alpha_field;
1949 if ( *opt_arg ==
'#' )
1957 if ( strchr(
opttmp,
'_' ) )
1960 color_field = strtok(
opttmp,
"_" );
1961 alpha_field = strtok( NULL,
"_" );
1969 bgcolor = strtol( color_field, NULL, 16 );
1974 switch ( strlen( color_field ) )
1977 r = (
PLINT) ( ( bgcolor & 0xF00 ) >> 8 );
1978 g = (
PLINT) ( ( bgcolor & 0x0F0 ) >> 4 );
1979 b = (
PLINT) ( bgcolor & 0x00F );
1987 r = (
PLINT) ( ( bgcolor & 0xFF0000 ) >> 16 );
1988 g = (
PLINT) ( ( bgcolor & 0x00FF00 ) >> 8 );
1989 b = (
PLINT) ( bgcolor & 0x0000FF );
1993 fprintf( stderr,
"Unrecognized background color value %s\n", color_field );
1998 a = atof( alpha_field );
2024 plsc->ncol0 = atoi( opt_arg );
2045 plsc->ncol1 = atoi( opt_arg );
2067 PLFLT xl, yl, xr, yr;
2072 if ( ( field = strtok(
opttmp,
"," ) ) == NULL )
2077 if ( ( field = strtok( NULL,
"," ) ) == NULL )
2082 if ( ( field = strtok( NULL,
"," ) ) == NULL )
2087 if ( ( field = strtok( NULL,
"," ) ) == NULL )
2117 option = (
char *) malloc( (
size_t) ( 1 + strlen( opt_arg ) ) *
sizeof (
char ) );
2119 plexit(
"opt_drvopt: Out of memory!?" );
2121 value = (
char *) malloc( (
size_t) ( 1 + strlen( opt_arg ) ) *
sizeof (
char ) );
2122 if (
value == NULL )
2123 plexit(
"opt_drvopt: Out of memory!?" );
2128 while ( ( t = *opt_arg++ ) )
2145 if ( drvp->
next == NULL )
2146 plexit(
"opt_drvopt: Out of memory!?\n" );
2153 *tt =
'\0'; tt =
value;
2173 fprintf( stderr,
"\nopt_drvopt: -drvopt parsed options:\n" );
2176 fprintf( stderr,
"%s %s\n", drvp->
option, drvp->
value );
2177 while ( drvp = drvp->
next );
2178 fprintf( stderr,
"\n" );
2234 size_t len = strlen( opt_arg );
2235 char lastchar = opt_arg[len - 1];
2236 PLFLT multiplier = 1.0e6;
2237 char *spec = (
char *) malloc( len + 1 );
2240 plexit(
"opt_fsiz: Insufficient memory" );
2248 multiplier = 1.0e3; len--;
2252 multiplier = 1.0e6; len--;
2256 multiplier = 1.0e9; len--;
2259 strncpy( spec, opt_arg, len );
2262 bytemax = (
PLINT) ( multiplier * atof( spec ) );
2265 fprintf( stderr,
"?invalid file size %d. 2.14G is the maximum.\n", bytemax );
2268 plsfam( 1, -1, bytemax );
2291 plsc->member = atoi( opt_arg );
2313 plsc->finc = atoi( opt_arg );
2335 plsc->fflen = atoi( opt_arg );
2420 plsc->bufmax = atoi( opt_arg );
2441 plsc->server_name =
plstrdup( opt_arg );
2462 plsc->plserver =
plstrdup( opt_arg );
2483 if ( ( plsc->plwindow = (
char *) malloc( (
size_t) ( 1 + strlen( opt_arg ) ) *
sizeof (
char ) ) ) == NULL )
2485 plexit(
"opt_plwindow: Insufficient memory" );
2487 strcpy( plsc->plwindow, opt_arg );
2508 plsc->auto_path =
plstrdup( opt_arg );
2529 plssub( atoi( opt_arg ), -1 );
2550 plssub( -1, atoi( opt_arg ) );
2576 PLFLT xdpi = 0., ydpi = 0.;
2577 PLINT xwid, ywid, xoff, yoff;
2581 if ( ( plsc->geometry = (
char *) malloc( (
size_t) ( 1 + strlen( opt_arg ) ) *
sizeof (
char ) ) ) == NULL )
2583 plexit(
"opt_geo: Insufficient memory" );
2586 strcpy( plsc->geometry, opt_arg );
2588 numargs = sscanf( opt_arg,
"%dx%d%d%d", &xwid, &ywid, &xoff, &yoff );
2594 fprintf( stderr,
"?invalid xwid in -geometry %s\n", opt_arg );
2596 fprintf( stderr,
"?invalid ywid in -geometry %s\n", opt_arg );
2599 fprintf( stderr,
"?invalid xwid in -geometry %s\n", opt_arg );
2604 fprintf( stderr,
"?invalid ywid in -geometry %s\n", opt_arg );
2608 else if ( numargs == 4 )
2611 fprintf( stderr,
"?invalid xwid in -geometry %s\n", opt_arg );
2613 fprintf( stderr,
"?invalid ywid in -geometry %s\n", opt_arg );
2616 fprintf( stderr,
"?invalid xwid in -geometry %s\n", opt_arg );
2621 fprintf( stderr,
"?invalid ywid in -geometry %s\n", opt_arg );
2624 if ( abs( xoff ) == 0 )
2625 fprintf( stderr,
"?invalid xoff in -geometry %s\n", opt_arg );
2626 if ( abs( yoff ) == 0 )
2627 fprintf( stderr,
"?invalid yoff in -geometry %s\n", opt_arg );
2631 numargs = sscanf( opt_arg,
"%d%d", &xoff, &yoff );
2636 if ( abs( xoff ) == 0 )
2637 fprintf( stderr,
"?invalid xoff in -geometry %s\n", opt_arg );
2638 if ( abs( yoff ) == 0 )
2639 fprintf( stderr,
"?invalid yoff in -geometry %s\n", opt_arg );
2643 fprintf( stderr,
"?invalid -geometry %s\n", opt_arg );
2648 plspage( xdpi, ydpi, xwid, ywid, xoff, yoff );
2668 if ( ( plsc->tk_file = (
char *) malloc( (
size_t) ( 1 + strlen( opt_arg ) ) *
sizeof (
char ) ) ) == NULL )
2670 plexit(
"opt_tk_file: Insufficient memory" );
2673 strcpy( plsc->tk_file, opt_arg );
2699 PLFLT xdpi = 0., ydpi = 0.;
2700 PLINT xwid = 0, ywid = 0, xoff = 0, yoff = 0;
2704 if ( strchr(
opttmp,
'x' ) )
2706 field = strtok(
opttmp,
"x" );
2707 xdpi = atof( field );
2709 fprintf( stderr,
"?invalid xdpi\n" );
2711 if ( ( field = strtok( NULL,
" " ) ) == NULL )
2714 ydpi = atof( field );
2716 fprintf( stderr,
"?invalid ydpi\n" );
2726 plspage( xdpi, ydpi, xwid, ywid, xoff, yoff );
2748 comp = atoi( opt_arg );
2751 fprintf( stderr,
"?invalid compression\n" );
2816 if ( ( locale = setlocale( LC_NUMERIC,
"" ) ) )
2818 printf(
"LC_NUMERIC locale set to \"%s\"\n", locale );
2822 plwarn(
"Could not use invalid environment (e.g., LC_ALL, LC_NUMERIC, or LANG) to set LC_NUMERIC locale. Falling back to LC_NUMERIC \"C\" locale instead.\n" );
2823 if ( !( locale = setlocale( LC_NUMERIC,
"C" ) ) )
2825 plexit(
"Your platform is seriously broken. Not even a \"C\" locale could be set." );
2849 plsc->dev_eofill = 1;
2850 if ( plsc->level > 0 )
2871 if ( ( plsc->mf_outfile = (
char *) malloc( (
size_t) ( 1 + strlen( opt_arg ) ) *
sizeof (
char ) ) ) == NULL )
2873 plexit(
"opt_mfo: Insufficient memory" );
2876 strcpy( plsc->mf_outfile, opt_arg );
2896 if ( ( plsc->mf_infile = (
char *) malloc( (
size_t) ( 1 + strlen( opt_arg ) ) *
sizeof (
char ) ) ) == NULL )
2898 plexit(
"opt_mfi: Insufficient memory" );
2901 strcpy( plsc->mf_infile, opt_arg );
#define PL_MAX_OPT_TABLES
int plParseDrvOpts(DrvOpt *acc_opt)
PLINT plMergeOpts(PLOptionTable *options, PLCHAR_VECTOR name, PLCHAR_VECTOR *notes)
static int opt_portrait(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
#define PL_PARSE_NOPROGRAM
void plexit(PLCHAR_VECTOR errormsg)
static int opt_v(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
int(* handler)(PLCHAR_VECTOR, PLCHAR_VECTOR, PLPointer)
static int opt_auto_path(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static PLCHAR_VECTOR usage
static int opt_locale(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_nopixmap(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_fflen(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
const char * PLCHAR_VECTOR
static int opt_width(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
#define PL_PARSE_NODELETE
static int opt_dev(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_db(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
void plabort(PLCHAR_VECTOR errormsg)
static int ParseOpt(int *, char ***, int *, char ***, PLOptionTable *)
static int opt_py(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_fsiz(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_verbose(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_dpi(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_dev_compression(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
PLINT c_plparseopts(int *p_argc, char **argv, PLINT mode)
static int opt_wplt(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_jy(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
void plSetUsage(PLCHAR_VECTOR program_string, PLCHAR_VECTOR usage_string)
static int opt_geo(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_eofill(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int GetOptarg(char **, int *, char ***, int *)
static int opt_o(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_ncol1(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
struct DrvOptCmd DrvOptCmd
static int opt_cmap1(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_server_name(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_h(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
PLOptionInfo ploption_info_default
static int opt_jx(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
PLINT c_plsetopt(PLCHAR_VECTOR opt, PLCHAR_VECTOR opt_arg)
static int opt_a(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_px(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static PLCHAR_VECTOR program
static char opttmp[OPTMAX]
void plHelpDrvOpts(DrvOpt *acc_opt)
static PLCHAR_VECTOR plplot_notes[]
static int opt_mfi(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_bufmax(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_plwindow(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static PLFLT value(double n1, double n2, double hue)
static PLOptionTable options[]
char PLDLLIMPEXP * plstrdup(PLCHAR_VECTOR src)
static int opt_cmap0(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_mar(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int mode_noprogram
static int ProcessOpt(char *, PLOptionTable *, int *, char ***, int *)
static int opt_ori(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
void plwarn(PLCHAR_VECTOR errormsg)
static int opt_finc(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_drvopt(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_np(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_bg(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
PLOptionInfo ploption_info[PL_MAX_OPT_TABLES]
static int opt_freeaspect(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_hack(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_fbeg(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_plserver(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_debug(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_ncol0(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_mfo(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static PLOptionTable ploption_table[]
static int opt_tk_file(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)
static int opt_fam(PLCHAR_VECTOR, PLCHAR_VECTOR, void *)