mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-23 16:08:43 +00:00
iterate on stdio/mmap lrec-reader abstraction
This commit is contained in:
parent
62cb323f03
commit
5b77eb214a
10 changed files with 18 additions and 10 deletions
|
|
@ -6,7 +6,7 @@
|
|||
#include "mapping/context.h"
|
||||
#include "input/file_reader_mmap.h"
|
||||
|
||||
typedef lrec_t* lrec_reader_mmap_process_func_t(file_reader_mmap_state_t* pfh, void* pvstate, context_t* pctx);
|
||||
typedef lrec_t* lrec_reader_mmap_process_func_t(void* pvhandle, void* pvstate, context_t* pctx);
|
||||
typedef void lrec_reader_mmap_sof_func_t(void* pvstate);
|
||||
|
||||
typedef struct _lrec_reader_mmap_t {
|
||||
|
|
|
|||
|
|
@ -151,7 +151,8 @@ static lrec_t* lrec_reader_mmap_csv_get_record(file_reader_mmap_state_t* phandle
|
|||
return prec;
|
||||
}
|
||||
|
||||
static lrec_t* lrec_reader_mmap_csv_process(file_reader_mmap_state_t* phandle, void* pvstate, context_t* pctx) {
|
||||
static lrec_t* lrec_reader_mmap_csv_process(void* pvhandle, void* pvstate, context_t* pctx) {
|
||||
file_reader_mmap_state_t* phandle = pvhandle;
|
||||
lrec_reader_mmap_csv_state_t* pstate = pvstate;
|
||||
|
||||
while (TRUE) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ typedef struct _lrec_reader_mmap_dkvp_state_t {
|
|||
} lrec_reader_mmap_dkvp_state_t;
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
static lrec_t* lrec_reader_mmap_dkvp_process(file_reader_mmap_state_t* phandle, void* pvstate, context_t* pctx) {
|
||||
static lrec_t* lrec_reader_mmap_dkvp_process(void* pvhandle, void* pvstate, context_t* pctx) {
|
||||
file_reader_mmap_state_t* phandle = pvhandle;
|
||||
lrec_reader_mmap_dkvp_state_t* pstate = pvstate;
|
||||
if (phandle->sol >= phandle->eof) // xxx encapsulate a method for this ...
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ typedef struct _lrec_reader_mmap_nidx_state_t {
|
|||
} lrec_reader_mmap_nidx_state_t;
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
static lrec_t* lrec_reader_mmap_nidx_process(file_reader_mmap_state_t* phandle, void* pvstate, context_t* pctx) {
|
||||
static lrec_t* lrec_reader_mmap_nidx_process(void* pvhandle, void* pvstate, context_t* pctx) {
|
||||
file_reader_mmap_state_t* phandle = pvhandle;
|
||||
lrec_reader_mmap_nidx_state_t* pstate = pvstate;
|
||||
if (phandle->sol >= phandle->eof) // xxx encapsulate a method for this ...
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ typedef struct _lrec_reader_mmap_xtab_state_t {
|
|||
} lrec_reader_mmap_xtab_state_t;
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
static lrec_t* lrec_reader_mmap_xtab_process(file_reader_mmap_state_t* phandle, void* pvstate, context_t* pctx) {
|
||||
static lrec_t* lrec_reader_mmap_xtab_process(void* pvhandle, void* pvstate, context_t* pctx) {
|
||||
file_reader_mmap_state_t* phandle = pvhandle;
|
||||
lrec_reader_mmap_xtab_state_t* pstate = pvstate;
|
||||
|
||||
if (phandle->sol >= phandle->eof)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "containers/lrec.h"
|
||||
#include "mapping/context.h"
|
||||
|
||||
typedef lrec_t* lrec_reader_stdio_process_func_t(FILE* fp, void* pvstate, context_t* pctx);
|
||||
typedef lrec_t* lrec_reader_stdio_process_func_t(void* pvhandle, void* pvstate, context_t* pctx);
|
||||
typedef void lrec_reader_stdio_sof_func_t(void* pvstate);
|
||||
typedef void lrec_reader_stdio_free_func_t(void* pvstate);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ typedef struct _lrec_reader_stdio_csv_state_t {
|
|||
//
|
||||
// etc.
|
||||
|
||||
static lrec_t* lrec_reader_stdio_csv_process(FILE* input_stream, void* pvstate, context_t* pctx) {
|
||||
static lrec_t* lrec_reader_stdio_csv_process(void* pvhandle, void* pvstate, context_t* pctx) {
|
||||
FILE* input_stream = pvhandle;
|
||||
lrec_reader_stdio_csv_state_t* pstate = pvstate;
|
||||
|
||||
while (TRUE) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ typedef struct _lrec_reader_stdio_dkvp_state_t {
|
|||
} lrec_reader_stdio_dkvp_state_t;
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
static lrec_t* lrec_reader_stdio_dkvp_process(FILE* input_stream, void* pvstate, context_t* pctx) {
|
||||
static lrec_t* lrec_reader_stdio_dkvp_process(void* pvhandle, void* pvstate, context_t* pctx) {
|
||||
FILE* input_stream = pvhandle;
|
||||
lrec_reader_stdio_dkvp_state_t* pstate = pvstate;
|
||||
|
||||
char* line = mlr_get_line(input_stream, pstate->irs);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ typedef struct _lrec_reader_stdio_nidx_state_t {
|
|||
} lrec_reader_stdio_nidx_state_t;
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
static lrec_t* lrec_reader_stdio_nidx_process(FILE* input_stream, void* pvstate, context_t* pctx) {
|
||||
static lrec_t* lrec_reader_stdio_nidx_process(void* pvhandle, void* pvstate, context_t* pctx) {
|
||||
FILE* input_stream = pvhandle;
|
||||
lrec_reader_stdio_nidx_state_t* pstate = pvstate;
|
||||
char* line = mlr_get_line(input_stream, pstate->irs);
|
||||
if (line == NULL)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ typedef struct _lrec_reader_stdio_xtab_state_t {
|
|||
} lrec_reader_stdio_xtab_state_t;
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
static lrec_t* lrec_reader_stdio_xtab_process(FILE* input_stream, void* pvstate, context_t* pctx) {
|
||||
static lrec_t* lrec_reader_stdio_xtab_process(void* pvhandle, void* pvstate, context_t* pctx) {
|
||||
FILE* input_stream = pvhandle;
|
||||
lrec_reader_stdio_xtab_state_t* pstate = pvstate;
|
||||
|
||||
if (pstate->at_eof)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue