FreeCalypso > hg > ueda-linux
comparison 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 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:cd92449fdb51 |
|---|---|
| 1 /* | |
| 2 * Miscellaneous utility functions for libueda | |
| 3 */ | |
| 4 | |
| 5 #include <ctype.h> | |
| 6 #include <strings.h> | |
| 7 | |
| 8 extern char *malloc(); | |
| 9 | |
| 10 char * | |
| 11 copystr(src) | |
| 12 register char *src; | |
| 13 { | |
| 14 register char *buf; | |
| 15 | |
| 16 buf = malloc(strlen(src) + 1); | |
| 17 if (!buf) { | |
| 18 perror("malloc"); | |
| 19 exit(1); | |
| 20 } | |
| 21 strcpy(buf, src); | |
| 22 return(buf); | |
| 23 } | |
| 24 | |
| 25 string_is_valid_decnum(str) | |
| 26 char *str; | |
| 27 { | |
| 28 register char *cp = str; | |
| 29 | |
| 30 if (*cp == '-') | |
| 31 cp++; | |
| 32 if (!isdigit(*cp)) | |
| 33 return(0); | |
| 34 while (isdigit(*cp)) | |
| 35 cp++; | |
| 36 return(*cp == '\0'); | |
| 37 } |
