Move all required includes to specific files to follow yet another standard and reformat code
This commit is contained in:
parent
a0245cd78a
commit
24480c7cb7
12
src/buffer.c
12
src/buffer.c
|
@ -18,6 +18,18 @@
|
||||||
|
|
||||||
#include "buffer.h"
|
#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
|
ssize_t
|
||||||
get_buffer_line(char* buf)
|
get_buffer_line(char* buf)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,16 +16,7 @@
|
||||||
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
* 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 <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 get_buffer_line(char* buf);
|
||||||
ssize_t flush_buffer(char* buf, size_t buflen, int fd);
|
ssize_t flush_buffer(char* buf, size_t buflen, int fd);
|
||||||
|
|
|
@ -18,6 +18,17 @@
|
||||||
|
|
||||||
#include "channels.h"
|
#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
|
int
|
||||||
init_chanarray(Channel** chans)
|
init_chanarray(Channel** chans)
|
||||||
{
|
{
|
||||||
|
@ -40,9 +51,9 @@ resize_chanarray(Channel** chans)
|
||||||
Channel* tmp = NULL;
|
Channel* tmp = NULL;
|
||||||
LOG(LOG_DEBUG, "Found %i existing channels.", i);
|
LOG(LOG_DEBUG, "Found %i existing channels.", i);
|
||||||
if ((tmp = realloc(*chans, (i + 2) * sizeof(Channel))) != NULL) {
|
if ((tmp = realloc(*chans, (i + 2) * sizeof(Channel))) != NULL) {
|
||||||
*chans = tmp;
|
*chans = tmp;
|
||||||
tmp[i+1].name = NULL;
|
tmp[i + 1].name = NULL;
|
||||||
tmp[i+1].key = NULL;
|
tmp[i + 1].key = NULL;
|
||||||
} else {
|
} else {
|
||||||
LOG(LOG_WARN, "Could not allocate channel struct. " ERRNOFMT, strerror(errno), errno);
|
LOG(LOG_WARN, "Could not allocate channel struct. " ERRNOFMT, strerror(errno), errno);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -62,7 +73,11 @@ set_channel(Channel* chan, const char* name, const char* key, bool joined)
|
||||||
}
|
}
|
||||||
if (key != NULL) {
|
if (key != NULL) {
|
||||||
if (!allocate_copy(&chan->key, key)) {
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,15 +16,7 @@
|
||||||
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "logging.h" // LOG()
|
#include <stdbool.h> // bool
|
||||||
#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
|
|
||||||
|
|
||||||
#ifndef UIRCD_GUARD_CHANNELS
|
#ifndef UIRCD_GUARD_CHANNELS
|
||||||
#define UIRCD_GUARD_CHANNELS
|
#define UIRCD_GUARD_CHANNELS
|
||||||
|
|
|
@ -18,7 +18,14 @@
|
||||||
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
|
#include "channels.h"
|
||||||
|
#include "connection.h"
|
||||||
|
#include "logging.h"
|
||||||
|
#include "memory.h"
|
||||||
|
|
||||||
#ifdef UIRCD_FEATURE_LIBCONFIG
|
#ifdef UIRCD_FEATURE_LIBCONFIG
|
||||||
|
#include <libconfig.h> // config_t config_setting_t config_init() ...
|
||||||
|
|
||||||
int
|
int
|
||||||
parse_configfile(char* config_path, Connection* conn)
|
parse_configfile(char* config_path, Connection* conn)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,11 +20,7 @@
|
||||||
#include <libconfig.h> // config_t config_setting_t config_init() ...
|
#include <libconfig.h> // config_t config_setting_t config_init() ...
|
||||||
|
|
||||||
#endif /* UIRCD_FEATURE_LIBCONFIG */
|
#endif /* UIRCD_FEATURE_LIBCONFIG */
|
||||||
|
|
||||||
#include "channels.h"
|
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "logging.h"
|
|
||||||
#include "memory.h"
|
|
||||||
|
|
||||||
#ifndef UIRCD_GUARD_CONFIGURATION
|
#ifndef UIRCD_GUARD_CONFIGURATION
|
||||||
#define UIRCD_GUARD_CONFIGURATION
|
#define UIRCD_GUARD_CONFIGURATION
|
||||||
|
|
|
@ -18,6 +18,25 @@
|
||||||
|
|
||||||
#include "connection.h"
|
#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
|
signed int
|
||||||
init_connection(Connection* conn)
|
init_connection(Connection* conn)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,21 +16,11 @@
|
||||||
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "buffer.h"
|
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "limits.h"
|
#include "limits.h"
|
||||||
#include "logging.h"
|
|
||||||
#include "memory.h"
|
|
||||||
|
|
||||||
#include <errno.h> // errno
|
#include <stdbool.h> // bool
|
||||||
#include <limits.h> // ??
|
#include <sys/types.h> // size_t ssize_t socklen_t
|
||||||
#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_IRCV3
|
#define UIRC_IRCV3
|
||||||
#define UIRC_HELPERS
|
#define UIRC_HELPERS
|
||||||
|
|
|
@ -18,6 +18,20 @@
|
||||||
|
|
||||||
#include "filesystem.h"
|
#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
|
int
|
||||||
mkdir_bottomup(char* path)
|
mkdir_bottomup(char* path)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,18 +17,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "limits.h"
|
|
||||||
#include "logging.h"
|
|
||||||
|
|
||||||
#include <ctype.h> // isalpha() isdigit()
|
#include <stdbool.h>
|
||||||
#include <errno.h> // errno
|
#include <sys/types.h>
|
||||||
#include <fcntl.h> // fnctl()
|
|
||||||
#include <limits.h> // ??
|
#define UIRC_IRCV3
|
||||||
#include <stdbool.h> // bool
|
#include <uirc/uirc.h> // IRC_Message
|
||||||
#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
|
|
||||||
|
|
||||||
#ifndef UIRCD_GUARD_FILESYSTEM
|
#ifndef UIRCD_GUARD_FILESYSTEM
|
||||||
#define UIRCD_GUARD_FILESYSTEM
|
#define UIRCD_GUARD_FILESYSTEM
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h> // fprintf()
|
|
||||||
|
|
||||||
#ifndef UIRCD_GUARD_LOGGING
|
#ifndef UIRCD_GUARD_LOGGING
|
||||||
#define UIRCD_GUARD_LOGGING
|
#define UIRCD_GUARD_LOGGING
|
||||||
|
|
||||||
|
|
20
src/main.c
20
src/main.c
|
@ -18,6 +18,26 @@
|
||||||
|
|
||||||
#include "main.h"
|
#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
|
int
|
||||||
parse_args(int argc, char** argv, Connection* conn)
|
parse_args(int argc, char** argv, Connection* conn)
|
||||||
{
|
{
|
||||||
|
|
15
src/main.h
15
src/main.h
|
@ -16,22 +16,7 @@
|
||||||
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "buffer.h"
|
|
||||||
#include "configuration.h"
|
|
||||||
#include "connection.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
|
#ifndef UIRCD_GUARD_MAIN
|
||||||
#define UIRCD_GUARD_MAIN
|
#define UIRCD_GUARD_MAIN
|
||||||
|
|
|
@ -18,6 +18,13 @@
|
||||||
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
#include "logging.h"
|
||||||
|
|
||||||
|
#include <stdbool.h> // bool
|
||||||
|
#include <stdio.h> // fprintf()
|
||||||
|
#include <stdlib.h> // malloc() free()
|
||||||
|
#include <string.h> // strcpy()
|
||||||
|
|
||||||
/* Description:
|
/* Description:
|
||||||
* This is a allocation manager that frees or allocates variables to pointers depending on the context.
|
* 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
|
* If the pointer is already allocated it will free it and replace it with var
|
||||||
|
|
|
@ -16,12 +16,6 @@
|
||||||
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
* 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
|
#ifndef UIRCD_GUARD_MEMORY
|
||||||
#define UIRCD_GUARD_MEMORY
|
#define UIRCD_GUARD_MEMORY
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,14 @@
|
||||||
|
|
||||||
#include "signal.h"
|
#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;
|
sig_atomic_t volatile run = true;
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -16,13 +16,7 @@
|
||||||
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "logging.h"
|
#include <signal.h> // sig_atomic_t, siginfo_t
|
||||||
|
|
||||||
#include <errno.h> // errno
|
|
||||||
#include <signal.h> // sig_atomic_t
|
|
||||||
#include <stdbool.h> // true, false
|
|
||||||
#include <stdio.h> // NULL
|
|
||||||
#include <string.h> // strerror()
|
|
||||||
|
|
||||||
#ifndef UIRCD_GUARD_SIGNAL
|
#ifndef UIRCD_GUARD_SIGNAL
|
||||||
#define UIRCD_GUARD_SIGNAL
|
#define UIRCD_GUARD_SIGNAL
|
||||||
|
|
Reference in New Issue