support cachecrls=yes

This commit is contained in:
Andreas Steffen
2007-04-05 17:07:14 +00:00
parent e58afb1a0a
commit 8883eef7b8
9 changed files with 169 additions and 25 deletions
+40
View File
@@ -25,6 +25,7 @@
#include "chunk.h"
#include <debug.h>
#include <printf_hook.h>
/**
@@ -205,6 +206,45 @@ void chunk_split(chunk_t chunk, const char *mode, ...)
va_end(chunks);
}
/**
* Described in header.
*/
bool chunk_write(chunk_t chunk, const char *path, const char *label, mode_t mask, bool force)
{
mode_t oldmask;
FILE *fd;
if (!force)
{
fd = fopen(path, "r");
if (fd)
{
fclose(fd);
DBG1(" %s file '%s' already exists", label, path);
return FALSE;
}
}
/* set umask */
oldmask = umask(mask);
fd = fopen(path, "w");
if (fd)
{
fwrite(chunk.ptr, sizeof(u_char), chunk.len, fd);
fclose(fd);
DBG1(" written %s file '%s' (%u bytes)", label, path, chunk.len);
umask(oldmask);
return TRUE;
}
else
{
DBG1(" could not open %s file '%s' for writing", label, path);
umask(oldmask);
return FALSE;
}
}
/**
* Described in header.