summaryrefslogtreecommitdiff
path: root/include/helperfuncs.h
blob: 9c3207a9eaa857fe4277706ef0edfe6fc552263d (plain)
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
/*       +------------------------------------+
 *       | Inspire Internet Relay Chat Daemon |
 *       +------------------------------------+
 *
 *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
 *                       E-mail:
 *                <brain@chatspike.net>
 *                <Craig@chatspike.net>
 *
 * Written by Craig Edwards, Craig McLure, and others.
 * This program is free but copyrighted software; see
 *            the file COPYING for details.
 *
 * ---------------------------------------------------
 */

#ifndef _HELPER_H_
#define _HELPER_H_

#include "dynamic.h"
#include "base.h"
#include "ctables.h"
#include "users.h"
#include "channels.h"
#include "typedefs.h"
#include <string>
#include <deque>
#include <sstream>

/** Debug levels for use with InspIRCd::Log()
 */
enum DebugLevel
{
	DEBUG = 10,
	VERBOSE = 20,
	DEFAULT = 30,
	SPARSE = 40,
	NONE = 50,
};

/* I'm not entirely happy with this, the ## before 'args' is a g++ extension.
 * The problem is that if you #define log(l, x, args...) and then call it
 * with only two parameters, you get do_log(l, x, ), which is a syntax error...
 * The ## tells g++ to remove the trailing comma...
 * If this is ever an issue, we can just have an #ifndef GCC then #define log(a...) do_log(a)
 */
#define STRINGIFY2(x) #x
#define STRINGIFY(x) STRINGIFY2(x) 
#define log(l, x, args...) InspIRCd::Log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args)

void strlower(char *n);
void Error(int status);
void ShowMOTD(userrec *user);
void ShowRULES(userrec *user);
bool AllModulesReportReady(userrec* user);
bool DirValid(char* dirandfile);
bool FileExists(const char* file);
char* CleanFilename(char* name);
std::string GetFullProgDir(char** argv, int argc);
int InsertMode(std::string &output, const char* modes, unsigned short section);
bool IsValidChannelName(const char *);

#endif