Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
BitchX
GitHub Repository: BitchX/BitchX1.3
Path: blob/master/include/ircaux.h
1069 views
1
/*
2
* ircaux.h: header file for ircaux.c
3
*
4
* Written By Michael Sandrof
5
*
6
* Copyright(c) 1990
7
*
8
* See the COPYRIGHT file, or do a HELP IRCII COPYRIGHT
9
*
10
* @(#)$Id: ircaux.h 80 2009-11-24 10:21:30Z keaston $
11
*/
12
13
#ifndef _IRCAUX_H_
14
#define _IRCAUX_H_
15
16
#include "irc.h"
17
#include "irc_std.h"
18
#include <stdio.h>
19
#ifdef WANT_TCL
20
#undef USE_TCLALLOC
21
#include <tcl.h>
22
#endif
23
24
typedef int comp_len_func (char *, char *, int);
25
typedef int comp_func (char *, char *);
26
27
extern unsigned char stricmp_table[];
28
29
30
char * BX_check_nickname (char *);
31
char * BX_next_arg (char *, char **);
32
char * BX_new_next_arg (char *, char **);
33
char * BX_new_new_next_arg (char *, char **, char *);
34
char * BX_last_arg (char **);
35
char * BX_expand_twiddle (char *);
36
char * BX_upper (char *);
37
char * BX_lower (char *);
38
char * BX_sindex (register char *, char *);
39
char * BX_rsindex (register char *, char *, char *, int);
40
char * BX_path_search (char *, char *);
41
char * BX_double_quote (const char *, const char *, char *);
42
char * quote_it (const char *, const char *, char *);
43
44
char * n_malloc_strcpy (char **, const char *, const char *, const char *, const int);
45
char * BX_malloc_str2cpy (char **, const char *, const char *);
46
char * n_malloc_strcat (char **, const char *, const char *, const char *, const int);
47
48
char * BX_m_s3cat_s (char **, const char *, const char *);
49
char * BX_m_s3cat (char **, const char *, const char *);
50
char * BX_m_3cat (char **, const char *, const char *);
51
char * BX_m_e3cat (char **, const char *, const char *);
52
char * BX_m_2dup (const char *, const char *);
53
char * BX_m_3dup (const char *, const char *, const char *);
54
char * BX_m_opendup (const char *, ...);
55
char * n_m_strdup (const char *, const char *, const char *, const int);
56
char * BX_malloc_sprintf (char **, const char *, ...);
57
char * BX_m_sprintf (const char *, ...);
58
int BX_is_number (const char *);
59
char * BX_my_ctime (time_t);
60
61
#if 0
62
#define my_stricmp(x, y) strcasecmp(x, y) /* unable to use these for reasons of case sensitivity and finish */
63
#define my_strnicmp(x, y, n) strncasecmp(x, y, n)
64
#else
65
int BX_my_stricmp (const char *, const char *);
66
int BX_my_strnicmp (const char *, const char *, size_t);
67
#endif
68
69
int BX_my_strnstr (const unsigned char *, const unsigned char *, size_t);
70
int BX_scanstr (char *, char *);
71
void really_free (int);
72
char * BX_chop (char *, int);
73
char * BX_strmcpy (char *, const char *, int);
74
char * BX_strmcat (char *, const char *, int);
75
char * strmcat_ue (char *, const char *, int);
76
char * n_m_strcat_ues (char **, char *, int, const char *, const char *, const int);
77
char * BX_stristr (const char *, const char *);
78
char * BX_rstristr (char *, char *);
79
FILE * BX_uzfopen (char **, char *, int);
80
int BX_end_strcmp (const char *, const char *, int);
81
void BX_ircpanic (char *, ...);
82
int fw_strcmp (comp_len_func *, char *, char *);
83
int lw_strcmp (comp_func *, char *, char *);
84
int open_to (char *, int, off_t);
85
struct timeval BX_get_time (struct timeval *);
86
double BX_time_diff (struct timeval, struct timeval);
87
char * BX_plural (int);
88
int BX_time_to_next_minute (void);
89
char * BX_remove_trailing_spaces (char *);
90
char * BX_my_ltoa (long);
91
char * BX_strformat (char *, const char *, int, char);
92
char * chop_word (char *);
93
int BX_splitw (char *, char ***);
94
char * BX_unsplitw (char ***, int);
95
int BX_check_val (char *);
96
char * BX_strextend (char *, char, int);
97
char * strext (char *, char *);
98
char * BX_pullstr (char *, char *);
99
int BX_empty (const char *);
100
char * safe_new_next_arg (char *, char **);
101
char * BX_MatchingBracket (register char *, register char, register char);
102
int BX_word_count (char *);
103
int BX_parse_number (char **);
104
char * BX_remove_brackets (const char *, const char *, int *);
105
u_long hashpjw (char *, u_long);
106
char * BX_m_dupchar (int);
107
char * BX_strmccat (char *, char, int);
108
off_t file_size (char *);
109
int is_root (char *, char *, int);
110
size_t BX_streq (const char *, const char *);
111
size_t BX_strieq (const char *, const char *);
112
char * n_m_strndup (const char *, size_t, const char *, const char *, const int);
113
char * BX_on_off (int);
114
char * BX_rfgets (char *, int, FILE *);
115
char * BX_strmopencat (char *, int, ...);
116
long BX_my_atol (const char *);
117
char * s_next_arg (char **);
118
char * BX_next_in_comma_list (char *, char **);
119
void BX_strip_control (const char *, char *);
120
int BX_figure_out_address (char *, char **, char **, char **, char **, int *);
121
int count_char (const unsigned char *, const unsigned char);
122
char * BX_strnrchr (char *, char, int);
123
void BX_mask_digits (char **);
124
const char *BX_strfill (char, int);
125
char * BX_ov_strcpy (char *, const char *);
126
char * BX_strpcat (char *, const char *, ...);
127
char * BX_strmpcat (char *, size_t, const char *, ...);
128
char * chomp (char *);
129
size_t BX_ccspan (const char *, int);
130
u_char *BX_strcpy_nocolorcodes (u_char *, const u_char *);
131
132
u_long BX_random_number (u_long);
133
char * get_userhost (void);
134
135
char * urlencode (const char *);
136
char * urldecode (char *);
137
138
/* From words.c */
139
#define SOS -32767
140
#define EOS 32767
141
char *BX_strsearch (register char *, char *, char *, int);
142
char *BX_move_to_abs_word (const register char *, char **, int);
143
char *BX_move_word_rel (const register char *, char **, int);
144
char *BX_extract (char *, int, int);
145
char *BX_extract2 (const char *, int, int);
146
int BX_wild_match (const char *, const char *);
147
148
/* Used for connect_by_number */
149
#define SERVICE_SERVER 0
150
#define SERVICE_CLIENT 1
151
#define PROTOCOL_TCP 0
152
#define PROTOCOL_UDP 1
153
154
/* Used from network.c */
155
int BX_connect_by_number (char *, unsigned short *, int, int, int);
156
struct sockaddr_foobar * BX_lookup_host(const char *);
157
char * BX_host_to_ip (const char *);
158
char * BX_ip_to_host (const char *);
159
char * BX_one_to_another (const char *);
160
int BX_set_blocking (int);
161
int BX_set_non_blocking (int);
162
int my_accept (int, struct sockaddr *, int *);
163
int lame_resolv (const char *, struct sockaddr_foobar *);
164
165
#define my_isspace(x) \
166
((x) == 9 || (x) == 10 || (x) == 11 || (x) == 12 || (x) == 13 || (x) == 32)
167
168
#define my_isdigit(x) \
169
(*x >= '0' && *x <= '9') || \
170
((*x == '-' || *x == '+') && (x[1] >= '0' && x[1] <= '9'))
171
172
#define LOCAL_COPY(y) strcpy(alloca(strlen((y)) + 1), y)
173
174
175
#define _1KB ((double) 1000)
176
#define _1MEG (_1KB * _1KB)
177
#define _1GIG (_1KB * _1KB * _1KB)
178
#define _1TER (_1KB * _1KB * _1KB * _1KB)
179
#define _1ETA (_1KB * _1KB * _1KB * _1KB * _1KB)
180
181
#if 0
182
#define _1MEG (1024.0*1024.0)
183
#define _1GIG (1024.0*1024.0*1024.0)
184
#define _1TER (1024.0*1024.0*1024.0*1024.0)
185
#define _1ETA (1024.0*1024.0*1024.0*1024.0*1024.0)
186
#endif
187
188
#define _GMKs(x) ( ((double)x > _1ETA) ? "eb" : \
189
(((double)x > _1TER) ? "tb" : (((double)x > _1GIG) ? "gb" : \
190
(((double)x > _1MEG) ? "mb" : (((double)x > _1KB)? "kb" : "bytes")))))
191
192
#define _GMKv(x) (((double)x > _1ETA) ? \
193
((double)x/_1ETA) : (((double)x > _1TER) ? \
194
((double)x/_1TER) : (((double)x > _1GIG) ? \
195
((double)x/_1GIG) : (((double)x > _1MEG) ? \
196
((double)x/_1MEG) : (((double)x > _1KB) ? \
197
((double)x/_1KB): (double)x)))) )
198
199
void *n_malloc (size_t, const char *, const char *, const int);
200
void *n_realloc (void *, size_t, const char *, const char *, const int);
201
202
void *n_free (void *, const char *, const char *, const int);
203
204
#define MODULENAME NULL
205
206
#define new_malloc(x) n_malloc(x, MODULENAME, __FILE__, __LINE__)
207
#define new_free(x) (*(x) = n_free(*(x), MODULENAME, __FILE__, __LINE__))
208
209
#define RESIZE(x, y, z) ((x) = n_realloc((x), sizeof(y) * (z), MODULENAME, __FILE__, __LINE__))
210
#define malloc_strcpy(x, y) n_malloc_strcpy((char **)x, (char *)y, MODULENAME, __FILE__, __LINE__)
211
#define malloc_strcat(x, y) n_malloc_strcat((char **)x, (char *)y, MODULENAME, __FILE__, __LINE__)
212
#define m_strdup(x) n_m_strdup(x, MODULENAME, __FILE__, __LINE__)
213
#define m_strcat_ues(x, y, z) n_m_strcat_ues(x, y, z, MODULENAME, __FILE__, __LINE__)
214
#define m_strndup(x, y) n_m_strndup(x, y, MODULENAME, __FILE__, __LINE__)
215
216
char *encode (const char *, int);
217
char *decode (const char *);
218
char *BX_cryptit (const char *);
219
int checkpass (const char *, const char *);
220
221
222
/* Used for the inbound mangling stuff */
223
224
#define MANGLE_ESCAPES 1 << 0
225
#define MANGLE_ANSI_CODES 1 << 1
226
#define STRIP_COLOR 1 << 2
227
#define STRIP_REVERSE 1 << 3
228
#define STRIP_UNDERLINE 1 << 4
229
#define STRIP_BOLD 1 << 5
230
#define STRIP_BLINK 1 << 6
231
#define STRIP_ROM_CHAR 1 << 7
232
#define STRIP_ND_SPACE 1 << 8
233
#define STRIP_ALL_OFF 1 << 9
234
#define STRIP_ALT_CHAR 1 << 10
235
#define PRE_MANGLE 1 << 11
236
237
extern int outbound_line_mangler;
238
extern int inbound_line_mangler;
239
extern int logfile_line_mangler;
240
extern int operlog_line_mangler;
241
242
size_t BX_mangle_line (char *, int, size_t);
243
int BX_charcount (const char *, char);
244
char *BX_stripdev (char *);
245
char *convert_dos (char *);
246
char *convert_unix (char *);
247
int is_dos (char *);
248
void strip_chars (char *, char *, char);
249
char *longcomma (long);
250
char *ulongcomma (unsigned long);
251
252
#define SAFE(x) (((x) && *(x)) ? (x) : empty_string)
253
254
/* Used in compat.c */
255
#ifndef HAVE_TPARM
256
char *tparm (const char *, ...);
257
#endif
258
259
int my_base64_encode (const void *, int, char **);
260
261
#ifndef HAVE_STRTOUL
262
unsigned long strtoul (const char *, char **, int);
263
#endif
264
265
char * bsd_getenv (const char *);
266
int bsd_putenv (const char *);
267
int bsd_setenv (const char *, const char *, int);
268
void bsd_unsetenv (const char *);
269
270
#ifndef HAVE_INET_ATON
271
int inet_aton (const char *, struct in_addr *);
272
#endif
273
274
#ifndef HAVE_STRLCPY
275
size_t strlcpy (char *, const char *, size_t);
276
#endif
277
278
#ifndef HAVE_STRLCAT
279
size_t strlcat (char *, const char *, size_t);
280
#endif
281
282
#ifndef HAVE_VSNPRINTF
283
int vsnprintf (char *, size_t, const char *, va_list);
284
#endif
285
286
#ifndef HAVE_SNPRINTF
287
int snprintf (char *, size_t, const char *, ...);
288
#endif
289
290
#ifndef HAVE_SETSID
291
int setsid (void);
292
#endif
293
294
#endif /* _IRCAUX_H_ */
295
296