"I am a person who works hard and plays hard."

Yuan Wei
Second Year Graduate Student Department of Computer Science
University of Virginia Charlottesville, VA 22903
Email: yw3f@cs.virginia.edu


Source Code Analysis

Main Page   Compound List   File List   Compound Members   File Members  

options.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Compounds

Typedefs

Enumerations

Functions


Typedef Documentation

typedef int(* orphan_fn_t)(int i, int argc, char **argv)
 

Definition at line 139 of file options.h.


Enumeration Type Documentation

enum opt_class_t
 

Enumeration values:
oc_int 
oc_uint 
oc_float 
oc_double 
oc_enum 
oc_flag 
oc_string 
oc_NUM 

Definition at line 83 of file options.h.

00083                  {
00084   oc_int = 0,           /* integer option */
00085   oc_uint,              /* unsigned integer option */
00086   oc_float,             /* float option */
00087   oc_double,            /* double option */
00088   oc_enum,              /* enumeration option */
00089   oc_flag,              /* boolean option */
00090   oc_string,            /* string option */
00091   oc_NUM
00092 };


Function Documentation

void opt_delete struct opt_odb_t   odb
 

Definition at line 109 of file options.c.

References opt_note_t::next, opt_opt_t::next, opt_odb_t::notes, and opt_odb_t::options.

00110 {
00111   struct opt_opt_t *opt, *opt_next;
00112   struct opt_note_t *note, *note_next;
00113 
00114   /* free all options */
00115   for (opt=odb->options; opt; opt=opt_next)
00116     {
00117       opt_next = opt->next;
00118       opt->next = NULL;
00119       free(opt);
00120     }
00121 
00122   /* free all notes */
00123   for (note = odb->notes; note != NULL; note = note_next)
00124     {
00125       note_next = note->next;
00126       note->next = NULL;
00127       free(note);
00128     }
00129   odb->notes = NULL;
00130 
00131   free(odb);
00132 }

struct opt_opt_t* opt_find_option struct opt_odb_t   odb,
char *    opt_name
 

Definition at line 1658 of file options.c.

References opt_opt_t::name, and opt_opt_t::next.

Referenced by dlite_option().

01660 {
01661   struct opt_opt_t *opt;
01662 
01663   /* search builtin options */
01664   for (opt = builtin_options; opt != NULL; opt = opt->next)
01665     {
01666       if (!strcmp(opt->name, opt_name))
01667         {
01668           /* located option */
01669           return opt;
01670         }
01671     }
01672 
01673   /* search user-installed options */
01674   for (opt = odb->options; opt != NULL; opt = opt->next)
01675     {
01676       if (!strcmp(opt->name, opt_name))
01677         {
01678           /* located option */
01679           return opt;
01680         }
01681     }
01682   /* not found */
01683   return NULL;
01684 }

struct opt_odb_t* opt_new orphan_fn_t    orphan_fn
 

Definition at line 91 of file options.c.

References fatal(), opt_odb_t::header, opt_odb_t::notes, opt_odb_t::options, and opt_odb_t::orphan_fn.

Referenced by main().

00092 {
00093   struct opt_odb_t *odb;
00094 
00095   odb = (struct opt_odb_t *)calloc(1, sizeof(struct opt_odb_t));
00096   if (!odb)
00097     fatal("out of virtual memory");
00098 
00099   odb->options = NULL;
00100   odb->orphan_fn = orphan_fn;
00101   odb->header = NULL;
00102   odb->notes = NULL;
00103 
00104   return odb;
00105 }

void opt_print_help struct opt_odb_t   odb,
FILE *    fd
 

Definition at line 1606 of file options.c.

References opt_opt_t::next, opt_odb_t::options, print_help(), print_option_header(), and print_option_notes().

Referenced by usage().

01608 {
01609   struct opt_opt_t *opt;
01610 
01611   /* print any options header */
01612   print_option_header(odb, fd);
01613 
01614   fprintf(fd, "#\n");
01615   fprintf(fd, "%-16s %-16s # %12s # %-22s\n",
01616           "# -option", "<args>", "<default>", "description");
01617   fprintf(fd, "#\n");
01618 
01619   /* print out help info for builtin options */
01620   for (opt=builtin_options; opt != NULL; opt=opt->next)
01621     print_help(opt, fd);
01622 
01623   /* print out help info for options in options database */
01624   for (opt=odb->options; opt != NULL; opt=opt->next)
01625     print_help(opt, fd);
01626 
01627   /* print option notes */
01628   print_option_notes(odb, fd);
01629 }

void opt_print_option struct opt_opt_t   opt,
FILE *    fd
 

Definition at line 1311 of file options.c.

References bind_to_str(), opt_opt_t::opt_variant_t::opt_for_enum_t::emap, opt_opt_t::opt_variant_t::opt_for_enum_t::emap_sz, opt_opt_t::opt_variant_t::opt_for_enum_t::eval, opt_opt_t::opt_variant_t::for_double, opt_opt_t::opt_variant_t::for_enum, opt_opt_t::opt_variant_t::for_float, opt_opt_t::opt_variant_t::for_int, opt_opt_t::opt_variant_t::for_string, opt_opt_t::opt_variant_t::for_uint, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::nvars, opt_opt_t::oc, oc_double, oc_enum, oc_flag, oc_float, oc_int, oc_string, oc_uint, panic(), opt_opt_t::opt_variant_t::opt_for_string_t::var, opt_opt_t::opt_variant_t::opt_for_enum_t::var, opt_opt_t::opt_variant_t::opt_for_double_t::var, opt_opt_t::opt_variant_t::opt_for_float_t::var, opt_opt_t::opt_variant_t::opt_for_uint_t::var, opt_opt_t::opt_variant_t::opt_for_int_t::var, and opt_opt_t::variant.

Referenced by dlite_option(), opt_print_options(), and print_help().

01313 {
01314   int i, nelt;
01315 
01316   switch (opt->oc)
01317     {
01318     case oc_int:
01319       if (opt->nelt)
01320         nelt = *(opt->nelt);
01321       else
01322         nelt = 1;
01323       for (i=0; i<nelt; i++)
01324         {
01325           fprintf(fd, opt->format, opt->variant.for_int.var[i]);
01326           fprintf(fd, " ");
01327         }
01328       break;
01329     case oc_uint:
01330       if (opt->nelt)
01331         nelt = *(opt->nelt);
01332       else
01333         nelt = 1;
01334       for (i=0; i<nelt; i++)
01335         {
01336           fprintf(fd, opt->format, opt->variant.for_uint.var[i]);
01337           fprintf(fd, " ");
01338         }
01339       break;
01340     case oc_float:
01341       if (opt->nelt)
01342         nelt = *(opt->nelt);
01343       else
01344         nelt = 1;
01345       for (i=0; i<nelt; i++)
01346         {
01347           fprintf(fd, opt->format, (double)opt->variant.for_float.var[i]);
01348           fprintf(fd, " ");
01349         }
01350       break;
01351     case oc_double:
01352       if (opt->nelt)
01353         nelt = *(opt->nelt);
01354       else
01355         nelt = 1;
01356       for (i=0; i<nelt; i++)
01357         {
01358           fprintf(fd, opt->format, opt->variant.for_double.var[i]);
01359           fprintf(fd, " ");
01360         }
01361       break;
01362     case oc_enum:
01363       if (opt->nelt)
01364         nelt = *(opt->nelt);
01365       else
01366         nelt = 1;
01367       for (i=0; i<nelt; i++)
01368         {
01369           char *estr = bind_to_str(opt->variant.for_enum.var[i],
01370                                    opt->variant.for_enum.emap,
01371                                    opt->variant.for_enum.eval,
01372                                    opt->variant.for_enum.emap_sz);
01373           if (!estr)
01374             panic("could not bind enum `%d' for option `%s'",
01375                   opt->variant.for_enum.var[i], opt->name);
01376 
01377           fprintf(fd, opt->format, estr);
01378           fprintf(fd, " ");
01379         }
01380       break;
01381     case oc_flag:
01382       if (opt->nelt)
01383         nelt = *(opt->nelt);
01384       else
01385         nelt = 1;
01386       for (i=0; i<nelt; i++)
01387         {
01388           char *estr = bind_to_str(opt->variant.for_enum.var[i],
01389                                    opt->variant.for_enum.emap,
01390                                    opt->variant.for_enum.eval,
01391                                    opt->variant.for_enum.emap_sz);
01392           if (!estr)
01393             panic("could not bind boolean `%d' for option `%s'",
01394                   opt->variant.for_enum.var[i], opt->name);
01395           
01396           fprintf(fd, opt->format, estr);
01397           fprintf(fd, " ");
01398         }
01399       break;
01400     case oc_string:
01401       if (!opt->nvars)
01402         {
01403           fprintf(fd, "%12s ", "<null>");
01404           break;
01405         }
01406       if (opt->nelt)
01407         nelt = *(opt->nelt);
01408       else
01409         nelt = 1;
01410       if (nelt == 0)
01411         {
01412           fprintf(fd, "%12s ", "<null>");
01413           break;
01414         }
01415       else
01416         {
01417           for (i=0; i<nelt; i++)
01418             {
01419               fprintf(fd, opt->format,
01420                       (opt->variant.for_string.var[i]
01421                        ? opt->variant.for_string.var[i]
01422                        : "<null>"));
01423               fprintf(fd, " ");
01424             }
01425         }
01426       break;
01427     default:
01428       panic("bogus option class");
01429     }
01430 }

void opt_print_options struct opt_odb_t   odb,
FILE *    fd,
int    terse,
int    notes
 

Definition at line 1483 of file options.c.

References opt_opt_t::desc, opt_opt_t::name, opt_opt_t::next, opt_null_string(), opt_print_option(), opt_odb_t::options, opt_opt_t::print, print_option_header(), and print_option_notes().

Referenced by dlite_options(), dump_config(), and main().

01487 {
01488   struct opt_opt_t *opt;
01489 
01490   if (!odb)
01491     {
01492       /* no options */
01493       return;
01494     }
01495 
01496   /* print any options header */
01497   if (notes)
01498     print_option_header(odb, fd);
01499 
01500   /* dump out builtin options */
01501   for (opt=builtin_options; opt != NULL; opt=opt->next)
01502     {
01503       if (terse)
01504         fprintf(fd, "# %-27s # %s\n", opt->name, opt->desc);
01505       else
01506         {
01507           fprintf(fd, "# %s\n", opt->desc);
01508           fprintf(fd, "# %-22s\n\n", opt->name);
01509         }
01510     }
01511 
01512   /* dump out options from options database */
01513   for (opt=odb->options; opt != NULL; opt=opt->next)
01514     {
01515       if (terse)
01516         {
01517           if (!opt->print || opt_null_string(opt))
01518               fprintf(fd, "# %-14s ", opt->name);
01519           else
01520             fprintf(fd, "%-16s ", opt->name);
01521           opt_print_option(opt, fd);
01522           if (opt->desc)
01523             fprintf(fd, "# %-22s", opt->desc);
01524           fprintf(fd, "\n");
01525         }
01526       else
01527         {
01528           if (opt->desc)
01529             fprintf(fd, "# %s\n", opt->desc);
01530           if (!opt->print || opt_null_string(opt))
01531             fprintf(fd, "# %-20s ", opt->name);
01532           else
01533             fprintf(fd, "%-22s ", opt->name);
01534           opt_print_option(opt, fd);
01535           fprintf(fd, "\n\n");
01536         }
01537     }
01538 
01539   /* print option notes */
01540   if (notes)
01541     print_option_notes(odb, fd);
01542 }

void opt_process_options struct opt_odb_t   odb,
int    argc,
char **    argv
 

Definition at line 1204 of file options.c.

References __opt_process_options().

Referenced by main().

01207 {
01208   /* need at least two entries to have an option */
01209   if (argc < 2)
01210     return;
01211 
01212   /* process the command, starting at `-config' depth zero */
01213   __opt_process_options(odb, argc-1, argv+1, /* top level */0);
01214 }

void opt_reg_double struct opt_odb_t   odb,
char *    name,
char *    desc,
double *    var,
double    def_val,
int    print,
char *    format
 

Definition at line 381 of file options.c.

References opt_opt_t::accrue, add_option(), opt_opt_t::desc, FALSE, fatal(), opt_opt_t::opt_variant_t::for_double, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, opt_opt_t::nvars, opt_opt_t::oc, oc_double, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_double_t::var, and opt_opt_t::variant.

00388 {
00389   struct opt_opt_t *opt;
00390 
00391   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00392   if (!opt)
00393     fatal("out of virtual memory");
00394 
00395   opt->name = name;
00396   opt->desc = desc;
00397   opt->nvars = 1;
00398   opt->nelt = NULL;
00399   opt->format = format ? format : "%12.4f";
00400   opt->oc = oc_double;
00401   opt->variant.for_double.var = var;
00402   opt->print = print;
00403   opt->accrue = FALSE;
00404 
00405   /* place on ODB's option list */
00406   opt->next = NULL;
00407   add_option(odb, opt);
00408 
00409   /* set default value */
00410   *var = def_val;
00411 }

void opt_reg_double_list struct opt_odb_t   odb,
char *    name,
char *    desc,
double *    vars,
int    nvars,
int *    nelt,
double *    def_val,
int    print,
char *    format,
int    accrue
 

Definition at line 415 of file options.c.

References opt_opt_t::accrue, add_option(), opt_opt_t::desc, fatal(), opt_opt_t::opt_variant_t::for_double, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, opt_opt_t::nvars, opt_opt_t::oc, oc_double, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_double_t::var, and opt_opt_t::variant.

00425 {
00426   int i;
00427   struct opt_opt_t *opt;
00428 
00429   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00430   if (!opt)
00431     fatal("out of virtual memory");
00432 
00433   opt->name = name;
00434   opt->desc = desc;
00435   opt->nvars = nvars;
00436   opt->nelt = nelt;
00437   opt->format = format ? format : "%.4f";
00438   opt->oc = oc_double;
00439   opt->variant.for_double.var = vars;
00440   opt->print = print;
00441   opt->accrue = accrue;
00442 
00443   /* place on ODB's option list */
00444   opt->next = NULL;
00445   add_option(odb, opt);
00446 
00447   /* set default value */
00448   for (i=0; i < *nelt; i++)
00449     vars[i] = def_val[i];
00450 }

void opt_reg_enum struct opt_odb_t   odb,
char *    name,
char *    desc,
int *    var,
char *    def_val,
char **    emap,
int *    eval,
int    emap_sz,
int    print,
char *    format
 

Definition at line 526 of file options.c.

References opt_opt_t::accrue, add_option(), bind_to_enum(), opt_opt_t::desc, opt_opt_t::opt_variant_t::opt_for_enum_t::emap, opt_opt_t::opt_variant_t::opt_for_enum_t::emap_sz, opt_opt_t::opt_variant_t::opt_for_enum_t::eval, FALSE, fatal(), opt_opt_t::opt_variant_t::for_enum, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, opt_opt_t::nvars, opt_opt_t::oc, oc_enum, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_enum_t::var, and opt_opt_t::variant.

00536 {
00537   int enum_val;
00538   struct opt_opt_t *opt;
00539 
00540   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00541   if (!opt)
00542     fatal("out of virtual memory");
00543 
00544   opt->name = name;
00545   opt->desc = desc;
00546   opt->nvars = 1;
00547   opt->nelt = NULL;
00548   opt->format = format ? format : "%12s";
00549   opt->oc = oc_enum;
00550   opt->variant.for_enum.var = var;
00551   opt->variant.for_enum.emap = emap;
00552   opt->variant.for_enum.eval = eval;
00553   opt->variant.for_enum.emap_sz = emap_sz;
00554   if (def_val)
00555     {
00556       if (!bind_to_enum(def_val, emap, eval, emap_sz, &enum_val))
00557         fatal("could not bind default value for option `%s'", name);
00558     }
00559   else
00560     enum_val = 0;
00561   opt->print = print;
00562   opt->accrue = FALSE;
00563 
00564   /* place on ODB's option list */
00565   opt->next = NULL;
00566   add_option(odb, opt);
00567 
00568   /* set default value */
00569   *var = enum_val;
00570 }

void opt_reg_enum_list struct opt_odb_t   odb,
char *    name,
char *    desc,
int *    vars,
int    nvars,
int *    nelt,
char *    def_val,
char **    emap,
int *    eval,
int    emap_sz,
int    print,
char *    format,
int    accrue
 

Definition at line 576 of file options.c.

References opt_opt_t::accrue, add_option(), bind_to_enum(), opt_opt_t::desc, opt_opt_t::opt_variant_t::opt_for_enum_t::emap, opt_opt_t::opt_variant_t::opt_for_enum_t::emap_sz, opt_opt_t::opt_variant_t::opt_for_enum_t::eval, fatal(), opt_opt_t::opt_variant_t::for_enum, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, opt_opt_t::nvars, opt_opt_t::oc, oc_enum, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_enum_t::var, and opt_opt_t::variant.

00589 {
00590   int i, enum_val;
00591   struct opt_opt_t *opt;
00592 
00593   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00594   if (!opt)
00595     fatal("out of virtual memory");
00596 
00597   opt->name = name;
00598   opt->desc = desc;
00599   opt->nvars = nvars;
00600   opt->nelt = nelt;
00601   opt->format = format ? format : "%s";
00602   opt->oc = oc_enum;
00603   opt->variant.for_enum.var = vars;
00604   opt->variant.for_enum.emap = emap;
00605   opt->variant.for_enum.eval = eval;
00606   opt->variant.for_enum.emap_sz = emap_sz;
00607   if (def_val)
00608     {
00609       if (!bind_to_enum(def_val, emap, eval, emap_sz, &enum_val))
00610         fatal("could not bind default value for option `%s'", name);
00611     }
00612   else
00613     enum_val = 0;
00614   opt->print = print;
00615   opt->accrue = accrue;
00616 
00617   /* place on ODB's option list */
00618   opt->next = NULL;
00619   add_option(odb, opt);
00620 
00621   /* set default value */
00622   for (i=0; i < *nelt; i++)
00623     vars[i] = enum_val;
00624 }

void opt_reg_flag struct opt_odb_t   odb,
char *    name,
char *    desc,
int *    var,
int    def_val,
int    print,
char *    format
 

Definition at line 641 of file options.c.

References opt_opt_t::accrue, add_option(), opt_opt_t::desc, opt_opt_t::opt_variant_t::opt_for_enum_t::emap, opt_opt_t::opt_variant_t::opt_for_enum_t::emap_sz, opt_opt_t::opt_variant_t::opt_for_enum_t::eval, FALSE, fatal(), flag_emap, flag_eval, opt_opt_t::opt_variant_t::for_enum, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, NUM_FLAGS, opt_opt_t::nvars, opt_opt_t::oc, oc_flag, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_enum_t::var, and opt_opt_t::variant.

Referenced by main(), and sim_reg_options().

00648 {
00649   struct opt_opt_t *opt;
00650 
00651   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00652   if (!opt)
00653     fatal("out of virtual memory");
00654 
00655   opt->name = name;
00656   opt->desc = desc;
00657   opt->nvars = 1;
00658   opt->nelt = NULL;
00659   opt->format = format ? format : "%12s";
00660   opt->oc = oc_flag;
00661   opt->variant.for_enum.var = var;
00662   opt->variant.for_enum.emap = flag_emap;
00663   opt->variant.for_enum.eval = flag_eval;
00664   opt->variant.for_enum.emap_sz = NUM_FLAGS;
00665   opt->print = print;
00666   opt->accrue = FALSE;
00667 
00668   /* place on ODB's option list */
00669   opt->next = NULL;
00670   add_option(odb, opt);
00671 
00672   /* set default value */
00673   *var = def_val;
00674 }

void opt_reg_flag_list struct opt_odb_t   odb,
char *    name,
char *    desc,
int *    vars,
int    nvars,
int *    nelt,
int *    def_val,
int    print,
char *    format,
int    accrue
 

Definition at line 678 of file options.c.

References opt_opt_t::accrue, add_option(), opt_opt_t::desc, opt_opt_t::opt_variant_t::opt_for_enum_t::emap, opt_opt_t::opt_variant_t::opt_for_enum_t::emap_sz, opt_opt_t::opt_variant_t::opt_for_enum_t::eval, fatal(), flag_emap, flag_eval, opt_opt_t::opt_variant_t::for_enum, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, NUM_FLAGS, opt_opt_t::nvars, opt_opt_t::oc, oc_flag, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_enum_t::var, and opt_opt_t::variant.

00688 {
00689   int i;
00690   struct opt_opt_t *opt;
00691 
00692   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00693   if (!opt)
00694     fatal("out of virtual memory");
00695 
00696   opt->name = name;
00697   opt->desc = desc;
00698   opt->nvars = nvars;
00699   opt->nelt = nelt;
00700   opt->format = format ? format : "%s";
00701   opt->oc = oc_flag;
00702   opt->variant.for_enum.var = vars;
00703   opt->variant.for_enum.emap = flag_emap;
00704   opt->variant.for_enum.eval = flag_eval;
00705   opt->variant.for_enum.emap_sz = NUM_FLAGS;
00706   opt->print = print;
00707   opt->accrue = accrue;
00708 
00709   /* place on ODB's option list */
00710   opt->next = NULL;
00711   add_option(odb, opt);
00712 
00713   /* set default value */
00714   for (i=0; i < *nelt; i++)
00715     vars[i] = def_val[i];
00716 }

void opt_reg_float struct opt_odb_t   odb,
char *    name,
char *    desc,
float *    var,
float    def_val,
int    print,
char *    format
 

Definition at line 308 of file options.c.

References opt_opt_t::accrue, add_option(), opt_opt_t::desc, FALSE, fatal(), opt_opt_t::opt_variant_t::for_float, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, opt_opt_t::nvars, opt_opt_t::oc, oc_float, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_float_t::var, and opt_opt_t::variant.

00315 {
00316   struct opt_opt_t *opt;
00317 
00318   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00319   if (!opt)
00320     fatal("out of virtual memory");
00321 
00322   opt->name = name;
00323   opt->desc = desc;
00324   opt->nvars = 1;
00325   opt->nelt = NULL;
00326   opt->format = format ? format : "%12.4f";
00327   opt->oc = oc_float;
00328   opt->variant.for_float.var = var;
00329   opt->print = print;
00330   opt->accrue = FALSE;
00331 
00332   /* place on ODB's option list */
00333   opt->next = NULL;
00334   add_option(odb, opt);
00335 
00336   /* set default value */
00337   *var = def_val;
00338 }

void opt_reg_float_list struct opt_odb_t   odb,
char *    name,
char *    desc,
float *    vars,
int    nvars,
int *    nelt,
float *    def_val,
int    print,
char *    format,
int    accrue
 

Definition at line 342 of file options.c.

References opt_opt_t::accrue, add_option(), opt_opt_t::desc, fatal(), opt_opt_t::opt_variant_t::for_float, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, opt_opt_t::nvars, opt_opt_t::oc, oc_float, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_float_t::var, and opt_opt_t::variant.

00352 {
00353   int i;
00354   struct opt_opt_t *opt;
00355 
00356   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00357   if (!opt)
00358     fatal("out of virtual memory");
00359 
00360   opt->name = name;
00361   opt->desc = desc;
00362   opt->nvars = nvars;
00363   opt->nelt = nelt;
00364   opt->format = format ? format : "%.4f";
00365   opt->oc = oc_float;
00366   opt->variant.for_float.var = vars;
00367   opt->print = print;
00368   opt->accrue = accrue;
00369 
00370   /* place on ODB's option list */
00371   opt->next = NULL;
00372   add_option(odb, opt);
00373 
00374   /* set default value */
00375   for (i=0; i < *nelt; i++)
00376     vars[i] = def_val[i];
00377 }

void opt_reg_header struct opt_odb_t   odb,
char *    header
 

Definition at line 1688 of file options.c.

References opt_odb_t::header.

Referenced by sim_reg_options().

01690 {
01691   odb->header = header;
01692 }

void opt_reg_int struct opt_odb_t   odb,
char *    name,
char *    desc,
int *    var,
int    def_val,
int    print,
char *    format
 

Definition at line 162 of file options.c.

References opt_opt_t::accrue, add_option(), opt_opt_t::desc, FALSE, fatal(), opt_opt_t::opt_variant_t::for_int, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, opt_opt_t::nvars, opt_opt_t::oc, oc_int, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_int_t::var, and opt_opt_t::variant.

Referenced by main(), and sim_reg_options().

00169 {
00170   struct opt_opt_t *opt;
00171 
00172   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00173   if (!opt)
00174     fatal("out of virtual memory");
00175 
00176   opt->name = name;
00177   opt->desc = desc;
00178   opt->nvars = 1;
00179   opt->nelt = NULL;
00180   opt->format = format ? format : "%12d";
00181   opt->oc = oc_int;
00182   opt->variant.for_int.var = var;
00183   opt->print = print;
00184   opt->accrue = FALSE;
00185 
00186   /* place on ODB's option list */
00187   opt->next = NULL;
00188   add_option(odb, opt);
00189 
00190   /* set default value */
00191   *var = def_val;
00192 }

void opt_reg_int_list struct opt_odb_t   odb,
char *    name,
char *    desc,
int *    vars,
int    nvars,
int *    nelt,
int *    def_val,
int    print,
char *    format,
int    accrue
 

Definition at line 196 of file options.c.

References opt_opt_t::accrue, add_option(), opt_opt_t::desc, fatal(), opt_opt_t::opt_variant_t::for_int, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, opt_opt_t::nvars, opt_opt_t::oc, oc_int, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_int_t::var, and opt_opt_t::variant.

Referenced by sim_reg_options().

00206 {
00207   int i;
00208   struct opt_opt_t *opt;
00209 
00210   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00211   if (!opt)
00212     fatal("out of virtual memory");
00213 
00214   opt->name = name;
00215   opt->desc = desc;
00216   opt->nvars = nvars;
00217   opt->nelt = nelt;
00218   opt->format = format ? format : "%d";
00219   opt->oc = oc_int;
00220   opt->variant.for_int.var = vars;
00221   opt->print = print;
00222   opt->accrue = accrue;
00223 
00224   /* place on ODB's option list */
00225   opt->next = NULL;
00226   add_option(odb, opt);
00227 
00228   /* set default value */
00229   for (i=0; i < *nelt; i++)
00230     vars[i] = def_val[i];
00231 }

void opt_reg_note struct opt_odb_t   odb,
char *    note
 

Definition at line 1696 of file options.c.

References fatal(), opt_note_t::next, opt_note_t::note, and opt_odb_t::notes.

Referenced by sim_reg_options().

01698 {
01699   struct opt_note_t *note, *elt, *prev;
01700 
01701   note = (struct opt_note_t *)calloc(1, sizeof(struct opt_note_t));
01702   if (!note)
01703     fatal("out of virtual memory");
01704 
01705   /* record note */
01706   note->next = NULL;
01707   note->note = note_str;
01708 
01709   /* add to end of option notes list */
01710   for (prev=NULL, elt=odb->notes; elt != NULL; prev=elt, elt=elt->next)
01711     /* nada */;
01712 
01713   if (prev != NULL)
01714     prev->next = note;
01715   else /* prev == NULL */
01716     odb->notes = note;
01717   note->next = NULL;
01718 }

void opt_reg_string struct opt_odb_t   odb,
char *    name,
char *    desc,
char **    var,
char *    def_val,
int    print,
char *    format
 

Definition at line 720 of file options.c.

References opt_opt_t::accrue, add_option(), opt_opt_t::desc, FALSE, fatal(), opt_opt_t::opt_variant_t::for_string, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, opt_opt_t::nvars, opt_opt_t::oc, oc_string, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_string_t::var, and opt_opt_t::variant.

Referenced by main(), and sim_reg_options().

00727 {
00728   struct opt_opt_t *opt;
00729 
00730   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00731   if (!opt)
00732     fatal("out of virtual memory");
00733 
00734   opt->name = name;
00735   opt->desc = desc;
00736   opt->nvars = 1;
00737   opt->nelt = NULL;
00738   opt->format = format ? format : "%12s";
00739   opt->oc = oc_string;
00740   opt->variant.for_string.var = var;
00741   opt->print = print;
00742   opt->accrue = FALSE;
00743 
00744   /* place on ODB's option list */
00745   opt->next = NULL;
00746   add_option(odb, opt);
00747 
00748   /* set default value */
00749   *var = def_val;
00750 }

void opt_reg_string_list struct opt_odb_t   odb,
char *    name,
char *    desc,
char **    vars,
int    nvars,
int *    nelt,
char **    def_val,
int    print,
char *    format,
int    accrue
 

Definition at line 754 of file options.c.

References opt_opt_t::accrue, add_option(), opt_opt_t::desc, fatal(), opt_opt_t::opt_variant_t::for_string, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, opt_opt_t::nvars, opt_opt_t::oc, oc_string, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_string_t::var, and opt_opt_t::variant.

Referenced by sim_reg_options().

00764 {
00765   int i;
00766   struct opt_opt_t *opt;
00767 
00768   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00769   if (!opt)
00770     fatal("out of virtual memory");
00771 
00772   opt->name = name;
00773   opt->desc = desc;
00774   opt->nvars = nvars;
00775   opt->nelt = nelt;
00776   opt->format = format ? format : "%s";
00777   opt->oc = oc_string;
00778   opt->variant.for_string.var = vars;
00779   opt->print = print;
00780   opt->accrue = accrue;
00781 
00782   /* place on ODB's option list */
00783   opt->next = NULL;
00784   add_option(odb, opt);
00785 
00786   /* set default value */
00787   for (i=0; i < *nelt; i++)
00788     vars[i] = def_val[i];
00789 }

void opt_reg_uint struct opt_odb_t   odb,
char *    name,
char *    desc,
unsigned int *    var,
unsigned int    def_val,
int    print,
char *    format
 

Definition at line 235 of file options.c.

References opt_opt_t::accrue, add_option(), opt_opt_t::desc, FALSE, fatal(), opt_opt_t::opt_variant_t::for_uint, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, opt_opt_t::nvars, opt_opt_t::oc, oc_uint, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_uint_t::var, and opt_opt_t::variant.

Referenced by sim_reg_options().

00242 {
00243   struct opt_opt_t *opt;
00244 
00245   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00246   if (!opt)
00247     fatal("out of virtual memory");
00248 
00249   opt->name = name;
00250   opt->desc = desc;
00251   opt->nvars = 1;
00252   opt->nelt = NULL;
00253   opt->format = format ? format : "%12u";
00254   opt->oc = oc_uint;
00255   opt->variant.for_uint.var = var;
00256   opt->print = print;
00257   opt->accrue = FALSE;
00258 
00259   /* place on ODB's option list */
00260   opt->next = NULL;
00261   add_option(odb, opt);
00262 
00263   /* set default value */
00264   *var = def_val;
00265 }

void opt_reg_uint_list struct opt_odb_t   odb,
char *    name,
char *    desc,
unsigned int *    vars,
int    nvars,
int *    nelt,
unsigned int *    def_val,
int    print,
char *    format,
int    accrue
 

Definition at line 269 of file options.c.

References opt_opt_t::accrue, add_option(), opt_opt_t::desc, fatal(), opt_opt_t::opt_variant_t::for_uint, opt_opt_t::format, opt_opt_t::name, opt_opt_t::nelt, opt_opt_t::next, opt_opt_t::nvars, opt_opt_t::oc, oc_uint, opt_opt_t::print, opt_opt_t::opt_variant_t::opt_for_uint_t::var, and opt_opt_t::variant.

00279 {
00280   int i;
00281   struct opt_opt_t *opt;
00282 
00283   opt = (struct opt_opt_t *)calloc(1, sizeof(struct opt_opt_t));
00284   if (!opt)
00285     fatal("out of virtual memory");
00286 
00287   opt->name = name;
00288   opt->desc = desc;
00289   opt->nvars = nvars;
00290   opt->nelt = nelt;
00291   opt->format = format ? format : "%u";
00292   opt->oc = oc_uint;
00293   opt->variant.for_uint.var = vars;
00294   opt->print = print;
00295   opt->accrue = accrue;
00296 
00297   /* place on ODB's option list */
00298   opt->next = NULL;
00299   add_option(odb, opt);
00300 
00301   /* set default value */
00302   for (i=0; i < *nelt; i++)
00303     vars[i] = def_val[i];
00304 }



UVa CS Department of Computer Science
School of Engineering, University of Virginia
151 Engineer's Way, P.O. Box 400740
Charlottesville, Virginia 22904-4740

(434) 982-2200  Fax: (434) 982-2214