1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
25 * return the record format descriptor given a format string
26 * e!=0 set to the first unrecognized char after the format
27 * REC_N_TYPE() returned on error
29 * d[0xNN|delimiter] (delimited, newline default)
30 * [f][+]size (fixed length)
31 * v hN oN zN b|l i|n (variable length with size header)
32 * h header size in bytes (ibm V 4)
33 * o size offset in bytes (ibm V 0)
34 * z size length in bytes (ibm V 2)
35 * l|b little-endian or big-endian size (ibm V b (0))
36 * i|n header included/not-included in size (ibm V i (1))
43 recstr(register const char* s
, char** e
)
50 while (*s
== ' ' || *s
== '\t' || *s
== ',')
60 if (*s
== '0' && (*(s
+ 1) == 'x' || *(s
+ 1) == 'X'))
61 n
= (int)strtol(s
, &t
, 0);
71 while (*++s
== ' ' || *s
== '\t' || *s
== ',');
74 case '0': case '1': case '2': case '3': case '4':
75 case '5': case '6': case '7': case '8': case '9':
76 n
= strton(s
, &t
, NiL
, 0);
77 if (n
> 0 && t
> (char*)s
)
86 while (*++s
== ' ' || *s
== '\t' || *s
== ',');
87 for (t
= (char*)s
; *t
&& *t
!= ' ' && *t
!= '\t' && *t
!= ','; t
++);
90 if (strneq(s
, "data", 4))
94 return REC_M_TYPE(REC_M_data
);
96 else if (strneq(s
, "path", 4))
100 return REC_M_TYPE(REC_M_path
);
105 * TBD: look up name in method libraries
106 * and assign an integer index
112 while (*++s
== ' ' || *s
== '\t' || *s
== ',');
113 n
= strtol(s
, &t
, 0);
114 if (n
< 0 || n
> 15 || *t
++ != '.')
116 v
= strtol(t
, &t
, 0);
121 return REC_U_TYPE(n
, v
);
179 case '0': case '1': case '2': case '3': case '4':
180 case '5': case '6': case '7': case '8': case '9':
182 a
[n
++] = strtol(s
, &t
, 0);
183 s
= (const char*)t
- 1;
190 if (a
[3] > (a
[1] - a
[2]))
192 return REC_V_RECORD(REC_V_TYPE(a
[1], a
[2], a
[3], a
[4], a
[5]), a
[0]);
196 return REC_M_TYPE(REC_M_path
);
201 return REC_M_TYPE(REC_M_data
);