Back to index

plt-scheme  4.2.1
Classes | Defines | Typedefs | Functions | Variables
plargs.c File Reference
#include "plplotP.h"
#include <ctype.h>

Go to the source code of this file.

Classes

struct  PLOptionInfo
struct  DrvOptCmd

Defines

#define OPTMAX   1024
#define PL_MAX_OPT_TABLES   10

Typedefs

typedef struct DrvOptCmd DrvOptCmd

Functions

static int ParseOpt (int *, char ***, int *, char ***, PLOptionTable *)
static int ProcessOpt (char *, PLOptionTable *, int *, char ***, int *)
static int GetOptarg (char **, int *, char ***, int *)
static void Help (void)
static void Syntax (void)
static int opt_h (char *, char *, void *)
static int opt_v (char *, char *, void *)
static int opt_verbose (char *, char *, void *)
static int opt_debug (char *, char *, void *)
static int opt_hack (char *, char *, void *)
static int opt_dev (char *, char *, void *)
static int opt_o (char *, char *, void *)
static int opt_geo (char *, char *, void *)
static int opt_a (char *, char *, void *)
static int opt_jx (char *, char *, void *)
static int opt_jy (char *, char *, void *)
static int opt_mar (char *, char *, void *)
static int opt_ori (char *, char *, void *)
static int opt_freeaspect (char *, char *, void *)
static int opt_portrait (char *, char *, void *)
static int opt_width (char *, char *, void *)
static int opt_bg (char *, char *, void *)
static int opt_ncol0 (char *, char *, void *)
static int opt_ncol1 (char *, char *, void *)
static int opt_fam (char *, char *, void *)
static int opt_fsiz (char *, char *, void *)
static int opt_fbeg (char *, char *, void *)
static int opt_finc (char *, char *, void *)
static int opt_fflen (char *, char *, void *)
static int opt_bufmax (char *, char *, void *)
static int opt_nopixmap (char *, char *, void *)
static int opt_db (char *, char *, void *)
static int opt_np (char *, char *, void *)
static int opt_px (char *, char *, void *)
static int opt_py (char *, char *, void *)
static int opt_wplt (char *, char *, void *)
static int opt_drvopt (char *, char *, void *)
static int opt_plserver (char *, char *, void *)
static int opt_plwindow (char *, char *, void *)
static int opt_tcl_cmd (char *, char *, void *)
static int opt_auto_path (char *, char *, void *)
static int opt_server_name (char *, char *, void *)
static int opt_server_host (char *, char *, void *)
static int opt_server_port (char *, char *, void *)
static int opt_user (char *, char *, void *)
static int opt_tk_file (char *, char *, void *)
static int opt_dpi (char *, char *, void *)
static int opt_dev_compression (char *, char *, void *)
int c_plsetopt (char *opt, char *optarg)
int plSetOpt (char *opt, char *optarg)
int plMergeOpts (PLOptionTable *options, char *name, char **notes)
void plClearOpts (void)
void plResetOpts (void)
int plParseOpts (int *p_argc, char **argv, PLINT mode)
void plSetUsage (char *program_string, char *usage_string)
void plOptUsage (void)
int plParseDrvOpts (DrvOpt *acc_opt)
void plHelpDrvOpts (DrvOpt *acc_opt)

Variables

static char * program = NULL
static char * usage = NULL
static int mode_full
static int mode_quiet
static int mode_nodelete
static int mode_showall
static int mode_noprogram
static int mode_nodash
static int mode_skip
static char opttmp [OPTMAX]
static PLOptionTable ploption_table []
static char * plplot_notes []
PLOptionInfo ploption_info_default
PLOptionInfo ploption_info [PL_MAX_OPT_TABLES]
static DrvOptCmd drv_opt
static int tables = 1

Class Documentation

struct PLOptionInfo

Definition at line 619 of file plargs.c.

Collaboration diagram for PLOptionInfo:
Class Members
char * name
char ** notes
PLOptionTable * options
struct DrvOptCmd

Definition at line 642 of file plargs.c.

Collaboration diagram for DrvOptCmd:
Class Members
struct DrvOptCmd * next
char * option
char * value

Define Documentation

#define OPTMAX   1024

Definition at line 167 of file plargs.c.

#define PL_MAX_OPT_TABLES   10

Definition at line 631 of file plargs.c.


Typedef Documentation


Function Documentation

int c_plsetopt ( char *  opt,
char *  optarg 
)

Definition at line 661 of file plargs.c.

{
    return(plSetOpt(opt, optarg));
}

Here is the call graph for this function:

static int GetOptarg ( char **  poptarg,
int p_myargc,
char ***  p_argv,
int p_argc 
) [static]

Definition at line 1048 of file plargs.c.

{
    int result = 0;

    --(*p_myargc);

    if ((*p_myargc) <= 0)          /* oops, no more arguments */
       result = 1;

    if ( ! result) {
       (*p_argv)++;
       if ((*p_argv)[0][0] == '-' && isalpha((*p_argv)[0][1])) {

           (*p_argv)--;            /* oops, next arg is a flag */
           result = 1;
       }
    }

    if ( ! result) {               /* yeah, the user got it right */
       (*p_argc)--;
       *poptarg = (*p_argv)[0];
    }
    else {
       if ( ! mode_quiet) {
           fprintf(stderr, "Argument missing for %s option.\n", (*p_argv)[0]);
           plOptUsage();
       }
    }
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void Help ( void  ) [static]

Definition at line 1170 of file plargs.c.

{
    PLOptionTable *tab;
    char **note;
    int i;
    FILE *outfile = stderr;

#ifdef HAVE_POPEN
    FILE *pager = NULL;
    if (getenv("PAGER") != NULL)
       pager = (FILE *) popen("$PAGER", "w");
    if (pager == NULL)
       pager = (FILE *) popen("more", "w");
    if (pager != NULL)
       outfile = pager;
#endif

/* Usage line */

    if (usage == NULL)
       fprintf(outfile, "\nUsage:\n        %s [options]\n", program);
    else
       fputs(usage, outfile);

/* Loop over all options tables */

    for (i = tables-1; i >= 0; i--) {

    /* Introducer */

       if (ploption_info[i].name)
           fprintf(outfile, "\n%s:\n", ploption_info[i].name);
       else
           fputs("\nUser options:\n", outfile);

    /* Print description for each option */

       for (tab = ploption_info[i].options; tab->opt; tab++) {
           if (tab->mode & PL_OPT_DISABLED)
              continue;

           if ( ! mode_showall && (tab->mode & PL_OPT_INVISIBLE))
              continue;

           if (tab->desc == NULL)
              continue;

           if (tab->mode & PL_OPT_INVISIBLE) 
              fprintf(outfile, " *  %-20s %s\n", tab->syntax, tab->desc);
           else 
              fprintf(outfile, "    %-20s %s\n", tab->syntax, tab->desc);
       }

    /* Usage notes */

       if (ploption_info[i].notes) {
           putc('\n', outfile);
           for (note = ploption_info[i].notes; *note; note++) {
              fputs(*note, outfile);
              putc('\n', outfile);
           }
       }
    }

#ifdef HAVE_POPEN
    if (pager != NULL)
       pclose(pager);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int opt_a ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1454 of file plargs.c.

{
    plsdidev(PL_NOTSET, atof(optarg), PL_NOTSET, PL_NOTSET);
    return 0;
}
static int opt_auto_path ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 2044 of file plargs.c.

{
    plsc->auto_path = optarg;
    return 0;
}
static int opt_bg ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1576 of file plargs.c.

{
    char *rgb;
    long bgcolor, r, g, b;

/* Always in hex!  Strip off leading "#" (TK-ism) if present. */

    if (*optarg == '#')
       rgb = optarg + 1;
    else
       rgb = optarg;

/* Get number in hex */

    bgcolor = strtol(rgb, NULL, 16);

/* Must be either a 3 or 6 digit hex number */
/* If 3 digits, each is "doubled" (i.e. ABC becomes AABBCC). */

    switch (strlen(rgb)) {
    case 3:
       r = (bgcolor & 0xF00) >> 8;
       g = (bgcolor & 0x0F0) >> 4;
       b = (bgcolor & 0x00F);

       r = r | (r << 4);
       g = g | (g << 4);    /* doubling */
       b = b | (b << 4);
       break;

    case 6:
       r = (bgcolor & 0xFF0000) >> 16;
       g = (bgcolor & 0x00FF00) >> 8;
       b = (bgcolor & 0x0000FF);
       break;

    default:
       fprintf(stderr, "Unrecognized background color value %s\n", rgb);
       return 1;
    }

    plscolbg(r, g, b);

    return 0;
}

Here is the call graph for this function:

static int opt_bufmax ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1931 of file plargs.c.

{
    plsc->bufmax = atoi(optarg);
    return 0;
}
static int opt_db ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1917 of file plargs.c.

{
    plsc->db = 1;
    return 0;
}
static int opt_debug ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1383 of file plargs.c.

{
    plsc->debug = 1;
    plsc->verbose = 1;
    return 0;
}
static int opt_dev ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1412 of file plargs.c.

{
    plsdev(optarg);
    return 0;
}
static int opt_dev_compression ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 2201 of file plargs.c.

{
    PLINT comp = 0;
   
    comp = atoi(optarg);
    if (comp == 0) {
       fprintf(stderr, "?invalid compression\n");
       return 1;
    }
    plscompression (comp);

    return 0;
}
static int opt_dpi ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 2164 of file plargs.c.

{
    char *field;
    PLFLT xdpi = 0., ydpi = 0.;
    PLINT xwid = 0, ywid = 0, xoff = 0, yoff = 0;
    
    strncpy(opttmp, optarg, OPTMAX-1);
    if (strchr (opttmp, 'x')) {
       field = strtok (opttmp, "x");
       xdpi = atof (field);
       if (xdpi == 0)
           fprintf (stderr, "?invalid xdpi\n");

       if ((field = strtok (NULL, " ")) == NULL)
          return 1;
          
        ydpi = atof (field);
        if (ydpi == 0)
          fprintf (stderr, "?invalid ydpi\n");

    } else {
       xdpi = atof (opttmp);
       ydpi=xdpi;
       if (xdpi==0) return 1;
    }

    plspage (xdpi, ydpi, xwid, ywid, xoff, yoff);
    return 0;
}

Here is the call graph for this function:

static int opt_drvopt ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1697 of file plargs.c.

{
  char t, *tt, *option, *value;
  int fl = 0;
  DrvOptCmd *drvp;

  option = (char *) malloc((size_t)(1+strlen(optarg))*sizeof(char));
  if (option == NULL)
    plexit("opt_drvopt: Out of memory!?");

  value = (char *) malloc((size_t)(1+1)*sizeof(char));
  if (value == NULL)
    plexit("opt_drvopt: Out of memory!?");

  drvp = &drv_opt;
  *option = *value = '\0';
  tt = option;
    while((t = *optarg++)) {
      switch (t) {
      case ',':
       if (fl)
         fl = 0;
       else {
         value[0] = '1';
         value[1] = '\0';
       }
       
       *tt = '\0'; tt = option;
       drvp->option = plstrdup(option); /* it should not be release, because of familying */
       drvp->value = plstrdup(value); /* don't release */
       drvp->next = (DrvOptCmd *) malloc(sizeof(DrvOptCmd)); /* don't release */
       if (drvp->next == NULL)
         plexit("opt_drvopt: Out of memory!?\n");

       drvp = drvp->next;
       break;

      case '=':
       fl = 1;
       *tt = '\0'; tt = value;
       break;

      default:
       *tt++ = t;
      }
    }

    *tt = '\0';
    if (!fl) {
      value[0] = '1';
      value[1] = '\0';
    }

    drvp->option = plstrdup(option); /* don't release */
    drvp->value = plstrdup(value); /* don't release */
    drvp->next = NULL;

#ifdef DEBUG
    fprintf(stderr, "\nopt_drvopt: -drvopt parsed options:\n");
    drvp = &drv_opt;
    do 
      fprintf(stderr, "%s %s\n", drvp->option, drvp->value);
    while(drvp = drvp->next);
    fprintf(stderr, "\n");
#endif

    free(option); free(value);

    return 0;
}

Here is the call graph for this function:

static int opt_fam ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1776 of file plargs.c.

{
    plsfam(1, -1, -1);
    return 0;
}
static int opt_fbeg ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1844 of file plargs.c.

{
    plsc->member = atoi(optarg);

    return 0;
}
static int opt_fflen ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1874 of file plargs.c.

{
    plsc->fflen = atoi(optarg);

    return 0;
}
static int opt_finc ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1859 of file plargs.c.

{
    plsc->finc = atoi(optarg);

    return 0;
}
static int opt_freeaspect ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1510 of file plargs.c.

{
    plsc->freeaspect = 1;
    return 0;
}
static int opt_fsiz ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1799 of file plargs.c.

{
    PLINT bytemax;
    int len = strlen(optarg);
    char lastchar = optarg[len-1];
    PLFLT multiplier = 1.0e6;
    char *spec = (char*)malloc(len+1);

/* Interpret optional suffix */

    switch (lastchar) {
    case 'k':
    case 'K':
       multiplier = 1.0e3; len--;
       break;
    case 'm':
    case 'M':
       multiplier = 1.0e6; len--;
       break;
    case 'g':
    case 'G':
       multiplier = 1.0e9; len--;
       break;
    }
    strncpy(spec, optarg, len);
    spec[len] = '\0';

    bytemax = multiplier * atof(spec);
    if (bytemax == 0) {
       fprintf(stderr, "?invalid bytemax\n");
       return 1;
    }
    plsfam(1, -1, bytemax);

    return 0;
}

Here is the call graph for this function:

static int opt_geo ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 2089 of file plargs.c.

{
    char *field;
    PLFLT xdpi = 0., ydpi = 0.;
    PLINT xwid = 0, ywid = 0, xoff = 0, yoff = 0;
    
/* The TK driver uses the geometry string directly */    

    plsc->geometry = (char *) malloc((size_t)(1+strlen(optarg))*sizeof(char));
    strcpy (plsc->geometry, optarg);

/* Set up plplot dimensions */

    strncpy(opttmp, optarg, OPTMAX-1);
    if (strchr (opttmp, 'x')) {

    /* -geometry WxH or -geometry WxH+Xoff+Yoff */

       field = strtok (opttmp, "x");
       xwid = atoi (field);
       if (xwid == 0)
           fprintf (stderr, "?invalid xwid\n");

       if ((field = strtok (NULL, "+")) == NULL)
           return 1;

       ywid = atoi (field);
       if (ywid == 0)
           fprintf (stderr, "?invalid ywid\n");

       field = strtok (NULL, "+");
    }
    else {

    /* -geometry +Xoff or -geometry +Xoff+Yoff only */

       field = strtok (opttmp, "+");
    }

    if (field != NULL) {
       xoff = atoi (field);
       if ((field = strtok (NULL, "+")) != NULL)
           yoff = atoi (field);
    }

    plspage (xdpi, ydpi, xwid, ywid, xoff, yoff);
    return 0;
}

Here is the call graph for this function:

static int opt_h ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1337 of file plargs.c.

{
    if ( ! mode_quiet)
       Help();

    return 2;
}

Here is the call graph for this function:

static int opt_hack ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1398 of file plargs.c.

{
    plsc->hack = 1;
    return 0;
}
static int opt_jx ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1468 of file plargs.c.

{
    plsdidev(PL_NOTSET, PL_NOTSET, atof(optarg), PL_NOTSET);
    return 0;
}
static int opt_jy ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1482 of file plargs.c.

{
    plsdidev(PL_NOTSET, PL_NOTSET, PL_NOTSET, atof(optarg));
    return 0;
}
static int opt_mar ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1440 of file plargs.c.

{
    plsdidev(atof(optarg), PL_NOTSET, PL_NOTSET, PL_NOTSET);
    return 0;
}
static int opt_ncol0 ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1630 of file plargs.c.

{
    plsc->ncol0 = atoi(optarg);
    return 0;
}
static int opt_ncol1 ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1644 of file plargs.c.

{
    plsc->ncol1 = atoi(optarg);
    return 0;
}
static int opt_nopixmap ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1903 of file plargs.c.

{
    plsc->nopixmap = 1;
    return 0;
}
static int opt_np ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1889 of file plargs.c.

{
    plspause(0);
    return 0;
}
static int opt_o ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1426 of file plargs.c.

{
    plsfnam(optarg);
    return 0;
}
static int opt_ori ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1496 of file plargs.c.

{
    plsdiori(atof(optarg));
    return 0;
}
static int opt_plserver ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 2001 of file plargs.c.

{
    plsc->plserver = optarg;
    return 0;
}
static int opt_plwindow ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 2015 of file plargs.c.

{
    plsc->plwindow = (char *) malloc((size_t)(1+strlen(optarg))*sizeof(char));
    strcpy (plsc->plwindow, optarg);
    return 0;
}
static int opt_portrait ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1538 of file plargs.c.

{
    plsc->portrait = 1;
    return 0;
}
static int opt_px ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 2058 of file plargs.c.

{
    plssub(atoi(optarg), -1);
    return 0;
}
static int opt_py ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 2072 of file plargs.c.

{
    plssub(-1, atoi(optarg));
    return 0;
}
static int opt_server_host ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1959 of file plargs.c.

{
    plsc->server_host = optarg;
    return 0;
}
static int opt_server_name ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1945 of file plargs.c.

{
    plsc->server_name = optarg;
    return 0;
}
static int opt_server_port ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1973 of file plargs.c.

{
    plsc->server_port = optarg;
    return 0;
}
static int opt_tcl_cmd ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 2030 of file plargs.c.

{
    plsc->tcl_cmd = optarg;
    return 0;
}
static int opt_tk_file ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 2145 of file plargs.c.

{
    plsc->tk_file = (char *) malloc((size_t)(1+strlen(optarg))*sizeof(char));
    strcpy (plsc->tk_file, optarg);
    return 0;
}
static int opt_user ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1987 of file plargs.c.

{
    plsc->user = optarg;
    return 0;
}
static int opt_v ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1353 of file plargs.c.

{
    if ( ! mode_quiet) 
       fprintf(stderr, "PLplot library version: %s\n", VERSION);

    return 2;
}
static int opt_verbose ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1369 of file plargs.c.

{
    plsc->verbose = 1;
    return 0;
}
static int opt_width ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1552 of file plargs.c.

{
    int width;

    width = atoi(optarg);
    if (width < 0) {
       fprintf(stderr, "?invalid width\n");
       return 1;
    }
    else {
       plwid(width);
       plsc->widthlock = 1;
    }
    return 0;
}
static int opt_wplt ( char *  opt,
char *  optarg,
void client_data 
) [static]

Definition at line 1658 of file plargs.c.

{
    char *field;
    PLFLT xl, yl, xr, yr;

    strncpy(opttmp, optarg, OPTMAX-1);

    if ((field = strtok(opttmp, ",")) == NULL)
       return 1;

    xl = atof(field);

    if ((field = strtok(NULL, ",")) == NULL)
       return 1;

    yl = atof(field);

    if ((field = strtok(NULL, ",")) == NULL)
       return 1;

    xr = atof(field);

    if ((field = strtok(NULL, ",")) == NULL)
       return 1;

    yr = atof(field);

    plsdiplt(xl, yl, xr, yr);
    return 0;
}

Here is the call graph for this function:

static int ParseOpt ( int p_myargc,
char ***  p_argv,
int p_argc,
char ***  p_argsave,
PLOptionTable option_table 
) [static]

Definition at line 883 of file plargs.c.

{
    PLOptionTable *tab;
    char *opt;

/* Only handle actual flags and their arguments */

    if ( mode_nodash || (*p_argv)[0][0] == '-') {

       opt = (*p_argv)[0];
       if (*opt == '-') 
           opt++;

       for (tab = option_table; tab->opt; tab++) {

       /* Skip if option not enabled */

           if (tab->mode & PL_OPT_DISABLED) 
              continue;

       /* Try to match it */

           if (*opt == *tab->opt && ! strcmp(opt, tab->opt)) {

           /* Option matched, so remove from argv list if applicable. */

              if ( ! mode_nodelete) {
                  if (tab->mode & PL_OPT_NODELETE)
                     (*(*p_argsave)++) = (**p_argv);
                  else
                     --(*p_argc);
              }

           /* Process option (and argument if applicable) */

              return (ProcessOpt(opt, tab, p_myargc, p_argv, p_argc));
           }
       }
    }

    return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 740 of file plargs.c.

{
    tables = 0;
}
void plHelpDrvOpts ( DrvOpt acc_opt)

Definition at line 1315 of file plargs.c.

                               {
  DrvOpt *t;

  t = acc_opt;
  while(t->opt) {
    fprintf(stderr, "%s:\t%s\n", t->opt, t->hlp_msg);
    t++;
  }
}

Here is the caller graph for this function:

int plMergeOpts ( PLOptionTable options,
char *  name,
char **  notes 
)

Definition at line 695 of file plargs.c.

{
    PLOptionTable *tab;

    pllib_init();

/* Check to make sure option table has been terminated correctly */

    for (tab = options; tab->opt; tab++)
       ;

/* We've reached the last table entry.  All the subentries must be NULL or 0 */

    if ((tab->handler     != NULL) ||
       (tab->client_data != NULL) ||
       (tab->var         != NULL) ||
       (tab->mode        != 0) ||
       (tab->syntax      != NULL) ||
       (tab->desc        != NULL)) {

       plabort("plMergeOpts: input table improperly terminated");
       return 1;
    }

/* No room for more tables */

    if (tables++ >= PL_MAX_OPT_TABLES) {
       plabort("plMergeOpts: max tables limit exceeded, table not merged");
       return 1;
    }

    ploption_info[tables-1].options = options;
    ploption_info[tables-1].name    = name;
    ploption_info[tables-1].notes   = notes;

    return 0;
}

Here is the call graph for this function:

Definition at line 1102 of file plargs.c.

{
    if (usage == NULL)
       fprintf(stderr, "\nUsage:\n        %s [options]\n", program);
    else
       fputs(usage, stderr);

    Syntax();

    fprintf(stderr, "\n\nType %s -h for a full description.\n\n",
           program);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int plParseDrvOpts ( DrvOpt acc_opt)

Definition at line 1247 of file plargs.c.

                                {
  DrvOptCmd *drvp;
  DrvOpt *t;
  int fl;
  char msg[80];

  if (!drv_opt.option)
    return 1;

  drvp = &drv_opt;
  do {
    t = acc_opt; fl = 0;
    while (t->opt) {
      if (strcmp(drvp->option, t->opt) == 0) {
       fl = 1;
       switch (t->type) {

       case DRV_STR:
         *(char **)(t->var_ptr) = (drvp->value);
#ifdef DEBUG
         fprintf(stderr,"plParseDrvOpts: %s %s\n", t->opt, *(char**)t->var_ptr);
#endif
         break;

       case DRV_INT:
         if (sscanf(drvp->value, "%d", (int *)t->var_ptr) != 1) {
           sprintf(msg,"Incorrect argument to '%s' option", drvp->option);
           plexit(msg);
         }
#ifdef DEBUG
         fprintf(stderr,"plParseDrvOpts: %s %d\n", t->opt, *(int *) t->var_ptr);
#endif  
         break;

       case DRV_FLT:
         if (sscanf(drvp->value, "%f", (float *)t->var_ptr) != 1) {
           sprintf(msg,"Incorrect argument to '%s' option", drvp->option);
           plexit(msg);
         }
#ifdef DEBUG
         fprintf(stderr,"plParseDrvOpts: %s %f\n", t->opt, *(float *) t->var_ptr);
#endif  
         break;
       }
      }
    t++;
    }

    if (!fl) {
      sprintf(msg, "Option '%s' not recognized.\n\nRecognized options for this driver are:\n", drvp->option);
      plwarn(msg);
      plHelpDrvOpts(acc_opt);      
      plexit(""); 
    }
  }
  while((drvp = drvp->next))
      ;

  return 0;
}

Here is the call graph for this function:

int plParseOpts ( int p_argc,
char **  argv,
PLINT  mode 
)

Definition at line 767 of file plargs.c.

{
    char **argsave, **argend;
    int       i, myargc, status = 0;

    pllib_init();

/* Initialize */

    mode_full      = mode & PL_PARSE_FULL;
    mode_quiet     = mode & PL_PARSE_QUIET;
    mode_nodelete  = mode & PL_PARSE_NODELETE;
    mode_showall   = mode & PL_PARSE_SHOWALL;
    mode_noprogram = mode & PL_PARSE_NOPROGRAM;
    mode_nodash    = mode & PL_PARSE_NODASH;
    mode_skip      = mode & PL_PARSE_SKIP;

    /* Initialize the driver specific option linked structure */
    drv_opt.option  = drv_opt.value  = NULL;
    drv_opt.next  = NULL;

    myargc = (*p_argc); 
    argend = argv + myargc;

/* If program name is first argument, save and advance */

    if ( ! mode_noprogram) {
       plsc->program = program = argv[0];
       --myargc; ++argv;
    }
    if (myargc == 0)
       return 0;

/* Process the command line */

    argsave = argv;
    for (; myargc > 0; --myargc, ++argv) {

    /* Allow for "holes" in argv list */

       if (*argv == NULL || *argv[0] == '\0')
           continue;

    /* Loop over all options tables, starting with the last */

       for (i = tables-1; i >= 0; i--) {

       /* Check option table for option */

           status = ParseOpt(&myargc, &argv, p_argc, &argsave,
                           ploption_info[i].options);

           if ( ! status) break;
       }

    /* Handle error return as specified by the mode flag */

       if (status == -1) {

       /* No match.  Keep going if mode_skip is set, otherwise abort if
          fully parsing, else return without error. */

           if (mode_skip) {
              if ( ! mode_nodelete) 
                  *argsave++ = *argv;
              continue;
           }
           if ( ! mode_quiet && mode_full) {
              fprintf(stderr, "\nBad command line option \"%s\"\n", argv[0]);
              plOptUsage();
           }
           if (mode_full) exit(1);

           status = 0;
           break;

       } else if (status == 1) {

       /* Illegal or badly formed */

           if ( ! mode_quiet) {
              fprintf(stderr, "\nBad command line option \"%s\"\n", argv[0]);
              plOptUsage();
           }
           if (mode_full) exit(1);

           break;

       } else if (status == 2) {

       /* Informational option encountered (-h or -v) */

           exit(0);
       }
    }

/* Compress and NULL-terminate argv */

    if ( ! mode_nodelete) {
       for (i = 0; i < myargc; i++)
           *argsave++ = *argv++;

       if (argsave < argend)
           *argsave = NULL;
    }

    return status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 752 of file plargs.c.

int plSetOpt ( char *  opt,
char *  optarg 
)

Definition at line 667 of file plargs.c.

{
    int mode = 0, argc = 2, status;
    char *argv[3];

    argv[0] = opt;
    argv[1] = optarg;
    argv[2] = NULL;
    mode =
       PL_PARSE_QUIET |
       PL_PARSE_NODELETE |
       PL_PARSE_NOPROGRAM |
       PL_PARSE_NODASH;

    status = plParseOpts(&argc, argv, mode);
    if (status) {
       fprintf( stderr, "plSetOpt: Unrecognized option %s\n", opt);
    }
    return status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void plSetUsage ( char *  program_string,
char *  usage_string 
)

Definition at line 1086 of file plargs.c.

{
    if (program_string != NULL)
       program = program_string;

    if (usage_string != NULL)
       usage = usage_string;
}
static int ProcessOpt ( char *  opt,
PLOptionTable tab,
int p_myargc,
char ***  p_argv,
int p_argc 
) [static]

Definition at line 934 of file plargs.c.

{
    int need_arg, res;
    char *optarg = NULL;

/* Get option argument if necessary */

    need_arg = PL_OPT_ARG | PL_OPT_INT | PL_OPT_FLOAT | PL_OPT_STRING;

    if (tab->mode & need_arg) {
       if (GetOptarg(&optarg, p_myargc, p_argv, p_argc))
           return 1;
    }

/* Process argument */

    switch (tab->mode & 0xFF00) {

    case PL_OPT_FUNC:

    /* Call function handler to do the job */

       if (tab->handler == NULL) {
           fprintf(stderr,
                  "ProcessOpt: no handler specified for option %s\n",
                  tab->opt);
           return 1;
       }

        if (mode_nodelete && optarg) {

       /* Make a copy, since handler may mung optarg with strtok() */
           char *copy = 
             (char *) malloc((size_t)(1+strlen(optarg))*sizeof(char));
           if (copy == NULL) {
               plabort("ProcessOpt: out of memory");
              return 1;
           }
           strcpy(copy, optarg);
           res = ((*tab->handler) (opt, copy, tab->client_data));
           free((void *) copy);
           return res;
       }
       else {
         return ((*tab->handler) (opt, optarg, tab->client_data));
       }

    case PL_OPT_BOOL:

    /* Set *var as a boolean */

       if (tab->var == NULL) {
           fprintf(stderr,
                  "ProcessOpt: no variable specified for option %s\n",
                  tab->opt);
           return 1;
       }
       *(int *)tab->var = 1;
       break;

    case PL_OPT_INT:

    /* Set *var as an int */

       if (tab->var == NULL) {
           fprintf(stderr,
                  "ProcessOpt: no variable specified for option %s\n",
                  tab->opt);
           return 1;
       }
       *(int *)tab->var = atoi(optarg);
       break;

    case PL_OPT_FLOAT:

    /* Set *var as a float */

       if (tab->var == NULL) {
           fprintf(stderr,
                  "ProcessOpt: no variable specified for option %s\n",
                  tab->opt);
           return 1;
       }
       *(PLFLT *)tab->var = atof(optarg);
       break;

    case PL_OPT_STRING:

    /* Set var (can be NULL initially) to point to optarg string */

       *(char **)tab->var = (char *)optarg;
       break;

    default:

    /* Somebody messed up.. */

       fprintf(stderr,
              "ProcessOpt: invalid processing mode for option %s\n",
              tab->opt);
       return 1;
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void Syntax ( void  ) [static]

Definition at line 1122 of file plargs.c.

{
    PLOptionTable *tab;
    int i, col, len;

/* Loop over all options tables */

    for (i = tables-1; i >= 0; i--) {

    /* Introducer */

       if (ploption_info[i].name)
           fprintf(stderr, "\n%s:", ploption_info[i].name);
       else
           fputs("\nUser options:", stderr);

    /* Print syntax for each option */

       col = 80;
       for (tab = ploption_info[i].options; tab->opt; tab++) {
           if (tab->mode & PL_OPT_DISABLED)
              continue;

           if ( ! mode_showall && (tab->mode & PL_OPT_INVISIBLE))
              continue;

           if (tab->syntax == NULL)
              continue;

           len = 3 + strlen(tab->syntax);        /* space [ string ] */
           if (col + len > 79) {
              fprintf(stderr, "\n   ");          /* 3 spaces */
              col = 3;
           }
           fprintf(stderr, " [%s]", tab->syntax);
           col += len;
       }
       fprintf(stderr, "\n");
    }
}

Here is the caller graph for this function:


Variable Documentation

DrvOptCmd drv_opt [static]

Definition at line 649 of file plargs.c.

int mode_full [static]

Definition at line 157 of file plargs.c.

int mode_nodash [static]

Definition at line 162 of file plargs.c.

int mode_nodelete [static]

Definition at line 159 of file plargs.c.

int mode_noprogram [static]

Definition at line 161 of file plargs.c.

int mode_quiet [static]

Definition at line 158 of file plargs.c.

int mode_showall [static]

Definition at line 160 of file plargs.c.

int mode_skip [static]

Definition at line 163 of file plargs.c.

char opttmp[OPTMAX] [static]

Definition at line 168 of file plargs.c.

Initial value:
 { 
    {
       ploption_table,
       "PLplot options",
       plplot_notes
    }
}

Definition at line 632 of file plargs.c.

Initial value:
 {
    ploption_table,
    "PLplot options",
    plplot_notes
}

Definition at line 625 of file plargs.c.

Definition at line 221 of file plargs.c.

char* plplot_notes[] [static]
Initial value:
 {
"All parameters must be white-space delimited.  Some options are driver",
"dependent.  Please see the PLplot reference document for more detail.",
NULL}

Definition at line 600 of file plargs.c.

char* program = NULL [static]

Definition at line 154 of file plargs.c.

int tables = 1 [static]

Definition at line 651 of file plargs.c.

char* usage = NULL [static]

Definition at line 155 of file plargs.c.