1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

New utility function logevent_and_free.

This should make it easier to do formatted-string based logging
outside ssh.c, because I can wrap up a local macro in any source file
I like that expands to logevent_and_free(wherever my Frontend is,
dupprintf(macro argument)).

It caused yet another stub function to be needed in testbn, but there
we go.

(Also, while I'm here, removed a redundant declaration of logevent
itself from ssh.h. The one in putty.h is all we need.)
This commit is contained in:
Simon Tatham 2018-09-19 17:37:00 +01:00
parent 61f18ac451
commit a313048763
6 changed files with 22 additions and 2 deletions

6
misc.c
View File

@ -337,6 +337,12 @@ void burnstr(char *string) /* sfree(str), only clear it first */
}
}
void logevent_and_free(Frontend *frontend, char *s)
{
logevent(frontend, s);
sfree(s);
}
int toint(unsigned u)
{
/*

7
misc.h
View File

@ -31,6 +31,13 @@ char *dupprintf(const char *fmt, ...)
char *dupvprintf(const char *fmt, va_list ap);
void burnstr(char *string);
/*
* Pass a dynamically allocated string to logevent and immediately
* free it. Intended for use by wrapper macros which pass the return
* value of dupprintf straight to this.
*/
void logevent_and_free(Frontend *frontend, char *msg);
struct strbuf {
char *s;
unsigned char *u;

2
ssh.h
View File

@ -777,8 +777,6 @@ int random_byte(void);
void random_add_noise(void *noise, int length);
void random_add_heavynoise(void *noise, int length);
void logevent(Frontend *, const char *);
/* Exports from x11fwd.c */
enum {
X11_TRANS_IPV4 = 0, X11_TRANS_IPV6 = 6, X11_TRANS_UNIX = 256

View File

@ -7,6 +7,7 @@
* testdata/bignum.py.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
@ -31,6 +32,8 @@ int random_byte(void)
return 0;
}
void logevent(Frontend *frontend, const char *msg) { assert(0); }
#define fromxdigit(c) ( (c)>'9' ? ((c)&0xDF) - 'A' + 10 : (c) - '0' )
/* For Unix in particular, but harmless if this main() is reused elsewhere */

View File

@ -60,6 +60,9 @@ void nonfatal(const char *fmt, ...)
sfree(stuff);
}
/* Stub needed to link against misc.c */
void logevent(Frontend *frontend, const char *msg) { assert(0); }
/* ----------------------------------------------------------------------
* Progress report code. This is really horrible :-)
*/

View File

@ -113,6 +113,9 @@ static void unmungestr(char *in, char *out, int outlen)
return;
}
/* Stub needed to link against misc.c */
void logevent(Frontend *frontend, const char *msg) { assert(0); }
static int has_security;
struct PassphraseProcStruct {