]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * client_util.c: Utility functions for making test clients | |
3 | * Copyright 2017 Simon Arlott | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | |
18 | * USA | |
19 | */ | |
20 | #include <stdio.h> | |
21 | #include <string.h> | |
22 | #include <stdlib.h> | |
23 | #include <unistd.h> | |
24 | ||
25 | #include "stdinc.h" | |
26 | #include "ircd_defs.h" | |
27 | #include "msg.h" | |
28 | #include "client.h" | |
29 | ||
30 | #include "ircd_util.h" | |
31 | ||
32 | #define TEST_NICK "local_test" | |
33 | #define TEST_USERNAME "username" | |
34 | #define TEST_HOSTNAME "example.test" | |
35 | #define TEST_IP "2001:db8::1:5ee:bad:c0de" | |
36 | #define TEST_REALNAME "Test user" | |
37 | #define TEST_ID TEST_ME_ID "00000" | |
38 | ||
39 | #define TEST_ID_SUFFIX "!" TEST_USERNAME "@" TEST_HOSTNAME | |
40 | ||
41 | #define TEST_SERVER_NAME "remote.test" | |
42 | #define TEST_SERVER_ID "1BB" | |
43 | ||
44 | #define TEST_REMOTE_NICK "remote_test" | |
45 | #define TEST_REMOTE_ID TEST_SERVER_ID "00001" | |
46 | ||
47 | #define TEST_SERVER2_NAME "remote2.test" | |
48 | #define TEST_SERVER2_ID "2CC" | |
49 | ||
50 | #define TEST_REMOTE2_NICK "remote2_test" | |
51 | #define TEST_REMOTE2_ID TEST_SERVER2_ID "00002" | |
52 | ||
53 | #define TEST_SERVER3_NAME "remote3.test" | |
54 | #define TEST_SERVER3_ID "3DD" | |
55 | ||
56 | #define TEST_REMOTE3_NICK "remote3_test" | |
57 | #define TEST_REMOTE3_ID TEST_SERVER3_ID "00003" | |
58 | ||
59 | #define TEST_CHANNEL "#test" | |
60 | ||
61 | #define CRLF "\r\n" | |
62 | ||
63 | void client_util_init(void); | |
64 | void client_util_free(void); | |
65 | ||
66 | struct Client *make_local_unknown(void); | |
67 | struct Client *make_local_person(void); | |
68 | struct Client *make_local_person_nick(const char *nick); | |
69 | struct Client *make_local_person_full(const char *nick, const char *username, const char *hostname, const char *ip, const char *realname); | |
70 | void make_local_person_oper(struct Client *client); | |
71 | void remove_local_person(struct Client *client); | |
72 | ||
73 | struct Client *make_remote_server(struct Client *uplink); | |
74 | struct Client *make_remote_server_name(struct Client *uplink, const char *name); | |
75 | struct Client *make_remote_server_full(struct Client *uplink, const char *name, const char *id); | |
76 | struct Client *make_remote_person(struct Client *server); | |
77 | struct Client *make_remote_person_nick(struct Client *server, const char *nick); | |
78 | struct Client *make_remote_person_full(struct Client *server, const char *nick, const char *username, const char *hostname, const char *ip, const char *realname); | |
79 | void make_remote_person_oper(struct Client *client); | |
80 | void remove_remote_person(struct Client *client); | |
81 | void remove_remote_server(struct Client *server); | |
82 | ||
83 | struct Channel *make_channel(void); | |
84 | ||
85 | char *get_client_sendq(const struct Client *client); | |
86 | ||
87 | void client_util_parse(struct Client *client, const char *message); | |
88 | ||
89 | #define is_client_sendq_empty(client, message, ...) do { \ | |
90 | is_string("", get_client_sendq(client), message, ##__VA_ARGS__); \ | |
91 | } while (0) | |
92 | ||
93 | #define is_client_sendq_one(queue, client, message, ...) do { \ | |
94 | is_string(queue, get_client_sendq(client), message, ##__VA_ARGS__); \ | |
95 | } while (0) | |
96 | ||
97 | #define is_client_sendq(queue, client, message, ...) do { \ | |
98 | is_client_sendq_one(queue, client, message, ##__VA_ARGS__); \ | |
99 | is_client_sendq_empty(client, message, ##__VA_ARGS__); \ | |
100 | } while (0) |