FreeCalypso > hg > ueda-linux
annotate ueda/libueda/util.c @ 88:aab9b7e63fb6
FH12 footprints: square pads
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 26 Apr 2018 01:09:19 +0000 |
parents | c91e7a30fab3 |
children |
rev | line source |
---|---|
0
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Miscellaneous utility functions for libueda |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <ctype.h> |
2
c91e7a30fab3
ueda/libueda Linuxified
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
0
diff
changeset
|
6 #include <stdlib.h> |
c91e7a30fab3
ueda/libueda Linuxified
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
0
diff
changeset
|
7 #include <string.h> |
0
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <strings.h> |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 char * |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 copystr(src) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 register char *src; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 { |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 register char *buf; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 buf = malloc(strlen(src) + 1); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 if (!buf) { |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 perror("malloc"); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 exit(1); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 } |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 strcpy(buf, src); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 return(buf); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 } |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 string_is_valid_decnum(str) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 char *str; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 { |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 register char *cp = str; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 if (*cp == '-') |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 cp++; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 if (!isdigit(*cp)) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 return(0); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 while (isdigit(*cp)) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 cp++; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 return(*cp == '\0'); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 } |