mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-15 18:17:32 -05:00
Start using C99 variadic macros.
In the past, I've had a lot of macros which you call with double parentheses, along the lines of debug(("format string", params)), so that the inner parens protect the commas and permit the macro to treat the whole printf-style argument list as one macro argument. That's all very well, but it's a bit inconvenient (it doesn't leave you any way to implement such a macro by prepending another argument to the list), and now this code base's rules allow C99isms, I can switch all those macros to using a single pair of parens, using the C99 ability to say '...' in the parameter list of the #define and get at the corresponding suffix of the arguments as __VA_ARGS__. So I'm doing it. I've made the following printf-style macros variadic: bpp_logevent, ppl_logevent, ppl_printf and debug. While I'm here, I've also fixed up a collection of conditioned-out calls to debug() in the Windows front end which were clearly expecting a macro with a different calling syntax, because they had an integer parameter first. If I ever have a need to condition those back in, they should actually work now.
This commit is contained in:
14
sshppl.h
14
sshppl.h
@ -118,16 +118,14 @@ void ssh2_userauth_set_transport_layer(PacketProtocolLayer *userauth,
|
||||
|
||||
/* Convenience macro for protocol layers to send formatted strings to
|
||||
* the Event Log. Assumes a function parameter called 'ppl' is in
|
||||
* scope, and takes a double pair of parens because it passes a whole
|
||||
* argument list to dupprintf. */
|
||||
#define ppl_logevent(params) ( \
|
||||
logevent_and_free((ppl)->logctx, dupprintf params))
|
||||
* scope. */
|
||||
#define ppl_logevent(...) ( \
|
||||
logevent_and_free((ppl)->logctx, dupprintf(__VA_ARGS__)))
|
||||
|
||||
/* Convenience macro for protocol layers to send formatted strings to
|
||||
* the terminal. Also expects 'ppl' to be in scope and takes double
|
||||
* parens. */
|
||||
#define ppl_printf(params) \
|
||||
ssh_ppl_user_output_string_and_free(ppl, dupprintf params)
|
||||
* the terminal. Also expects 'ppl' to be in scope. */
|
||||
#define ppl_printf(...) \
|
||||
ssh_ppl_user_output_string_and_free(ppl, dupprintf(__VA_ARGS__))
|
||||
void ssh_ppl_user_output_string_and_free(PacketProtocolLayer *ppl, char *text);
|
||||
|
||||
/* Methods for userauth to communicate back to the transport layer */
|
||||
|
Reference in New Issue
Block a user