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>
50 memset(new->program, 0,
sizeof(new->program));
55 memset(new->param, 0,
sizeof(new->param));
56 memset(new->type, 0,
sizeof(new->type));
57 memset(new->value, 0,
sizeof(new->value));
97 for(length = 0; head; head = head->
next)
112 static const char table_name[] =
"process_params";
116 struct MetaioParseEnvironment env;
127 if(MetaioOpenFile(&env,
filename)) {
128 XLALPrintError(
"%s(): error opening \"%s\": %s\n", __func__,
filename, env.mierrmsg.data ? env.mierrmsg.data :
"unknown reason");
131 if(MetaioOpenTableOnly(&env, table_name)) {
133 XLALPrintError(
"%s(): cannot find %s table: %s\n", __func__, table_name, env.mierrmsg.data ? env.mierrmsg.data :
"unknown reason");
150 XLALPrintError(
"%s(): failure reading %s table\n", __func__, table_name);
156 while((miostatus = MetaioGetRow(&env)) > 0) {
170 next = &(*next)->
next;
174 strncpy(row->
program, env.ligo_lw.table.elt[column_pos.program].data.lstring.data,
sizeof(row->
program) - 1);
175 row->
process_id = env.ligo_lw.table.elt[column_pos.process_id].data.int_8s;
176 strncpy(row->
param, env.ligo_lw.table.elt[column_pos.param].data.lstring.data,
sizeof(row->
param) - 1);
177 strncpy(row->
type, env.ligo_lw.table.elt[column_pos.type].data.lstring.data,
sizeof(row->
type) - 1);
178 strncpy(row->
value, env.ligo_lw.table.elt[column_pos.value].data.lstring.data,
sizeof(row->
value) - 1);
183 XLALPrintError(
"%s(): I/O error parsing %s table: %s\n", __func__, table_name, env.mierrmsg.data ? env.mierrmsg.data :
"unknown reason");
189 if(MetaioClose(&env)) {
191 XLALPrintError(
"%s(): error parsing document after %s table: %s\n", __func__, table_name, env.mierrmsg.data ? env.mierrmsg.data :
"unknown reason");
209 const char *row_head =
"\n\t\t\t";
214 XLALFilePuts(
"\t<Table Name=\"process_params:table\">\n", xml->
fp);
215 XLALFilePuts(
"\t\t<Column Name=\"program\" Type=\"lstring\"/>\n", xml->
fp);
216 XLALFilePuts(
"\t\t<Column Name=\"process:process_id\" Type=\"int_8s\"/>\n", xml->
fp);
217 XLALFilePuts(
"\t\t<Column Name=\"param\" Type=\"lstring\"/>\n", xml->
fp);
218 XLALFilePuts(
"\t\t<Column Name=\"type\" Type=\"lstring\"/>\n", xml->
fp);
219 XLALFilePuts(
"\t\t<Column Name=\"value\" Type=\"lstring\"/>\n", xml->
fp);
220 XLALFilePuts(
"\t\t<Stream Name=\"process_params:table\" Type=\"Local\" Delimiter=\",\">", xml->
fp);
226 for(; process_params; process_params = process_params->
next) {
227 if(
XLALFilePrintf(xml->
fp,
"%s\"%s\",%ld,\"%s\",\"%s\",\"%s\"", row_head, process_params->
program, process_params->
process_id, process_params->
param, process_params->
type, process_params->
value) < 0)
229 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
ProcessParamsTable * XLALProcessParamsTableFromLIGOLw(const char *filename)
Read the process_params table from a LIGO Light Weight XML file into a linked list of ProcessParamsTa...
ProcessParamsTable * XLALCreateProcessParamsTableRow(const ProcessTable *process)
Create a ProcessParamsTable structure.
int XLALWriteLIGOLwXMLProcessParamsTable(LIGOLwXMLStream *xml, const ProcessParamsTable *process_params)
Write a process_params table to an XML file.
void XLALDestroyProcessParamsTable(ProcessParamsTable *head)
Destroy a ProcessParamsTable linked list.
int XLALCountProcessParamsTable(ProcessParamsTable *head)
Count the number of rows in a ProcessParamsTable linked the list.
ProcessParamsTable * XLALDestroyProcessParamsTableRow(ProcessParamsTable *row)
Destroy a ProcessParamsTable structure.
This structure contains the file stream and current table type for writing to LIGO lightweight XML fi...
CHAR type[LIGOMETA_TYPE_MAX]
CHAR param[LIGOMETA_PARAM_MAX]
CHAR value[LIGOMETA_VALUE_MAX]
struct tagProcessParamsTable * next
CHAR program[LIGOMETA_PROGRAM_MAX]