Open a CSV File */
| 38 | |
| 39 | /* Open a CSV File */ |
| 40 | hb_csv_file_t *hb_open_csv_file( const char *filepath ) |
| 41 | { |
| 42 | hb_csv_file_t *file = NULL; |
| 43 | FILE * fileref; |
| 44 | |
| 45 | if( filepath == NULL ) |
| 46 | { |
| 47 | return file; |
| 48 | } |
| 49 | |
| 50 | fileref = hb_fopen(filepath, "r"); |
| 51 | if( fileref == NULL ) |
| 52 | { |
| 53 | return file; |
| 54 | } |
| 55 | |
| 56 | file = malloc( sizeof( hb_csv_file_t ) ); |
| 57 | if( file == NULL ) |
| 58 | { |
| 59 | return file; |
| 60 | } |
| 61 | |
| 62 | file->fileref = fileref; |
| 63 | file->eof = 0; |
| 64 | file->parse_state = CSV_PARSE_SEEK; |
| 65 | file->curr_col = 0; |
| 66 | file->curr_row = 0; |
| 67 | return file; |
| 68 | } |
| 69 | |
| 70 | void hb_close_csv_file( hb_csv_file_t *file ) |
| 71 | { |