This repository has been archived on 2021-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
uIRCd/src/connection.h

72 lines
1.9 KiB
C

/*
* This file is part of uIRCd. (https://git.redxen.eu/caskd/uIRCd)
* Copyright (c) 2019, 2020 Alex-David Denes
*
* uIRCd is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* uIRCd is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with uIRCd. If not, see <https://www.gnu.org/licenses/>.
*/
#include "limits.h"
#include "logging.h"
#include <errno.h>
#include <netdb.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#define UIRC_IRCV3
#define UIRC_HELPERS
#include <uirc/uirc.h>
#ifndef UIRCD_GUARD_CONNECTION
#define UIRCD_GUARD_CONNECTION
#define INIT_HARDFAIL -1
#define INIT_SOFTFAIL -2
#define CONN_ACTIVE 2
#define CONN_REGISTERED 1
#define CONN_PENDING 0
#define CONN_RECONNECTING -1
#define CONN_CLOSING -2
#define CONN_CLOSED -3
typedef struct {
const char *addr, *port, *chans, *pass;
} Connection_Data;
typedef struct {
const char *nick, *user, *real;
} Connection_User;
typedef struct {
char buffer[UIRCD_LIMITS_LINE + 1];
size_t append_pos;
int fd;
} Buffer_Info;
typedef struct {
Connection_User names;
Connection_Data data;
const char *quitmsg, *path;
unsigned long timeout;
signed short state;
time_t lastping, lastpong, lastconnect, lastmessage;
} Connection;
signed int init_connection(Connection* info);
ssize_t flush_buffer(char* buf, size_t buflen, int fd);
ssize_t get_buffer_line(char* buf, IRC_Message* parsed);
ssize_t get_connstr(char* buf, size_t maxlen, Connection* conn);
#endif /* UIRCD_GUARD_CONNECTION */