From 0608e319656422dde791000f73d98c18c6117a12 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Wed, 7 Mar 2018 20:09:23 +0000 Subject: [PATCH] Move some static functions earlier --- net_io.c | 80 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/net_io.c b/net_io.c index 32a7500..a0260fa 100644 --- a/net_io.c +++ b/net_io.c @@ -1072,6 +1072,22 @@ static int decodeHexMessage(struct client *c, char *hex) { useModesMessage(&mm); return (0); } + +__attribute__ ((format (printf,3,0))) static char *safe_vsnprintf(char *p, char *end, const char *format, va_list ap) +{ + p += vsnprintf(p < end ? p : NULL, p < end ? (size_t)(end - p) : 0, format, ap); + return p; +} + + __attribute__ ((format (printf,3,4))) static char *safe_snprintf(char *p, char *end, const char *format, ...) +{ + va_list ap; + va_start(ap, format); + p += vsnprintf(p < end ? p : NULL, p < end ? (size_t)(end - p) : 0, format, ap); + va_end(ap); + return p; +} + // //========================================================================= // @@ -1197,6 +1213,30 @@ static const char *addrtype_enum_string(addrtype_t type) { } } +static const char *emergency_enum_string(emergency_t emergency) +{ + switch (emergency) { + case EMERGENCY_NONE: return "none"; + case EMERGENCY_GENERAL: return "general"; + case EMERGENCY_LIFEGUARD: return "lifeguard"; + case EMERGENCY_MINFUEL: return "minfuel"; + case EMERGENCY_NORDO: return "nordo"; + case EMERGENCY_UNLAWFUL: return "unlawful"; + case EMERGENCY_DOWNED: return "downed"; + default: return "reserved"; + } +} + +static const char *sil_type_enum_string(sil_type_t type) +{ + switch (type) { + case SIL_UNKNOWN: return "unknown"; + case SIL_PER_HOUR: return "perhour"; + case SIL_PER_SAMPLE: return "persample"; + default: return "invalid"; + } +} + char *generateAircraftJson(const char *url_path, int *len) { uint64_t now = mstime(); struct aircraft *a; @@ -1756,22 +1796,6 @@ static void modesReadFromClient(struct client *c) { } } -__attribute__ ((format (printf,3,0))) static char *safe_vsnprintf(char *p, char *end, const char *format, va_list ap) -{ - p += vsnprintf(p < end ? p : NULL, p < end ? (size_t)(end - p) : 0, format, ap); - return p; -} - - __attribute__ ((format (printf,3,4))) static char *safe_snprintf(char *p, char *end, const char *format, ...) -{ - va_list ap; - va_start(ap, format); - p += vsnprintf(p < end ? p : NULL, p < end ? (size_t)(end - p) : 0, format, ap); - va_end(ap); - return p; -} - - __attribute__ ((format (printf,4,5))) static char *appendFATSV(char *p, char *end, const char *field, const char *format, ...) { va_list ap; @@ -1997,30 +2021,6 @@ static const char *airground_enum_string(airground_t ag) } } -static const char *emergency_enum_string(emergency_t emergency) -{ - switch (emergency) { - case EMERGENCY_NONE: return "none"; - case EMERGENCY_GENERAL: return "general"; - case EMERGENCY_LIFEGUARD: return "lifeguard"; - case EMERGENCY_MINFUEL: return "minfuel"; - case EMERGENCY_NORDO: return "nordo"; - case EMERGENCY_UNLAWFUL: return "unlawful"; - case EMERGENCY_DOWNED: return "downed"; - default: return "reserved"; - } -} - -static const char *sil_type_enum_string(sil_type_t type) -{ - switch (type) { - case SIL_UNKNOWN: return "unknown"; - case SIL_PER_HOUR: return "perhour"; - case SIL_PER_SAMPLE: return "persample"; - default: return "invalid"; - } -} - static void writeFATSV() { struct aircraft *a;