92 lines
2.3 KiB
C
92 lines
2.3 KiB
C
/*
|
|
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
|
|
* Copyright (c) 2019-2021 Alex-David Denes
|
|
*
|
|
* uIRC 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.
|
|
*
|
|
* uIRC 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 uIRC. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/*! \file */
|
|
|
|
#include <corelibs/llist.h> // llist_t
|
|
#include <inttypes.h> // uintmax_t
|
|
#include <stdbool.h> // bool
|
|
|
|
#ifndef UIRC_GUARD_PUBLIC_TYPES
|
|
#define UIRC_GUARD_PUBLIC_TYPES
|
|
|
|
typedef unsigned short IRC_Modes;
|
|
typedef uintmax_t IRC_Counter;
|
|
|
|
#ifdef UIRC_FEATURE_IRCV3
|
|
typedef struct {
|
|
char *key, *value;
|
|
bool clientbound;
|
|
} IRC_Tag;
|
|
|
|
typedef struct {
|
|
char* name;
|
|
bool active;
|
|
} IRC_Capability;
|
|
#endif /* UIRC_FEATURE_IRCV3 */
|
|
|
|
typedef struct {
|
|
char * nick, *user, *host, *real;
|
|
IRC_Modes modes;
|
|
bool is_service;
|
|
} IRC_User;
|
|
|
|
#define IRC_MAXARGS 15
|
|
|
|
typedef struct {
|
|
IRC_User* source;
|
|
char* command;
|
|
char* args[IRC_MAXARGS]; /* 0-13 + trailing, ended early with a NULL */
|
|
bool trailing; /* Tells if the last argument is trailing */
|
|
#ifdef UIRC_FEATURE_IRCV3
|
|
llist_t* tag_list;
|
|
#endif /* UIRC_FEATURE_IRCV3 */
|
|
} IRC_Message;
|
|
|
|
typedef enum { IRC_DIRECT, IRC_CHANNEL, IRC_GLOBAL } IRC_Buffer_Type;
|
|
typedef struct {
|
|
IRC_Buffer_Type type;
|
|
char * name, *topic, *key;
|
|
bool subscribed;
|
|
IRC_Modes modes;
|
|
llist_t * user_list, *message_list;
|
|
} IRC_Buffer;
|
|
|
|
typedef struct {
|
|
char * addr, *svc, *pass;
|
|
IRC_User* user;
|
|
llist_t* buf_list;
|
|
#ifdef UIRC_FEATURE_IRCV3
|
|
llist_t* cap_list;
|
|
#endif /* UIRC_FEATURE_IRCV3 */
|
|
} IRC_Network;
|
|
|
|
typedef enum {
|
|
#ifdef UIRC_FEATURE_IRCV3
|
|
IRC_STRUCT_TAG,
|
|
IRC_STRUCT_CAPABILITY,
|
|
#endif /* UIRC_FEATURE_IRCV3 */
|
|
IRC_STRUCT_USER,
|
|
IRC_STRUCT_MESSAGE,
|
|
IRC_STRUCT_BUFFER,
|
|
IRC_STRUCT_NETWORK
|
|
} IRC_Struct_Type;
|
|
|
|
#endif /* UIRC_GUARD_PUBLIC_TYPES */
|
|
|