LAL  7.5.0.1-b72065a
ConfigFile.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Reinhard Prix
3  * Copyright (C) 2010 Larne Pekowsky
4  * Copyright (C) 2004, 2005 Reinhard Prix
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with with program; see the file COPYING. If not, write to the
18  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301 USA
20  */
21 
22 #include <stdlib.h>
23 #include <string.h>
24 #include <stdio.h>
25 
26 #include <lal/LALStdlib.h>
27 #include <lal/LALError.h>
28 #include <lal/LALStdio.h>
29 #include <lal/LALString.h>
30 #include <lal/FileIO.h>
31 #include <lal/StreamInput.h>
32 #include <lal/AVFactories.h>
33 #include <lal/StringVector.h>
34 
35 #include <lal/UserInputParse.h>
36 
37 #include <lal/ConfigFile.h>
38 
39 // ---------- local defines ----------
40 #define WHITESPACE " \t"
41 
42 #define TRUE (1==1)
43 #define FALSE (1==0)
44 
45 // ---------- local prototypes ----------
46 static void cleanConfig ( char *text );
47 static CHAR *XLALGetSectionName ( const CHAR *line );
48 
49 // ==================== function definitions ==========
50 /**
51  * Parse an ASCII data-file into a pre-cleaned array of lines.
52  * The cleaning gets rid of comments ('\#', '\%'), empty lines,
53  * and performs line-continuation if '\\' is found at EOL
54  *
55  * NOTE: This function can transparently detect and read gzip-compressed
56  * data-files, independently of filename-extension
57  *
58  * NOTE2: allows passing of *file-contents* directly instead of filename to read
59  * by passing a string like "{ file-contents }" instead of a file-path,
60  * ie if first character == '{' and last character == '}'
61  * This is useful to allow ascii-file user inputs to be transparently
62  * passed as filenames or direct contents
63  */
64 int
65 XLALParseDataFile (LALParsedDataFile **cfgdata, /**< [out] pre-parsed data-file lines */
66  const CHAR *path /**< [in] file-path of config-file to be read */
67  )
68 {
69  XLAL_CHECK ( (cfgdata != NULL) && (*cfgdata == NULL), XLAL_EINVAL );
70  XLAL_CHECK ( path != NULL, XLAL_EINVAL );
71 
72  char *dataBuffer;
73  if ( (path[0] == '{') && (path[strlen(path)-1] == '}') )
74  {
75  XLAL_CHECK ( (dataBuffer = XLALStringDuplicate ( path + 1 )) != NULL, XLAL_EFUNC );
76  dataBuffer[strlen(dataBuffer)-1] = 0;
77  }
78  else
79  {
80  XLAL_CHECK ( (dataBuffer = XLALFileLoad ( path )) != NULL, XLAL_EFUNC );
81  }
82 
83  if ( XLALParseDataFileContent ( cfgdata, dataBuffer ) != XLAL_SUCCESS ) {
84  XLALFree ( dataBuffer );
86  }
87 
88  XLALFree ( dataBuffer );
89 
90  return XLAL_SUCCESS;
91 
92 } /* XLALParseDataFile() */
93 
94 int
95 XLALParseDataFileContent (LALParsedDataFile **cfgdata, /**< [out] pre-parsed data-file lines */
96  const CHAR *string /**< [in] string-contents of config-file: can get modified! */
97  )
98 {
99  XLAL_CHECK ( (cfgdata != NULL) && (*cfgdata == NULL), XLAL_EINVAL );
100  XLAL_CHECK ( string != NULL, XLAL_EINVAL );
101 
102  char *rawdata;
103  XLAL_CHECK ( (rawdata = XLALMalloc ( strlen(string) + 1 )) != NULL, XLAL_ENOMEM );
104  strcpy ( rawdata, string ); // keep local copy for modifying
105 
106  /* get rid of comments and do line-continuation */
107  cleanConfig ( rawdata );
108 
109  LALParsedDataFile *cfg;
110  XLAL_CHECK ( (cfg = XLALCalloc (1, sizeof(*cfg))) != NULL, XLAL_ENOMEM );
111 
112  /* parse this into individual lines */
113  int err = XLALCreateTokenList ( &(cfg->lines), rawdata, "\n");
114  if (err) {
115  XLALFree (cfg);
116  XLALFree (rawdata);
117  XLAL_ERROR ( XLAL_EFUNC, "XLALCreateTokenList() failed.\n" );
118  }
119  XLALFree (rawdata);
120 
121  /* initialize the 'wasRead' flags for the lines */
122  if ( cfg->lines->nTokens )
123  {
124  int len = cfg->lines->nTokens * sizeof(cfg->wasRead[0]);
125  if ( (cfg->wasRead = XLALCalloc(1, len )) == NULL )
126  {
127  XLALFree (cfg->lines);
128  XLALFree (cfg);
129  XLAL_ERROR ( XLAL_ENOMEM, "XLALCalloc(1,%d) failed.\n", len );
130  }
131  }
132  else {
133  cfg->wasRead = NULL;
134  }
135 
136  (*cfgdata) = cfg;
137 
138  return XLAL_SUCCESS;
139 
140 } // XLALParseDataFileContent()
141 
142 
143 /**
144  * Free memory associated with a LALParsedDataFile structure.
145  */
146 void
147 XLALDestroyParsedDataFile (LALParsedDataFile *cfgdata) /**< [in] config-file data */
148 {
149  if ( cfgdata == NULL ) {
150  return;
151  }
152 
153  XLALDestroyTokenList ( cfgdata->lines );
154  XLALFree ( cfgdata->wasRead );
155  XLALFree ( cfgdata );
156 
157  return;
158 } /* XLALDestroyParsedDataFile() */
159 
160 
161 /**
162  * Function to determine whether a given section secName exists in the parsed
163  * config-file contents cfgdata.
164  *
165  * \note: this function tolerates NULL input as secName, cfgdata, or cfgdata->lines,
166  * in which case the answer is simply 'FALSE'.
167  *
168  * NOTE2: quite inefficient implementation, re-creates table of content each time it's called
169  * however this function also doesn't seem to be used right now and should probably be removed?
170  */
171 int
172 XLALConfigSectionExists ( const LALParsedDataFile *cfgdata, /**< [in] pre-parsed config-data */
173  const CHAR *secName) /**< [in] section-name to read */
174 {
175  /* If there's no config file, or no section, then */
176  /* the section isn;t in the config file, return 0 */
177  if ( secName == NULL || cfgdata == NULL || cfgdata->lines == NULL )
178  {
179  return 0;
180  }
181 
182  CHAR *secName_cleaned;
183  XLAL_CHECK ( (secName_cleaned = XLALDeblankString ( secName, strlen(secName) )) != NULL, XLAL_EFUNC );
184 
185  LALStringVector *toc;
186  XLAL_CHECK ( (toc = XLALListConfigFileSections ( cfgdata )) != NULL, XLAL_EFUNC );
187 
188  int foundit = 0;
189  for ( UINT4 i = 0; i < toc->length; i ++ )
190  {
191  if ( strcmp ( secName_cleaned, toc->data[i] ) == 0 )
192  {
193  foundit = 1;
194  break;
195  }
196  }
197 
198  XLALDestroyStringVector ( toc );
199  XLALFree ( secName_cleaned );
200 
201  return foundit;
202 
203 } /* XLALConfigSectionExists() */
204 
205 /**
206  * Function to find all sections in given config-file contents cfgdata.
207  *
208  * A section start is defined by a string "[ section-name ]" found at the beginning of a line
209  * The first non-section part of a config-file is referred to as the "default" section,
210  * which is included in the returned list of section-names provided it is not empty.
211  *
212  */
214 XLALListConfigFileSections ( const LALParsedDataFile *cfgdata ) /**< [in] pre-parsed config-data */
215 {
216  XLAL_CHECK_NULL ( (cfgdata != NULL) && ( cfgdata->lines != NULL), XLAL_EINVAL );
217 
218  const TokenList *lines = cfgdata->lines;
219 
220  LALStringVector *sections;
221  XLAL_CHECK_NULL ( (sections = XLALCalloc ( 1, sizeof(*sections) ) ) != NULL, XLAL_ENOMEM ); // empty string vector
222 
223  if ( lines->tokens[0][0] != '[' ) // there is a non-empty 'default' section
224  {
225  XLAL_CHECK_NULL ( (sections = XLALAppendString2Vector ( sections, "default" )) != NULL, XLAL_EFUNC );
226  } // if non-empty default section
227 
228  for ( UINT4 i = 0; i < lines->nTokens; i++ )
229  {
230  const CHAR *thisLine = lines->tokens[i];
231  XLAL_CHECK_NULL ( thisLine != NULL, XLAL_EINVAL );
232  /* Is this the start of a new section? */
233  if ( thisLine[0] == '[' )
234  {
235  CHAR *secName;
236  XLAL_CHECK_NULL ( (secName = XLALGetSectionName ( thisLine )) != NULL, XLAL_EFUNC );
237  XLAL_CHECK_NULL ( (sections = XLALAppendString2Vector ( sections, secName )) != NULL, XLAL_EFUNC );
238  XLALFree ( secName );
239  } // if section found
240 
241  } // for i < numLines
242 
243  return sections;
244 
245 } // XLALListConfigFileSections()
246 
247 
248 // local helper function: check section syntax '[...]' and extract de-blanked section name
249 static CHAR *
250 XLALGetSectionName ( const CHAR *line )
251 {
252  XLAL_CHECK_NULL ( line != NULL, XLAL_EINVAL );
253 
254  CHAR *lineCleaned = XLALDeblankString ( line, strlen(line) );
255  size_t lenLine = strlen ( lineCleaned );
256  if ( lineCleaned[0] != '[' || lineCleaned[lenLine-1] != ']' ) {
257  XLALPrintError ( "Invalid input line '%s' is not of the form '[...]' specifying a section name\n", lineCleaned );
258  XLALFree ( lineCleaned );
260  }
261 
262  CHAR *secName;
263  XLAL_CHECK_NULL ( (secName = XLALDeblankString ( lineCleaned+1, lenLine - 2 )) != NULL, XLAL_EFUNC );
264  XLALFree ( lineCleaned );
265 
266  return secName;
267 
268 } // XLALGetSectionName()
269 
270 /**
271  * String parser for config-file: can read config-variables of the form VARIABLE [=:] VALUE.
272  * Input is a TokenList containing the 'logical' lines of the cleaned config-file
273  *
274  * \note Opening and closing quotes (\' or \") are removed from the returned string.
275  */
276 int
277 XLALReadConfigSTRINGVariable ( CHAR **varp, //!< [out] return string value if found (NULL otherwise)
278  LALParsedDataFile *cfgdata, //!< [in,out] pre-parsed config-data
279  const CHAR * secName, //!< [in] section name in which to find variable 'varName', NULL='default' section
280  const CHAR * varName, //!< [in] variable name to be read
281  BOOLEAN *wasRead //!< [out] did we succeed in reading? */
282  )
283 {
284  // check input consistency
285  XLAL_CHECK ( (varp != NULL) && (*varp == NULL), XLAL_EINVAL );
286  XLAL_CHECK ( cfgdata != NULL, XLAL_EINVAL );
287  XLAL_CHECK ( cfgdata->lines != NULL, XLAL_EINVAL );
288  XLAL_CHECK ( cfgdata->lines->nTokens > 0, XLAL_EINVAL );
289  XLAL_CHECK ( cfgdata->wasRead != NULL, XLAL_EINVAL );
290 
291  BOOLEAN inRightSection = FALSE;
292 
293  (*wasRead) = FALSE;
294 
295  // If we haven't been asked for a section then we want the
296  // "default" section, which starts at the top of the file without any section heading
297  CHAR *secName_cleaned = NULL;
298  if ( secName == NULL )
299  {
300  inRightSection = TRUE;
301  }
302  else
303  {
304  XLAL_CHECK ( (secName_cleaned = XLALDeblankString ( secName, strlen(secName) )) != NULL, XLAL_EFUNC );
305  }
306 
307  /* find the variable-name in the token-list (and in the right section, if given) */
308  size_t searchlen = strlen ( varName );
309 
310  for ( UINT4 i = 0; i < cfgdata->lines->nTokens; i++ )
311  {
312  if (cfgdata->lines->tokens[i][0] == '[') /* Is this the start of a new section? */
313  {
314  if ( inRightSection ) {
315  // if we previously were in the right section, it means we've now left it
316  // and therefore didn't find the variable we were looking for, so we return,
317  // but this is not an error!
318  return XLAL_SUCCESS;
319  }
320 
321  CHAR *thisSec = XLALGetSectionName ( cfgdata->lines->tokens[i] );
322  XLAL_CHECK ( thisSec != NULL, XLAL_EFUNC );
323  if ( (secName_cleaned != NULL) && ( strcmp ( secName_cleaned, thisSec ) == 0 ) )
324  {
325  inRightSection = TRUE;
326  }
327  XLALFree ( thisSec );
328  } // end: if start of new section found
329  else
330  {
331  if ( !inRightSection ) {
332  continue;
333  }
334 
335  UINT4 varlen = strcspn ( cfgdata->lines->tokens[i], WHITESPACE "=:" ); /* get length of variable-name */
336  XLAL_CHECK ( varlen > 0, XLAL_EDOM, "Parsing error: nonexistent variable name in '%s'\n", cfgdata->lines->tokens[i] );
337 
338  // pre-select based on length of variable-name
339  if ( varlen != searchlen ) {
340  continue;
341  }
342 
343  // same len, but are they identical ?
344  if ( strncmp ( varName, cfgdata->lines->tokens[i], varlen ) == 0 )
345  {
346  char *strVal = cfgdata->lines->tokens[i] + varlen;
347  strVal += strspn ( strVal, WHITESPACE "=:" ); // skip all whitespace and define-chars
348  XLAL_CHECK ( XLALParseStringValueAsSTRING ( varp, strVal ) == XLAL_SUCCESS, XLAL_EFUNC ); // copy and remove quotes (if any)
349  cfgdata->wasRead[i] = 1;
350  (*wasRead) = TRUE;
351  break; // exit loop, we've found it
352  } // end: if found variable
353 
354  } // end: if in right section
355 
356  } // end: for i < num_lines
357 
358  XLALFree ( secName_cleaned );
359 
360  return XLAL_SUCCESS;
361 
362 } // XLALReadConfigSTRINGVariable()
363 
364 // ------------------------------------------------------------
365 // define type-specific wrappers to the generic XLALReadConfigSTRINGVariable() function,
366 // using a template macro:
367 #define DEFINE_XLALREADCONFIGVARIABLE(TYPE,CTYPE) \
368 DECLARE_XLALREADCONFIGVARIABLE(TYPE,CTYPE) \
369 { \
370  /* first read the value as a string */ \
371  CHAR *valString = NULL; \
372  XLAL_CHECK ( XLALReadConfigSTRINGVariable ( &valString, cfgdata, secName, varName, wasRead ) == XLAL_SUCCESS, XLAL_EFUNC ); \
373  if ( ! (*wasRead ) ) { \
374  return XLAL_SUCCESS; \
375  } \
376  XLAL_CHECK ( XLALParseStringValueAs ##TYPE ( varp, valString ) == XLAL_SUCCESS, XLAL_EFUNC ); \
377  XLALFree (valString); \
378  return XLAL_SUCCESS; \
379 }
380 
391 // ------------------------------------------------------------
392 
393 
394 /**
395  * Return a list of unread config-file entries, NULL if none found (without error).
396  */
397 UINT4Vector *
398 XLALConfigFileGetUnreadEntries ( const LALParsedDataFile *cfgdata ///< [in] config-file data
399  )
400 {
401  XLAL_CHECK_NULL ( cfgdata != NULL, XLAL_EINVAL );
402  XLAL_CHECK_NULL ( cfgdata->lines != NULL, XLAL_EINVAL );
403  XLAL_CHECK_NULL ( cfgdata->lines->nTokens > 0, XLAL_EINVAL );
404  XLAL_CHECK_NULL ( cfgdata->wasRead != NULL, XLAL_EINVAL );
405 
406  UINT4Vector *ret;
407  XLAL_CHECK_NULL ( (ret = XLALCalloc ( 1, sizeof(*ret))) != NULL, XLAL_ENOMEM );
408 
409  for (UINT4 i=0; i < cfgdata->lines->nTokens; i++)
410  {
411  // We don't require section headers to be marked as read
412  // ie we consider the config-file to be fully read/parsed if
413  // if every value in every section has been parsed.
414  if (cfgdata->lines->tokens[i][0] == '[') {
415  continue;
416  }
417 
418  if ( ! cfgdata->wasRead[i] ) {
419  ret->length ++;
420  XLAL_CHECK_NULL ( (ret->data = XLALRealloc ( ret->data, ret->length * sizeof(ret->data[0]) )) != NULL, XLAL_ENOMEM );
421  ret->data[ret->length-1] = i;
422  }
423 
424  } // for i < numLines
425 
426  if ( ret->length == 0 )
427  {
428  XLALFree ( ret );
429  ret = NULL;
430  }
431 
432  return ret;
433 
434 } // XLALConfigFileGetUnreadEntries()
435 
436 /*----------------------------------------------------------------------*/
437 
438 
439 /* ----------------------------------------------------------------------
440  * cleanConfig(): do some preprocessing on the config-file, namely 'erase'
441  * all comments by '\n', and glue '\'-continued lines
442  *----------------------------------------------------------------------*/
443 void
444 cleanConfig ( char *text )
445 {
446  if ( text == NULL ) {
447  return;
448  }
449 
450  size_t len;
451  CHAR *ptr, *ptr2, *eol;
452  BOOLEAN inQuotes = 0;
453  INT4 inBracesCount = 0;
454  /*----------------------------------------------------------------------
455  * RUN 1: clean out comments, by replacing them by '\n'
456  */
457  ptr = text;
458  while ( *ptr )
459  {
460  if ( (*ptr) == '\"' ) {
461  inQuotes = !inQuotes; /* flip state */
462  }
463  if ( (*ptr) == '{' ) {
464  inBracesCount ++;
465  }
466  if ( (*ptr) == '}' ) {
467  inBracesCount --;
468  }
469 
470  if ( ((*ptr) == '#') || ( (*ptr) == '%') ) {
471  if ( !inQuotes ) /* only consider as comments if not quoted */
472  {
473  len = strcspn (ptr, "\n");
474  memset ( (void*)ptr, '\n', len);
475  }
476  }
477 
478  // replace un-quoted ';' {iff outside of any braces} by '\n' to allow semi-colons to separate assignments
479  if ( (!inQuotes) && (inBracesCount == 0) && ((*ptr) == ';') ) {
480  (*ptr) = '\n';
481  }
482  // replace DOS-style '\r' EOL characters by '\n'
483  if ( (*ptr) == '\r' ) {
484  (*ptr) = '\n';
485  }
486 
487  ptr ++;
488 
489  } /* while *ptr */
490 
491  /*----------------------------------------------------------------------
492  * RUN 2: do line-gluing when '\' is found at end-of-line
493  */
494  ptr = text;
495  while ( (ptr = strchr(ptr, '\\')) != NULL )
496  {
497  if ( ptr[1] == '\n' )
498  {
499  /* ok, now it gets a bit tricky: to avoid getting spurious spaces from
500  * the line-continuation, we shift the rest of the file forward by 2 positions
501  * to nicely fit to the previous line...
502  */
503  len = strlen (ptr+2);
504  memmove(ptr, ptr+2, len+1); /* move the whole rest (add +1 for '\0') */
505  }
506  else
507  {
508  ptr ++;
509  }
510  } /* while '\' found in text */
511 
512  /*----------------------------------------------------------------------
513  * RUN 3: turn all tabs into single spaces..
514  */
515  ptr = text;
516  while ( (ptr = strchr(ptr, '\t')) != NULL ) {
517  *ptr = ' ';
518  }
519 
520  /*----------------------------------------------------------------------
521  * RUN 4: get rid of initial and trailing whitespace (replace it by '\n')
522  */
523  ptr = text;
524  char *endptr = text + strlen(text); // points to closing '\0' character in input-string
525  while (ptr < endptr )
526  {
527  eol = strchr (ptr, '\n'); /* point to end-of-line */
528 
529  len = strspn (ptr, WHITESPACE);
530  if (len) { memset ( (void*)ptr, '\n', len); }
531 
532  if (eol != NULL) {
533  ptr = eol;
534  }
535  else {
536  ptr = strchr (ptr, '\0'); /* or end of file */
537  }
538 
539  /* clean away all trailing whitespace of last line*/
540  ptr2 = ptr - 1;
541  while ( ptr2 >= text && ( strspn ( ptr2, WHITESPACE ) != 0 ) ) {
542  *ptr2-- = '\n';
543  }
544 
545  /* step to next line */
546  ptr += 1;
547  } // while ptr < end
548 
549  return;
550 
551 } /* cleanConfig() */
int XLALReadConfigSTRINGVariable(CHAR **varp, LALParsedDataFile *cfgdata, const CHAR *secName, const CHAR *varName, BOOLEAN *wasRead)
String parser for config-file: can read config-variables of the form VARIABLE [=:] VALUE.
Definition: ConfigFile.c:277
#define TRUE
Definition: ConfigFile.c:42
#define FALSE
Definition: ConfigFile.c:43
#define WHITESPACE
Definition: ConfigFile.c:40
static void cleanConfig(char *text)
Definition: ConfigFile.c:444
static CHAR * XLALGetSectionName(const CHAR *line)
Definition: ConfigFile.c:250
#define DEFINE_XLALREADCONFIGVARIABLE(TYPE, CTYPE)
Definition: ConfigFile.c:367
void XLALDestroyTokenList(TokenList *list)
See StringToken.c for documentation.
Definition: StringToken.c:262
int XLALCreateTokenList(TokenList **list, const CHAR *string, const CHAR *delimiters)
Split given input string into a list of 'tokens' separated by any of the characters given in 'delimit...
Definition: StringToken.c:168
int XLALPrintError(const char *fmt,...)
Definition: XLALError.c:68
UINT4Vector * XLALConfigFileGetUnreadEntries(const LALParsedDataFile *cfgdata)
Return a list of unread config-file entries, NULL if none found (without error).
Definition: ConfigFile.c:398
int XLALParseDataFileContent(LALParsedDataFile **cfgdata, const CHAR *string)
Definition: ConfigFile.c:95
int XLALParseDataFile(LALParsedDataFile **cfgdata, const CHAR *path)
Parse an ASCII data-file into a pre-cleaned array of lines.
Definition: ConfigFile.c:65
int XLALConfigSectionExists(const LALParsedDataFile *cfgdata, const CHAR *secName)
Function to determine whether a given section secName exists in the parsed config-file contents cfgda...
Definition: ConfigFile.c:172
LALStringVector * XLALListConfigFileSections(const LALParsedDataFile *cfgdata)
Function to find all sections in given config-file contents cfgdata.
Definition: ConfigFile.c:214
void XLALDestroyParsedDataFile(LALParsedDataFile *cfgdata)
Free memory associated with a LALParsedDataFile structure.
Definition: ConfigFile.c:147
char * XLALFileLoad(const char *path)
Read a complete data-file into memory as a string.
Definition: FileIO.c:235
unsigned char BOOLEAN
Boolean logical type, see Headers LAL(Atomic)Datatypes.h for more details.
uint64_t UINT8
Eight-byte unsigned integer; on some platforms this is equivalent to unsigned long int instead.
double REAL8
Double precision real floating-point number (8 bytes).
int64_t INT8
Eight-byte signed integer; on some platforms this is equivalent to long int instead.
char CHAR
One-byte signed integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint32_t UINT4
Four-byte unsigned integer.
int32_t INT4
Four-byte signed integer.
#define XLALMalloc(n)
Definition: LALMalloc.h:44
#define XLALCalloc(m, n)
Definition: LALMalloc.h:45
#define XLALFree(p)
Definition: LALMalloc.h:47
#define XLALRealloc(p, n)
Definition: LALMalloc.h:46
char * XLALStringDuplicate(const char *s)
Like strdup but uses LAL allocation routines (free with LALFree).
Definition: LALString.c:89
LALStringVector * XLALAppendString2Vector(LALStringVector *vect, const CHAR *string)
Append the given string to the string-vector (XLAL interface), return pointer to the resulting string...
Definition: StringVector.c:47
char * XLALDeblankString(const CHAR *start, UINT4 len)
Copy (and allocate) string from 'start' with length 'len', removing all starting- and trailing blanks...
Definition: StringVector.c:330
void XLALDestroyStringVector(LALStringVector *vect)
XLAL-interface: Free a string-vector ;)
Definition: StringVector.c:204
int XLALParseStringValueAsSTRING(CHAR **out, const CHAR *valStr)
Duplicate string 'in', removing surrounding quotes " or \' if present.
#define XLAL_ERROR_NULL(...)
Macro to invoke a failure from a XLAL routine returning a pointer.
Definition: XLALError.h:713
#define XLAL_ERROR(...)
Macro to invoke a failure from a XLAL routine returning an integer.
Definition: XLALError.h:700
#define XLAL_CHECK(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns an integ...
Definition: XLALError.h:810
#define XLAL_CHECK_NULL(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns a pointe...
Definition: XLALError.h:825
@ XLAL_ENOMEM
Memory allocation error.
Definition: XLALError.h:407
@ XLAL_SUCCESS
Success return value (not an error number)
Definition: XLALError.h:401
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.
Definition: XLALError.h:462
@ XLAL_EDOM
Input domain error.
Definition: XLALError.h:410
@ XLAL_EINVAL
Invalid argument.
Definition: XLALError.h:409
This structure is returned by XLALParseDataFile() and holds the contents of an ASCII data-file in a p...
Definition: ConfigFile.h:107
TokenList * lines
list of pre-parsed data-file lines
Definition: ConfigFile.h:108
BOOLEAN * wasRead
keep track of successfully read lines
Definition: ConfigFile.h:109
Vector of type CHAR*, ie 'strings', see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:82
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:86
CHAR ** data
Pointer to the data array.
Definition: LALDatatypes.h:87
Epoch relative to GPS epoch, see LIGOTimeGPS type for more details.
Definition: LALDatatypes.h:458
This structure stores a number of null-terminated strings of arbitrary length.
Definition: StringInput.h:135
CHAR ** tokens
A list of pointers to the individual tokens; the elements tokens[0..nTokens-1] point to tokens,...
Definition: StringInput.h:137
UINT4 nTokens
The number of tokens in the list.
Definition: StringInput.h:136
Vector of type UINT4, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:118
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:122
UINT4 * data
Pointer to the data array.
Definition: LALDatatypes.h:123