This commit is contained in:
Liam Waldron 2023-10-25 11:46:12 -04:00
parent 9f9476c233
commit 1ce2a2a9a2
2 changed files with 53 additions and 5 deletions

27
src/csvparser.h Normal file
View File

@ -0,0 +1,27 @@
/*
csvparser.h - function declarations
This file is part of libcsvparser.
libcsvparser is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
libcsvparser 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 Lesser General Public License
for more details.
You should have received a copy of the GNU Lesser General Public License
along with mp3fw. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef CSVPARSER_H_
#define CSVPARSER_H_
#define MAXCHAR 1000
int parse_tokens(char *file);
#endif

View File

@ -1,24 +1,44 @@
/*
libcsvparser.c - simple CSV parser
*/
libcsvparer.c - csv parsing library
This file is part of libcsvparser.
libcsvparser is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
libcsvparser 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 Lesser General Public License
for more details.
You should have received a copy of the GNU Lesser General Public License
along with mp3fw. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "csvparser.h"
#define MAXCHAR 1000
int
parse_tokens(char *file)
{
int return_value;
FILE *fp;
char row[MAXCHAR];
char *token;
fp = fopen(file, "r");
if (fp == NULL) {
printf("csv file %s not found\n", file);
return 1;
return_value = 1;
return return_value;
}
while (feof(fp) != true) {
@ -31,5 +51,6 @@ parse_tokens(char *file)
}
}
return 0;
return_value = 0;
return return_value;
}