|
|
1.1 ! root 1: /* dat_file.h */ ! 2: ! 3: /* Functions to deal with comma (CSV) and tab-delimited files and lists */ ! 4: ! 5: /* $Id: dat_file.h,v 1.3 2005/05/05 01:57:17 rswindell Exp $ */ ! 6: ! 7: /**************************************************************************** ! 8: * @format.tab-size 4 (Plain Text/Source Code File Header) * ! 9: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * ! 10: * * ! 11: * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html * ! 12: * * ! 13: * This library is free software; you can redistribute it and/or * ! 14: * modify it under the terms of the GNU Lesser General Public License * ! 15: * as published by the Free Software Foundation; either version 2 * ! 16: * of the License, or (at your option) any later version. * ! 17: * See the GNU Lesser General Public License for more details: lgpl.txt or * ! 18: * http://www.fsf.org/copyleft/lesser.html * ! 19: * * ! 20: * Anonymous FTP access to the most recent released source is available at * ! 21: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * ! 22: * * ! 23: * Anonymous CVS access to the development source and modification history * ! 24: * is available at cvs.synchro.net:/cvsroot/sbbs, example: * ! 25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login * ! 26: * (just hit return, no password is necessary) * ! 27: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src * ! 28: * * ! 29: * For Synchronet coding style and modification guidelines, see * ! 30: * http://www.synchro.net/source.html * ! 31: * * ! 32: * You are encouraged to submit any modifications (preferably in Unix diff * ! 33: * format) via e-mail to [email protected] * ! 34: * * ! 35: * Note: If this box doesn't appear square, then you need to fix your tabs. * ! 36: ****************************************************************************/ ! 37: ! 38: #ifndef _DAT_FILE_H ! 39: #define _DAT_FILE_H ! 40: ! 41: #include "str_list.h" ! 42: ! 43: #if defined(__cplusplus) ! 44: extern "C" { ! 45: #endif ! 46: ! 47: /***************/ ! 48: /* Generic API */ ! 49: /***************/ ! 50: ! 51: typedef str_list_t (*dataLineParser_t)(const char*); ! 52: typedef char* (*dataLineCreator_t)(const str_list_t); ! 53: ! 54: /* columns arguments are optional (may be NULL) */ ! 55: str_list_t* dataParseList(const str_list_t records, str_list_t* columns, dataLineParser_t); ! 56: str_list_t* dataReadFile(FILE* fp, str_list_t* columns, dataLineParser_t); ! 57: ! 58: str_list_t dataCreateList(const str_list_t records[], const str_list_t columns, dataLineCreator_t); ! 59: BOOL dataWriteFile(FILE* fp, const str_list_t records[], const str_list_t columns ! 60: ,const char* separator, dataLineCreator_t); ! 61: ! 62: /* CSV (comma separated value) API */ ! 63: char* csvLineCreator(const str_list_t); ! 64: str_list_t csvLineParser(const char* line); ! 65: #define csvParseList(list,col) dataParseList(list,col,csvLineParser) ! 66: #define csvCreateList(rec,col) dataCreateList(rec,col,csvLineCreator) ! 67: #define csvReadFile(fp,col) dataReadFile(fp,col,csvLineParser) ! 68: #define csvWriteFile(fp,rec,sep,col) dataWriteFile(fp,rec,col,sep,csvLineCreator) ! 69: ! 70: /* Tab-delimited API */ ! 71: char* tabLineCreator(const str_list_t); ! 72: str_list_t tabLineParser(const char* line); ! 73: #define tabParseList(list,col) dataParseList(list,col,tabLineParser) ! 74: #define tabCreateList(rec,col) dataCreateList(rec,col,tabLineCreator) ! 75: #define tabReadFile(fp,col) dataReadFile(fp,col,tabLineParser) ! 76: #define tabWriteFile(fp,rec,sep,col) dataWriteFile(fp,rec,col,sep,tabLineCreator) ! 77: ! 78: #if defined(__cplusplus) ! 79: } ! 80: #endif ! 81: ! 82: #endif /* Don't add anything after this line */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.