msn-proxy-devel Mailing List for msn-proxy: the msn connection control (Page 5)
Brought to you by:
loos-br
You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(10) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(45) |
Feb
(19) |
Mar
(21) |
Apr
(17) |
May
(43) |
Jun
(11) |
Jul
(3) |
Aug
(17) |
Sep
(17) |
Oct
(1) |
Nov
(4) |
Dec
(7) |
| 2010 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
(1) |
Oct
|
Nov
(3) |
Dec
(4) |
| 2011 |
Jan
(1) |
Feb
(3) |
Mar
(9) |
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(8) |
Jun
(19) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Delton <del...@gm...> - 2009-08-03 12:05:18
|
Estou usando a versão 0.7 e notei que já está sendo desenvolvida uma nova versão. Pergunto: alguém testou ou está testando a versão 126? Irei ajudar se eu testá-la? Quais as modificações? |
|
From: <lo...@us...> - 2009-08-02 16:03:40
|
Revision: 126
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=126&view=rev
Author: loos-br
Date: 2009-08-02 16:03:27 +0000 (Sun, 02 Aug 2009)
Log Message:
-----------
corrige um problema no msn-proxy quando encerrado com algum usuario conectado (gerava segfault).
+ atualizacoes do codigo.
Modified Paths:
--------------
branches/dbmod/client.c
branches/dbmod/client.h
branches/dbmod/ns-data.h
branches/dbmod/ns.c
branches/dbmod/ns.h
branches/dbmod/protocol.c
branches/dbmod/sb-data.h
branches/dbmod/sb.c
branches/dbmod/server.c
branches/dbmod/server.h
branches/dbmod/user.c
branches/dbmod/user.h
Modified: branches/dbmod/client.c
===================================================================
--- branches/dbmod/client.c 2009-08-02 13:59:30 UTC (rev 125)
+++ branches/dbmod/client.c 2009-08-02 16:03:27 UTC (rev 126)
@@ -29,27 +29,26 @@
#include "msn-proxy.h"
void
-client_sched_read(client_ *client) {
+client_sched_read(struct client_ *client) {
if (EVENT_FD((&client->read)) == -1) return;
event_add(&client->read, &config.timeout_client_read);
}
void
-client_sched_write(client_ *client) {
+client_sched_write(struct client_ *client) {
if (EVENT_FD((&client->write)) == -1) return;
event_add(&client->write, &config.timeout_client_write);
}
-client_ *
+struct client_ *
client_alloc( int client_fd,
void (*fn_read)(int, short, void *),
void (*fn_write)(int, short, void *),
void *arg) {
- client_ *client = (client_ *)0;
+ struct client_ *client;
- client = (client_ *)malloc(sizeof(*client));
- if (client == (client_ *)0)
- die_nomem();
+ client = (struct client_ *)malloc(sizeof(*client));
+ if (client == NULL) die_nomem();
memset(client, 0, sizeof(*client));
/* prepare commands */
@@ -69,9 +68,9 @@
}
int
-client_flush_commands(client_ *client) {
- command *cmd = client->commands.cmd;
- command *next;
+client_cleanup_commands(struct client_ *client) {
+ command *cmd = client->commands.cmd;
+ command *next;
/* clean commands */
while (cmd) {
@@ -90,25 +89,26 @@
return(0);
}
-client_ *
-client_disconnect(client_ *client) {
+struct client_ *
+client_disconnect(struct client_ *client) {
+
/* is client connected ? */
- if (client == (client_ *)0)
- return((client_ *)0);
+ if (client == NULL) return(NULL);
/* disconnect */
real_client_disconnect(client);
/* flush commands */
- client_flush_commands(client);
+ client_cleanup_commands(client);
- /* release client */
+ /* free client */
free(client);
- return((client_ *)0);
+
+ return(NULL);
}
void
-real_client_disconnect(client_ *client) {
+real_client_disconnect(struct client_ *client) {
/* delete i/o events */
if (EVENT_FD((&client->read)) != -1) {
@@ -128,7 +128,7 @@
}
void
-shift_client_commands(client_ *client, command *cmd) {
+shift_client_commands(struct client_ *client, command *cmd) {
client->commands.cmd = cmd->next;
if (client->commands.cmd == (command *)0) {
client->commands.cmd_last = (command *)0;
Modified: branches/dbmod/client.h
===================================================================
--- branches/dbmod/client.h 2009-08-02 13:59:30 UTC (rev 125)
+++ branches/dbmod/client.h 2009-08-02 16:03:27 UTC (rev 126)
@@ -28,29 +28,27 @@
#include "command.h"
-typedef struct client__ {
+struct client_ {
int fd; /* client connection fd */
string *xfr; /* old xfr address */
commands commands; /* command queue */
struct event read; /* event queues */
struct event write; /* - */
struct event listen; /* - */
-} client_;
+};
#define read_client_command(a, b, c) read_command(&a->commands, a->fd, b, c)
void new_client(const int listenfd, short event, void *ev);
-void client_write(int evfd, short event, void *client_);
-void client_read(const int evfd, short event, void *client_);
-void client_sched_read(client_ *client);
-void client_sched_write(client_ *client);
-client_ *client_alloc( int client_fd,
- void (*fn_read)(int, short, void *),
- void (*fn_write)(int, short, void *),
- void *arg);
-client_ *client_disconnect(client_ *client);
-void real_client_disconnect(client_ *client);
-void shift_client_commands(client_ *client, command *cmd);
-int client_flush_commands(client_ *client);
+void client_write(int evfd, short event, void *client__);
+void client_read(const int evfd, short event, void *client__);
+void client_sched_read(struct client_ *client);
+void client_sched_write(struct client_ *client);
+struct client_ *client_alloc(int client_fd, void (*fn_read)(int, short, void *),
+ void (*fn_write)(int, short, void *), void *arg);
+struct client_ *client_disconnect(struct client_ *client);
+void real_client_disconnect(struct client_ *client);
+void shift_client_commands(struct client_ *client, command *cmd);
+int client_cleanup_commands(struct client_ *client);
#endif
Modified: branches/dbmod/ns-data.h
===================================================================
--- branches/dbmod/ns-data.h 2009-08-02 13:59:30 UTC (rev 125)
+++ branches/dbmod/ns-data.h 2009-08-02 16:03:27 UTC (rev 126)
@@ -24,11 +24,11 @@
#include "client.h"
#include "server.h"
-typedef struct ns__ {
- client_ *client;
- client_ *xfr_proxy;
- server_ *server;
-} ns_;
+struct ns_ {
+ struct client_ *client;
+ struct client_ *xfr_proxy;
+ struct server_ *server;
+};
#endif
Modified: branches/dbmod/ns.c
===================================================================
--- branches/dbmod/ns.c 2009-08-02 13:59:30 UTC (rev 125)
+++ branches/dbmod/ns.c 2009-08-02 16:03:27 UTC (rev 126)
@@ -35,9 +35,9 @@
void
ns_server_read(int evfd, short event, void *p) {
- struct user_ *user = p;
- client_ *client = user->ns.client;
- server_ *server = user->ns.server;
+ struct user_ *user = (struct user_ *)p;
+ struct client_ *client = user->ns.client;
+ struct server_ *server = user->ns.server;
(void) evfd;
@@ -77,9 +77,9 @@
void
ns_server_write(int evfd, short event, void *p) {
struct user_ *user = p;
+ struct client_ *client = user->ns.client;
+ struct server_ *server = user->ns.server;
const char *to = "ns server";
- client_ *client = user->ns.client;
- server_ *server = user->ns.server;
command *cmd = client->commands.cmd;
(void) evfd;
@@ -191,9 +191,9 @@
void
ns_client_write(const int evfd, short event, void *p) {
struct user_ *user = p;
+ struct client_ *client = user->ns.client;
+ struct server_ *server = user->ns.server;
const char *to = "ns client";
- client_ *client = user->ns.client;
- server_ *server = user->ns.server;
command *cmd = server->commands.cmd;
(void) evfd;
@@ -289,8 +289,8 @@
void
ns_client_read(const int evfd, short event, void *p) {
struct user_ *user = p;
- client_ *client = user->ns.client;
- server_ *server = user->ns.server;
+ struct client_ *client = user->ns.client;
+ struct server_ *server = user->ns.server;
(void) evfd;
if ((event & EV_TIMEOUT)) {
@@ -317,20 +317,19 @@
client_sched_read(client);
}
-server_ *
-ns_disconnect(server_ *ns) {
+struct server_ *
+ns_disconnect(struct server_ *ns) {
return(server_disconnect(ns));
}
int
xfr_ns_proxy(struct user_ *user, command *cmd, int args) {
- client_ *proxy;
+ struct client_ *proxy;
string *port;
- proxy = (client_ *)malloc(sizeof(client_));
- if (proxy == (client_ *)0)
- die_nomem();
- memset(proxy, 0, sizeof(client_));
+ proxy = (struct client_ *)malloc(sizeof(*proxy));
+ if (proxy == NULL) die_nomem();
+ memset(proxy, 0, sizeof(*proxy));
/* bind to free port for new client connection */
proxy->fd = -1;
@@ -358,8 +357,8 @@
int
msnp13_xfr_ns_proxy(struct user_ *user, command *cmd, int args) {
- client_ *proxy;
- string *port;
+ struct client_ *proxy;
+ string *port;
/*
* goes like this:
@@ -368,10 +367,9 @@
if (cmd->args_len < 4 || check_arg(cmd->args[3], "U") == RFAIL)
return(RFAIL);
- proxy = (client_ *)malloc(sizeof(client_));
- if (proxy == (client_ *)0)
- die_nomem();
- memset(proxy, 0, sizeof(client_));
+ proxy = (struct client_ *)malloc(sizeof(*proxy));
+ if (proxy == NULL) die_nomem();
+ memset(proxy, 0, sizeof(*proxy));
/* bind to free port for new client connection */
proxy->fd = -1;
@@ -442,7 +440,7 @@
user->ns.server = server_connect(&config->default_ns_host,
&config->default_ns_port,
ns_server_read, ns_server_write, user);
- if (user->ns.server == (server_ *)0) {
+ if (user->ns.server == NULL) {
log->debug("debug: unable to connect to ns server\n");
while (close(client_fd) != 0 && errno == EINTR);
return;
@@ -457,8 +455,8 @@
ns_proxy_client(int listenfd, short event, void *p) {
struct sockaddr client_sa;
struct user_ *user = p;
+ struct client_ *proxy = user->ns.xfr_proxy;
socklen_t client_sa_len;
- client_ *proxy = user->ns.xfr_proxy;
int client_fd;
if ((event & EV_TIMEOUT)) {
@@ -491,17 +489,17 @@
/* free xfr_proxy */
proxy_free(proxy);
- user->ns.xfr_proxy = (client_ *)0;
free(proxy);
+ user->ns.xfr_proxy = NULL;
return;
}
int
xfr_ns_post_proxy(struct user_ *user, command *cmd, int args) {
- client_ *client = user->ns.client;
- client_ *proxy = user->ns.xfr_proxy;
- server_ *server = user->ns.server;
+ struct client_ *client = user->ns.client;
+ struct client_ *proxy = user->ns.xfr_proxy;
+ struct server_ *server = user->ns.server;
if (cmd->args_len < 4)
return(ROK);
@@ -514,7 +512,7 @@
/* connect to new NS */
user->ns.server = server_connect2(proxy->xfr, ns_server_read,
ns_server_write, user);
- if (user->ns.server == (server_ *)0) {
+ if (user->ns.server == NULL) {
log->debug("debug: cannot connect to ns server\n");
return(RFAIL);
}
@@ -526,7 +524,7 @@
}
void
-proxy_free(client_ *proxy) {
+proxy_free(struct client_ *proxy) {
/* close listenfd and remove events */
if (EVENT_FD((&proxy->listen)) != -1) {
event_del(&proxy->listen);
Modified: branches/dbmod/ns.h
===================================================================
--- branches/dbmod/ns.h 2009-08-02 13:59:30 UTC (rev 125)
+++ branches/dbmod/ns.h 2009-08-02 16:03:27 UTC (rev 126)
@@ -23,12 +23,12 @@
#include "user.h"
-server_ *ns_disconnect(server_ *ns);
+struct server_ *ns_disconnect(struct server_ *ns);
int xfr_ns_proxy(struct user_ *user, command *cmd, int args);
int msnp13_xfr_ns_proxy(struct user_ *user, command *cmd, int args);
void ns_client(int listenfd, short event, void *_config);
void ns_proxy_client(int listenfd, short event, void *principal_);
int xfr_ns_post_proxy(struct user_ *user, command *cmd, int args);
-void proxy_free(client_ *proxy);
+void proxy_free(struct client_ *proxy);
#endif
Modified: branches/dbmod/protocol.c
===================================================================
--- branches/dbmod/protocol.c 2009-08-02 13:59:30 UTC (rev 125)
+++ branches/dbmod/protocol.c 2009-08-02 16:03:27 UTC (rev 126)
@@ -789,8 +789,8 @@
int
msnp18_adl_sync(struct user_ *user, command *cmd, int args) {
- client_ *client = user->ns.client;
- server_ *server = user->ns.server;
+ struct client_ *client = user->ns.client;
+ struct server_ *server = user->ns.server;
has_trid(cmd);
if (cmd->trid >= client->commands.wait) {
Modified: branches/dbmod/sb-data.h
===================================================================
--- branches/dbmod/sb-data.h 2009-08-02 13:59:30 UTC (rev 125)
+++ branches/dbmod/sb-data.h 2009-08-02 16:03:27 UTC (rev 126)
@@ -44,14 +44,14 @@
struct event listen; /* listen event */
struct user_ *user; /* pointer to user */
+ struct client_ *client; /* sb client data */
+ struct server_ *server; /* sb server data */
+
__uint32_t id; /* sql chat id */
__uint32_t warned; /* warned about message logging */
__uint32_t warn_block_contact; /* warned about contact blocked */
__uint32_t closed; /* need to log stop at disconnect ? */
- server_ *server; /* sb server data */
- client_ *client; /* sb client data */
-
string start;
string *xfr;
};
Modified: branches/dbmod/sb.c
===================================================================
--- branches/dbmod/sb.c 2009-08-02 13:59:30 UTC (rev 125)
+++ branches/dbmod/sb.c 2009-08-02 16:03:27 UTC (rev 126)
@@ -129,7 +129,7 @@
/* attach server */
sb->server = server_connect2(sb->xfr, sb_server_read, sb_server_write, sb);
- if (sb->server == (server_ *)0) {
+ if (sb->server == NULL) {
log->debug("debug: fail to connect to sb server\n");
sb = sb_disconnect(sb);
goto end;
@@ -209,9 +209,9 @@
sb_client_write(const int evfd, short event, void *p) {
struct sb_ *sb = p;
struct user_ *user = sb->user;
- client_ *client = sb->client;
- server_ *server = sb->server;
- client_ *nsclient = user->ns.client;
+ struct client_ *client = sb->client;
+ struct server_ *server = sb->server;
+ struct client_ *nsclient = user->ns.client;
command *cmd = server->commands.cmd;
const char *to = "sb client";
@@ -280,8 +280,8 @@
void sb_client_read(const int evfd, short event, void *p) {
struct sb_ *sb = p;
- client_ *client = sb->client;
- client_ *nsclient = sb->user->ns.client;
+ struct client_ *client = sb->client;
+ struct client_ *nsclient = sb->user->ns.client;
(void) evfd;
@@ -317,8 +317,8 @@
void
sb_server_read(int evfd, short event, void *p) {
struct sb_ *sb = p;
- server_ *server = sb->server;
- server_ *nsserver = sb->user->ns.server;
+ struct server_ *server = sb->server;
+ struct server_ *nsserver = sb->user->ns.server;
(void) evfd;
@@ -365,8 +365,8 @@
sb_server_write(int evfd, short event, void *p) {
struct sb_ *sb = p;
struct user_ *user = sb->user;
- client_ *client = sb->client;
- server_ *server = sb->server;
+ struct client_ *client = sb->client;
+ struct server_ *server = sb->server;
command *cmd = client->commands.cmd;
const char *to = "sb server";
Modified: branches/dbmod/server.c
===================================================================
--- branches/dbmod/server.c 2009-08-02 13:59:30 UTC (rev 125)
+++ branches/dbmod/server.c 2009-08-02 16:03:27 UTC (rev 126)
@@ -29,7 +29,7 @@
#include "msn-proxy.h"
int
-server_flush_commands(server_ *server) {
+server_cleanup_commands(struct server_ *server) {
command *cmd = server->commands.cmd;
command *next;
@@ -51,7 +51,7 @@
}
void
-server_close(server_ *server) {
+server_close(struct server_ *server) {
/* delete i/o events */
if (EVENT_FD((&server->read)) != -1) {
@@ -70,37 +70,35 @@
}
}
-server_ *
-server_disconnect(server_ *server) {
+struct server_ *
+server_disconnect(struct server_ *server) {
- if (server == (server_ *)0)
- return((server_ *)0);
+ if (server == NULL) return(NULL);
/* close connection */
server_close(server);
/* clean commands */
- server_flush_commands(server);
+ server_cleanup_commands(server);
/* clean ns host and port and free memory */
str_free(&server->host);
str_free(&server->port);
free(server);
- return((server_ *)0);
+ return(NULL);
}
-server_ *
+struct server_ *
server_alloc(void) {
- server_ *server = (server_ *)0;
+ struct server_ *server;
/* alloc */
- server = (server_ *)malloc(sizeof(server_));
- if (server == (server_ *)0)
- die_nomem();
+ server = (struct server_ *)malloc(sizeof(*server));
+ if (server == NULL) die_nomem();
/* zero everything */
- memset(server, 0, sizeof(server_));
+ memset(server, 0, sizeof(*server));
server->fd = -1;
server->read.ev_fd = -1;
server->write.ev_fd = -1;
@@ -112,31 +110,30 @@
}
void
-server_sched_read(server_ *server) {
+server_sched_read(struct server_ *server) {
if (EVENT_FD((&server->read)) == -1) return;
event_add(&server->read, &config.timeout_server_read);
}
void
-server_sched_write(server_ *server) {
+server_sched_write(struct server_ *server) {
if (EVENT_FD((&server->write)) == -1) return;
event_add(&server->write, &config.timeout_server_write);
}
-server_ *
+struct server_ *
server_connect2(string *host,
void (*fn_read)(int, short, void *),
void (*fn_write)(int, short, void *),
void *arg) {
- server_ *server = (server_ *)0;
+ struct server_ *server = NULL;
string tmp;
if (!host || !host->s)
return(server);
server = server_alloc();
- if (server == (server_ *)0)
- die_nomem();
+ if (server == NULL) die_nomem();
/* XXX */
str_zero(&tmp);
@@ -166,19 +163,18 @@
return(server);
}
-server_ *
+struct server_ *
server_connect( string *host, string *port,
void (*fn_read)(int, short, void *),
void (*fn_write)(int, short, void *),
void *arg) {
- server_ *server = (server_ *)0;
+ struct server_ *server = NULL;
if (!host || !host->s || !port || !port->s)
return(server);
server = server_alloc();
- if (server == (server_ *)0)
- return(server);
+ if (server == NULL) return(server);
if (str_copy(&server->host, host->s, host->len) == 0 ||
str_copy(&server->port, port->s, port->len) == 0) {
@@ -196,7 +192,7 @@
}
int
-server_real_connect(server_ *server,
+server_real_connect(struct server_ *server,
void (*fn_read)(int, short, void *),
void (*fn_write)(int, short, void *),
void *arg) {
@@ -224,7 +220,7 @@
}
void
-shift_server_commands(server_ *server, command *cmd) {
+shift_server_commands(struct server_ *server, command *cmd) {
server->commands.cmd = cmd->next;
if (server->commands.cmd == (command *)0) {
server->commands.cmd_last = (command *)0;
@@ -232,7 +228,7 @@
}
int
-read_server_command(server_ *server, void (*sched_write)(), void *ev_write) {
+read_server_command(struct server_ *server, void (*sched_write)(), void *ev_write) {
/* read command */
switch (read_command(&server->commands, server->fd, sched_write, ev_write)) {
Modified: branches/dbmod/server.h
===================================================================
--- branches/dbmod/server.h 2009-08-02 13:59:30 UTC (rev 125)
+++ branches/dbmod/server.h 2009-08-02 16:03:27 UTC (rev 126)
@@ -28,34 +28,34 @@
#include "command.h"
-typedef struct server__ {
+struct server_ {
int fd;
string host;
string port;
commands commands;
struct event read;
struct event write;
-} server_;
+};
-void server_close(server_ *server);
-server_ *server_disconnect(server_ *server);
-server_ *server_alloc(void);
-void server_sched_read(server_ *server);
-void server_sched_write(server_ *server);
-server_ *server_connect2(string *host,
- void (*fn_read)(int, short, void *),
- void (*fn_write)(int, short, void *),
- void *arg);
-server_ *server_connect( string *host, string *port,
- void (*fn_read)(int, short, void *),
- void (*fn_write)(int, short, void *),
- void *arg);
-int server_real_connect(server_ *server,
- void (*fn_read)(int, short, void *),
- void (*fn_write)(int, short, void *),
- void *arg);
-void shift_server_commands(server_ *server, command *cmd);
-int read_server_command(server_ *server, void (*sched_write)(), void *ev_write);
-int server_flush_commands(server_ *server);
+void server_close(struct server_ *server);
+struct server_ *server_disconnect(struct server_ *server);
+struct server_ *server_alloc(void);
+void server_sched_read(struct server_ *server);
+void server_sched_write(struct server_ *server);
+struct server_ *server_connect2(string *host,
+ void (*fn_read)(int, short, void *),
+ void (*fn_write)(int, short, void *),
+ void *arg);
+struct server_ *server_connect( string *host, string *port,
+ void (*fn_read)(int, short, void *),
+ void (*fn_write)(int, short, void *),
+ void *arg);
+int server_real_connect(struct server_ *server,
+ void (*fn_read)(int, short, void *),
+ void (*fn_write)(int, short, void *),
+ void *arg);
+void shift_server_commands(struct server_ *server, command *cmd);
+int read_server_command(struct server_ *server, void (*sched_write)(), void *ev_write);
+int server_cleanup_commands(struct server_ *server);
#endif
Modified: branches/dbmod/user.c
===================================================================
--- branches/dbmod/user.c 2009-08-02 13:59:30 UTC (rev 125)
+++ branches/dbmod/user.c 2009-08-02 16:03:27 UTC (rev 126)
@@ -43,7 +43,7 @@
void
user_rb_init(void) {
- memset(&users, 0, sizeof(struct users_));
+ RB_INIT(&users);
}
int
@@ -226,7 +226,7 @@
void
user_disconnect(struct user_ *user) {
- client_ *proxy = user->ns.xfr_proxy;
+ struct client_ *proxy = user->ns.xfr_proxy;
if (user->state == USR_TWN_S)
db.sql_password_error(&user->email);
@@ -265,50 +265,15 @@
user = user_free(user);
}
-/* remove users from tree and memory */
+/* remove and disconnect users from tree and memory */
void
free_users_tree(void) {
- struct sb_user_ *sb_user;
struct user_ *user;
struct user_ *next;
- struct sb_ *sb;
for (user = RB_MIN(users_, &users); user != NULL; user = next) {
next = RB_NEXT(users_, &users, user);
- contacts_free(user);
- str_free(&user->addr);
- str_free(&user->dn);
- str_free(&user->email);
- str_free(&user->status);
- server_flush_commands(user->ns.server);
- str_free(&user->ns.server->host);
- str_free(&user->ns.server->port);
- client_flush_commands(user->ns.client);
-
- while (!LIST_EMPTY(&user->sbs)) {
- sb = LIST_FIRST(&user->sbs);
- sb_free_xfr(sb);
- str_free(&sb->start);
- server_flush_commands(sb->server);
- str_free(&sb->server->host);
- str_free(&sb->server->port);
- client_flush_commands(sb->client);
- free(sb->server);
- free(sb->client);
-
- while (!SLIST_EMPTY(&sb->sb_users)) {
- sb_user = SLIST_FIRST(&sb->sb_users);
- sb_user = sb_user_free(sb, sb_user);
- }
-
- LIST_REMOVE(sb, sb__);
- free(sb);
- }
-
- free(user->ns.server);
- free(user->ns.client);
- RB_REMOVE(users_, &users, user);
- free(user);
+ user_disconnect(user);
}
}
Modified: branches/dbmod/user.h
===================================================================
--- branches/dbmod/user.h 2009-08-02 13:59:30 UTC (rev 125)
+++ branches/dbmod/user.h 2009-08-02 16:03:27 UTC (rev 126)
@@ -36,7 +36,7 @@
struct user_ {
struct contacts contacts; /* contacts rb list */
RB_ENTRY(user_) user__; /* RB list user data */
- struct ns__ ns; /* ns connection */
+ struct ns_ ns; /* ns connection */
struct sbs sbs; /* sb connections list */
__uint32_t id;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lo...@us...> - 2009-08-02 13:59:40
|
Revision: 125
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=125&view=rev
Author: loos-br
Date: 2009-08-02 13:59:30 +0000 (Sun, 02 Aug 2009)
Log Message:
-----------
salvando mais uma parte do trabalho.
o suporte ao mysql esta pronto e para o pgsql estamos quase la...
algumas pequenas alteracoes, atualizacao do restante do codigo.
modificadas as tabelas do pgsql de acordo com as sugestoes do Alessandro Madruga Correia (thanks) - removido o uso de "types".
Modified Paths:
--------------
branches/dbmod/command.c
branches/dbmod/config.c
branches/dbmod/contacts.c
branches/dbmod/ctl.c
branches/dbmod/db.c
branches/dbmod/db.h
branches/dbmod/db_modules/mysql/mysql.c
branches/dbmod/db_modules/mysql/mysql.h
branches/dbmod/db_modules/mysql/sql.c
branches/dbmod/db_modules/mysql/sql.h
branches/dbmod/db_modules/pgsql/Makefile
branches/dbmod/db_modules/pgsql/pgsql.c
branches/dbmod/db_modules/pgsql/pgsql.h
branches/dbmod/io.c
branches/dbmod/msnp18.h
branches/dbmod/php/lists.inc.php
branches/dbmod/user.c
Added Paths:
-----------
branches/dbmod/db_modules/pgsql/conf
branches/dbmod/db_modules/pgsql/sql.c
branches/dbmod/db_modules/pgsql/sql.h
branches/dbmod/db_modules/pgsql/tables/
branches/dbmod/db_modules/pgsql/tables/contact_groups
branches/dbmod/db_modules/pgsql/tables/contacts
branches/dbmod/db_modules/pgsql/tables/defaults
branches/dbmod/db_modules/pgsql/tables/log
branches/dbmod/db_modules/pgsql/tables/sb
branches/dbmod/db_modules/pgsql/tables/users
Property Changed:
----------------
branches/dbmod/db.c
branches/dbmod/db.h
branches/dbmod/db_modules/mysql/conf
branches/dbmod/db_modules/mysql/mysql.c
branches/dbmod/db_modules/mysql/mysql.h
branches/dbmod/db_modules/mysql/sql.c
branches/dbmod/db_modules/mysql/sql.h
branches/dbmod/db_modules/pgsql/pgsql.c
branches/dbmod/db_modules/pgsql/pgsql.h
branches/dbmod/php/lists.inc.php
Modified: branches/dbmod/command.c
===================================================================
--- branches/dbmod/command.c 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/command.c 2009-08-02 13:59:30 UTC (rev 125)
@@ -63,7 +63,8 @@
if (cmd->cmd.len == 0)
return(0);
- if (strcasecmp((char *)cmd->cmd.s, "241") != 0 &&
+ if (strcasecmp((char *)cmd->cmd.s, "205") != 0 &&
+ strcasecmp((char *)cmd->cmd.s, "241") != 0 &&
strcasecmp((char *)cmd->cmd.s, "508") != 0 &&
strcasecmp((char *)cmd->cmd.s, "509") != 0 &&
strcasecmp((char *)cmd->cmd.s, "511") != 0 &&
Modified: branches/dbmod/config.c
===================================================================
--- branches/dbmod/config.c 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/config.c 2009-08-02 13:59:30 UTC (rev 125)
@@ -65,7 +65,7 @@
/* set the default config file path */
if (strlen(DEFAULT_CONFIG_FILE) > 0 &&
str_copys(&config->file, (unsigned char *)DEFAULT_CONFIG_FILE) == 0)
- exit(51);
+ die_nomem();
/* setup the configuration parameters */
config->confkey = confKeys;
@@ -196,7 +196,7 @@
void
set_string(const unsigned char *val, string *conf) {
if (!val || strlen((char *)val) == 0 || !conf) return;
- if (str_copys(conf, val) == 0) exit(51);
+ if (str_copys(conf, val) == 0) die_nomem();
}
void
Modified: branches/dbmod/contacts.c
===================================================================
--- branches/dbmod/contacts.c 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/contacts.c 2009-08-02 13:59:30 UTC (rev 125)
@@ -267,7 +267,7 @@
/* get contact e-mail */
str_zero(&c);
c.len = fmt_printf(NULL, "%s@%s", &name, &domain);
- if (str_ready(&c, c.len + 1) == 0) exit(51);
+ if (str_ready(&c, c.len + 1) == 0) die_nomem();
c.len = fmt_printf(c.s, "%s@%s", &name, &domain);
str_free(&name);
@@ -558,7 +558,7 @@
case MSNP16:
case MSNP17:
case MSNP18:
- if (str_copys(o, (unsigned char *)"0") == 0) exit (51);
+ if (str_copys(o, (unsigned char *)"0") == 0) die_nomem();
break;
default:
str_free(o);
@@ -768,7 +768,7 @@
/* SEEIMG */
if (o && (user->commands & SEEIMG)) {
- if (str_copys(o, (unsigned char *)"0") == 0) exit (51);
+ if (str_copys(o, (unsigned char *)"0") == 0) die_nomem();
}
if (db.sql_contact_save(user, save) == RFAIL)
@@ -839,7 +839,7 @@
case MSNP16:
case MSNP17:
case MSNP18:
- if (str_copys(o, (unsigned char *)"0") == 0) exit (51);
+ if (str_copys(o, (unsigned char *)"0") == 0) die_nomem();
break;
default:
str_free(o);
Modified: branches/dbmod/ctl.c
===================================================================
--- branches/dbmod/ctl.c 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/ctl.c 2009-08-02 13:59:30 UTC (rev 125)
@@ -82,7 +82,7 @@
/* alloc new ctl */
ctl = (struct ctl_ *)malloc(sizeof(struct ctl_));
- if (ctl == NULL) exit(51);
+ if (ctl == NULL) die_nomem();
memset(ctl, 0, sizeof(struct ctl_));
/* misc set */
@@ -163,7 +163,7 @@
str_free(&ctl->buf);
ctl->end = 0;
}
- if (*p && str_cat(&ctl->buf, p, 1) == 0) exit(51);
+ if (*p && str_cat(&ctl->buf, p, 1) == 0) die_nomem();
len--; p++;
}
Modified: branches/dbmod/db.c
===================================================================
--- branches/dbmod/db.c 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/db.c 2009-08-02 13:59:30 UTC (rev 125)
@@ -14,7 +14,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-static const char rcsid[] = "$Id: modules.c 248 2009-01-19 15:36:41Z loos $";
+static const char rcsid[] = "$Id$";
#include <sys/types.h>
@@ -92,7 +92,7 @@
/* XXX - stat file */
if (db_mod->len > 0 && str_copy(&db.modPath, db_mod->s, db_mod->len) == 0)
- exit(51);
+ die_nomem();
log->debug("loading db module.....: [%s]\n", &db.modPath);
db.data = dlopen((char *)db.modPath.s, RTLD_LAZY);
Property changes on: branches/dbmod/db.c
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db.h
===================================================================
--- branches/dbmod/db.h 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/db.h 2009-08-02 13:59:30 UTC (rev 125)
@@ -15,7 +15,7 @@
*/
/*
- * $Id: modules.h,v 1.2 2009-01-03 15:21:47 luiz Exp $
+ * $Id$
*/
#ifndef DB_H
Property changes on: branches/dbmod/db.h
___________________________________________________________________
Added: svn:keywords
+ Id
Property changes on: branches/dbmod/db_modules/mysql/conf
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/mysql/mysql.c
===================================================================
--- branches/dbmod/db_modules/mysql/mysql.c 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/db_modules/mysql/mysql.c 2009-08-02 13:59:30 UTC (rev 125)
@@ -14,9 +14,9 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-static const char rcsid[] = "$Id: mysql.c 117 2009-04-13 11:58:02Z leorogoski $";
+static const char rcsid[] = "$Id$";
-#define MODULE_NAME "mysql"
+#define MODULE_NAME "mysql"
#include <sys/types.h>
#include <sys/stat.h>
@@ -24,14 +24,13 @@
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
-#include <string.h>
#include <dirent.h>
+#include <string.h>
#include <unistd.h>
#include "sql.h"
#include "mysql.h"
#include "../../db.h"
-#include "../../io.h"
#include "../../fmt.h"
#include "../../return.h"
#include "../../msn-proxy.h"
@@ -39,7 +38,7 @@
#define print_bar(a) (a[strlen(a) - 1] == '/') ? "" : "/"
/* global - mysql private data */
-struct mysql_ mysql;
+struct mysql_ mysql;
int
tablecmp(struct table__ *t1, struct table__ *t2) {
@@ -152,12 +151,12 @@
if (table->sql.len == 0 || table->name.len == 0) continue;
sql.len = fmt_printf(NULL, (char *)table->sql.s, table->name.s);
- if (str_ready(&sql, sql.len + 1) == 0) exit(51);
+ if (str_ready(&sql, sql.len + 1) == 0) die_nomem();
sql.len = fmt_printf(sql.s, (char *)table->sql.s, table->name.s);
if (db_query2(mysql, &sql) != ROK &&
mysql_errno(&mysql->mysql) != 0) {
- str_free(&sql);
- return(RFAIL);
+ str_free(&sql);
+ return(RFAIL);
}
str_free(&sql);
}
@@ -197,7 +196,7 @@
char *
db_error(struct mysql_ *mysql) {
- char *p;
+ char *p;
p = (char *)mysql_error(&mysql->mysql);
if (p && *p)
@@ -218,22 +217,22 @@
if (!mysql->host.s) {
if (str_copys(&mysql->host, (unsigned char *)DEFAULT_MYSQL_HOST) == 0)
- exit(51);
+ die_nomem();
}
if (!mysql->user.s) {
if (str_copys(&mysql->user, (unsigned char *)DEFAULT_MYSQL_USER) == 0)
- exit(51);
+ die_nomem();
}
if (!mysql->pass.s) {
if (str_copys(&mysql->pass, (unsigned char *)DEFAULT_MYSQL_PASS) == 0)
- exit(51);
+ die_nomem();
}
if (!mysql->db.s) {
if (str_copys(&mysql->db, (unsigned char *)DEFAULT_MYSQL_DB) == 0)
- exit(51);
+ die_nomem();
}
if (mysql->port == 0)
@@ -266,7 +265,8 @@
}
/* erase the database password from memory ?!?? Safety ? */
- memset(mysql->pass.s, 0, mysql->pass.len);
+ str_free(&mysql->pass);
+
mysql->connected = 1;
/* set auto-reconnect */
@@ -323,31 +323,31 @@
return(RFAIL);
*table_ = (struct table__ *)malloc(sizeof(struct table__));
- if (*table_ == NULL) exit(51);
+ if (*table_ == NULL) die_nomem();
table = *table_;
str_zero(&table->name);
str_zero(&table->sql);
table->size = size;
table->exist = 0;
- if (str_ready(&table->sql, table->size + 1) == 0) exit(51);
- if (str_copy(&table->name, (unsigned char *)file, filelen) == 0) exit(51);
+ if (str_ready(&table->sql, table->size + 1) == 0) die_nomem();
+ if (str_copy(&table->name, (unsigned char *)file, filelen) == 0) die_nomem();
/* open file and read read */
fd = open((char *)table->name.s, O_RDONLY);
if (fd == -1) {
- io_printf(1, "cannot open table file [%S] [%S]\n", table->name.s,
- strerror(errno));
+ log->debug("cannot open table file [%S]: [%S]\n", table->name.s,
+ strerror(errno));
db_table_free(table);
free(*table_);
return(RFAIL);
}
while (table->sql.len < size) {
- len = io_read(fd, (char *)table->sql.s + table->sql.len,
- table->sql.a - table->sql.len);
+ len = read(fd, (char *)table->sql.s + table->sql.len,
+ table->sql.a - table->sql.len);
if (len == -1) {
- io_printf(1, "cannot read table file [%S] [%S]\n", table->name.s,
- strerror(errno));
+ log->debug("cannot read table file [%S]: [%S]\n", table->name.s,
+ strerror(errno));
db_table_free(table);
free(*table_);
return(RFAIL);
@@ -372,9 +372,9 @@
RB_INIT(&mysql->table_head);
if (chdir(MYSQLTABLE) == -1) {
- io_printf(1, "cannot chdir to mysql tables directory: [%S%Stables] [%S]\n",
- configdir, print_bar(configdir), strerror(errno));
- return(RFAIL);
+ log->debug("cannot chdir to mysql tables directory: [%S%Stables] [%S]\n",
+ configdir, print_bar(configdir), strerror(errno));
+ return(RFAIL);
}
dir = opendir(".");
if (dir == NULL)
@@ -389,13 +389,13 @@
memset(&st, 0, sizeof(st));
if (stat(de->d_name, &st) == -1) {
- io_printf(1, "cannot stat table file: [%S]: [%S]\n", de->d_name,
- strerror(errno));
+ log->debug("cannot stat table file: [%S]: [%S]\n", de->d_name,
+ strerror(errno));
continue;
}
if (st.st_size == 0) {
- io_printf(1, "table file with zero size: [%S]. ignored.\n", de->d_name);
+ log->debug("table file with zero size: [%S]. ignoring file...\n", de->d_name);
continue;
}
@@ -403,7 +403,7 @@
tmp = RB_INSERT(tables, &mysql->table_head, table);
if (tmp) {
db_table_free(table);
- io_printf(1, "duplicated file: [%S]. ignored.\n", de->d_name);
+ log->debug("you can't go over there... [%S]: ignoring...\n", de->d_name);
}
}
}
@@ -426,33 +426,33 @@
/* save the current dir */
curdir = open(".", O_RDONLY);
if (curdir == -1) {
- io_printf(1, "cannot open curdir: [%S]\n", strerror(errno));
+ log->debug("cannot open curdir: [%S]\n", strerror(errno));
goto fail;
}
/* chdir to config dir */
if (chdir(configdir) == -1) {
- io_printf(1, "cannot chdir to mysql configuration directory: [%S]: [%S]\n",
- configdir, strerror(errno));
+ log->debug("cannot chdir to mysql configuration directory: [%S]: [%S]\n",
+ configdir, strerror(errno));
goto fail;
}
/* check access to config */
memset(&sb, 0, sizeof(sb));
if (stat(MYSQLCONF, &sb) == -1) {
- io_printf(1, "cannot stat configuration file: [%S%Sconf]: [%S]\n",
+ log->debug("cannot stat configuration file: [%S%Sconf]: [%S]\n",
configdir, print_bar(configdir), strerror(errno));
goto fail;
}
if (sb.st_mode & S_IRWXO)
- io_printf(STDERR, "PUBLIC ACCESS on %S%Sconf should be removed !!!\n",
+ log->debug("PUBLIC ACCESS on %S%Sconf should be removed !!!\n",
"ie: chmod 400 %S%Sconf\n", configdir, print_bar(configdir),
configdir, print_bar(configdir));
fp = fopen(MYSQLCONF, "r");
if (fp == (FILE *)0) {
- io_printf(1, "cannot open configuration file: [%S%Sconf]: [%S]\n",
+ log->debug("cannot open configuration file: [%S%Sconf]: [%S]\n",
configdir, print_bar(configdir), strerror(errno));
goto fail;
}
@@ -479,7 +479,7 @@
/* check for buffer */
if (!p || !*p) {
- io_printf(1, "zero configuration data (no content) on file: [%S%Sconf]\n",
+ log->debug("zero configuration data (no content) on file: [%S%Sconf]\n",
configdir, print_bar(configdir));
goto fail;
}
@@ -489,7 +489,7 @@
label = "o host";
goto field_fail;
}
- if (str_copys(&mysql->host, (unsigned char *)key) == 0) exit(51);
+ if (str_copys(&mysql->host, (unsigned char *)key) == 0) die_nomem();
/* port */
if (db_get_conf_key(&key, &p) == RFAIL) {
@@ -503,28 +503,28 @@
label = "the user";
goto field_fail;
}
- if (str_copys(&mysql->user, (unsigned char *)key) == 0) exit(51);
+ if (str_copys(&mysql->user, (unsigned char *)key) == 0) die_nomem();
/* pass */
if (db_get_conf_key(&key, &p) == RFAIL) {
label = "the password";
goto field_fail;
}
- if (str_copys(&mysql->pass, (unsigned char *)key) == 0) exit(51);
+ if (str_copys(&mysql->pass, (unsigned char *)key) == 0) die_nomem();
/* db */
if (db_get_conf_key(&key, &p) == RFAIL) {
label = "the database";
goto field_fail;
}
- if (str_copys(&mysql->db, (unsigned char *)key) == 0) exit(51);
+ if (str_copys(&mysql->db, (unsigned char *)key) == 0) die_nomem();
if (db_read_tables(mysql, configdir) == RFAIL)
goto fail;
/* check for tables */
/* if (RB_EMPTY(&mysql->table_head))
- * io_printf(1, "nenhuma tabela foi carregada !\n");
+ * log->debug("nenhuma tabela foi carregada !\n");
*/
fchdir(curdir);
@@ -532,9 +532,9 @@
return(ROK);
field_fail:
- io_printf(1, "cannot read %S: [%S%Sconf]\n"
- "should be: host|port|user|pass|db\n",
- label, configdir, print_bar(configdir));
+ log->debug("cannot read %S: [%S%Sconf]\n"
+ "should be: host|port|user|pass|db\n",
+ label, configdir, print_bar(configdir));
fail:
fchdir(curdir);
close(curdir);
@@ -561,15 +561,8 @@
log->debug("debug: module " MODULE_NAME " loading...\n");
if (str_copys(&mod->modName, (unsigned char *)MODULE_NAME) == 0)
- exit(51);
+ die_nomem();
- /* adiciona os comandos xml do modulo */
-// xml_cmds_AddMod(mod, MODULE_XML_CMD);
-// xml_cmds_AddMod(mod, MODULE_XML_CMD "_teste");
-// xml_cmds_AddMod(mod, MODULE_XML_CMD "_teste_321");
-// xml_cmds_AddMod(mod, MODULE_XML_CMD "_teste_123");
-
-
/* read mysql configuration */
if (db_read_conf(&mysql, MYSQLCONFDIR) == RFAIL)
return(-1);
@@ -605,8 +598,10 @@
str_free(&mysql.host);
str_free(&mysql.pass);
str_free(&mysql.user);
+ mysql.debug = NULL;
+ mysql.info = NULL;
+ mysql.port = 0;
/* defaults_cleanup */
defaults_cleanup(&config.defaults);
}
-
Property changes on: branches/dbmod/db_modules/mysql/mysql.c
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/mysql/mysql.h
===================================================================
--- branches/dbmod/db_modules/mysql/mysql.h 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/db_modules/mysql/mysql.h 2009-08-02 13:59:30 UTC (rev 125)
@@ -15,7 +15,7 @@
*/
/*
- * $Id: mysql.h 104 2009-02-11 19:04:58Z leorogoski $
+ * $Id$
*/
#ifndef MYSQL_H
Property changes on: branches/dbmod/db_modules/mysql/mysql.h
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/mysql/sql.c
===================================================================
--- branches/dbmod/db_modules/mysql/sql.c 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/db_modules/mysql/sql.c 2009-08-02 13:59:30 UTC (rev 125)
@@ -14,7 +14,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-static const char rcsid[] = "$Id: sql.c 120 2009-04-27 10:20:20Z leorogoski $";
+static const char rcsid[] = "$Id$";
#include <errno.h>
#include <stdlib.h>
@@ -34,11 +34,11 @@
str_zero(&buf);
if (len != sql->len)
- if (str_cats(sql, (unsigned char *)", ") == 0) exit(51);
+ if (str_cats(sql, (unsigned char *)", ") == 0) die_nomem();
buf.len = fmt_printf(NULL, "`%S` = '%q'", key, value);
- if (str_ready(&buf, buf.len + 1) == 0) exit(51);
+ if (str_ready(&buf, buf.len + 1) == 0) die_nomem();
buf.len = fmt_printf(buf.s, "`%S` = '%q'", key, value);
- if (str_cat(sql, buf.s, buf.len) == 0) exit(51);
+ if (str_cat(sql, buf.s, buf.len) == 0) die_nomem();
str_free(&buf);
}
@@ -48,11 +48,11 @@
str_zero(&buf);
if (len != sql->len)
- if (str_cats(sql, (unsigned char *)", ") == 0) exit(51);
+ if (str_cats(sql, (unsigned char *)", ") == 0) die_nomem();
buf.len = fmt_printf(NULL, "`%S` = '%d'", key, value);
- if (str_ready(&buf, buf.len + 1) == 0) exit(51);
+ if (str_ready(&buf, buf.len + 1) == 0) die_nomem();
buf.len = fmt_printf(buf.s, "`%S` = '%d'", key, value);
- if (str_cat(sql, buf.s, buf.len) == 0) exit(51);
+ if (str_cat(sql, buf.s, buf.len) == 0) die_nomem();
str_free(&buf);
}
@@ -62,11 +62,11 @@
str_zero(&buf);
if (len != sql->len)
- if (str_cats(sql, (unsigned char *)", ") == 0) exit(51);
+ if (str_cats(sql, (unsigned char *)", ") == 0) die_nomem();
buf.len = fmt_printf(NULL, "`%S` = '%l'", key, value);
- if (str_ready(&buf, buf.len + 1) == 0) exit(51);
+ if (str_ready(&buf, buf.len + 1) == 0) die_nomem();
buf.len = fmt_printf(buf.s, "`%S` = '%l'", key, value);
- if (str_cat(sql, buf.s, buf.len) == 0) exit(51);
+ if (str_cat(sql, buf.s, buf.len) == 0) die_nomem();
str_free(&buf);
}
@@ -104,10 +104,8 @@
die_nomem();
sql.len = fmt_printf(sql.s, "UPDATE users SET status = 'OFF'");
- if (db_query2(&mysql, &sql) == RFAIL) {
- str_free(&sql);
- return(RFAIL);
- }
+ if (db_query2(&mysql, &sql) == RFAIL)
+ goto err;
str_free(&sql);
return(ROK);
@@ -185,10 +183,11 @@
/* user does not exist */
fmt = "INSERT INTO users (email, display_name, last_seen, last_addr, "
"connect, save_msg, save_contacts, commands) VALUES "
- "('%q', '%q', NOW(), '%q', (SELECT connect FROM defaults), "
- "(SELECT save_msg FROM defaults), "
- "(SELECT save_contacts FROM defaults), "
- "(SELECT commands FROM defaults))";
+ "('%q', '%q', NOW(), '%q', "
+ "(SELECT connect FROM defaults LIMIT 1), "
+ "(SELECT save_msg FROM defaults LIMIT 1), "
+ "(SELECT save_contacts FROM defaults LIMIT 1), "
+ "(SELECT commands FROM defaults LIMIT 1))";
sql.len = fmt_printf(NULL, fmt, user->email.s,
user->email.s, user->addr.s);
@@ -423,7 +422,7 @@
sql.a = fmt_printf(sql.s, fmt);
res = db_query(&mysql, &sql);
- if (res == (MYSQL_RES *)0)
+ if (res == NULL)
goto err;
str_free(&sql);
@@ -432,40 +431,33 @@
if (row == (MYSQL_ROW)0)
goto err;
+ /* defaults */
+ defaults->commands = 0;
+ defaults->connect = NO;
+ defaults->save_msg = NO;
+ defaults->save_contacts = NO;
+
/* connect */
- if (row[0]) {
- if (strcasecmp(row[0], "YES") == 0)
- defaults->connect = YES;
- else if (strcasecmp(row[0], "NO") == 0)
- defaults->connect = NO;
- }
+ if (row[0] && strcasecmp(row[0], "YES") == 0)
+ defaults->connect = YES;
/* save_msg */
- if (row[1]) {
- if (strcasecmp(row[1], "YES") == 0)
- defaults->save_msg = YES;
- else if (strcasecmp(row[1], "NO") == 0)
- defaults->save_msg = NO;
- }
+ if (row[1] && strcasecmp(row[1], "YES") == 0)
+ defaults->save_msg = YES;
/* save_contacts */
- if (row[2]) {
- if (strcasecmp(row[2], "YES") == 0)
- defaults->save_contacts = YES;
- else if (strcasecmp(row[2], "NO") == 0)
- defaults->save_contacts = NO;
- }
+ if (row[2] && strcasecmp(row[2], "YES") == 0)
+ defaults->save_contacts = YES;
/* commands */
if (row[3]) {
- defaults->commands = (int)strtol(row[3], (char **)0, 10);
+ defaults->commands = (int)strtol(row[3], NULL, 10);
}
/* listen_host */
if (row[4]) {
- if (str_copys(&defaults->proxy_ip, (unsigned char *)row[4]) == 0) {
- goto err;
- }
+ if (str_copys(&defaults->proxy_ip, (unsigned char *)row[4]) == 0)
+ die_nomem();
}
res = db_free(res);
@@ -492,11 +484,11 @@
res = db_query(&mysql, &sql);
str_free(&sql);
- if (res == (MYSQL_RES *)0)
+ if (res == NULL)
return(RFAIL);
row = db_fetch_row(res);
- if (row == (MYSQL_ROW)0 || row[0] == (char *)0) {
+ if (row == (MYSQL_ROW)0 || row[0] == NULL) {
res = db_free(res);
return(RFAIL);
}
@@ -505,11 +497,8 @@
res = db_free(res);
return(YES);
}
- else if (strcasecmp(row[0], "NO") == 0) {
- res = db_free(res);
- return(NO);
- }
- return(RFAIL);
+ res = db_free(res);
+ return(NO);
}
int
@@ -529,11 +518,11 @@
res = db_query(&mysql, &sql);
str_free(&sql);
- if (res == (MYSQL_RES *)0)
- return(RFAIL);
+ if (res == NULL)
+ return(RFAIL);
row = db_fetch_row(res);
- if (row == (MYSQL_ROW)0 || row[0] == (char *)0) {
+ if (row == (MYSQL_ROW)0 || row[0] == NULL) {
res = db_free(res);
return(RFAIL);
}
@@ -723,7 +712,7 @@
str_zero(&buf);
str_zero(&sql);
if (str_copys(&sql, (unsigned char *)"UPDATE contacts SET ") == 0)
- exit(51);
+ die_nomem();
len = sql.len;
if ((contact->dn.len > 0 && contact->save->dn.len > 0 &&
@@ -745,7 +734,7 @@
if (str_copy(&contact->info, contact->save->info.s,
contact->save->info.len) == 0)
- exit(51);
+ die_nomem();
sql_data(&sql, len, "contact_info", (char *)contact->info.s);
}
if ((contact->status.len > 0 && contact->save->status.len > 0 &&
@@ -754,7 +743,7 @@
if (str_copy(&contact->status, contact->save->status.s,
contact->save->status.len) == 0)
- exit(51);
+ die_nomem();
sql_data(&sql, len, "contact_status", (char *)contact->status.s);
}
if ((contact->o.len > 0 && contact->save->o.len > 0 &&
@@ -763,7 +752,7 @@
if (str_copy(&contact->o, contact->save->o.s,
contact->save->o.len) == 0)
- exit(51);
+ die_nomem();
sql_data(&sql, len, "contact_obj", (char *)contact->o.s);
}
if (contact->deny != contact->save->deny) {
@@ -799,12 +788,12 @@
"`email` = '%q' AND "
"`contact_email` = '%q'", user->email.s,
contact->c.s);
- if (str_ready(&buf, buf.len + 1) == 0) exit(51);
+ if (str_ready(&buf, buf.len + 1) == 0) die_nomem();
buf.len = fmt_printf(buf.s, " WHERE "
"`email` = '%q' AND "
"`contact_email` = '%q'", user->email.s,
contact->c.s);
- if (buf.len > 0 && str_cat(&sql, buf.s, buf.len) == 0) exit(51);
+ if (buf.len > 0 && str_cat(&sql, buf.s, buf.len) == 0) die_nomem();
str_free(&buf);
}
@@ -862,7 +851,7 @@
contact_print(contact);
return(RFAIL);
}
- } else if (contact->updated == NONE && delete) {
+ } else if (contact->updated == NONE && delete == 1) {
if ((contact->deny & CONTACT_REMOVED) == 0) {
@@ -878,18 +867,14 @@
return(RFAIL);
}
}
-
-// RB_REMOVE(contacts, &user->contacts, contact);
-// contact_free(contact);
-// free(contact);
-
}
}
return(ROK);
}
-int sql_check_contactgroup(string *email, string *name, string *id) {
+int
+sql_check_contactgroup(string *email, string *name, string *id) {
char fmt[] = "SELECT name, id FROM contact_groups WHERE "
"email = '%q' AND name = '%q'";
MYSQL_RES *res;
@@ -946,8 +931,8 @@
sql.len = fmt_printf(sql.s, fmt, name->s, id->s, email->s, name->s);
if (db_query2(&mysql, &sql) == RFAIL) {
- str_free(&sql);
- return(RFAIL);
+ str_free(&sql);
+ return(RFAIL);
}
str_free(&sql);
@@ -1028,15 +1013,15 @@
}
if (row[0] && strlen(row[0]) > 0) /* contact_email */
- if (str_copys(&contact->c, (unsigned char *)row[0]) == 0) exit(51);
+ if (str_copys(&contact->c, (unsigned char *)row[0]) == 0) die_nomem();
if (row[1] && strlen(row[1]) > 0) /* contact_dn */
- if (str_copys(&contact->dn, (unsigned char *)row[1]) == 0) exit(51);
+ if (str_copys(&contact->dn, (unsigned char *)row[1]) == 0) die_nomem();
if (row[2] && strlen(row[2]) > 0) /* contact_uid */
- if (str_copys(&contact->uid, (unsigned char *)row[2]) == 0) exit(51);
+ if (str_copys(&contact->uid, (unsigned char *)row[2]) == 0) die_nomem();
if (row[3] && strlen(row[3]) > 0) /* contact_status */
- if (str_copys(&contact->status, (unsigned char *)row[3]) == 0) exit(51);
+ if (str_copys(&contact->status, (unsigned char *)row[3]) == 0) die_nomem();
if (row[4] && strlen(row[4]) > 0) /* contact_info */
- if (str_copys(&contact->info, (unsigned char *)row[4]) == 0) exit(51);
+ if (str_copys(&contact->info, (unsigned char *)row[4]) == 0) die_nomem();
contact->flags = row[5] ? atoll(row[5]) : 0; /* flags */
contact->flags2 = row[6] ? atoll(row[6]) : 0; /* flags2 */
@@ -1082,18 +1067,18 @@
if (row[0] == NULL || strlen(row[0]) == 0)
continue;
- if (str_copys(&c, (unsigned char *)row[0]) == 0) exit(51);
+ if (str_copys(&c, (unsigned char *)row[0]) == 0) die_nomem();
contact = contact_add(user, &c);
str_free(&c);
if (row[1] && strlen(row[1]) > 0) /* contact_dn */
- if (str_copys(&contact->dn, (unsigned char *)row[1]) == 0) exit(51);
+ if (str_copys(&contact->dn, (unsigned char *)row[1]) == 0) die_nomem();
if (row[2] && strlen(row[2]) > 0) /* contact_uid */
- if (str_copys(&contact->uid, (unsigned char *)row[2]) == 0) exit(51);
+ if (str_copys(&contact->uid, (unsigned char *)row[2]) == 0) die_nomem();
if (row[3] && strlen(row[3]) > 0) /* contact_status */
- if (str_copys(&contact->status, (unsigned char *)row[3]) == 0) exit(51);
+ if (str_copys(&contact->status, (unsigned char *)row[3]) == 0) die_nomem();
if (row[4] && strlen(row[4]) > 0) /* contact_info */
- if (str_copys(&contact->info, (unsigned char *)row[4]) == 0) exit(51);
+ if (str_copys(&contact->info, (unsigned char *)row[4]) == 0) die_nomem();
contact->flags = row[5] ? atoll(row[5]) : 0; /* flags */
contact->flags2 = row[6] ? atoll(row[6]) : 0; /* flags2 */
@@ -1202,4 +1187,3 @@
res = db_free(res);
return(RFAIL);
}
-
Property changes on: branches/dbmod/db_modules/mysql/sql.c
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/mysql/sql.h
===================================================================
--- branches/dbmod/db_modules/mysql/sql.h 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/db_modules/mysql/sql.h 2009-08-02 13:59:30 UTC (rev 125)
@@ -15,7 +15,7 @@
*/
/*
- * $Id: sql.h 96 2009-01-20 15:34:19Z loos-br $
+ * $Id$
*/
#ifndef SQL_H
Property changes on: branches/dbmod/db_modules/mysql/sql.h
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/Makefile
===================================================================
--- branches/dbmod/db_modules/pgsql/Makefile 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/db_modules/pgsql/Makefile 2009-08-02 13:59:30 UTC (rev 125)
@@ -1,3 +1,9 @@
+INSTALL=/usr/bin/install
+SYSCONFDIR=$(DESTDIR)/usr/local/msn-proxy
+
+# you need to point this to the libevent header path
+LIBEVENTINC=/usr/local/include
+
# FreeBSD
PGSQLINC=/usr/local/include
PGSQLLIB=/usr/local/lib
@@ -6,20 +12,22 @@
#PGSQLINC=
#PGSQLLIB=
-CCFLAGS=-g -Wall -O2 -pipe -fno-builtin-log -I$(PGSQLINC)
+CCFLAGS=-g -Wall -O2 -pipe -fno-builtin-log -I$(LIBEVENTINC) -I$(PGSQLINC)
+LDFLAGS=-L$(PGSQLLIB) -lpq
MODULE=pgsql.so
-OBJS=pgsql.o
+OBJS=pgsql.o sql.o
-INCLUDES=pgsql.h
+INCLUDES=pgsql.h sql.h
+TABLES=tables/contacts tables/contact_groups tables/sb tables/log tables/defaults tables/users
all: $(MODULE)
$(MODULE): $(OBJS) $(INCLUDES)
- cc -shared -o $(MODULE) $(OBJS)
+ cc -shared -o $(MODULE) $(OBJS) $(LDFLAGS)
.c.o: $(INCLUDES)
cc $(CCFLAGS) -c $<
@@ -28,6 +36,8 @@
rm -f *.o $(MODULE)
install: all
- install -d /usr/local/msn-proxy
- install -b -m 755 $(MODULE) /usr/local/msn-proxy/$(MODULE)
+ $(INSTALL) -d $(SYSCONFDIR)/pgsql/tables
+ $(INSTALL) -b -m 755 $(MODULE) $(SYSCONFDIR)/pgsql/$(MODULE)
+ $(INSTALL) -b -m 600 conf $(SYSCONFDIR)/pgsql
+ $(INSTALL) -m 644 $(TABLES) $(SYSCONFDIR)/pgsql/tables
Added: branches/dbmod/db_modules/pgsql/conf
===================================================================
--- branches/dbmod/db_modules/pgsql/conf (rev 0)
+++ branches/dbmod/db_modules/pgsql/conf 2009-08-02 13:59:30 UTC (rev 125)
@@ -0,0 +1,2 @@
+# postgresql connection options
+host=localhost dbname=msn-proxy user=msn-proxy password=secret
Property changes on: branches/dbmod/db_modules/pgsql/conf
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/pgsql.c
===================================================================
--- branches/dbmod/db_modules/pgsql/pgsql.c 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/db_modules/pgsql/pgsql.c 2009-08-02 13:59:30 UTC (rev 125)
@@ -14,30 +14,501 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-static const char rcsid[] = "$Id: net.c,v 1.5 2009-01-15 23:38:26 luiz Exp $";
+static const char rcsid[] = "$Id$";
-#define MODULE_NAME "pgsql"
+#define MODULE_NAME "pgsql"
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "sql.h"
+#include "pgsql.h"
#include "../../db.h"
+#include "../../fmt.h"
+#include "../../return.h"
#include "../../msn-proxy.h"
+#define print_bar(a) (a[strlen(a) - 1] == '/') ? "" : "/"
+
+/* global - pgsql private data */
+struct pgsql_ pgsql;
+
+int
+tablecmp(struct table__ *t1, struct table__ *t2) {
+ if (t1 == NULL ||
+ t2 == NULL ||
+ t1->name.len == 0 ||
+ t2->name.len == 0) {
+ return 1;
+ }
+ return (strcmp((char *)t1->name.s, (char *)t2->name.s));
+}
+
+RB_GENERATE(tables, table__, table_, tablecmp)
+
+char *
+db_row(PGresult *res, int row, int column) {
+ return(PQgetvalue(res, row, column));
+}
+
+__uint32_t
+db_count(PGresult *res) {
+ return(PQntuples(res));
+}
+
+PGresult *
+db_free(PGresult *res) {
+ if (res == NULL)
+ return((PGresult *)NULL);
+
+ PQclear(res);
+ return((PGresult *)NULL);
+}
+
+PGresult *
+db_query(struct pgsql_ *pgsql, string *query) {
+ PGresult *res;
+
+ if(query == NULL || query->len == 0 || query->s == NULL || *query->s == 0)
+ return((PGresult *)NULL);
+
+ pgsql->info("SQL: (%s)\n", query);
+ res = PQexec(pgsql->pgsql, (char *)query->s);
+ if (PQresultStatus(res) != PGRES_TUPLES_OK) {
+ pgsql->debug("SQL ERROR: (%s) PGSQL: %S", query, db_error(pgsql));
+ res = db_free(res);
+ }
+
+ return(res);
+}
+
+int
+db_query2(struct pgsql_ *pgsql, string *query) {
+ PGresult *res;
+
+ if (query == NULL || query->len == 0 || query->s == NULL || *query->s == 0)
+ return(RFAIL);
+
+ pgsql->info("SQL: (%s)\n", query);
+
+ res = PQexec(pgsql->pgsql, (char *)query->s);
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ pgsql->debug("SQL ERROR: (%s) PGSQL: %S", query, db_error(pgsql));
+ res = db_free(res);
+ return(RFAIL);
+ }
+
+ pgsql->affected = atoi(PQcmdTuples(res));
+ res = db_free(res);
+ return(ROK);
+}
+
+int
+db_create_all(struct pgsql_ *pgsql) {
+ struct table__ *table;
+ string sql;
+
+ str_zero(&sql);
+ RB_FOREACH(table, tables, &pgsql->table_head) {
+
+ if (table->exist == 1) continue;
+ if (table->sql.len == 0 || table->name.len == 0) continue;
+
+ sql.len = fmt_printf(NULL, (char *)table->sql.s, table->name.s);
+ if (str_ready(&sql, sql.len + 1) == 0) die_nomem();
+ sql.len = fmt_printf(sql.s, (char *)table->sql.s, table->name.s);
+ if (db_query2(pgsql, &sql) != ROK) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+ }
+
+ return(ROK);
+}
+
+int
+db_check(struct pgsql_ *pgsql) {
+ unsigned char sqlfmt[] = "SELECT table_name FROM information_schema.tables "
+ "WHERE table_schema = 'public' AND "
+ "table_type = 'BASE TABLE'";
+ struct table__ find;
+ struct table__ *table;
+ PGresult *res;
+ string sql;
+ char *t;
+ int i;
+
+ /* check tables */
+ str_zero(&sql);
+ sql.s = sqlfmt;
+ sql.len = strlen((char *)sql.s);
+ if ((res = db_query(pgsql, &sql)) == NULL)
+ return(RFAIL);
+
+ for (i = 0; i < db_count(res); i++) {
+ t = db_row(res, i, 0);
+ if (strlen(t) == 0) continue;
+ str_zero(&find.name);
+ find.name.len = strlen(t);
+ find.name.s = (unsigned char *)t;
+ table = RB_FIND(tables, &pgsql->table_head, &find);
+ if (table != NULL)
+ table->exist = 1;
+ }
+ res = db_free(res);
+
+ /* create missing tables */
+ return(db_create_all(pgsql));
+}
+
+char *
+db_error(struct pgsql_ *pgsql) {
+ char *p;
+
+ p = (char *)PQerrorMessage(pgsql->pgsql);
+ if (p && *p)
+ return(p);
+ else
+ return("");
+}
+
+int
+db_init(struct pgsql_ *pgsql, void (*debug)(const char *, ...),
+ void (*info)(const char *, ...)) {
+
+ pgsql->debug = debug;
+ pgsql->info = info;
+
+ if (!pgsql->conninfo.s || pgsql->conninfo.len == 0) {
+ if (!pgsql->conninfo.s) {
+ if (str_copys(&pgsql->conninfo,
+ (unsigned char *)DEFAULT_PGSQL_CONNINFO) == 0)
+ die_nomem();
+ }
+ pgsql->debug("check your pgsql config !!! using defaults !!!\n"
+ " conninfo: [%s]\n", &pgsql->conninfo);
+ }
+
+ /* connect */
+ pgsql->pgsql = PQconnectdb((char *)pgsql->conninfo.s);
+ memset(pgsql->conninfo.s, 0, pgsql->conninfo.len);
+ str_free(&pgsql->conninfo);
+
+ if (PQstatus(pgsql->pgsql) != CONNECTION_OK) {
+ pgsql->debug("connection to database failed: %S", db_error(pgsql));
+ db_close(pgsql);
+ return(RFAIL);
+ }
+
+ /* erase the database password from memory ?!?? Safety ? */
+ str_free(&pgsql->conninfo);
+
+ pgsql->connected = 1;
+ PQsetClientEncoding(pgsql->pgsql, "LATIN1");
+
+ /* check if db is ok */
+ return(db_check(pgsql));
+}
+
void
+db_close(struct pgsql_ *pgsql) {
+ if (pgsql->connected)
+ PQfinish(pgsql->pgsql);
+ pgsql->connected = 0;
+}
+
+int
+db_get_conf_key(char **key, char **buf) {
+ register char *p;
+
+ p = *buf;
+ *key = *buf;
+ while (*p && *p != '|' && *p != '\n' && *p != '\r') p++;
+ if (*p == 0)
+ return(ROK);
+
+ *p++ = 0;
+ *buf = p;
+
+ return(ROK);
+}
+
+void
+db_table_free(struct table__ *table) {
+ if (table == NULL) return;
+ str_free(&table->name);
+ str_free(&table->sql);
+ table->exist = 0;
+ table->size = 0;
+}
+
+int
+db_read_table_sql(const char *file, long filelen, size_t size,
+ struct table__ **table_) {
+ struct table__ *table;
+ size_t len;
+ int fd;
+
+ if (file == NULL || filelen == 0)
+ return(RFAIL);
+
+ *table_ = (struct table__ *)malloc(sizeof(struct table__));
+ if (*table_ == NULL) die_nomem();
+ table = *table_;
+ str_zero(&table->name);
+ str_zero(&table->sql);
+ table->size = size;
+ table->exist = 0;
+
+ if (str_ready(&table->sql, table->size + 1) == 0) die_nomem();
+ if (str_copy(&table->name, (unsigned char *)file, filelen) == 0) die_nomem();
+
+ /* open file and read read */
+ fd = open((char *)table->name.s, O_RDONLY);
+ if (fd == -1) {
+ log->debug("cannot open table file [%S]: [%S]\n", table->name.s,
+ strerror(errno));
+ db_table_free(table);
+ free(*table_);
+ return(RFAIL);
+ }
+ while (table->sql.len < size) {
+ len = read(fd, (char *)table->sql.s + table->sql.len,
+ table->sql.a - table->sql.len);
+ if (len == -1) {
+ log->debug("cannot read table file [%S]: [%S]\n", table->name.s,
+ strerror(errno));
+ db_table_free(table);
+ free(*table_);
+ return(RFAIL);
+ }
+ if (len == 0) break;
+ table->sql.len += len;
+ }
+ close(fd);
+
+ return(ROK);
+}
+
+int
+db_read_tables(struct pgsql_ *pgsql, const char *configdir) {
+ struct table__ *table = NULL;
+ struct table__ *tmp = NULL;
+ struct dirent *de;
+ struct stat st;
+ DIR *dir;
+
+ /* RB_INIT */
+ RB_INIT(&pgsql->table_head);
+
+ if (chdir(PGSQLTABLE) == -1) {
+ log->debug("cannot chdir to pgsql tables directory: [%S%Stables] [%S]\n",
+ configdir, print_bar(configdir), strerror(errno));
+ return(RFAIL);
+ }
+ dir = opendir(".");
+ if (dir == NULL)
+ return(RFAIL);
+ while ((de = readdir(dir)) != NULL) {
+ if (de->d_name == NULL ||
+ strlen(de->d_name) == 0 ||
+ strcmp(de->d_name, ".") == 0 ||
+ strcmp(de->d_name, "..") == 0) {
+ continue;
+ }
+
+ memset(&st, 0, sizeof(st));
+ if (stat(de->d_name, &st) == -1) {
+ log->debug("cannot stat table file: [%S]: [%S]\n", de->d_name,
+ strerror(errno));
+ continue;
+ }
+
+ if (st.st_size == 0) {
+ log->debug("table file with zero size: [%S]. ignoring file...\n", de->d_name);
+ continue;
+ }
+
+ if (db_read_table_sql(de->d_name, strlen(de->d_name), st.st_size, &table) == ROK) {
+ tmp = RB_INSERT(tables, &pgsql->table_head, table);
+ if (tmp) {
+ db_table_free(table);
+ log->debug("you can't go over there... [%S]: ignoring...\n", de->d_name);
+ }
+ }
+ }
+ closedir(dir);
+ return(ROK);
+}
+
+int
+db_read_conf(struct pgsql_ *pgsql, const char *configdir) {
+ struct stat sb;
+ FILE *fp;
+ char buf[1024];
+ char *p;
+ int curdir = -1;
+
+ memset(pgsql, 0, sizeof(struct pgsql_));
+
+ /* save the current dir */
+ curdir = open(".", O_RDONLY);
+ if (curdir == -1) {
+ log->debug("cannot open curdir: [%S]\n", strerror(errno));
+ goto fail;
+ }
+
+ /* chdir to config dir */
+ if (chdir(configdir) == -1) {
+ log->debug("cannot chdir to pgsql configuration directory: [%S]: [%S]\n",
+ configdir, strerror(errno));
+ goto fail;
+ }
+
+ /* check access to config */
+ memset(&sb, 0, sizeof(sb));
+ if (stat(PGSQLCONF, &sb) == -1) {
+ log->debug("cannot stat configuration file: [%S%Sconf]: [%S]\n",
+ configdir, print_bar(configdir), strerror(errno));
+ goto fail;
+ }
+
+ if (sb.st_mode & S_IRWXO)
+ log->debug("PUBLIC ACCESS on %S%Sconf should be removed !!!\n",
+ "ie: chmod 400 %S%Sconf\n", configdir, print_bar(configdir),
+ configdir, print_bar(configdir));
+
+ fp = fopen(PGSQLCONF, "r");
+ if (fp == (FILE *)0) {
+ log->debug("cannot open configuration file: [%S%Sconf]: [%S]\n",
+ configdir, print_bar(configdir), strerror(errno));
+ goto fail;
+ }
+
+ p = (char *)0;
+ memset(buf, 0, sizeof(buf));
+ while (fgets(buf, sizeof(buf), fp)) {
+
+ /* strip cr/lf */
+ if (strlen(buf) > 0) {
+ p = strchr(buf, '\r');
+ if (!p) p = strchr(buf, '\n');
+ if (p) *p = 0;
+ }
+
+ /* skip spaces and tabs */
+ p = buf;
+ while (p && *p && (*p == ' ' || *p == '\t')) ++p;
+ if (!*p) {
+ memset(buf, 0, sizeof(buf));
+ continue;
+ }
+
+ if (*p == '\n' || *p == '\r' || *p == '#') {
+ memset(buf, 0, sizeof(buf));
+ p = (char *)0;
+ continue;
+ }
+
+ /* break on first valid line */
+ break;
+ }
+ fclose(fp);
+
+ /* check for buffer */
+ if (!p || !*p) {
+ log->debug("zero configuration data (no content) on file: [%S%Sconf]\n",
+ configdir, print_bar(configdir));
+ goto fail;
+ }
+
+ if (strlen(p) > 0 && str_copys(&pgsql->conninfo, (unsigned char *)p) == 0)
+ die_nomem();
+
+ if (db_read_tables(pgsql, configdir) == RFAIL)
+ goto fail;
+
+ /* check for tables */
+ /* if (RB_EMPTY(&pgsql->table_head))
+ * log->debug("nenhuma tabela foi carregada !\n");
+ */
+
+ fchdir(curdir);
+ close(curdir);
+ return(ROK);
+
+fail:
+ fchdir(curdir);
+ close(curdir);
+ return(RFAIL);
+}
+
+/* remove tables from tree and memory */
+void
+free_sqltable_tree(struct pgsql_ *pgsql) {
+ struct table__ *table;
+ struct table__ *next;
+
+ for (table = RB_MIN(tables, &pgsql->table_head); table != NULL; table = next) {
+ next = RB_NEXT(tables, &pgsql->table_head, table);
+ RB_REMOVE(tables, &pgsql->table_head, table);
+ db_table_free(table);
+ free(table);
+ }
+}
+
+int
modLoad(struct mod_ *mod) {
log->debug("debug: module " MODULE_NAME " loading...\n");
if (str_copys(&mod->modName, (unsigned char *)MODULE_NAME) == 0)
- exit(51);
+ die_nomem();
- /* adiciona os comandos xml do modulo */
-// xml_cmds_AddMod(mod, MODULE_XML_CMD);
-// xml_cmds_AddMod(mod, MODULE_XML_CMD "_teste");
-// xml_cmds_AddMod(mod, MODULE_XML_CMD "_teste_321");
-// xml_cmds_AddMod(mod, MODULE_XML_CMD "_teste_123");
+ /* read pgsql configuration */
+ if (db_read_conf(&pgsql, PGSQLCONFDIR) == RFAIL)
+ return(-1);
+
+ /* connect to pgsql */
+ if (db_init(&pgsql, config.log.debug, config.log.sql) == RFAIL)
+ return(-1);
+
+ /* read config defaults */
+ if (sql_read_defaults() == RFAIL)
+ return(-1);
+
+ /* remove stale records */
+ if (sql_disconnect_all() == RFAIL)
+ return(-1);
+
+ return(0);
}
void
modUnload(void) {
+
log->debug("debug: module " MODULE_NAME " unloading...\n");
+
+ /* close pgsql connection */
+ db_close(&pgsql);
+
+ /* free sql tree - tables */
+ free_sqltable_tree(&pgsql);
+
+ /* free pgsql data */
+ str_free(&pgsql.conninfo);
+ pgsql.connected = 0;
+ pgsql.affected = 0;
+ pgsql.debug = NULL;
+ pgsql.info = NULL;
+
+ /* defaults_cleanup */
+ defaults_cleanup(&config.defaults);
}
-
Property changes on: branches/dbmod/db_modules/pgsql/pgsql.c
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/pgsql.h
===================================================================
--- branches/dbmod/db_modules/pgsql/pgsql.h 2009-07-28 19:59:49 UTC (rev 124)
+++ branches/dbmod/db_modules/pgsql/pgsql.h 2009-08-02 13:59:30 UTC (rev 125)
@@ -15,40 +15,29 @@
*/
/*
- * $Id: mysql.h 104 2009-02-11 19:04:58Z leorogoski $
+ * $Id$
*/
#ifndef PGSQL_H
#define PGSQL_H
-#ifndef MYSQLCONFDIR
-#define MYSQLCONFDIR "/usr/local/etc/msn-proxy/mysql"
+#ifndef PGSQLCONFDIR
+#define PGSQLCONFDIR "/usr/local/msn-proxy/pgsql"
#endif
-#ifndef MYSQLCONF
-#define MYSQLCONF "conf"
+#ifndef PGSQLCONF
+#define PGSQLCONF "conf"
#endif
-#ifndef MYSQLTABLE
-#define MYSQLTABLE "tables"
+#ifndef PGSQLTABLE
+#define PGSQLTABLE "tables"
#endif
-#ifndef DEFAULT_MYSQL_HOST
-#define DEFAULT_MYSQL_HOST "/tmp/mysql.sock"
+#ifndef DEFAULT_PGSQL_CONNINFO
+#define DEFAULT_PGSQL_CONNINFO "host=localhost dbname=msn-proxy port=5432 " \
+ "user=msn-proxy password=secret"
#endif
-#ifndef DEFAULT_MYSQL_PORT
-#define DEFAULT_MYSQL_PORT 3306
-#endif
-#ifndef DEFAULT_MYSQL_USER
-#define DEFAULT_MYSQL_USER "maildir-index"
-#endif
-#ifndef DEFAULT_MYSQL_PASS
-#define DEFAULT_MYSQL_PASS "secret"
-#endif
-#ifndef DEFAULT_MYSQL_DB
-#define DEFAULT_MYSQL_DB "maildir-index"
-#endif
#include "../../tree.h"
#include "../../string.h"
-#include <mysql/mysql.h>
+#include <libpq-fe.h>
struct table__ {
RB_ENTRY(table__) table_;
@@ -62,36 +51,27 @@
struct table__ *rbh_root; /* root of the tree */
};
-typedef struct {
+struct pgsql_ {
struct tables table_head; /* sql to create table */
- MYSQL mysql; /* mysql internal data */
- string user; /* mysql user */
- string pass; /* mysql pass */
- string db; /* mysql db */
- string host; /* mysql host */
- unsigned int port; /* mysql port */
- int connected; /* is mysql connected ? */
+ PGconn *pgsql; /* pgsql internal data */
+ string conninfo; /* pgsql conninfo data */
+ int affected; /* affected rows */
+ int connected; /* is pgsql connected ? */
void (*info)(const char *, ...);
void (*debug)(const char *, ...);
-} mysql_;
+};
-MYSQL_ROW db_fetch_row(MYSQL_RES *res);
-u_int64_t db_count(MYSQL_RES *res);
-u_int64_t db_affected_rows(MYSQL *mysql);
-u_int64_t db_last_id(MYSQL *mysql);
-MYSQL_RES *db_free(MYSQL_RES *res);
-char *db_escape(mysql_ *mysql, char *from);
-MYSQL_RES *db_query(mysql_ *mysql, string *query);
-int db_query2(mysql_ *mysql, string *query);
-int db_create_all(mysql_ *mysql);
-int db_check(mysql_ *mysql);
-char *db_error(mysql_ *mysql);
-int db_init(mysql_ *mysql,
- void (*debug)(const char *, ...),
- void (*sql)(const char *,...));
-void db_close(mysql_ *mysql);
-int db_read_conf(mysql_ *mysql, const char *configdir);
+int db_read_conf(struct pgsql_ *pgsql, const char *configdir);
+int db_init(struct pgsql_ *pgsql, void (*debug)(const char *, ...),
+ void (*info)(const char *, ...));
+int db_query2(struct pgsql_ *pgsql, string *query);
+char *db_row(PGresult *res, int row, int column);
+char *db_error(struct pgsql_ *pgsql);
+void db_close(struct pgsql_ *pgsql);
+PGresult *db_free(PGresult *res);
+PGresult *db_query(struct pgsql_ *pgsql, string *query);
+__uint32_t db_count(PGresult *res);
-void free_sqltable_tree(mysql_ *mysql);
+extern struct pgsql_ pgsql;
#endif
Property changes on: branches/dbmod/db_modules/pgsql/pgsql.h
___________________________________________________________________
Added: svn:keywords
+ Id
Added: branches/dbmod/db_modules/pgsql/sql.c
===================================================================
--- branches/dbmod/db_modules/pgsql/sql.c (rev 0)
+++ branches/dbmod/db_modules/pgsql/sql.c 2009-08-02 13:59:30 UTC (rev 125)
@@ -0,0 +1,1168 @@
+/*
+ * Copyright (c) 2004-2009, Luiz Otavio O Souza <lo...@gm...>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+static const char rcsid[] = "$Id$";
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "sql.h"
+#include "pgsql.h"
+#include "../../fmt.h"
+#include "../../return.h"
+#include "../../protocol.h"
+#include "../../array_cmd.h"
+#include "../../msn-proxy.h"
+
+void
+sql_data(string *sql, unsigned int len, char *key, char *value) {
+ string buf;
+
+ str_zero(&buf);
+ if (len != sql->len)
+ if (str_cats(sql, (unsigned char *)", ") == 0) die_nomem();
+ buf.len = fmt_printf(NULL, "\"%S\" = E'%q'", key, value);
+ if (str_ready(&buf, buf.len + 1) == 0) die_nomem();
+ buf.len = fmt_printf(buf.s, "\"%S\" = E'%q'", key, value);
+ if (str_cat(sql, buf.s, buf.len) == 0) die_nomem();
+ str_free(&buf);
+}
+
+void
+sql_int_data(string *sql, unsigned int len, char *key, unsigned long value) {
+ string buf;
+
+ str_zero(&buf);
+ if (len != sql->len)
+ if (str_cats(sql, (unsigned char *)", ") == 0) die_nomem();
+ buf.len = fmt_printf(NULL, "\"%S\" = '%d'", key, value);
+ if (str_ready(&buf, buf.len + 1) == 0) die_nomem();
+ buf.len = fmt_printf(buf.s, "\"%S\" = '%d'", key, value);
+ if (str_cat(sql, buf.s, buf.len) == 0) die_nomem();
+ str_free(&buf);
+}
+
+void
+sql_lint_data(string *sql, unsigned int len, char *key, unsigned long long value) {
+ string buf;
+
+ str_zero(&buf);
+ if (len != sql->len)
+ if (str_cats(sql, (unsigned char *)", ") == 0) die_nomem();
+ buf.len = fmt_printf(NULL, "\"%S\" = '%l'", key, value);
+ if (str_ready(&buf, buf.len + 1) == 0) die_nomem();
+ buf.len = fmt_printf(buf.s, "\"%S\" = '%l'", key, value);
+ if (str_cat(sql, buf.s, buf.len) == 0) die_nomem();
+ str_free(&buf);
+}
+
+int
+sql_disconnect_all(void) {
+ string sql;
+
+ str_zero(&sql);
+
+ /* remove stale sb sessions */
+ sql.len = fmt_printf(NULL, "DELETE FROM sb");
+ if (str_ready(&sql, sql.len + 1) == 0) die_nomem();
+ sql.len = fmt_printf(sql.s, "DELETE FROM sb");
+
+ if (db_query2(&pgsql, &sql) == RFAIL)
+ goto err;
+
+ /* logoff all contacts */
+ sql.len = fmt_printf(NULL, "UPDATE contacts SET contact_status = 'OFF', "
+ "contact_deny = contact_deny & ~%d",
+ CONTACT_BLOCKED);
+ if (str_ready(&sql, sql.len + 1) == 0) die_nomem();
+ sql.len = fmt_printf(sql.s, "UPDATE contacts SET contact_status = 'OFF', "
+ "contact_deny = contact_deny & ~%d",
+ CONTACT_BLOCKED);
+
+ if (db_query2(&pgsql, &sql) == RFAIL)
+ goto err;
+
+ str_free(&sql);
+
+ /* logoff everyone */
+ sql.len = fmt_printf(NULL, "UPDATE users SET status = 'OFF'");
+ if (str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, "UPDATE users SET status = 'OFF'");
+
+ if (db_query2(&pgsql, &sql) == RFAIL)
+ goto err;
+
+ str_free(&sql);
+ return(ROK);
+
+err:
+ log->debug("debug: fail to reset database\n");
+ str_free(&sql);
+ return(RFAIL);
+}
+
+int
+sql_user_disconnect(string *email) {
+ string sql;
+ char *fmt;
+
+ str_zero(&sql);
+
+ /* logoff user contacts */
+ fmt = "UPDATE contacts SET contact_status = 'OFF', "
+ "contact_deny = contact_deny & ~%d WHERE email = '%q'";
+ sql.len = fmt_printf(NULL, fmt, CONTACT_BLOCKED, email->s);
+ if(str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, CONTACT_BLOCKED, email->s);
+
+ if (db_query2(&pgsql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+
+ /* logoff user */
+ fmt = "UPDATE users SET status = 'OFF' WHERE email = '%q'";
+ sql.len = fmt_printf(NULL, fmt, email->s);
+ if(str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, email->s);
+
+ if (db_query2(&pgsql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+
+ str_free(&sql);
+ return(ROK);
+}
+
+int
+sql_users_update(struct user_ *user) {
+ string sql;
+ char *fmt;
+
+ str_zero(&sql);
+
+ /* user exists ? */
+ fmt = "UPDATE users SET last_seen = NOW(), last_addr = '%q' "
+ "WHERE email = '%q'";
+ sql.len = fmt_printf(NULL, fmt, user->addr.s, user->email.s);
+ if(str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, user->addr.s, user->email.s);
+
+ if (db_query2(&pgsql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ if (pgsql.affected > 0) {
+
+ /* user exist */
+ return(ROK);
+
+ } else if (pgsql.affected == 0) {
+
+ /* user does not exist */
+ fmt = "INSERT INTO users (email, display_name, last_seen, last_addr, "
+ "connect, save_msg, save_contacts, commands) VALUES "
+ "('%q', '%q', NOW(), '%q', "
+ "(SELECT connect FROM defaults LIMIT 1), "
+ "(SELECT save_msg FROM defaults LIMIT 1), "
+ "(SELECT save_contacts FROM defaults LIMIT 1), "
+ "(SELECT commands FROM defaults LIMIT 1))";
+
+ sql.len = fmt_printf(NULL, fmt, user->email.s,
+ user->email.s, user->addr.s);
+ if (str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, user->email.s,
+ user->email.s, user->addr.s);
+
+ if (db_query2(&pgsql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ return(ROK);
+ }
+
+ /* notreached */
+ return(RFAIL);
+}
+
+int
+sql_set_status(struct user_ *user) {
+ string sql;
+ char fmt[] = "UPDATE users SET status = '%q' WHERE email = '%q'";
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, user->status.s, user->email.s);
+ if (str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, user->status.s, user->email.s);
+
+ if (db_query2(&pgsql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ return(ROK);
+}
+
+int
+sql_update_user_dn(struct user_ *user) {
+ char fmt[] = "UPDATE users SET display_name = '%q' "
+ "WHERE email = '%q'";
+ string sql;
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, user->dn.s, user->email.s);
+ if (str_ready(&sql, sql.len + 1) == 0)
+ return(RFAIL);
+ sql.len = fmt_printf(sql.s, fmt, user->dn.s, user->email.s);
+
+ if (db_query2(&pgsql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ return(ROK);
+}
+
+__uint32_t
+sql_insert_sb(struct user_ *user) {
+ __uint32_t rtrn;
+ PGresult *res;
+ string sql;
+ char fmt[] = "INSERT INTO sb (email, since) VALUES ('%q', NOW());"
+ "SELECT lastval()";
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, user->email.s);
+ if(str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, user->email.s);
+
+ res = db_query(&pgsql, &sql);
+ str_free(&sql);
+ if (res == NULL)
+ return(0);
+
+ rtrn = 0;
+ if (db_count(res) > 0)
+ rtrn = (__uint32_t)atoi(db_row(res, 0, 0));
+
+ res = db_free(res);
+ return(rtrn);
+}
+
+int
+sql_remove_sb(int id) {
+ string sql;
+ char fmt[] = "DELETE FROM sb WHERE id = %d";
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, id);
+ if(str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, id);
+
+ if (db_query2(&pgsql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ return(ROK);
+}
+
+int
+sql_log_join(int sb_id, string *email, string *dn) {
+ char fmt[] = "INSERT INTO log (sb_id, date, email, display_name, "
+ "type) VALUES (%d, NOW(), E'%q', E'%q', 'join')";
+ string sql;
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, sb_id, email->s, dn->s);
+ if(str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, sb_id, email->s, dn->s);
+
+ if (db_query2(&pgsql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ return(ROK);
+}
+
+int
+sql_log_stop2(struct sb_ *sb, string *email, string *contact_email) {
+ string sql;
+ char fmt[] = "INSERT INTO log (sb_id, date, email, display_name, "
+ "type) VALUES (%d, NOW(), '%q', "
+ "(SELECT contact_dn FROM contacts WHERE email = '%q' "
+ "AND contact_email = '%q'), 'stop')";
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, sb->id, contact_email->s,
+ email->s, contact_email->s);
+ if(str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, sb->id, contact_email->s,
+ email->s, contact_email->s);
+
+ if (db_query2(&pgsql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ return(ROK);
+}
+
+int
+sql_log_stop(struct sb_ *sb, string *email, string *dn) {
+ string sql;
+ char fmt[] = "INSERT INTO log (sb_id, date, email, display_name, "
+ "type) VALUES (%d, NOW(), E'%q', E'%q', 'stop')";
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, sb->id, email->s, dn->s);
+ if(str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, sb->id, email->s, dn->s);
+
+ if (db_query2(&pgsql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ return(ROK);
+}
+
+int
+sql_log_start(int sb_id, string *email, string *dn) {
+ char fmt[] = "INSERT INTO log (sb_id, date, email, display_name, "
+ "type) VALUES (%d, NOW(), E'%q', E'%q', 'start')";
+ string sql;
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, sb_id, email->s, dn->s);
+ if(str_ready(&sql, sql.len + 1) == 0) die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, sb_id, email->s, dn->s);
+
+ if (db_query2(&pgsql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ return(ROK);
+}
+
+int
+sql_log_msg(int sb_id, string *email, string *dn, string *to, string *msg) {
+ char fmt[] = "INSERT INTO log (\"sb_id\", \"date\", \"email\", "
+ "\"to\", \"display_name\", \"type\", \"content\") "
+ "VALUES (%d, NOW(), E'%q', E'%q', E'%q', 'msg', "
+ "E'%q')";
+ string sql;
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, sb_id,
+ email->s ? email->s : (unsigned char *)"",
+ to->s ? to->s : (unsigned char *)"",
+ dn->s ? dn->s : (unsigned char *)"",
+ msg->s ? msg->s : (unsigned char *)"");
+ if (str_ready(&sql, sql.len + 1) == 0) die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, sb_id,
+ email->s ? email->s : (unsigned char *)"",
+ to->s ? to->s : (unsigned char *)"",
+ dn->s ? dn->s : (unsigned char *)"",
+ msg->s ? msg->s : (unsigned char *)"");
+
+ if (db_query2(&pgsql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ return(ROK);
+}
+
+int
+sql_read_defaults(void) {
+ char fmt[] = "SELECT connect, save_msg, save_contacts, "
+ "commands, internal_host FROM defaults LIMIT 1";
+ struct defaults_ *defaults = &config.defaults;
+ PGresult *res;
+ string sql;
+ char *connect;
+ char *savemsg;
+ char *savecontact;
+ char *commands;
+ char *listenhost;
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt);
+ if (str_ready(&sql, sql.len + 1) == 0) die_nomem();
+ sql.a = fmt_printf(sql.s, fmt);
+
+ res = db_query(&pgsql, &sql);
+ str_free(&sql);
+ if (res == NULL)
+ return(RFAIL);
+
+ if (db_count(res) == 0) {
+ res = db_free(res);
+ return(RFAIL);
+ }
+
+ connect = db_row(res, 0, 0);
+ savemsg = db_row(res, 0, 1);
+ savecontact = db_row(res, 0, 2);
+ commands = db_row(res, 0, 3);
+ listenhost = db_row(res, 0, 4);
+
+ /* defaults */
+ defaults->commands = 0;
+ defaults->connect = NO;
+ defaults->save_msg = NO;
+ defaults->save_contacts = NO;
+
+ /* connect */
+ if (connect != NULL && strcasecmp(connect, "YES") == 0)
+ defaults->connect = YES;
+
+ /* save_msg */
+ if (savemsg != NULL && strcasecmp(savemsg, "YES") == 0)
+ defaults->save_msg = YES;
+
+ /* save_contacts */
+ if (savecontact != NULL && strcasecmp(savecontact, "YES") == 0)
+ defaults->save_contacts = YES;
+
+ /* commands */
+ if (commands) {
+ defaults->commands = (int)strtol(commands, (char **)0, 10);
+ }
+
+ /* listen_host */
+ if (listenhost) {
+ if (strlen(listenhost) > 0 &&
+ str_copys(&defaults->proxy_ip, (unsigned char *)listenhost) == 0)
+ die_nomem();
+ }
+
+ res = db_free(res);
+ return(ROK);
+}
+
+int
+read_acl(char *fmt, string *email) {
+ PGresult *res;
+ string sql;
+ char *row;
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, email->s);
+ if (str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, email->s);
+
+ res = db_query(&pgsql, &sql);
+ str_free(&sql);
+ if (res == NULL)
+ return(RFAIL);
+
+ row = db_row(res, 0, 0);
+ ...
[truncated message content] |
|
From: <lo...@us...> - 2009-07-28 19:59:59
|
Revision: 124
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=124&view=rev
Author: loos-br
Date: 2009-07-28 19:59:49 +0000 (Tue, 28 Jul 2009)
Log Message:
-----------
algumas alteracoes nos paths do arquivos de configuracoes e do mysql/pgsql serao necesarias...
Modified Paths:
--------------
branches/dbmod/Makefile
branches/dbmod/config.h
branches/dbmod/db_modules/mysql/Makefile
branches/dbmod/db_modules/mysql/mysql.h
branches/dbmod/msn-proxy.conf
Modified: branches/dbmod/Makefile
===================================================================
--- branches/dbmod/Makefile 2009-07-28 13:39:12 UTC (rev 123)
+++ branches/dbmod/Makefile 2009-07-28 19:59:49 UTC (rev 124)
@@ -1,44 +1,22 @@
RM=/bin/rm
INSTALL=/usr/bin/install
-SYSCONFDIR=$(DESTDIR)/usr/local/etc/msn-proxy
+SYSCONFDIR=$(DESTDIR)/usr/local/etc
BINDIR=$(DESTDIR)/usr/local/bin
-# FreeBSD
-MYSQLINC=/usr/local/include
-MYSQLLIB=/usr/local/lib/mysql
+CCFLAGS=-g -Wall -O2 -pipe -I/usr/local/include -fno-builtin-log
-# Linux (most)
-#MYSQLINC=/usr/lib/mysql
-#MYSQLLIB=/usr/local/mysql/lib/mysql
+LDFLAGS=-L/usr/local/lib -levent
-CCFLAGS=-g -Wall -O2 -pipe -I/usr/local/include -I$(MYSQLINC) -fno-builtin-log
-
-LDFLAGS=-L/usr/local/lib -levent -L$(MYSQLLIB) -lmysqlclient
-
OBJS=check-cmd.o client.o command.o config.o contacts.o ctl.o db.o fmt.o io.o \
msg.o msn-proxy.o ns.o net-io.o p2p.o protocol.o sb.o sig.o server.o \
string.o syslog.o user.o xml.o
-#OBJS=check-cmd.o client.o command.o config.o contacts.o ctl.o fmt.o io.o msg.o \
-# mysql.o msn-proxy.o ns.o net-io.o p2p.o protocol.o sb.o sig.o sql.o \
-# server.o string.o syslog.o user.o xml.o
-
-
INCLUDES=array_cmd.h check-cmd.h client.h command.h config.h contacts.h \
contacts-data.h ctl.h db.h fmt.h io.h msg.h msn-proxy.h msnp8.h \
msnp12.h msnp18.h ns.h ns-data.h net-io.h protocol.h return.h sb.h \
sig.h server.h string.h syslog.h sb-data.h user.h xml.h xml-data.h
-#INCLUDES=array_cmd.h check-cmd.h client.h command.h config.h contacts.h \
-# contacts-data.h ctl.h fmt.h io.h msg.h msn-proxy.h mysql.h msnp8.h \
-# msnp12.h msnp18.h ns.h ns-data.h net-io.h protocol.h return.h sb.h \
-# sig.h sql.h server.h string.h syslog.h sb-data.h user.h xml.h \
-# xml-data.h
-
-TABLES=mysql/tables/contacts mysql/tables/contact_groups mysql/tables/sb \
- mysql/tables/log mysql/tables/defaults mysql/tables/users
-
all: msn-proxy
msn-proxy: $(OBJS) $(INCLUDES)
@@ -51,9 +29,7 @@
$(RM) -f *.o *.core msn-proxy
install: all
- $(INSTALL) -d $(SYSCONFDIR)/mysql/tables
- $(INSTALL) -b -m 600 mysql/conf $(SYSCONFDIR)/mysql
- $(INSTALL) -m 644 $(TABLES) $(SYSCONFDIR)/mysql/tables
+ $(INSTALL) -d $(SYSCONFDIR)
$(INSTALL) -b -m 644 msn-proxy.conf $(SYSCONFDIR)
$(INSTALL) -d $(BINDIR)
$(INSTALL) -s msn-proxy $(BINDIR)
Modified: branches/dbmod/config.h
===================================================================
--- branches/dbmod/config.h 2009-07-28 13:39:12 UTC (rev 123)
+++ branches/dbmod/config.h 2009-07-28 19:59:49 UTC (rev 124)
@@ -37,7 +37,7 @@
#endif
#ifndef DEFAULT_CONFIG_FILE
-#define DEFAULT_CONFIG_FILE "/usr/local/etc/msn-proxy/msn-proxy.conf"
+#define DEFAULT_CONFIG_FILE "/usr/local/etc/msn-proxy.conf"
#endif
struct confkey_ {
Modified: branches/dbmod/db_modules/mysql/Makefile
===================================================================
--- branches/dbmod/db_modules/mysql/Makefile 2009-07-28 13:39:12 UTC (rev 123)
+++ branches/dbmod/db_modules/mysql/Makefile 2009-07-28 19:59:49 UTC (rev 124)
@@ -1,12 +1,19 @@
+INSTALL=/usr/bin/install
+SYSCONFDIR=$(DESTDIR)/usr/local/msn-proxy
+
+# you need to point this to the libevent header path
+LIBEVENTINC=/usr/local/include
+
# FreeBSD
-MYSQLINC=/usr/local/include
+MYSQLINC=/usr/local/include/mysql
MYSQLLIB=/usr/local/lib/mysql
# Linux (most)
#MYSQLINC=/usr/lib/mysql
#MYSQLLIB=/usr/local/mysql/lib/mysql
-CCFLAGS=-g -Wall -O2 -pipe -fno-builtin-log -I$(MYSQLINC)
+CCFLAGS=-g -Wall -O2 -pipe -fno-builtin-log -I$(LIBEVENTINC) -I$(MYSQLINC)
+LDFLAGS=-L$(MYSQLLIB) -lmysqlclient
MODULE=mysql.so
@@ -14,12 +21,13 @@
INCLUDES=mysql.h sql.h
+TABLES=tables/contacts tables/contact_groups tables/sb tables/log tables/defaults tables/users
all: $(MODULE)
$(MODULE): $(OBJS) $(INCLUDES)
- cc -shared -o $(MODULE) $(OBJS)
+ cc -shared -o $(MODULE) $(OBJS) $(LDFLAGS)
.c.o: $(INCLUDES)
cc $(CCFLAGS) -c $<
@@ -28,6 +36,8 @@
rm -f *.o $(MODULE)
install: all
- install -d /usr/local/msn-proxy
- install -b -m 755 $(MODULE) /usr/local/msn-proxy/$(MODULE)
+ $(INSTALL) -d $(SYSCONFDIR)/mysql/tables
+ $(INSTALL) -b -m 755 $(MODULE) $(SYSCONFDIR)/mysql/$(MODULE)
+ $(INSTALL) -b -m 600 conf $(SYSCONFDIR)/mysql
+ $(INSTALL) -m 644 $(TABLES) $(SYSCONFDIR)/mysql/tables
Modified: branches/dbmod/db_modules/mysql/mysql.h
===================================================================
--- branches/dbmod/db_modules/mysql/mysql.h 2009-07-28 13:39:12 UTC (rev 123)
+++ branches/dbmod/db_modules/mysql/mysql.h 2009-07-28 19:59:49 UTC (rev 124)
@@ -22,7 +22,7 @@
#define MYSQL_H
#ifndef MYSQLCONFDIR
-#define MYSQLCONFDIR "/usr/local/etc/msn-proxy/mysql"
+#define MYSQLCONFDIR "/usr/local/msn-proxy/mysql"
#endif
#ifndef MYSQLCONF
#define MYSQLCONF "conf"
@@ -37,18 +37,18 @@
#define DEFAULT_MYSQL_PORT 3306
#endif
#ifndef DEFAULT_MYSQL_USER
-#define DEFAULT_MYSQL_USER "maildir-index"
+#define DEFAULT_MYSQL_USER "msn-proxy"
#endif
#ifndef DEFAULT_MYSQL_PASS
#define DEFAULT_MYSQL_PASS "secret"
#endif
#ifndef DEFAULT_MYSQL_DB
-#define DEFAULT_MYSQL_DB "maildir-index"
+#define DEFAULT_MYSQL_DB "msn-proxy"
#endif
#include "../../tree.h"
#include "../../string.h"
-#include <mysql/mysql.h>
+#include <mysql.h>
struct table__ {
RB_ENTRY(table__) table_;
Modified: branches/dbmod/msn-proxy.conf
===================================================================
--- branches/dbmod/msn-proxy.conf 2009-07-28 13:39:12 UTC (rev 123)
+++ branches/dbmod/msn-proxy.conf 2009-07-28 19:59:49 UTC (rev 124)
@@ -37,8 +37,6 @@
# database module
#
# this is the path of the database module
-# db_mod=/usr/local/msn-proxy/mysql.so
-# db_mod=/usr/local/msn-proxy/pgsql.so
-db_mod=/usr/local/msn-proxy/mysql.so
-db_mod=/usr/local/msn-proxy/pgsql.so
-
+# db_mod=/usr/local/msn-proxy/mysql/mysql.so
+# db_mod=/usr/local/msn-proxy/pgsql/pgsql.so
+db_mod=/usr/local/msn-proxy/mysql/mysql.so
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lo...@us...> - 2009-07-28 13:39:19
|
Revision: 123
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=123&view=rev
Author: loos-br
Date: 2009-07-28 13:39:12 +0000 (Tue, 28 Jul 2009)
Log Message:
-----------
adicionando um novo branch para os testes da versao com modulos de banco de dados.
no momento disponivel apenas a versao mysql (a verso postgres esta sendo trabalhada)
ainda ha bastante trabalho por vir... fiquem atentos.
Modified Paths:
--------------
branches/dbmod/Makefile
branches/dbmod/check-cmd.c
branches/dbmod/command.c
branches/dbmod/config.c
branches/dbmod/config.h
branches/dbmod/contacts.c
branches/dbmod/ctl.c
branches/dbmod/ctl.h
branches/dbmod/io.c
branches/dbmod/msg.c
branches/dbmod/msn-proxy.c
branches/dbmod/msn-proxy.conf
branches/dbmod/msn-proxy.h
branches/dbmod/net-io.c
branches/dbmod/ns.c
branches/dbmod/ns.h
branches/dbmod/protocol.c
branches/dbmod/sb.c
branches/dbmod/server.c
branches/dbmod/syslog.c
branches/dbmod/syslog.h
branches/dbmod/user.c
Added Paths:
-----------
branches/dbmod/
branches/dbmod/db.c
branches/dbmod/db.h
branches/dbmod/db_modules/
branches/dbmod/db_modules/mysql/
branches/dbmod/db_modules/mysql/Makefile
branches/dbmod/db_modules/mysql/conf
branches/dbmod/db_modules/mysql/mysql.c
branches/dbmod/db_modules/mysql/mysql.h
branches/dbmod/db_modules/mysql/sql.c
branches/dbmod/db_modules/mysql/sql.h
branches/dbmod/db_modules/mysql/tables/
branches/dbmod/db_modules/mysql/tables/contact_groups
branches/dbmod/db_modules/mysql/tables/contacts
branches/dbmod/db_modules/mysql/tables/defaults
branches/dbmod/db_modules/mysql/tables/log
branches/dbmod/db_modules/mysql/tables/sb
branches/dbmod/db_modules/mysql/tables/users
branches/dbmod/db_modules/pgsql/
branches/dbmod/db_modules/pgsql/Makefile
branches/dbmod/db_modules/pgsql/pgsql.c
branches/dbmod/db_modules/pgsql/pgsql.h
Removed Paths:
-------------
branches/dbmod/mysql/
branches/dbmod/mysql.c
branches/dbmod/mysql.h
branches/dbmod/sql.c
branches/dbmod/sql.h
Modified: branches/dbmod/Makefile
===================================================================
--- trunk/Makefile 2009-06-17 19:26:25 UTC (rev 122)
+++ branches/dbmod/Makefile 2009-07-28 13:39:12 UTC (rev 123)
@@ -16,22 +16,33 @@
LDFLAGS=-L/usr/local/lib -levent -L$(MYSQLLIB) -lmysqlclient
-OBJS=msn-proxy.o server.o sb.o command.o config.o net-io.o client.o syslog.o \
- ns.o mysql.o sql.o protocol.o check-cmd.o contacts.o msg.o p2p.o \
- user.o string.o io.o sig.o fmt.o xml.o ctl.o
+OBJS=check-cmd.o client.o command.o config.o contacts.o ctl.o db.o fmt.o io.o \
+ msg.o msn-proxy.o ns.o net-io.o p2p.o protocol.o sb.o sig.o server.o \
+ string.o syslog.o user.o xml.o
-INCLUDES=msn-proxy.h server.h sb.h command.h config.h net-io.h client.h \
- syslog.h ns.h mysql.h sql.h protocol.h check-cmd.h contacts.h msg.h \
- user.h array_cmd.h string.h io.h return.h sig.h fmt.h xml.h msnp8.h \
- msnp12.h msnp18.h contacts-data.h ns-data.h sb-data.h ctl.h xml-data.h
+#OBJS=check-cmd.o client.o command.o config.o contacts.o ctl.o fmt.o io.o msg.o \
+# mysql.o msn-proxy.o ns.o net-io.o p2p.o protocol.o sb.o sig.o sql.o \
+# server.o string.o syslog.o user.o xml.o
+
+INCLUDES=array_cmd.h check-cmd.h client.h command.h config.h contacts.h \
+ contacts-data.h ctl.h db.h fmt.h io.h msg.h msn-proxy.h msnp8.h \
+ msnp12.h msnp18.h ns.h ns-data.h net-io.h protocol.h return.h sb.h \
+ sig.h server.h string.h syslog.h sb-data.h user.h xml.h xml-data.h
+
+#INCLUDES=array_cmd.h check-cmd.h client.h command.h config.h contacts.h \
+# contacts-data.h ctl.h fmt.h io.h msg.h msn-proxy.h mysql.h msnp8.h \
+# msnp12.h msnp18.h ns.h ns-data.h net-io.h protocol.h return.h sb.h \
+# sig.h sql.h server.h string.h syslog.h sb-data.h user.h xml.h \
+# xml-data.h
+
TABLES=mysql/tables/contacts mysql/tables/contact_groups mysql/tables/sb \
mysql/tables/log mysql/tables/defaults mysql/tables/users
all: msn-proxy
msn-proxy: $(OBJS) $(INCLUDES)
- $(CC) -o msn-proxy $(OBJS) $(LDFLAGS)
+ $(CC) -rdynamic -o msn-proxy $(OBJS) $(LDFLAGS)
.c.o: $(INCLUDES)
$(CC) $(CCFLAGS) -c $<
Modified: branches/dbmod/check-cmd.c
===================================================================
--- trunk/check-cmd.c 2009-06-17 19:26:25 UTC (rev 122)
+++ branches/dbmod/check-cmd.c 2009-07-28 13:39:12 UTC (rev 123)
@@ -61,7 +61,6 @@
int
check_cmd(struct user_ *user, command *cmd, int type) {
unsigned long erro = 0;
- log_ *log = &config.log;
CMDS_ *cmds_ = (CMDS_ *)0;
CMD *cmds = (CMD *)0;
char *label = "";
@@ -125,7 +124,6 @@
unsigned long erro = 0;
SBCMDS_ *cmds_ = (SBCMDS_ *)0;
SBCMD *cmds = (SBCMD *)0;
- log_ *log = &config.log;
char *label = "";
char *ep;
Modified: branches/dbmod/command.c
===================================================================
--- trunk/command.c 2009-06-17 19:26:25 UTC (rev 122)
+++ branches/dbmod/command.c 2009-07-28 13:39:12 UTC (rev 123)
@@ -142,7 +142,6 @@
*/
int
command_fill_buffer(int fd, string *buf) {
- log_ *log = &config.log;
/* empty buffer */
if (buf->len == 0) {
@@ -315,7 +314,6 @@
int
read_command(commands *cmds, int fd, void (*sched_write)(), void *ev_write) {
- log_ *log = &config.log;
for (;;) {
@@ -382,7 +380,6 @@
void
print_command(command *cmd) {
- log_ *log = &config.log;
string **arg;
log->debug("%s ", &cmd->cmd);
@@ -399,7 +396,6 @@
void
print_client_command(string *email, command *cmd) {
- log_ *log = &config.log;
if (email)
log->debug("[%s] from client: ", email);
@@ -410,7 +406,6 @@
void
print_server_command(string *email, command *cmd) {
- log_ *log = &config.log;
if (email)
log->debug("[%s] from server: ", email);
@@ -445,7 +440,6 @@
int
send_command(int tofd, command *cmd, string *email, const char *to) {
- log_ *log = &config.log;
string **arg = cmd->args;
switch (cmd->fase) {
Modified: branches/dbmod/config.c
===================================================================
--- trunk/config.c 2009-06-17 19:26:25 UTC (rev 122)
+++ branches/dbmod/config.c 2009-07-28 13:39:12 UTC (rev 123)
@@ -16,6 +16,7 @@
static const char rcsid[] = "$Id$";
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -25,85 +26,78 @@
#include "return.h"
#include "msn-proxy.h"
-#ifndef MAX_BUF
-#define MAX_BUF 1024
-#endif
-
#define ISSPACE(c) ((c) == 0x20 || (c) == 0x09)
#define ISNOTEOL(c) ((c) != 0x0a && (c) != 0x0d)
#define ISCOMMENT(c) ((c) == 0x23)
#define ISNOTEQUAL(c) ((c) != 0x3d)
-typedef struct {
- const char *key;
- int (*func)();
-} __cmd;
+/* configuration parameters */
+struct confkey_ confKeys[] = {
-const __cmd _cmd[] = {
- { "default_ns_host", set_string },
- { "default_ns_port", set_string },
- { "listen_host", set_string },
- { "listen_port", set_string },
- { "backlog", set_int },
- { "port_min", set_int },
- { "port_max", set_int },
- { "max_clients", set_int },
- { "max_ctl_clients", set_int },
- { "timeout_listen", set_timeout },
- { "timeout_ctl_read", set_timeout },
- { "timeout_client_read", set_timeout },
- { "timeout_client_write", set_timeout },
- { "timeout_server_read", set_timeout },
- { "timeout_server_write", set_timeout },
- { (char *)0, config_no_op }
+ { "default_ns_host", set_string, &config.default_ns_host, "messenger.hotmail.com" },
+ { "default_ns_port", set_string, &config.default_ns_port, "1863" },
+ { "listen_host", set_string, &config.listen_host, "0.0.0.0" },
+ { "listen_port", set_string, &config.listen_port, "1863" },
+ { "db_mod", set_string, &config.db_mod, "/usr/local/msn-proxy/db_modules/xml.so" },
+ { "backlog", set_int, &config.backlog, "100" },
+ { "port_min", set_int, &config.port_min, "25000" },
+ { "port_max", set_int, &config.port_max, "30000" },
+ { "max_clients", set_int, &config.max_clients, "500" },
+ { "max_ctl_clients", set_int, &config.max_ctl_clients, "10" },
+ { "timeout_listen", set_timeout, &config.timeout_listen, "180" },
+ { "timeout_ctl_read", set_timeout, &config.timeout_ctl_read, "10" },
+ { "timeout_client_read", set_timeout, &config.timeout_client_read, "600" },
+ { "timeout_client_write", set_timeout, &config.timeout_client_write, "60" },
+ { "timeout_server_read", set_timeout, &config.timeout_server_read, "600" },
+ { "timeout_server_write", set_timeout, &config.timeout_server_write, "60" },
+
+ { NULL, NULL, NULL, NULL } /* Last option should always be null */
};
-int config_default(config_ *config) {
+void
+config_init(struct config_ *config) {
- memset(config, 0, sizeof(*config));
+ /*
+ * zero config structure data
+ */
+ memset(config, 0, sizeof(struct config_));
- /* default config file path */
- if (str_copys(&config->file, (unsigned char *)DEFAULT_CONFIG_PATH) == 0 ||
- str_cats(&config->file, (unsigned char *)DEFAULT_CONFIG_FILE) == 0) {
+ /* set the default config file path */
+ if (strlen(DEFAULT_CONFIG_FILE) > 0 &&
+ str_copys(&config->file, (unsigned char *)DEFAULT_CONFIG_FILE) == 0)
+ exit(51);
- die_nomem();
- }
+ /* setup the configuration parameters */
+ config->confkey = confKeys;
- /* default M$ notification server */
- if (str_copys(&config->default_ns_host, (unsigned char *)DEFAULT_NS_HOST) == 0 ||
- str_copys(&config->default_ns_port, (unsigned char *)DEFAULT_NS_PORT) == 0 ||
- str_copys(&config->listen_host, (unsigned char *)LISTEN_HOST) == 0 ||
- str_copys(&config->listen_port, (unsigned char *)LISTEN_PORT) == 0) {
+ /* load the default values for the config parameters */
+ config_load_defaults(config);
+}
- die_nomem();
- }
+void
+defaults_cleanup(struct defaults_ *defaults) {
+ str_free(&defaults->proxy_ip);
+}
- /* defaults */
- config->backlog = 10;
- config->port_min = 25000;
- config->port_max = 30000;
- config->max_clients = 10;
- config->max_ctl_clients = 10;
+void
+config_cleanup(struct config_ *config) {
+ str_free(&config->file);
+ //str_free(&config->pidFilePath);
+ //str_free(&config->log_debug);
- /* timeouts */
- config->timeout_listen.tv_sec = 180;
- config->timeout_ctl_read.tv_sec = 5;
- config->timeout_client_read.tv_sec = 600;
- config->timeout_client_write.tv_sec = 60;
- config->timeout_server_read.tv_sec = 600;
- config->timeout_server_write.tv_sec = 60;
-
- return(0);
+ /* free defaults */
+ config_cleanup_defaults(config);
}
-int parse_config(config_ *config) {
- int i;
+int
+parse_config(struct config_ *config) {
+ struct confkey_ *confkey;
string buf = {0};
string tmp = {0};
string key = {0};
string val = {0};
FILE *fp;
- log_ *log = &config->log;
+ int i;
/* open config file */
log->info("info: reading config file [%s]\n", &config->file);
@@ -140,58 +134,56 @@
}
/* get key */
+ str_zero(&key);
key.s = tmp.s;
- while (tmp.len > 0 && ISNOTEQUAL(*tmp.s)) {
+ while ((tmp.len > 0) && (ISNOTEQUAL(*tmp.s) && !ISSPACE(*tmp.s))) {
++tmp.s; --tmp.len;
}
- if ((key.len = tmp.s - key.s) < 0) {
+ key.len = tmp.s - key.s;
+ if (key.len < 0)
key.len = 0;
- }
- /* skip equal */
+ /* make sure to add the final \0 to key */
if (tmp.len > 0) {
*tmp.s++ = 0;
--tmp.len;
}
+ /* skip equal */
+ while ((tmp.len > 0) && (ISSPACE(*tmp.s) || *tmp.s == '=')) {
+ ++tmp.s; --tmp.len;
+ }
+
/* get value */
+ str_zero(&val);
val.s = tmp.s;
- while (tmp.len > 0 && ISNOTEOL(*tmp.s)) {
+ while (tmp.len > 0 && ISNOTEOL(*tmp.s) && !ISCOMMENT(*tmp.s) &&
+ !ISSPACE(*tmp.s)) {
++tmp.s; --tmp.len;
}
- if ((val.len = tmp.s - val.s) < 0) {
+ val.len = tmp.s - val.s;
+ if (val.len < 0)
val.len = 0;
- }
if (tmp.len > 0) {
*tmp.s++ = 0;
--tmp.len;
}
- i = 0;
- while (key.len > 0) {
+ if (key.len > 0) {
+ for (i = 0, confkey = &config->confkey[i];
+ config->confkey[i].key != NULL;
+ confkey = &config->confkey[++i]) {
- /* invalid command */
- if (_cmd[i].key == (char *)0) {
- log->debug("debug: invalid config parameter: [%s]\n", &key);
- str_free(&buf);
- fclose(fp);
- return(RFAIL);
- }
+ if (strcasecmp(confkey->key, (char *)key.s) == 0) {
- if (strcasecmp(_cmd[i].key, (char *)key.s) == 0) {
-
- if (_cmd[i].func(config, &key, &val) == -1) {
- str_free(&buf);
- fclose(fp);
- return(RFAIL);
+ if (val.len > 0)
+ confkey->func(val.s, confkey->conf);
+ break;
}
- break;
}
-
- ++i;
}
}
@@ -201,104 +193,74 @@
return(ROK);
}
-int config_no_op(config_ *config, string *key, string *val) {
- return(0);
+void
+set_string(const unsigned char *val, string *conf) {
+ if (!val || strlen((char *)val) == 0 || !conf) return;
+ if (str_copys(conf, val) == 0) exit(51);
}
-int set_string(config_ *config, string *key, string *val) {
+void
+set_int(const unsigned char *val, int *conf) {
+ if (!val || strlen((char *)val) == 0 || !conf) return;
+ *conf = (int)strtol((char *)val, (char **)0, 10);
+}
- if (!val || !val->s)
- return(-1);
+void
+set_size(const unsigned char *val, int *conf) {
+ char *ep;
- if (strcasecmp((char *)key->s, "default_ns_host") == 0) {
- if (str_copy(&config->default_ns_host, val->s, val->len) == 0)
- die_nomem();
- } else if (strcasecmp((char *)key->s, "default_ns_port") == 0) {
- if (str_copy(&config->default_ns_port, val->s, val->len) == 0)
- die_nomem();
- } else if (strcasecmp((char *)key->s, "listen_host") == 0) {
- if (str_copy(&config->listen_host, val->s, val->len) == 0)
- die_nomem();
- } else if (strcasecmp((char *)key->s, "listen_port") == 0) {
- if (str_copy(&config->listen_port, val->s, val->len) == 0)
- die_nomem();
+ if (!val || strlen((char *)val) == 0 || !conf) return;
+ *conf = (int)strtol((char *)val, &ep, 10);
+ switch (tolower(*ep)) {
+ case 'm':
+ *conf *= 1024;
+ /* fallthrough */
+ case 'k':
+ *conf *= 1024;
}
-
- return(0);
}
-int set_int(config_ *config, string *key, string *val) {
- unsigned int rtrn = 0;
-
- if (!val || !val->s)
- return(-1);
-
- rtrn = (unsigned int)strtol((char *)val->s, (char **)0, 10);
-
- if (strcasecmp((char *)key->s, "max_clients") == 0)
- config->max_clients = rtrn;
- else if (strcasecmp((char *)key->s, "max_ctl_clients") == 0)
- config->max_ctl_clients = rtrn;
- else if (strcasecmp((char *)key->s, "port_min") == 0)
- config->port_min = rtrn;
- else if (strcasecmp((char *)key->s, "port_max") == 0)
- config->port_max = rtrn;
- else if (strcasecmp((char *)key->s, "backlog") == 0)
- config->backlog = rtrn;
-
- return(0);
+void
+set_timeout(const unsigned char *val, struct timeval *conf) {
+ if (!val || strlen((char *)val) == 0 || !conf) return;
+ conf->tv_sec = (int)strtol((char *)val, (char **)0, 10);
}
-int set_timeout(config_ *config, string *key, string *val) {
- unsigned int secs;
+void
+config_load_defaults(struct config_ *config) {
+ struct confkey_ *confkey;
+ int i;
- if (!val || !val->s)
- return(-1);
+ for (i = 0, confkey = &config->confkey[i];
+ config->confkey[i].key != NULL;
+ confkey = &config->confkey[++i]) {
- secs = (unsigned int)strtol((char *)val->s, (char **)0, 10);
-
- if (strcasecmp((char *)key->s, "timeout_listen") == 0)
- config->timeout_listen.tv_sec = secs;
- else if (strcasecmp((char *)key->s, "timeout_ctl_read") == 0)
- config->timeout_ctl_read.tv_sec = secs;
- else if (strcasecmp((char *)key->s, "timeout_client_read") == 0)
- config->timeout_client_read.tv_sec = secs;
- else if (strcasecmp((char *)key->s, "timeout_client_write") == 0)
- config->timeout_client_write.tv_sec = secs;
- else if (strcasecmp((char *)key->s, "timeout_server_read") == 0)
- config->timeout_server_read.tv_sec = secs;
- else if (strcasecmp((char *)key->s, "timeout_server_write") == 0)
- config->timeout_server_write.tv_sec = secs;
-
- return(0);
+ confkey->func((unsigned char *)confkey->init, confkey->conf);
+ }
}
-int config_set_path(string *file, char *path) {
- /* Deallocate previous memory */
- str_free(file);
- str_zero(file);
- if (str_cats(file, (unsigned char *)path) == 0)
- die_nomem();
+void
+config_cleanup_defaults(struct config_ *config) {
+ struct confkey_ *confkey;
+ int i;
- if ( file->len > 0 && *(file->s + file->len - 1) != '/' ) {
- if (str_cats(file, (unsigned char *)"/") == 0)
- die_nomem();
- }
+ for (i = 0, confkey = &config->confkey[i];
+ confkey != NULL && confkey->key != NULL;
+ confkey = &config->confkey[++i]) {
- if (str_cats(file, (unsigned char *)DEFAULT_CONFIG_FILE) == 0)
- die_nomem();
-
- return(0);
+ if (confkey->func == set_string && confkey->conf != NULL)
+ str_free(confkey->conf);
+ }
}
-void print_config(config_ *config) {
- log_ *log = &config->log;
- defaults_ *defaults = &config->defaults;
+void
+print_config(struct config_ *config) {
log->debug("msn-proxy release : %S [%S]\n", "msn-proxy-"
MSNPROXY_VERSION,
MSNPROXY_RELEASE);
log->debug("config file : %s\n", &config->file);
+ log->debug("db module : %s\n", &config->db_mod);
log->debug("default ns host : %s\n", &config->default_ns_host);
log->debug("default ns port : %s\n", &config->default_ns_port);
log->debug("listen host : %s\n", &config->listen_host);
@@ -315,6 +277,11 @@
log->debug("server write timeout : %d\n", config->timeout_server_write.tv_sec);
log->debug("client connect timeout: %d\n", config->timeout_listen.tv_sec);
log->debug("\n");
+}
+
+void
+print_defaults(struct defaults_ *defaults) {
+
log->debug("ACLs\n");
log->debug("connect : %S\n",
(defaults->connect == YES) ? "ALLOW" : "DENY");
Modified: branches/dbmod/config.h
===================================================================
--- trunk/config.h 2009-06-17 19:26:25 UTC (rev 122)
+++ branches/dbmod/config.h 2009-07-28 13:39:12 UTC (rev 123)
@@ -26,7 +26,10 @@
#include "tree.h"
#include "string.h"
+#if 0
+
#include "mysql.h"
+#endif
#include "syslog.h"
#ifndef READONLY
@@ -34,67 +37,59 @@
#endif
#ifndef DEFAULT_CONFIG_FILE
-#define DEFAULT_CONFIG_FILE "msn-proxy.conf"
+#define DEFAULT_CONFIG_FILE "/usr/local/etc/msn-proxy/msn-proxy.conf"
#endif
-#ifndef DEFAULT_CONFIG_PATH
-#define DEFAULT_CONFIG_PATH "/usr/local/etc/msn-proxy/"
-#endif
+struct confkey_ {
+ const char *key; /* the configuration key/parameter */
+ void (*func)(); /* function to load the appropriate data */
+ void *conf; /* the data field to load the value */
+ const char *init; /* default value for the field */
+};
-#ifndef DEFAULT_NS_HOST
-#define DEFAULT_NS_HOST "messenger.hotmail.com"
-#endif
-
-#ifndef DEFAULT_NS_PORT
-#define DEFAULT_NS_PORT "1863"
-#endif
-
-#ifndef LISTEN_HOST
-#define LISTEN_HOST "0.0.0.0"
-#endif
-
-#ifndef LISTEN_PORT
-#define LISTEN_PORT "1863"
-#endif
-
-typedef struct defaults__ {
+struct defaults_ {
unsigned long commands;
- string internal_host;
+ string proxy_ip;
int save_contacts;
int save_msg;
int connect;
-} defaults_;
+};
-typedef struct config__ {
- log_ log; /* log options */
+struct config_ {
string file; /* path of config file */
+ string db_mod; /* library path of database module */
string default_ns_host; /* default ns server host */
string default_ns_port; /* default ns server port */
string listen_host; /* internal bind address */
string listen_port; /* default to 1863 */
- mysql_ mysql; /* mysql private data */
- defaults_ defaults; /* global configuration */
unsigned int backlog; /* default backlog for listen */
unsigned int port_min; /* begin of port range used on
internal connections */
unsigned int port_max; /* end of port range */
unsigned int max_clients; /* number of clients */
unsigned int max_ctl_clients; /* number of ctl clients */
+ struct log_ log; /* log functions */
struct timeval timeout_client_read; /* timeouts */
struct timeval timeout_client_write;
struct timeval timeout_server_read;
struct timeval timeout_server_write;
struct timeval timeout_ctl_read;
struct timeval timeout_listen;
-} config_;
+ struct confkey_ *confkey; /* config parameters */
+ struct defaults_ defaults; /* default settings */
+};
-int config_default(config_ *config);
-int parse_config(config_ *config);
-int config_no_op(config_ *config, string *key, string *val);
-int set_int(config_ *config, string *key, string *val);
-int set_string(config_ *config, string *key, string *val);
-int set_timeout(config_ *config, string *key, string *val);
-int config_set_path(string *file, char *path);
-void print_config(config_ *config);
+void config_init(struct config_ *config);
+void config_cleanup(struct config_ *config);
+int parse_config(struct config_ *config);
+void set_string(const unsigned char *val, string *conf);
+void set_int(const unsigned char *val, int *conf);
+void set_size(const unsigned char *val, int *conf);
+void set_timeout(const unsigned char *val, struct timeval *conf);
+void config_load_defaults(struct config_ *config);
+void defaults_cleanup(struct defaults_ *defaults);
+void config_cleanup_defaults(struct config_ *config);
+void print_config(struct config_ *config);
+void print_defaults(struct defaults_ *defaults);
#endif
Modified: branches/dbmod/contacts.c
===================================================================
--- trunk/contacts.c 2009-06-17 19:26:25 UTC (rev 122)
+++ branches/dbmod/contacts.c 2009-07-28 13:39:12 UTC (rev 123)
@@ -19,9 +19,9 @@
#include <errno.h>
#include <string.h>
+#include "db.h"
#include "io.h"
#include "fmt.h"
-#include "sql.h"
#include "xml.h"
#include "return.h"
#include "contacts.h"
@@ -302,7 +302,6 @@
struct contact_ c;
unsigned long tmp;
string buf;
- log_ *log = &config.log;
char *ep;
int i;
@@ -480,9 +479,9 @@
return(RFAIL);
/* save group on database */
- if (sql_save_contactgroup(email, &tmp, gid) != ROK) {
- str_free(&tmp);
- return(RFAIL);
+ if (db.sql_save_contactgroup(email, &tmp, gid) != ROK) {
+ str_free(&tmp);
+ return(RFAIL);
}
str_free(&tmp);
@@ -569,7 +568,7 @@
}
}
- if (sql_contact_save(user, save) == RFAIL)
+ if (db.sql_contact_save(user, save) == RFAIL)
return(RFAIL);
/* check for blocked contacts */
@@ -638,7 +637,7 @@
cmd->args_len--;
}
- if (sql_contact_save(user, save) == RFAIL)
+ if (db.sql_contact_save(user, save) == RFAIL)
return(RFAIL);
/* check for blocked contacts */
@@ -692,7 +691,7 @@
if (str_copys(&save->status, (unsigned char *)"OFF") == 0) die_nomem();
save->deny &= ~CONTACT_BLOCKED;
- (void)sql_contact_save(user, save);
+ (void)db.sql_contact_save(user, save);
if (contact->deny & CONTACT_DENY)
return(RETURN);
@@ -772,7 +771,7 @@
if (str_copys(o, (unsigned char *)"0") == 0) exit (51);
}
- if (sql_contact_save(user, save) == RFAIL)
+ if (db.sql_contact_save(user, save) == RFAIL)
return(ROK);
/* check for blocked contacts */
@@ -850,7 +849,7 @@
}
}
- if (sql_contact_save(user, save) == RFAIL)
+ if (db.sql_contact_save(user, save) == RFAIL)
return(ROK);
/* check for blocked contacts */
@@ -919,7 +918,7 @@
cmd->args_len--;
}
- if (sql_contact_save(user, save) == RFAIL)
+ if (db.sql_contact_save(user, save) == RFAIL)
return(ROK);
/* check for blocked contacts */
@@ -1105,7 +1104,6 @@
struct contact_ cfind;
struct user_ *user;
struct user_ *ufind;
- log_ *log = &config.log;
/* check for contact */
c = u = NULL;
@@ -1158,7 +1156,7 @@
return(RFAIL);
}
- if (sql_contact_load(user, save) == RFAIL) {
+ if (db.sql_contact_load(user, save) == RFAIL) {
log->debug("debug: loaduser: fail to load user from sql\n");
return(RFAIL);
}
@@ -1177,7 +1175,7 @@
return(RFAIL);
}
save->deny |= CONTACT_BLOCKED;
- if (sql_contact_save(user, save) == RFAIL)
+ if (db.sql_contact_save(user, save) == RFAIL)
return(RFAIL);
}
@@ -1190,7 +1188,7 @@
return(RFAIL);
}
save->deny &= ~CONTACT_BLOCKED;
- if (sql_contact_save(user, save) == RFAIL)
+ if (db.sql_contact_save(user, save) == RFAIL)
return(RFAIL);
}
Modified: branches/dbmod/ctl.c
===================================================================
--- trunk/ctl.c 2009-06-17 19:26:25 UTC (rev 122)
+++ branches/dbmod/ctl.c 2009-07-28 13:39:12 UTC (rev 123)
@@ -79,7 +79,6 @@
struct ctl_ *
ctl_alloc(int fd) {
struct ctl_ *ctl;
- log_ *log = &config.log;
/* alloc new ctl */
ctl = (struct ctl_ *)malloc(sizeof(struct ctl_));
@@ -106,7 +105,6 @@
unsigned char buf[MAX_BUF];
unsigned char *p;
struct ctl_ *ctl = ctl__;
- log_ *log = &config.log;
int len;
(void) evfd;
@@ -173,12 +171,11 @@
}
void
-ctl_client(const int ctlfd, short event, void *p) {
+ctl_client(const int ctlfd, short event, void *_config) {
+ struct config_ *config = (struct config_ *)_config;
struct sockaddr_un ctl_sun;
struct ctl_ *ctl;
socklen_t ctl_sun_len;
- config_ *config = p;
- log_ *log = &config->log;
int fd;
/* prepare client sockaddr */
Modified: branches/dbmod/ctl.h
===================================================================
--- trunk/ctl.h 2009-06-17 19:26:25 UTC (rev 122)
+++ branches/dbmod/ctl.h 2009-07-28 13:39:12 UTC (rev 123)
@@ -40,6 +40,6 @@
struct ctl_ *rbh_root; /* root of the tree */
};
-void ctl_client(int ctlfd, short event, void *config_);
+void ctl_client(int ctlfd, short event, void *_config);
#endif
Added: branches/dbmod/db.c
===================================================================
--- branches/dbmod/db.c (rev 0)
+++ branches/dbmod/db.c 2009-07-28 13:39:12 UTC (rev 123)
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2004-2009, Luiz Otavio O Souza <lo...@gm...>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+static const char rcsid[] = "$Id: modules.c 248 2009-01-19 15:36:41Z loos $";
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "db.h"
+#include "xml.h"
+#include "syslog.h"
+#include "msn-proxy.h"
+
+/* database module */
+struct mod_ db;
+unsigned int db_mod_count;
+
+/* functions to register */
+struct mod_cmds_ mod_cmds[] = {
+
+ { (void *)&db.modLoad, "modLoad" },
+ { (void *)&db.modUnload, "modUnload" },
+ { (void *)&db.sql_log_msg, "sql_log_msg" },
+ { (void *)&db.sql_log_join, "sql_log_join" },
+ { (void *)&db.sql_log_stop, "sql_log_stop" },
+ { (void *)&db.sql_log_start, "sql_log_start" },
+ { (void *)&db.sql_log_stop2, "sql_log_stop2" },
+ { (void *)&db.sql_remove_sb, "sql_remove_sb" },
+ { (void *)&db.sql_set_status, "sql_set_status" },
+ { (void *)&db.sql_contact_load, "sql_contact_load" },
+ { (void *)&db.sql_contact_save, "sql_contact_save" },
+ { (void *)&db.sql_read_warning, "sql_read_warning" },
+ { (void *)&db.sql_users_update, "sql_users_update" },
+ { (void *)&db.sql_read_defaults, "sql_read_defaults" },
+ { (void *)&db.sql_read_user_acl, "sql_read_user_acl" },
+ { (void *)&db.sql_password_error, "sql_password_error" },
+ { (void *)&db.sql_update_user_dn, "sql_update_user_dn" },
+ { (void *)&db.sql_version_denied, "sql_version_denied" },
+ { (void *)&db.sql_user_disconnect, "sql_user_disconnect" },
+ { (void *)&db.sql_contact_load_all, "sql_contact_load_all" },
+ { (void *)&db.sql_contact_save_all, "sql_contact_save_all" },
+ { (void *)&db.sql_connection_denied, "sql_connection_denied" },
+ { (void *)&db.sql_save_contactgroup, "sql_save_contactgroup" },
+ { (void *)&db.sql_insert_sb, "sql_insert_sb" },
+ { NULL, NULL }
+};
+
+void
+db_mod_init(void) {
+ db_mod_count = 0;
+ memset(&db, 0, sizeof(db));
+}
+
+void
+db_mod_free(void) {
+ str_free(&db.modName);
+ str_free(&db.modPath);
+ db_mod_count = 0;
+ memset(&db, 0, sizeof(db));
+}
+
+int
+db_mod_load(string *db_mod) {
+ struct mod_cmds_ *cmd;
+ int i;
+
+ if (db_mod->len == 0) {
+ log->debug("debug: no database module set\n");
+ return -1;
+ }
+
+/* XXX - stat file */
+
+ if (db_mod->len > 0 && str_copy(&db.modPath, db_mod->s, db_mod->len) == 0)
+ exit(51);
+
+ log->debug("loading db module.....: [%s]\n", &db.modPath);
+ db.data = dlopen((char *)db.modPath.s, RTLD_LAZY);
+ if (db.data == NULL) {
+ log->debug("debug: cannot open module: [%S]\n", dlerror());
+ return(-1);
+ }
+
+ for (i = 0, cmd = &mod_cmds[i];
+ cmd != NULL && cmd->mod_func != NULL && cmd->func_name != NULL;
+ cmd = &mod_cmds[++i]) {
+
+ *cmd->mod_func = dlsym(db.data, cmd->func_name);
+ if (*cmd->mod_func == NULL) {
+ log->debug("debug: invalid database module, skiping... [%s: %S]\n",
+ &db.modPath, dlerror());
+ return(-1);
+ }
+ }
+
+ /* inicializa o modulo */
+ if (db.modLoad(&db) == -1)
+ return(-1);
+
+ ++db_mod_count;
+
+ if (db_mod_count == 0)
+ log->debug("debug: no database module loaded.\n");
+
+ return(0);
+}
+
+int
+db_mod_unload(void) {
+
+ log->debug("unloading db module...: [%s]\n", &db.modPath);
+
+ /* permite ao modulo limpar suas dependencias */
+ if (db.modUnload != NULL)
+ db.modUnload();
+
+ /* fecha o modulo */
+ if (db.data != NULL)
+ dlclose(db.data);
+
+ /* libera a memoria */
+ db_mod_free();
+
+ return(0);
+}
+
Added: branches/dbmod/db.h
===================================================================
--- branches/dbmod/db.h (rev 0)
+++ branches/dbmod/db.h 2009-07-28 13:39:12 UTC (rev 123)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2004-2009, Luiz Otavio O Souza <lo...@gm...>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * $Id: modules.h,v 1.2 2009-01-03 15:21:47 luiz Exp $
+ */
+
+#ifndef DB_H
+#define DB_H
+
+#include "string.h"
+
+struct mod_ {
+ /* cmds or functions */
+ int (*sql_log_msg)();
+ int (*sql_log_join)();
+ int (*sql_log_stop)();
+ int (*sql_log_start)();
+ int (*sql_log_stop2)();
+ int (*sql_remove_sb)();
+ int (*sql_set_status)();
+ int (*sql_contact_load)();
+ int (*sql_contact_save)();
+ int (*sql_read_warning)();
+ int (*sql_users_update)();
+ int (*sql_read_defaults)();
+ int (*sql_read_user_acl)();
+ int (*sql_password_error)();
+ int (*sql_update_user_dn)();
+ int (*sql_version_denied)();
+ int (*sql_user_disconnect)();
+ int (*sql_contact_load_all)();
+ int (*sql_contact_save_all)();
+ int (*sql_connection_denied)();
+ int (*sql_save_contactgroup)();
+ __uint32_t (*sql_insert_sb)();
+
+ int (*modLoad)();
+ void (*modUnload)();
+ void *data;
+ string modName;
+ string modPath;
+};
+
+struct mod_cmds_ {
+ void **mod_func;
+ const char *func_name;
+};
+
+void db_mod_init(void);
+int db_mod_load(string *db_mod_path);
+int db_mod_unload(void);
+
+extern struct mod_ db;
+extern unsigned int db_mod_count;
+
+#endif
Added: branches/dbmod/db_modules/mysql/Makefile
===================================================================
--- branches/dbmod/db_modules/mysql/Makefile (rev 0)
+++ branches/dbmod/db_modules/mysql/Makefile 2009-07-28 13:39:12 UTC (rev 123)
@@ -0,0 +1,33 @@
+# FreeBSD
+MYSQLINC=/usr/local/include
+MYSQLLIB=/usr/local/lib/mysql
+
+# Linux (most)
+#MYSQLINC=/usr/lib/mysql
+#MYSQLLIB=/usr/local/mysql/lib/mysql
+
+CCFLAGS=-g -Wall -O2 -pipe -fno-builtin-log -I$(MYSQLINC)
+
+MODULE=mysql.so
+
+OBJS=mysql.o sql.o
+
+INCLUDES=mysql.h sql.h
+
+
+
+all: $(MODULE)
+
+$(MODULE): $(OBJS) $(INCLUDES)
+ cc -shared -o $(MODULE) $(OBJS)
+
+.c.o: $(INCLUDES)
+ cc $(CCFLAGS) -c $<
+
+clean:
+ rm -f *.o $(MODULE)
+
+install: all
+ install -d /usr/local/msn-proxy
+ install -b -m 755 $(MODULE) /usr/local/msn-proxy/$(MODULE)
+
Added: branches/dbmod/db_modules/mysql/conf
===================================================================
--- branches/dbmod/db_modules/mysql/conf (rev 0)
+++ branches/dbmod/db_modules/mysql/conf 2009-07-28 13:39:12 UTC (rev 123)
@@ -0,0 +1,2 @@
+# "host or socket|port (zero for socket)|user|pass|database name"
+/tmp/mysql.sock|0|msn-proxy|secret|msn-proxy
Added: branches/dbmod/db_modules/mysql/mysql.c
===================================================================
--- branches/dbmod/db_modules/mysql/mysql.c (rev 0)
+++ branches/dbmod/db_modules/mysql/mysql.c 2009-07-28 13:39:12 UTC (rev 123)
@@ -0,0 +1,612 @@
+/*
+ * Copyright (c) 2004-2009, Luiz Otavio O Souza <lo...@gm...>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+static const char rcsid[] = "$Id: mysql.c 117 2009-04-13 11:58:02Z leorogoski $";
+
+#define MODULE_NAME "mysql"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dirent.h>
+#include <unistd.h>
+
+#include "sql.h"
+#include "mysql.h"
+#include "../../db.h"
+#include "../../io.h"
+#include "../../fmt.h"
+#include "../../return.h"
+#include "../../msn-proxy.h"
+
+#define print_bar(a) (a[strlen(a) - 1] == '/') ? "" : "/"
+
+/* global - mysql private data */
+struct mysql_ mysql;
+
+int
+tablecmp(struct table__ *t1, struct table__ *t2) {
+ if (t1 == NULL ||
+ t2 == NULL ||
+ t1->name.len == 0 ||
+ t2->name.len == 0) {
+ return 1;
+ }
+ return (strcmp((char *)t1->name.s, (char *)t2->name.s));
+}
+
+RB_GENERATE(tables, table__, table_, tablecmp)
+
+MYSQL_ROW
+db_fetch_row(MYSQL_RES *res) {
+ return(mysql_fetch_row(res));
+}
+
+u_int64_t
+db_count(MYSQL_RES *res) {
+ if(res == NULL)
+ return 0;
+ return(mysql_num_rows(res));
+}
+
+u_int64_t
+db_affected_rows(MYSQL *mysql) {
+ if(mysql == NULL)
+ return 0;
+ return(mysql_affected_rows(mysql));
+}
+
+u_int64_t
+db_last_id(MYSQL *mysql) {
+ if(mysql == NULL)
+ return 0;
+ return(mysql_insert_id(mysql));
+}
+
+MYSQL_RES *
+db_free(MYSQL_RES *res) {
+ if(res == NULL)
+ return((MYSQL_RES *)NULL);
+
+ mysql_free_result(res);
+
+ return((MYSQL_RES *)NULL);
+}
+
+char *
+db_escape(struct mysql_ *mysql, char *from) {
+ char *rtrn;
+ size_t len;
+
+ if(from == NULL)
+ return(NULL);
+
+ len = strlen(from);
+
+ rtrn = (char *)malloc(sizeof(char) * len * 2 + 1);
+ if(rtrn == NULL)
+ return(NULL);
+
+ mysql_real_escape_string(&mysql->mysql, rtrn, from, len);
+
+ return(rtrn);
+}
+
+MYSQL_RES *
+db_query(struct mysql_ *mysql, string *query) {
+ MYSQL_RES *res;
+
+ if(query == NULL || query->s == NULL || *query->s == 0)
+ return((MYSQL_RES *)NULL);
+
+ mysql->info("SQL: (%s)\n", query);
+ if (mysql_real_query(&mysql->mysql, (char *)query->s, query->len) != 0) {
+ mysql->debug("SQL ERROR: (%s) MySQL: (%S)\n", query, db_error(mysql));
+ return((MYSQL_RES *)NULL);
+ }
+ res = mysql_store_result(&mysql->mysql);
+
+ return(res);
+}
+
+int
+db_query2(struct mysql_ *mysql, string *query) {
+ if (query == NULL || query->s == NULL || *query->s == 0)
+ return(RFAIL);
+
+ mysql->info("SQL: (%s)\n", query);
+ if (mysql_real_query(&mysql->mysql, (char *)query->s, query->len) != 0) {
+ mysql->debug("SQL ERROR: (%s) MySQL: (%S)\n", query, db_error(mysql));
+ return(RFAIL);
+ }
+
+ return(ROK);
+}
+
+int
+db_create_all(struct mysql_ *mysql) {
+ struct table__ *table;
+ string sql;
+
+ str_zero(&sql);
+ RB_FOREACH(table, tables, &mysql->table_head) {
+
+ if (table->exist == 1) continue;
+ if (table->sql.len == 0 || table->name.len == 0) continue;
+
+ sql.len = fmt_printf(NULL, (char *)table->sql.s, table->name.s);
+ if (str_ready(&sql, sql.len + 1) == 0) exit(51);
+ sql.len = fmt_printf(sql.s, (char *)table->sql.s, table->name.s);
+ if (db_query2(mysql, &sql) != ROK &&
+ mysql_errno(&mysql->mysql) != 0) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+ }
+
+ return(ROK);
+}
+
+int
+db_check(struct mysql_ *mysql) {
+ struct table__ find;
+ struct table__ *table;
+ MYSQL_RES *res;
+ MYSQL_ROW row;
+ string sql;
+
+ /* check tables */
+ str_zero(&sql);
+ sql.s = (unsigned char *)"SHOW TABLES";
+ sql.len = strlen((char *)sql.s);
+ if ((res = db_query(mysql, &sql)) == NULL)
+ return(RFAIL);
+
+ while ((row = db_fetch_row(res))) {
+ if (row[0] == NULL) continue;
+ str_zero(&find.name);
+ find.name.len = strlen(row[0]);
+ find.name.s = (unsigned char *)row[0];
+ table = RB_FIND(tables, &mysql->table_head, &find);
+ if (table != NULL)
+ table->exist = 1;
+ }
+ res = db_free(res);
+
+ /* create missing tables */
+ return(db_create_all(mysql));
+}
+
+char *
+db_error(struct mysql_ *mysql) {
+ char *p;
+
+ p = (char *)mysql_error(&mysql->mysql);
+ if (p && *p)
+ return(p);
+ else
+ return("");
+}
+
+int
+db_init(struct mysql_ *mysql, void (*debug)(const char *, ...),
+ void (*info)(const char *, ...)) {
+ my_bool reconnect = 1;
+
+ mysql->debug = debug;
+ mysql->info = info;
+
+ if (!mysql->host.s || !mysql->user.s || !mysql->pass.s || !mysql->db.s) {
+
+ if (!mysql->host.s) {
+ if (str_copys(&mysql->host, (unsigned char *)DEFAULT_MYSQL_HOST) == 0)
+ exit(51);
+ }
+
+ if (!mysql->user.s) {
+ if (str_copys(&mysql->user, (unsigned char *)DEFAULT_MYSQL_USER) == 0)
+ exit(51);
+ }
+
+ if (!mysql->pass.s) {
+ if (str_copys(&mysql->pass, (unsigned char *)DEFAULT_MYSQL_PASS) == 0)
+ exit(51);
+ }
+
+ if (!mysql->db.s) {
+ if (str_copys(&mysql->db, (unsigned char *)DEFAULT_MYSQL_DB) == 0)
+ exit(51);
+ }
+
+ if (mysql->port == 0)
+ mysql->port = DEFAULT_MYSQL_PORT;
+
+ mysql->debug("check your mysql config !!! using defaults !!!\n"
+ " host: (%s)\n"
+ " port: (%d)\n"
+ " user: (%s)\n"
+ " pass: (%S)\n"
+ " db : (%s)\n",
+ &mysql->host, mysql->port, &mysql->user,
+ mysql->pass.s ? "*********" : (char *)mysql->pass.s,
+ &mysql->db);
+ }
+
+ /* init && connect */
+ if (mysql_init(&mysql->mysql) == NULL) {
+ mysql->debug("SQL INIT: (%S)\n", db_error(mysql));
+ return(RFAIL);
+ }
+
+ if (!mysql_real_connect(&mysql->mysql,
+ (*mysql->host.s == '/') ? NULL : (char *)mysql->host.s,
+ (char *)mysql->user.s, (char *)mysql->pass.s,
+ (char *)mysql->db.s, mysql->port,
+ (*mysql->host.s == '/') ? (char *)mysql->host.s : NULL, 0)) {
+ mysql->debug("SQL INIT: (%S)\n", db_error(mysql));
+ return(RFAIL);
+ }
+
+ /* erase the database password from memory ?!?? Safety ? */
+ memset(mysql->pass.s, 0, mysql->pass.len);
+ mysql->connected = 1;
+
+ /* set auto-reconnect */
+ mysql_options(&mysql->mysql, MYSQL_OPT_RECONNECT, &reconnect);
+
+ /* check if db is ok */
+ return(db_check(mysql));
+}
+
+void
+db_close(struct mysql_ *mysql) {
+
+ if (mysql->connected)
+ mysql_close(&mysql->mysql);
+
+ /* Free memory */
+ mysql_server_end();
+ mysql->connected = 0;
+}
+
+int
+db_get_conf_key(char **key, char **buf) {
+ register char *p;
+
+ p = *buf;
+ *key = *buf;
+ while (*p && *p != '|' && *p != '\n' && *p != '\r') p++;
+ if (*p == 0)
+ return(ROK);
+
+ *p++ = 0;
+ *buf = p;
+
+ return(ROK);
+}
+
+void
+db_table_free(struct table__ *table) {
+ if (table == NULL) return;
+ str_free(&table->name);
+ str_free(&table->sql);
+ table->exist = 0;
+ table->size = 0;
+}
+
+int
+db_read_table_sql(const char *file, long filelen, size_t size,
+ struct table__ **table_) {
+ struct table__ *table;
+ size_t len;
+ int fd;
+
+ if (file == NULL || filelen == 0)
+ return(RFAIL);
+
+ *table_ = (struct table__ *)malloc(sizeof(struct table__));
+ if (*table_ == NULL) exit(51);
+ table = *table_;
+ str_zero(&table->name);
+ str_zero(&table->sql);
+ table->size = size;
+ table->exist = 0;
+
+ if (str_ready(&table->sql, table->size + 1) == 0) exit(51);
+ if (str_copy(&table->name, (unsigned char *)file, filelen) == 0) exit(51);
+
+ /* open file and read read */
+ fd = open((char *)table->name.s, O_RDONLY);
+ if (fd == -1) {
+ io_printf(1, "cannot open table file [%S] [%S]\n", table->name.s,
+ strerror(errno));
+ db_table_free(table);
+ free(*table_);
+ return(RFAIL);
+ }
+ while (table->sql.len < size) {
+ len = io_read(fd, (char *)table->sql.s + table->sql.len,
+ table->sql.a - table->sql.len);
+ if (len == -1) {
+ io_printf(1, "cannot read table file [%S] [%S]\n", table->name.s,
+ strerror(errno));
+ db_table_free(table);
+ free(*table_);
+ return(RFAIL);
+ }
+ if (len == 0) break;
+ table->sql.len += len;
+ }
+ close(fd);
+
+ return(ROK);
+}
+
+int
+db_read_tables(struct mysql_ *mysql, const char *configdir) {
+ struct table__ *table = NULL;
+ struct table__ *tmp = NULL;
+ struct dirent *de;
+ struct stat st;
+ DIR *dir;
+
+ /* RB_INIT */
+ RB_INIT(&mysql->table_head);
+
+ if (chdir(MYSQLTABLE) == -1) {
+ io_printf(1, "cannot chdir to mysql tables directory: [%S%Stables] [%S]\n",
+ configdir, print_bar(configdir), strerror(errno));
+ return(RFAIL);
+ }
+ dir = opendir(".");
+ if (dir == NULL)
+ return(RFAIL);
+ while ((de = readdir(dir)) != NULL) {
+ if (de->d_name == NULL ||
+ strlen(de->d_name) == 0 ||
+ strcmp(de->d_name, ".") == 0 ||
+ strcmp(de->d_name, "..") == 0) {
+ continue;
+ }
+
+ memset(&st, 0, sizeof(st));
+ if (stat(de->d_name, &st) == -1) {
+ io_printf(1, "cannot stat table file: [%S]: [%S]\n", de->d_name,
+ strerror(errno));
+ continue;
+ }
+
+ if (st.st_size == 0) {
+ io_printf(1, "table file with zero size: [%S]. ignored.\n", de->d_name);
+ continue;
+ }
+
+ if (db_read_table_sql(de->d_name, strlen(de->d_name), st.st_size, &table) == ROK) {
+ tmp = RB_INSERT(tables, &mysql->table_head, table);
+ if (tmp) {
+ db_table_free(table);
+ io_printf(1, "duplicated file: [%S]. ignored.\n", de->d_name);
+ }
+ }
+ }
+ closedir(dir);
+ return(ROK);
+}
+
+int
+db_read_conf(struct mysql_ *mysql, const char *configdir) {
+ struct stat sb;
+ FILE *fp;
+ char buf[1024];
+ char *label = "";
+ char *key;
+ char *p;
+ int curdir = -1;
+
+ memset(mysql, 0, sizeof(struct mysql_));
+
+ /* save the current dir */
+ curdir = open(".", O_RDONLY);
+ if (curdir == -1) {
+ io_printf(1, "cannot open curdir: [%S]\n", strerror(errno));
+ goto fail;
+ }
+
+ /* chdir to config dir */
+ if (chdir(configdir) == -1) {
+ io_printf(1, "cannot chdir to mysql configuration directory: [%S]: [%S]\n",
+ configdir, strerror(errno));
+ goto fail;
+ }
+
+ /* check access to config */
+ memset(&sb, 0, sizeof(sb));
+ if (stat(MYSQLCONF, &sb) == -1) {
+ io_printf(1, "cannot stat configuration file: [%S%Sconf]: [%S]\n",
+ configdir, print_bar(configdir), strerror(errno));
+ goto fail;
+ }
+
+ if (sb.st_mode & S_IRWXO)
+ io_printf(STDERR, "PUBLIC ACCESS on %S%Sconf should be removed !!!\n",
+ "ie: chmod 400 %S%Sconf\n", configdir, print_bar(configdir),
+ configdir, print_bar(configdir));
+
+ fp = fopen(MYSQLCONF, "r");
+ if (fp == (FILE *)0) {
+ io_printf(1, "cannot open configuration file: [%S%Sconf]: [%S]\n",
+ configdir, print_bar(configdir), strerror(errno));
+ goto fail;
+ }
+
+ p = (char *)0;
+ while (fgets(buf, sizeof(buf), fp)) {
+
+ p = buf;
+
+ /* skip spaces and tabs */
+ while (p && *p && (*p == ' ' || *p == '\t')) ++p;
+ if (!*p)
+ continue;
+
+ if (*p == '\n' || *p == '\r' || *p == '#') {
+ p = (char *)0;
+ continue;
+ }
+
+ /* break on first valid line */
+ break;
+ }
+ fclose(fp);
+
+ /* check for buffer */
+ if (!p || !*p) {
+ io_printf(1, "zero configuration data (no content) on file: [%S%Sconf]\n",
+ configdir, print_bar(configdir));
+ goto fail;
+ }
+
+ /* host */
+ if (db_get_conf_key(&key, &p) == RFAIL) {
+ label = "o host";
+ goto field_fail;
+ }
+ if (str_copys(&mysql->host, (unsigned char *)key) == 0) exit(51);
+
+ /* port */
+ if (db_get_conf_key(&key, &p) == RFAIL) {
+ label = "a porta";
+ goto field_fail;
+ }
+ mysql->port = atoi(key);
+
+ /* user */
+ if (db_get_conf_key(&key, &p) == RFAIL) {
+ label = "the user";
+ goto field_fail;
+ }
+ if (str_copys(&mysql->user, (unsigned char *)key) == 0) exit(51);
+
+ /* pass */
+ if (db_get_conf_key(&key, &p) == RFAIL) {
+ label = "the password";
+ goto field_fail;
+ }
+ if (str_copys(&mysql->pass, (unsigned char *)key) == 0) exit(51);
+
+ /* db */
+ if (db_get_conf_key(&key, &p) == RFAIL) {
+ label = "the database";
+ goto field_fail;
+ }
+ if (str_copys(&mysql->db, (unsigned char *)key) == 0) exit(51);
+
+ if (db_read_tables(mysql, configdir) == RFAIL)
+ goto fail;
+
+ /* check for tables */
+ /* if (RB_EMPTY(&mysql->table_head))
+ * io_printf(1, "nenhuma tabela foi carregada !\n");
+ */
+
+ fchdir(curdir);
+ close(curdir);
+ return(ROK);
+
+field_fail:
+ io_printf(1, "cannot read %S: [%S%Sconf]\n"
+ "should be: host|port|user|pass|db\n",
+ label, configdir, print_bar(configdir));
+fail:
+ fchdir(curdir);
+ close(curdir);
+ return(RFAIL);
+}
+
+/* remove tables from tree and memory */
+void
+free_sqltable_tree(struct mysql_ *mysql) {
+ struct table__ *table;
+ struct table__ *next;
+
+ for (table = RB_MIN(tables, &mysql->table_head); table != NULL; table = next) {
+ next = RB_NEXT(tables, &mysql->table_head, table);
+ RB_REMOVE(tables, &mysql->table_head, table);
+ db_table_free(table);
+ free(table);
+ }
+}
+
+int
+modLoad(struct mod_ *mod) {
+
+ log->debug("debug: module " MODULE_NAME " loading...\n");
+
+ if (str_copys(&mod->modName, (unsigned char *)MODULE_NAME) == 0)
+ exit(51);
+
+ /* adiciona os comandos xml do modulo */
+// xml_cmds_AddMod(mod, MODULE_XML_CMD);
+// xml_cmds_AddMod(mod, MODULE_XML_CMD "_teste");
+// xml_cmds_AddMod(mod, MODULE_XML_CMD "_teste_321");
+// xml_cmds_AddMod(mod, MODULE_XML_CMD "_teste_123");
+
+
+ /* read mysql configuration */
+ if (db_read_conf(&mysql, MYSQLCONFDIR) == RFAIL)
+ return(-1);
+
+ /* connect to mysql */
+ if (db_init(&mysql, config.log.debug, config.log.sql) == RFAIL)
+ return(-1);
+
+ /* read config defaults */
+ if (sql_read_defaults() == RFAIL)
+ return(-1);
+
+ /* remove stale records */
+ if (sql_disconnect_all() == RFAIL)
+ return(-1);
+
+ return(0);
+}
+
+void
+modUnload(void) {
+
+ log->debug("debug: module " MODULE_NAME " unloading...\n");
+
+ /* close mysql connection */
+ db_close(&mysql);
+
+ /* free sql tree - tables */
+ free_sqltable_tree(&mysql);
+
+ /* free mysql data */
+ str_free(&mysql.db);
+ str_free(&mysql.host);
+ str_free(&mysql.pass);
+ str_free(&mysql.user);
+
+ /* defaults_cleanup */
+ defaults_cleanup(&config.defaults);
+}
+
Added: branches/dbmod/db_modules/mysql/mysql.h
===================================================================
--- branches/dbmod/db_modules/mysql/mysql.h (rev 0)
+++ branches/dbmod/db_modules/mysql/mysql.h 2009-07-28 13:39:12 UTC (rev 123)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2004-2009, Luiz Otavio O Souza <lo...@gm...>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * $Id: mysql.h 104 2009-02-11 19:04:58Z leorogoski $
+ */
+
+#ifndef MYSQL_H
+#define MYSQL_H
+
+#ifndef MYSQLCONFDIR
+#define MYSQLCONFDIR "/usr/local/etc/msn-proxy/mysql"
+#endif
+#ifndef MYSQLCONF
+#define MYSQLCONF "conf"
+#endif
+#ifndef MYSQLTABLE
+#define MYSQLTABLE "tables"
+#endif
+#ifndef DEFAULT_MYSQL_HOST
+#define DEFAULT_MYSQL_HOST "/tmp/mysql.sock"
+#endif
+#ifndef DEFAULT_MYSQL_PORT
+#define DEFAULT_MYSQL_PORT 3306
+#endif
+#ifndef DEFAULT_MYSQL_USER
+#define DEFAULT_MYSQL_USER "maildir-index"
+#endif
+#ifndef DEFAULT_MYSQL_PASS
+#define DEFAULT_MYSQL_PASS "secret"
+#endif
+#ifndef DEFAULT_MYSQL_DB
+#define DEFAULT_MYSQL_DB "maildir-index"
+#endif
+
+#include "../../tree.h"
+#include "../../string.h"
+#include <mysql/mysql.h>
+
+struct table__ {
+ RB_ENTRY(table__) table_;
+ string name;
+ string sql;
+ size_t size;
+ int exist;
+};
+
+struct tables {
+ struct table__ *rbh_root; /* root of the tree */
+};
+
+struct mysql_ {
+ struct tables table_head; /* sql to create table */
+ MYSQL mysql; /* mysql internal data */
+ string user; /* mysql user */
+ string pass; /* mysql pass */
+ string db; /* mysql db */
+ string host; /* mysql host */
+ unsigned int port; /* mysql port */
+ int connected; /* is mysql connected ? */
+ void (*info)(const char *, ...);
+ void (*debug)(const char *, ...);
+};
+
+MYSQL_ROW db_fetch_row(MYSQL_RES *res);
+u_int64_t db_count(MYSQL_RES *res);
+u_int64_t db_affected_rows(MYSQL *mysql);
+u_int64_t db_last_id(MYSQL *mysql);
+MYSQL_RES *db_free(MYSQL_RES *res);
+char *db_escape(struct mysql_ *mysql, char *from);
+MYSQL_RES *db_query(struct mysql_ *mysql, string *query);
+int db_query2(struct mysql_ *mysql, string *query);
+int db_create_all(struct mysql_ *mysql);
+int db_check(struct mysql_ *mysql);
+char *db_error(struct mysql_ *mysql);
+int db_init(struct mysql_ *mysql,
+ void (*debug)(const char *, ...),
+ void (*sql)(const char *,...));
+void db_close(struct mysql_ *mysql);
+int db_read_conf(struct mysql_ *mysql, const char *configdir);
+void free_sqltable_tree(struct mysql_ *mysql);
+
+extern struct mysql_ mysql;
+#endif
Added: branches/dbmod/db_modules/mysql/sql.c
===================================================================
--- branches/dbmod/db_modules/mysql/sql.c (rev 0)
+++ branches/dbmod/db_modules/mysql/sql.c 2009-07-28 13:39:12 UTC (rev 123)
@@ -0,0 +1,1205 @@
+/*
+ * Copyright (c) 2004-2009, Luiz Otavio O Souza <lo...@gm...>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+static const char rcsid[] = "$Id: sql.c 120 2009-04-27 10:20:20Z leorogoski $";
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "sql.h"
+#include "mysql.h"
+#include "../../fmt.h"
+#include "../../return.h"
+#include "../../protocol.h"
+#include "../../array_cmd.h"
+#include "../../msn-proxy.h"
+
+void
+sql_data(string *sql, unsigned int len, char *key, char *value) {
+ string buf;
+
+ str_zero(&buf);
+ if (len != sql->len)
+ if (str_cats(sql, (unsigned char *)", ") == 0) exit(51);
+ buf.len = fmt_printf(NULL, "`%S` = '%q'", key, value);
+ if (str_ready(&buf, buf.len + 1) == 0) exit(51);
+ buf.len = fmt_printf(buf.s, "`%S` = '%q'", key, value);
+ if (str_cat(sql, buf.s, buf.len) == 0) exit(51);
+ str_free(&buf);
+}
+
+void
+sql_int_data(string *sql, unsigned int len, char *key, unsigned long value) {
+ string buf;
+
+ str_zero(&buf);
+ if (len != sql->len)
+ if (str_cats(sql, (unsigned char *)", ") == 0) exit(51);
+ buf.len = fmt_printf(NULL, "`%S` = '%d'", key, value);
+ if (str_ready(&buf, buf.len + 1) == 0) exit(51);
+ buf.len = fmt_printf(buf.s, "`%S` = '%d'", key, value);
+ if (str_cat(sql, buf.s, buf.len) == 0) exit(51);
+ str_free(&buf);
+}
+
+void
+sql_lint_data(string *sql, unsigned int len, char *key, unsigned long long value) {
+ string buf;
+
+ str_zero(&buf);
+ if (len != sql->len)
+ if (str_cats(sql, (unsigned char *)", ") == 0) exit(51);
+ buf.len = fmt_printf(NULL, "`%S` = '%l'", key, value);
+ if (str_ready(&buf, buf.len + 1) == 0) exit(51);
+ buf.len = fmt_printf(buf.s, "`%S` = '%l'", key, value);
+ if (str_cat(sql, buf.s, buf.len) == 0) exit(51);
+ str_free(&buf);
+}
+
+int
+sql_disconnect_all(void) {
+ string sql;
+
+ str_zero(&sql);
+
+ /* remove stale sb sessions */
+ sql.len = fmt_printf(NULL, "DELETE FROM sb");
+ if (str_ready(&sql, sql.len + 1) == 0) die_nomem();
+ sql.len = fmt_printf(sql.s, "DELETE FROM sb");
+
+ if (db_query2(&mysql, &sql) == RFAIL)
+ goto err;
+
+ /* logoff all contacts */
+ sql.len = fmt_printf(NULL, "UPDATE contacts SET contact_status = 'OFF', "
+ "contact_deny = contact_deny & ~%d",
+ CONTACT_BLOCKED);
+ if (str_ready(&sql, sql.len + 1) == 0) die_nomem();
+ sql.len = fmt_printf(sql.s, "UPDATE contacts SET contact_status = 'OFF', "
+ "contact_deny = contact_deny & ~%d",
+ CONTACT_BLOCKED);
+
+ if (db_query2(&mysql, &sql) == RFAIL)
+ goto err;
+
+ str_free(&sql);
+
+ /* logoff everyone */
+ sql.len = fmt_printf(NULL, "UPDATE users SET status = 'OFF'");
+ if (str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, "UPDATE users SET status = 'OFF'");
+
+ if (db_query2(&mysql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+
+ str_free(&sql);
+ return(ROK);
+
+err:
+ log->debug("debug: fail to reset database\n");
+ str_free(&sql);
+ return(RFAIL);
+}
+
+int
+sql_user_disconnect(string *email) {
+ string sql;
+ char *fmt;
+
+ str_zero(&sql);
+
+ /* logoff user contacts */
+ fmt = "UPDATE contacts SET contact_status = 'OFF', "
+ "contact_deny = contact_deny & ~%d WHERE email = '%q'";
+ sql.len = fmt_printf(NULL, fmt, CONTACT_BLOCKED, email->s);
+ if(str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, CONTACT_BLOCKED, email->s);
+
+ if (db_query2(&mysql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+
+ /* logoff user */
+ fmt = "UPDATE users SET status = 'OFF' WHERE email = '%q'";
+ sql.len = fmt_printf(NULL, fmt, email->s);
+ if(str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, email->s);
+
+ if (db_query2(&mysql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+
+ str_free(&sql);
+ return(ROK);
+}
+
+int
+sql_users_update(struct user_ *user) {
+ string sql;
+ char *fmt;
+
+ str_zero(&sql);
+
+ /* user exists ? */
+ fmt = "UPDATE users SET last_seen = NOW(), last_addr = '%q' "
+ "WHERE email = '%q'";
+ sql.len = fmt_printf(NULL, fmt, user->addr.s, user->email.s);
+ if(str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, user->addr.s, user->email.s);
+
+ if (db_query2(&mysql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ if (db_affected_rows(&mysql.mysql) > 0) {
+
+ /* user exist */
+ return(ROK);
+
+ } else if (db_affected_rows(&mysql.mysql) == 0) {
+
+ /* user does not exist */
+ fmt = "INSERT INTO users (email, display_name, last_seen, last_addr, "
+ "connect, save_msg, save_contacts, commands) VALUES "
+ "('%q', '%q', NOW(), '%q', (SELECT connect FROM defaults), "
+ "(SELECT save_msg FROM defaults), "
+ "(SELECT save_contacts FROM defaults), "
+ "(SELECT commands FROM defaults))";
+
+ sql.len = fmt_printf(NULL, fmt, user->email.s,
+ user->email.s, user->addr.s);
+ if (str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, user->email.s,
+ user->email.s, user->addr.s);
+
+ if (db_query2(&mysql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ return(ROK);
+ }
+
+ /* notreached */
+ return(RFAIL);
+}
+
+int
+sql_set_status(struct user_ *user) {
+ string sql;
+ char fmt[] = "UPDATE users SET status = '%q' WHERE email = '%q'";
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, user->status.s, user->email.s);
+ if (str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, user->status.s, user->email.s);
+
+ if (db_query2(&mysql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ return(ROK);
+}
+
+int
+sql_update_user_dn(struct user_ *user) {
+ char fmt[] = "UPDATE users SET display_name = '%q' "
+ "WHERE email = '%q'";
+ string sql;
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, user->dn.s, user->email.s);
+ if (str_ready(&sql, sql.len + 1) == 0)
+ return(RFAIL);
+ sql.len = fmt_printf(sql.s, fmt, user->dn.s, user->email.s);
+
+ if (db_query2(&mysql, &sql) == RFAIL) {
+ str_free(&sql);
+ return(RFAIL);
+ }
+ str_free(&sql);
+
+ return(ROK);
+}
+
+__uint32_t
+sql_insert_sb(struct user_ *user) {
+ string sql;
+ char fmt [] = "INSERT INTO sb (email, since) VALUES ('%q', NOW())";
+
+ str_zero(&sql);
+ sql.len = fmt_printf(NULL, fmt, user->email.s);
+ if(str_ready(&sql, sql.len + 1) == 0)
+ die_nomem();
+ sql.len = fmt_printf(sql.s, fmt, user->email.s);
+
+ if (db_query2(&mysql, &sql) == RFAIL) {
+ str_free(&sql);...
[truncated message content] |
|
From: Luiz O. O S. <lo...@gm...> - 2009-07-27 13:41:21
|
Pessoal, Estou trabalhando nos modulos de banco de dados e vou começar a fazer os commits em breve. Isso quer dizer que o trunk/head to svn pode ficar um pouco bagunçado nos próximos dias... Att., Luiz |
|
From: <lo...@us...> - 2009-06-17 19:26:36
|
Revision: 122
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=122&view=rev
Author: loos-br
Date: 2009-06-17 19:26:25 +0000 (Wed, 17 Jun 2009)
Log Message:
-----------
pequena correcao (porem importante) no msn_decode
Modified Paths:
--------------
trunk/protocol.c
Modified: trunk/protocol.c
===================================================================
--- trunk/protocol.c 2009-05-11 11:06:03 UTC (rev 121)
+++ trunk/protocol.c 2009-06-17 19:26:25 UTC (rev 122)
@@ -146,9 +146,9 @@
if (*buf.s >= '0' && *buf.s <= '9')
c = (*buf.s - '0') << 4;
else if (*buf.s >= 'a' && *buf.s <= 'f')
- c = (*buf.s - 'a') << 4;
+ c = ((*buf.s - 'a') + 10) << 4;
else if (*buf.s >= 'A' && *buf.s <= 'F')
- c = (*buf.s - 'A') << 4;
+ c = ((*buf.s - 'A') + 10) << 4;
buf.len--;
buf.s++;
@@ -156,9 +156,9 @@
if (*buf.s >= '0' && *buf.s <= '9')
c |= (*buf.s - '0');
else if (*buf.s >= 'a' && *buf.s <= 'f')
- c |= (*buf.s - 'a');
+ c |= (*buf.s - 'a') + 10;
else if (*buf.s >= 'A' && *buf.s <= 'F')
- c |= (*buf.s - 'A');
+ c |= (*buf.s - 'A') + 10;
if (str_cat(out, &c, 1) == 0)
die_nomem();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Nilson C. <nil...@gm...> - 2009-06-12 21:12:45
|
Cara este é o problema. Tenho duas redes no mesmo squid, ligado ao msn-proxy. Uma rede, deve bloquear tudo, e ir liberando só o que eu quero, na outra deve liberar todos indiscriminadamente. Por isto pensei que ao clicar no S do conectados/desconectados, ele já mudava para todos os contatos. 2009/6/12 Claudir Pereira dos Santos - Claupers <cla...@ho...> > apague a base de dados. Marque como padrão bloqueado. Assim todos os > contatos serão bloqueados quando o usuário fizer o primeiro acesso. > Ai vc libera somente os que devem ser usados. > A regra vai ser aplicada a todos os usuarios. > > Cordialmente; > > > Claudir > > *From:* Nilson Chagas <nil...@gm...> > *Sent:* Friday, June 12, 2009 4:40 PM > *To:* msn...@li... > *Subject:* Re: [msn-proxy-devel] Habilitar para conversar > > Com relação a liberação/bloqueio em tempo real, até que eles acontecem, o > problema é que ao clicar no sim e não, da opção conectados ou > desconectados, gostaria que ele mudasse os parametros de todos os contatos. > Tem um cara aqui que tem 200 contatos, não tem como fazer um a um. > > > 2009/6/12 Claudir Pereira dos Santos - Claupers <cla...@ho...> > >> Veja a opção de matar todos os processos. >> pkill -9 msn-proxy >> /dev/null >> >> E mude também as configurações do php para exibir os erros. >> >> Altere no arquivo /etc/php5/apache2/php.ini os valores de: >> >> *display_errors = On * >> >> *display_startup_errors = On * >> >> >> Quando tem mais de um processo rodando não bloqueia em tempo real. >> Por isso você deve matar todos os processos e iniciar o ms-proxy via >> daemon. >> Ativando as opções do php para exibir os erros vc vai receber uma mensagem >> quando houver mais de um processo rodando >> veja o artigo atualizado em >> http://claupers.spaces.live.com/blog/cns!80F64739372147EE!508.entry<http://claupers.spaces.live.com/blog/cns%2180F64739372147EE%21508.entry> >> >> >> Cordialmente; >> >> >> Claudir >> >> *From:* Nilson Chagas <nil...@gm...> >> *Sent:* Friday, June 12, 2009 4:10 PM >> *To:* msn...@li... >> *Subject:* Re: [msn-proxy-devel] Habilitar para conversar >> >> On Fri, Jun 12, 2009 at 2:53 PM, Claudir Pereira dos Santos - Claupers < >> cla...@ho...> wrote: >> >>> Sim, mas fique atento. Se tiver mais que um processo rodando não >>> funciona. Tive esse mesmo problema. >>> Fique atendo a todos os componentes necessários >>> Para ter mais informações leia o artigo que publiquei do site vivaolinux. >>> O link está abaixo. >>> >>> >>> http://www.vivaolinux.com.br/artigo/Instalando-o-MSNProxy-0.7-no-OpenSuSE-11.1-Linux >>> >>> >>> >> >> Claudir, >> >> Seu artigo, não me esclareceu sobre o meu problema, fora um problema que o >> pessoa estava tendo com iptables. >> >> Teria como vc dar uma luz mais direta em cima do problema, tá >> escuuurroooo!!! rsrsrs >> >> -- >> []s >> Nilson Chagas - Ubuntu User 25794 >> --- >> Visite: >> http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico >> http://tempodesalvacao.blogspot.com/ >> http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso >> Biblico >> >> >> ------------------------------ >> >> >> ------------------------------------------------------------------------------ >> Crystal Reports - New Free Runtime and 30 Day Trial >> Check out the new simplified licensing option that enables unlimited >> royalty-free distribution of the report engine for externally facing >> server and web deployment. >> http://p.sf.net/sfu/businessobjects >> >> ------------------------------ >> >> _______________________________________________ >> msn-proxy-devel mailing list >> msn...@li... >> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >> >> >> ------------------------------------------------------------------------------ >> Crystal Reports - New Free Runtime and 30 Day Trial >> Check out the new simplified licensing option that enables unlimited >> royalty-free distribution of the report engine for externally facing >> server and web deployment. >> http://p.sf.net/sfu/businessobjects >> _______________________________________________ >> msn-proxy-devel mailing list >> msn...@li... >> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >> >> > > > -- > []s > Nilson Chagas - Ubuntu User 25794 > --- > Visite: > http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico > http://tempodesalvacao.blogspot.com/ > http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico > > > ------------------------------ > > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables unlimited > royalty-free distribution of the report engine for externally facing > server and web deployment. > http://p.sf.net/sfu/businessobjects > > ------------------------------ > > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables unlimited > royalty-free distribution of the report engine for externally facing > server and web deployment. > http://p.sf.net/sfu/businessobjects > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > -- []s Nilson Chagas - Ubuntu User 25794 --- Visite: http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico http://tempodesalvacao.blogspot.com/ http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico |
|
From: Claudir P. d. S. - C. <cla...@ho...> - 2009-06-12 21:00:26
|
apague a base de dados. Marque como padrão bloqueado. Assim todos os contatos serão bloqueados quando o usuário fizer o primeiro acesso. Ai vc libera somente os que devem ser usados. A regra vai ser aplicada a todos os usuarios. Cordialmente; Claudir From: Nilson Chagas Sent: Friday, June 12, 2009 4:40 PM To: msn...@li... Subject: Re: [msn-proxy-devel] Habilitar para conversar Com relação a liberação/bloqueio em tempo real, até que eles acontecem, o problema é que ao clicar no sim e não, da opção conectados ou desconectados, gostaria que ele mudasse os parametros de todos os contatos. Tem um cara aqui que tem 200 contatos, não tem como fazer um a um. 2009/6/12 Claudir Pereira dos Santos - Claupers <cla...@ho...> Veja a opção de matar todos os processos. pkill -9 msn-proxy >> /dev/null E mude também as configurações do php para exibir os erros. Altere no arquivo /etc/php5/apache2/php.ini os valores de: display_errors = On display_startup_errors = On Quando tem mais de um processo rodando não bloqueia em tempo real. Por isso você deve matar todos os processos e iniciar o ms-proxy via daemon. Ativando as opções do php para exibir os erros vc vai receber uma mensagem quando houver mais de um processo rodando veja o artigo atualizado em http://claupers.spaces.live.com/blog/cns!80F64739372147EE!508.entry Cordialmente; Claudir From: Nilson Chagas Sent: Friday, June 12, 2009 4:10 PM To: msn...@li... Subject: Re: [msn-proxy-devel] Habilitar para conversar On Fri, Jun 12, 2009 at 2:53 PM, Claudir Pereira dos Santos - Claupers <cla...@ho...> wrote: Sim, mas fique atento. Se tiver mais que um processo rodando não funciona. Tive esse mesmo problema. Fique atendo a todos os componentes necessários Para ter mais informações leia o artigo que publiquei do site vivaolinux. O link está abaixo. http://www.vivaolinux.com.br/artigo/Instalando-o-MSNProxy-0.7-no-OpenSuSE-11.1-Linux Claudir, Seu artigo, não me esclareceu sobre o meu problema, fora um problema que o pessoa estava tendo com iptables. Teria como vc dar uma luz mais direta em cima do problema, tá escuuurroooo!!! rsrsrs -- []s Nilson Chagas - Ubuntu User 25794 --- Visite: http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico http://tempodesalvacao.blogspot.com/ http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ------------------------------------------------------------------------------ _______________________________________________ msn-proxy-devel mailing list msn...@li... https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ msn-proxy-devel mailing list msn...@li... https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel -- []s Nilson Chagas - Ubuntu User 25794 --- Visite: http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico http://tempodesalvacao.blogspot.com/ http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico -------------------------------------------------------------------------------- ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects -------------------------------------------------------------------------------- _______________________________________________ msn-proxy-devel mailing list msn...@li... https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel |
|
From: Nilson C. <nil...@gm...> - 2009-06-12 19:42:47
|
Com relação a liberação/bloqueio em tempo real, até que eles acontecem, o problema é que ao clicar no sim e não, da opção conectados ou desconectados, gostaria que ele mudasse os parametros de todos os contatos. Tem um cara aqui que tem 200 contatos, não tem como fazer um a um. 2009/6/12 Claudir Pereira dos Santos - Claupers <cla...@ho...> > Veja a opção de matar todos os processos. > pkill -9 msn-proxy >> /dev/null > > E mude também as configurações do php para exibir os erros. > > Altere no arquivo /etc/php5/apache2/php.ini os valores de: > > *display_errors = On * > > *display_startup_errors = On * > > > Quando tem mais de um processo rodando não bloqueia em tempo real. > Por isso você deve matar todos os processos e iniciar o ms-proxy via > daemon. > Ativando as opções do php para exibir os erros vc vai receber uma mensagem > quando houver mais de um processo rodando > veja o artigo atualizado em > http://claupers.spaces.live.com/blog/cns!80F64739372147EE!508.entry<http://claupers.spaces.live.com/blog/cns%2180F64739372147EE%21508.entry> > > > Cordialmente; > > > Claudir > > *From:* Nilson Chagas <nil...@gm...> > *Sent:* Friday, June 12, 2009 4:10 PM > *To:* msn...@li... > *Subject:* Re: [msn-proxy-devel] Habilitar para conversar > > On Fri, Jun 12, 2009 at 2:53 PM, Claudir Pereira dos Santos - Claupers < > cla...@ho...> wrote: > >> Sim, mas fique atento. Se tiver mais que um processo rodando não >> funciona. Tive esse mesmo problema. >> Fique atendo a todos os componentes necessários >> Para ter mais informações leia o artigo que publiquei do site vivaolinux. >> O link está abaixo. >> >> >> http://www.vivaolinux.com.br/artigo/Instalando-o-MSNProxy-0.7-no-OpenSuSE-11.1-Linux >> >> >> > > Claudir, > > Seu artigo, não me esclareceu sobre o meu problema, fora um problema que o > pessoa estava tendo com iptables. > > Teria como vc dar uma luz mais direta em cima do problema, tá > escuuurroooo!!! rsrsrs > > -- > []s > Nilson Chagas - Ubuntu User 25794 > --- > Visite: > http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico > http://tempodesalvacao.blogspot.com/ > http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico > > > ------------------------------ > > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables unlimited > royalty-free distribution of the report engine for externally facing > server and web deployment. > http://p.sf.net/sfu/businessobjects > > ------------------------------ > > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables unlimited > royalty-free distribution of the report engine for externally facing > server and web deployment. > http://p.sf.net/sfu/businessobjects > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > -- []s Nilson Chagas - Ubuntu User 25794 --- Visite: http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico http://tempodesalvacao.blogspot.com/ http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico |
|
From: Claudir P. d. S. - C. <cla...@ho...> - 2009-06-12 19:35:21
|
Veja a opção de matar todos os processos. pkill -9 msn-proxy >> /dev/null E mude também as configurações do php para exibir os erros. Altere no arquivo /etc/php5/apache2/php.ini os valores de: display_errors = On display_startup_errors = On Quando tem mais de um processo rodando não bloqueia em tempo real. Por isso você deve matar todos os processos e iniciar o ms-proxy via daemon. Ativando as opções do php para exibir os erros vc vai receber uma mensagem quando houver mais de um processo rodando veja o artigo atualizado em http://claupers.spaces.live.com/blog/cns!80F64739372147EE!508.entry Cordialmente; Claudir From: Nilson Chagas Sent: Friday, June 12, 2009 4:10 PM To: msn...@li... Subject: Re: [msn-proxy-devel] Habilitar para conversar On Fri, Jun 12, 2009 at 2:53 PM, Claudir Pereira dos Santos - Claupers <cla...@ho...> wrote: Sim, mas fique atento. Se tiver mais que um processo rodando não funciona. Tive esse mesmo problema. Fique atendo a todos os componentes necessários Para ter mais informações leia o artigo que publiquei do site vivaolinux. O link está abaixo. http://www.vivaolinux.com.br/artigo/Instalando-o-MSNProxy-0.7-no-OpenSuSE-11.1-Linux Claudir, Seu artigo, não me esclareceu sobre o meu problema, fora um problema que o pessoa estava tendo com iptables. Teria como vc dar uma luz mais direta em cima do problema, tá escuuurroooo!!! rsrsrs -- []s Nilson Chagas - Ubuntu User 25794 --- Visite: http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico http://tempodesalvacao.blogspot.com/ http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico -------------------------------------------------------------------------------- ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects -------------------------------------------------------------------------------- _______________________________________________ msn-proxy-devel mailing list msn...@li... https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel |
|
From: Nilson C. <nil...@gm...> - 2009-06-12 19:10:32
|
On Fri, Jun 12, 2009 at 2:53 PM, Claudir Pereira dos Santos - Claupers < cla...@ho...> wrote: > Sim, mas fique atento. Se tiver mais que um processo rodando não > funciona. Tive esse mesmo problema. > Fique atendo a todos os componentes necessários > Para ter mais informações leia o artigo que publiquei do site vivaolinux. O > link está abaixo. > > > http://www.vivaolinux.com.br/artigo/Instalando-o-MSNProxy-0.7-no-OpenSuSE-11.1-Linux > > > Claudir, Seu artigo, não me esclareceu sobre o meu problema, fora um problema que o pessoa estava tendo com iptables. Teria como vc dar uma luz mais direta em cima do problema, tá escuuurroooo!!! rsrsrs -- []s Nilson Chagas - Ubuntu User 25794 --- Visite: http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico http://tempodesalvacao.blogspot.com/ http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico |
|
From: Claudir P. d. S. - C. <cla...@ho...> - 2009-06-12 17:53:52
|
Sim, mas fique atento. Se tiver mais que um processo rodando não funciona. Tive esse mesmo problema. Fique atendo a todos os componentes necessários Para ter mais informações leia o artigo que publiquei do site vivaolinux. O link está abaixo. http://www.vivaolinux.com.br/artigo/Instalando-o-MSNProxy-0.7-no-OpenSuSE-11.1-Linux Cordialmente; Claudir From: Nilson Chagas Sent: Friday, June 12, 2009 2:44 PM To: msn...@li... Subject: [msn-proxy-devel] Habilitar para conversar Quando eu clino no S ou no N, ao lado das opções conectados e desconectados, ele não deveria automaticamente habilitar ou desabilitar todos os contatos?? -- []s Nilson Chagas - Ubuntu User 25794 --- Visite: http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico http://tempodesalvacao.blogspot.com/ http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico -------------------------------------------------------------------------------- ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects -------------------------------------------------------------------------------- _______________________________________________ msn-proxy-devel mailing list msn...@li... https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel |
|
From: Nilson C. <nil...@gm...> - 2009-06-12 17:44:19
|
Quando eu clino no S ou no N, ao lado das opções conectados e desconectados, ele não deveria automaticamente habilitar ou desabilitar todos os contatos?? -- []s Nilson Chagas - Ubuntu User 25794 --- Visite: http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico http://tempodesalvacao.blogspot.com/ http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico |
|
From: Alessandro M. C. <amc...@uc...> - 2009-06-01 17:36:05
|
>Estou usando a versão que foi distribuida no pacote 0.7.35.1 do site OpenSuse.
>Uma observação é que marcando para fonte da mensagem ficar azul ela está
fincado
>vermelha, e se marco para ficar vermelha ela fica azul.
Testa esse patch:
Index: conf.php
===================================================================
--- conf.php (revisão 121)
+++ conf.php (cópia de trabalho)
@@ -193,11 +193,11 @@
$colors = array (
array("000000", "Preto"),
- array("ff0000", "Vermelho"),
+ array("0000ff", "Vermelho"),
array("00ff00", "Verde"),
- array("0000ff", "Azul"),
- array("ffff00", "Amarelo"),
- array("00ffff", "Ciano"),
+ array("ff0000", "Azul"),
+ array("00ffff", "Amarelo"),
+ array("ffff00", "Ciano"),
array("ff00ff", "Magenta"),
array("c0c0c0", "Cinza"),
array("ffffff", "Branco")
--
,= ,-_-. =. [<o>] Alessandro Madruga Correia
((_/)o o(\_)) [http://counter.li.org] Ubuntu User# 342751
`-'(. .)`-' "A matemática é a arte de transformar uma coisa...
\_/ ... na mesma coisa." (Demétrius Melo de Souza)
---------------------------------------
Essa mensagem foi enviada pelo UCS Mail
|
|
From: Claudir P. d. S. - C. <cla...@ho...> - 2009-06-01 14:05:13
|
Olha, as configurações são todas salvas do banco de dados. Tem que ver que a verão 0.7 efetuou mudanças na base de dados referente a estrutura. Não sei qual será o impacto da mudança pois iniciei a operação já na 0.7. O que recomento é você fazer uma cópia da base que é onde fica todas as informações. Ai você atualiza. Procure na documentação o que foi alterado na base. Não sei se a atualização ira fazer as mudanças automaticamente na base, por isso veja a documentação e verifique a base. Se não alterou automaticamente, faça manualmente. Teste, teste teste. Depois poste os resultados ai para gente saber. Cordialmente; Claudir -------------------------------------------------- From: "Marcelo Salavee Lemos" <msa...@gm...> Sent: Monday, June 01, 2009 9:20 AM To: <msn...@li...> Subject: Re: [msn-proxy-devel] msn-proxy-0.6.2 X msn > Tem alguma maneira simples de atualizar?Preservando toda a configuracao? > > Obrigado, > Marcelo > > Claudir Pereira dos Santos - Claupers wrote: >> Já tentou atualizar para o msn-proxy 0.7? >> >> >> Cordialmente; >> >> >> Claudir >> >> -------------------------------------------------- >> From: "Marcelo Salavee Lemos" <msa...@gm...> >> Sent: Friday, May 29, 2009 2:37 PM >> To: <msn...@li...> >> Subject: [msn-proxy-devel] msn-proxy-0.6.2 X msn >> >> >>> Srs, >>> >>> Tenho um usuario(bem remoto) que esta tendo dificuldades de logar o msn >>> apos ter feito uma atualizacao do msn(segundo ele esta com a ultima >>> versao disponivel no site do msn e antes com a versao 8 ele logava). >>> O que acontece eh o seguinte, durante o horario de almoco roda um script >>> que tira o redirecionamento da porta 1863 para o msn-proxy(almoco >>> liberado sem monitoramento), dai ele consegue conectar com o msn dele, >>> quando volta o horario de servico roda outro script que volta a >>> redirecionar a porta 1863 para o msn-proxy, e quando isso acontece ele >>> nao consegue logar mais no msn. >>> Isto procede? alguem percebeu algo semelhante? >>> >>> Abraços, >>> Marcelo >>> >>> ------------------------------------------------------------------------------ >>> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT >>> is a gathering of tech-side developers & brand creativity professionals. >>> Meet >>> the minds behind Google Creative Lab, Visual Complexity, Processing, & >>> iPhoneDevCamp as they present alongside digital heavyweights like >>> Barbarian >>> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com >>> _______________________________________________ >>> msn-proxy-devel mailing list >>> msn...@li... >>> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >>> >>> >> >> ------------------------------------------------------------------------------ >> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT >> is a gathering of tech-side developers & brand creativity professionals. >> Meet >> the minds behind Google Creative Lab, Visual Complexity, Processing, & >> iPhoneDevCamp as they present alongside digital heavyweights like >> Barbarian >> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com >> _______________________________________________ >> msn-proxy-devel mailing list >> msn...@li... >> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >> > > ------------------------------------------------------------------------------ > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT > is a gathering of tech-side developers & brand creativity professionals. > Meet > the minds behind Google Creative Lab, Visual Complexity, Processing, & > iPhoneDevCamp as they present alongside digital heavyweights like > Barbarian > Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > |
|
From: Marcelo S. L. <msa...@gm...> - 2009-06-01 13:18:14
|
Tem alguma maneira simples de atualizar?Preservando toda a configuracao? Obrigado, Marcelo Claudir Pereira dos Santos - Claupers wrote: > Já tentou atualizar para o msn-proxy 0.7? > > > Cordialmente; > > > Claudir > > -------------------------------------------------- > From: "Marcelo Salavee Lemos" <msa...@gm...> > Sent: Friday, May 29, 2009 2:37 PM > To: <msn...@li...> > Subject: [msn-proxy-devel] msn-proxy-0.6.2 X msn > > >> Srs, >> >> Tenho um usuario(bem remoto) que esta tendo dificuldades de logar o msn >> apos ter feito uma atualizacao do msn(segundo ele esta com a ultima >> versao disponivel no site do msn e antes com a versao 8 ele logava). >> O que acontece eh o seguinte, durante o horario de almoco roda um script >> que tira o redirecionamento da porta 1863 para o msn-proxy(almoco >> liberado sem monitoramento), dai ele consegue conectar com o msn dele, >> quando volta o horario de servico roda outro script que volta a >> redirecionar a porta 1863 para o msn-proxy, e quando isso acontece ele >> nao consegue logar mais no msn. >> Isto procede? alguem percebeu algo semelhante? >> >> Abraços, >> Marcelo >> >> ------------------------------------------------------------------------------ >> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT >> is a gathering of tech-side developers & brand creativity professionals. >> Meet >> the minds behind Google Creative Lab, Visual Complexity, Processing, & >> iPhoneDevCamp as they present alongside digital heavyweights like >> Barbarian >> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com >> _______________________________________________ >> msn-proxy-devel mailing list >> msn...@li... >> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >> >> > > ------------------------------------------------------------------------------ > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT > is a gathering of tech-side developers & brand creativity professionals. Meet > the minds behind Google Creative Lab, Visual Complexity, Processing, & > iPhoneDevCamp as they present alongside digital heavyweights like Barbarian > Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > |
|
From: Claudir P. d. S. - C. <cla...@ho...> - 2009-05-29 19:52:56
|
Já tentou atualizar para o msn-proxy 0.7? Cordialmente; Claudir -------------------------------------------------- From: "Marcelo Salavee Lemos" <msa...@gm...> Sent: Friday, May 29, 2009 2:37 PM To: <msn...@li...> Subject: [msn-proxy-devel] msn-proxy-0.6.2 X msn > Srs, > > Tenho um usuario(bem remoto) que esta tendo dificuldades de logar o msn > apos ter feito uma atualizacao do msn(segundo ele esta com a ultima > versao disponivel no site do msn e antes com a versao 8 ele logava). > O que acontece eh o seguinte, durante o horario de almoco roda um script > que tira o redirecionamento da porta 1863 para o msn-proxy(almoco > liberado sem monitoramento), dai ele consegue conectar com o msn dele, > quando volta o horario de servico roda outro script que volta a > redirecionar a porta 1863 para o msn-proxy, e quando isso acontece ele > nao consegue logar mais no msn. > Isto procede? alguem percebeu algo semelhante? > > Abraços, > Marcelo > > ------------------------------------------------------------------------------ > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT > is a gathering of tech-side developers & brand creativity professionals. > Meet > the minds behind Google Creative Lab, Visual Complexity, Processing, & > iPhoneDevCamp as they present alongside digital heavyweights like > Barbarian > Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > |
|
From: Marcelo S. L. <msa...@gm...> - 2009-05-29 18:01:32
|
Srs, Tenho um usuario(bem remoto) que esta tendo dificuldades de logar o msn apos ter feito uma atualizacao do msn(segundo ele esta com a ultima versao disponivel no site do msn e antes com a versao 8 ele logava). O que acontece eh o seguinte, durante o horario de almoco roda um script que tira o redirecionamento da porta 1863 para o msn-proxy(almoco liberado sem monitoramento), dai ele consegue conectar com o msn dele, quando volta o horario de servico roda outro script que volta a redirecionar a porta 1863 para o msn-proxy, e quando isso acontece ele nao consegue logar mais no msn. Isto procede? alguem percebeu algo semelhante? Abraços, Marcelo |
|
From: Francisco E. <fed...@gm...> - 2009-05-22 23:11:48
|
Luiz, Estou em uma posição semelhante. Mas eu tenho o msn-proxy rodando em duas empresas. Uma em uma máquina dedicada e na outra junto com o firewall. Tenho algumas idéias também e tenho as necessidades destes clientes com itens como: - Definir mais de um administrador e colocar quais MSNs eles podem ver as conversas e efetuar bloqueios. - ACL e por ai vai. Concordo com o Delton quanto as necessidades, mas vejo mais urgência na interface web e relatórios. Estou a disposição. abraços Chico 2009/5/15 Delton <del...@gm...>: > Luiz, > Eu posso contribuir da seguinte maneira: > 1- Testando o software - tenho aproximandamente 100 usuários usando o > Msn-proxy com diferentes clientes; > 2 - Não é minha principal ocupação, mas conheço PHP, SQL, CSS, HTML, > Javascript, etc. De C não entendo muito, mas o que sei ponho a disposição; > 3 - Posso colaborar com documentação e suporte; > 4 - As vezes tenho algumas idéias! :P > > Devemos definir algumas metas e trabalhar para atingir os objetivos > traçados. > Vejo que algo que pode ser trabalhado hoje é a interface web, um gerador de > relatórios e criar uma documentação oficial. > > Bom, de minha parte, é isso. > > Delton > > 2009/5/15 Luiz Otavio O Souza <lo...@gm...> >> >> 2009/5/11 Fábio Mello <ilu...@gm...>: >> > Meus anexos não foram porque excederam o número kb da mensagem. >> > Mas enfim, temos algum progresso? Quem são os realmente interessados em >> > contribuir? >> > Outra coisa: Eu olhei a lista do 'ToDo' e como ainda se têm bastante >> > coisas >> > a serem feitas, poderiamos fazer uma base e modulos para cada >> > funcionalidade. >> > >> > 2009/4/30 Delton <del...@gm...> >> >> >> >> Como foi citado, está na hora de nos unirmos em busca de uma solução >> >> ótima. Devemos decidir que solução será adotada e concentrar nossos >> >> esforços >> >> nesta opção. >> >> Quanto a utilizar Java o PHP, devemos levar em conta a facilidade de >> >> instalação, o consumo de recursos, o custo de programação, etc. >> >> Proponho que seja primeiramente elegida uma linguagem para depois >> >> passarmos ao levantamento dos requisitos e só então a programação. O >> >> que >> >> acham? >> >> >> > Eu estou realmente interessando em contribuir. >> > >> > abraços >> > >> > Chico >> >> Chico, Fábio, Delton e all =) >> >> Eu acho que precisamos saber como cada um pode contribuir para que >> possamos >> distribuir as tarefas, se cada um contribuir com uma parte (ainda que >> pequena) em breve teremos um sistema muito melhor e sem tantos >> defeitos/problemas. >> >> O que precisamos (sempre !) é de pessoas que estejam realmente dispostas a >> contribuir, seja com código, com documentação, com boas idéias e até na >> ajuda para com os outros usuários menos experientes. >> >> Podemos levantar o que falta no projeto para um acabamento mais >> profissional >> (tudo o que precisa ser adicionado, melhorado ou alterado) e então >> distribuir as tarefas de acordo com as competencias e disponibilidade de >> cada um. >> >> Desde já agradeço a colaboração de todos. >> >> Grande abraço, >> Luiz >> >> >> >> ------------------------------------------------------------------------------ >> Crystal Reports - New Free Runtime and 30 Day Trial >> Check out the new simplified licensing option that enables >> unlimited royalty-free distribution of the report engine >> for externally facing server and web deployment. >> http://p.sf.net/sfu/businessobjects >> _______________________________________________ >> msn-proxy-devel mailing list >> msn...@li... >> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > > > -- > gnote te auton! > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables > unlimited royalty-free distribution of the report engine > for externally facing server and web deployment. > http://p.sf.net/sfu/businessobjects > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > |
|
From: Fábio M. <ilu...@gm...> - 2009-05-22 11:23:40
|
### BEGIN INIT INFO
# Provides: sniffer
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
#!/bin/sh
case "$1" in
start)
echo "Iniciando msn-proxy..."
/usr/local/bin/msn-proxy -b
;;
stop)
echo "Encerrando msn-proxy..."
ps ax|grep msn-proxy|grep -v grep|kill -15 `awk {'print $1'}`
;;
*)
echo $"Usar: $0 {start|stop}"
exit 1
;;
esac
exit $RETVAL
2009/5/21 Nilson Chagas <nil...@gm...>
> Tenho certeza que será bem vindo.
>
> 2009/5/21 Fábio Mello <ilu...@gm...>
>
>
>> Eu uso kill -15 pid
>> Fiz um script com start/stop , funciona perfeitamente no meu debian,
>> queres?
>>
>> 2009/5/21 Nilson Chagas <nil...@gm...>
>>
>>> Como posso parar o serviço do msn, ou dar um resetada nele????
>>>
>>> --
>>> []s
>>> Nilson Chagas - Ubuntu User 25794
>>> ---
>>> Visite:
>>> http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico
>>> http://tempodesalvacao.blogspot.com/
>>> http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso
>>> Biblico
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
>>> is a gathering of tech-side developers & brand creativity professionals.
>>> Meet
>>> the minds behind Google Creative Lab, Visual Complexity, Processing, &
>>> iPhoneDevCamp asthey present alongside digital heavyweights like
>>> Barbarian
>>> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
>>> _______________________________________________
>>> msn-proxy-devel mailing list
>>> msn...@li...
>>> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
>> is a gathering of tech-side developers & brand creativity professionals.
>> Meet
>> the minds behind Google Creative Lab, Visual Complexity, Processing, &
>> iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
>> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
>> _______________________________________________
>> msn-proxy-devel mailing list
>> msn...@li...
>> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel
>>
>>
>
>
> --
> []s
> Nilson Chagas - Ubuntu User 25794
> ---
> Visite:
> http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico
> http://tempodesalvacao.blogspot.com/
> http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico
>
>
>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals.
> Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
> _______________________________________________
> msn-proxy-devel mailing list
> msn...@li...
> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel
>
>
|
|
From: Nilson C. <nil...@gm...> - 2009-05-22 00:53:35
|
Tenho certeza que será bem vindo. 2009/5/21 Fábio Mello <ilu...@gm...> > > Eu uso kill -15 pid > Fiz um script com start/stop , funciona perfeitamente no meu debian, > queres? > > 2009/5/21 Nilson Chagas <nil...@gm...> > >> Como posso parar o serviço do msn, ou dar um resetada nele???? >> >> -- >> []s >> Nilson Chagas - Ubuntu User 25794 >> --- >> Visite: >> http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico >> http://tempodesalvacao.blogspot.com/ >> http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso >> Biblico >> >> >> >> >> ------------------------------------------------------------------------------ >> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT >> is a gathering of tech-side developers & brand creativity professionals. >> Meet >> the minds behind Google Creative Lab, Visual Complexity, Processing, & >> iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian >> Group, R/GA, & Big Spaceship. http://www.creativitycat.com >> _______________________________________________ >> msn-proxy-devel mailing list >> msn...@li... >> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >> >> > > > ------------------------------------------------------------------------------ > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT > is a gathering of tech-side developers & brand creativity professionals. > Meet > the minds behind Google Creative Lab, Visual Complexity, Processing, & > iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian > Group, R/GA, & Big Spaceship. http://www.creativitycat.com > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > -- []s Nilson Chagas - Ubuntu User 25794 --- Visite: http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico http://tempodesalvacao.blogspot.com/ http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico |
|
From: Fábio M. <ilu...@gm...> - 2009-05-22 00:05:20
|
Eu uso kill -15 pid Fiz um script com start/stop , funciona perfeitamente no meu debian, queres? 2009/5/21 Nilson Chagas <nil...@gm...> > Como posso parar o serviço do msn, ou dar um resetada nele???? > > -- > []s > Nilson Chagas - Ubuntu User 25794 > --- > Visite: > http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico > http://tempodesalvacao.blogspot.com/ > http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico > > > > > ------------------------------------------------------------------------------ > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT > is a gathering of tech-side developers & brand creativity professionals. > Meet > the minds behind Google Creative Lab, Visual Complexity, Processing, & > iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian > Group, R/GA, & Big Spaceship. http://www.creativitycat.com > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > |
|
From: Nilson C. <nil...@gm...> - 2009-05-21 21:28:58
|
Estes dois mensageiros, estão conseguindo navegar sem qualquer controle do msn-proxy pela minha rede. Tem alguma configuração que tem que ser feita??? -- []s Nilson Chagas - Ubuntu User 25794 --- Visite: http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico http://tempodesalvacao.blogspot.com/ http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico |
|
From: Nilson C. <nil...@gm...> - 2009-05-21 21:14:15
|
Como posso parar o serviço do msn, ou dar um resetada nele???? -- []s Nilson Chagas - Ubuntu User 25794 --- Visite: http://www.amados.com.br/podcast -> Peça gratuitamente um curso Bíblico http://tempodesalvacao.blogspot.com/ http://bbnradio.org/ -> Ouça a rádio e faça gratuitamente um Curso Biblico |