/* * csv.h * * Copyright 2024 Michael Rasmussen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * */ #ifndef __CSV_H__ #define __CSV_H__ #ifdef HAVE_CONFIG_H # include #endif #include #include #include G_BEGIN_DECLS typedef struct _CsvParser CsvParser; typedef struct { gchar* sn; gchar* maker; gchar* data; gchar* notes; gchar* date; } Record; typedef struct { const gchar* file; bool write; bool first_line_header; bool overwrite; } Instructions; typedef struct { size_t line; gchar* message; } CvsError; CsvParser* csv_parser_new(Instructions* instructions, CvsError** error); Record* csv_parser_next_line(CsvParser* parser, CvsError** error); bool csv_parser_dump_row(CsvParser* parser, const Record* row, CvsError** error); void csv_parser_free(CsvParser* parser); CvsError* csv_error_new(); void csv_error_free(CvsError* error); void csv_error_clear(CvsError** error); void csv_record_print(Record* r); void csv_record_free(Record* r); G_END_DECLS #endif