more updates to the sqlsrv emulation... only Users and Servers are exported atm

fix up Ultimate vhost handling
added a smodetostring function like umodetostring
This commit is contained in:
Fish 2003-12-12 06:40:42 +00:00
parent 6c378f9cbd
commit b6e15a8ac9
7 changed files with 289 additions and 2 deletions

View file

@ -38,7 +38,9 @@ NeoStats ChangeLog - Anything we add/remove/fix/change is in here (even our rant
- AddUser changes to fix bug 94 (M)
- New function UmodeMaskToString as a helper for Umode handling (M)
- Import new SQL Server emulation library, Real Time Access. (F)
- new configure option --enable-sqlsrv to enable sql server emulation
- new configure option --enable-sqlsrv to enable sql server emulation (F)
- Fix up vhost handling on Ultimate (F)
- Addded Smodetostring function (F)
* NeoStats * Fish (F) * Version 2.5.10
- Fix a problem with Umode +T being reintroduced on Unreal Beta19 as a normal usermode.

View file

@ -1067,9 +1067,9 @@ static void
Srv_Client (char *origin, char **argv, int argc)
{
char *realname;
realname = joinbuf (argv, argc, 11);
AddUser (argv[0], argv[5], argv[6], realname, argv[8], strtoul (argv[10], NULL, 10), strtoul (argv[2], NULL, 10));
SetUserVhost(argv[0], argv[7]);
free (realname);
nlog (LOG_DEBUG1, LOG_CORE, "Mode: UserMode: %s", argv[3]);
UserMode (argv[0], argv[3]);

36
ircd.c
View file

@ -33,6 +33,7 @@
static char ircd_buf[BUFSIZE];
static char UmodeStringBuf[64];
static char SmodeStringBuf[64];
/** @brief UmodeMaskToString
*
@ -84,6 +85,41 @@ UmodeStringToMask(char* UmodeString)
return(Umode);
}
/** @brief SmodeMaskToString
*
* Translate a smode mask to the string equivalent
*
* @return
*/
char*
SmodeMaskToString(long Smode)
{
int i, j;
SmodeStringBuf[0] = '+';
j = 1;
for (i = 0; i < ircd_srv.usmodecount; i++) {
if (Smode & susr_mds[i].umodes) {
SmodeStringBuf[j] = susr_mds[i].mode;
j++;
}
}
SmodeStringBuf[j] = '\0';
return(SmodeStringBuf);
}
/** @brief SmodeStringToMask
*
* Translate a smode string to the mask equivalent
*
* @return
*/
long
SmodeStringToMask(char* SmodeString)
{
return(0);
}
/** @brief init_bot_modes
*
* Translate a mode string to the mask equivalent

2
ircd.h
View file

@ -61,6 +61,8 @@ extern aCtab cFlagTab[33];
char* UmodeMaskToString(long Umode);
long UmodeStringToMask(char* UmodeString);
char* SmodeMaskToString(long Umode);
long SmodeStringToMask(char* UmodeString);
int init_services_bot (void);
void ns_usr_motd (char *nick, char **argv, int argc);
void ns_usr_admin (char *nick, char **argv, int argc);

View file

@ -25,10 +25,14 @@
** $Id$
*/
#include "stats.h"
#include "dl.h"
#include "hash.h"
#include "log.h"
#ifdef SQLSRV
#include "sqlsrv/rta.h"
#endif
hash_t *sh;
@ -155,15 +159,97 @@ ServerDump ()
debugtochannel("End of Listing.");
}
#ifdef SQLSRV
COLDEF neo_serverscols[] = {
{
"servers",
"name",
RTA_STR,
MAXHOST,
offsetof(struct Server, name),
0,
NULL,
NULL,
"The name of the server linked to the IRC network"
},
{
"servers",
"hops",
RTA_INT,
sizeof(int),
offsetof(struct Server, hops),
0,
NULL,
NULL,
"The Number of hops away from the NeoStats Server"
},
{
"servers",
"connected",
RTA_INT,
sizeof(int),
offsetof(struct Server, connected_since),
0,
NULL,
NULL,
"The time the server connected to the IRC network"
},
{
"servers",
"last_ping",
RTA_INT,
sizeof(int),
offsetof(struct Server, ping),
0,
NULL,
NULL,
"The last ping time to this server from the NeoStats Server"
},
{
"servers",
"uplink",
RTA_STR,
MAXHOST,
offsetof(struct Server, uplink),
0,
NULL,
NULL,
"The uplink Server this server is connected to. if it = self, means the NeoStats Server"
},
};
TBLDEF neo_servers = {
"servers",
NULL, /* for now */
sizeof(struct Server),
0,
TBL_HASH,
neo_serverscols,
sizeof(neo_serverscols) / sizeof(COLDEF),
"",
"The list of Servers connected to the IRC network"
};
#endif /* SQLSRV */
int
init_server_hash ()
{
sh = hash_create (S_TABLE_SIZE, 0, 0);
if (!sh) {
nlog (LOG_CRITICAL, LOG_CORE, "Create Server Hash Failed\n");
return NS_FAILURE;
}
AddServer (me.name, NULL, 0);
#ifdef SQLSRV
/* add the server hash to the sql library */
neo_servers.address = sh;
rta_add_table(&neo_servers);
#endif
return NS_SUCCESS;
}

View file

@ -26,6 +26,7 @@
#ifndef STATS_H
#define STATS_H
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>

160
users.c
View file

@ -32,6 +32,10 @@
#include "log.h"
#include "users.h"
#include "chans.h"
#ifdef SQLSRV
#include "sqlsrv/rta.h"
#endif
hash_t *uh;
@ -233,6 +237,154 @@ finduser (const char *nick)
return NULL;
}
#ifdef SQLSRV
/* @brief Returns the users server in text form that they are connected too
*/
void *display_server(void *tbl, char *col, char *sql, void *row) {
User *data = row;
return data->server->name;
}
void *display_umode(void *tbl, char *col, char *sql, void *row) {
User *data = row;
return UmodeMaskToString(data->Umode);
}
void *display_smode(void *tbl, char *col, char *sql, void *row) {
User *data = row;
return SmodeMaskToString(data->Smode);
}
COLDEF neo_userscols[] = {
{
"users",
"nick",
RTA_STR,
MAXNICK,
offsetof(struct User, nick),
0,
NULL,
NULL,
"The nickname of the user"
},
{
"users",
"hostname",
RTA_STR,
MAXHOST,
offsetof(struct User, hostname),
0,
NULL,
NULL,
"The real Hostname of the user"
},
{
"users",
"ident",
RTA_STR,
MAXUSER,
offsetof(struct User, username),
0,
NULL,
NULL,
"The ident portion of the users connection"
},
{
"users",
"realname",
RTA_STR,
MAXREALNAME,
offsetof(struct User, realname),
0,
NULL,
NULL,
"The users realname/info message"
},
{
"users",
"vhost",
RTA_STR,
MAXHOST,
offsetof(struct User, vhost),
0,
NULL,
NULL,
"The users Vhost, if the IRCd supports VHOSTS"
},
{
"users",
"away",
RTA_INT,
sizeof(int),
offsetof(struct User, is_away),
0,
NULL,
NULL,
"Boolean variable indiciating if the user is away"
},
{
"users",
"modes",
RTA_STR,
64, /* as defined in ircd.c */
offsetof(struct User, Umode),
0,
display_umode,
NULL,
"the users umodes. Does not include SMODES."
},
{
"users",
"smodes",
RTA_STR,
64,
offsetof(struct User, Smode),
0,
display_smode,
NULL,
"the users Smodes, if the IRCd supports it. Does not include UMODES."
},
{
"users",
"connected",
RTA_INT,
sizeof(int),
offsetof(struct User, TS),
0,
NULL,
NULL,
"When the User Connected"
},
{
"users",
"server",
RTA_STR,
MAXHOST,
offsetof(struct User, server),
0,
display_server,
NULL,
"the users Smodes, if the IRCd supports it. Does not include UMODES."
},
};
TBLDEF neo_users = {
"users",
NULL, /* for now */
sizeof(struct User),
0,
TBL_HASH,
neo_userscols,
sizeof(neo_userscols) / sizeof(COLDEF),
"",
"The list of users connected to the IRC network"
};
#endif /* SQLSRV */
int
init_user_hash ()
@ -240,6 +392,14 @@ init_user_hash ()
uh = hash_create (U_TABLE_SIZE, 0, 0);
if(!uh)
return NS_FAILURE;
#ifdef SQLSRV
/* add the server hash to the sql library */
neo_users.address = uh;
rta_add_table(&neo_users);
#endif
return NS_SUCCESS;
}