2. Csv
The csv(3m) module parses the popular comma separated values (CSV) format exported by applications like spreadsheets.
2.1. Csv functions
The csv_row_parse function
Synopsis
#include <mba/csv.h>
int csv_row_parse(const char *src, size_t sn, char *buf, size_t bn, char *row[], int rn, int trim)
Description
Parse a line of text at src for no more than sn bytes and place pointers to zero terminiated strings allocated from no more than bn bytes of the memory at buf into the array row for at most rn data elements.
Returns
The csv_row_parse function returns the number of bytes of src parsed or -1 if an error occured in which case errno will be set appropriately.
The csv_row_fread function
Synopsis
#include <mba/csv.h>
int csv_row_fread(FILE *in, char *buf, size_t bn, char *row[], int numcols, int trim)
Description
Read a line of text from the stream in and place pointers to zero terminiated strings allocated from no more than bn bytes of the memory at buf into the array row for at most rn data elements.
Returns
The csv_row_fread function returns the number of bytes read from the stream in or -1 if an error occured in which case errno will be set appropriately.
Copyright 2003 Michael B. Allen <mballen@erols.com>