Move all required includes to specific files to follow yet another standard and reformat code

This commit is contained in:
Alex D. 2021-01-02 14:12:13 +00:00
parent a0245cd78a
commit 24480c7cb7
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
17 changed files with 115 additions and 79 deletions

View File

@ -18,6 +18,18 @@
#include "buffer.h"
#include "logging.h"
#include <errno.h> // errno
#include <stdio.h> // fprintf()
#include <string.h> // strerror()
#include <sys/types.h> // size_t ssize_t
#include <unistd.h> // write()
#define UIRC_IRCV3
#define UIRC_HELPERS
#include <uirc/uirc.h> // Tok_mesg()
ssize_t
get_buffer_line(char* buf)
{

View File

@ -16,16 +16,7 @@
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
*/
#include "logging.h"
#include <errno.h> // errno
#include <string.h> // strerror()
#include <sys/types.h> // size_t ssize_t
#include <unistd.h> // write()
#define UIRC_IRCV3
#define UIRC_HELPERS
#include <uirc/uirc.h> // Tok_mesg()
ssize_t get_buffer_line(char* buf);
ssize_t flush_buffer(char* buf, size_t buflen, int fd);

View File

@ -18,6 +18,17 @@
#include "channels.h"
#include "logging.h" // LOG()
#include "memory.h" // allocate_copy()
#include <errno.h> // errno
#include <stdbool.h> // bool
#include <stdio.h> // snprintf()
#include <string.h> // strerror()
#include <sys/socket.h> // sockaddr connect()
#include <sys/types.h> // size_t ssize_t socklen_t
#include <stdlib.h> // malloc() realloc()
int
init_chanarray(Channel** chans)
{
@ -40,9 +51,9 @@ resize_chanarray(Channel** chans)
Channel* tmp = NULL;
LOG(LOG_DEBUG, "Found %i existing channels.", i);
if ((tmp = realloc(*chans, (i + 2) * sizeof(Channel))) != NULL) {
*chans = tmp;
tmp[i+1].name = NULL;
tmp[i+1].key = NULL;
*chans = tmp;
tmp[i + 1].name = NULL;
tmp[i + 1].key = NULL;
} else {
LOG(LOG_WARN, "Could not allocate channel struct. " ERRNOFMT, strerror(errno), errno);
return -1;
@ -62,7 +73,11 @@ set_channel(Channel* chan, const char* name, const char* key, bool joined)
}
if (key != NULL) {
if (!allocate_copy(&chan->key, key)) {
LOG(LOG_WARN, "Couldn't allocate memory for the channel %s key. " ERRNOFMT, (name == NULL) ? chan->name : name, strerror(errno), errno);
LOG(LOG_WARN,
"Couldn't allocate memory for the channel %s key. " ERRNOFMT,
(name == NULL) ? chan->name : name,
strerror(errno),
errno);
return 0;
}
}

View File

@ -16,15 +16,7 @@
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
*/
#include "logging.h" // LOG()
#include "memory.h" // allocate_copy()
#include <errno.h> // errno
#include <stdbool.h> // bool
#include <stdio.h> // snprintf()
#include <string.h> // strerror()
#include <sys/socket.h> // sockaddr connect()
#include <sys/types.h> // size_t ssize_t socklen_t
#include <stdbool.h> // bool
#ifndef UIRCD_GUARD_CHANNELS
#define UIRCD_GUARD_CHANNELS

View File

@ -18,7 +18,14 @@
#include "configuration.h"
#include "channels.h"
#include "connection.h"
#include "logging.h"
#include "memory.h"
#ifdef UIRCD_FEATURE_LIBCONFIG
#include <libconfig.h> // config_t config_setting_t config_init() ...
int
parse_configfile(char* config_path, Connection* conn)
{

View File

@ -20,11 +20,7 @@
#include <libconfig.h> // config_t config_setting_t config_init() ...
#endif /* UIRCD_FEATURE_LIBCONFIG */
#include "channels.h"
#include "connection.h"
#include "logging.h"
#include "memory.h"
#ifndef UIRCD_GUARD_CONFIGURATION
#define UIRCD_GUARD_CONFIGURATION

View File

@ -18,6 +18,25 @@
#include "connection.h"
#include "buffer.h"
#include "channels.h"
#include "limits.h"
#include "logging.h"
#include "memory.h"
#include <errno.h> // errno
#include <limits.h> // ??
#include <netdb.h> // getaddrinfo() gai_strerror()
#include <stdbool.h> // bool
#include <stdio.h> // snprintf()
#include <string.h> // strerror()
#include <sys/socket.h> // sockaddr connect()
#include <sys/types.h> // size_t ssize_t socklen_t
#include <unistd.h> // ??
#define UIRC_HELPERS
#include <uirc/uirc.h> // Assm_mesg Assm_cmd...
signed int
init_connection(Connection* conn)
{

View File

@ -16,21 +16,11 @@
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
*/
#include "buffer.h"
#include "channels.h"
#include "limits.h"
#include "logging.h"
#include "memory.h"
#include <errno.h> // errno
#include <limits.h> // ??
#include <netdb.h> // getaddrinfo() gai_strerror()
#include <stdbool.h> // bool
#include <stdio.h> // snprintf()
#include <string.h> // strerror()
#include <sys/socket.h> // sockaddr connect()
#include <sys/types.h> // size_t ssize_t socklen_t
#include <unistd.h> // ??
#include <stdbool.h> // bool
#include <sys/types.h> // size_t ssize_t socklen_t
#define UIRC_IRCV3
#define UIRC_HELPERS

View File

@ -18,6 +18,20 @@
#include "filesystem.h"
#include "connection.h"
#include "limits.h"
#include "logging.h"
#include <ctype.h> // isalpha() isdigit()
#include <errno.h> // errno
#include <fcntl.h> // fnctl()
#include <limits.h> // ??
#include <stdbool.h> // bool
#include <stdio.h> // fopen() FILE fprintf()
#include <string.h> // strerror()
#include <sys/stat.h> // mkfifo() mkdir()
#include <sys/types.h> // size_t ssize_t mode_t
int
mkdir_bottomup(char* path)
{

View File

@ -17,18 +17,12 @@
*/
#include "connection.h"
#include "limits.h"
#include "logging.h"
#include <ctype.h> // isalpha() isdigit()
#include <errno.h> // errno
#include <fcntl.h> // fnctl()
#include <limits.h> // ??
#include <stdbool.h> // bool
#include <stdio.h> // fopen() FILE fprintf()
#include <string.h> // strerror()
#include <sys/stat.h> // mkfifo() mkdir()
#include <sys/types.h> // size_t ssize_t mode_t
#include <stdbool.h>
#include <sys/types.h>
#define UIRC_IRCV3
#include <uirc/uirc.h> // IRC_Message
#ifndef UIRCD_GUARD_FILESYSTEM
#define UIRCD_GUARD_FILESYSTEM

View File

@ -16,8 +16,6 @@
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdio.h> // fprintf()
#ifndef UIRCD_GUARD_LOGGING
#define UIRCD_GUARD_LOGGING

View File

@ -18,6 +18,26 @@
#include "main.h"
#include "buffer.h"
#include "configuration.h"
#include "connection.h"
#include "filesystem.h"
#include "logging.h"
#include "memory.h"
#include "signal.h"
#include <errno.h> // errno
#include <fcntl.h> // O_NONBLOCK
#include <stdio.h> // printf()
#include <stdlib.h> // srand()
#include <string.h> // strerror()
#include <sys/types.h> // time_t size_t
#include <unistd.h> // getopt() chdir() close()
#define UIRC_IRCV3
#define UIRC_HELPERS
#include <uirc/uirc.h> // IRC_Message
int
parse_args(int argc, char** argv, Connection* conn)
{

View File

@ -16,22 +16,7 @@
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
*/
#include "buffer.h"
#include "configuration.h"
#include "connection.h"
#include "filesystem.h"
#include "logging.h"
#include "memory.h"
#include "signal.h"
#include <stdio.h> // printf()
#include <stdlib.h> // srand()
#include <sys/types.h> // time_t size_t
#include <unistd.h> // getopt() chdir() close()
#define UIRC_IRCV3
#define UIRC_HELPERS
#include <uirc/uirc.h> // IRC_Message
#ifndef UIRCD_GUARD_MAIN
#define UIRCD_GUARD_MAIN

View File

@ -18,6 +18,13 @@
#include "memory.h"
#include "logging.h"
#include <stdbool.h> // bool
#include <stdio.h> // fprintf()
#include <stdlib.h> // malloc() free()
#include <string.h> // strcpy()
/* Description:
* This is a allocation manager that frees or allocates variables to pointers depending on the context.
* If the pointer is already allocated it will free it and replace it with var

View File

@ -16,12 +16,6 @@
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
*/
#include "logging.h"
#include <stdbool.h> // bool
#include <stdlib.h> // malloc() free()
#include <string.h> // strcpy()
#ifndef UIRCD_GUARD_MEMORY
#define UIRCD_GUARD_MEMORY

View File

@ -18,6 +18,14 @@
#include "signal.h"
#include "logging.h"
#include <errno.h> // errno
#include <signal.h> // sig_atomic_t
#include <stdbool.h> // true, false
#include <stdio.h> // NULL, fprintf()
#include <string.h> // strerror()
sig_atomic_t volatile run = true;
void

View File

@ -16,13 +16,7 @@
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
*/
#include "logging.h"
#include <errno.h> // errno
#include <signal.h> // sig_atomic_t
#include <stdbool.h> // true, false
#include <stdio.h> // NULL
#include <string.h> // strerror()
#include <signal.h> // sig_atomic_t, siginfo_t
#ifndef UIRCD_GUARD_SIGNAL
#define UIRCD_GUARD_SIGNAL