summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/src2html.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-03-11 05:06:34 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-03-11 05:06:34 +0000
commitdf24d3be598574ed27f3a2bb6ec322f65562af34 (patch)
treef56fcafc0d562c2fedf5c1f5c5d6f5daa6751d0f /src/tools/src2html.c
parent695bdfd04dce5cbbbb6efbb68086a20e83215163 (diff)
Added new function core_fload() to load a file into an allocated buffer.
Updated src2html, regrep, and chdman tools to use this function where appropriate. In chdman, changed -addmeta to -addmetatext or -addmetabin to explicitly specify the type of data (previous auto-detect was too dangerous).
Diffstat (limited to 'src/tools/src2html.c')
-rw-r--r--src/tools/src2html.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/tools/src2html.c b/src/tools/src2html.c
index 4854849ff59..0b5322d516b 100644
--- a/src/tools/src2html.c
+++ b/src/tools/src2html.c
@@ -202,8 +202,9 @@ static astring *find_include_file(int srcrootlen, int dstrootlen, const astring
int main(int argc, char *argv[])
{
astring *srcdir = NULL, *dstdir = NULL, *tempfilename = NULL, *tempheader = NULL, *tempfooter = NULL;
- core_file *tempfile;
int unadorned = 0;
+ UINT32 bufsize;
+ void *buffer;
int result;
int argnum;
@@ -249,17 +250,10 @@ int main(int argc, char *argv[])
goto usage;
/* read the template file into an astring */
- if (core_fopen(astring_c(tempfilename), OPEN_FLAG_READ, &tempfile) == FILERR_NONE)
+ if (core_fload(astring_c(tempfilename), &buffer, &bufsize) == FILERR_NONE)
{
- UINT64 filesize = core_fsize(tempfile);
- void *buffer = malloc(filesize);
- if (buffer != NULL)
- {
- core_fread(tempfile, buffer, filesize);
- tempheader = astring_dupch(buffer, filesize);
- free(buffer);
- }
- core_fclose(tempfile);
+ tempheader = astring_dupch(buffer, bufsize);
+ free(buffer);
}
/* verify the template */