Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
a11eb7be
Commit
a11eb7be
authored
2 years ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Add Open/CloseFile and ListFree methods
parent
4e990b47
No related branches found
No related tags found
1 merge request
!463
MRC mods by Codefenix (2024-10-20)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xpdev/dat_file.c
+24
-17
24 additions, 17 deletions
src/xpdev/dat_file.c
src/xpdev/dat_file.h
+9
-0
9 additions, 0 deletions
src/xpdev/dat_file.h
with
33 additions
and
17 deletions
src/xpdev/dat_file.c
+
24
−
17
View file @
a11eb7be
/* dat_file.c */
/* Functions to deal with comma (CSV) and tab-delimited files and lists */
/* $Id: dat_file.c,v 1.8 2018/07/24 01:13:09 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
...
...
@@ -15,23 +11,11 @@
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* See the GNU Lesser General Public License for more details: lgpl.txt or *
* http://www.fsf.org/copyleft/lesser.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
...
...
@@ -288,3 +272,26 @@ str_list_t* dataReadFile(FILE* fp, str_list_t* columns, dataLineParser_t linePar
return
(
records
);
}
BOOL
dataListFree
(
str_list_t
*
list
)
{
size_t
i
;
if
(
list
==
NULL
)
return
FALSE
;
for
(
i
=
0
;
list
[
i
]
!=
NULL
;
i
++
)
strListFree
(
&
list
[
i
]);
strListFree
(
list
);
return
TRUE
;
}
FILE
*
dataOpenFile
(
const
char
*
path
,
const
char
*
mode
)
{
return
fopen
(
path
,
mode
);
}
int
dataCloseFile
(
FILE
*
fp
)
{
return
fclose
(
fp
);
}
This diff is collapsed.
Click to expand it.
src/xpdev/dat_file.h
+
9
−
0
View file @
a11eb7be
...
...
@@ -58,6 +58,9 @@ str_list_t* dataReadFile(FILE* fp, str_list_t* columns, dataLineParser_t);
str_list_t
dataCreateList
(
const
str_list_t
records
[],
const
str_list_t
columns
,
dataLineCreator_t
);
BOOL
dataWriteFile
(
FILE
*
fp
,
const
str_list_t
records
[],
const
str_list_t
columns
,
const
char
*
separator
,
dataLineCreator_t
);
FILE
*
dataOpenFile
(
const
char
*
path
,
const
char
*
mode
);
int
dataCloseFile
(
FILE
*
);
BOOL
dataListFree
(
str_list_t
*
);
/* CSV (comma separated value) API */
char
*
csvLineCreator
(
const
str_list_t
);
...
...
@@ -66,6 +69,9 @@ str_list_t csvLineParser(const char* line);
#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)
#define cvsOpenFile(path, mode) dataOpenFile(path, mode)
#define csvCloseFile(fp) dataCloseFile(fp)
#define cvsListFree(list) dataListFree(list)
/* Tab-delimited API */
char
*
tabLineCreator
(
const
str_list_t
);
...
...
@@ -74,6 +80,9 @@ str_list_t tabLineParser(const char* line);
#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)
#define tabOpenFile(path, mode) dataOpenFile(path, mode)
#define tabCloseFile(fp) dataCloseFile(fp)
#define tabListFree(list) dataListFree(list)
#if defined(__cplusplus)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment