29#include <lal/LALMalloc.h>
30#include <lal/LIGOLwXML.h>
31#include <lal/LIGOLwXMLRead.h>
32#include <lal/LIGOMetadataTables.h>
33#include <lal/LIGOMetadataUtils.h>
34#include <lal/XLALError.h>
51 new->time_slide_id = -1;
52 memset(new->instrument, 0,
sizeof(new->instrument));
95 const char *instrument
98 for(; time_slide && (time_slide->
time_slide_id != time_slide_id || strcmp(time_slide->
instrument, instrument)); time_slide = time_slide->
next);
117 const char *instrument
120 for(; time_slide && (time_slide->
time_slide_id != time_slide_id || strcmp(time_slide->
instrument, instrument)); time_slide = time_slide->
next);
133 static const char table_name[] =
"time_slide";
137 struct MetaioParseEnvironment env;
147 if(MetaioOpenFile(&env,
filename)) {
148 XLALPrintError(
"%s(): error opening \"%s\": %s\n", __func__,
filename, env.mierrmsg.data ? env.mierrmsg.data :
"unknown reason");
151 if(MetaioOpenTableOnly(&env, table_name)) {
153 XLALPrintError(
"%s(): cannot find %s table: %s\n", __func__, table_name, env.mierrmsg.data ? env.mierrmsg.data :
"unknown reason");
169 XLALPrintError(
"%s(): failure reading %s table\n", __func__, table_name);
175 while((miostatus = MetaioGetRow(&env)) > 0) {
189 next = &(*next)->
next;
193 row->
process_id = env.ligo_lw.table.elt[column_pos.process_id].data.int_8s;
194 row->
time_slide_id = env.ligo_lw.table.elt[column_pos.time_slide_id].data.int_8s;
195 strncpy(row->
instrument, env.ligo_lw.table.elt[column_pos.instrument].data.lstring.data,
sizeof(row->
instrument) - 1);
196 row->
offset = env.ligo_lw.table.elt[column_pos.offset].data.real_8;
201 XLALPrintError(
"%s(): I/O error parsing %s table: %s\n", __func__, table_name, env.mierrmsg.data ? env.mierrmsg.data :
"unknown reason");
207 if(MetaioClose(&env)) {
209 XLALPrintError(
"%s(): error parsing document after %s table: %s\n", __func__, table_name, env.mierrmsg.data ? env.mierrmsg.data :
"unknown reason");
227 const char *row_head =
"\n\t\t\t";
233 XLALFilePuts(
"\t\t<Column Name=\"process:process_id\" Type=\"int_8s\"/>\n", xml->
fp);
234 XLALFilePuts(
"\t\t<Column Name=\"time_slide_id\" Type=\"int_8s\"/>\n", xml->
fp);
235 XLALFilePuts(
"\t\t<Column Name=\"instrument\" Type=\"lstring\"/>\n", xml->
fp);
236 XLALFilePuts(
"\t\t<Column Name=\"offset\" Type=\"real_8\"/>\n", xml->
fp);
237 XLALFilePuts(
"\t\t<Stream Name=\"time_slide:table\" Type=\"Local\" Delimiter=\",\">", xml->
fp);
243 for(; time_slide; time_slide = time_slide->
next) {
246 row_head =
",\n\t\t\t";
int XLALLIGOLwFindColumn(struct MetaioParseEnvironment *env, const char *name, unsigned int type, int required)
Convenience wrapper for MetaioFindColumn(), translating to XLAL-style error reporting and printing us...
int XLALFilePuts(const char *s, LALFILE *file)
int XLALFilePrintf(LALFILE *file, const char *fmt,...)
void * XLALMalloc(size_t n)
#define XLAL_ERROR_NULL(...)
int XLALGetBaseErrno(void)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
This structure contains the file stream and current table type for writing to LIGO lightweight XML fi...
This structure corresponds to one row of a time_slide table.
CHAR instrument[LIGOMETA_STRING_MAX]
struct tagTimeSlide * next
TimeSlide * XLALCreateTimeSlide(void)
Create a TimeSlide structure.
const TimeSlide * XLALTimeSlideConstGetByIDAndInstrument(const TimeSlide *time_slide, long time_slide_id, const char *instrument)
Find and return the address of the first element in the linked list of TimeSlide objects whose time_s...
TimeSlide * XLALTimeSlideGetByIDAndInstrument(TimeSlide *time_slide, long time_slide_id, const char *instrument)
Find and return the address of the first element in the linked list of TimeSlide objects whose time_s...
TimeSlide * XLALDestroyTimeSlide(TimeSlide *row)
Destroy a TimeSlide structure.
TimeSlide * XLALTimeSlideTableFromLIGOLw(const char *filename)
Read the time_slide table from a LIGO Light Weight XML file into a linked list of TimeSlide structure...
int XLALWriteLIGOLwXMLTimeSlideTable(LIGOLwXMLStream *xml, const TimeSlide *time_slide)
Write a time_slide table to an XML file.
void XLALDestroyTimeSlideTable(TimeSlide *head)
Destroy a TimeSlide linked list.