aboutsummaryrefslogtreecommitdiffstats
path: root/src/command_parse.cpp
blob: fff8653b36986afa3bbed70430887ccddd936de0 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
/*       +------------------------------------+
 *       | Inspire Internet Relay Chat Daemon |
 *       +------------------------------------+
 *
 *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
 * See: http://www.inspircd.org/wiki/index.php/Credits
 *
 * This program is free but copyrighted software; see
 *	    the file COPYING for details.
 *
 * ---------------------------------------------------
 */

/* $Core: libIRCDcommand_parse */

#include "inspircd.h"
#include "wildcard.h"
#include "xline.h"
#include "socketengine.h"
#include "socket.h"
#include "command_parse.h"
#include "exitcodes.h"

/* Directory Searching for Unix-Only */
#ifndef WIN32
#include <dirent.h>
#include <dlfcn.h>
#endif

int InspIRCd::PassCompare(Extensible* ex, const char* data,const char* input, const char* hashtype)
{
	int MOD_RESULT = 0;
	FOREACH_RESULT_I(this,I_OnPassCompare,OnPassCompare(ex, data, input, hashtype))
	if (MOD_RESULT == 1)
		return 0;
	if (MOD_RESULT == -1)
		return 1;
	return strcmp(data,input);
}

/* LoopCall is used to call a command classes handler repeatedly based on the contents of a comma seperated list.
 * There are two overriden versions of this method, one of which takes two potential lists and the other takes one.
 * We need a version which takes two potential lists for JOIN, because a JOIN may contain two lists of items at once,
 * the channel names and their keys as follows:
 * JOIN #chan1,#chan2,#chan3 key1,,key3
 * Therefore, we need to deal with both lists concurrently. The first instance of this method does that by creating
 * two instances of irc::commasepstream and reading them both together until the first runs out of tokens.
 * The second version is much simpler and just has the one stream to read, and is used in NAMES, WHOIS, PRIVMSG etc.
 * Both will only parse until they reach ServerInstance->Config->MaxTargets number of targets, to stop abuse via spam.
 */
int CommandParser::LoopCall(User* user, Command* CommandObj, const char* const* parameters, int pcnt, unsigned int splithere, unsigned int extra)
{
	/* First check if we have more than one item in the list, if we don't we return zero here and the handler
	 * which called us just carries on as it was.
	 */
	if (!strchr(parameters[splithere],','))
		return 0;

	/** Some lame ircds will weed out dupes using some shitty O(n^2) algorithm.
	 * By using std::map (thanks for the idea w00t) we can cut this down a ton.
	 * ...VOOODOOOO!
	 */
	std::map<irc::string, bool> dupes;

	/* Create two lists, one for channel names, one for keys
	 */
	irc::commasepstream items1(parameters[splithere]);
	irc::commasepstream items2(parameters[extra]);
	std::string extrastuff;
	std::string item;
	unsigned int max = 0;

	/* Attempt to iterate these lists and call the command objech
	 * which called us, for every parameter pair until there are
	 * no more left to parse.
	 */
	while (items1.GetToken(item) && (max++ < ServerInstance->Config->MaxTargets))
	{
		if (dupes.find(item.c_str()) == dupes.end())
		{
			const char* new_parameters[MAXPARAMETERS];

			for (int t = 0; (t < pcnt) && (t < MAXPARAMETERS); t++)
				new_parameters[t] = parameters[t];

			if (!items2.GetToken(extrastuff))
				extrastuff = "";

			new_parameters[splithere] = item.c_str();
			new_parameters[extra] = extrastuff.c_str();

			CommandObj->Handle(new_parameters,pcnt,user);

			dupes[item.c_str()] = true;
		}
	}
	return 1;
}

int CommandParser::LoopCall(User* user, Command* CommandObj, const char* const* parameters, int pcnt, unsigned int splithere)
{
	/* First check if we have more than one item in the list, if we don't we return zero here and the handler
	 * which called us just carries on as it was.
	 */
	if (!strchr(parameters[splithere],','))
		return 0;

	std::map<irc::string, bool> dupes;

	/* Only one commasepstream here */
	irc::commasepstream items1(parameters[splithere]);
	std::string item;
	unsigned int max = 0;

	/* Parse the commasepstream until there are no tokens remaining.
	 * Each token we parse out, call the command handler that called us
	 * with it
	 */
	while (items1.GetToken(item) && (max++ < ServerInstance->Config->MaxTargets))
	{
		if (dupes.find(item.c_str()) == dupes.end())
		{
			const char* new_parameters[MAXPARAMETERS];

			for (int t = 0; (t < pcnt) && (t < MAXPARAMETERS); t++)
				new_parameters[t] = parameters[t];

			new_parameters[splithere] = item.c_str();

			/* Execute the command handler over and over. If someone pulls our user
			 * record out from under us (e.g. if we /kill a comma sep list, and we're
			 * in that list ourselves) abort if we're gone.
			 */
			CommandObj->Handle(new_parameters,pcnt,user);

			dupes[item.c_str()] = true;
		}
	}
	/* By returning 1 we tell our caller that nothing is to be done,
	 * as all the previous calls handled the data. This makes the parent
	 * return without doing any processing.
	 */
	return 1;
}

bool CommandParser::IsValidCommand(const std::string &commandname, int pcnt, User * user)
{
	Commandable::iterator n = cmdlist.find(commandname);

	if (n != cmdlist.end())
	{
		if ((pcnt>=n->second->min_params) && (n->second->source != "<core>"))
		{
			if (IS_LOCAL(user) && n->second->flags_needed)
			{
				if (user->IsModeSet(n->second->flags_needed))
				{
					return (user->HasPermission(commandname));
				}
			}
			else
			{
				return true;
			}
		}
	}
	return false;
}

Command* CommandParser::GetHandler(const std::string &commandname)
{
	Commandable::iterator n = cmdlist.find(commandname);
	if (n != cmdlist.end())
		return n->second;

	return NULL;
}

// calls a handler function for a command

CmdResult CommandParser::CallHandler(const std::string &commandname,const char* const* parameters, int pcnt, User *user)
{
	Commandable::iterator n = cmdlist.find(commandname);

	if (n != cmdlist.end())
	{
		if (pcnt >= n->second->min_params)
		{
			bool bOkay = false;

			if (IS_LOCAL(user) && n->second->flags_needed)
			{
				/* if user is local, and flags are needed .. */

				if (user->IsModeSet(n->second->flags_needed))
				{
					/* if user has the flags, and now has the permissions, go ahead */
					if (user->HasPermission(commandname))
						bOkay = true;
				}
			}
			else
			{
				/* remote or no flags required anyway */
				bOkay = true;
			}

			if (bOkay)
			{
				return n->second->Handle(parameters,pcnt,user);
			}
		}
	}
	return CMD_INVALID;
}

void CommandParser::DoLines(User* current, bool one_only)
{
	// while there are complete lines to process...
	unsigned int floodlines = 0;

	while (current->BufferIsReady())
	{
		if (current->MyClass)
		{
			if (ServerInstance->Time() > current->reset_due)
			{
				current->reset_due = ServerInstance->Time() + current->MyClass->GetThreshold();
				current->lines_in = 0;
			}

			if (++current->lines_in > current->MyClass->GetFlood() && current->MyClass->GetFlood())
			{
				ServerInstance->FloodQuitUser(current);
				return;
			}

			if ((++floodlines > current->MyClass->GetFlood()) && (current->MyClass->GetFlood() != 0))
			{
				ServerInstance->FloodQuitUser(current);
				return;
			}
		}

		// use GetBuffer to copy single lines into the sanitized string
		std::string single_line = current->GetBuffer();
		current->bytes_in += single_line.length();
		current->cmds_in++;
		if (single_line.length() > MAXBUF - 2)  // MAXBUF is 514 to allow for neccessary line terminators
			single_line.resize(MAXBUF - 2); // So to trim to 512 here, we use MAXBUF - 2

		// ProcessBuffer returns false if the user has gone over penalty
		if (!ServerInstance->Parser->ProcessBuffer(single_line, current) || one_only)
			break;
	}
}

bool CommandParser::ProcessCommand(User *user, std::string &cmd)
{
	const char *command_p[MAXPARAMETERS];
	int items = 0;
	irc::tokenstream tokens(cmd);
	std::string command;
	tokens.GetToken(command);

	/* A client sent a nick prefix on their command (ick)
	 * rhapsody and some braindead bouncers do this --
	 * the rfc says they shouldnt but also says the ircd should
	 * discard it if they do.
	 */
	if (*command.c_str() == ':')
		tokens.GetToken(command);

	while (tokens.GetToken(para[items]) && (items < MAXPARAMETERS))
	{
		command_p[items] = para[items].c_str();
		items++;
	}

	std::transform(command.begin(), command.end(), command.begin(), ::toupper);
		
	int MOD_RESULT = 0;
	FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,false,cmd));
	if (MOD_RESULT == 1) {
		return true;
	}

	/* find the command, check it exists */
	Commandable::iterator cm = cmdlist.find(command);
	
	if (cm == cmdlist.end())
	{
		if (user->registered == REG_ALL)
		{
			user->WriteNumeric(421, "%s %s :Unknown command",user->nick,command.c_str());
		}
		ServerInstance->stats->statsUnknown++;
		return true;
	}

	/* Modify the user's penalty */
	bool do_more = true;
	if (!user->ExemptFromPenalty)
	{
		user->IncreasePenalty(cm->second->Penalty);
		do_more = (user->Penalty < 10);
		if (!do_more)
			user->OverPenalty = true;
	}

	/* activity resets the ping pending timer */
	if (user->MyClass)
		user->nping = ServerInstance->Time() + user->MyClass->GetPingTime();

	if (cm->second->flags_needed)
	{
		if (!user->IsModeSet(cm->second->flags_needed))
		{
			user->WriteNumeric(481, "%s :Permission Denied - You do not have the required operator privileges",user->nick);
			return do_more;
		}
		if (!user->HasPermission(command))
		{
			user->WriteNumeric(481, "%s :Permission Denied - Oper type %s does not have access to command %s",user->nick,user->oper,command.c_str());
			return do_more;
		}
	}
	if ((user->registered == REG_ALL) && (!IS_OPER(user)) && (cm->second->IsDisabled()))
	{
		/* command is disabled! */
		user->WriteNumeric(421, "%s %s :This command has been disabled.",user->nick,command.c_str());
		ServerInstance->SNO->WriteToSnoMask('d', "%s denied for %s (%s@%s)",
				command.c_str(), user->nick, user->ident, user->host);
		return do_more;
	}
	if (items < cm->second->min_params)
	{
		user->WriteNumeric(461, "%s %s :Not enough parameters.", user->nick, command.c_str());
		if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (cm->second->syntax.length()))
			user->WriteNumeric(304, "%s :SYNTAX %s %s", user->nick, cm->second->command.c_str(), cm->second->syntax.c_str());
		return do_more;
	}
	if ((user->registered != REG_ALL) && (!cm->second->WorksBeforeReg()))
	{
		user->WriteNumeric(451, "%s :You have not registered",command.c_str());
		return do_more;
	}
	else
	{
		/* passed all checks.. first, do the (ugly) stats counters. */
		cm->second->use_count++;
		cm->second->total_bytes += cmd.length();

		/* module calls too */
		MOD_RESULT = 0;
		FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,true,cmd));
		if (MOD_RESULT == 1)
			return do_more;

		/*
		 * WARNING: be careful, the user may be deleted soon
		 */
		CmdResult result = cm->second->Handle(command_p,items,user);

		FOREACH_MOD(I_OnPostCommand,OnPostCommand(command, command_p, items, user, result,cmd));
		return do_more;
	}
}

bool CommandParser::RemoveCommands(const char* source)
{
	Commandable::iterator i,safei;
	for (i = cmdlist.begin(); i != cmdlist.end(); i++)
	{
		safei = i;
		safei++;
		if (safei != cmdlist.end())
		{
			RemoveCommand(safei, source);
		}
	}
	safei = cmdlist.begin();
	if (safei != cmdlist.end())
	{
		RemoveCommand(safei, source);
	}
	return true;
}

void CommandParser::RemoveCommand(Commandable::iterator safei, const char* source)
{
	Command* x = safei->second;
	if (x->source == std::string(source))
	{
		cmdlist.erase(safei);
		delete x;
	}
}

bool CommandParser::ProcessBuffer(std::string &buffer,User *user)
{
	std::string::size_type a;

	if (!user)
		return true;

	while ((a = buffer.rfind("\n")) != std::string::npos)
		buffer.erase(a);
	while ((a = buffer.rfind("\r")) != std::string::npos)
		buffer.erase(a);

	if (buffer.length())
	{
		ServerInstance->Logs->Log("USERINPUT", DEBUG,"C[%d] I :%s %s",user->GetFd(), user->nick, buffer.c_str());
		return this->ProcessCommand(user,buffer);
	}

	return true;
}

bool CommandParser::CreateCommand(Command *f, void* so_handle)
{
	if (so_handle)
	{
		if (RFCCommands.find(f->command) == RFCCommands.end())
			RFCCommands[f->command] = so_handle;
		else
		{
			ServerInstance->Logs->Log("COMMAND",DEFAULT,"ERK! Somehow, we loaded a cmd_*.so file twice! Only the first instance is being recorded.");
			return false;
		}
	}

	/* create the command and push it onto the table */
	if (cmdlist.find(f->command) == cmdlist.end())
	{
		cmdlist[f->command] = f;
		return true;
	}
	else return false;
}

CommandParser::CommandParser(InspIRCd* Instance) : ServerInstance(Instance)
{
	para.resize(128);
}

bool CommandParser::FindSym(void** v, void* h, const std::string &name)
{
	*v = dlsym(h, "init_command");
	const char* err = dlerror();
	if (err && !(*v))
	{
		ServerInstance->Logs->Log("COMMAND",SPARSE, "Error loading core command %s: %s\n", name.c_str(), err);
		return false;
	}
	return true;
}

bool CommandParser::ReloadCommand(const char* cmd, User* user)
{
	char filename[MAXBUF];
	char commandname[MAXBUF];
	int y = 0;

	for (const char* x = cmd; *x; x++, y++)
		commandname[y] = toupper(*x);

	commandname[y] = 0;

	SharedObjectList::iterator command = RFCCommands.find(commandname);

	if (command != RFCCommands.end())
	{
		Command* cmdptr = cmdlist.find(commandname)->second;
		cmdlist.erase(cmdlist.find(commandname));

		for (char* x = commandname; *x; x++)
			*x = tolower(*x);


		delete cmdptr;
		dlclose(command->second);
		RFCCommands.erase(command);

		snprintf(filename, MAXBUF, "cmd_%s.so", commandname);
		const char* err = this->LoadCommand(filename);
		if (err)
		{
			if (user)
				user->WriteServ("NOTICE %s :*** Error loading 'cmd_%s.so': %s", user->nick, cmd, err);
			return false;
		}

		return true;
	}

	return false;
}

CmdResult cmd_reload::Handle(const char* const* parameters, int /* pcnt */, User *user)
{
	user->WriteServ("NOTICE %s :*** Reloading command '%s'",user->nick, parameters[0]);
	if (ServerInstance->Parser->ReloadCommand(parameters[0], user))
	{
		user->WriteServ("NOTICE %s :*** Successfully reloaded command '%s'", user->nick, parameters[0]);
		ServerInstance->SNO->WriteToSnoMask('A', "RELOAD: %s reloaded the '%s' command.", user->nick, parameters[0]);
		return CMD_SUCCESS;
	}
	else
	{
		user->WriteServ("NOTICE %s :*** Could not reload command '%s' -- fix this problem, then /REHASH as soon as possible!", user->nick, parameters[0]);
		return CMD_FAILURE;
	}
}

const char* CommandParser::LoadCommand(const char* name)
{
	char filename[MAXBUF];
	void* h;
	Command* (*cmd_factory_func)(InspIRCd*);

	/* Command already exists? Succeed silently - this is needed for REHASH */
	if (RFCCommands.find(name) != RFCCommands.end())
	{
		ServerInstance->Logs->Log("COMMAND",DEBUG,"Not reloading command %s/%s, it already exists", LIBRARYDIR, name);
		return NULL;
	}

	snprintf(filename, MAXBUF, "%s/%s", LIBRARYDIR, name);
	h = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);

	if (!h)
	{
		const char* n = dlerror();
		ServerInstance->Logs->Log("COMMAND",SPARSE, "Error loading core command %s: %s", name, n);
		return n;
	}

	if (this->FindSym((void **)&cmd_factory_func, h, name))
	{
		Command* newcommand = cmd_factory_func(ServerInstance);
		this->CreateCommand(newcommand, h);
	}
	return NULL;
}

void CommandParser::SetupCommandTable(User* user)
{
	RFCCommands.clear();

	if (!user)
	{
		printf("\nLoading core commands");
		fflush(stdout);
	}

	DIR* library = opendir(LIBRARYDIR);
	if (library)
	{
		dirent* entry = NULL;
		while ((entry = readdir(library)))
		{
			if (match(entry->d_name, "cmd_*.so"))
			{
				if (!user)
				{
					printf(".");
					fflush(stdout);
				}
				const char* err = this->LoadCommand(entry->d_name);
				if (err)
				{
					if (user)
					{
						user->WriteServ("NOTICE %s :*** Failed to load core command %s: %s", user->nick, entry->d_name, err);
					}
					else
					{
						printf("Error loading %s: %s", entry->d_name, err);
						exit(EXIT_STATUS_BADHANDLER);
					}
				}
			}
		}
		closedir(library);
		if (!user)
			printf("\n");
	}

	if (cmdlist.find("RELOAD") == cmdlist.end())
		this->CreateCommand(new cmd_reload(ServerInstance));
}

int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, std::string &dest)
{
	User* user = NULL;
	std::string item;
	int translations = 0;
	dest.clear();

	switch (to)
	{
		case TR_NICK:
			/* Translate single nickname */
			user = ServerInstance->FindNick(source);
			if (user)
			{
				dest = user->uuid;
				translations++;
			}
			else
				dest = source;
		break;
		case TR_NICKLIST:
		{
			/* Translate comma seperated list of nicknames */
			irc::commasepstream items(source);
			while (items.GetToken(item))
			{
				user = ServerInstance->FindNick(item);
				if (user)
				{
					dest.append(user->uuid);
					translations++;
				}
				else
					dest.append(item);
				dest.append(",");
			}
			if (!dest.empty())
				dest.erase(dest.end() - 1);
		}
		break;
		case TR_SPACENICKLIST:
		{
			/* Translate space seperated list of nicknames */
			irc::spacesepstream items(source);
			while (items.GetToken(item))
			{
				user = ServerInstance->FindNick(item);
				if (user)
				{
					dest.append(user->uuid);
					translations++;
				}
				else
					dest.append(item);
				dest.append(" ");
			}
			if (!dest.empty())
				dest.erase(dest.end() - 1);
		}
		break;
		case TR_END:
		case TR_TEXT:
		default:
			/* Do nothing */
			dest = source;
		break;
	}

	return translations;
}
dnl configure.in for irc-2.9.5
dnl Matthew Green (mrg@mame.mu.oz.au), Alain Nissen (Alain.Nissen@ulg.ac.be)
dnl using portions of Avalon's Config and GNU Autoconf 1.12.

dnl ---------
dnl new tests
dnl ---------

AC_DEFUN(IRC_PATH_ZLIB,
[AC_MSG_CHECKING(for zlib package)
AC_ARG_WITH(zlib, [  --with-zlib             checks for zlib; if found, enables compressed links])
AC_ARG_WITH(zlib, [  --without-zlib          does not check for zlib; disables compressed links])
if test "x$with_zlib" = xno; then
  no_zlib=yes
else
AC_CACHE_VAL(irc_cv_path_zlib,
[no_zlib=yes
no_zlib_include=yes
no_zlib_library=yes
AC_TRY_CPP([#include <zlib.h>],
[no_zlib_include=
irc_zlib_include=],
[for irc_dir in "$irc_zlib_include" \
                     `test -z "$irc_zlib_prefix" || echo "$irc_zlib_prefix/include"` \
                     `echo "$irc_zlib_library" | sed s/lib/include/` \
                     /usr/include /usr/local/include /usr/unsupported/include \
                     /usr/share/include /usr/local/share/include /include \
                     /usr/zlib/include /usr/local/zlib/include \
                     /usr/include/zlib /usr/local/include/zlib \
                     /usr/unsupported/include/zlib /usr/share/include/zlib \
                     /usr/local/share/include/zlib /include/zlib \
                     /usr/zlib/include/zlib /usr/local/zlib/include/zlib; \
  do
    if test -r "$irc_dir/zlib.h"; then
      no_zlib_include=
      irc_zlib_include=$irc_dir
      break
    fi
  done
])
irc_save_LIBS="$LIBS"
LIBS="-lz $LIBS"
AC_TRY_LINK(,
[inflate()],
[no_zlib_library=
irc_zlib_library=
LIBS="$irc_save_LIBS"],
[LIBS="$irc_save_LIBS"
for irc_dir in "$irc_zlib_library" \
                    `test -z "$irc_zlib_prefix" || echo "$irc_zlib_prefix/lib"` \
                    `echo "$irc_zlib_include" | sed s/include/lib/` \
                    /usr/lib /usr/local/lib /usr/unsupported/lib \
                    /usr/share/lib /usr/local/share/lib /lib /usr/zlib/lib \
                    /usr/local/zlib/lib /usr/lib/zlib /usr/local/lib/zlib \
                    /usr/unsupported/lib/zlib /usr/share/lib/zlib \
                    /usr/local/share/lib/zlib /lib/zlib \
                    /usr/zlib/lib/zlib /usr/local/zlib/lib/zlib; \
do
  for irc_extension in a so sl; do
    if test -r $irc_dir/libz.$irc_extension; then
      no_zlib_library=
      irc_zlib_library=$irc_dir
      break 2
    fi
  done
done
])
if test "x$no_zlib_include" = x && test "x$no_zlib_library" = x; then
  no_zlib=
fi
if test "$no_zlib" = yes; then
  irc_cv_path_zlib="no_zlib=yes"
else
  irc_cv_path_zlib="no_zlib= irc_zlib_include=$irc_zlib_include irc_zlib_library=$irc_zlib_library"
fi])
  eval "$irc_cv_path_zlib"
fi
if test "$no_zlib" = yes; then
  IRC_ZLIB_LIBRARY=
  IRC_ZLIB_INCLUDE=
  AC_MSG_RESULT(no)
else
  AC_DEFINE(USE_ZLIB)
  if test "x$irc_zlib_library" = x; then
    irc_zlib_library_message="found by the linker"
    IRC_ZLIB_LIBRARY=-lz
  else
    irc_zlib_library_message="in $irc_zlib_library"
    IRC_ZLIB_LIBRARY=-L$irc_zlib_library
    if test ! "$irc_cv_solaris_2" = no; then
      IRC_ZLIB_LIBRARY="$IRC_ZLIB_LIBRARY -R$irc_zlib_library"
    fi
    IRC_ZLIB_LIBRARY="$IRC_ZLIB_LIBRARY -lz"
  fi
  if test "x$irc_zlib_include" = x; then
    irc_zlib_include_message="found by the compiler"
    IRC_ZLIB_INCLUDE=
  else
    irc_zlib_include_message="in $irc_zlib_include"
    IRC_ZLIB_INCLUDE=-I$irc_zlib_include
  fi
  AC_MSG_RESULT([])
  AC_MSG_RESULT([  library $irc_zlib_library_message])
  AC_MSG_RESULT([  header $irc_zlib_include_message])
fi
AC_SUBST(IRC_ZLIB_INCLUDE)
AC_SUBST(IRC_ZLIB_LIBRARY)
])


AC_DEFUN(IRC_CURSES_TERMCAP,
[AC_MSG_CHECKING([which curses or termcap library will be used])
AC_ARG_WITH(ncurses, [  --without-ncurses       does not look for ncurses library, will not use it])
AC_ARG_WITH(cursesX, [  --without-cursesX       does not look for cursesX library, will not use it])
AC_ARG_WITH(curses, [  --without-curses        does not look for curses library, will not use it])
AC_ARG_WITH(termcap, [  --without-termcap       does not look for termcap library, will not use it])
AC_CACHE_VAL(irc_cv_curses_termcap,
[irc_save_LIBS="$LIBS"
LIBS="-lncurses $irc_save_LIBS"
AC_TRY_LINK(,
[initscr()],
irc_ncurses=yes,
irc_ncurses=no)
LIBS="-lcursesX $irc_save_LIBS"
AC_TRY_LINK(,
[initscr()],
irc_cursesX=yes,
irc_cursesX=no)
LIBS="-lcurses $irc_save_LIBS"
AC_TRY_LINK(,
[initscr()],
irc_curses=yes,
irc_curses=no)
LIBS="-lcurses -ltermcap $irc_save_LIBS"
AC_TRY_LINK(,
[initscr()],
irc_curses_termcap=yes,
irc_curses_termcap=no)
LIBS="-ltermcap $irc_save_LIBS"
AC_TRY_LINK(,
[tgetent()],
irc_termcap=yes,
irc_termcap=no)
LIBS="$irc_save_LIBS"
irc_cv_curses_termcap="irc_ncurses=$irc_ncurses irc_curses=$irc_curses irc_cursesX=$irc_cursesX irc_curses_termcap=$irc_curses_termcap irc_termcap=$irc_termcap"
])
eval $irc_cv_curses_termcap
if test "x$with_ncurses" = xno; then
  irc_ncurses=no
fi
if test "x$with_cursesX" = xno; then
  irc_cursesX=no
fi
if test "x$with_curses" = xno; then
  irc_curses=no
  irc_curses_termcap=no
fi
if test "x$with_termcap" = xno; then
  irc_termcap=no
fi
if test $irc_ncurses = yes; then
  AC_MSG_RESULT(ncurses)
  AC_DEFINE(USE_NCURSES)
  IRC_CURSES_TERMCAP_LIBRARY="-lncurses"
elif test $irc_cursesX = yes; then
  AC_MSG_RESULT(cursesX)
  AC_DEFINE(USE_CURSESX)
  IRC_CURSES_TERMCAP_LIBRARY="-lcursesX"
elif test $irc_curses = yes; then
  AC_MSG_RESULT(curses)
  AC_DEFINE(USE_CURSES)
  IRC_CURSES_TERMCAP_LIBRARY="-lcurses"
elif test $irc_curses_termcap = yes; then
  AC_MSG_RESULT(curses over termcap)
  AC_DEFINE(USE_CURSES)
  IRC_CURSES_TERMCAP_LIBRARY="-lcurses -ltermcap"
elif test $irc_termcap = yes; then
  AC_MSG_RESULT(termcap)
  AC_DEFINE(USE_TERMCAP)
  IRC_CURSES_TERMCAP_LIBRARY="-ltermcap"
else
  AC_MSG_RESULT(none)
  AC_MSG_WARN([I can't find either ncurses, cursesX, curses or termcap library.])
  IRC_CURSES_TERMCAP_LIBRARY=
fi
AC_SUBST(IRC_CURSES_TERMCAP_LIBRARY)
])


AC_DEFUN(IRC_UNION_WAIT,
[AC_MSG_CHECKING(whether an union wait * is mandatory in waitpid)
AC_CACHE_VAL(irc_cv_type_union_wait,
AC_TRY_COMPILE([
#if HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif],
[
int status;
waitpid(-1, &status, 0);
],
irc_cv_type_union_wait=no,
AC_TRY_COMPILE([
#if HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif],
[
union wait status;
waitpid(-1, &status, 0);
],
irc_cv_type_union_wait=yes,
irc_cv_type_union_wait=no)))
if test $irc_cv_type_union_wait = yes; then
  AC_MSG_RESULT(yes)
  AC_DEFINE(USE_UNION_WAIT)
else
  AC_MSG_RESULT(no)
fi
])


AC_DEFUN(IRC_SOLARIS_2,
[AC_MSG_CHECKING([for Solaris 2.x (SunOS 5.x)])
AC_CACHE_VAL(irc_cv_solaris_2,
[if test "x`(uname) 2>/dev/null`" = "xSunOS" &&
  uname -r 2>/dev/null | grep "^5" >/dev/null; then
  irc_cv_solaris_2="`uname -r | sed -e \"s/^5/2/g\"`"
else
  irc_cv_solaris_2=no
fi
])
if test "$irc_cv_solaris_2" = no; then
  AC_MSG_RESULT(no)
else
  AC_MSG_RESULT([yes, $irc_cv_solaris_2])
  AC_DEFINE(SOLARIS_2)
  if echo "$irc_cv_solaris_2" | egrep "^2\.(0|1|2)" >/dev/null; then
    AC_DEFINE(SOLARIS_2_0_2_1_2_2)
  elif echo "$irc_cv_solaris_2" | grep "^2\.3" >/dev/null; then
    AC_DEFINE(SOLARIS_2_3)
  fi
fi
])


AC_DEFUN(IRC_DECL_SYS_ERRLIST,
[AC_CACHE_CHECK([for sys_errlist declaration in stdio.h, errno.h or sys/errno.h],
  irc_cv_decl_sys_errlist,
[AC_TRY_COMPILE([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_ERRNO_H
#include <errno.h>
#endif
#if HAVE_SYS_ERRNO_H
#include <sys/errno.h>
#endif],
[char *msg = sys_errlist[0];],
  irc_cv_decl_sys_errlist=yes, irc_cv_decl_sys_errlist=no)])
if test $irc_cv_decl_sys_errlist = yes; then
  AC_DEFINE(SYS_ERRLIST_DECLARED)
fi
])


AC_DEFUN(IRC_DECL_SYS_NERR,
[AC_CACHE_CHECK([for sys_nerr declaration in stdio.h, errno.h or sys/errno.h],
  irc_cv_decl_sys_nerr,
[AC_TRY_COMPILE([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_ERRNO_H
#include <errno.h>
#endif
#if HAVE_SYS_ERRNO_H
#include <sys/errno.h>
#endif],
[int num = sys_nerr;],
  irc_cv_decl_sys_nerr=yes, irc_cv_decl_sys_nerr=no)])
if test $irc_cv_decl_sys_nerr = yes; then
  AC_DEFINE(SYS_NERR_DECLARED)
fi
])


AC_DEFUN(IRC_DECL_ERRNO,
[AC_CACHE_CHECK([for errno declaration in errno.h or sys/errno.h],
  irc_cv_decl_errno,
[AC_TRY_COMPILE([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_ERRNO_H
#include <errno.h>
#endif
#if HAVE_SYS_ERRNO_H
#include <sys/errno.h>
#endif],
[int num = errno;],
  irc_cv_decl_errno=yes, irc_cv_decl_errno=no)])
if test $irc_cv_decl_errno = yes; then
  AC_DEFINE(ERRNO_DECLARED)
fi
])


AC_DEFUN(IRC_DECL_H_ERRNO,
[AC_CACHE_CHECK([for h_errno declaration in errno.h, sys/errno.h or netdb.h],
  irc_cv_decl_h_errno,
[AC_TRY_COMPILE([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_ERRNO_H
#include <errno.h>
#endif
#if HAVE_SYS_ERRNO_H
#include <sys/errno.h>
#endif
#if HAVE_NETDB_H
#include <netdb.h>
#endif],
[int num = h_errno;],
  irc_cv_decl_h_errno=yes, irc_cv_decl_h_errno=no)])
if test $irc_cv_decl_h_errno = yes; then
  AC_DEFINE(H_ERRNO_DECLARED)
fi
])


AC_DEFUN(IRC_SGI_CC,
[AC_MSG_CHECKING([for SGI's cc])
AC_EGREP_CPP(yes,
[#ifdef sgi
yes
#endif],
if test x$CC = xcc; then
  AC_MSG_RESULT(yes)
  CC="$CC -cckr"
else
  AC_MSG_RESULT(no)
fi,
AC_MSG_RESULT(no))
])


AC_DEFUN(IRC_ALPHA_BETA,
[AC_MSG_CHECKING(whether this is an alpha/beta release)
AC_CACHE_VAL(irc_cv_alpha_beta,
[AC_EGREP_CPP(^\"......00,
[#include "../common/patchlevel.h"
#ifdef PATCHLEVEL
PATCHLEVEL
#else
"0000000000"
#endif
],irc_cv_alpha_beta=,
irc_cv_alpha_beta=yes)
])
if test x$irc_cv_alpha_beta = xyes; then
  AC_MSG_RESULT(yes)
  AC_MSG_WARN([

This is a development version of the package,
it is not intended to be used in a production environment.
])
  if test ! "$ac_test_CFLAGS" = set; then
    if test x$ac_cv_prog_cc_g = xyes -o x$GCC = x; then
      CFLAGS="$CFLAGS -g"
    fi
  fi
else
  AC_MSG_RESULT(no)
  if test ! "${LDFLAGS+set}" = set; then
    LDFLAGS="-s"
  fi
fi
])


AC_DEFUN(IRC_SELECT_POLL,
[AC_MSG_CHECKING([whether select or poll system call will be used])
AC_CACHE_VAL(irc_cv_select_poll,
[if test x$ac_cv_func_select = xyes; then
  irc_cv_select_poll=select
else
  irc_cv_select_poll=poll
fi
AC_EGREP_CPP(yes,[
#if (defined(sun) && (defined(__SVR4) || defined(__svr4__))) \
    || defined(sgi) || defined(__sgi) \
    || defined(_AIX)
yes
#endif
],
irc_cv_select_poll=poll,
)])
if test $irc_cv_select_poll = poll; then
  AC_MSG_RESULT(poll)
  AC_DEFINE(USE_POLL)
else
  AC_MSG_RESULT(select)
fi
])


AC_DEFUN(IRC_SIGNAL_IMPLEMENTATION,
[AC_MSG_CHECKING([for signal implementation])
AC_CACHE_VAL(irc_cv_signal_implementation,
[if test x$ac_cv_func_sigaction = xyes; then
  irc_cv_signal_implementation=posix_sigaction
elif test x$ac_cv_func_sigset = xyes; then
  irc_cv_signal_implementation=bsd_sigset
else
  AC_TRY_RUN([
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifndef SIGCHLD
#define SIGCHLD SIGCLD
#endif

int got = 0;

RETSIGTYPE hand()
{
  got++;
}

main()
{
  (void)signal(SIGCHLD, hand);
  kill(getpid(), SIGCHLD);
  kill(getpid(), SIGCHLD);
  if (got < 2)
    exit(1);
  exit(0);
}
],
    irc_cv_signal_implementation=bsd_signal,
    irc_cv_signal_implementation=sysv_signal)
fi
])
if test $irc_cv_signal_implementation = posix_sigaction; then
  AC_MSG_RESULT([using POSIX sigaction])
  AC_DEFINE(POSIX_SIGNALS)
elif test $irc_cv_signal_implementation = bsd_sigset; then
  AC_MSG_RESULT([using BSD sigset])
  AC_DEFINE(BSD_RELIABLE_SIGNALS)
  AC_DEFINE(signal, sigset)
elif test $irc_cv_signal_implementation = bsd_signal; then
  AC_MSG_RESULT([using reliable BSD signal])
  AC_DEFINE(BSD_RELIABLE_SIGNALS)
else
  AC_MSG_RESULT([using unreliable SystemV signal])
  AC_DEFINE(SYSV_UNRELIABLE_SIGNALS)
fi
])


AC_DEFUN(IRC_NON_BLOCKING_SYSTEM,
[AC_MSG_CHECKING([for a working non-blocking system])
AC_CACHE_VAL(irc_cv_non_blocking_system,
[
changequote(<<, >>)dnl
irc_precode='#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
#if HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#if HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#if HAVE_SIGNAL_H
#include <signal.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif

RETSIGTYPE alarmed()
{
  exit(1);
}

main()
{
  char b[12];
  struct sockaddr_in x;
  int f, l = sizeof(x);
  f = socket(AF_INET, SOCK_DGRAM, 0);
  if (f >= 0 && !(fcntl(f, F_SETFL, '
irc_postcode=')))
    {
      signal(SIGALRM, alarmed);
      alarm(3);
      recvfrom(f, b, 12, 0, &x, &l);
      alarm(0);
      exit(0);
    }
   exit(1);
}'
changequote([, ])dnl
irc_code_posix="${irc_precode}O_NONBLOCK${irc_postcode}"
irc_code_bsd="${irc_precode}O_NDELAY${irc_postcode}"
irc_code_sysv="${irc_precode}FIONBIO${irc_postcode}"
AC_TRY_RUN($irc_code_posix,
  irc_cv_non_blocking_system=posix,
  AC_TRY_RUN($irc_code_bsd,
    irc_cv_non_blocking_system=bsd,
    AC_TRY_RUN($irc_code_sysv,
      irc_cv_non_blocking_system=sysv,
      irc_cv_non_blocking_system=none)))
])
if test $irc_cv_non_blocking_system = posix; then
  AC_MSG_RESULT([using POSIX O_NONBLOCK])
  AC_DEFINE(NBLOCK_POSIX)
elif test $irc_cv_non_blocking_system = bsd; then
  AC_MSG_RESULT([using BSD O_NDELAY])
  AC_DEFINE(NBLOCK_BSD)
elif test $irc_cv_non_blocking_system = sysv; then
  AC_MSG_RESULT([using SystemV FIONBIO])
  AC_DEFINE(NBLOCK_SYSV)
else
  AC_MSG_RESULT([using none])
  AC_MSG_WARN([I can't find a working non-blocking system.])
fi
])


AC_DEFUN(IRC_STDARG,
[AC_MSG_CHECKING([for working stdarg])
AC_CACHE_VAL(irc_cv_stdarg,
AC_TRY_RUN(
[
changequote(<<, >>)dnl
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_STDARG_H
#include <stdarg.h>
#endif
#if HAVE_STRING_H
#include <string.h>
#endif

char buf1[256];

int level1(char *data, char *format, va_list ap)
{
  return vsprintf(data, format, ap);
}

int level2(char *data, int rounds, char *format, va_list ap)
{
  if(!--rounds)
    return level1(data, format, ap);
  else {
    if(rounds == 2) {
      va_list ap2 = ap;
      char *arg = va_arg(ap2, char *);
      strcpy(buf1, arg);
    }
    return level2(data, rounds, format, ap);
  }
}

int level3(char *data, char *format, va_list ap)
{
  return level2(data, 5, format, ap);
}

int dotest(int size, char *val, char *data)
{
  if(size != strlen(val))
    return 0;
  if(strcmp(data, val))
    return 0;
  if(strcmp(buf1, "was"))
    return 0;
  return 1;
}

int base(char *val, char *format, ...)
{
  int res = 1;
  char data[256];

  {
    va_list ap;
    data[0]=0;
    va_start(ap, format);
    res = dotest(level3(data, format, ap), val, data);
    va_end(ap);
  }

  {
    va_list ap;
    data[0]=0;
    va_start(ap, format);
    res = res && dotest(level3(data, format, ap), val, data);
    va_end(ap);
  }

  return res;
}

int main(void)
{
  int res = base("toto was here ! 42", "toto %s here ! %d", "was", 42);

  exit(res ? 0 : 1);
}
changequote([, ])dnl
],
irc_cv_stdarg=yes,
irc_cv_stdarg=no)
)
if test $irc_cv_stdarg = yes; then
  AC_MSG_RESULT(yes)
  AC_DEFINE(USE_STDARG)
else
  AC_MSG_RESULT(no)
fi
])


AC_DEFUN(IRC_PATH_RESCONF,
[AC_MSG_CHECKING([for resolver configuration file])
AC_CACHE_VAL(irc_cv_path_resconf,
[no_resconf=yes
for irc_file in `test -z "$irc_resconf" || echo "$irc_resconf"` \
                /etc/resolv.conf; \
  do
    if test -r "$irc_file"; then
      no_resconf=
      irc_cv_path_resconf="$irc_file"
      break
    fi
  done
])
if test "$no_resconf" = yes; then
  AC_MSG_RESULT(not found... falling back on default (/etc/resolv.conf))
  AC_MSG_WARN([without resolver configuration file, the server won't work.])
  AC_DEFINE(IRC_RESCONF, "/etc/resolv.conf")
else
  AC_MSG_RESULT($irc_cv_path_resconf)
  AC_DEFINE_UNQUOTED(IRC_RESCONF, "$irc_cv_path_resconf")
fi
])


AC_DEFUN(IRC_EGREP_RMLF_CPP,
[cat > conftest.$ac_ext <<EOF
[#]line __oline__ "configure"
#include "confdefs.h"
[$2]
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |
  $AWK "{if (NR > 1) printf(\" \"); printf(\[$]0)}" |
changequote(, )dnl
  egrep "$1" >/dev/null 2>&1; then
changequote([, ])dnl
  ifelse([$3], , :, [rm -rf conftest*
  $3])
ifelse([$4], , , [else
  rm -rf conftest*
  $4
])dnl
fi
rm -f conftest*
])


AC_DEFUN(IRC_LINUX,
[AC_MSG_CHECKING(for Linux)
AC_CACHE_VAL(irc_cv_linux,
[if test "x`(uname) 2>/dev/null`" = "xLinux"; then
  IRC_EGREP_RMLF_CPP(
    [struct( |	)+hostent( |	)+\{.*const.*h_name],
    [#include <netdb.h>],
    irc_cv_linux=bad,
    irc_cv_linux=good)
else
  irc_cv_linux=no
fi
])
if test "$irc_cv_linux" = no; then
  AC_MSG_RESULT(no)
elif test "$irc_cv_linux" = good; then
  AC_MSG_RESULT([yes, with a good <netdb.h> file])
else
  AC_MSG_RESULT([yes, with a bad <netdb.h> file])
  AC_DEFINE(BAD___CONST_NETDB_H)
fi
])


AC_DEFUN(IRC_IP6,
[AC_ARG_ENABLE(ip6, [  --enable-ip6            enables IPv6])
if test "x$enable_ip6" != x; then
  AC_DEFINE(INET6)
  AC_MSG_CHECKING(for IPv6 name server addresses in resolv.conf ($irc_cv_path_resconf))
  if grep nameserver $irc_cv_path_resconf | grep ':' >/dev/null 2>&1; then
    AC_MSG_RESULT(yes)
    AC_MSG_WARN([$irc_cv_path_resconf is not setup correctly.])
  else
    AC_MSG_RESULT(no)
  fi
fi
])


dnl -------------------------------------------------------------------
dnl modified Autoconf tests; their names begin with IRC_ instead of AC_
dnl -------------------------------------------------------------------

AC_DEFUN(IRC_INIT_PARSE_ARGS,
[
# Initialize some variables set by options.
# The variables have the same names as the options, with
# dashes changed to underlines.
build=NONE
cache_file=./config.cache
exec_prefix=NONE
host=NONE
no_create=
nonopt=NONE
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
target=NONE
verbose=
zlib_include=NONE
zlib_library=NONE
dnl Installation directory options.
dnl These are left unexpanded so users can "make install exec_prefix=/foo"
dnl and all the variables that are supposed to be based on exec_prefix
dnl by default will actually change.
dnl Use braces instead of parens because sh, perl, etc. also accept them.
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datadir='${prefix}/share'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
libdir='${exec_prefix}/lib/ircd'
includedir='${prefix}/include'
oldincludedir='/usr/include'
infodir='${prefix}/info'
mandir='${prefix}/man'

# Initialize some other variables.
subdirs=
MFLAGS= MAKEFLAGS=
# Maximum number of lines to put in a shell here document.
ac_max_here_lines=12

ac_prev=
for ac_option
do

  # If the previous option needs an argument, assign it.
  if test -n "$ac_prev"; then
    eval "$ac_prev=\$ac_option"
    ac_prev=
    continue
  fi

  case "$ac_option" in
changequote(, )dnl
  -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
changequote([, ])dnl
  *) ac_optarg= ;;
  esac

  # Accept the important Cygnus configure options, so we can diagnose typos.

  case "$ac_option" in

  -bindir | --bindir | --bindi | --bind | --bin | --bi)
    ac_prev=bindir ;;
  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
    bindir="$ac_optarg" ;;

  -build | --build | --buil | --bui | --bu)
    ac_prev=build ;;
  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
    build="$ac_optarg" ;;

  -cache-file | --cache-file | --cache-fil | --cache-fi \
  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
    ac_prev=cache_file ;;
  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
    cache_file="$ac_optarg" ;;

  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
    ac_prev=datadir ;;
  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
  | --da=*)
    datadir="$ac_optarg" ;;

  -disable-* | --disable-*)
    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
    # Reject names that are not valid shell variable names.
changequote(, )dnl
    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
changequote([, ])dnl
      AC_MSG_ERROR($ac_feature: invalid feature name)
    fi
    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
    eval "enable_${ac_feature}=no" ;;

  -enable-* | --enable-*)
    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
    # Reject names that are not valid shell variable names.
changequote(, )dnl
    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
changequote([, ])dnl
      AC_MSG_ERROR($ac_feature: invalid feature name)
    fi
    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
    case "$ac_option" in
      *=*) ;;
      *) ac_optarg=yes ;;
    esac
    eval "enable_${ac_feature}='$ac_optarg'" ;;

  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
  | --exec | --exe | --ex)
    ac_prev=exec_prefix ;;
  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
  | --exec=* | --exe=* | --ex=*)
    exec_prefix="$ac_optarg" ;;

  -gas | --gas | --ga | --g)
    # Obsolete; use --with-gas.
    with_gas=yes ;;

  -help | --help | --hel | --he)
    # Omit some internal or obsolete options to make the list less imposing.
    # This message is too long to be a string in the A/UX 3.1 sh.
    cat << EOF
changequote(, )dnl
Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
  --cache-file=FILE       cache test results in FILE
  --help                  print this message
  --no-create             do not create output files
  --quiet, --silent       do not print \`checking...' messages
  --version               print the version of autoconf that created configure
Directory and file names:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [$ac_default_prefix]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [same as prefix]
  --bindir=DIR            user executables in DIR [EPREFIX/bin]
  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
  --datadir=DIR           read-only architecture-independent data in DIR
                          [PREFIX/share]
  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
                          [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
  --includedir=DIR        C header files in DIR [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
  --infodir=DIR           info documentation in DIR [PREFIX/info]
  --mandir=DIR            man documentation in DIR [PREFIX/man]
  --srcdir=DIR            find the sources in DIR [configure dir or ..]
  --program-prefix=PREFIX prepend PREFIX to installed program names
  --program-suffix=SUFFIX append SUFFIX to installed program names
  --program-transform-name=PROGRAM
                          run sed PROGRAM on installed program names
EOF
    cat << EOF
Host type:
  --build=BUILD           configure for building on BUILD [BUILD=HOST]
  --host=HOST             configure for HOST [guessed]
  --target=TARGET         configure for TARGET [TARGET=HOST]
Features and packages:
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --resconf=FILE          use FILE as resolver config file [/etc/resolv.conf]
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --zlib-prefix=ZDIR      zlib installation prefix is ZDIR
  --zlib-include=ZIDIR    zlib include files are in ZIDIR [ZDIR/include]
  --zlib-library=ZLDIR    zlib library files are in ZLDIR [ZDIR/lib]
changequote([, ])dnl
EOF
    if test -n "$ac_help"; then
      echo "--enable and --with options recognized:$ac_help"
    fi
    exit 0 ;;

  -host | --host | --hos | --ho)
    ac_prev=host ;;
  -host=* | --host=* | --hos=* | --ho=*)
    host="$ac_optarg" ;;

  -includedir | --includedir | --includedi | --included | --include \
  | --includ | --inclu | --incl | --inc)
    ac_prev=includedir ;;
  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
  | --includ=* | --inclu=* | --incl=* | --inc=*)
    includedir="$ac_optarg" ;;

  -infodir | --infodir | --infodi | --infod | --info | --inf)
    ac_prev=infodir ;;
  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
    infodir="$ac_optarg" ;;

  -libdir | --libdir | --libdi | --libd)
    ac_prev=libdir ;;
  -libdir=* | --libdir=* | --libdi=* | --libd=*)
    libdir="$ac_optarg" ;;

  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
  | --libexe | --libex | --libe)
    ac_prev=libexecdir ;;
  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
  | --libexe=* | --libex=* | --libe=*)
    libexecdir="$ac_optarg" ;;

  -localstatedir | --localstatedir | --localstatedi | --localstated \
  | --localstate | --localstat | --localsta | --localst \
  | --locals | --local | --loca | --loc | --lo)
    ac_prev=localstatedir ;;
  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
    localstatedir="$ac_optarg" ;;

  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
    ac_prev=mandir ;;
  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
    mandir="$ac_optarg" ;;

  -nfp | --nfp | --nf)
    # Obsolete; use --without-fp.
    with_fp=no ;;

  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
  | --no-cr | --no-c)
    no_create=yes ;;

  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
    no_recursion=yes ;;

  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
  | --oldin | --oldi | --old | --ol | --o)
    ac_prev=oldincludedir ;;
  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
    oldincludedir="$ac_optarg" ;;

  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
    ac_prev=prefix ;;
  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
    prefix="$ac_optarg" ;;

  -program-prefix | --program-prefix | --program-prefi | --program-pref \
  | --program-pre | --program-pr | --program-p)
    ac_prev=program_prefix ;;
  -program-prefix=* | --program-prefix=* | --program-prefi=* \
  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
    program_prefix="$ac_optarg" ;;

  -program-suffix | --program-suffix | --program-suffi | --program-suff \
  | --program-suf | --program-su | --program-s)
    ac_prev=program_suffix ;;
  -program-suffix=* | --program-suffix=* | --program-suffi=* \
  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
    program_suffix="$ac_optarg" ;;

  -program-transform-name | --program-transform-name \
  | --program-transform-nam | --program-transform-na \
  | --program-transform-n | --program-transform- \
  | --program-transform | --program-transfor \
  | --program-transfo | --program-transf \
  | --program-trans | --program-tran \
  | --progr-tra | --program-tr | --program-t)
    ac_prev=program_transform_name ;;
  -program-transform-name=* | --program-transform-name=* \
  | --program-transform-nam=* | --program-transform-na=* \
  | --program-transform-n=* | --program-transform-=* \
  | --program-transform=* | --program-transfor=* \
  | --program-transfo=* | --program-transf=* \
  | --program-trans=* | --program-tran=* \
  | --progr-tra=* | --program-tr=* | --program-t=*)
    program_transform_name="$ac_optarg" ;;

  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
  | -silent | --silent | --silen | --sile | --sil)
    silent=yes ;;

  -resconf | --resconf | --rescon | --resco | --resc | --res \
  | --re | --r)
    ac_prev=irc_resconf ;;
  -resconf=* | --resconf=* | --rescon=* | --resco=* | --resc=* \
  | --res=* | --re=* | --r=*)
    irc_resconf="$ac_optarg" ;;

  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
    ac_prev=sbindir ;;
  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
  | --sbi=* | --sb=*)
    sbindir="$ac_optarg" ;;

  -sharedstatedir | --sharedstatedir | --sharedstatedi \
  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
  | --sharedst | --shareds | --shared | --share | --shar \
  | --sha | --sh)
    ac_prev=sharedstatedir ;;
  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
  | --sha=* | --sh=*)
    sharedstatedir="$ac_optarg" ;;

  -site | --site | --sit)
    ac_prev=site ;;
  -site=* | --site=* | --sit=*)
    site="$ac_optarg" ;;

  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
    ac_prev=srcdir ;;
  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
    srcdir="$ac_optarg" ;;

  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
  | --syscon | --sysco | --sysc | --sys | --sy)
    ac_prev=sysconfdir ;;
  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
    sysconfdir="$ac_optarg" ;;

  -target | --target | --targe | --targ | --tar | --ta | --t)
    ac_prev=target ;;
  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
    target="$ac_optarg" ;;

  -v | -verbose | --verbose | --verbos | --verbo | --verb)
    verbose=yes ;;

  -version | --version | --versio | --versi | --vers)
    echo "configure generated by autoconf version AC_ACVERSION"
    exit 0 ;;

  -with-* | --with-*)
    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
    # Reject names that are not valid shell variable names.
changequote(, )dnl
    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
changequote([, ])dnl
      AC_MSG_ERROR($ac_package: invalid package name)
    fi
    ac_package=`echo $ac_package| sed 's/-/_/g'`
    case "$ac_option" in
      *=*) ;;
      *) ac_optarg=yes ;;
    esac
    eval "with_${ac_package}='$ac_optarg'" ;;

  -without-* | --without-*)
    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
    # Reject names that are not valid shell variable names.
changequote(, )dnl
    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
changequote([, ])dnl
      AC_MSG_ERROR($ac_package: invalid package name)
    fi
    ac_package=`echo $ac_package| sed 's/-/_/g'`
    eval "with_${ac_package}=no" ;;

  -zlib-prefix | --zlib-prefix | --zlib-prefi | --zlib-pref \
  | --zlib-pre | --zlib-pr | --zlib-p)
    ac_prev=irc_zlib_prefix ;;
  -zlib-prefix=* | --zlib-prefix=* | --zlib-prefi=* | --zlib-pref=* \
  | --zlib-pre=* | --zlib-pr=* | --zlib-p=*)
    irc_zlib_prefix="$ac_optarg" ;;

  -zlib-include | --zlib-include | --zlib-includ | --zlib-inclu \
  | --zlib-incl | --zlib-inc | --zlib-in | --zlib-i)
    ac_prev=irc_zlib_include ;;
  -zlib-include=* | --zlib-include=* | --zlib-includ=* | --zlib-inclu=* \
  | --zlib-incl=* | --zlib-inc=* | --zlib-in=* | --zlib-i=*)
    irc_zlib_include="$ac_optarg" ;;

  -zlib-library | --zlib-library | --zlib-librar | --zlib-libra | --zlib-libr \
  | --zlib-lib | --zlib-li | --zlib-l)
    ac_prev=irc_zlib_library ;;
  -zlib-library=* | --zlib-library=* | --zlib-librar=* | --zlib-libra=* \
  | --zlib-libr=* | --zlib-lib=* | --zlib-li=* | --zlib-l=*)
    irc_zlib_library="$ac_optarg" ;;

  -*) AC_MSG_ERROR([$ac_option: invalid option; use --help to show usage])
    ;;

  *)
changequote(, )dnl
    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
changequote([, ])dnl
      AC_MSG_WARN($ac_option: invalid host type)
    fi
    if test "x$nonopt" != xNONE; then
      AC_MSG_ERROR(can only configure for one host and one target at a time)
    fi
    nonopt="$ac_option"
    ;;

  esac
done

if test -n "$ac_prev"; then
  AC_MSG_ERROR(missing argument to --`echo $ac_prev | sed 's/_/-/g'`)
fi
])


AC_DEFUN(IRC_INIT,
[sinclude(acsite.m4)dnl
sinclude(./aclocal.m4)dnl
AC_REQUIRE([AC_INIT_BINSH])dnl
AC_INIT_NOTICE
AC_DIVERT_POP()dnl to NORMAL
AC_DIVERT_PUSH(AC_DIVERSION_INIT)dnl
IRC_INIT_PARSE_ARGS
AC_INIT_PREPARE($1)dnl
AC_DIVERT_POP()dnl to NORMAL
])


AC_DEFUN(IRC_PROG_INSTALL,
[define(AC_PROVIDE_AC_PROG_INSTALL)
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
# Find a good install program.  We prefer a C program (faster),
# so one script is as good as another.  But avoid the broken or
# incompatible versions:
# SysV /etc/install, /usr/sbin/install
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
# AIX v4 /usr/bin/installbsd, which does not work if the user is not root
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
AC_MSG_CHECKING(for a BSD compatible install)
if test -z "$INSTALL"; then
AC_CACHE_VAL(ac_cv_path_install,
[  IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS="${IFS}:"
  for ac_dir in $PATH; do
    # Account for people who put trailing slashes in PATH elements.
    case "$ac_dir/" in
    /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
    *)
      # OSF1 and SCO ODT 3.0 have their own names for install.
      for ac_prog in ginstall installbsd scoinst install; do
        if test -f $ac_dir/$ac_prog; then
	  if test $ac_prog = install &&
            grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
	    # AIX install.  It has an incompatible calling convention.
	    # OSF/1 installbsd also uses dspmsg, but is usable.
	    :
	  elif test $ac_prog = installbsd -a "x`(uname -sv) 2>/dev/null`" = "xAIX 4"; then
            # AIX v4 installbsd. Does not work if the user is not root.
            :
          else
	    ac_cv_path_install="$ac_dir/$ac_prog -c"
	    break 2
	  fi
	fi
      done
      ;;
    esac
  done
  IFS="$ac_save_IFS"
])dnl
  if test "${ac_cv_path_install+set}" = set; then
    INSTALL="$ac_cv_path_install"
  else
    # As a last resort, use the slow shell script.  We don't cache a
    # path for INSTALL within a source directory, because that will
    # break other packages using the cache if that directory is
    # removed, or if the path is relative.
    INSTALL="$ac_install_sh"
  fi
fi
dnl We do special magic for INSTALL instead of AC_SUBST, to get
dnl relative paths right.
AC_MSG_RESULT($INSTALL)

# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
AC_SUBST(INSTALL_PROGRAM)dnl

test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
AC_SUBST(INSTALL_DATA)dnl
])


AC_DEFUN(IRC_PROG_CC,
[define(AC_PROVIDE_AC_PROG_CC)
AC_BEFORE([$0], [AC_PROG_CPP])dnl
AC_CHECK_PROG(CC, gcc, gcc)
if test -z "$CC"; then
  AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
  test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
fi
AC_PROG_CC_WORKS
AC_PROG_CC_GNU
ac_test_CFLAGS="${CFLAGS+set}"
if test $ac_cv_prog_gcc = yes; then
  GCC=yes
  ac_save_CFLAGS="$CFLAGS"
  CFLAGS=
  AC_PROG_CC_G
  if test "$ac_test_CFLAGS" = set; then
    CFLAGS="$ac_save_CFLAGS"
  else
    CFLAGS="-O2"
  fi
else
  GCC=
fi
])


AC_DEFUN(IRC_AIX,
[AC_MSG_CHECKING(for AIX)
AC_CACHE_VAL(irc_cv_aix,
[if test "x`(uname) 2>/dev/null`" = "xAIX"; then
  irc_cv_aix="`uname -rv`"
else
  irc_cv_aix=no
fi
])
if test "$irc_cv_aix" = no; then
  AC_MSG_RESULT(no)
else
  AC_MSG_RESULT(yes)
  AC_DEFINE(_ALL_SOURCE)
  if test "x$irc_cv_aix" = "x2 3"; then
    AC_DEFINE(AIX_3_2)
  fi
  if test x$CC = xcc; then
    CFLAGS="$CFLAGS -O3 -qstrict"
  fi
fi
])


AC_DEFUN(IRC_CHECK_TYPE,
[AC_REQUIRE([AC_HEADER_STDC])dnl
AC_MSG_CHECKING(for $1)
AC_CACHE_VAL(ac_cv_type_$1,
[AC_EGREP_CPP(dnl
changequote(<<,>>)dnl
<<$1[^a-zA-Z_0-9]>>dnl
changequote([,]), [
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
#if HAVE_SYS_BITYPES_H
#include <sys/bitypes.h>
#endif], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
AC_MSG_RESULT($ac_cv_type_$1)
if test $ac_cv_type_$1 = no; then
  AC_DEFINE($1, $2)
fi
])


AC_DEFUN(IRC_FUNC_MEMCMP,
[AC_CACHE_CHECK(for 8-bit clean memcmp, irc_cv_func_memcmp_clean,
[AC_TRY_RUN([
main()
{
  char c0 = 0x40, c1 = 0x80, c2 = 0x81;
  exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1);
}
], irc_cv_func_memcmp_clean=yes, irc_cv_func_memcmp_clean=no,
irc_cv_func_memcmp_clean=no)])
if test $irc_cv_func_memcmp_clean = no; then
  AC_DEFINE(MEMCMP_BROKEN)
fi
])


dnl ----
dnl main
dnl ----

AC_REVISION([$Id: configure.in,v 1.19.2.2 1998/04/22 16:56:28 kalt Exp $])
AC_PREREQ(1.12)
IRC_INIT(../ircd/ircd.c)
AC_CONFIG_HEADER(setup.h:../support/setup.h.in)
AC_CONFIG_AUX_DIR(../support)

IRC_PROG_CC
AC_PROG_CPP
AC_PROG_AWK
IRC_PROG_INSTALL
AC_PATH_PROGS(SUM, md5sum sum cksum, true)
AC_PROG_GCC_TRADITIONAL

IRC_AIX
AC_ISC_POSIX
AC_MINIX
IRC_SGI_CC
IRC_SOLARIS_2
IRC_LINUX

AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(stdio.h stdlib.h sys/types.h sys/bitypes.h stddef.h stdarg.h unistd.h ctype.h memory.h curses.h cursesX.h term.h sgtty.h errno.h sys/errno.h sys/syscall.h pwd.h math.h utmp.h fcntl.h signal.h sys/ioctl.h sys/file.h sys/filio.h sys/socket.h sys/stat.h sys/resource.h sys/select.h sys/poll.h stropts.h netdb.h netinet/in.h sys/un.h arpa/inet.h sys/param.h syslog.h sys/syslog.h string.h strings.h sys/time.h time.h sys/times.h netinet/in_systm.h netinfo/ni.h resolv.h arpa/nameser.h)
IRC_DECL_SYS_ERRLIST
IRC_DECL_SYS_NERR
IRC_DECL_ERRNO
IRC_DECL_H_ERRNO
AC_HEADER_STAT
AC_HEADER_TIME
AC_STRUCT_TM
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_TYPE_UID_T
IRC_UNION_WAIT
IRC_CHECK_TYPE(int8_t, char)
IRC_CHECK_TYPE(u_int8_t, unsigned char)
IRC_CHECK_TYPE(int16_t, short)
IRC_CHECK_TYPE(u_int16_t, unsigned short)
IRC_CHECK_TYPE(int32_t, int)
IRC_CHECK_TYPE(u_int32_t, unsigned int)
IRC_CHECK_TYPE(u_char, unsigned char)
IRC_CHECK_TYPE(u_short, unsigned short)
IRC_CHECK_TYPE(u_int, unsigned int)
IRC_CHECK_TYPE(u_long, unsigned long)

AC_C_BIGENDIAN
AC_C_CONST

AC_CHECK_LIB(crypt, crypt)
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, socket)

IRC_PATH_ZLIB
IRC_CURSES_TERMCAP

AC_FUNC_SETPGRP
AC_FUNC_SETVBUF_REVERSED
AC_FUNC_VFORK
AC_CHECK_FUNCS(setpgrp strchr strrchr memcmp memset memmove memcpy index rindex bcmp bcopy bzero select inet_ntoa inet_aton inet_addr inet_netof getrusage times strerror strtoken strtok sigaction sigset truncate vsyslog)
dnl ---
dnl Note: additional tests should be performed and used inside the source code
dnl       for the following functions:
dnl       gethostname gettimeofday lrand48 mkdir socket
dnl ---
IRC_FUNC_MEMCMP
IRC_SELECT_POLL

IRC_SIGNAL_IMPLEMENTATION
IRC_NON_BLOCKING_SYSTEM
IRC_STDARG
IRC_PATH_RESCONF
IRC_IP6
IRC_ALPHA_BETA

AC_OUTPUT(Makefile:../support/Makefile.in version.c.SH:../ircd/version.c.SH.in sums:../ircd/crypt/sums.in)
AC_OUTPUT_COMMANDS(chmod a+x version.c.SH)