solanum-vs-hackint-and-char.../tests/client_util.h

78 lines
2.9 KiB
C
Raw Normal View History

2017-08-05 13:09:01 +00:00
/*
* client_util.c: Utility functions for making test clients
* Copyright 2017 Simon Arlott
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "stdinc.h"
#include "ircd_defs.h"
#include "msg.h"
#include "client.h"
#include "ircd_util.h"
#define TEST_NICK "local_test"
2017-08-05 13:09:01 +00:00
#define TEST_USERNAME "username"
#define TEST_HOSTNAME "example.test"
#define TEST_IP "2001:db8::1:5ee:bad:c0de"
#define TEST_REALNAME "Test user"
#define TEST_ID TEST_ME_ID "00000"
#define TEST_ID_SUFFIX "!" TEST_USERNAME "@" TEST_HOSTNAME
#define TEST_SERVER_NAME "remote.test"
#define TEST_SERVER_ID "1BB"
#define TEST_REMOTE_NICK "remote_test"
#define TEST_REMOTE_ID TEST_SERVER_ID "00001"
2017-08-05 13:09:01 +00:00
#define CRLF "\r\n"
void client_util_init(void);
void client_util_free(void);
struct Client *make_local_person(void);
struct Client *make_local_person_nick(const char *nick);
struct Client *make_local_person_full(const char *nick, const char *username, const char *hostname, const char *ip, const char *realname);
void make_local_person_oper(struct Client *client);
2017-08-05 13:09:01 +00:00
void remove_local_person(struct Client *client);
struct Client *make_remote_server(struct Client *uplink);
struct Client *make_remote_server_name(struct Client *uplink, const char *name);
struct Client *make_remote_server_full(struct Client *uplink, const char *name, const char *id);
struct Client *make_remote_person(struct Client *server);
struct Client *make_remote_person_nick(struct Client *server, const char *nick);
struct Client *make_remote_person_full(struct Client *server, const char *nick, const char *username, const char *hostname, const char *ip, const char *realname);
void make_remote_person_oper(struct Client *client);
void remove_remote_person(struct Client *client);
void remove_remote_server(struct Client *server);
2017-08-05 13:09:01 +00:00
char *get_client_sendq(const struct Client *client);
#define is_client_sendq_empty(client, message, ...) do { \
is_string("", get_client_sendq(client), message, ##__VA_ARGS__); \
} while (0)
#define is_client_sendq(queue, client, message, ...) do { \
is_string(queue, get_client_sendq(client), message, ##__VA_ARGS__); \
is_client_sendq_empty(client, message, ##__VA_ARGS__); \
} while (0)