store away message in user struct

This commit is contained in:
Mark 2004-02-07 22:13:27 +00:00
parent 795e61089e
commit befe9b7ed0
6 changed files with 56 additions and 7 deletions

3
Ircu.c
View file

@ -116,6 +116,9 @@ UserModes user_umodes[] = {
{UMODE_SERVNOTICE, 's', 0}, {UMODE_SERVNOTICE, 's', 0},
{UMODE_DEAF, 'd', 0}, {UMODE_DEAF, 'd', 0},
{UMODE_CHSERV, 'k', 0}, {UMODE_CHSERV, 'k', 0},
{UMODE_ACCOUNT, 'r', 0},
{UMODE_HIDDENHOST, 'x', 0},
/* Afternet extension */
{UMODE_HELPER, 'h', 0}, {UMODE_HELPER, 'h', 0},
}; };

2
Ircu.h
View file

@ -230,6 +230,8 @@
#define UMODE_CHSERV 0x0040 /* Unkickable/-o able */ #define UMODE_CHSERV 0x0040 /* Unkickable/-o able */
#define UMODE_DEBUG 0x0080 /* See hack notices */ #define UMODE_DEBUG 0x0080 /* See hack notices */
#define UMODE_HELPER 0x0100 /* Afternets +h cs override mode */ #define UMODE_HELPER 0x0100 /* Afternets +h cs override mode */
#define UMODE_ACCOUNT 0x1100 /* */
#define UMODE_HIDDENHOST 0x2100 /* */
/* Cmodes */ /* Cmodes */
#define CMODE_CHANOP 0x0001 #define CMODE_CHANOP 0x0001

43
bans.c
View file

@ -21,11 +21,25 @@
** $Id$ ** $Id$
*/ */
#include "stats.h"
#include "log.h"
static hash_t *banshash; static hash_t *banshash;
void void
AddBan() AddBan(const char* type, const char* user, const char* host, const char* mask,
const char* reason, const char* setby, const char* tsset, const char* tsexpires)
{ {
Ban* ban;
ban.type = type;
strlcpy(ban.user, user, MAXUSER];
strlcpy(ban.host, host, MAXHOST];
strlcpy(ban.mask, mask, MAXHOST];
strlcpy(ban.reason, reason,,BUFSIZE];
strlcpy(ban.setby ,setby, MAXHOST];
ban.tsset;
ban.tsexpires;
} }
void void
@ -33,3 +47,30 @@ DelBan()
{ {
} }
int
InitBans (void)
{
banshash = hash_create (-1, 0, 0);
if (!banshash) {
nlog (LOG_CRITICAL, LOG_CORE, "Create bans hash failed\n");
return NS_FAILURE;
}
return NS_SUCCESS;
}
void
FreeBans ()
{
Ban *ban;
hnode_t *bansnode;
hscan_t hs;
hash_scan_begin(&hs, banshash);
while ((bansnode = hash_scan_next(&hs)) != NULL ) {
ban = hnode_get (bansnode);
hash_delete (banshash, bansnode);
hnode_destroy (bansnode);
free (ban);
}
hash_destroy(banshash);
}

2
bans.h
View file

@ -24,5 +24,7 @@
#ifndef _BANS_H_ #ifndef _BANS_H_
#define _BANS_H_ #define _BANS_H_
int InitBans (void);
void FreeBans (void);
#endif /* _BANS_H_ */ #endif /* _BANS_H_ */

6
main.c
View file

@ -178,6 +178,8 @@ main (int argc, char *argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
if(init_chan_hash () != NS_SUCCESS) if(init_chan_hash () != NS_SUCCESS)
return EXIT_FAILURE; return EXIT_FAILURE;
if(InitBans () != NS_SUCCESS)
return EXIT_FAILURE;
/* initilize out transfer subsystem */ /* initilize out transfer subsystem */
if (init_curl () != NS_SUCCESS) if (init_curl () != NS_SUCCESS)
return EXIT_FAILURE; return EXIT_FAILURE;
@ -582,6 +584,7 @@ do_exit (NS_EXIT_TYPE exitcode, char* quitmsg)
/* now free up the users and servers memory */ /* now free up the users and servers memory */
FreeUsers(); FreeUsers();
FreeServers(); FreeServers();
FreeBans();
fini_adns(); fini_adns();
finiModuleHash(); finiModuleHash();
} }
@ -590,9 +593,6 @@ do_exit (NS_EXIT_TYPE exitcode, char* quitmsg)
kp_exit(); kp_exit();
fini_logs (); fini_logs ();
if ((exitcode == NS_EXIT_RECONNECT && me.r_time > 0) || exitcode == NS_EXIT_RELOAD) { if ((exitcode == NS_EXIT_RECONNECT && me.r_time > 0) || exitcode == NS_EXIT_RELOAD) {
execve ("./neostats", NULL, NULL); execve ("./neostats", NULL, NULL);
return_code=EXIT_FAILURE; /* exit code to error */ return_code=EXIT_FAILURE; /* exit code to error */

View file

@ -219,6 +219,7 @@ UserAway (const char *nick, const char *awaymsg)
u = finduser (nick); u = finduser (nick);
if (u) { if (u) {
strlcpy(u->awaymsg, awaymsg, MAXHOST);
AddStringToList (&av, u->nick, &ac); AddStringToList (&av, u->nick, &ac);
if ((u->is_away == 1) && (!awaymsg)) { if ((u->is_away == 1) && (!awaymsg)) {
u->is_away = 0; u->is_away = 0;