Use uglier names.
git-svn-id: svn://svn.tartarus.org/sgt/putty@5352
cda61777-01e9-0310-a592-
d414129be87e
/* log session to file stuff ... */
struct LogContext {
FILE *lgfp;
/* log session to file stuff ... */
struct LogContext {
FILE *lgfp;
- enum { CLOSED, OPENING, OPEN, ERROR } state;
+ enum { L_CLOSED, L_OPENING, L_OPEN, L_ERROR } state;
bufchain queue;
Filename currlogfilename;
void *frontend;
bufchain queue;
Filename currlogfilename;
void *frontend;
static void logwrite(struct LogContext *ctx, void *data, int len)
{
/*
static void logwrite(struct LogContext *ctx, void *data, int len)
{
/*
- * In state CLOSED, we call logfopen, which will set the state
- * to one of OPENING, OPEN or ERROR. Hence we process all of
- * those three _after_ processing CLOSED.
+ * In state L_CLOSED, we call logfopen, which will set the state
+ * to one of L_OPENING, L_OPEN or L_ERROR. Hence we process all of
+ * those three _after_ processing L_CLOSED.
- if (ctx->state == CLOSED)
+ if (ctx->state == L_CLOSED)
- if (ctx->state == OPENING) {
+ if (ctx->state == L_OPENING) {
bufchain_add(&ctx->queue, data, len);
bufchain_add(&ctx->queue, data, len);
- } else if (ctx->state == OPEN) {
+ } else if (ctx->state == L_OPEN) {
assert(ctx->lgfp);
fwrite(data, 1, len, ctx->lgfp);
assert(ctx->lgfp);
fwrite(data, 1, len, ctx->lgfp);
- } /* else ERROR, so ignore the write */
+ } /* else L_ERROR, so ignore the write */
void logflush(void *handle) {
struct LogContext *ctx = (struct LogContext *)handle;
if (ctx->cfg.logtype > 0)
void logflush(void *handle) {
struct LogContext *ctx = (struct LogContext *)handle;
if (ctx->cfg.logtype > 0)
- if (ctx->state == OPEN)
+ if (ctx->state == L_OPEN)
const char *fmode;
if (mode == 0) {
const char *fmode;
if (mode == 0) {
- ctx->state = ERROR; /* disable logging */
+ ctx->state = L_ERROR; /* disable logging */
} else {
fmode = (mode == 1 ? "a" : "w");
ctx->lgfp = f_open(ctx->currlogfilename, fmode);
if (ctx->lgfp)
} else {
fmode = (mode == 1 ? "a" : "w");
ctx->lgfp = f_open(ctx->currlogfilename, fmode);
if (ctx->lgfp)
- if (ctx->state == OPEN) {
+ if (ctx->state == L_OPEN) {
/* Write header line into log file. */
tm = ltime();
strftime(buf, 24, "%Y.%m.%d %H:%M:%S", &tm);
/* Write header line into log file. */
tm = ltime();
strftime(buf, 24, "%Y.%m.%d %H:%M:%S", &tm);
* Having either succeeded or failed in opening the log file,
* we should write any queued data out.
*/
* Having either succeeded or failed in opening the log file,
* we should write any queued data out.
*/
- assert(ctx->state != OPENING); /* make _sure_ it won't be requeued */
+ assert(ctx->state != L_OPENING); /* make _sure_ it won't be requeued */
while (bufchain_size(&ctx->queue)) {
void *data;
int len;
while (bufchain_size(&ctx->queue)) {
void *data;
int len;
int mode;
/* Prevent repeat calls */
int mode;
/* Prevent repeat calls */
- if (ctx->state != CLOSED)
+ if (ctx->state != L_CLOSED)
return;
if (!ctx->cfg.logtype)
return;
if (!ctx->cfg.logtype)
mode = 2; /* create == overwrite */
if (mode < 0)
mode = 2; /* create == overwrite */
if (mode < 0)
+ ctx->state = L_OPENING;
else
logfopen_callback(ctx, mode); /* open the file */
}
else
logfopen_callback(ctx, mode); /* open the file */
}
fclose(ctx->lgfp);
ctx->lgfp = NULL;
}
fclose(ctx->lgfp);
ctx->lgfp = NULL;
}
{
struct LogContext *ctx = snew(struct LogContext);
ctx->lgfp = NULL;
{
struct LogContext *ctx = snew(struct LogContext);
ctx->lgfp = NULL;
ctx->frontend = frontend;
ctx->cfg = *cfg; /* STRUCTURE COPY */
bufchain_init(&ctx->queue);
ctx->frontend = frontend;
ctx->cfg = *cfg; /* STRUCTURE COPY */
bufchain_init(&ctx->queue);