Files
kospm/include/kospm_csv.h
Nikita Pikalov f76f191d62 Another commit of another iteration.
Another milestone: school project submission. Library doesn't work yet, though. Also licensing things, I guess
2025-04-19 03:33:07 +03:00

61 lines
1.6 KiB
C

/*
* kospm_csv.h
*
* Copyright 2025 keXa <nikitospikalov2008@gmail.com>
*
* 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 KOSPM_CSV
#define KOSPM_CSV
#include <stdio.h>
#include <stdlib.h>
#include "../lib/ccsv.h"
#include "kospm_list.h"
ccsv_reader_options kospm_csv_reader_options = {
.delim = ',',
.quote_char = '"',
.skip_initial_space = 1,
.skip_empty_lines = 1,
.skip_comments = 1
};
ccsv_reader_options kospm_csv_writer_options = {
.delim = ',',
.quote_char = '"'
};
typedef struct kospm_csv_header_col {
int col_number;
char *col_name;
} kospm_csv_header_col;
typedef struct kospm_csv_header {
kospm_list_t *col_list;
int col_amount;
} kospm_csv_header;
kospm_csv_header* kospm_csv_header_get(FILE* file);
int kospm_csv_col_get(kospm_csv_header *header, char* col_name);
char* kospm_csv_string_get(ccsv_row *row, kospm_csv_header *header, char* col_name);
#endif