FreeCalypso > hg > ueda-linux
diff ueda/libueda/popopt.c @ 0:cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 20 Jul 2015 00:24:37 +0000 |
parents | |
children | c91e7a30fab3 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ueda/libueda/popopt.c Mon Jul 20 00:24:37 2015 +0000 @@ -0,0 +1,68 @@ +/* + * These are the libueda routines for handling population options. + */ + +#include <stdio.h> +#include <ctype.h> +#include <strings.h> +#include "mcl.h" + +extern char *get_comp_attr(); + +#define MAX_POPOPT_LIST 10 +static int popopt_list[MAX_POPOPT_LIST], npopopt = 1; +static int all_popopt; + +set_popopt_list(arg) + char *arg; +{ + register char *cp, *np; + register int i; + + if (!strcmp(arg, "all")) { + all_popopt = 1; + return; + } + for (cp = arg, i = 0; *cp; ) { + if (*cp == ',') { + cp++; + continue; + } + if (!isdigit(*cp)) { + fprintf(stderr, + "%s: invalid population option specification\n", + arg); + exit(1); + } + for (np = cp; isdigit(*cp); cp++) + ; + if (i >= MAX_POPOPT_LIST) { + fprintf(stderr, + "%s: too many population options listed\n", + arg); + exit(1); + } + popopt_list[i++] = atoi(np); + } + npopopt = i; +} + +check_component_popopt(comp) + struct component *comp; +{ + register char *popopt_string; + register int popopt, i; + + if (all_popopt) + return(1); + popopt_string = get_comp_attr(comp, "population_option"); + if (!popopt_string) + popopt_string = "0"; + if (!strcmp(popopt_string, "NO")) + return(0); + popopt = atoi(popopt_string); + for (i = 0; i < npopopt; i++) + if (popopt_list[i] == popopt) + return(1); + return(0); +}