mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-15 18:17:32 -05:00
misc.h: make some #defines into inline functions.
Mainly this change affects the whole {GET,PUT}_??BIT_?SB_FIRST family, which has always been a horrible set of macros for massive multiple- expansion of its arguments. Now we're allowed to use C99 in this code base, I can finally turn them into nice clean inline functions. As bonus they now take their pointer argument as a void * (const- qualified as appropriate) which means the call site doesn't have to worry about exactly which flavour of pointer it's passing. (That change also affects the GET_*_X11 macros in x11fwd.c, since I was just reminded of their existence too!) I've also converted NULLTOEMPTY, which was sitting right next to the GET/PUT macros in misc.h and it seemed a shame to leave it out.
This commit is contained in:
15
x11fwd.c
15
x11fwd.c
@ -12,11 +12,18 @@
|
||||
#include "sshchan.h"
|
||||
#include "tree234.h"
|
||||
|
||||
#define GET_16BIT_X11(endian, cp) \
|
||||
(endian=='B' ? GET_16BIT_MSB_FIRST(cp) : GET_16BIT_LSB_FIRST(cp))
|
||||
static inline uint16_t GET_16BIT_X11(char endian, const void *p)
|
||||
{
|
||||
return endian == 'B' ? GET_16BIT_MSB_FIRST(p) : GET_16BIT_LSB_FIRST(p);
|
||||
}
|
||||
|
||||
#define PUT_16BIT_X11(endian, cp, val) \
|
||||
(endian=='B' ? PUT_16BIT_MSB_FIRST(cp, val) : PUT_16BIT_LSB_FIRST(cp, val))
|
||||
static inline void PUT_16BIT_X11(char endian, void *p, uint16_t value)
|
||||
{
|
||||
if (endian == 'B')
|
||||
PUT_16BIT_MSB_FIRST(p, value);
|
||||
else
|
||||
PUT_16BIT_LSB_FIRST(p, value);
|
||||
}
|
||||
|
||||
const char *const x11_authnames[] = {
|
||||
"", "MIT-MAGIC-COOKIE-1", "XDM-AUTHORIZATION-1"
|
||||
|
Reference in New Issue
Block a user