Added databases

This commit is contained in:
Michiel Broek 2005-04-18 12:56:28 +00:00
parent 5682f871c1
commit 2d590e6bac
2 changed files with 56 additions and 0 deletions

View File

@ -137,6 +137,15 @@ void dump_ncslist(void)
*/ */
void send_all(char *msg) void send_all(char *msg)
{ {
ncs_list *tnsl;
sprintf(csbuf, "%s\r\n", msg);
for (tnsl = ncsl; tnsl; tnsl = tnsl->next) {
if (tnsl->state == NCS_CONNECT) {
send_msg(tnsl->socket, tnsl->servaddr_in, tnsl->server, csbuf);
}
}
} }
@ -500,6 +509,8 @@ void command_squit(char *hostname, char *parameters)
tnsl->gotserver = FALSE; tnsl->gotserver = FALSE;
tnsl->token = 0; tnsl->token = 0;
changed = TRUE; changed = TRUE;
} else {
Syslog('r', "IBC: disconnect server %s: message is not for us, but update database");
} }
} }
@ -602,7 +613,9 @@ void receiver(struct servent *se)
sprintf(csbuf, "461 %s: Not enough parameters\r\n", command); sprintf(csbuf, "461 %s: Not enough parameters\r\n", command);
send_msg(tnsl->socket, tnsl->servaddr_in, tnsl->server, csbuf); send_msg(tnsl->socket, tnsl->servaddr_in, tnsl->server, csbuf);
} else { } else {
sprintf(csbuf, "SQUIT %s %s", hostname, parameters);
command_squit(hostname, parameters); command_squit(hostname, parameters);
send_all(csbuf);
} }
} else if (atoi(command)) { } else if (atoi(command)) {
Syslog('r', "IBC: Got error %d", atoi(command)); Syslog('r', "IBC: Got error %d", atoi(command));

View File

@ -28,6 +28,49 @@ typedef struct _ncs_list {
} ncs_list; } ncs_list;
/*
* Database with servers
*/
typedef struct _srv_list {
struct _srv_list *next;
char server[64]; /* FQDN of the server */
time_t connected; /* Connection time */
int users; /* Users in chat */
} srv_list;
/*
* Database with users
*/
typedef struct _usr_list {
struct _usr_list *next;
char server[64]; /* FQDN of users server */
char nick[9]; /* Users nick */
char realname[36]; /* Users real name */
char channel[21]; /* Users channel */
time_t connected; /* Users connect time */
unsigned chanop : 1; /* User is a chanop */
} usr_list;
/*
* Database with channels
*/
typedef struct _chn_list {
struct _chn_list *next;
char server[64]; /* Originating server */
char name[21]; /* Channel name */
char topic[55]; /* Channel topic */
char owner[9]; /* Channel owner */
time_t created; /* Channel created */
int users; /* Users in channel */
} chn_list;
void send_all(char *); void send_all(char *);
void *ibc_thread(void *); void *ibc_thread(void *);