conversion from 8 spaces to 4 spaces per tab

This commit is contained in:
Andreas Steffen
2009-04-19 19:16:09 +00:00
parent d940c7638c
commit 3d7a244b54
138 changed files with 47306 additions and 47306 deletions
+93 -93
View File
@@ -27,25 +27,25 @@
#include "constants.h"
#include "defs.h"
#include "log.h"
#include "whack.h" /* for RC_LOG_SERIOUS */
#include "whack.h" /* for RC_LOG_SERIOUS */
bool
all_zero(const unsigned char *m, size_t len)
{
size_t i;
size_t i;
for (i = 0; i != len; i++)
if (m[i] != '\0')
return FALSE;
return TRUE;
for (i = 0; i != len; i++)
if (m[i] != '\0')
return FALSE;
return TRUE;
}
void *clone_bytes(const void *orig, size_t size)
{
void *p = malloc(size);
void *p = malloc(size);
memcpy(p, orig, size);
return p;
memcpy(p, orig, size);
return p;
}
/* Note that there may be as many as six IDs that are temporary at
@@ -53,16 +53,16 @@ void *clone_bytes(const void *orig, size_t size)
* at least six temporary buffers for DER_ASN1_DN IDs.
* We rotate them. Be careful!
*/
#define MAX_BUF 10
#define MAX_BUF 10
char*
temporary_cyclic_buffer(void)
{
static char buf[MAX_BUF][BUF_LEN]; /* MAX_BUF internal buffers */
static int counter = 0; /* cyclic counter */
static char buf[MAX_BUF][BUF_LEN]; /* MAX_BUF internal buffers */
static int counter = 0; /* cyclic counter */
if (++counter == MAX_BUF) counter = 0; /* next internal buffer */
return buf[counter]; /* assign temporary buffer */
if (++counter == MAX_BUF) counter = 0; /* next internal buffer */
return buf[counter]; /* assign temporary buffer */
}
/* concatenates two sub paths into a string with a maximum size of BUF_LEN
@@ -71,14 +71,14 @@ temporary_cyclic_buffer(void)
const char*
concatenate_paths(const char *a, const char *b)
{
char *c;
char *c;
if (*b == '/' || *b == '.')
return b;
if (*b == '/' || *b == '.')
return b;
c = temporary_cyclic_buffer();
snprintf(c, BUF_LEN, "%s/%s", a, b);
return c;
c = temporary_cyclic_buffer();
snprintf(c, BUF_LEN, "%s/%s", a, b);
return c;
}
/* moves a chunk to a memory position, chunk is freed afterwards
@@ -87,11 +87,11 @@ concatenate_paths(const char *a, const char *b)
void
mv_chunk(u_char **pos, chunk_t content)
{
if (content.len > 0)
{
chunkcpy(*pos, content);
free(content.ptr);
}
if (content.len > 0)
{
chunkcpy(*pos, content);
free(content.ptr);
}
}
/*
@@ -101,46 +101,46 @@ bool
write_chunk(const char *filename, const char *label, chunk_t ch
, mode_t mask, bool force)
{
mode_t oldmask;
FILE *fd;
size_t written;
mode_t oldmask;
FILE *fd;
size_t written;
if (!force)
{
fd = fopen(filename, "r");
if (fd)
{
fclose(fd);
plog(" %s file '%s' already exists", label, filename);
return FALSE;
}
}
/* set umask */
oldmask = umask(mask);
fd = fopen(filename, "w");
if (!force)
{
fd = fopen(filename, "r");
if (fd)
{
fclose(fd);
plog(" %s file '%s' already exists", label, filename);
return FALSE;
written = fwrite(ch.ptr, sizeof(u_char), ch.len, fd);
fclose(fd);
if (written != ch.len)
{
plog(" writing to %s file '%s' failed", label, filename);
umask(oldmask);
return FALSE;
}
plog(" written %s file '%s' (%d bytes)", label, filename, (int)ch.len);
umask(oldmask);
return TRUE;
}
}
/* set umask */
oldmask = umask(mask);
fd = fopen(filename, "w");
if (fd)
{
written = fwrite(ch.ptr, sizeof(u_char), ch.len, fd);
fclose(fd);
if (written != ch.len)
else
{
plog(" writing to %s file '%s' failed", label, filename);
umask(oldmask);
return FALSE;
plog(" could not open %s file '%s' for writing", label, filename);
umask(oldmask);
return FALSE;
}
plog(" written %s file '%s' (%d bytes)", label, filename, (int)ch.len);
umask(oldmask);
return TRUE;
}
else
{
plog(" could not open %s file '%s' for writing", label, filename);
umask(oldmask);
return FALSE;
}
}
/* checks if the expiration date has been reached and
@@ -151,44 +151,44 @@ write_chunk(const char *filename, const char *label, chunk_t ch
const char*
check_expiry(time_t expiration_date, int warning_interval, bool strict)
{
time_t now;
int time_left;
time_t now;
int time_left;
if (expiration_date == UNDEFINED_TIME)
return "ok (expires never)";
if (expiration_date == UNDEFINED_TIME)
return "ok (expires never)";
/* determine the current time */
time(&now);
/* determine the current time */
time(&now);
time_left = (expiration_date - now);
if (time_left < 0)
return strict? "fatal (expired)" : "warning (expired)";
time_left = (expiration_date - now);
if (time_left < 0)
return strict? "fatal (expired)" : "warning (expired)";
if (time_left > 86400*warning_interval)
return "ok";
{
static char buf[35]; /* temporary storage */
const char* unit = "second";
if (time_left > 172800)
if (time_left > 86400*warning_interval)
return "ok";
{
time_left /= 86400;
unit = "day";
static char buf[35]; /* temporary storage */
const char* unit = "second";
if (time_left > 172800)
{
time_left /= 86400;
unit = "day";
}
else if (time_left > 7200)
{
time_left /= 3600;
unit = "hour";
}
else if (time_left > 120)
{
time_left /= 60;
unit = "minute";
}
snprintf(buf, 35, "warning (expires in %d %s%s)", time_left,
unit, (time_left == 1)?"":"s");
return buf;
}
else if (time_left > 7200)
{
time_left /= 3600;
unit = "hour";
}
else if (time_left > 120)
{
time_left /= 60;
unit = "minute";
}
snprintf(buf, 35, "warning (expires in %d %s%s)", time_left,
unit, (time_left == 1)?"":"s");
return buf;
}
}
@@ -198,8 +198,8 @@ check_expiry(time_t expiration_date, int warning_interval, bool strict)
int
file_select(const struct dirent *entry)
{
return strcmp(entry->d_name, "." ) &&
strcmp(entry->d_name, "..");
return strcmp(entry->d_name, "." ) &&
strcmp(entry->d_name, "..");
}