26 #include <lal/LALDatatypes.h>
27 #include <lal/LALMalloc.h>
28 #include <lal/XLALError.h>
48 if(*s ==
'X' || *s ==
'x') {
66 if(*s ==
'E' || *s ==
'e') {
68 if(*s ==
'+' || *s ==
'-')
78 if(*s ==
'P' || *s ==
'p') {
80 if(*s ==
'+' || *s ==
'-')
93 union {
char *s;
const char *cs; } pconv;
108 radix = localeconv()->decimal_point[0];
114 while(isspace(*(pconv.cs)))
120 if(*(pconv.cs) ==
'-') {
123 }
else if(*(pconv.cs) ==
'+') {
133 }
else if(
isbase10((pconv.cs), radix)) {
146 for(len = 0; 1; len++) {
147 if(isdigit((pconv.cs)[len]))
149 if((pconv.cs)[len] == radix && radixpos < 0) {
158 for(len = 0; 1; len++) {
159 if(isxdigit((pconv.cs)[len]))
161 if((pconv.cs)[len] == radix && radixpos < 0) {
173 digits = malloc(len + 1);
174 memcpy(digits, (pconv.cs), radixpos);
175 memcpy(digits + radixpos, (pconv.cs) + radixpos + 1, len - radixpos - 1);
176 digits[len - 1] =
'\0';
180 digits = malloc(len + 2);
181 memcpy(digits, (pconv.cs), len);
194 radixpos += strtol((pconv.cs) + 1, &pconv.s, 10);
200 exppart = strtol((pconv.cs) + 1, &pconv.s, 10);
201 radixpos += exppart / 4;
207 exppart = 1 << exppart;
219 digits = realloc(digits, len + 2 + (2 - radixpos));
220 memmove(digits + (2 - radixpos) + 1, digits, len + 1);
221 memset(digits,
'0', (2 - radixpos) + 1);
223 digits[1] = digits[2];
225 }
else if(radixpos > len) {
226 digits = realloc(digits, radixpos + 2);
227 memset(digits + len,
'0', radixpos - len);
228 digits[radixpos + 1] =
'\0';
230 memmove(digits + radixpos + 1, digits + radixpos, len - radixpos + 1);
232 digits[radixpos] = radix;
238 if(errno != ERANGE) {
244 digits[radixpos - 2] =
'0';
245 digits[radixpos - 1] =
'x';
325 while(*(--
end) ==
'0')
#define XLAL_BILLION_INT4
#define XLAL_BILLION_INT8
static int isbinaryexp(const char *s)
static int isbase16(const char *s, int radix)
static int isbase10(const char *s, int radix)
int XLALStrToGPS(LIGOTimeGPS *t, const char *nptr, char **endptr)
Parse an ASCII string into a LIGOTimeGPS structure.
static int isdecimalexp(const char *s)
char * XLALGPSToStr(char *s, const LIGOTimeGPS *t)
Return a string containing the ASCII base 10 representation of a LIGOTimeGPS.
#define XLAL_ERROR_NULL(...)
Macro to invoke a failure from a XLAL routine returning a pointer.
#define XLAL_ERROR(...)
Macro to invoke a failure from a XLAL routine returning an integer.
@ XLAL_ERANGE
Output range error.
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
Adds a double to a GPS time.
LIGOTimeGPS * XLALGPSSet(LIGOTimeGPS *epoch, INT4 gpssec, INT8 gpsnan)
Sets GPS time given GPS integer seconds and residual nanoseconds.
LIGOTimeGPS * XLALINT8NSToGPS(LIGOTimeGPS *epoch, INT8 ns)
Converts nano seconds stored as an INT8 to GPS time.
Epoch relative to GPS epoch, see LIGOTimeGPS type for more details.
INT4 gpsSeconds
Seconds since 0h UTC 6 Jan 1980.
INT4 gpsNanoSeconds
Residual nanoseconds.