Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
28e2637f
Commit
28e2637f
authored
Apr 29, 2005
by
rswindell
Browse files
Pass line-separator string to cvs/tab/dataWriteFile functions rather than using
hard-coded "\n".
parent
7ca503a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
src/xpdev/dat_file.c
src/xpdev/dat_file.c
+5
-4
src/xpdev/dat_file.h
src/xpdev/dat_file.h
+11
-11
No files found.
src/xpdev/dat_file.c
View file @
28e2637f
/* dat_file.c */
/* Functions t
hat
deal with
line-based (text) data
files and lists */
/* Functions t
o
deal with
comma (CSV) and tab-delimited
files and lists */
/* $Id$ */
...
...
@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 200
4
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 200
5
Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
...
...
@@ -217,7 +217,8 @@ str_list_t dataCreateList(str_list_t records[], str_list_t columns, dataLineCrea
return
(
list
);
}
BOOL
dataWriteFile
(
FILE
*
fp
,
str_list_t
records
[],
str_list_t
columns
,
dataLineCreator_t
lineCreator
)
BOOL
dataWriteFile
(
FILE
*
fp
,
str_list_t
records
[],
str_list_t
columns
,
const
char
*
separator
,
dataLineCreator_t
lineCreator
)
{
size_t
count
,
total
;
str_list_t
list
;
...
...
@@ -231,7 +232,7 @@ BOOL dataWriteFile(FILE* fp, str_list_t records[], str_list_t columns, dataLineC
return
(
FALSE
);
total
=
strListCount
(
list
);
count
=
strListWriteFile
(
fp
,
list
,
"
\n
"
);
count
=
strListWriteFile
(
fp
,
list
,
separator
);
strListFree
(
&
list
);
return
(
count
==
total
);
...
...
src/xpdev/dat_file.h
View file @
28e2637f
/* dat_file.h */
/* Functions to deal with comma
-separated value (CSV)
files and lists */
/* Functions to deal with comma
(CSV) and tab-delimited
files and lists */
/* $Id$ */
...
...
@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 200
4
Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 200
5
Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
...
...
@@ -56,23 +56,23 @@ str_list_t* dataParseList(str_list_t list, str_list_t* columns, dataLineParser_t
str_list_t
*
dataReadFile
(
FILE
*
fp
,
str_list_t
*
columns
,
dataLineParser_t
);
str_list_t
dataCreateList
(
str_list_t
records
[],
str_list_t
columns
,
dataLineCreator_t
);
BOOL
dataWriteFile
(
FILE
*
fp
,
str_list_t
records
[],
str_list_t
columns
,
dataLineCreator_t
);
BOOL
dataWriteFile
(
FILE
*
fp
,
str_list_t
records
[],
str_list_t
columns
,
const
char
*
separator
,
dataLineCreator_t
);
/* CSV (comma separated value) API */
char
*
csvLineCreator
(
str_list_t
);
str_list_t
csvLineParser
(
char
*
line
);
#define csvParseList(list,col) dataParseList(list,col,csvLineParser)
#define csvCreateList(rec,col) dataCreateList(rec,col,csvLineCreator)
#define csvReadFile(fp,col) dataReadFile(fp,col,csvLineParser)
#define csvWriteFile(fp,rec,col) dataWriteFile(fp,rec,col,csvLineCreator)
#define csvParseList(list,col)
dataParseList(list,col,csvLineParser)
#define csvCreateList(rec,col)
dataCreateList(rec,col,csvLineCreator)
#define csvReadFile(fp,col)
dataReadFile(fp,col,csvLineParser)
#define csvWriteFile(fp,rec,
sep,
col) dataWriteFile(fp,rec,col,
sep,
csvLineCreator)
/* Tab-delimited API */
char
*
tabLineCreator
(
str_list_t
);
str_list_t
tabLineParser
(
char
*
line
);
#define tabParseList(list,col) dataParseList(list,col,tabLineParser)
#define tabCreateList(rec,col) dataCreateList(rec,col,tabLineCreator)
#define tabReadFile(fp,col) dataReadFile(fp,col,tabLineParser)
#define tabWriteFile(fp,rec,col) dataWriteFile(fp,rec,col,tabLineCreator)
#define tabParseList(list,col)
dataParseList(list,col,tabLineParser)
#define tabCreateList(rec,col)
dataCreateList(rec,col,tabLineCreator)
#define tabReadFile(fp,col)
dataReadFile(fp,col,tabLineParser)
#define tabWriteFile(fp,rec,
sep,
col) dataWriteFile(fp,rec,col,
sep,
tabLineCreator)
#if defined(__cplusplus)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment