From 596bc096b02ef94efe3d73bb747c6ab0368f63bf Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Sun, 24 Oct 2010 21:48:32 +0200 Subject: [PATCH] Make sourcecode compatible with ansi2knr again This allows to compile ngIRCd using a pre-ANSI K&R C compiler again: all source files are automatically converted by the included ansi2knr program (of GNU automake/autoconf) before compiling them with the K&R C compiler, but a few coding standards must be met. Tested on Apple A/UX 3.x. Regression testing on Linux and Mac OS X. --- src/ipaddr/ng_ipaddr.h | 7 ++++-- src/ngircd/client.c | 3 ++- src/ngircd/conf-ssl.h | 3 ++- src/ngircd/conf.c | 3 ++- src/ngircd/conn.c | 6 ++++-- src/ngircd/conn.h | 4 +++- src/ngircd/io.c | 49 +++++++++++++++++++++++++++++++----------- src/ngircd/irc-info.c | 4 +++- src/ngircd/resolve.c | 8 +++---- src/tool/tool.c | 4 ++-- 10 files changed, 63 insertions(+), 28 deletions(-) diff --git a/src/ipaddr/ng_ipaddr.h b/src/ipaddr/ng_ipaddr.h index 4582e2a5..54a97036 100644 --- a/src/ipaddr/ng_ipaddr.h +++ b/src/ipaddr/ng_ipaddr.h @@ -103,8 +103,11 @@ GLOBAL const char *ng_ipaddr_tostr PARAMS((const ng_ipaddr_t *addr)); /* convert struct sockaddr to string. dest must be NG_INET_ADDRSTRLEN bytes long */ GLOBAL bool ng_ipaddr_tostr_r PARAMS((const ng_ipaddr_t *addr, char *dest)); #else -static inline const char * -ng_ipaddr_tostr(const ng_ipaddr_t *addr) { return inet_ntoa(addr->sin4.sin_addr); } +static inline const char* +ng_ipaddr_tostr(const ng_ipaddr_t *addr) +{ + return inet_ntoa(addr->sin4.sin_addr); +} static inline bool ng_ipaddr_tostr_r(const ng_ipaddr_t *addr, char *d) diff --git a/src/ngircd/client.c b/src/ngircd/client.c index 03347835..739c5ea5 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -363,7 +363,8 @@ Client_SetUser( CLIENT *Client, const char *User, bool Idented ) * @param User User name to set. */ GLOBAL void -Client_SetOrigUser(CLIENT UNUSED *Client, const char UNUSED *User) { +Client_SetOrigUser(CLIENT UNUSED *Client, const char UNUSED *User) +{ assert(Client != NULL); assert(User != NULL); diff --git a/src/ngircd/conf-ssl.h b/src/ngircd/conf-ssl.h index e88d3e89..cdb99682 100644 --- a/src/ngircd/conf-ssl.h +++ b/src/ngircd/conf-ssl.h @@ -39,7 +39,8 @@ bool ConnSSL_InitLibrary(void); #else static inline bool -ConnSSL_InitLibrary(void) { return true; } +ConnSSL_InitLibrary(void) +{ return true; } #endif /* SSL_SUPPORT */ #endif /* conf_ssl_h */ diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index f8b470fa..4804f2bb 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -844,7 +844,8 @@ Check_ArgIsTrue( const char *Arg ) } /* Check_ArgIsTrue */ -static unsigned int Handle_MaxNickLength(int Line, const char *Arg) +static unsigned int +Handle_MaxNickLength(int Line, const char *Arg) { unsigned new; diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index d74f2511..bbb186e9 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -681,9 +681,11 @@ SSL_WantWrite(const CONNECTION *c) } #else static inline bool -SSL_WantRead(UNUSED const CONNECTION *c) { return false; } +SSL_WantRead(UNUSED const CONNECTION *c) +{ return false; } static inline bool -SSL_WantWrite(UNUSED const CONNECTION *c) { return false; } +SSL_WantWrite(UNUSED const CONNECTION *c) +{ return false; } #endif diff --git a/src/ngircd/conn.h b/src/ngircd/conn.h index 1e938ada..280c61bb 100644 --- a/src/ngircd/conn.h +++ b/src/ngircd/conn.h @@ -122,7 +122,9 @@ GLOBAL PROC_STAT* Conn_GetProcStat PARAMS((CONN_ID i)); GLOBAL bool Conn_GetCipherInfo PARAMS((CONN_ID Idx, char *buf, size_t len)); GLOBAL bool Conn_UsesSSL PARAMS((CONN_ID Idx)); #else -static inline bool Conn_UsesSSL(UNUSED CONN_ID Idx) { return false; } +static inline bool +Conn_UsesSSL(UNUSED CONN_ID Idx) +{ return false; } #endif GLOBAL long Conn_Count PARAMS((void)); diff --git a/src/ngircd/io.c b/src/ngircd/io.c index 411b383e..d13a5e25 100644 --- a/src/ngircd/io.c +++ b/src/ngircd/io.c @@ -115,7 +115,7 @@ static fd_set writers; * the largest fd registered, plus one. */ static int select_maxfd; -static int io_dispatch_select(struct timeval *tv); +static int io_dispatch_select PARAMS((struct timeval *tv)); #ifndef IO_USE_EPOLL #define io_masterfd -1 @@ -127,12 +127,15 @@ static array io_events; static void io_docallback PARAMS((int fd, short what)); #ifdef DEBUG_IO -static void io_debug(const char *s, int fd, int what) +static void +io_debug(const char *s, int fd, int what) { Log(LOG_DEBUG, "%s: %d, %d\n", s, fd, what); } #else -static inline void io_debug(const char UNUSED *s,int UNUSED a, int UNUSED b) {/*NOTHING*/} +static inline void +io_debug(const char UNUSED *s,int UNUSED a, int UNUSED b) +{ /* NOTHING */ } #endif static io_event * @@ -227,8 +230,12 @@ io_library_init_devpoll(unsigned int eventsize) eventsize, io_masterfd); } #else -static inline void io_close_devpoll(int UNUSED x) {/* NOTHING */} -static inline void io_library_init_devpoll(unsigned int UNUSED ev) {/*NOTHING*/} +static inline void +io_close_devpoll(int UNUSED x) +{ /* NOTHING */ } +static inline void +io_library_init_devpoll(unsigned int UNUSED ev) +{ /* NOTHING */ } #endif @@ -331,8 +338,12 @@ io_library_init_poll(unsigned int eventsize) } } #else -static inline void io_close_poll(int UNUSED x) {/* NOTHING */} -static inline void io_library_init_poll(unsigned int UNUSED ev) {/*NOTHING*/} +static inline void +io_close_poll(int UNUSED x) +{ /* NOTHING */ } +static inline void +io_library_init_poll(unsigned int UNUSED ev) +{ /* NOTHING */ } #endif @@ -340,11 +351,15 @@ static inline void io_library_init_poll(unsigned int UNUSED ev) {/*NOTHING*/} static int io_dispatch_select(struct timeval *tv) { - fd_set readers_tmp = readers; - fd_set writers_tmp = writers; + fd_set readers_tmp; + fd_set writers_tmp; short what; int ret, i; int fds_ready; + + readers_tmp = readers; + writers_tmp = writers; + ret = select(select_maxfd + 1, &readers_tmp, &writers_tmp, NULL, tv); if (ret <= 0) return ret; @@ -418,8 +433,12 @@ io_close_select(int fd) } } #else -static inline void io_library_init_select(int UNUSED x) {/* NOTHING */} -static inline void io_close_select(int UNUSED x) {/* NOTHING */} +static inline void +io_library_init_select(int UNUSED x) +{ /* NOTHING */ } +static inline void +io_close_select(int UNUSED x) +{ /* NOTHING */ } #endif /* SELECT */ @@ -494,7 +513,9 @@ io_library_init_epoll(unsigned int eventsize) #endif } #else -static inline void io_library_init_epoll(unsigned int UNUSED ev) {/* NOTHING */} +static inline void +io_library_init_epoll(unsigned int UNUSED ev) +{ /* NOTHING */ } #endif /* IO_USE_EPOLL */ @@ -620,7 +641,9 @@ io_library_init_kqueue(unsigned int eventsize) library_initialized = true; } #else -static inline void io_library_init_kqueue(unsigned int UNUSED ev) {/* NOTHING */} +static inline void +io_library_init_kqueue(unsigned int UNUSED ev) +{ /* NOTHING */ } #endif diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 8f86e805..638a8e92 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -1239,7 +1239,9 @@ static bool Show_MOTD_SSLInfo(CLIENT *Client) return ret; } #else -static inline bool Show_MOTD_SSLInfo(UNUSED CLIENT *c) { return true; } +static inline bool +Show_MOTD_SSLInfo(UNUSED CLIENT *c) +{ return true; } #endif GLOBAL bool diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c index 9bc3a87a..5839c194 100644 --- a/src/ngircd/resolve.c +++ b/src/ngircd/resolve.c @@ -344,15 +344,15 @@ Addr_in_list(const array *resolved_addr, const ng_ipaddr_t *Addr) static void Log_Forgery_NoIP(const char *ip, const char *host) { - Log_Subprocess(LOG_WARNING, "Possible forgery: %s resolved to %s " - "(which has no ip address)", ip, host); + Log_Subprocess(LOG_WARNING, + "Possible forgery: %s resolved to %s (which has no ip address)", ip, host); } static void Log_Forgery_WrongIP(const char *ip, const char *host) { - Log_Subprocess(LOG_WARNING,"Possible forgery: %s resolved to %s " - "(which points to different address)", ip, host); + Log_Subprocess(LOG_WARNING, + "Possible forgery: %s resolved to %s (which points to different address)", ip, host); } diff --git a/src/tool/tool.c b/src/tool/tool.c index 9e290749..dbdb49a2 100644 --- a/src/tool/tool.c +++ b/src/tool/tool.c @@ -186,8 +186,8 @@ CODE facilitynames[] = { #endif -GLOBAL const char -*ngt_SyslogFacilityName(int Facility) +GLOBAL const char* +ngt_SyslogFacilityName(int Facility) { int i = 0; while(facilitynames[i].c_name) { -- 2.39.2