FreeCalypso > hg > ueda-linux
diff ueda/libueda/util.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/util.c Mon Jul 20 00:24:37 2015 +0000 @@ -0,0 +1,37 @@ +/* + * Miscellaneous utility functions for libueda + */ + +#include <ctype.h> +#include <strings.h> + +extern char *malloc(); + +char * +copystr(src) + register char *src; +{ + register char *buf; + + buf = malloc(strlen(src) + 1); + if (!buf) { + perror("malloc"); + exit(1); + } + strcpy(buf, src); + return(buf); +} + +string_is_valid_decnum(str) + char *str; +{ + register char *cp = str; + + if (*cp == '-') + cp++; + if (!isdigit(*cp)) + return(0); + while (isdigit(*cp)) + cp++; + return(*cp == '\0'); +}