FreeCalypso > hg > ueda-linux
view ueda/libueda/popopt.c @ 86:ccbf05fcbcb2
ifctf-part-lib/m4-fp/geda.inc: JUMPERn covers full [1,20] range
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 25 Apr 2018 20:13:34 +0000 |
parents | c91e7a30fab3 |
children |
line wrap: on
line source
/* * These are the libueda routines for handling population options. */ #include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <string.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); }