long long strtoq(const char *buf, const char **ptr, int base){ long long val=0; int i=0, neg=0; if( !base ){ if( buf[0] != '0' ) base = 10; else{ if( buf[1] == 'x' || buf[1] == 'X' ){ base = 16; buf += 2; }else base = 8; } } while( !islegit(base, buf[i])){ if( buf[i]=='-') neg = 1; i++; } while( islegit(base, buf[i])) val = (val * base) + vallof(buf[i++]); if( ptr ) *ptr = buf + i; return neg?-val:val; }
int compareDates(char *date1, char *date2) { int day1, mon1, year1, day2, mon2, year2; if (!islegit(date1, &day1, &mon1, &year1) || !islegit(date2, &day2, &mon2, &year2)) return -1; if (year1 > year2 || (year1 == year2 && mon1 > mon2) || (year1 == year2 && mon1 == mon2 && day1 > day2))// 1 is newer return 1; else if (year2 > year1 || (year1 == year2 && mon2 > mon1) || (year1 == year2 && mon1 == mon2 && day2 > day1)) return 2; return 0; }
/* ---------------------------------------------------------------------- */ int parse_eq (char *eqn, struct elt_list **elt_ptr, int association) /* ---------------------------------------------------------------------- */ /* * function to break equation up into component species * returns species name, coefficient, and charge in global variable "rxn_list". * Also returns pointer to elt_list structure array with list of elements * and coefficients in species. * rxn_list global variable, output with contiguous rxn_list structures, * which is the reaction. Target species is first in * list, coefficient is -1.0. * * Argurments: * *eqn input, pointer to equation to be parsed. * **elt_ptr output, pointer to contiguous elt_list structures, * which is list of elements and coefficients in the * target species. * association input, TRUE or FALSE if reaction is an association reaction */ { int i; LDBLE coef, z; char c; char *ptr, *char_ptr; char token[MAX_LENGTH]; if (svnid == NULL) fprintf (stderr, " "); paren_count = 0; /* * Remove white space */ squeeze_white (eqn); /* * Check for illegal characters */ for (i = 0; (c = eqn[i]) != '\0'; i++) { if (islegit (c) == FALSE) { sprintf (error_string, "Character is not allowed,\ %c (octal: %o).", c, c); error_msg (error_string, CONTINUE); return (ERROR); } }