msn-proxy-devel Mailing List for msn-proxy: the msn connection control (Page 4)
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: Fábio M. <ilu...@gm...> - 2009-09-29 18:05:31
|
Sim! Tanto que na versao stable funciona ok, o banco muda algo? 2009/9/29 Leonardo Duarte Rogoski <leo...@gm...> > Olá Fábio. > > Lembrou de adicionar na tabela "defaults" o "internal_host" ? > > [ ]'s > > -- > Leonardo > > 2009/9/29 Fábio Mello <ilu...@gm...>: > > Alguém mais pegou este erro: > > > > listen on [0.0.0.0:1863] > > debug: connection from [192.168.1.235:3693] > > connected to [messenger.hotmail.com:1863] > > read fail: [Connection reset by peer] > > server_read_command cmd buf: [(null)] > > debug: fail to read ns server command > > debug: connection from [192.168.1.181:2338] > > connected to [messenger.hotmail.com:1863] > > read fail: [Connection reset by peer] > > > > ?? > > > > Grato! > > > > > ------------------------------------------------------------------------------ > > Come build with us! The BlackBerry® Developer Conference in SF, CA > > is the only developer event you need to attend this year. Jumpstart your > > developing skills, take BlackBerry mobile applications to market and stay > > ahead of the curve. Join us from November 9-12, 2009. Register > now! > > http://p.sf.net/sfu/devconf > > _______________________________________________ > > msn-proxy-devel mailing list > > msn...@li... > > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > > > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > |
|
From: Leonardo D. R. <leo...@gm...> - 2009-09-29 17:56:29
|
Olá Fábio. Lembrou de adicionar na tabela "defaults" o "internal_host" ? [ ]'s -- Leonardo 2009/9/29 Fábio Mello <ilu...@gm...>: > Alguém mais pegou este erro: > > listen on [0.0.0.0:1863] > debug: connection from [192.168.1.235:3693] > connected to [messenger.hotmail.com:1863] > read fail: [Connection reset by peer] > server_read_command cmd buf: [(null)] > debug: fail to read ns server command > debug: connection from [192.168.1.181:2338] > connected to [messenger.hotmail.com:1863] > read fail: [Connection reset by peer] > > ?? > > Grato! > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > |
|
From: Fábio M. <ilu...@gm...> - 2009-09-29 17:05:25
|
Alguém mais pegou este erro: listen on [0.0.0.0:1863] debug: connection from [192.168.1.235:3693] connected to [messenger.hotmail.com:1863] read fail: [Connection reset by peer] server_read_command cmd buf: [(null)] debug: fail to read ns server command debug: connection from [192.168.1.181:2338] connected to [messenger.hotmail.com:1863] read fail: [Connection reset by peer] ?? Grato! |
|
From: Fábio M. <ilu...@gm...> - 2009-09-14 13:09:13
|
Peguei a versão nova, foi bala... Valeu! 2009/9/14 Delton <del...@gm...> > A muito tempo atrás eu tive problemas com a libevent de Debian. Baixei a > última versão aqui http://www.monkey.org/~provos/libevent/<http://www.monkey.org/%7Eprovos/libevent/>e compilei. > Com a 1.4.4 funcionou sem erros pra mim. A última é a 1.4.10. Baixe e > compile, depois compile novamente o msn-proxy. > > > 2009/9/14 Fábio Mello <ilu...@gm...> > >> Desired=Unknown/Install/Remove/Purge/Hold >> | >> Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend >> |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: >> uppercase=bad) >> ||/ Name >> Version Description >> >> +++-==============================================-==============================================-============================================================================================================ >> ii libevent-dev >> 1.3e-3 Development libraries, header >> files and docs for libevent >> >> >> 2009/9/14 Delton <del...@gm...> >> >> Qual versão da libevent? Compilei a mesma versão no Etch sem erros. >>> >>> 2009/9/14 Fábio Mello <ilu...@gm...> >>> >>>> Estou pegando este erro no make: >>>> >>>> cc -g -Wall -O2 -pipe -I/usr/local/include -fno-builtin-log -c event.c >>>> In file included from event.h:24, >>>> from event.c:21: >>>> /usr/include/event.h:214: error: expected specifier-qualifier-list >>>> before 'u_char' >>>> /usr/include/event.h:292: error: expected '=', ',', ';', 'asm' or >>>> '__attribute__' before '*' token >>>> event.c: In function 'msn_ev_stat': >>>> event.c:37: warning: implicit declaration of function 'time' >>>> make: *** [event.o] Error 1 >>>> >>>> alguem sabe me dizer o que pode ser?(versao da lib, ou algo do genero?) >>>> versao 139... >>>> >>>> - Estou usando Debian Lenny 5.0.3 >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >>>> 30-Day >>>> trial. Simplify your report design, integration and deployment - and >>>> focus on >>>> what you do best, core application coding. Discover what's new with >>>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>>> _______________________________________________ >>>> msn-proxy-devel mailing list >>>> msn...@li... >>>> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >>>> >>>> >>> >>> >>> -- >>> gnote te auton! >>> >>> >>> ------------------------------------------------------------------------------ >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >>> 30-Day >>> trial. Simplify your report design, integration and deployment - and >>> focus on >>> what you do best, core application coding. Discover what's new with >>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>> _______________________________________________ >>> msn-proxy-devel mailing list >>> msn...@li... >>> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >>> >>> >> >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and focus >> on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> msn-proxy-devel mailing list >> msn...@li... >> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >> >> > > > -- > gnote te auton! > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > |
|
From: Delton <del...@gm...> - 2009-09-14 12:55:19
|
A muito tempo atrás eu tive problemas com a libevent de Debian. Baixei a última versão aqui http://www.monkey.org/~provos/libevent/ e compilei. Com a 1.4.4 funcionou sem erros pra mim. A última é a 1.4.10. Baixe e compile, depois compile novamente o msn-proxy. 2009/9/14 Fábio Mello <ilu...@gm...> > Desired=Unknown/Install/Remove/Purge/Hold > | > Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend > |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: > uppercase=bad) > ||/ Name > Version Description > > +++-==============================================-==============================================-============================================================================================================ > ii libevent-dev > 1.3e-3 Development libraries, header > files and docs for libevent > > > 2009/9/14 Delton <del...@gm...> > > Qual versão da libevent? Compilei a mesma versão no Etch sem erros. >> >> 2009/9/14 Fábio Mello <ilu...@gm...> >> >>> Estou pegando este erro no make: >>> >>> cc -g -Wall -O2 -pipe -I/usr/local/include -fno-builtin-log -c event.c >>> In file included from event.h:24, >>> from event.c:21: >>> /usr/include/event.h:214: error: expected specifier-qualifier-list before >>> 'u_char' >>> /usr/include/event.h:292: error: expected '=', ',', ';', 'asm' or >>> '__attribute__' before '*' token >>> event.c: In function 'msn_ev_stat': >>> event.c:37: warning: implicit declaration of function 'time' >>> make: *** [event.o] Error 1 >>> >>> alguem sabe me dizer o que pode ser?(versao da lib, ou algo do genero?) >>> versao 139... >>> >>> - Estou usando Debian Lenny 5.0.3 >>> >>> >>> ------------------------------------------------------------------------------ >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >>> 30-Day >>> trial. Simplify your report design, integration and deployment - and >>> focus on >>> what you do best, core application coding. Discover what's new with >>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>> _______________________________________________ >>> msn-proxy-devel mailing list >>> msn...@li... >>> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >>> >>> >> >> >> -- >> gnote te auton! >> >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and focus >> on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> msn-proxy-devel mailing list >> msn...@li... >> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >> >> > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > -- gnote te auton! |
|
From: Fábio M. <ilu...@gm...> - 2009-09-14 12:52:34
|
Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad) ||/ Name Version Description +++-==============================================-==============================================-============================================================================================================ ii libevent-dev 1.3e-3 Development libraries, header files and docs for libevent 2009/9/14 Delton <del...@gm...> > Qual versão da libevent? Compilei a mesma versão no Etch sem erros. > > 2009/9/14 Fábio Mello <ilu...@gm...> > >> Estou pegando este erro no make: >> >> cc -g -Wall -O2 -pipe -I/usr/local/include -fno-builtin-log -c event.c >> In file included from event.h:24, >> from event.c:21: >> /usr/include/event.h:214: error: expected specifier-qualifier-list before >> 'u_char' >> /usr/include/event.h:292: error: expected '=', ',', ';', 'asm' or >> '__attribute__' before '*' token >> event.c: In function 'msn_ev_stat': >> event.c:37: warning: implicit declaration of function 'time' >> make: *** [event.o] Error 1 >> >> alguem sabe me dizer o que pode ser?(versao da lib, ou algo do genero?) >> versao 139... >> >> - Estou usando Debian Lenny 5.0.3 >> >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and focus >> on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> msn-proxy-devel mailing list >> msn...@li... >> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >> >> > > > -- > gnote te auton! > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > |
|
From: Delton <del...@gm...> - 2009-09-14 12:50:25
|
Qual versão da libevent? Compilei a mesma versão no Etch sem erros. 2009/9/14 Fábio Mello <ilu...@gm...> > Estou pegando este erro no make: > > cc -g -Wall -O2 -pipe -I/usr/local/include -fno-builtin-log -c event.c > In file included from event.h:24, > from event.c:21: > /usr/include/event.h:214: error: expected specifier-qualifier-list before > 'u_char' > /usr/include/event.h:292: error: expected '=', ',', ';', 'asm' or > '__attribute__' before '*' token > event.c: In function 'msn_ev_stat': > event.c:37: warning: implicit declaration of function 'time' > make: *** [event.o] Error 1 > > alguem sabe me dizer o que pode ser?(versao da lib, ou algo do genero?) > versao 139... > > - Estou usando Debian Lenny 5.0.3 > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > -- gnote te auton! |
|
From: Fábio M. <ilu...@gm...> - 2009-09-14 12:47:20
|
Estou pegando este erro no make:
cc -g -Wall -O2 -pipe -I/usr/local/include -fno-builtin-log -c event.c
In file included from event.h:24,
from event.c:21:
/usr/include/event.h:214: error: expected specifier-qualifier-list before
'u_char'
/usr/include/event.h:292: error: expected '=', ',', ';', 'asm' or
'__attribute__' before '*' token
event.c: In function 'msn_ev_stat':
event.c:37: warning: implicit declaration of function 'time'
make: *** [event.o] Error 1
alguem sabe me dizer o que pode ser?(versao da lib, ou algo do genero?)
versao 139...
- Estou usando Debian Lenny 5.0.3
|
|
From: <leo...@us...> - 2009-09-02 01:30:50
|
Revision: 139
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=139&view=rev
Author: leorogoski
Date: 2009-09-02 01:30:38 +0000 (Wed, 02 Sep 2009)
Log Message:
-----------
- Pequenas correcoes.
- Sim, o chao ainda esta molhado e o cachorro ainda esta bravo.
Modified Paths:
--------------
trunk/Makefile
trunk/db_modules/mysql/mysql.h
trunk/ns.c
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2009-09-01 17:07:23 UTC (rev 138)
+++ trunk/Makefile 2009-09-02 01:30:38 UTC (rev 139)
@@ -6,7 +6,7 @@
CCFLAGS=-g -Wall -O2 -pipe -I/usr/local/include -fno-builtin-log
-LDFLAGS=-L/usr/local/lib -levent
+LDFLAGS=-L/usr/local/lib -levent -ldl
OBJS=base64.o check-cmd.o client.o command.o config.o contacts.o ctl.o db.o \
event.o fmt.o io.o msg.o msn-proxy.o ns.o net-io.o p2p.o protocol.o \
Modified: trunk/db_modules/mysql/mysql.h
===================================================================
--- trunk/db_modules/mysql/mysql.h 2009-09-01 17:07:23 UTC (rev 138)
+++ trunk/db_modules/mysql/mysql.h 2009-09-02 01:30:38 UTC (rev 139)
@@ -48,7 +48,7 @@
#include "../../tree.h"
#include "../../string.h"
-#include <mysql.h>
+#include <mysql/mysql.h>
struct table__ {
RB_ENTRY(table__) table_;
Modified: trunk/ns.c
===================================================================
--- trunk/ns.c 2009-09-01 17:07:23 UTC (rev 138)
+++ trunk/ns.c 2009-09-02 01:30:38 UTC (rev 139)
@@ -545,6 +545,7 @@
if (proxy->xfr) {
str_free(proxy->xfr);
+ str_free(&proxy->host);
free(proxy->xfr);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lo...@us...> - 2009-09-01 17:07:31
|
Revision: 138
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=138&view=rev
Author: loos-br
Date: 2009-09-01 17:07:23 +0000 (Tue, 01 Sep 2009)
Log Message:
-----------
- comecou cedo :) faltou um pequeno detalhe na ultilma alteracao... corrige a
versao anterior que nao funciova (acusava comando negado).
Modified Paths:
--------------
trunk/check-cmd.c
Modified: trunk/check-cmd.c
===================================================================
--- trunk/check-cmd.c 2009-09-01 11:23:43 UTC (rev 137)
+++ trunk/check-cmd.c 2009-09-01 17:07:23 UTC (rev 138)
@@ -80,20 +80,11 @@
//print_command(cmd);
if (cmds->func != NULL)
return(cmds->func(user, cmd));
- return(ROK);
+ break;
}
}
- /* post commands cannot drop connection */
- switch (type) {
- case SERVER_POST_CMD:
- case CLIENT_POST_CMD:
- return(ROK);
- }
-
- log->debug("debug: %S command blocked: ", label);
- print_command(cmd);
- return(RFAIL);
+ return(ROK);
}
int
@@ -114,7 +105,7 @@
}
}
- if (cmds == (SBCMD *)0) {
+ if (cmds == NULL) {
log->debug("unknown protocol type [%d] / version [%d]\n", type,
sb->user->version);
return(RFAIL);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lo...@us...> - 2009-09-01 11:23:54
|
Revision: 137
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=137&view=rev
Author: loos-br
Date: 2009-09-01 11:23:43 +0000 (Tue, 01 Sep 2009)
Log Message:
-----------
- Estamos copiando o branch dbmod para o trunk para que assim, possamos receber
mais testes.
- Essa nova versao eh um trabalho em andamento, existem funcionalidades que-
bradas de proposito para que possamos providenciar a solucao correta.
- Na medida do possivel (tempo) vamos tentar providenciar a documentacao para
a instalacao dessa versao.
- Cuidado: cachorro bravo ! Piso molhado ! beware of dog !
Modified Paths:
--------------
trunk/Makefile
trunk/check-cmd.c
trunk/check-cmd.h
trunk/client.c
trunk/client.h
trunk/command.c
trunk/command.h
trunk/config.c
trunk/config.h
trunk/contacts.c
trunk/contacts.h
trunk/ctl.c
trunk/ctl.h
trunk/fmt.c
trunk/fmt.h
trunk/io.c
trunk/io.h
trunk/msg.c
trunk/msg.h
trunk/msn-proxy.c
trunk/msn-proxy.conf
trunk/msn-proxy.h
trunk/msnp12.h
trunk/msnp18.h
trunk/msnp8.h
trunk/net-io.c
trunk/net-io.h
trunk/ns.c
trunk/ns.h
trunk/p2p.c
trunk/protocol.c
trunk/protocol.h
trunk/sb.c
trunk/sb.h
trunk/server.c
trunk/server.h
trunk/string.c
trunk/string.h
trunk/syslog.c
trunk/syslog.h
trunk/user.c
trunk/user.h
trunk/xml.c
trunk/xml.h
Added Paths:
-----------
trunk/base64.c
trunk/base64.h
trunk/check-cmd-types.h
trunk/client-types.h
trunk/command-types.h
trunk/contacts-types.h
trunk/db.c
trunk/db.h
trunk/db_modules/
trunk/db_modules/mysql/
trunk/db_modules/mysql/Makefile
trunk/db_modules/mysql/conf
trunk/db_modules/mysql/mysql.c
trunk/db_modules/mysql/mysql.h
trunk/db_modules/mysql/php/
trunk/db_modules/mysql/php/.htaccess
trunk/db_modules/mysql/php/chat-to.php
trunk/db_modules/mysql/php/chat.php
trunk/db_modules/mysql/php/class.ctl.php
trunk/db_modules/mysql/php/conf.php
trunk/db_modules/mysql/php/default.array.cmd.inc.php
trunk/db_modules/mysql/php/default.array.option.inc.php
trunk/db_modules/mysql/php/default.array.status.inc.php
trunk/db_modules/mysql/php/fl.inc.php
trunk/db_modules/mysql/php/group.inc.php
trunk/db_modules/mysql/php/header.inc.php
trunk/db_modules/mysql/php/imagens/
trunk/db_modules/mysql/php/imagens/ausente.gif
trunk/db_modules/mysql/php/imagens/block.gif
trunk/db_modules/mysql/php/imagens/notinlist.png
trunk/db_modules/mysql/php/imagens/ocupado.gif
trunk/db_modules/mysql/php/imagens/offline.gif
trunk/db_modules/mysql/php/imagens/online.gif
trunk/db_modules/mysql/php/imagens/send_im.gif
trunk/db_modules/mysql/php/imagens/webcam.png
trunk/db_modules/mysql/php/index.php
trunk/db_modules/mysql/php/js.inc.php
trunk/db_modules/mysql/php/lists.inc.php
trunk/db_modules/mysql/php/mysql.inc.php
trunk/db_modules/mysql/php/save_contact_op.php
trunk/db_modules/mysql/php/save_default_op.php
trunk/db_modules/mysql/php/save_msg.php
trunk/db_modules/mysql/php/save_user_op.php
trunk/db_modules/mysql/php/user.inc.php
trunk/db_modules/mysql/php/user.php
trunk/db_modules/mysql/php/view-to.php
trunk/db_modules/mysql/php/view.php
trunk/db_modules/mysql/sql.c
trunk/db_modules/mysql/sql.h
trunk/db_modules/mysql/tables/
trunk/db_modules/mysql/tables/contact_groups
trunk/db_modules/mysql/tables/contacts
trunk/db_modules/mysql/tables/defaults
trunk/db_modules/mysql/tables/log
trunk/db_modules/mysql/tables/sb
trunk/db_modules/mysql/tables/users
trunk/db_modules/pgsql/
trunk/db_modules/pgsql/Makefile
trunk/db_modules/pgsql/conf
trunk/db_modules/pgsql/pgsql.c
trunk/db_modules/pgsql/pgsql.h
trunk/db_modules/pgsql/php/
trunk/db_modules/pgsql/php/ajax.inc.php
trunk/db_modules/pgsql/php/al.inc.php
trunk/db_modules/pgsql/php/bl.inc.php
trunk/db_modules/pgsql/php/chat-to.php
trunk/db_modules/pgsql/php/chat.php
trunk/db_modules/pgsql/php/class.ctl.php
trunk/db_modules/pgsql/php/conf.php
trunk/db_modules/pgsql/php/default.array.cmd.inc.php
trunk/db_modules/pgsql/php/default.array.option.inc.php
trunk/db_modules/pgsql/php/default.array.status.inc.php
trunk/db_modules/pgsql/php/fl.inc.php
trunk/db_modules/pgsql/php/group.inc.php
trunk/db_modules/pgsql/php/header.inc.php
trunk/db_modules/pgsql/php/imagens/
trunk/db_modules/pgsql/php/imagens/ausente.gif
trunk/db_modules/pgsql/php/imagens/block.gif
trunk/db_modules/pgsql/php/imagens/notinlist.png
trunk/db_modules/pgsql/php/imagens/ocupado.gif
trunk/db_modules/pgsql/php/imagens/offline.gif
trunk/db_modules/pgsql/php/imagens/online.gif
trunk/db_modules/pgsql/php/imagens/send_im.gif
trunk/db_modules/pgsql/php/imagens/webcam.png
trunk/db_modules/pgsql/php/index.php
trunk/db_modules/pgsql/php/pgsql.inc.php
trunk/db_modules/pgsql/php/save_contact_op.php
trunk/db_modules/pgsql/php/save_default_op.php
trunk/db_modules/pgsql/php/save_msg.php
trunk/db_modules/pgsql/php/save_user_op.php
trunk/db_modules/pgsql/php/user.inc.php
trunk/db_modules/pgsql/php/user.php
trunk/db_modules/pgsql/php/view-to.php
trunk/db_modules/pgsql/php/view.php
trunk/db_modules/pgsql/sql.c
trunk/db_modules/pgsql/sql.h
trunk/db_modules/pgsql/tables/
trunk/db_modules/pgsql/tables/contact_groups
trunk/db_modules/pgsql/tables/contacts
trunk/db_modules/pgsql/tables/defaults
trunk/db_modules/pgsql/tables/log
trunk/db_modules/pgsql/tables/sb
trunk/db_modules/pgsql/tables/users
trunk/event.c
trunk/event.h
trunk/ns-types.h
trunk/obj-types.h
trunk/sb-types.h
trunk/server-types.h
trunk/user-types.h
trunk/xml-types.h
Removed Paths:
-------------
trunk/contacts-data.h
trunk/db_modules/mysql/
trunk/db_modules/mysql/Makefile
trunk/db_modules/mysql/conf
trunk/db_modules/mysql/mysql.c
trunk/db_modules/mysql/mysql.h
trunk/db_modules/mysql/php/
trunk/db_modules/mysql/php/.htaccess
trunk/db_modules/mysql/php/chat-to.php
trunk/db_modules/mysql/php/chat.php
trunk/db_modules/mysql/php/class.ctl.php
trunk/db_modules/mysql/php/conf.php
trunk/db_modules/mysql/php/default.array.cmd.inc.php
trunk/db_modules/mysql/php/default.array.option.inc.php
trunk/db_modules/mysql/php/default.array.status.inc.php
trunk/db_modules/mysql/php/fl.inc.php
trunk/db_modules/mysql/php/group.inc.php
trunk/db_modules/mysql/php/header.inc.php
trunk/db_modules/mysql/php/imagens/
trunk/db_modules/mysql/php/imagens/ausente.gif
trunk/db_modules/mysql/php/imagens/block.gif
trunk/db_modules/mysql/php/imagens/notinlist.png
trunk/db_modules/mysql/php/imagens/ocupado.gif
trunk/db_modules/mysql/php/imagens/offline.gif
trunk/db_modules/mysql/php/imagens/online.gif
trunk/db_modules/mysql/php/imagens/send_im.gif
trunk/db_modules/mysql/php/imagens/webcam.png
trunk/db_modules/mysql/php/index.php
trunk/db_modules/mysql/php/js.inc.php
trunk/db_modules/mysql/php/lists.inc.php
trunk/db_modules/mysql/php/mysql.inc.php
trunk/db_modules/mysql/php/save_contact_op.php
trunk/db_modules/mysql/php/save_default_op.php
trunk/db_modules/mysql/php/save_msg.php
trunk/db_modules/mysql/php/save_user_op.php
trunk/db_modules/mysql/php/user.inc.php
trunk/db_modules/mysql/php/user.php
trunk/db_modules/mysql/php/view-to.php
trunk/db_modules/mysql/php/view.php
trunk/db_modules/mysql/sql.c
trunk/db_modules/mysql/sql.h
trunk/db_modules/mysql/tables/
trunk/db_modules/mysql/tables/contact_groups
trunk/db_modules/mysql/tables/contacts
trunk/db_modules/mysql/tables/defaults
trunk/db_modules/mysql/tables/log
trunk/db_modules/mysql/tables/sb
trunk/db_modules/mysql/tables/users
trunk/db_modules/pgsql/
trunk/db_modules/pgsql/Makefile
trunk/db_modules/pgsql/conf
trunk/db_modules/pgsql/pgsql.c
trunk/db_modules/pgsql/pgsql.h
trunk/db_modules/pgsql/php/
trunk/db_modules/pgsql/php/ajax.inc.php
trunk/db_modules/pgsql/php/al.inc.php
trunk/db_modules/pgsql/php/bl.inc.php
trunk/db_modules/pgsql/php/chat-to.php
trunk/db_modules/pgsql/php/chat.php
trunk/db_modules/pgsql/php/class.ctl.php
trunk/db_modules/pgsql/php/conf.php
trunk/db_modules/pgsql/php/default.array.cmd.inc.php
trunk/db_modules/pgsql/php/default.array.option.inc.php
trunk/db_modules/pgsql/php/default.array.status.inc.php
trunk/db_modules/pgsql/php/fl.inc.php
trunk/db_modules/pgsql/php/group.inc.php
trunk/db_modules/pgsql/php/header.inc.php
trunk/db_modules/pgsql/php/imagens/
trunk/db_modules/pgsql/php/imagens/ausente.gif
trunk/db_modules/pgsql/php/imagens/block.gif
trunk/db_modules/pgsql/php/imagens/notinlist.png
trunk/db_modules/pgsql/php/imagens/ocupado.gif
trunk/db_modules/pgsql/php/imagens/offline.gif
trunk/db_modules/pgsql/php/imagens/online.gif
trunk/db_modules/pgsql/php/imagens/send_im.gif
trunk/db_modules/pgsql/php/imagens/webcam.png
trunk/db_modules/pgsql/php/index.php
trunk/db_modules/pgsql/php/pgsql.inc.php
trunk/db_modules/pgsql/php/save_contact_op.php
trunk/db_modules/pgsql/php/save_default_op.php
trunk/db_modules/pgsql/php/save_msg.php
trunk/db_modules/pgsql/php/save_user_op.php
trunk/db_modules/pgsql/php/user.inc.php
trunk/db_modules/pgsql/php/user.php
trunk/db_modules/pgsql/php/view-to.php
trunk/db_modules/pgsql/php/view.php
trunk/db_modules/pgsql/sql.c
trunk/db_modules/pgsql/sql.h
trunk/db_modules/pgsql/tables/
trunk/db_modules/pgsql/tables/contact_groups
trunk/db_modules/pgsql/tables/contacts
trunk/db_modules/pgsql/tables/defaults
trunk/db_modules/pgsql/tables/log
trunk/db_modules/pgsql/tables/sb
trunk/db_modules/pgsql/tables/users
trunk/mysql/
trunk/mysql.c
trunk/mysql.h
trunk/ns-data.h
trunk/php/
trunk/sb-data.h
trunk/sql.c
trunk/sql.h
trunk/xml-data.h
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/dbmod:123-136
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2009-08-25 20:45:00 UTC (rev 136)
+++ trunk/Makefile 2009-09-01 11:23:43 UTC (rev 137)
@@ -1,37 +1,28 @@
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
+OBJS=base64.o check-cmd.o client.o command.o config.o contacts.o ctl.o db.o \
+ event.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
-LDFLAGS=-L/usr/local/lib -levent -L$(MYSQLLIB) -lmysqlclient
+INCLUDES=array_cmd.h base64.h check-cmd.h check-cmd-types.h client.h \
+ client-types.h command.h command-types.h config.h contacts.h \
+ contacts-types.h ctl.h db.h event.h fmt.h io.h msg.h msn-proxy.h \
+ msnp8.h msnp12.h msnp18.h ns.h ns-types.h net-io.h obj-types.h \
+ protocol.h return.h sb.h sig.h server.h server-types.h string.h \
+ syslog.h sb-types.h user.h user-types.h xml.h xml-types.h
-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
-
-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
-
-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 $<
@@ -40,9 +31,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)
Copied: trunk/base64.c (from rev 136, branches/dbmod/base64.c)
===================================================================
--- trunk/base64.c (rev 0)
+++ trunk/base64.c 2009-09-01 11:23:43 UTC (rev 137)
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2004, 2005, 2006, 2007, 2008
+ * 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.
+ */
+
+#include <strings.h>
+
+#include "base64.h"
+
+static const char rcsid[] = "$Id$";
+
+int
+find_ch(const char *str, char c) {
+ char *p;
+
+ p = (char *)str;
+ while (*p++) {
+ if (*p == c)
+ return(p - str);
+ }
+
+ return(0);
+}
+
+int
+b64decode(string *in, string *out) {
+ unsigned char a[4];
+ unsigned char b;
+ int i;
+ int j;
+
+ if (!in || in->len == 0)
+ return(-1);
+
+ for (i = 0; i < in->len; i += 4) {
+ for (j = 0; j < 4; j++) {
+ if ((i + j) < in->len && in->s[i + j] != B64PAD) {
+ a[j] = find_ch(base64, in->s[i + j]);
+ if (a[j] > 63)
+ return(-1);
+ } else
+ a[j] = 0;
+ }
+
+ b = (a[0] << 2) | (a[1] >> 4);
+ if (str_cat(out, &b, 1) == 0) exit(51);
+
+ if (in->s[i + 2] == B64PAD)
+ return(0);
+
+ b = (a[1] << 4) | (a[2] >> 2);
+ if (str_cat(out, &b, 1) == 0) exit(51);
+
+ if (in->s[i + 3] == B64PAD)
+ return(0);
+
+ b = (a[2] << 6) | a[3];
+ if (str_cat(out, &b, 1) == 0) exit(51);
+ }
+
+ return(0);
+}
+
+int
+b64encode(string *in, string *out) {
+ unsigned char a;
+ unsigned char b;
+ unsigned char c;
+ unsigned char o;
+ int i;
+
+ if (!in || in->len == 0)
+ return(-1);
+
+ for (i = 0; i < in->len; i += 3) {
+ a = in->s[i];
+ b = i + 1 < in->len ? in->s[i + 1] : 0;
+ c = i + 2 < in->len ? in->s[i + 2] : 0;
+
+ o = base64[a >> 2];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+
+ o = base64[((a & 3) << 4) | (b >> 4)];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+
+ if (i + 1 >= in->len)
+ o = B64PAD;
+ else
+ o = base64[((b & 15) << 2) | (c >> 6)];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+
+ if (i + 2 >= in->len)
+ o = B64PAD;
+ else
+ o = base64[c & 63];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+ }
+
+ return(0);
+}
+
+int
+b64mdecode(string *in, string *out) {
+ unsigned char a[4];
+ unsigned char o;
+ int i;
+ int j;
+
+ if (in->len == 0) {
+ if (str_copy(out, (unsigned char *)"", 1) == 0) exit(51);
+ return(-1);
+ }
+
+ for (i = 0; i < in->len; i += 4) {
+ for (j = 0; j < 4; j++) {
+ if ((i + j) < in->len) {
+ a[j] = find_ch(base64modified, in->s[i + j]);
+ if (a[j] > 63)
+ return(-1);
+ } else
+ a[j] = 0;
+ }
+
+ o = (a[0] << 2) | (a[1] >> 4);
+ if (o != 0) if (str_cat(out, &o, 1) == 0) exit(51);
+
+ o = (a[1] << 4) | (a[2] >> 2);
+ if (o != 0) if (str_cat(out, &o, 1) == 0) exit(51);
+
+ o = (a[2] << 6) | a[3];
+ if (o != 0) if (str_cat(out, &o, 1) == 0) exit(51);
+ }
+
+ return(0);
+}
+
+/*
+ * modified base64 for utf-7 use
+ */
+int
+b64mencode(string *in, string *out) {
+ unsigned char a;
+ unsigned char b;
+ unsigned char c;
+ unsigned char o;
+ int i;
+
+ if (in->len == 0) {
+ if (str_copy(out, (unsigned char *)"", 1) == 0) exit(51);
+ return(-1);
+ }
+
+ for (i = 0; i < in->len; i += 3) {
+
+ a = in->s[i];
+ b = i + 1 < in->len ? in->s[i + 1] : 0;
+ c = i + 2 < in->len ? in->s[i + 2] : 0;
+
+ o = base64modified[a >> 2];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+
+ o = base64modified[((a & 3) << 4) | (b >> 4)];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+
+ if (i + 1 >= in->len)
+ return(0);
+
+ o = base64modified[((b & 15) << 2) | (c >> 6)];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+
+ if (i + 2 >= in->len)
+ return(0);
+
+ o = base64modified[c & 63];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+ }
+
+ return(0);
+}
Copied: trunk/base64.h (from rev 136, branches/dbmod/base64.h)
===================================================================
--- trunk/base64.h (rev 0)
+++ trunk/base64.h 2009-09-01 11:23:43 UTC (rev 137)
@@ -0,0 +1,39 @@
+/*
+ * 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$
+ */
+
+#ifndef BASE64_H
+#define BASE64_H
+
+#include "string.h"
+
+static const char base64[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char base64modified[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
+#define B64PAD '='
+
+int find_ch(const char *str, char c);
+int b64decode(string *in, string *out);
+int b64encode(string *in, string *out);
+int b64mdecode(string *in, string *out);
+int b64mencode(string *in, string *out);
+
+#endif
+
Copied: trunk/check-cmd-types.h (from rev 136, branches/dbmod/check-cmd-types.h)
===================================================================
--- trunk/check-cmd-types.h (rev 0)
+++ trunk/check-cmd-types.h 2009-09-01 11:23:43 UTC (rev 137)
@@ -0,0 +1,46 @@
+/*
+ * 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$
+ */
+
+#ifndef CHECK_CMD_TYPES_H
+#define CHECK_CMD_TYPES_H
+
+typedef struct {
+ char *cmd;
+ int (*func)(struct user_ *user, command *cmd);
+} CMD;
+
+typedef struct {
+ unsigned int type;
+ char *label;
+ CMD *cmd;
+} CMDS_;
+
+typedef struct {
+ char *cmd;
+ int (*func)(struct sb_ *sb, command *cmd);
+} SBCMD;
+
+typedef struct {
+ unsigned int type;
+ char *label;
+ SBCMD *sbcmd;
+} SBCMDS_;
+
+#endif
Modified: trunk/check-cmd.c
===================================================================
--- trunk/check-cmd.c 2009-08-25 20:45:00 UTC (rev 136)
+++ trunk/check-cmd.c 2009-09-01 11:23:43 UTC (rev 137)
@@ -17,53 +17,25 @@
static const char rcsid[] = "$Id$";
#include <errno.h>
-#include <stdio.h>
#include <string.h>
-#include "io.h"
-#include "sb.h"
-#include "client.h"
-#include "server.h"
-#include "return.h"
#include "syslog.h"
+#include "return.h"
#include "protocol.h"
+#include "check-cmd.h"
#include "msn-proxy.h"
+/* default */
CMD PRE_CMDS[] = {
- { "VER", 0, msn_get_ver },
- { NULL, 0, NULL }
+ { "VER", msn_get_ver },
+ { NULL, NULL }
};
-int check_ok(struct user_ *user, command *cmd, int args) { return(ROK); }
-
-int _check_args(command *cmd, int args) {
-
- if ( strcmp((char *)cmd->cmd.s, "BYE") == 0 && cmd->args_len >=1 ) {
- return(ROK);
- }
-
- if (args != cmd->args_len) {
- io_printf(1, "numero de args: [%d] != [%d]\n", args, cmd->args_len);
- print_command(cmd);
- return(RFAIL);
- }
- return(ROK);
-}
-
-int check_args(struct user_ *user, command *cmd, int args) {
- return(_check_args(cmd, args));
-}
-
-int check_sb_args(struct sb_ *sb, command *cmd, int args) {
- return(_check_args(cmd, args));
-}
-
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;
+ CMDS_ *cmds_ = NULL;
+ CMD *cmds = NULL;
char *label = "";
char *ep;
@@ -80,7 +52,7 @@
if (user->version == 0)
cmds = PRE_CMDS;
- if (cmds == (CMD *)0) {
+ if (cmds == NULL) {
log->debug("unknown protocol type [%d] / version [%d]\n", type,
user->version);
return(RFAIL);
@@ -91,11 +63,13 @@
erro = strtoul((char *)cmd->cmd.s, &ep, 10);
if (errno == 0 && *cmd->cmd.s && (ep && *ep == 0)) {
- /* ignore the 241, 508, 509 and 511 commands */
- if (erro != 511 && erro != 509 && erro != 508 && erro != 241) {
- log->debug("===> warning error received\n");
- return(ROK);
- }
+ /*
+ * just let the error pass through
+ * let the client disconnect gracefully (if needed - some errors are
+ * just ignored or don't imply the disconnection)
+ */
+ log->debug("===> warning error received\n");
+ return(ROK);
}
/* dispatch command */
@@ -104,7 +78,9 @@
//io_printf(1, "%S: [%S] == [%s]\n", label, cmds->cmd, &cmd->cmd);
if (strncmp(cmds->cmd, (char *)cmd->cmd.s, cmd->cmd.len) == 0) {
//print_command(cmd);
- return(cmds->func(user, cmd, cmds->args));
+ if (cmds->func != NULL)
+ return(cmds->func(user, cmd));
+ return(ROK);
}
}
@@ -125,7 +101,6 @@
unsigned long erro = 0;
SBCMDS_ *cmds_ = (SBCMDS_ *)0;
SBCMD *cmds = (SBCMD *)0;
- log_ *log = &config.log;
char *label = "";
char *ep;
@@ -158,18 +133,11 @@
//io_printf(1, "%S: [%S] == [%s]\n", label, cmds->cmd, &cmd->cmd);
if (strncmp(cmds->cmd, (char *)cmd->cmd.s, cmd->cmd.len) == 0) {
//print_command(cmd);
- return(cmds->func(sb, cmd, cmds->args));
+ if (cmds->func != NULL)
+ return(cmds->func(sb, cmd));
+ break;
}
}
- /* post commands cannot drop connection */
- switch (type) {
- case SERVER_SB_POST_CMD:
- case CLIENT_SB_POST_CMD:
- return(ROK);
- }
-
- log->debug("debug: %S command blocked: ", label);
- print_command(cmd);
- return(RFAIL);
+ return(ROK);
}
Modified: trunk/check-cmd.h
===================================================================
--- trunk/check-cmd.h 2009-08-25 20:45:00 UTC (rev 136)
+++ trunk/check-cmd.h 2009-09-01 11:23:43 UTC (rev 137)
@@ -21,34 +21,9 @@
#ifndef CHECK_CMD_H
#define CHECK_CMD_H
-typedef struct {
- char *cmd;
- int args;
- int (*func)(struct user_ *user, command *cmd, int args);
-} CMD;
+#include "user-types.h"
-typedef struct {
- __uint32_t type;
- char *label;
- CMD *cmd;
-} CMDS_;
-
-typedef struct {
- char *cmd;
- int args;
- int (*func)(struct sb_ *sb, command *cmd, int args);
-} SBCMD;
-
-typedef struct {
- __uint32_t type;
- char *label;
- SBCMD *sbcmd;
-} SBCMDS_;
-
-int check_ok(struct user_ *user, command *cmd, int args);
int check_cmd(struct user_ *user, command *cmd, int type);
int check_sb_cmd(struct sb_ *sb, command *cmd, int type);
-int check_args(struct user_ *user, command *cmd, int args);
-int check_sb_args(struct sb_ *sb, command *cmd, int args);
#endif
Copied: trunk/client-types.h (from rev 136, branches/dbmod/client-types.h)
===================================================================
--- trunk/client-types.h (rev 0)
+++ trunk/client-types.h 2009-09-01 11:23:43 UTC (rev 137)
@@ -0,0 +1,44 @@
+/*
+ * 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$
+ */
+
+#ifndef CLIENT_TYPES_H
+#define CLIENT_TYPES_H
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <event.h>
+
+#include "string.h"
+#include "command-types.h"
+
+struct client_ {
+ int fd; /* client connection fd */
+ size_t sent; /* bytes already sent to client */
+ string host; /* host address */
+ string obuf; /* output buffer */
+ string *xfr; /* old xfr address */
+ commands commands; /* command queue */
+ struct event read; /* event queues */
+ struct event write; /* - */
+ struct event listen; /* - */
+};
+
+#endif
Modified: trunk/client.c
===================================================================
--- trunk/client.c 2009-08-25 20:45:00 UTC (rev 136)
+++ trunk/client.c 2009-09-01 11:23:43 UTC (rev 137)
@@ -24,33 +24,37 @@
#include <string.h>
#include <unistd.h>
+#include "event.h"
#include "client.h"
#include "return.h"
+#include "command.h"
#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));
+ client->read.ev_fd = -1;
+ client->write.ev_fd = -1;
+ client->listen.ev_fd = -1;
/* prepare commands */
commands_init(&client->commands);
@@ -58,22 +62,52 @@
/* set fd */
client->fd = client_fd;
+ /* attach client functions */
+ client_attach(client, fn_read, fn_write, arg);
+
+ return(client);
+}
+
+struct client_ *
+client_alloc2(void) {
+ struct client_ *client;
+
+ client = (struct client_ *)malloc(sizeof(*client));
+ if (client == NULL) die_nomem();
+ memset(client, 0, sizeof(*client));
+
+ client->fd = -1;
+ client->read.ev_fd = -1;
+ client->write.ev_fd = -1;
+ client->listen.ev_fd = -1;
+
+ /* prepare commands */
+ commands_init(&client->commands);
+
+ return(client);
+}
+
+void
+client_attach( struct client_ *client,
+ void (*fn_read)(int, short, void *),
+ void (*fn_write)(int, short, void *),
+ void *arg) {
+
/* set events */
event_set(&client->read, client->fd, EV_READ, fn_read, arg);
event_set(&client->write, client->fd, EV_WRITE, fn_write, arg);
/* sched read */
client_sched_read(client);
-
- return(client);
}
int
-client_flush_commands(client_ *client) {
- command *cmd = client->commands.cmd;
- command *next;
+client_cleanup_commands(struct client_ *client) {
+ command *cmd;
+ command *next;
/* clean commands */
+ cmd = client->commands.cmd;
while (cmd) {
next = cmd->next;
free_command(cmd);
@@ -81,8 +115,8 @@
}
/* reset pointers */
- client->commands.cmd = (command *)0;
- client->commands.cmd_last = (command *)0;
+ client->commands.cmd = NULL;
+ client->commands.cmd_last = NULL;
/* clean rx buffer */
str_free(&client->commands.buf);
@@ -90,25 +124,32 @@
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 host address */
+ str_free(&client->host);
+
+ /* free the output buffer */
+ str_free(&client->obuf);
+
+ /* 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,10 +169,103 @@
}
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;
+ if (client->commands.cmd == NULL)
+ client->commands.cmd_last = NULL;
+}
+
+int
+client_send_command(struct client_ *client, struct user_ *user,
+ command *cmd, const char *to) {
+
+ switch (cmd->fase) {
+
+ case 0:
+
+ /* prepare the command to send */
+ send_command(cmd, &client->obuf, &user->email, to);
+
+ cmd->fase = 1;
+ /* fallthrough */
+
+ case 1:
+
+ /* write the command to the client */
+ switch (client_write_command(client, user)) {
+
+ case -2: return(AGAIN);
+ case -1:
+ log->debug("debug: %s: write fail: [%S] buf: [%s][%d]\n",
+ &user->email, strerror(errno), &client->obuf,
+ client->obuf.len);
+ str_free(&client->obuf);
+ cmd->fase = 0;
+ return(RFAIL);
+ }
+
+ cmd->fase = 0;
}
+
+ return(ROK);
}
+int
+client_write_command(struct client_ *client, struct user_ *user) {
+ size_t len;
+
+ if (client->obuf.len - client->sent <= 0) {
+ log->debug("debug: %s: wrong number of bytes to send (connection closed)\n",
+ &user->email);
+ return(-1);
+ }
+
+ len = write(client->fd, (char *)client->obuf.s + client->sent,
+ client->obuf.len - client->sent);
+ if (len == -1) {
+ if (errno == EINTR || errno == EAGAIN) {
+ /* schedule another write - would block */
+ return(-2);
+ }
+ log->debug("debug: %s: cannot write to sb client (connection closed) "
+ "[%s:%s] fd: %d\n", &user->email, &user->host, &user->port,
+ client->fd);
+ return(-1);
+ }
+ client->sent += len;
+
+ if (client->sent < client->obuf.len) {
+
+ /* schedule another write - there is more to write */
+ return(-2);
+ }
+
+ /* reset output buffer */
+ client->sent = 0;
+ client->obuf.len = 0;
+
+ return(0);
+}
+
+void
+client_stat(struct client_ *client) {
+
+ log->debug("client fd.............: [%d]\n", client->fd);
+ if (client->host.len > 0)
+ log->debug("client host...........: [%s]\n", &client->host);
+ if (client->xfr != NULL && client->xfr->len > 0)
+ log->debug("client xfr............: [%s]\n", client->xfr);
+ if (client->obuf.len > 0) {
+ log->debug("client output buffer..: [%s][%d]\n", &client->obuf,
+ client->obuf.len);
+ }
+ log->debug("client already sent...: [%d]\n", client->sent);
+
+ /* print the command information */
+ commands_stat(&client->commands);
+
+ msn_ev_stat(&client->read, "client event read");
+ msn_ev_stat(&client->write, "client event write");
+ msn_ev_stat(&client->listen, "client event listen");
+}
Modified: trunk/client.h
===================================================================
--- trunk/client.h 2009-08-25 20:45:00 UTC (rev 136)
+++ trunk/client.h 2009-09-01 11:23:43 UTC (rev 137)
@@ -21,36 +21,28 @@
#ifndef CLIENT_H
#define CLIENT_H
-#include <sys/types.h>
-#include <sys/time.h>
+#include "user-types.h"
+#include "client-types.h"
-#include <event.h>
-
-#include "command.h"
-
-typedef 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_alloc2(void);
+void client_attach(struct client_ *client, 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);
+int client_send_command(struct client_ *client, struct user_ *user,
+ command *cmd, const char *to);
+int client_write_command(struct client_ *client, struct user_ *user);
+void client_stat(struct client_ *client);
#endif
Copied: trunk/command-types.h (from rev 136, branches/dbmod/command-types.h)
===================================================================
--- trunk/command-types.h (rev 0)
+++ trunk/command-types.h 2009-09-01 11:23:43 UTC (rev 137)
@@ -0,0 +1,47 @@
+/*
+ * 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$
+ */
+
+#ifndef COMMAND_TYPES_H
+#define COMMAND_TYPES_H
+
+#include "string.h"
+
+typedef struct _command {
+ int ignore;
+ int fase;
+ string cmd;
+ string **args;
+ string payload;
+ unsigned int args_len;
+ unsigned long trid;
+ struct _command *next;
+} command;
+
+typedef struct _commands {
+ string buf; /* io command buffer */
+ string *arg; /* tmp pointer to last arg */
+ size_t payload_size; /* payload size */
+ unsigned int state; /* command state */
+ struct _command *tmp; /* tmp pointer to ongoing command */
+ struct _command *cmd; /* linked list to ready commands */
+ struct _command *cmd_last; /* pointer to last entry on list */
+} commands;
+
+#endif
Modified: trunk/command.c
===================================================================
--- trunk/command.c 2009-08-25 20:45:00 UTC (rev 136)
+++ trunk/command.c 2009-09-01 11:23:43 UTC (rev 137)
@@ -19,8 +19,8 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
-#include "io.h"
#include "return.h"
#include "command.h"
#include "protocol.h"
@@ -56,14 +56,15 @@
cmd->trid = 0;
}
-__uint32_t
+unsigned int
has_payload(command *cmd) {
- long rtrn;
+ unsigned int rtrn;
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 &&
@@ -95,7 +96,7 @@
if (cmd->args_len < 1)
return(0);
- rtrn = (__uint32_t)atoi((char *)cmd->args[cmd->args_len - 1]->s);
+ rtrn = (unsigned int)strtoul((char *)cmd->args[cmd->args_len - 1]->s, NULL, 10);
return(rtrn);
}
@@ -142,16 +143,15 @@
*/
int
command_fill_buffer(int fd, string *buf) {
- log_ *log = &config.log;
/* empty buffer */
if (buf->len == 0) {
/* read buffer */
- buf->len = io_read(fd, (char *)buf->s, buf->a);
+ buf->len = read(fd, (char *)buf->s, buf->a);
if (buf->len == -1) {
- if (errno == EAGAIN)
+ if (errno == EAGAIN || errno == EINTR)
return(-2);
str_reset(buf);
@@ -162,9 +162,6 @@
buf->p = buf->s;
}
- if (buf->len == 0)
- return(0);
-
return(buf->len);
}
@@ -315,7 +312,6 @@
int
read_command(commands *cmds, int fd, void (*sched_write)(), void *ev_write) {
- log_ *log = &config.log;
for (;;) {
@@ -382,7 +378,6 @@
void
print_command(command *cmd) {
- log_ *log = &config.log;
string **arg;
log->debug("%s ", &cmd->cmd);
@@ -399,7 +394,6 @@
void
print_client_command(string *email, command *cmd) {
- log_ *log = &config.log;
if (email)
log->debug("[%s] from client: ", email);
@@ -410,7 +404,6 @@
void
print_server_command(string *email, command *cmd) {
- log_ *log = &config.log;
if (email)
log->debug("[%s] from server: ", email);
@@ -437,83 +430,53 @@
void
free_command(command *cmd) {
str_free(&cmd->cmd);
- str_free(&cmd->obuf);
str_free(&cmd->payload);
free_command_args(cmd);
free(cmd);
}
-int
-send_command(int tofd, command *cmd, string *email, const char *to) {
- log_ *log = &config.log;
+void
+send_command(command *cmd, string *obuf, string *email, const char *to) {
string **arg = cmd->args;
+ string buf;
- switch (cmd->fase) {
+ /* put command on buffer */
+ str_zero(&buf);
+ if (str_copy(&buf, cmd->cmd.s, cmd->cmd.len) == 0)
+ die_nomem();
- case 0:
+ /* send args */
+ while (arg && *arg) {
- /* put command on buffer */
- str_zero(&cmd->obuf);
- if (str_copy(&cmd->obuf, cmd->cmd.s, cmd->cmd.len) == 0)
- die_nomem();
+ if (str_cat(&buf, (unsigned char *)" ", 1) == 0)
+ die_nomem();
+ if (str_cat(&buf, (*arg)->s, (*arg)->len) == 0)
+ die_nomem();
- /* send args */
- while (arg && *arg) {
+ ++arg;
+ }
- if (str_cat(&cmd->obuf, (unsigned char *)" ", 1) == 0)
- die_nomem();
- if (str_cat(&cmd->obuf, (*arg)->s, (*arg)->len) == 0)
- die_nomem();
+ /* end of line */
+ if (str_cat(&buf, (unsigned char *)"\r\n", 2) == 0)
+ die_nomem();
- ++arg;
- }
+ if (cmd->payload.len > 0 &&
+ str_cat(&buf, cmd->payload.s, cmd->payload.len) == 0) {
+ die_nomem();
+ }
- /* end of line */
- if (str_cat(&cmd->obuf, (unsigned char *)"\r\n", 2) == 0)
- die_nomem();
+ log->protocol("[%s] send to %S ==> %s", email, to, &buf);
+ log->protocol("\n");
- if (cmd->payload.len > 0) {
- if (str_cat(&cmd->obuf, cmd->payload.s, cmd->payload.len) == 0)
- die_nomem();
- }
+ if (buf.len > 0 && str_cat(obuf, buf.s, buf.len) == 0)
+ die_nomem();
- cmd->fase = 1;
- /* fallthrough */
-
- case 1:
-
- /* write command */
- switch (io_write(tofd, (char *)cmd->obuf.s, cmd->obuf.len)) {
-
- case -2:
- return(AGAIN);
-
- case -1:
- log->debug("write fail: [%S] buf: [%s][%d]\n", strerror(errno),
- &cmd->obuf, cmd->obuf.len);
- str_free(&cmd->obuf);
- cmd->fase = 0;
- return(RFAIL);
-
- default: break;
- }
-
- cmd->fase = 2;
- /* fallthrough */
-
- case 2:
-
- log->protocol("[%s] send to %S ==> %s", email, to, &cmd->obuf);
- log->protocol("\n");
- str_free(&cmd->obuf);
- cmd->fase = 0;
- }
-
- return(ROK);
+ str_free(&buf);
}
void
commands_add_command(commands *cmds, command *cmd) {
+
/* tailq add */
if (cmds->cmd_last)
cmds->cmd_last->next = cmd;
@@ -534,3 +497,88 @@
memset(cmds->buf.s, 0, cmds->buf.a);
cmds->state = COMMAND;
}
+
+void
+commands_print_state(unsigned int state) {
+ int space = 0;
+
+ log->debug("<");
+ if (state & ARG) {
+ log->debug("ARG"); space++;
+ }
+ if (state & EOC) {
+ if (space) log->debug(" ");
+ log->debug("EOC"); space++;
+ }
+ if (state & COMMAND) {
+ if (space) log->debug(" ");
+ log->debug("COMMAND"); space++;
+ }
+ if (state & PAYLOAD) {
+ if (space) log->debug(" ");
+ log->debug("PAYLOAD"); space++;
+ }
+ log->debug(">\n");
+}
+
+void
+command_stat(command *cmd, char *debug) {
+ string **arg;
+ int i;
+
+ if (debug != NULL)
+ log->debug(" -- %S --\n", debug);
+
+ log->debug("command addr..........: [0x%x]\n", cmd);
+ log->debug("command ignore........: [%d]\n", cmd->ignore);
+ log->debug("command fase..........: [%d]\n", cmd->fase); /* XXX */
+// log->debug("command obuf..........: [%s]\n", &cmd->obuf); /* XXX */
+ log->debug("command trid..........: [%d]\n", cmd->trid);
+ log->debug("command cmd...........: [%s][%d]\n", &cmd->cmd, cmd->cmd.len);
+ log->debug("command args len......: [%d]\n", cmd->args_len);
+
+ i = 1;
+ arg = cmd->args;
+ while (arg && *arg) {
+ log->debug("command arg...........: [%d][%s][%d] (idx/data/size)\n",
+ i++, *arg, (*arg)->len);
+ ++arg;
+ }
+
+ if (cmd->payload.len > 0) {
+ log->debug("command payload.......: [%s][%d]\n", &cmd->payload,
+ cmd->payload.len);
+ }
+ log->debug("command next..........: [0x%x]\n", cmd->next);
+}
+
+void
+commands_stat(commands *cmds) {
+ command *cmd;
+ command *next;
+
+ log->debug(" -- commands information --\n");
+
+ log->debug("commands state........: ");
+ commands_print_state(cmds->state);
+
+ if (cmds->buf.len > 0) {
+ log->debug("commands input buf.s..: [%s]\n", &cmds->buf);
+ log->debug("commands input buf.p..: [%p]\n", &cmds->buf);
+ }
+
+ if (cmds->arg != NULL && cmds->arg->len > 0)
+ log->debug("commands next arg.....: [%s]\n", cmds->arg);
+
+ log->debug("commands payload size.: [%d]\n", cmds->payload_size);
+
+ if (cmds->tmp)
+ command_stat(cmds->tmp, "temporary command");
+
+ cmd = cmds->cmd;
+ while (cmd) {
+ next = cmd->next;
+ command_stat(cmd, "command");
+ cmd = next;
+ }
+}
Modified: trunk/command.h
===================================================================
--- trunk/command.h 2009-08-25 20:45:00 UTC (rev 136)
+++ trunk/command.h 2009-09-01 11:23:43 UTC (rev 137)
@@ -22,6 +22,7 @@
#define COMMAND_H
#include "string.h"
+#include "sb-types.h"
#define CMD_BUF 512
@@ -31,35 +32,11 @@
#define ARG 0x0004
#define EOC 0x0008
#define SENDMASK 0xff00
-#define SENDDELAY 0x0100
-typedef struct _command {
- int ignore;
- int fase;
- string obuf;
- string cmd;
- string **args;
- string payload;
- unsigned int args_len;
- unsigned long trid;
- struct _command *next;
-} command;
-
-typedef struct _commands {
- string buf; /* io command buffer */
- string *arg; /* tmp pointer to last arg */
- __uint32_t wait; /* trid to wait */
- __uint32_t state; /* command state */
- __uint32_t payload_size; /* payload size */
- struct _command *tmp; /* tmp pointer to ongoing command */
- struct _command *cmd; /* linked list to ready commands */
- struct _command *cmd_last; /* pointer to last entry on list */
-} commands;
-
#define HAS_CMD(p) (p->commands.cmd != NULL)
command *command_alloc(void);
-__uint32_t has_payload(command *cmd);
+unsigned int has_payload(command *cmd);
string **args_alloc(void *ptr, size_t len);
string *command_add_arg(command *cmd);
void has_trid(command *cmd);
@@ -70,7 +47,9 @@
void print_client_command(string *email, command *cmd);
void print_server_command(string *email, command *cmd);
void commands_add_command(commands *cmds, command *cmd);
-int send_command(int tofd, command *cmd, string *email, const char *to);
+void send_command(command *cmd, string *obuf, string *email, const char *to);
int read_command(commands *cmds, int fd, void (*sched_write)(), void *ev_write);
+void commands_print_state(unsigned int state);
+void commands_stat(commands *cmds);
#endif
Modified: trunk/config.c
===================================================================
--- trunk/config.c 2009-08-25 20:45:00 UTC (rev 136)
+++ trunk/config.c 2009-09-01 11:23:43 UTC (rev 137)
@@ -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)
+ die_nomem();
- 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) die_nomem();
}
-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,12 +277,17 @@
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");
- log->debug("log messages : %S\n",
- (defaults->save_msg == YES) ? "YES" : "NO");
- log->debug("save_contacts : %S\n",
+ log->debug("save contacts : %S\n",
(defaults->save_contacts == YES) ? "YES" : "NO");
+ log->debug("save messages : %S\n",
+ (defaults->save_msg == YES) ? "YES" : "NO");
log->debug("\n");
}
Modified: trunk/config.h
===================================================================
--- trunk/config.h 2009-08-25 20:45:00 UTC (rev 136)
+++ trunk/config.h 2009-09-01 11:23:43 UTC (rev 137)
@@ -26,7 +26,6 @@
#include "tree.h"
#include "string.h"
-#include "mysql.h"
#include "syslog.h"
#ifndef READONLY
@@ -34,67 +33,59 @@
#endif
#ifndef DEFAULT_CONFIG_FILE
-#define DEFAULT_CONFIG_FILE "msn-proxy.conf"
+#define DEFAULT_CONFIG_FILE "/usr/local/etc/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;
-} ...
[truncated message content] |
|
From: <lo...@us...> - 2009-08-25 20:45:16
|
Revision: 136
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=136&view=rev
Author: loos-br
Date: 2009-08-25 20:45:00 +0000 (Tue, 25 Aug 2009)
Log Message:
-----------
sempre sobra alguma coisa...
Modified Paths:
--------------
branches/dbmod/client.c
branches/dbmod/server.c
Modified: branches/dbmod/client.c
===================================================================
--- branches/dbmod/client.c 2009-08-25 20:37:59 UTC (rev 135)
+++ branches/dbmod/client.c 2009-08-25 20:45:00 UTC (rev 136)
@@ -139,6 +139,9 @@
/* free host address */
str_free(&client->host);
+ /* free the output buffer */
+ str_free(&client->obuf);
+
/* free client */
free(client);
@@ -225,7 +228,7 @@
/* schedule another write - would block */
return(-2);
}
- log->debug("debug: %s: cannot write to sb server (connection closed) "
+ log->debug("debug: %s: cannot write to sb client (connection closed) "
"[%s:%s] fd: %d\n", &user->email, &user->host, &user->port,
client->fd);
return(-1);
Modified: branches/dbmod/server.c
===================================================================
--- branches/dbmod/server.c 2009-08-25 20:37:59 UTC (rev 135)
+++ branches/dbmod/server.c 2009-08-25 20:45:00 UTC (rev 136)
@@ -80,12 +80,16 @@
/* close connection */
server_close(server);
- /* clean commands */
+ /* free commands */
server_cleanup_commands(server);
- /* clean ns host and port and free memory */
+ /* free ns host and port and free memory */
str_free(&server->host);
str_free(&server->port);
+
+ /* free the output buffer */
+ str_free(&server->obuf);
+
free(server);
return(NULL);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lo...@us...> - 2009-08-25 20:38:10
|
Revision: 135
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=135&view=rev
Author: loos-br
Date: 2009-08-25 20:37:59 +0000 (Tue, 25 Aug 2009)
Log Message:
-----------
- algumas corrrecoes/atualizacoes de codigo
- mudanca do buffer de saida da estrutura de comando (?) para as estruturas
server e client
- mudanca na forma de escrita do buffer para o uso do write() de forma
assincrona (como deveria ser desde o comeco)
(agora falta pouco... ufa !)
Modified Paths:
--------------
branches/dbmod/Makefile
branches/dbmod/check-cmd.c
branches/dbmod/check-cmd.h
branches/dbmod/client.c
branches/dbmod/client.h
branches/dbmod/command.c
branches/dbmod/command.h
branches/dbmod/contacts.h
branches/dbmod/ctl.h
branches/dbmod/db.h
branches/dbmod/db_modules/mysql/mysql.c
branches/dbmod/db_modules/mysql/sql.c
branches/dbmod/db_modules/pgsql/pgsql.c
branches/dbmod/db_modules/pgsql/sql.c
branches/dbmod/ns.c
branches/dbmod/ns.h
branches/dbmod/protocol.c
branches/dbmod/sb.c
branches/dbmod/sb.h
branches/dbmod/server.c
branches/dbmod/server.h
branches/dbmod/user.c
branches/dbmod/user.h
branches/dbmod/xml.h
Added Paths:
-----------
branches/dbmod/check-cmd-types.h
branches/dbmod/client-types.h
branches/dbmod/command-types.h
branches/dbmod/contacts-types.h
branches/dbmod/ns-types.h
branches/dbmod/sb-types.h
branches/dbmod/server-types.h
branches/dbmod/user-types.h
branches/dbmod/xml-types.h
Removed Paths:
-------------
branches/dbmod/contacts-data.h
branches/dbmod/ns-data.h
branches/dbmod/sb-data.h
branches/dbmod/xml-data.h
Modified: branches/dbmod/Makefile
===================================================================
--- branches/dbmod/Makefile 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/Makefile 2009-08-25 20:37:59 UTC (rev 135)
@@ -12,11 +12,12 @@
event.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=array_cmd.h base64.h check-cmd.h client.h command.h config.h \
- contacts.h contacts-data.h ctl.h db.h event.h fmt.h io.h msg.h \
- msn-proxy.h msnp8.h msnp12.h msnp18.h ns.h ns-data.h net-io.h \
- obj-types.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 base64.h check-cmd.h check-cmd-types.h client.h \
+ client-types.h command.h command-types.h config.h contacts.h \
+ contacts-types.h ctl.h db.h event.h fmt.h io.h msg.h msn-proxy.h \
+ msnp8.h msnp12.h msnp18.h ns.h ns-types.h net-io.h obj-types.h \
+ protocol.h return.h sb.h sig.h server.h server-types.h string.h \
+ syslog.h sb-types.h user.h user-types.h xml.h xml-types.h
all: msn-proxy
Added: branches/dbmod/check-cmd-types.h
===================================================================
--- branches/dbmod/check-cmd-types.h (rev 0)
+++ branches/dbmod/check-cmd-types.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -0,0 +1,46 @@
+/*
+ * 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$
+ */
+
+#ifndef CHECK_CMD_TYPES_H
+#define CHECK_CMD_TYPES_H
+
+typedef struct {
+ char *cmd;
+ int (*func)(struct user_ *user, command *cmd);
+} CMD;
+
+typedef struct {
+ unsigned int type;
+ char *label;
+ CMD *cmd;
+} CMDS_;
+
+typedef struct {
+ char *cmd;
+ int (*func)(struct sb_ *sb, command *cmd);
+} SBCMD;
+
+typedef struct {
+ unsigned int type;
+ char *label;
+ SBCMD *sbcmd;
+} SBCMDS_;
+
+#endif
Property changes on: branches/dbmod/check-cmd-types.h
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/check-cmd.c
===================================================================
--- branches/dbmod/check-cmd.c 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/check-cmd.c 2009-08-25 20:37:59 UTC (rev 135)
@@ -19,12 +19,10 @@
#include <errno.h>
#include <string.h>
-#include "sb.h"
-#include "client.h"
-#include "server.h"
-#include "return.h"
#include "syslog.h"
+#include "return.h"
#include "protocol.h"
+#include "check-cmd.h"
#include "msn-proxy.h"
/* default */
@@ -54,7 +52,7 @@
if (user->version == 0)
cmds = PRE_CMDS;
- if (cmds == (CMD *)0) {
+ if (cmds == NULL) {
log->debug("unknown protocol type [%d] / version [%d]\n", type,
user->version);
return(RFAIL);
Modified: branches/dbmod/check-cmd.h
===================================================================
--- branches/dbmod/check-cmd.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/check-cmd.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -21,28 +21,8 @@
#ifndef CHECK_CMD_H
#define CHECK_CMD_H
-typedef struct {
- char *cmd;
- int (*func)(struct user_ *user, command *cmd);
-} CMD;
+#include "user-types.h"
-typedef struct {
- unsigned int type;
- char *label;
- CMD *cmd;
-} CMDS_;
-
-typedef struct {
- char *cmd;
- int (*func)(struct sb_ *sb, command *cmd);
-} SBCMD;
-
-typedef struct {
- unsigned int type;
- char *label;
- SBCMD *sbcmd;
-} SBCMDS_;
-
int check_cmd(struct user_ *user, command *cmd, int type);
int check_sb_cmd(struct sb_ *sb, command *cmd, int type);
Added: branches/dbmod/client-types.h
===================================================================
--- branches/dbmod/client-types.h (rev 0)
+++ branches/dbmod/client-types.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -0,0 +1,44 @@
+/*
+ * 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$
+ */
+
+#ifndef CLIENT_TYPES_H
+#define CLIENT_TYPES_H
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <event.h>
+
+#include "string.h"
+#include "command-types.h"
+
+struct client_ {
+ int fd; /* client connection fd */
+ size_t sent; /* bytes already sent to client */
+ string host; /* host address */
+ string obuf; /* output buffer */
+ string *xfr; /* old xfr address */
+ commands commands; /* command queue */
+ struct event read; /* event queues */
+ struct event write; /* - */
+ struct event listen; /* - */
+};
+
+#endif
Property changes on: branches/dbmod/client-types.h
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/client.c
===================================================================
--- branches/dbmod/client.c 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/client.c 2009-08-25 20:37:59 UTC (rev 135)
@@ -27,6 +27,7 @@
#include "event.h"
#include "client.h"
#include "return.h"
+#include "command.h"
#include "msn-proxy.h"
void
@@ -172,6 +173,78 @@
client->commands.cmd_last = NULL;
}
+int
+client_send_command(struct client_ *client, struct user_ *user,
+ command *cmd, const char *to) {
+
+ switch (cmd->fase) {
+
+ case 0:
+
+ /* prepare the command to send */
+ send_command(cmd, &client->obuf, &user->email, to);
+
+ cmd->fase = 1;
+ /* fallthrough */
+
+ case 1:
+
+ /* write the command to the client */
+ switch (client_write_command(client, user)) {
+
+ case -2: return(AGAIN);
+ case -1:
+ log->debug("debug: %s: write fail: [%S] buf: [%s][%d]\n",
+ &user->email, strerror(errno), &client->obuf,
+ client->obuf.len);
+ str_free(&client->obuf);
+ cmd->fase = 0;
+ return(RFAIL);
+ }
+
+ cmd->fase = 0;
+ }
+
+ return(ROK);
+}
+
+int
+client_write_command(struct client_ *client, struct user_ *user) {
+ size_t len;
+
+ if (client->obuf.len - client->sent <= 0) {
+ log->debug("debug: %s: wrong number of bytes to send (connection closed)\n",
+ &user->email);
+ return(-1);
+ }
+
+ len = write(client->fd, (char *)client->obuf.s + client->sent,
+ client->obuf.len - client->sent);
+ if (len == -1) {
+ if (errno == EINTR || errno == EAGAIN) {
+ /* schedule another write - would block */
+ return(-2);
+ }
+ log->debug("debug: %s: cannot write to sb server (connection closed) "
+ "[%s:%s] fd: %d\n", &user->email, &user->host, &user->port,
+ client->fd);
+ return(-1);
+ }
+ client->sent += len;
+
+ if (client->sent < client->obuf.len) {
+
+ /* schedule another write - there is more to write */
+ return(-2);
+ }
+
+ /* reset output buffer */
+ client->sent = 0;
+ client->obuf.len = 0;
+
+ return(0);
+}
+
void
client_stat(struct client_ *client) {
@@ -180,6 +253,11 @@
log->debug("client host...........: [%s]\n", &client->host);
if (client->xfr != NULL && client->xfr->len > 0)
log->debug("client xfr............: [%s]\n", client->xfr);
+ if (client->obuf.len > 0) {
+ log->debug("client output buffer..: [%s][%d]\n", &client->obuf,
+ client->obuf.len);
+ }
+ log->debug("client already sent...: [%d]\n", client->sent);
/* print the command information */
commands_stat(&client->commands);
Modified: branches/dbmod/client.h
===================================================================
--- branches/dbmod/client.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/client.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -21,23 +21,9 @@
#ifndef CLIENT_H
#define CLIENT_H
-#include <sys/types.h>
-#include <sys/time.h>
+#include "user-types.h"
+#include "client-types.h"
-#include <event.h>
-
-#include "command.h"
-
-struct client_ {
- int fd; /* client connection fd */
- string host; /* host address */
- string *xfr; /* old xfr address */
- commands commands; /* command queue */
- struct event read; /* event queues */
- struct event write; /* - */
- struct event listen; /* - */
-};
-
#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);
@@ -54,6 +40,9 @@
void real_client_disconnect(struct client_ *client);
void shift_client_commands(struct client_ *client, command *cmd);
int client_cleanup_commands(struct client_ *client);
+int client_send_command(struct client_ *client, struct user_ *user,
+ command *cmd, const char *to);
+int client_write_command(struct client_ *client, struct user_ *user);
void client_stat(struct client_ *client);
#endif
Added: branches/dbmod/command-types.h
===================================================================
--- branches/dbmod/command-types.h (rev 0)
+++ branches/dbmod/command-types.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -0,0 +1,47 @@
+/*
+ * 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$
+ */
+
+#ifndef COMMAND_TYPES_H
+#define COMMAND_TYPES_H
+
+#include "string.h"
+
+typedef struct _command {
+ int ignore;
+ int fase;
+ string cmd;
+ string **args;
+ string payload;
+ unsigned int args_len;
+ unsigned long trid;
+ struct _command *next;
+} command;
+
+typedef struct _commands {
+ string buf; /* io command buffer */
+ string *arg; /* tmp pointer to last arg */
+ size_t payload_size; /* payload size */
+ unsigned int state; /* command state */
+ struct _command *tmp; /* tmp pointer to ongoing command */
+ struct _command *cmd; /* linked list to ready commands */
+ struct _command *cmd_last; /* pointer to last entry on list */
+} commands;
+
+#endif
Property changes on: branches/dbmod/command-types.h
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/command.c
===================================================================
--- branches/dbmod/command.c 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/command.c 2009-08-25 20:37:59 UTC (rev 135)
@@ -21,7 +21,6 @@
#include <string.h>
#include <unistd.h>
-#include "io.h" /* XXX */
#include "return.h"
#include "command.h"
#include "protocol.h"
@@ -431,78 +430,48 @@
void
free_command(command *cmd) {
str_free(&cmd->cmd);
- str_free(&cmd->obuf);
str_free(&cmd->payload);
free_command_args(cmd);
free(cmd);
}
-int
-send_command(int tofd, command *cmd, string *email, const char *to) {
+void
+send_command(command *cmd, string *obuf, string *email, const char *to) {
string **arg = cmd->args;
+ string buf;
- switch (cmd->fase) {
+ /* put command on buffer */
+ str_zero(&buf);
+ if (str_copy(&buf, cmd->cmd.s, cmd->cmd.len) == 0)
+ die_nomem();
- case 0:
+ /* send args */
+ while (arg && *arg) {
- /* put command on buffer */
- str_zero(&cmd->obuf);
- if (str_copy(&cmd->obuf, cmd->cmd.s, cmd->cmd.len) == 0)
- die_nomem();
+ if (str_cat(&buf, (unsigned char *)" ", 1) == 0)
+ die_nomem();
+ if (str_cat(&buf, (*arg)->s, (*arg)->len) == 0)
+ die_nomem();
- /* send args */
- while (arg && *arg) {
+ ++arg;
+ }
- if (str_cat(&cmd->obuf, (unsigned char *)" ", 1) == 0)
- die_nomem();
- if (str_cat(&cmd->obuf, (*arg)->s, (*arg)->len) == 0)
- die_nomem();
+ /* end of line */
+ if (str_cat(&buf, (unsigned char *)"\r\n", 2) == 0)
+ die_nomem();
- ++arg;
- }
+ if (cmd->payload.len > 0 &&
+ str_cat(&buf, cmd->payload.s, cmd->payload.len) == 0) {
+ die_nomem();
+ }
- /* end of line */
- if (str_cat(&cmd->obuf, (unsigned char *)"\r\n", 2) == 0)
- die_nomem();
+ log->protocol("[%s] send to %S ==> %s", email, to, &buf);
+ log->protocol("\n");
- if (cmd->payload.len > 0) {
- if (str_cat(&cmd->obuf, cmd->payload.s, cmd->payload.len) == 0)
- die_nomem();
- }
+ if (buf.len > 0 && str_cat(obuf, buf.s, buf.len) == 0)
+ die_nomem();
- cmd->fase = 1;
- /* fallthrough */
-
- case 1:
-
- /* write command - XXX - async */
- switch (io_write(tofd, (char *)cmd->obuf.s, cmd->obuf.len)) {
-
- case -2:
- return(AGAIN);
-
- case -1:
- log->debug("write fail: [%S] buf: [%s][%d]\n", strerror(errno),
- &cmd->obuf, cmd->obuf.len);
- str_free(&cmd->obuf);
- cmd->fase = 0;
- return(RFAIL);
-
- default: break;
- }
-
- cmd->fase = 2;
- /* fallthrough */
-
- case 2:
-
- log->protocol("[%s] send to %S ==> %s", email, to, &cmd->obuf);
- log->protocol("\n");
- str_free(&cmd->obuf);
- cmd->fase = 0;
- }
-
- return(ROK);
+ str_free(&buf);
}
void
@@ -563,7 +532,7 @@
log->debug("command addr..........: [0x%x]\n", cmd);
log->debug("command ignore........: [%d]\n", cmd->ignore);
log->debug("command fase..........: [%d]\n", cmd->fase); /* XXX */
- log->debug("command obuf..........: [%s]\n", &cmd->obuf); /* XXX */
+// log->debug("command obuf..........: [%s]\n", &cmd->obuf); /* XXX */
log->debug("command trid..........: [%d]\n", cmd->trid);
log->debug("command cmd...........: [%s][%d]\n", &cmd->cmd, cmd->cmd.len);
log->debug("command args len......: [%d]\n", cmd->args_len);
Modified: branches/dbmod/command.h
===================================================================
--- branches/dbmod/command.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/command.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -22,6 +22,7 @@
#define COMMAND_H
#include "string.h"
+#include "sb-types.h"
#define CMD_BUF 512
@@ -32,28 +33,6 @@
#define EOC 0x0008
#define SENDMASK 0xff00
-typedef struct _command {
- int ignore;
- int fase;
- string obuf;
- string cmd;
- string **args;
- string payload;
- unsigned int args_len;
- unsigned long trid;
- struct _command *next;
-} command;
-
-typedef struct _commands {
- string buf; /* io command buffer */
- string *arg; /* tmp pointer to last arg */
- size_t payload_size; /* payload size */
- unsigned int state; /* command state */
- struct _command *tmp; /* tmp pointer to ongoing command */
- struct _command *cmd; /* linked list to ready commands */
- struct _command *cmd_last; /* pointer to last entry on list */
-} commands;
-
#define HAS_CMD(p) (p->commands.cmd != NULL)
command *command_alloc(void);
@@ -68,7 +47,7 @@
void print_client_command(string *email, command *cmd);
void print_server_command(string *email, command *cmd);
void commands_add_command(commands *cmds, command *cmd);
-int send_command(int tofd, command *cmd, string *email, const char *to);
+void send_command(command *cmd, string *obuf, string *email, const char *to);
int read_command(commands *cmds, int fd, void (*sched_write)(), void *ev_write);
void commands_print_state(unsigned int state);
void commands_stat(commands *cmds);
Deleted: branches/dbmod/contacts-data.h
===================================================================
--- branches/dbmod/contacts-data.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/contacts-data.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -1,50 +0,0 @@
-/*
- * 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$
- */
-
-#ifndef CONTACTS_DATA_H
-#define CONTACTS_DATA_H
-
-#include "string.h"
-
-struct contact_ {
- RB_ENTRY(contact_) contact__; /* RB list contact data */
-
- int chat; /* has chat ? (yes/no) */
- int updated; /* saved in db */
- string status; /* status */
- string group; /* group */
- string info; /* general info */
- string uid; /* uid */
- string dn; /* display name */
- string c; /* email */
- string o; /* object */
- unsigned int deny; /* commands and data */
- unsigned int lists; /* lists information */
- struct contact_ *save; /* update data */
- unsigned long long flags; /* client flags */
- unsigned long long flags2; /* client flags */
-};
-
-struct contacts {
- struct contact_ *rbh_root; /* root of the tree */
-};
-
-#endif
-
Copied: branches/dbmod/contacts-types.h (from rev 130, branches/dbmod/contacts-data.h)
===================================================================
--- branches/dbmod/contacts-types.h (rev 0)
+++ branches/dbmod/contacts-types.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -0,0 +1,50 @@
+/*
+ * 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$
+ */
+
+#ifndef CONTACTS_TYPES_H
+#define CONTACTS_TYPES_H
+
+#include "string.h"
+
+struct contact_ {
+ RB_ENTRY(contact_) contact__; /* RB list contact data */
+
+ int chat; /* has chat ? (yes/no) */
+ int updated; /* saved in db */
+ string status; /* status */
+ string group; /* group */
+ string info; /* general info */
+ string uid; /* uid */
+ string dn; /* display name */
+ string c; /* email */
+ string o; /* object */
+ unsigned int deny; /* commands and data */
+ unsigned int lists; /* lists information */
+ struct contact_ *save; /* update data */
+ unsigned long long flags; /* client flags */
+ unsigned long long flags2; /* client flags */
+};
+
+struct contacts {
+ struct contact_ *rbh_root; /* root of the tree */
+};
+
+#endif
+
Modified: branches/dbmod/contacts.h
===================================================================
--- branches/dbmod/contacts.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/contacts.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -21,9 +21,9 @@
#ifndef CONTACTS_H
#define CONTACTS_H
-#include "contacts-data.h"
+#include "xml.h"
#include "user.h"
-#include "xml.h"
+#include "contacts-types.h"
void contacts_RB_INSERT_COLOR(struct contacts *head, struct contact_ *elm);
void contacts_RB_REMOVE_COLOR(struct contacts *head, struct contact_ *parent, struct contact_ *elm);
Modified: branches/dbmod/ctl.h
===================================================================
--- branches/dbmod/ctl.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/ctl.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -25,7 +25,7 @@
#include "tree.h"
#include "string.h"
-#include "xml-data.h"
+#include "xml-types.h"
struct ctl_ {
struct xml_tags xml_head;
Modified: branches/dbmod/db.h
===================================================================
--- branches/dbmod/db.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/db.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -23,7 +23,7 @@
#include "string.h"
-#define MINMOD_VERSION 1
+#define MINMOD_VERSION 2
struct mod_ {
/* cmds or functions */
Modified: branches/dbmod/db_modules/mysql/mysql.c
===================================================================
--- branches/dbmod/db_modules/mysql/mysql.c 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/db_modules/mysql/mysql.c 2009-08-25 20:37:59 UTC (rev 135)
@@ -17,7 +17,7 @@
static const char rcsid[] = "$Id$";
#define MODULE_NAME "mysql"
-#define MODULE_VERSION 1
+#define MODULE_VERSION 2
#include <sys/types.h>
#include <sys/stat.h>
Modified: branches/dbmod/db_modules/mysql/sql.c
===================================================================
--- branches/dbmod/db_modules/mysql/sql.c 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/db_modules/mysql/sql.c 2009-08-25 20:37:59 UTC (rev 135)
@@ -162,10 +162,10 @@
/* 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);
+ sql.len = fmt_printf(NULL, fmt, user->host.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);
+ sql.len = fmt_printf(sql.s, fmt, user->host.s, user->email.s);
if (db_query2(&mysql, &sql) == RFAIL) {
str_free(&sql);
@@ -190,11 +190,11 @@
"(SELECT commands FROM defaults LIMIT 1))";
sql.len = fmt_printf(NULL, fmt, user->email.s,
- user->email.s, user->addr.s);
+ user->email.s, user->host.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);
+ user->email.s, user->host.s);
if (db_query2(&mysql, &sql) == RFAIL) {
str_free(&sql);
Modified: branches/dbmod/db_modules/pgsql/pgsql.c
===================================================================
--- branches/dbmod/db_modules/pgsql/pgsql.c 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/db_modules/pgsql/pgsql.c 2009-08-25 20:37:59 UTC (rev 135)
@@ -17,7 +17,7 @@
static const char rcsid[] = "$Id$";
#define MODULE_NAME "pgsql"
-#define MODULE_VERSION 1
+#define MODULE_VERSION 2
#include <sys/types.h>
#include <sys/stat.h>
Modified: branches/dbmod/db_modules/pgsql/sql.c
===================================================================
--- branches/dbmod/db_modules/pgsql/sql.c 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/db_modules/pgsql/sql.c 2009-08-25 20:37:59 UTC (rev 135)
@@ -162,10 +162,10 @@
/* 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);
+ sql.len = fmt_printf(NULL, fmt, user->host.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);
+ sql.len = fmt_printf(sql.s, fmt, user->host.s, user->email.s);
if (db_query2(&pgsql, &sql) == RFAIL) {
str_free(&sql);
@@ -190,11 +190,11 @@
"(SELECT commands FROM defaults LIMIT 1))";
sql.len = fmt_printf(NULL, fmt, user->email.s,
- user->email.s, user->addr.s);
+ user->email.s, user->host.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);
+ user->email.s, user->host.s);
if (db_query2(&pgsql, &sql) == RFAIL) {
str_free(&sql);
Deleted: branches/dbmod/ns-data.h
===================================================================
--- branches/dbmod/ns-data.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/ns-data.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -1,34 +0,0 @@
-/*
- * 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$
- */
-
-#ifndef NS_DATA_H
-#define NS_DATA_H
-
-#include "client.h"
-#include "server.h"
-
-struct ns_ {
- struct client_ *client;
- struct client_ *xfr_proxy;
- struct server_ *server;
-};
-
-#endif
-
Copied: branches/dbmod/ns-types.h (from rev 130, branches/dbmod/ns-data.h)
===================================================================
--- branches/dbmod/ns-types.h (rev 0)
+++ branches/dbmod/ns-types.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -0,0 +1,34 @@
+/*
+ * 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$
+ */
+
+#ifndef NS_TYPES_H
+#define NS_TYPES_H
+
+#include "client-types.h"
+#include "server-types.h"
+
+struct ns_ {
+ struct client_ *client;
+ struct client_ *xfr_proxy;
+ struct server_ *server;
+};
+
+#endif
+
Modified: branches/dbmod/ns.c
===================================================================
--- branches/dbmod/ns.c 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/ns.c 2009-08-25 20:37:59 UTC (rev 135)
@@ -80,7 +80,7 @@
struct user_ *user = p;
struct client_ *client = user->ns.client;
struct server_ *server = user->ns.server;
- const char *to = "ns server";
+ const char *to = "ns server";
command *cmd = client->commands.cmd;
(void) evfd;
@@ -126,7 +126,7 @@
}
/* send command */
- switch (send_command(server->fd, cmd, &user->email, to)) {
+ switch (server_send_command(server, user, cmd, to)) {
case AGAIN:
server_sched_write(server);
@@ -226,7 +226,7 @@
}
/* send command */
- switch (send_command(client->fd, cmd, &user->email, to)) {
+ switch (client_send_command(client, user, cmd, to)) {
case AGAIN:
client_sched_write(client);
Modified: branches/dbmod/ns.h
===================================================================
--- branches/dbmod/ns.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/ns.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -22,6 +22,8 @@
#define NS_H
#include "user.h"
+#include "client.h"
+#include "server.h"
struct server_ *ns_disconnect(struct server_ *ns);
int xfr_ns_proxy(struct user_ *user, command *cmd);
Modified: branches/dbmod/protocol.c
===================================================================
--- branches/dbmod/protocol.c 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/protocol.c 2009-08-25 20:37:59 UTC (rev 135)
@@ -291,7 +291,6 @@
buf.s += 4;
continue;
}
-log->debug("aqui: [%s]\n", &buf);
if (buf.len > 5 && *(buf.s + 1) == '#' &&
(*(buf.s + 2) == 'x' || *(buf.s + 2) == 'X') &&
((*(buf.s + 3) >= '0' && *(buf.s + 3) <= '9') ||
Deleted: branches/dbmod/sb-data.h
===================================================================
--- branches/dbmod/sb-data.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/sb-data.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -1,61 +0,0 @@
-/*
- * 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$
- */
-
-#ifndef SB_DATA_H
-#define SB_DATA_H
-
-#include <sys/time.h>
-
-#include <event.h>
-
-#include "queue.h"
-#include "client.h"
-#include "server.h"
-
-struct sb_user_ {
- RB_ENTRY(sb_user_) sb_user__;
- string email;
-};
-
-struct sb_users_ {
- struct sb_user_ *rbh_root;
-};
-
-struct sb_ {
- struct sb_users_ sb_users; /* list of connected users */
- LIST_ENTRY(sb_) sb__; /* sb list */
- struct user_ *user; /* pointer to user */
-
- struct client_ *client; /* sb client data */
- struct server_ *server; /* sb server data */
-
- unsigned long long sb_session_id; /* sb session id - XXX */
- unsigned short warned; /* warned about message logging */
- unsigned int id; /* sql chat id - XXX */
-
- string start;
- string *xfr;
-};
-
-struct sbs {
- struct sb_ *lh_first; /* first element */
-};
-
-#endif
Copied: branches/dbmod/sb-types.h (from rev 134, branches/dbmod/sb-data.h)
===================================================================
--- branches/dbmod/sb-types.h (rev 0)
+++ branches/dbmod/sb-types.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -0,0 +1,62 @@
+/*
+ * 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$
+ */
+
+#ifndef SB_TYPES_H
+#define SB_TYPES_H
+
+#include <sys/time.h>
+
+#include <event.h>
+
+#include "tree.h"
+#include "queue.h"
+#include "client-types.h"
+#include "server-types.h"
+
+struct sb_user_ {
+ RB_ENTRY(sb_user_) sb_user__;
+ string email;
+};
+
+struct sb_users_ {
+ struct sb_user_ *rbh_root;
+};
+
+struct sb_ {
+ struct sb_users_ sb_users; /* list of connected users */
+ LIST_ENTRY(sb_) sb__; /* sb list */
+ struct user_ *user; /* pointer to user */
+
+ struct client_ *client; /* sb client data */
+ struct server_ *server; /* sb server data */
+
+ unsigned long long sb_session_id; /* sb session id - XXX */
+ unsigned short warned; /* warned about message logging */
+ unsigned int id; /* sql chat id - XXX */
+
+ string start;
+ string *xfr;
+};
+
+struct sbs {
+ struct sb_ *lh_first; /* first element */
+};
+
+#endif
Modified: branches/dbmod/sb.c
===================================================================
--- branches/dbmod/sb.c 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/sb.c 2009-08-25 20:37:59 UTC (rev 135)
@@ -27,6 +27,7 @@
#include "db.h"
#include "sb.h"
#include "event.h"
+#include "client.h"
#include "net-io.h"
#include "return.h"
#include "contacts.h"
@@ -349,7 +350,7 @@
}
/* flush the server command queue */
- switch (send_command(client->fd, cmd, &user->email, to)) {
+ switch (client_send_command(client, user, cmd, to)) {
case AGAIN:
client_sched_write(client);
@@ -509,7 +510,7 @@
}
- switch (send_command(server->fd, cmd, &user->email, to)) {
+ switch (server_send_command(server, user, cmd, to)) {
case AGAIN:
server_sched_write(server);
@@ -712,7 +713,7 @@
struct sb_user_ f;
string *email;
- if (cmd->args_len < 1 || (email = get_arg(cmd, 0)) != NULL) {
+ if (cmd->args_len < 1 || (email = get_arg(cmd, 0)) == NULL) {
return(RFAIL);
}
Modified: branches/dbmod/sb.h
===================================================================
--- branches/dbmod/sb.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/sb.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -22,6 +22,8 @@
#define SB_H
#include "user.h"
+#include "server.h"
+#include "sb-types.h"
void sb_free_xfr(struct sb_ *sb);
struct sb_ *sb_alloc(struct user_ *user);
Added: branches/dbmod/server-types.h
===================================================================
--- branches/dbmod/server-types.h (rev 0)
+++ branches/dbmod/server-types.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -0,0 +1,42 @@
+/*
+ * 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$
+ */
+
+#ifndef SERVER_TYPES_H
+#define SERVER_TYPES_H
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <event.h>
+
+#include "command-types.h"
+
+struct server_ {
+ int fd;
+ size_t sent;
+ string host;
+ string port;
+ string obuf;
+ commands commands;
+ struct event read;
+ struct event write;
+};
+
+#endif
Property changes on: branches/dbmod/server-types.h
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/server.c
===================================================================
--- branches/dbmod/server.c 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/server.c 2009-08-25 20:37:59 UTC (rev 135)
@@ -27,6 +27,7 @@
#include "net-io.h"
#include "server.h"
#include "return.h"
+#include "command.h"
#include "msn-proxy.h"
int
@@ -229,6 +230,78 @@
}
int
+server_send_command(struct server_ *server, struct user_ *user,
+ command *cmd, const char *to) {
+
+ switch (cmd->fase) {
+
+ case 0:
+
+ /* prepare the command to send */
+ send_command(cmd, &server->obuf, &user->email, to);
+
+ cmd->fase = 1;
+ /* fallthrough */
+
+ case 1:
+
+ /* write the command to the server */
+ switch (server_write_command(server, user)) {
+
+ case -2: return(AGAIN);
+ case -1:
+ log->debug("debug: %s: write fail: [%S] buf: [%s][%d]\n",
+ &user->email, strerror(errno), &server->obuf,
+ server->obuf.len);
+ str_free(&server->obuf);
+ cmd->fase = 0;
+ return(RFAIL);
+ }
+
+ cmd->fase = 0;
+ }
+
+ return(ROK);
+}
+
+int
+server_write_command(struct server_ *server, struct user_ *user) {
+ size_t len;
+
+ if (server->obuf.len - server->sent <= 0) {
+ log->debug("debug: %s: wrong number of bytes to send (connection closed)\n",
+ &user->email);
+ return(-1);
+ }
+
+ len = write(server->fd, (char *)server->obuf.s + server->sent,
+ server->obuf.len - server->sent);
+ if (len == -1) {
+ if (errno == EINTR || errno == EAGAIN) {
+ /* schedule another write - would block */
+ return(-2);
+ }
+ log->debug("debug: %s: cannot write to sb server (connection closed) "
+ "[%s:%s] fd: %d\n", &user->email, &user->host, &user->port,
+ server->fd);
+ return(-1);
+ }
+ server->sent += len;
+
+ if (server->sent < server->obuf.len) {
+
+ /* schedule another write - there is more to write */
+ return(-2);
+ }
+
+ /* reset output buffer */
+ server->sent = 0;
+ server->obuf.len = 0;
+
+ return(0);
+}
+
+int
read_server_command(struct server_ *server, void (*sched_write)(), void *ev_write) {
/* read command */
@@ -261,6 +334,11 @@
&server->host, server->host.len,
&server->port, server->port.len);
}
+ if (server->obuf.len > 0) {
+ log->debug("server output buffer..: [%s][%d]\n", &server->obuf,
+ server->obuf.len);
+ }
+ log->debug("server already sent...: [%d]\n", server->sent);
/* print the command information */
commands_stat(&server->commands);
Modified: branches/dbmod/server.h
===================================================================
--- branches/dbmod/server.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/server.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -21,22 +21,9 @@
#ifndef SERVER_H
#define SERVER_H
-#include <sys/types.h>
-#include <sys/time.h>
+#include "user.h"
+#include "server-types.h"
-#include <event.h>
-
-#include "command.h"
-
-struct server_ {
- int fd;
- string host;
- string port;
- commands commands;
- struct event read;
- struct event write;
-};
-
void server_close(struct server_ *server);
struct server_ *server_disconnect(struct server_ *server);
struct server_ *server_alloc(void);
@@ -55,7 +42,11 @@
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_send_command(struct server_ *server, struct user_ *user,
+ command *cmd, const char *to);
+int server_write_command(struct server_ *server, struct user_ *user);
+int read_server_command(struct server_ *server,
+ void (*sched_write)(), void *ev_write);
int server_cleanup_commands(struct server_ *server);
void server_stat(struct server_ *server);
Added: branches/dbmod/user-types.h
===================================================================
--- branches/dbmod/user-types.h (rev 0)
+++ branches/dbmod/user-types.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -0,0 +1,59 @@
+/*
+ * 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$
+ */
+
+#ifndef USER_TYPES_H
+#define USER_TYPES_H
+
+#include "tree.h"
+#include "ns-types.h"
+#include "sb-types.h"
+#include "check-cmd-types.h"
+#include "contacts-types.h"
+
+struct user_ {
+ struct contacts contacts; /* contacts rb list */
+ RB_ENTRY(user_) user__; /* RB list user data */
+ struct ns_ ns; /* ns connection */
+ struct sbs sbs; /* sb connections list */
+
+ unsigned int id;
+ unsigned int state; /* connection state */
+ unsigned int version; /* client version */
+ unsigned int commands; /* blocked commands */
+ short wait_trid; /* trid to wait */
+ short msnp8_syn_bug; /* windows messenger SYN bug workaround */
+ short contact_delete; /* remove unchanged contacts */
+
+ string dn; /* display name */
+ string host; /* client ip */
+ string port; /* client port */
+ string email; /* msn user */
+ string status; /* client status */
+
+ CMDS_ *cmds; /* allowed commands */
+ SBCMDS_ *sbcmds; /* allowed sb commands */
+};
+
+struct users_ {
+ struct user_ *rbh_root; /* root of the tree */
+};
+
+#endif
+
Property changes on: branches/dbmod/user-types.h
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/user.c
===================================================================
--- branches/dbmod/user.c 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/user.c 2009-08-25 20:37:59 UTC (rev 135)
@@ -182,7 +182,7 @@
struct user_ *
user_free(struct user_ *user) {
str_free(&user->dn);
- str_free(&user->addr);
+ str_free(&user->host);
str_free(&user->port);
str_free(&user->email);
str_free(&user->status);
@@ -210,7 +210,7 @@
if (str_copys(&user->status, (unsigned char *)"OFF") == 0) die_nomem();
/* get the user ip address */
- if (resolve_client(&user->addr, &user->port, sa, sa_len) == RFAIL) {
+ if (resolve_client(&user->host, &user->port, sa, sa_len) == RFAIL) {
log->debug("debug: fail to get ns client address\n");
user = user_free(user);
return(NULL);
@@ -222,7 +222,7 @@
return(NULL);
}
- log->debug("debug: connection from [%s:%s]\n", &user->addr, &user->port);
+ log->debug("debug: connection from [%s:%s]\n", &user->host, &user->port);
return(user);
}
@@ -294,7 +294,7 @@
log->debug("user display name.....: [%s]\n", &user->dn);
log->debug("user status...........: [%s]\n", &user->status);
log->debug("user email............: [%s]\n", &user->email);
- log->debug("user host.............: [%s:%s]\n", &user->addr, &user->port);
+ log->debug("user host.............: [%s:%s]\n", &user->host, &user->port);
/* print the ns information */
ns_stat(&user->ns);
@@ -303,7 +303,7 @@
sbs_stat(user);
/* print user contacts */
-// contacts_stat(user);
+ contacts_stat(user);
log->debug("\n");
}
Modified: branches/dbmod/user.h
===================================================================
--- branches/dbmod/user.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/user.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -24,49 +24,14 @@
#include <sys/types.h>
#include <sys/socket.h>
-#include <time.h>
+#include "user-types.h"
-#include "tree.h"
-#include "command.h"
-#include "ns-data.h"
-#include "sb-data.h"
-#include "check-cmd.h"
-#include "contacts-data.h"
-
#define PRE_AUTH 0x00000001
#define USR_TWN_I 0x00000002
#define USR_TWN_S 0x00000004
#define CONNECTED 0x00000008
#define SENDDELAY 0x00000010
-struct user_ {
- struct contacts contacts; /* contacts rb list */
- RB_ENTRY(user_) user__; /* RB list user data */
- struct ns_ ns; /* ns connection */
- struct sbs sbs; /* sb connections list */
-
- unsigned int id;
- unsigned int state; /* connection state */
- unsigned int version; /* client version */
- unsigned int commands; /* blocked commands */
- short wait_trid; /* trid to wait */
- short msnp8_syn_bug; /* windows messenger SYN bug workaround */
- short contact_delete; /* remove unchanged contacts */
-
- string dn; /* display name */
- string addr; /* client ip */
- string port; /* client port */
- string email; /* msn user */
- string status; /* client status */
-
- CMDS_ *cmds; /* allowed commands */
- SBCMDS_ *sbcmds; /* allowed sb commands */
-};
-
-struct users_ {
- struct user_ *rbh_root; /* root of the tree */
-};
-
void users__RB_INSERT_COLOR(struct users_ *head, struct user_ *elm);
void users__RB_REMOVE_COLOR(struct users_ *head, struct user_ *parent, struct user_ *elm);
struct user_ *users__RB_REMOVE(struct users_ *head, struct user_ *elm);
Deleted: branches/dbmod/xml-data.h
===================================================================
--- branches/dbmod/xml-data.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/xml-data.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -1,51 +0,0 @@
-/*
- * 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$
- */
-
-#ifndef XML_DATA_H
-#define XML_DATA_H
-
-#include "string.h"
-#include "queue.h"
-
-struct xml_tag_opt_ {
-
- SLIST_ENTRY(xml_tag_opt_) xml_tag_opt__;
-
- string name;
- string value;
-};
-
-struct xml_tag_opts { \
- struct xml_tag_opt_ *slh_first; /* first element */ \
-};
-
-struct xml_tag_ {
-
- SLIST_ENTRY(xml_tag_) xml_tag__;
-
- string name; /* tag name */
- string data; /* tag data */
- struct xml_tags {
- struct xml_tag_ *slh_first; /* first element */
- } xml_tag_head;
- struct xml_tag_opts xml_tag_opt_head; /* tag options */
-};
-
-#endif
Copied: branches/dbmod/xml-types.h (from rev 130, branches/dbmod/xml-data.h)
===================================================================
--- branches/dbmod/xml-types.h (rev 0)
+++ branches/dbmod/xml-types.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -0,0 +1,51 @@
+/*
+ * 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$
+ */
+
+#ifndef XML_TYPES_H
+#define XML_TYPES_H
+
+#include "queue.h"
+#include "string.h"
+
+struct xml_tag_opt_ {
+
+ SLIST_ENTRY(xml_tag_opt_) xml_tag_opt__;
+
+ string name;
+ string value;
+};
+
+struct xml_tag_opts {
+ struct xml_tag_opt_ *slh_first; /* first element */
+};
+
+struct xml_tag_ {
+
+ SLIST_ENTRY(xml_tag_) xml_tag__;
+
+ string name; /* tag name */
+ string data; /* tag data */
+ struct xml_tags {
+ struct xml_tag_ *slh_first; /* first element */
+ } xml_tag_head;
+ struct xml_tag_opts xml_tag_opt_head; /* tag options */
+};
+
+#endif
Modified: branches/dbmod/xml.h
===================================================================
--- branches/dbmod/xml.h 2009-08-25 12:50:22 UTC (rev 134)
+++ branches/dbmod/xml.h 2009-08-25 20:37:59 UTC (rev 135)
@@ -21,7 +21,6 @@
#ifndef XML_H
#define XML_H
-#include "xml-data.h"
#include "ctl.h"
void xml_print(struct xml_tags *head, int depth);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lo...@us...> - 2009-08-25 12:50:33
|
Revision: 134
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=134&view=rev
Author: loos-br
Date: 2009-08-25 12:50:22 +0000 (Tue, 25 Aug 2009)
Log Message:
-----------
- adicionado o endereco e porta do servidor no client_stat()
- pequenas correcoes/atualizacoes de codigo
Modified Paths:
--------------
branches/dbmod/client.c
branches/dbmod/client.h
branches/dbmod/db.c
branches/dbmod/net-io.c
branches/dbmod/ns.c
branches/dbmod/sb-data.h
branches/dbmod/sb.c
branches/dbmod/user.c
Modified: branches/dbmod/client.c
===================================================================
--- branches/dbmod/client.c 2009-08-25 00:38:39 UTC (rev 133)
+++ branches/dbmod/client.c 2009-08-25 12:50:22 UTC (rev 134)
@@ -61,14 +61,43 @@
/* set fd */
client->fd = client_fd;
+ /* attach client functions */
+ client_attach(client, fn_read, fn_write, arg);
+
+ return(client);
+}
+
+struct client_ *
+client_alloc2(void) {
+ struct client_ *client;
+
+ client = (struct client_ *)malloc(sizeof(*client));
+ if (client == NULL) die_nomem();
+ memset(client, 0, sizeof(*client));
+
+ client->fd = -1;
+ client->read.ev_fd = -1;
+ client->write.ev_fd = -1;
+ client->listen.ev_fd = -1;
+
+ /* prepare commands */
+ commands_init(&client->commands);
+
+ return(client);
+}
+
+void
+client_attach( struct client_ *client,
+ void (*fn_read)(int, short, void *),
+ void (*fn_write)(int, short, void *),
+ void *arg) {
+
/* set events */
event_set(&client->read, client->fd, EV_READ, fn_read, arg);
event_set(&client->write, client->fd, EV_WRITE, fn_write, arg);
/* sched read */
client_sched_read(client);
-
- return(client);
}
int
@@ -106,6 +135,9 @@
/* flush commands */
client_cleanup_commands(client);
+ /* free host address */
+ str_free(&client->host);
+
/* free client */
free(client);
@@ -144,6 +176,8 @@
client_stat(struct client_ *client) {
log->debug("client fd.............: [%d]\n", client->fd);
+ if (client->host.len > 0)
+ log->debug("client host...........: [%s]\n", &client->host);
if (client->xfr != NULL && client->xfr->len > 0)
log->debug("client xfr............: [%s]\n", client->xfr);
Modified: branches/dbmod/client.h
===================================================================
--- branches/dbmod/client.h 2009-08-25 00:38:39 UTC (rev 133)
+++ branches/dbmod/client.h 2009-08-25 12:50:22 UTC (rev 134)
@@ -30,6 +30,7 @@
struct client_ {
int fd; /* client connection fd */
+ string host; /* host address */
string *xfr; /* old xfr address */
commands commands; /* command queue */
struct event read; /* event queues */
@@ -46,6 +47,9 @@
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_alloc2(void);
+void client_attach(struct client_ *client, 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);
Modified: branches/dbmod/db.c
===================================================================
--- branches/dbmod/db.c 2009-08-25 00:38:39 UTC (rev 133)
+++ branches/dbmod/db.c 2009-08-25 12:50:22 UTC (rev 134)
@@ -119,7 +119,7 @@
return(-1);
if (db.modVersion < MINMOD_VERSION) {
- log->debug("debug: database module out of sync, please reinstall the module.\n");
+ log->debug("debug: database module is out of sync, please reinstall the module.\n");
return(-1);
}
Modified: branches/dbmod/net-io.c
===================================================================
--- branches/dbmod/net-io.c 2009-08-25 00:38:39 UTC (rev 133)
+++ branches/dbmod/net-io.c 2009-08-25 12:50:22 UTC (rev 134)
@@ -205,13 +205,12 @@
/* verify ports */
if (port_min < 0 || port_min > port_max || port_max > 65535) {
log->debug("debug: invalid port range (check config)\n");
- return((string *)0);
+ return(NULL);
}
/* alloc new string */
port = str_alloc();
- if (port == (string *)0)
- die_nomem();
+ if (port == NULL) die_nomem();
/* find unused port in range */
for (count = 0; count < 10; count++) {
@@ -243,14 +242,13 @@
log->debug("debug: cannot find free port to bind. check the internal ip config.\n");
str_free(port);
free(port);
- return((string *)0);
+ return(NULL);
}
/* fmt return [IP:PORT] */
- port->len = fmt_printf(NULL, "%S:%d", host->s, random_port);
- if (str_ready(port, port->len + 1) == 0)
- die_nomem();
- port->len = fmt_printf(port->s, "%S:%d", host->s, random_port);
+ port->len = fmt_printf(NULL, "%s:%d", host, random_port);
+ if (str_ready(port, port->len + 1) == 0) die_nomem();
+ port->len = fmt_printf(port->s, "%s:%d", host, random_port);
return(port);
}
@@ -261,8 +259,6 @@
static char host[NI_MAXHOST];
static char port[NI_MAXSERV];
- memset(host, 0, NI_MAXHOST);
-
/* get the user network address */
if (getnameinfo(sa, sa_len, host, sizeof(host), port, sizeof(port),
NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
Modified: branches/dbmod/ns.c
===================================================================
--- branches/dbmod/ns.c 2009-08-25 00:38:39 UTC (rev 133)
+++ branches/dbmod/ns.c 2009-08-25 12:50:22 UTC (rev 134)
@@ -27,6 +27,7 @@
#include "sb.h"
#include "ns.h"
+#include "fmt.h"
#include "net-io.h"
#include "return.h"
#include "protocol.h"
@@ -331,6 +332,10 @@
proxy->xfr = cmd->args[2];
cmd->args[2] = port;
+ /* copy the host address */
+ if (port->len > 0 && str_copy(&proxy->host, port->s, port->len) == 0)
+ die_nomem();
+
/* event set */
event_set(&proxy->listen, proxy->fd, EV_READ, ns_proxy_client, user);
event_add(&proxy->listen, &config.timeout_listen);
@@ -366,15 +371,19 @@
port = bind_free_port(config.port_min, config.port_max,
&config.defaults.proxy_ip, &proxy->fd);
if (port == NULL) {
- /* cannot allocate any port */
- free(proxy);
- return(RFAIL);
+ /* cannot allocate any port */
+ free(proxy);
+ return(RFAIL);
}
/* XFR address rewrite */
proxy->xfr = cmd->args[2];
cmd->args[2] = port;
+ /* copy the host address */
+ if (port->len > 0 && str_copy(&proxy->host, port->s, port->len) == 0)
+ die_nomem();
+
/* event set */
event_set(&proxy->listen, proxy->fd, EV_READ, ns_proxy_client, user);
event_add(&proxy->listen, &config.timeout_listen);
@@ -407,23 +416,23 @@
/* set socket options */
if (set_options(client_fd) == -1 || set_nonblock(client_fd) == -1) {
- log->debug("debug: unable to set ns client socket options\n");
- while (close(client_fd) != 0 && errno == EINTR);
- return;
+ log->debug("debug: unable to set ns client socket options\n");
+ while (close(client_fd) != 0 && errno == EINTR);
+ return;
}
/* max users */
if (config->max_clients && user_inuse >= config->max_clients) {
- log->debug("debug: Server full - too many clients\n");
- while (close(client_fd) != 0 && errno == EINTR);
- return;
+ log->debug("debug: Server full - too many clients\n");
+ while (close(client_fd) != 0 && errno == EINTR);
+ return;
}
/* new user */
user = user_alloc(&client_sa, client_sa_len);
if (user == NULL) {
- while (close(client_fd) != 0 && errno == EINTR);
- return;
+ while (close(client_fd) != 0 && errno == EINTR);
+ return;
}
/* new NS */
@@ -431,9 +440,9 @@
&config->default_ns_port,
ns_server_read, ns_server_write, user);
if (user->ns.server == NULL) {
- log->debug("debug: unable to connect to ns server\n");
- while (close(client_fd) != 0 && errno == EINTR);
- return;
+ log->debug("debug: unable to connect to ns server\n");
+ while (close(client_fd) != 0 && errno == EINTR);
+ return;
}
/* new client */
@@ -443,9 +452,9 @@
void
ns_proxy_client(int listenfd, short event, void *p) {
+ struct user_ *user = (struct user_ *)p;
+ struct client_ *proxy = user->ns.xfr_proxy;
struct sockaddr client_sa;
- struct user_ *user = p;
- struct client_ *proxy = user->ns.xfr_proxy;
socklen_t client_sa_len;
int client_fd;
@@ -475,6 +484,12 @@
user->ns.client = client_alloc(client_fd, ns_client_read,
ns_client_write, user);
+ /* copy the host address */
+ if (proxy->host.len > 0 &&
+ str_copy(&user->ns.client->host, proxy->host.s, proxy->host.len) == 0) {
+ die_nomem();
+ }
+
error:
/* free xfr_proxy */
Modified: branches/dbmod/sb-data.h
===================================================================
--- branches/dbmod/sb-data.h 2009-08-25 00:38:39 UTC (rev 133)
+++ branches/dbmod/sb-data.h 2009-08-25 12:50:22 UTC (rev 134)
@@ -41,7 +41,6 @@
struct sb_ {
struct sb_users_ sb_users; /* list of connected users */
LIST_ENTRY(sb_) sb__; /* sb list */
- struct event listen; /* listen event */
struct user_ *user; /* pointer to user */
struct client_ *client; /* sb client data */
Modified: branches/dbmod/sb.c
===================================================================
--- branches/dbmod/sb.c 2009-08-25 00:38:39 UTC (rev 133)
+++ branches/dbmod/sb.c 2009-08-25 12:50:22 UTC (rev 134)
@@ -90,9 +90,11 @@
sb->user = user;
sb->warned = NO;
- sb->listen.ev_fd = -1;
sb->sb_session_id = 0;
+ /* alloc the sb client struct */
+ sb->client = client_alloc2();
+
/* create a new sb entry on sql */
sb->id = db.sql_insert_sb(user);
if (sb->id <= 0) {
@@ -217,10 +219,10 @@
void
sb_connect(const int listenfd, short event, void *p) {
+ struct sb_ *sb = (struct sb_ *)p;
+ struct client_ *client = sb->client;
struct sockaddr client_sa;
- struct sb_ *sb = p;
socklen_t client_sa_len;
- int client_fd;
if ((event & EV_TIMEOUT)) {
log->debug("debug: sb proxy connection timeout\n");
@@ -233,15 +235,15 @@
memset(&client_sa, 0, client_sa_len);
/* accept connection */
- client_fd = accept(listenfd, &client_sa, &client_sa_len);
- if (client_fd < 0) {
+ client->fd = accept(listenfd, &client_sa, &client_sa_len);
+ if (client->fd < 0) {
log->debug("debug: unable to accept new sb client connection\n");
sb = sb_disconnect(sb);
goto end;
}
/* set socket options */
- if (set_options(client_fd) == -1 || set_nonblock(client_fd) == -1) {
+ if (set_options(client->fd) == -1 || set_nonblock(client->fd) == -1) {
log->debug("debug: unable to set socket options on sb client fd\n");
sb = sb_disconnect(sb);
goto end;
@@ -258,13 +260,13 @@
/* free xfr */
sb_free_xfr(sb);
- /* attach client */
- sb->client = client_alloc(client_fd, sb_client_read, sb_client_write, sb);
+ /* attach client functions */
+ client_attach(client, sb_client_read, sb_client_write, sb);
/* reset queue events */
- if (EVENT_FD((&sb->listen)) != -1) {
- event_del(&sb->listen);
- sb->listen.ev_fd = -1;
+ if (EVENT_FD((&client->listen)) != -1) {
+ event_del(&client->listen);
+ client->listen.ev_fd = -1;
}
end:
@@ -286,12 +288,6 @@
/* close connection to NS client */
sb->client = client_disconnect(sb->client);
- /* reset queue events */
- if (EVENT_FD((&sb->listen)) != -1) {
- event_del(&sb->listen);
- sb->listen.ev_fd = -1;
- }
-
/* free xfr if exist */
sb_free_xfr(sb);
@@ -555,18 +551,21 @@
struct sb_ *
sb_proxy(struct user_ *user, string **arg) {
+ struct client_ *client;
struct sb_ *sb;
string *port;
- int listenfd;
/* alloc new sb */
sb = sb_alloc(user);
if (sb == NULL)
return(NULL);
+ /* use the client struct to proxy connections */
+ client = sb->client;
+
port = bind_free_port(config.port_min, config.port_max,
- &config.defaults.proxy_ip, &listenfd);
- if (port == (string *)0) {
+ &config.defaults.proxy_ip, &client->fd);
+ if (port == NULL) {
/* cannot allocate any port */
sb = sb_disconnect(sb);
@@ -579,9 +578,13 @@
/* setup new xfr host */
*arg = port;
+ /* save the proxy address */
+ if (port->len > 0 && str_copy(&client->host, port->s, port->len) == 0)
+ die_nomem();
+
/* event set */
- event_set(&sb->listen, listenfd, EV_READ, sb_connect, sb);
- event_add(&sb->listen, &config.timeout_listen);
+ event_set(&client->listen, client->fd, EV_READ, sb_connect, sb);
+ event_add(&client->listen, &config.timeout_listen);
return(sb);
}
@@ -786,8 +789,6 @@
server_stat(sb->server);
}
- msn_ev_stat(&sb->listen, "sb event listen");
-
#undef YESNO
}
Modified: branches/dbmod/user.c
===================================================================
--- branches/dbmod/user.c 2009-08-25 00:38:39 UTC (rev 133)
+++ branches/dbmod/user.c 2009-08-25 12:50:22 UTC (rev 134)
@@ -222,7 +222,7 @@
return(NULL);
}
- log->debug("debug: connection from [%s]:[%s]\n", &user->addr, &user->port);
+ log->debug("debug: connection from [%s:%s]\n", &user->addr, &user->port);
return(user);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lo...@us...> - 2009-08-25 00:38:53
|
Revision: 133
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=133&view=rev
Author: loos-br
Date: 2009-08-25 00:38:39 +0000 (Tue, 25 Aug 2009)
Log Message:
-----------
- controle de versoes dos modulos - para impedir o uso de modulos antigos
- pequenas correcoes (diversas)
Modified Paths:
--------------
branches/dbmod/command.c
branches/dbmod/contacts.c
branches/dbmod/db.c
branches/dbmod/db.h
branches/dbmod/db_modules/mysql/mysql.c
branches/dbmod/db_modules/pgsql/pgsql.c
branches/dbmod/net-io.c
branches/dbmod/net-io.h
branches/dbmod/protocol.c
branches/dbmod/user.c
branches/dbmod/user.h
Modified: branches/dbmod/command.c
===================================================================
--- branches/dbmod/command.c 2009-08-24 23:11:59 UTC (rev 132)
+++ branches/dbmod/command.c 2009-08-25 00:38:39 UTC (rev 133)
@@ -97,8 +97,7 @@
if (cmd->args_len < 1)
return(0);
-/* XXX - strtoul*/
- rtrn = (unsigned int)atoi((char *)cmd->args[cmd->args_len - 1]->s);
+ rtrn = (unsigned int)strtoul((char *)cmd->args[cmd->args_len - 1]->s, NULL, 10);
return(rtrn);
}
Modified: branches/dbmod/contacts.c
===================================================================
--- branches/dbmod/contacts.c 2009-08-24 23:11:59 UTC (rev 132)
+++ branches/dbmod/contacts.c 2009-08-25 00:38:39 UTC (rev 133)
@@ -364,7 +364,7 @@
return(RFAIL);
}
} else if (buf.len >= 1 &&
- strtoul((char *)buf.s, (char **)0, 10) > 0) {
+ strtoul((char *)buf.s, NULL, 10) > 0) {
break;
}
}
Modified: branches/dbmod/db.c
===================================================================
--- branches/dbmod/db.c 2009-08-24 23:11:59 UTC (rev 132)
+++ branches/dbmod/db.c 2009-08-25 00:38:39 UTC (rev 133)
@@ -17,6 +17,7 @@
static const char rcsid[] = "$Id$";
#include <sys/types.h>
+#include <sys/stat.h>
#include <errno.h>
#include <dlfcn.h>
@@ -77,6 +78,7 @@
int
db_mod_load(string *db_mod) {
struct mod_cmds_ *cmd;
+ struct stat st;
int i;
if (db_mod->len == 0) {
@@ -84,7 +86,11 @@
return -1;
}
-/* XXX - stat file */
+ if (stat((char *)db_mod->s, &st) == -1) {
+ log->debug("debug: cannot stat module: [%s]: [%S]\n", db_mod,
+ strerror(errno));
+ return(-1);
+ }
if (db_mod->len > 0 && str_copy(&db.modPath, db_mod->s, db_mod->len) == 0)
die_nomem();
@@ -112,6 +118,12 @@
if (db.modLoad(&db) == -1)
return(-1);
+ if (db.modVersion < MINMOD_VERSION) {
+ log->debug("debug: database module out of sync, please reinstall the module.\n");
+ return(-1);
+ }
+
+ /* module load ok */
++db_mod_count;
if (db_mod_count == 0)
Modified: branches/dbmod/db.h
===================================================================
--- branches/dbmod/db.h 2009-08-24 23:11:59 UTC (rev 132)
+++ branches/dbmod/db.h 2009-08-25 00:38:39 UTC (rev 133)
@@ -23,6 +23,8 @@
#include "string.h"
+#define MINMOD_VERSION 1
+
struct mod_ {
/* cmds or functions */
int (*sql_log_msg)();
@@ -53,6 +55,7 @@
void *data;
string modName;
string modPath;
+ int modVersion;
};
struct mod_cmds_ {
Modified: branches/dbmod/db_modules/mysql/mysql.c
===================================================================
--- branches/dbmod/db_modules/mysql/mysql.c 2009-08-24 23:11:59 UTC (rev 132)
+++ branches/dbmod/db_modules/mysql/mysql.c 2009-08-25 00:38:39 UTC (rev 133)
@@ -16,7 +16,8 @@
static const char rcsid[] = "$Id$";
-#define MODULE_NAME "mysql"
+#define MODULE_NAME "mysql"
+#define MODULE_VERSION 1
#include <sys/types.h>
#include <sys/stat.h>
@@ -563,6 +564,8 @@
if (str_copys(&mod->modName, (unsigned char *)MODULE_NAME) == 0)
die_nomem();
+ mod->modVersion = MODULE_VERSION;
+
/* read mysql configuration */
if (db_read_conf(&mysql, MYSQLCONFDIR) == RFAIL)
return(-1);
Modified: branches/dbmod/db_modules/pgsql/pgsql.c
===================================================================
--- branches/dbmod/db_modules/pgsql/pgsql.c 2009-08-24 23:11:59 UTC (rev 132)
+++ branches/dbmod/db_modules/pgsql/pgsql.c 2009-08-25 00:38:39 UTC (rev 133)
@@ -16,7 +16,8 @@
static const char rcsid[] = "$Id$";
-#define MODULE_NAME "pgsql"
+#define MODULE_NAME "pgsql"
+#define MODULE_VERSION 1
#include <sys/types.h>
#include <sys/stat.h>
@@ -472,6 +473,8 @@
if (str_copys(&mod->modName, (unsigned char *)MODULE_NAME) == 0)
die_nomem();
+ mod->modVersion = MODULE_VERSION;
+
/* read pgsql configuration */
if (db_read_conf(&pgsql, PGSQLCONFDIR) == RFAIL)
return(-1);
Modified: branches/dbmod/net-io.c
===================================================================
--- branches/dbmod/net-io.c 2009-08-24 23:11:59 UTC (rev 132)
+++ branches/dbmod/net-io.c 2009-08-25 00:38:39 UTC (rev 133)
@@ -256,17 +256,23 @@
}
int
-resolve_client(string *str_host, struct sockaddr *sa, socklen_t sa_len) {
+resolve_client(string *str_host, string *str_port, struct sockaddr *sa,
+ socklen_t sa_len) {
static char host[NI_MAXHOST];
+ static char port[NI_MAXSERV];
memset(host, 0, NI_MAXHOST);
/* get the user network address */
- if (getnameinfo(sa, sa_len, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0)
+ if (getnameinfo(sa, sa_len, host, sizeof(host), port, sizeof(port),
+ NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
return(RFAIL);
+ }
- if (str_copys(str_host, (unsigned char *)host) == 0)
+ if ((strlen(host) > 0 && str_copys(str_host, (unsigned char *)host) == 0) ||
+ (strlen(port) > 0 && str_copys(str_port, (unsigned char *)port) == 0)) {
die_nomem();
+ }
return(ROK);
}
Modified: branches/dbmod/net-io.h
===================================================================
--- branches/dbmod/net-io.h 2009-08-24 23:11:59 UTC (rev 132)
+++ branches/dbmod/net-io.h 2009-08-25 00:38:39 UTC (rev 133)
@@ -32,9 +32,8 @@
int net_listen(const char *host, const char *port, int backlog);
int net_connect(const char *host, const char *port);
string *bind_free_port( unsigned int port_min,
- unsigned int port_max,
- string *host,
- int *listenfd);
-int resolve_client(string *str_host, struct sockaddr *sa, socklen_t sa_len);
+ unsigned int port_max, string *host, int *listenfd);
+int resolve_client(string *str_host, string *str_port,
+ struct sockaddr *sa, socklen_t sa_len);
#endif
Modified: branches/dbmod/protocol.c
===================================================================
--- branches/dbmod/protocol.c 2009-08-24 23:11:59 UTC (rev 132)
+++ branches/dbmod/protocol.c 2009-08-25 00:38:39 UTC (rev 133)
@@ -678,14 +678,12 @@
int
msn_sb_id(struct sb_ *sb, command *cmd) {
- char *ep;
if (strcmp((char *)cmd->cmd.s, "XFR") == 0) {
- sb->sb_session_id = strtoul((char *)cmd->args[4]->s, &ep, 10);
+ sb->sb_session_id = strtoul((char *)cmd->args[4]->s, NULL, 10);
} else {
-
/* RNG command */
- sb->sb_session_id = strtoul((char *)cmd->args[0]->s, &ep, 10);
+ sb->sb_session_id = strtoul((char *)cmd->args[0]->s, NULL, 10);
}
return(ROK);
}
@@ -905,13 +903,12 @@
int
server_msnp12_pre_usr(struct user_ *user, command *cmd) {
- string *dn;
+ string *dn;
/* USR OK - authentication sucessfull */
- /* XXX - xarg */
if (cmd->args_len == 5 &&
- check_arg(cmd->args[1], "OK") == ROK &&
- check_arg(cmd->args[4], "0") == ROK ) {
+ check_arg(cmd->args[1], "OK") == ROK &&
+ check_arg(cmd->args[4], "0") == ROK ) {
/* save user state */
user->state &= ~USR_TWN_S;
@@ -934,15 +931,15 @@
/* TWN S - hash for authentication */
} else if (cmd->args_len == 4 &&
- check_arg(cmd->args[1], "TWN") == ROK &&
- check_arg(cmd->args[2], "S") == ROK ) {
+ check_arg(cmd->args[1], "TWN") == ROK &&
+ check_arg(cmd->args[2], "S") == ROK ) {
user->state &= ~USR_TWN_I;
user->state |= USR_TWN_S;
return(ROK);
} else if (cmd->args_len == 5 &&
- check_arg(cmd->args[1], "SSO") == ROK &&
- check_arg(cmd->args[2], "S") == ROK ) {
+ check_arg(cmd->args[1], "SSO") == ROK &&
+ check_arg(cmd->args[2], "S") == ROK ) {
user->state &= ~USR_TWN_I;
user->state |= USR_TWN_S;
Modified: branches/dbmod/user.c
===================================================================
--- branches/dbmod/user.c 2009-08-24 23:11:59 UTC (rev 132)
+++ branches/dbmod/user.c 2009-08-25 00:38:39 UTC (rev 133)
@@ -183,6 +183,7 @@
user_free(struct user_ *user) {
str_free(&user->dn);
str_free(&user->addr);
+ str_free(&user->port);
str_free(&user->email);
str_free(&user->status);
free(user);
@@ -209,7 +210,7 @@
if (str_copys(&user->status, (unsigned char *)"OFF") == 0) die_nomem();
/* get the user ip address */
- if (resolve_client(&user->addr, sa, sa_len) == RFAIL) {
+ if (resolve_client(&user->addr, &user->port, sa, sa_len) == RFAIL) {
log->debug("debug: fail to get ns client address\n");
user = user_free(user);
return(NULL);
@@ -221,7 +222,7 @@
return(NULL);
}
- log->debug("debug: connection from [%s]\n", &user->addr);
+ log->debug("debug: connection from [%s]:[%s]\n", &user->addr, &user->port);
return(user);
}
@@ -293,7 +294,7 @@
log->debug("user display name.....: [%s]\n", &user->dn);
log->debug("user status...........: [%s]\n", &user->status);
log->debug("user email............: [%s]\n", &user->email);
- log->debug("user host.............: [%s]\n", &user->addr);
+ log->debug("user host.............: [%s:%s]\n", &user->addr, &user->port);
/* print the ns information */
ns_stat(&user->ns);
Modified: branches/dbmod/user.h
===================================================================
--- branches/dbmod/user.h 2009-08-24 23:11:59 UTC (rev 132)
+++ branches/dbmod/user.h 2009-08-25 00:38:39 UTC (rev 133)
@@ -55,6 +55,7 @@
string dn; /* display name */
string addr; /* client ip */
+ string port; /* client port */
string email; /* msn user */
string status; /* client status */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lo...@us...> - 2009-08-24 23:12:10
|
Revision: 132
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=132&view=rev
Author: loos-br
Date: 2009-08-24 23:11:59 +0000 (Mon, 24 Aug 2009)
Log Message:
-----------
- pequenas correcoes
- sb_users convertido para lista red/black para evitar duplicidades
Modified Paths:
--------------
branches/dbmod/client.c
branches/dbmod/contacts.c
branches/dbmod/event.c
branches/dbmod/msg.c
branches/dbmod/ns.c
branches/dbmod/sb-data.h
branches/dbmod/sb.c
branches/dbmod/sb.h
branches/dbmod/server.c
branches/dbmod/user.c
Modified: branches/dbmod/client.c
===================================================================
--- branches/dbmod/client.c 2009-08-24 19:28:43 UTC (rev 131)
+++ branches/dbmod/client.c 2009-08-24 23:11:59 UTC (rev 132)
@@ -51,6 +51,9 @@
client = (struct client_ *)malloc(sizeof(*client));
if (client == NULL) die_nomem();
memset(client, 0, sizeof(*client));
+ client->read.ev_fd = -1;
+ client->write.ev_fd = -1;
+ client->listen.ev_fd = -1;
/* prepare commands */
commands_init(&client->commands);
Modified: branches/dbmod/contacts.c
===================================================================
--- branches/dbmod/contacts.c 2009-08-24 19:28:43 UTC (rev 131)
+++ branches/dbmod/contacts.c 2009-08-24 23:11:59 UTC (rev 132)
@@ -30,11 +30,9 @@
int
contact_rb_cmp(struct contact_ *c1, struct contact_ *c2) {
- if (!c1 || !c1->c.s || !c1->c.len ||
- !c2 || !c2->c.s || !c2->c.len) {
- return(0);
- }
- return strcmp((char *)c1->c.s, (char *)c2->c.s);
+ if (c1 && c2 && c1->c.len > 0 && c2->c.len > 0)
+ return(strcasecmp((char *)c1->c.s, (char *)c2->c.s));
+ return(0);
}
RB_GENERATE(contacts, contact_, contact__, contact_rb_cmp)
Modified: branches/dbmod/event.c
===================================================================
--- branches/dbmod/event.c 2009-08-24 19:28:43 UTC (rev 131)
+++ branches/dbmod/event.c 2009-08-24 23:11:59 UTC (rev 132)
@@ -26,6 +26,8 @@
struct timeval tv;
time_t now;
+ if (ev->ev_fd < 0) return;
+
log->debug(" -- %S --\n", display);
memset(&tv, 0, sizeof(tv));
Modified: branches/dbmod/msg.c
===================================================================
--- branches/dbmod/msg.c 2009-08-24 19:28:43 UTC (rev 131)
+++ branches/dbmod/msg.c 2009-08-24 23:11:59 UTC (rev 132)
@@ -19,6 +19,7 @@
#include <string.h>
#include "db.h"
+#include "sb.h"
#include "msg.h"
#include "return.h"
#include "contacts.h"
@@ -353,17 +354,13 @@
int
msg_decode_utf8(struct sb_ *sb, command *cmd, msg_ *msg, int type) {
- struct contact_ *contact, *save, f;
- struct sb_user_ *sb_user;
struct user_ *user = sb->user;
string dn;
string to;
string tmp;
string *dn_;
string *email;
- int to_start;
- to_start = 0;
str_zero(&tmp);
str_zero(&dn);
str_zero(&to);
@@ -377,67 +374,9 @@
return(RFAIL);
email = cmd->args[0];
- SLIST_FOREACH(sb_user, &sb->sb_users, sb_user__) {
-
- if (sb_user->email.len == 0) continue;
-
- if (type == SERVER && email && email->len > 0 &&
- strcmp((char *)sb_user->email.s, (char *)email->s) == 0) {
- if (to_start && str_cats(&to, (unsigned char *)", ") == 0)
- die_nomem();
- if (user->dn.len > 0 &&
- str_cat(&to, user->dn.s, user->dn.len) == 0)
- die_nomem();
- if (str_cats(&to, (unsigned char *)" (") == 0)
- die_nomem();
- if (user->email.len > 0 &&
- str_cat(&to, user->email.s, user->email.len) == 0)
- die_nomem();
- if (str_cats(&to, (unsigned char *)")") == 0)
- die_nomem();
-
- if (!to_start) to_start = 1;
-
- } else if(strcmp((char *)user->email.s,(char *)sb_user->email.s) !=0) {
-
- memset(&f, 0, sizeof(f));
- if (str_copy(&f.c, sb_user->email.s, sb_user->email.len) == 0)
- die_nomem();
-
- contact = RB_FIND(contacts, &user->contacts, &f);
- contact_free(&f);
-
- if (contact && (contact->deny & CONTACT_DENY)) {
- log->debug("debug: user %s can not send messages to %s (blocked).\n", &user->email, &contact->c);
- str_free(&tmp);
- return(RETURN);
- }
-
- if (contact && contact->chat != YES) {
-
- save = contact_update(user, &contact->c);
- if (save) {
- save->chat = YES;
- (void)db.sql_contact_save(user, save);
- }
- contact->chat = YES;
- }
-
- if (to_start && str_cats(&to, (unsigned char *)", ") == 0)
- die_nomem();
- if (contact && contact->dn.len > 0 &&
- str_cat(&to, contact->dn.s, contact->dn.len) == 0)
- die_nomem();
- if (str_cats(&to, (unsigned char *)" (") == 0)
- die_nomem();
- if (sb_user->email.len > 0 &&
- str_cat(&to, sb_user->email.s, sb_user->email.len) == 0)
- die_nomem();
- if (str_cats(&to, (unsigned char *)")") == 0)
- die_nomem();
-
- if (!to_start) to_start = 1;
- }
+ if (sb_get_msg_to(sb, email, &to, type) == -1) {
+ str_free(&dn);
+ return(RETURN); /* return if contact denied */
}
switch (type) {
Modified: branches/dbmod/ns.c
===================================================================
--- branches/dbmod/ns.c 2009-08-24 19:28:43 UTC (rev 131)
+++ branches/dbmod/ns.c 2009-08-24 23:11:59 UTC (rev 132)
@@ -313,11 +313,15 @@
if (proxy == NULL) die_nomem();
memset(proxy, 0, sizeof(*proxy));
+ proxy->fd = -1;
+ proxy->read.ev_fd = -1;
+ proxy->write.ev_fd = -1;
+ proxy->listen.ev_fd = -1;
+
/* bind to free port for new client connection */
- proxy->fd = -1;
port = bind_free_port(config.port_min, config.port_max,
&config.defaults.proxy_ip, &proxy->fd);
- if (port == (string *)0) {
+ if (port == NULL) {
/* cannot allocate any port */
free(proxy);
return(RFAIL);
@@ -353,11 +357,15 @@
if (proxy == NULL) die_nomem();
memset(proxy, 0, sizeof(*proxy));
+ proxy->fd = -1;
+ proxy->read.ev_fd = -1;
+ proxy->write.ev_fd = -1;
+ proxy->listen.ev_fd = -1;
+
/* bind to free port for new client connection */
- proxy->fd = -1;
port = bind_free_port(config.port_min, config.port_max,
&config.defaults.proxy_ip, &proxy->fd);
- if (port == (string *)0) {
+ if (port == NULL) {
/* cannot allocate any port */
free(proxy);
return(RFAIL);
Modified: branches/dbmod/sb-data.h
===================================================================
--- branches/dbmod/sb-data.h 2009-08-24 19:28:43 UTC (rev 131)
+++ branches/dbmod/sb-data.h 2009-08-24 23:11:59 UTC (rev 132)
@@ -30,16 +30,16 @@
#include "server.h"
struct sb_user_ {
- SLIST_ENTRY(sb_user_) sb_user__;
+ RB_ENTRY(sb_user_) sb_user__;
string email;
};
-struct sb_users {
- struct sb_user_ *slh_first; /* first element */
+struct sb_users_ {
+ struct sb_user_ *rbh_root;
};
struct sb_ {
- struct sb_users sb_users; /* list of connected users */
+ struct sb_users_ sb_users; /* list of connected users */
LIST_ENTRY(sb_) sb__; /* sb list */
struct event listen; /* listen event */
struct user_ *user; /* pointer to user */
Modified: branches/dbmod/sb.c
===================================================================
--- branches/dbmod/sb.c 2009-08-24 19:28:43 UTC (rev 131)
+++ branches/dbmod/sb.c 2009-08-24 23:11:59 UTC (rev 132)
@@ -35,6 +35,16 @@
#include "check-cmd.h"
#include "msn-proxy.h"
+int
+sb_users_rb_cmp(struct sb_user_ *u1, struct sb_user_ *u2) {
+ if (u1 && u2 && u1->email.len > 0 && u2->email.len > 0)
+ return(strcasecmp((char *)u1->email.s, (char *)u2->email.s));
+ return(0);
+}
+
+RB_GENERATE(sb_users_, sb_user_, sb_user__, sb_users_rb_cmp)
+
+
#if 0
void
msn_sb_session(struct sb_ *sb, string *email) {
@@ -91,7 +101,7 @@
}
/* initialize users list */
- SLIST_INIT(&sb->sb_users);
+ RB_INIT(&sb->sb_users);
/* insert this new sb on user sb_list */
LIST_INSERT_HEAD(&user->sbs, sb, sb__);
@@ -102,25 +112,109 @@
struct sb_user_ *
sb_user_alloc(struct sb_ *sb, string *email) {
struct sb_user_ *sb_user;
+ struct sb_user_ *tmp;
sb_user = (struct sb_user_ *)malloc(sizeof(struct sb_user_));
if (sb_user == NULL) die_nomem();
memset(sb_user, 0, sizeof(struct sb_user_));
- SLIST_INSERT_HEAD(&sb->sb_users, sb_user, sb_user__);
if (email->len > 0 && str_copy(&sb_user->email, email->s, email->len) == 0)
die_nomem();
+
+ /* insert/very the rb list */
+ tmp = RB_INSERT(sb_users_, &sb->sb_users, sb_user);
+ if (tmp != NULL) {
+ str_free(&sb_user->email);
+ free(sb_user);
+ sb_user = tmp;
+ }
+
return(sb_user);
}
struct sb_user_ *
sb_user_free(struct sb_ *sb, struct sb_user_ *sb_user) {
- SLIST_REMOVE(&sb->sb_users, sb_user, sb_user_, sb_user__);
+ RB_REMOVE(sb_users_, &sb->sb_users, sb_user);
str_free(&sb_user->email);
free(sb_user);
return(NULL);
}
+int
+sb_get_msg_to(struct sb_ *sb, string *email, string *to, int type) {
+ struct contact_ *contact;
+ struct contact_ *save;
+ struct contact_ f;
+ struct sb_user_ *sb_user;
+ struct user_ *user;
+ int to_start;
+
+ user = sb->user;
+ to_start = 0;
+ RB_FOREACH(sb_user, sb_users_, &sb->sb_users) {
+
+ if (sb_user->email.len == 0) continue;
+
+ if (type == SERVER && email && email->len > 0 &&
+ strcmp((char *)sb_user->email.s, (char *)email->s) == 0) {
+ if (to_start && str_cats(to, (unsigned char *)", ") == 0)
+ die_nomem();
+ if (user->dn.len > 0 &&
+ str_cat(to, user->dn.s, user->dn.len) == 0)
+ die_nomem();
+ if (str_cats(to, (unsigned char *)" (") == 0)
+ die_nomem();
+ if (user->email.len > 0 &&
+ str_cat(to, user->email.s, user->email.len) == 0)
+ die_nomem();
+ if (str_cats(to, (unsigned char *)")") == 0)
+ die_nomem();
+
+ if (!to_start) to_start = 1;
+
+ } else if(strcmp((char *)user->email.s,(char *)sb_user->email.s) !=0) {
+
+ memset(&f, 0, sizeof(f));
+ if (str_copy(&f.c, sb_user->email.s, sb_user->email.len) == 0)
+ die_nomem();
+
+ contact = RB_FIND(contacts, &user->contacts, &f);
+ contact_free(&f);
+
+ if (contact && (contact->deny & CONTACT_DENY)) {
+ log->debug("debug: user %s can not send messages to %s (blocked).\n", &user->email, &contact->c);
+ return(-1);
+ }
+
+ if (contact && contact->chat != YES) {
+
+ save = contact_update(user, &contact->c);
+ if (save) {
+ save->chat = YES;
+ (void)db.sql_contact_save(user, save);
+ }
+ contact->chat = YES;
+ }
+
+ if (to_start && str_cats(to, (unsigned char *)", ") == 0)
+ die_nomem();
+ if (contact && contact->dn.len > 0 &&
+ str_cat(to, contact->dn.s, contact->dn.len) == 0)
+ die_nomem();
+ if (str_cats(to, (unsigned char *)" (") == 0)
+ die_nomem();
+ if (sb_user->email.len > 0 &&
+ str_cat(to, sb_user->email.s, sb_user->email.len) == 0)
+ die_nomem();
+ if (str_cats(to, (unsigned char *)")") == 0)
+ die_nomem();
+
+ if (!to_start) to_start = 1;
+ }
+ }
+ return(0);
+}
+
void
sb_connect(const int listenfd, short event, void *p) {
struct sockaddr client_sa;
@@ -181,6 +275,7 @@
struct sb_ *
sb_disconnect(struct sb_ *sb) {
struct sb_user_ *sb_user;
+ struct sb_user_ *sb_next;
/* remove sb session from sql */
db.sql_remove_sb(sb->id);
@@ -204,8 +299,10 @@
str_free(&sb->start);
/* free sb->sb_users */
- while (!SLIST_EMPTY(&sb->sb_users)) {
- sb_user = SLIST_FIRST(&sb->sb_users);
+ for (sb_user = RB_MIN(sb_users_, &sb->sb_users); sb_user != NULL;
+ sb_user = sb_next) {
+
+ sb_next = RB_NEXT(sb_users_, &sb->sb_users, sb_user);
sb_user = sb_user_free(sb, sb_user);
}
@@ -609,36 +706,29 @@
int
msn_sb_post_bye(struct sb_ *sb, command *cmd) {
struct sb_user_ *sb_user;
- struct sb_user_ *sb_next;
- string passport;
+ struct sb_user_ f;
string *email;
if (cmd->args_len < 1 || (email = get_arg(cmd, 0)) != NULL) {
return(RFAIL);
}
- str_zero(&passport);
- msn_tok_epdata(email, &passport);
+ memset(&f, 0, sizeof(f));
+ msn_tok_epdata(email, &f.email);
/* safety */
- if (passport.len == 0) return(RFAIL);
+ if (f.email.len == 0) return(RFAIL);
- sb_next = NULL;
- sb_user = SLIST_FIRST(&sb->sb_users);
- for ( ; sb_user != NULL; sb_user = sb_next) {
+ sb_user = RB_FIND(sb_users_, &sb->sb_users, &f);
+ str_free(&f.email);
- sb_next = SLIST_NEXT(sb_user, sb_user__);
-
- if (strcmp((char *)sb_user->email.s, (char *)passport.s) != 0)
- continue;
-
+ /* free sb_user */
+ if (sb_user != NULL) {
sb_user = sb_user_free(sb, sb_user);
}
- str_free(&passport);
-
/* last user on this sb connection ? */
- if (SLIST_EMPTY(&sb->sb_users))
+ if (RB_EMPTY(&sb->sb_users))
return(DISCONNECT);
return(ROK);
@@ -681,7 +771,7 @@
log->debug("sb xfr................: [%s][%d]\n", sb->xfr, sb->xfr->len);
/* print the users connected to this sb session */
- SLIST_FOREACH(sb_user, &sb->sb_users, sb_user__) {
+ RB_FOREACH(sb_user, sb_users_, &sb->sb_users) {
log->debug("sb user...............: [%s][%d]\n", &sb_user->email,
sb_user->email.len);
}
Modified: branches/dbmod/sb.h
===================================================================
--- branches/dbmod/sb.h 2009-08-24 19:28:43 UTC (rev 131)
+++ branches/dbmod/sb.h 2009-08-24 23:11:59 UTC (rev 132)
@@ -23,26 +23,27 @@
#include "user.h"
-void sb_free_xfr(struct sb_ *sb);
+void sb_free_xfr(struct sb_ *sb);
struct sb_ *sb_alloc(struct user_ *user);
-void sb_connect(const int listenfd, short event, void *p);
+void sb_connect(const int listenfd, short event, void *p);
struct sb_ *sb_disconnect(struct sb_ *sb);
-void sb_disconnect_all(struct user_ *user);
-void sb_client_write(const int evfd, short event, void *p);
-void sb_client_read(const int evfd, short event, void *p);
-void sb_server_read(int evfd, short event, void *p);
-void sb_server_write(int evfd, short event, void *p);
+void sb_disconnect_all(struct user_ *user);
+void sb_client_write(const int evfd, short event, void *p);
+void sb_client_read(const int evfd, short event, void *p);
+void sb_server_read(int evfd, short event, void *p);
+void sb_server_write(int evfd, short event, void *p);
struct sb_ *sb_proxy(struct user_ *user, string **arg);
-int xfr_sb_proxy(struct user_ *user, command *cmd);
-int rng_sb_proxy(struct user_ *user, command *cmd);
-int msn_sb_joi(struct sb_ *sb, command *cmd);
-int msn_sb_post_out(struct sb_ *sb, command *cmd);
-int msn_sb_iro(struct sb_ *sb, command *cmd);
-int msn_sb_post_bye(struct sb_ *sb, command *cmd);
-int msn_sb_cal(struct sb_ *sb, command *cmd);
+int xfr_sb_proxy(struct user_ *user, command *cmd);
+int rng_sb_proxy(struct user_ *user, command *cmd);
+int msn_sb_joi(struct sb_ *sb, command *cmd);
+int msn_sb_post_out(struct sb_ *sb, command *cmd);
+int msn_sb_iro(struct sb_ *sb, command *cmd);
+int msn_sb_post_bye(struct sb_ *sb, command *cmd);
+int msn_sb_cal(struct sb_ *sb, command *cmd);
struct sb_user_ *sb_user_free(struct sb_ *sb, struct sb_user_ *sb_user);
-void msn_sb_session(struct sb_ *sb, string *email);
-void sb_stat(struct sb_ *sb);
-void sbs_stat(struct user_ *user);
+int sb_get_msg_to(struct sb_ *sb, string *email, string *to, int type);
+void msn_sb_session(struct sb_ *sb, string *email);
+void sb_stat(struct sb_ *sb);
+void sbs_stat(struct user_ *user);
#endif
Modified: branches/dbmod/server.c
===================================================================
--- branches/dbmod/server.c 2009-08-24 19:28:43 UTC (rev 131)
+++ branches/dbmod/server.c 2009-08-24 23:11:59 UTC (rev 132)
@@ -256,14 +256,11 @@
server_stat(struct server_ *server) {
log->debug("server fd.............: [%d]\n", server->fd);
- if (server->host.len > 0) {
- log->debug("server host...........: [%s][%d]\n", &server->host,
- server->host.len);
+ if (server->host.len > 0 && server->port.len > 0) {
+ log->debug("server host...........: [%s][%d]:[%s][%d]\n",
+ &server->host, server->host.len,
+ &server->port, server->port.len);
}
- if (server->port.len > 0) {
- log->debug("server port...........: [%s][%d]\n", &server->port,
- server->port.len);
- }
/* print the command information */
commands_stat(&server->commands);
Modified: branches/dbmod/user.c
===================================================================
--- branches/dbmod/user.c 2009-08-24 19:28:43 UTC (rev 131)
+++ branches/dbmod/user.c 2009-08-24 23:11:59 UTC (rev 132)
@@ -206,6 +206,7 @@
user->state = PRE_AUTH;
RB_INIT(&user->contacts);
LIST_INIT(&user->sbs);
+ if (str_copys(&user->status, (unsigned char *)"OFF") == 0) die_nomem();
/* get the user ip address */
if (resolve_client(&user->addr, sa, sa_len) == RFAIL) {
@@ -312,7 +313,7 @@
log->debug("-- msn-proxy users statistics --\n");
log->debug("users count...........: %d/%d/%d (now/peak/max)\n", user_inuse,
user_max, config.max_clients);
- log->debug("user id counter.......: [%d]\n", user_id);
+ log->debug("user id counter.......: [%d]\n\n", user_id);
RB_FOREACH(user, users_, &users) user_stat(user);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lo...@us...> - 2009-08-24 19:28:53
|
Revision: 131
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=131&view=rev
Author: loos-br
Date: 2009-08-24 19:28:43 +0000 (Mon, 24 Aug 2009)
Log Message:
-----------
- sb stats
- limpeza no codigo de proxy de sb - switch board
- nao sera mais logado a abertura e fechamento de conexoes isso e um tanto sem
sentido. A partir de agora logaremos apenas as acoes (mensagens, arquivos
transferidos, etc)
Modified Paths:
--------------
branches/dbmod/db.c
branches/dbmod/db_modules/mysql/sql.c
branches/dbmod/db_modules/mysql/sql.h
branches/dbmod/db_modules/pgsql/sql.c
branches/dbmod/db_modules/pgsql/sql.h
branches/dbmod/msg.c
branches/dbmod/msnp12.h
branches/dbmod/msnp18.h
branches/dbmod/msnp8.h
branches/dbmod/protocol.c
branches/dbmod/protocol.h
branches/dbmod/sb-data.h
branches/dbmod/sb.c
branches/dbmod/sb.h
branches/dbmod/user.c
Modified: branches/dbmod/db.c
===================================================================
--- branches/dbmod/db.c 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/db.c 2009-08-24 19:28:43 UTC (rev 131)
@@ -40,10 +40,6 @@
{ (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" },
Modified: branches/dbmod/db_modules/mysql/sql.c
===================================================================
--- branches/dbmod/db_modules/mysql/sql.c 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/db_modules/mysql/sql.c 2009-08-24 19:28:43 UTC (rev 131)
@@ -291,93 +291,6 @@
}
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(), '%q', '%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(&mysql, &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(&mysql, &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(), '%q', '%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(&mysql, &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(), '%q', '%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(&mysql, &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`) "
Modified: branches/dbmod/db_modules/mysql/sql.h
===================================================================
--- branches/dbmod/db_modules/mysql/sql.h 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/db_modules/mysql/sql.h 2009-08-24 19:28:43 UTC (rev 131)
@@ -32,10 +32,6 @@
int sql_update_user_dn(struct user_ *user);
unsigned int sql_insert_sb(struct user_ *user);
int sql_remove_sb(int id);
-int sql_log_join(int sb_id, string *email, string *dn);
-int sql_log_stop2(struct sb_ *sb, string *email, string *contact_email);
-int sql_log_stop(struct sb_ *sb, string *email, string *dn);
-int sql_log_start(int sb_id, string *email, string *dn);
int sql_log_msg(int sb_id, string *email, string *dn, string *to,
string *msg);
int sql_read_defaults(void);
Modified: branches/dbmod/db_modules/pgsql/sql.c
===================================================================
--- branches/dbmod/db_modules/pgsql/sql.c 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/db_modules/pgsql/sql.c 2009-08-24 19:28:43 UTC (rev 131)
@@ -298,93 +298,6 @@
}
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\") "
Modified: branches/dbmod/db_modules/pgsql/sql.h
===================================================================
--- branches/dbmod/db_modules/pgsql/sql.h 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/db_modules/pgsql/sql.h 2009-08-24 19:28:43 UTC (rev 131)
@@ -32,10 +32,6 @@
int sql_update_user_dn(struct user_ *user);
unsigned int sql_insert_sb(struct user_ *user);
int sql_remove_sb(int id);
-int sql_log_join(int sb_id, string *email, string *dn);
-int sql_log_stop2(struct sb_ *sb, string *email, string *contact_email);
-int sql_log_stop(struct sb_ *sb, string *email, string *dn);
-int sql_log_start(int sb_id, string *email, string *dn);
int sql_log_msg(int sb_id, string *email, string *dn, string *to,
string *msg);
int sql_read_defaults(void);
Modified: branches/dbmod/msg.c
===================================================================
--- branches/dbmod/msg.c 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/msg.c 2009-08-24 19:28:43 UTC (rev 131)
@@ -262,10 +262,11 @@
return(ROK);
}
- if (sb->ctl == YES) {
- msg_free(&msg);
- return(ROK);
- }
+ /* XXX - check for the same session id on the proxy */
+// if (sb->ctl == YES) {
+// msg_free(&msg);
+// return(ROK);
+// }
if ((user->commands & LOGWARNING) && sb->warned == NO) {
msn_warning_msg_client(sb);
Modified: branches/dbmod/msnp12.h
===================================================================
--- branches/dbmod/msnp12.h 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/msnp12.h 2009-08-24 19:28:43 UTC (rev 131)
@@ -100,7 +100,7 @@
{ "ANS", NULL },
{ "BYE", NULL },
{ "CAL", NULL },
- { "IRO", sb_iro },
+ { "IRO", msn_sb_iro },
{ "JOI", msn_sb_joi },
{ "MSG", msn_sb_server_msg },
{ "USR", NULL },
Modified: branches/dbmod/msnp18.h
===================================================================
--- branches/dbmod/msnp18.h 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/msnp18.h 2009-08-24 19:28:43 UTC (rev 131)
@@ -106,7 +106,7 @@
{ "ANS", NULL },
{ "BYE", NULL },
{ "CAL", NULL },
- { "IRO", sb_iro },
+ { "IRO", msn_sb_iro },
{ "JOI", msn_sb_joi },
{ "MSG", msn_sb_server_msg },
{ "USR", NULL },
Modified: branches/dbmod/msnp8.h
===================================================================
--- branches/dbmod/msnp8.h 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/msnp8.h 2009-08-24 19:28:43 UTC (rev 131)
@@ -92,7 +92,7 @@
{ "ANS", NULL },
{ "BYE", NULL },
{ "CAL", NULL },
- { "IRO", sb_iro },
+ { "IRO", msn_sb_iro },
{ "JOI", msn_sb_joi },
{ "MSG", msn_sb_server_msg },
{ "USR", NULL },
Modified: branches/dbmod/protocol.c
===================================================================
--- branches/dbmod/protocol.c 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/protocol.c 2009-08-24 19:28:43 UTC (rev 131)
@@ -685,7 +685,7 @@
} else {
/* RNG command */
- sb->sb_session_id = strtoul((char *)cmd->args[0]->s,&ep,10);
+ sb->sb_session_id = strtoul((char *)cmd->args[0]->s, &ep, 10);
}
return(ROK);
}
@@ -1360,3 +1360,22 @@
return(ROK);
}
+
+void
+msn_tok_epdata(string *str, string *out) {
+
+ if (str == NULL || str->len == 0) return;
+
+ str->p = (unsigned char *)strchr((char *)str->s, ';');
+ if (str->p != NULL && str->p > str->s && str->p - str->s < str->len - 1) {
+
+ if ((size_t)(str->p - str->s) > 0 &&
+ str_copy(out, str->s, (size_t)(str->p - str->s)) == 0) {
+ die_nomem();
+ }
+ } else {
+
+ if (str->len > 0 && str_copy(out, str->s, str->len) == 0)
+ die_nomem();
+ }
+}
Modified: branches/dbmod/protocol.h
===================================================================
--- branches/dbmod/protocol.h 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/protocol.h 2009-08-24 19:28:43 UTC (rev 131)
@@ -97,5 +97,6 @@
int msnp18_adl_sync(struct user_ *user, command *cmd);
int msn_sb_id(struct sb_ *sb, command *cmd);
int send_out(struct user_ *user);
+void msn_tok_epdata(string *str, string *out);
#endif
Modified: branches/dbmod/sb-data.h
===================================================================
--- branches/dbmod/sb-data.h 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/sb-data.h 2009-08-24 19:28:43 UTC (rev 131)
@@ -49,8 +49,6 @@
unsigned long long sb_session_id; /* sb session id - XXX */
unsigned short warned; /* warned about message logging */
- unsigned short closed; /* need to log stop at disconnect ? */
- unsigned short ctl;
unsigned int id; /* sql chat id - XXX */
string start;
Modified: branches/dbmod/sb.c
===================================================================
--- branches/dbmod/sb.c 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/sb.c 2009-08-24 19:28:43 UTC (rev 131)
@@ -26,6 +26,7 @@
#include "db.h"
#include "sb.h"
+#include "event.h"
#include "net-io.h"
#include "return.h"
#include "contacts.h"
@@ -34,6 +35,7 @@
#include "check-cmd.h"
#include "msn-proxy.h"
+#if 0
void
msn_sb_session(struct sb_ *sb, string *email) {
@@ -56,13 +58,15 @@
}
}
+#endif
void
sb_free_xfr(struct sb_ *sb) {
- if (sb->xfr) {
+
+ if (sb->xfr != NULL) {
str_free(sb->xfr);
free(sb->xfr);
- sb->xfr = (string *)0;
+ sb->xfr = NULL;
}
}
@@ -74,11 +78,9 @@
if (sb == NULL) die_nomem();
memset(sb, 0, sizeof(struct sb_));
- sb->listen.ev_fd = -1;
- sb->user = user;
- sb->closed = NO;
- sb->warned = NO;
- sb->ctl = NO;
+ sb->user = user;
+ sb->warned = NO;
+ sb->listen.ev_fd = -1;
sb->sb_session_id = 0;
/* create a new sb entry on sql */
@@ -179,12 +181,7 @@
struct sb_ *
sb_disconnect(struct sb_ *sb) {
struct sb_user_ *sb_user;
- struct user_ *user = sb->user;
- /* log stop */
- if (sb->closed == NO && sb->ctl == NO)
- db.sql_log_stop(sb, &user->email, &user->dn);
-
/* remove sb session from sql */
db.sql_remove_sb(sb->id);
@@ -494,9 +491,9 @@
int
xfr_sb_proxy(struct user_ *user, command *cmd) {
+ struct sb_user_ *sb_user;
struct sb_ *sb;
string **address;
- struct sb_user_ *sb_user;
if (cmd->args_len < 3)
return(RFAIL);
@@ -515,17 +512,9 @@
return(RFAIL);
/* save sb_session id */
- if (msn_sb_id(sb,cmd) == RFAIL)
- return(RFAIL);
+ if (msn_sb_id(sb, cmd) == RFAIL)
+ return(RFAIL);
- if (user->commands & SAVE_MSG) {
- sb->ctl = YES;
- } else {
- if (db.sql_log_start(sb->id, &user->email, &user->dn) == RFAIL) {
- return(RFAIL);
- }
- }
-
return(ROK);
}
@@ -533,19 +522,14 @@
rng_sb_proxy(struct user_ *user, command *cmd) {
struct contact_ *contact;
struct sb_ *sb;
- string dn;
- string *dn_;
string *email;
string **address;
- struct sb_user_ *sb_user;
if (cmd->args_len < 6)
return(RFAIL);
address = &cmd->args[1];
- if ((email = get_arg(cmd, 4)) == NULL ||
- (dn_ = get_arg(cmd, 5)) == NULL ||
- *address == NULL) {
+ if ((email = get_arg(cmd, 4)) == NULL || *address == NULL) {
return(RFAIL);
}
@@ -560,79 +544,37 @@
if (sb == NULL)
return(RFAIL);
- sb_user = sb_user_alloc(sb, email);
+ /* add user to this sb session */
+ (void) sb_user_alloc(sb, email);
/* save start email */
if (msn_decode(email, &sb->start) == -1)
return(RFAIL);
- str_zero(&dn);
- if (msn_decode(dn_, &dn) == -1)
+ if (msn_sb_id(sb, cmd) == RFAIL)
return(RFAIL);
- if (msn_sb_id(sb,cmd) == RFAIL)
- return(RFAIL);
-
- if (user->commands & SAVE_MSG) {
- sb->ctl = YES;
- } else {
- msn_sb_session(sb, email);
- }
-
- if (sb->ctl == NO) {
- if (db.sql_log_start(sb->id, email, &dn) == RFAIL) {
- str_free(&dn);
- return(RFAIL);
- }
- }
-
- str_free(&dn);
-
- /*if (sql_log_join(sb->id, &user->email, &user->dn) == RFAIL)
- return(RFAIL);*/
-
return(ROK);
}
int
msn_sb_joi(struct sb_ *sb, command *cmd) {
- struct sb_user_ *sb_user;
- string *dn_ = cmd->args[1];
- string *email = cmd->args[0];
- string dn;
+ string passport;
+ string *email;
- if (cmd->args_len < 2)
+ if (cmd->args_len < 1 || (email = get_arg(cmd, 0)) == NULL)
return(RFAIL);
- /*
- * in messenger 2009 was added a new feature that allows the user to
- * use the same live ID to connect from various places generating some JOI
- * different args
- * for now, there is no problem ignore these new args
- */
- if ((strchr((char *)cmd->args[0]->s,';'))) {
- return(ROK);
- }
+ str_zero(&passport);
+ msn_tok_epdata(email, &passport);
- /*
- * save user email - this may be a multiuser chat, so this information
- * is needed when we receive a BYE command from user
- */
- sb_user = sb_user_alloc(sb, email);
+ /* safety */
+ if (passport.len == 0) return(RFAIL);
- if (sb->start.len > 0 && email->len > 0 && strcmp((char *) sb->start.s, (char *) email->s) != 0 && sb->ctl == NO) {
- /* decode display name */
- str_zero(&dn);
- if (msn_decode(dn_, &dn) == -1){
- return (RFAIL);
- }
- if (db.sql_log_join(sb->id, email, &dn) == RFAIL) {
- str_free(&dn);
- return (RFAIL);
- }
- str_free(&dn);
- }
+ /* add contact email to this sb session */
+ (void) sb_user_alloc(sb, &passport);
+ str_free(&passport);
return(ROK);
}
@@ -642,108 +584,62 @@
}
int
-sb_iro(struct sb_ *sb, command *cmd) {
- struct sb_user_ *sb_user;
+msn_sb_iro(struct sb_ *sb, command *cmd) {
string *email;
- string *dn_;
- string dn;
+ string passport;
- str_zero(&dn);
-
- if (cmd->args_len < 5) {
+ if (cmd->args_len < 5 || (email = get_arg(cmd, 3)) == NULL) {
log->debug("debug: ARGS_LEN != IRO_LEN\n");
print_command(cmd);
- return(RFAIL);
+ return(RFAIL);
}
- /* to access any pointer inside a command, check args_len first */
- dn_ = cmd->args[4];
- email = cmd->args[3];
+ str_zero(&passport);
+ msn_tok_epdata(email, &passport);
- if((strchr((char *)cmd->args[3]->s,';'))) {
- return(ROK);
- }
+ /* safety */
+ if (passport.len == 0) return(RFAIL);
- if (sb->start.len > 0 && email->len > 0 && strcmp((char *) sb->start.s, (char *) email->s) != 0) {
+ /* add contact email to this sb session */
+ (void) sb_user_alloc(sb, &passport);
- /*
- * save user email - this may be a multiuser chat, so this information
- * is needed when we receive a BYE command from user
- */
- sb_user = sb_user_alloc(sb, email);
-
- if (sb->ctl == NO) {
- msn_sb_session(sb, email);
- if (msn_decode(dn_, &dn) == -1) {
- log->debug("debug: fail to decode SB_IRO\n");
- str_free(&dn);
- return (RFAIL);
- }
-
- /* principal has not started the connection - log join */
- if (db.sql_log_join(sb->id, email, &dn) == RFAIL) {
- str_free(&dn);
- return (RFAIL);
- }
- }
-
- str_free(&dn);
- }
-
return(ROK);
}
int
msn_sb_post_bye(struct sb_ *sb, command *cmd) {
struct sb_user_ *sb_user;
- struct user_ *user = sb->user;
- string contact;
- unsigned char *tmp;
- unsigned int len = 0;
- unsigned int num_users = 0;
+ struct sb_user_ *sb_next;
+ string passport;
+ string *email;
- if (cmd->args_len < 1) {
- return(RFAIL);
+ if (cmd->args_len < 1 || (email = get_arg(cmd, 0)) != NULL) {
+ return(RFAIL);
}
- str_zero(&contact);
- if ((tmp = (unsigned char *)strchr((char *)cmd->args[0]->s, ';'))) {
- len = tmp - cmd->args[0]->s;
- if (str_copy(&contact, cmd->args[0]->s, len) == 0) {
- die_nomem();
- }
- } else if (str_copy(&contact, cmd->args[0]->s, cmd->args[0]->len) == 0) {
- die_nomem();
- }
+ str_zero(&passport);
+ msn_tok_epdata(email, &passport);
+ /* safety */
+ if (passport.len == 0) return(RFAIL);
+
+ sb_next = NULL;
sb_user = SLIST_FIRST(&sb->sb_users);
- while(sb_user){
- num_users++;
- if (strcmp((char *) sb_user->email.s, (char *) contact.s) == 0) {
+ for ( ; sb_user != NULL; sb_user = sb_next) {
- /* log stop */
- if (sb->ctl == NO) {
- if (strcmp((char *) user->email.s, (char *) sb_user->email.s) == 0) {
- db.sql_log_stop(sb, &user->email, &user->dn);
- } else {
- db.sql_log_stop2(sb, &user->email, &sb_user->email);
- }
- }
- sb_user = sb_user_free(sb, sb_user);
- num_users--;
- sb_user = SLIST_FIRST(&sb->sb_users);
- } else {
- sb_user = SLIST_NEXT(sb_user, sb_user__);
- }
+ sb_next = SLIST_NEXT(sb_user, sb_user__);
+
+ if (strcmp((char *)sb_user->email.s, (char *)passport.s) != 0)
+ continue;
+
+ sb_user = sb_user_free(sb, sb_user);
}
- str_free(&contact);
+ str_free(&passport);
/* last user on this sb connection ? */
- if (SLIST_EMPTY(&sb->sb_users) || num_users == 1) {
- sb->closed = YES;
+ if (SLIST_EMPTY(&sb->sb_users))
return(DISCONNECT);
- }
return(ROK);
}
@@ -768,3 +664,46 @@
return(ROK);
}
+void
+sb_stat(struct sb_ *sb) {
+ struct sb_user_ *sb_user;
+
+#define YESNO(a) ((a == YES) ? "YES" : "NO")
+
+ log->debug(" -- sb information --\n");
+ log->debug("sb id.................: [%d]\n", sb->id);
+ log->debug("sb_session_id.........: [%l]\n", sb->sb_session_id);
+ log->debug("sb warned.............: [%S]\n", YESNO(sb->warned));
+ if (sb->start.len > 0)
+ log->debug("sb start..............: [%s][%d]\n", &sb->start,
+ sb->start.len);
+ if (sb->xfr != NULL && sb->xfr->len > 0)
+ log->debug("sb xfr................: [%s][%d]\n", sb->xfr, sb->xfr->len);
+
+ /* print the users connected to this sb session */
+ SLIST_FOREACH(sb_user, &sb->sb_users, sb_user__) {
+ log->debug("sb user...............: [%s][%d]\n", &sb_user->email,
+ sb_user->email.len);
+ }
+
+ if (sb->client != NULL) {
+ log->debug(" -- sb client information --\n");
+ client_stat(sb->client);
+ }
+
+ if (sb->server != NULL) {
+ log->debug(" -- sb server information --\n");
+ server_stat(sb->server);
+ }
+
+ msn_ev_stat(&sb->listen, "sb event listen");
+
+#undef YESNO
+}
+
+void
+sbs_stat(struct user_ *user) {
+ struct sb_ *sb;
+
+ LIST_FOREACH(sb, &user->sbs, sb__) sb_stat(sb);
+}
Modified: branches/dbmod/sb.h
===================================================================
--- branches/dbmod/sb.h 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/sb.h 2009-08-24 19:28:43 UTC (rev 131)
@@ -37,10 +37,12 @@
int rng_sb_proxy(struct user_ *user, command *cmd);
int msn_sb_joi(struct sb_ *sb, command *cmd);
int msn_sb_post_out(struct sb_ *sb, command *cmd);
-int sb_iro(struct sb_ *sb, command *cmd);
+int msn_sb_iro(struct sb_ *sb, command *cmd);
int msn_sb_post_bye(struct sb_ *sb, command *cmd);
int msn_sb_cal(struct sb_ *sb, command *cmd);
struct sb_user_ *sb_user_free(struct sb_ *sb, struct sb_user_ *sb_user);
void msn_sb_session(struct sb_ *sb, string *email);
+void sb_stat(struct sb_ *sb);
+void sbs_stat(struct user_ *user);
#endif
Modified: branches/dbmod/user.c
===================================================================
--- branches/dbmod/user.c 2009-08-23 23:21:29 UTC (rev 130)
+++ branches/dbmod/user.c 2009-08-24 19:28:43 UTC (rev 131)
@@ -297,8 +297,8 @@
/* print the ns information */
ns_stat(&user->ns);
- /* XXX - print sb information */
- //sb_stat(&user->sbs);
+ /* print the sb information */
+ sbs_stat(user);
/* print user contacts */
// contacts_stat(user);
@@ -314,6 +314,5 @@
user_max, config.max_clients);
log->debug("user id counter.......: [%d]\n", user_id);
- RB_FOREACH(user, users_, &users)
- user_stat(user);
+ RB_FOREACH(user, users_, &users) user_stat(user);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lo...@us...> - 2009-08-23 23:21:41
|
Revision: 130
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=130&view=rev
Author: loos-br
Date: 2009-08-23 23:21:29 +0000 (Sun, 23 Aug 2009)
Log Message:
-----------
- ns stats
- correcoes de stilo - style(9)
Modified Paths:
--------------
branches/dbmod/Makefile
branches/dbmod/check-cmd.c
branches/dbmod/client.c
branches/dbmod/command.c
branches/dbmod/command.h
branches/dbmod/contacts.c
branches/dbmod/contacts.h
branches/dbmod/ctl.c
branches/dbmod/db.c
branches/dbmod/msn-proxy.c
branches/dbmod/msn-proxy.h
branches/dbmod/p2p.c
branches/dbmod/server.c
branches/dbmod/user.c
branches/dbmod/user.h
branches/dbmod/xml.c
Added Paths:
-----------
branches/dbmod/event.c
branches/dbmod/event.h
Modified: branches/dbmod/Makefile
===================================================================
--- branches/dbmod/Makefile 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/Makefile 2009-08-23 23:21:29 UTC (rev 130)
@@ -9,14 +9,14 @@
LDFLAGS=-L/usr/local/lib -levent
OBJS=base64.o 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
+ event.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=array_cmd.h base64.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 obj-types.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
+ contacts.h contacts-data.h ctl.h db.h event.h fmt.h io.h msg.h \
+ msn-proxy.h msnp8.h msnp12.h msnp18.h ns.h ns-data.h net-io.h \
+ obj-types.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
all: msn-proxy
Modified: branches/dbmod/check-cmd.c
===================================================================
--- branches/dbmod/check-cmd.c 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/check-cmd.c 2009-08-23 23:21:29 UTC (rev 130)
@@ -17,7 +17,6 @@
static const char rcsid[] = "$Id$";
#include <errno.h>
-#include <stdio.h>
#include <string.h>
#include "sb.h"
Modified: branches/dbmod/client.c
===================================================================
--- branches/dbmod/client.c 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/client.c 2009-08-23 23:21:29 UTC (rev 130)
@@ -24,6 +24,7 @@
#include <string.h>
#include <unistd.h>
+#include "event.h"
#include "client.h"
#include "return.h"
#include "msn-proxy.h"
@@ -69,10 +70,11 @@
int
client_cleanup_commands(struct client_ *client) {
- command *cmd = client->commands.cmd;
+ command *cmd;
command *next;
/* clean commands */
+ cmd = client->commands.cmd;
while (cmd) {
next = cmd->next;
free_command(cmd);
@@ -80,8 +82,8 @@
}
/* reset pointers */
- client->commands.cmd = (command *)0;
- client->commands.cmd_last = (command *)0;
+ client->commands.cmd = NULL;
+ client->commands.cmd_last = NULL;
/* clean rx buffer */
str_free(&client->commands.buf);
@@ -129,10 +131,10 @@
void
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;
- }
+ if (client->commands.cmd == NULL)
+ client->commands.cmd_last = NULL;
}
void
@@ -142,17 +144,10 @@
if (client->xfr != NULL && client->xfr->len > 0)
log->debug("client xfr............: [%s]\n", client->xfr);
- /* print commands stats */
- commands_stats(&client->commands);
+ /* print the command information */
+ commands_stat(&client->commands);
- log->debug("client events.............: \n");
-
-#if 0
- 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; /* - */
-#endif
+ msn_ev_stat(&client->read, "client event read");
+ msn_ev_stat(&client->write, "client event write");
+ msn_ev_stat(&client->listen, "client event listen");
}
Modified: branches/dbmod/command.c
===================================================================
--- branches/dbmod/command.c 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/command.c 2009-08-23 23:21:29 UTC (rev 130)
@@ -508,6 +508,7 @@
void
commands_add_command(commands *cmds, command *cmd) {
+
/* tailq add */
if (cmds->cmd_last)
cmds->cmd_last->next = cmd;
@@ -553,19 +554,29 @@
}
void
-command_stats(command *cmd, char *debug) {
+command_stat(command *cmd, char *debug) {
+ string **arg;
+ int i;
if (debug != NULL)
- log->debug(" -- %S --\n", debug);
+ log->debug(" -- %S --\n", debug);
log->debug("command addr..........: [0x%x]\n", cmd);
log->debug("command ignore........: [%d]\n", cmd->ignore);
- log->debug("command fase..........: [%d]\n", cmd->fase);
+ log->debug("command fase..........: [%d]\n", cmd->fase); /* XXX */
log->debug("command obuf..........: [%s]\n", &cmd->obuf); /* XXX */
log->debug("command trid..........: [%d]\n", cmd->trid);
log->debug("command cmd...........: [%s][%d]\n", &cmd->cmd, cmd->cmd.len);
log->debug("command args len......: [%d]\n", cmd->args_len);
-// log->debug("command cmd...........: [%s]\n", &cmd->cmd); /* XXX - args */
+
+ i = 1;
+ arg = cmd->args;
+ while (arg && *arg) {
+ log->debug("command arg...........: [%d][%s][%d] (idx/data/size)\n",
+ i++, *arg, (*arg)->len);
+ ++arg;
+ }
+
if (cmd->payload.len > 0) {
log->debug("command payload.......: [%s][%d]\n", &cmd->payload,
cmd->payload.len);
@@ -574,9 +585,11 @@
}
void
-commands_stats(commands *cmds) {
+commands_stat(commands *cmds) {
+ command *cmd;
+ command *next;
- log->debug("-- commands information --\n");
+ log->debug(" -- commands information --\n");
log->debug("commands state........: ");
commands_print_state(cmds->state);
@@ -592,9 +605,12 @@
log->debug("commands payload size.: [%d]\n", cmds->payload_size);
if (cmds->tmp)
- command_stats(cmds->tmp, "temporary command");
- if (cmds->cmd)
- command_stats(cmds->cmd, "first commmand");
+ command_stat(cmds->tmp, "temporary command");
- log->debug("commands on queue\n");
+ cmd = cmds->cmd;
+ while (cmd) {
+ next = cmd->next;
+ command_stat(cmd, "command");
+ cmd = next;
+ }
}
Modified: branches/dbmod/command.h
===================================================================
--- branches/dbmod/command.h 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/command.h 2009-08-23 23:21:29 UTC (rev 130)
@@ -71,6 +71,6 @@
int send_command(int tofd, command *cmd, string *email, const char *to);
int read_command(commands *cmds, int fd, void (*sched_write)(), void *ev_write);
void commands_print_state(unsigned int state);
-void commands_stats(commands *cmds);
+void commands_stat(commands *cmds);
#endif
Modified: branches/dbmod/contacts.c
===================================================================
--- branches/dbmod/contacts.c 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/contacts.c 2009-08-23 23:21:29 UTC (rev 130)
@@ -105,7 +105,7 @@
}
void
-contacts_stats(struct user_ *user) {
+contacts_stat(struct user_ *user) {
struct contact_ *contact;
log->debug("-- contacts information --\n");
Modified: branches/dbmod/contacts.h
===================================================================
--- branches/dbmod/contacts.h 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/contacts.h 2009-08-23 23:21:29 UTC (rev 130)
@@ -35,7 +35,7 @@
void contact_zero(struct contact_ *contact);
void contact_free(struct contact_ *contact);
void contact_print(struct contact_ *contact);
-void contacts_stats(struct user_ *user);
+void contacts_stat(struct user_ *user);
void contacts_free(struct user_ *user);
struct contact_ *contact_add(struct user_ *user, string *c);
struct contact_ *contact_find(struct user_ *user, string *c);
Modified: branches/dbmod/ctl.c
===================================================================
--- branches/dbmod/ctl.c 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/ctl.c 2009-08-23 23:21:29 UTC (rev 130)
@@ -24,7 +24,6 @@
#include <string.h>
#include <unistd.h>
-#include "io.h"
#include "ctl.h"
#include "xml.h"
#include "net-io.h"
Modified: branches/dbmod/db.c
===================================================================
--- branches/dbmod/db.c 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/db.c 2009-08-23 23:21:29 UTC (rev 130)
@@ -21,7 +21,6 @@
#include <errno.h>
#include <dlfcn.h>
#include <fcntl.h>
-#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <unistd.h>
Added: branches/dbmod/event.c
===================================================================
--- branches/dbmod/event.c (rev 0)
+++ branches/dbmod/event.c 2009-08-23 23:21:29 UTC (rev 130)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 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 <string.h>
+
+#include "event.h"
+#include "msn-proxy.h"
+
+void
+msn_ev_stat(struct event *ev, char *display) {
+ struct timeval tv;
+ time_t now;
+
+ log->debug(" -- %S --\n", display);
+
+ memset(&tv, 0, sizeof(tv));
+ evtimer_pending(ev, &tv);
+ log->debug("event fd..............: [%d]\n", EVENT_FD(ev));
+ if (tv.tv_sec > 0) {
+ now = time(NULL);
+ log->debug("event timeout secs....: [%d]\n", (tv.tv_sec - now));
+ }
+}
Property changes on: branches/dbmod/event.c
___________________________________________________________________
Added: svn:keywords
+ Id
Added: branches/dbmod/event.h
===================================================================
--- branches/dbmod/event.h (rev 0)
+++ branches/dbmod/event.h 2009-08-23 23:21:29 UTC (rev 130)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 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$
+ */
+
+#ifndef EVENT_H
+#define EVENT_H
+
+#include <event.h>
+
+void msn_ev_stat(struct event *ev, char *display);
+
+#endif
Property changes on: branches/dbmod/event.h
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/msn-proxy.c
===================================================================
--- branches/dbmod/msn-proxy.c 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/msn-proxy.c 2009-08-23 23:21:29 UTC (rev 130)
@@ -185,7 +185,7 @@
signal_add(&ev_sigterm, NULL);
signal_set(&ev_sigint, SIGINT, sigdie, &ev_sigint);
signal_add(&ev_sigint, NULL);
- signal_set(&ev_sighup, SIGHUP, msnproxy_stats, &ev_sighup);
+ signal_set(&ev_sighup, SIGHUP, msnproxy_stat, &ev_sighup);
signal_add(&ev_sighup, NULL);
/* set SIGALRM to reload ACL defaults */
@@ -207,7 +207,7 @@
}
void
-msnproxy_stats(int sig, short event, void *ev_) {
+msnproxy_stat(int sig, short event, void *ev_) {
(void) ev_;
(void) sig;
@@ -215,7 +215,7 @@
log->debug("\n-- msn-proxy statistics --\n");
print_defaults(&config.defaults);
- users_stats();
+ users_stat();
}
int
Modified: branches/dbmod/msn-proxy.h
===================================================================
--- branches/dbmod/msn-proxy.h 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/msn-proxy.h 2009-08-23 23:21:29 UTC (rev 130)
@@ -115,7 +115,7 @@
void cleanup(void);
void sigdie(int sig, short event, void *ev_);
void sig_read_defaults(int sig, short event, void *ev_);
-void msnproxy_stats(int sig, short event, void *ev_);
+void msnproxy_stat(int sig, short event, void *ev_);
extern struct config_ config;
Modified: branches/dbmod/p2p.c
===================================================================
--- branches/dbmod/p2p.c 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/p2p.c 2009-08-23 23:21:29 UTC (rev 130)
@@ -16,7 +16,6 @@
static const char rcsid[] = "$Id$";
-#include <stdio.h> /* XXX - printf */
#include <stdlib.h>
#include <string.h>
@@ -71,7 +70,7 @@
RB_FOREACH(p, p2p_tree_, &p2p_head_) {
acksize = p->totalsize + p->ackuid;
-printf("acksize [%lld] [%lld]\n", p2p->acksize, acksize); fflush(stdout);
+io_printf(1, "acksize [%lld] [%lld]\n", p2p->acksize, acksize);
io_printf(1, "acksize [%d] [%d]\n", p2p->acksize, acksize);
io_printf(1, "msgsize [%d] [%d]\n", p2p->msgsize, p->msgsize);
io_printf(1, "sessionid [%d] [%d]\n", p2p->sessionid, p->sessionid);
Modified: branches/dbmod/server.c
===================================================================
--- branches/dbmod/server.c 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/server.c 2009-08-23 23:21:29 UTC (rev 130)
@@ -22,7 +22,9 @@
#include <unistd.h>
#include <strings.h>
+#include "event.h"
#include "net-io.h"
+#include "net-io.h"
#include "server.h"
#include "return.h"
#include "msn-proxy.h"
@@ -252,12 +254,20 @@
void
server_stat(struct server_ *server) {
-#if 0
- int fd;
- string host;
- string port;
- commands commands;
- struct event read;
- struct event write;
-#endif
+
+ log->debug("server fd.............: [%d]\n", server->fd);
+ if (server->host.len > 0) {
+ log->debug("server host...........: [%s][%d]\n", &server->host,
+ server->host.len);
+ }
+ if (server->port.len > 0) {
+ log->debug("server port...........: [%s][%d]\n", &server->port,
+ server->port.len);
+ }
+
+ /* print the command information */
+ commands_stat(&server->commands);
+
+ msn_ev_stat(&server->read, "server event read");
+ msn_ev_stat(&server->write, "server event write");
}
Modified: branches/dbmod/user.c
===================================================================
--- branches/dbmod/user.c 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/user.c 2009-08-23 23:21:29 UTC (rev 130)
@@ -294,18 +294,19 @@
log->debug("user email............: [%s]\n", &user->email);
log->debug("user host.............: [%s]\n", &user->addr);
- /* print ns information */
+ /* print the ns information */
ns_stat(&user->ns);
-// struct ns_ ns; /* ns connection */
-// struct sbs sbs; /* sb connections list */
+ /* XXX - print sb information */
+ //sb_stat(&user->sbs);
+
/* print user contacts */
-// contacts_stats(user);
+// contacts_stat(user);
log->debug("\n");
}
void
-users_stats(void) {
+users_stat(void) {
struct user_ *user;
log->debug("-- msn-proxy users statistics --\n");
Modified: branches/dbmod/user.h
===================================================================
--- branches/dbmod/user.h 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/user.h 2009-08-23 23:21:29 UTC (rev 130)
@@ -81,7 +81,7 @@
int msnp12_update_dn(struct user_ *user, command *cmd);
int msn_update_status(struct user_ *user, command *cmd);
void free_users_tree(void);
-void users_stats(void);
+void users_stat(void);
extern struct users_ users;
extern unsigned int user_max;
Modified: branches/dbmod/xml.c
===================================================================
--- branches/dbmod/xml.c 2009-08-22 00:33:19 UTC (rev 129)
+++ branches/dbmod/xml.c 2009-08-23 23:21:29 UTC (rev 130)
@@ -23,7 +23,6 @@
#include "return.h"
#include "ctl.h"
#include "xml.h"
-#include "io.h"
#define SIZE(s) (sizeof(s)/sizeof(*s))
@@ -37,7 +36,7 @@
void
printt(int t) {
- while(t-- > 0) io_printf(1, "\t");
+ while(t-- > 0) log->debug("\t");
}
void
@@ -47,14 +46,14 @@
SLIST_FOREACH(tag, head, xml_tag__) {
printt(depth);
- io_printf(1, "name: [%s]\n", &tag->name);
+ log->debug("name: [%s]\n", &tag->name);
if (tag->data.len > 0) {
printt(depth);
- io_printf(1, "data: [%s]\n", &tag->data);
+ log->debug("data: [%s]\n", &tag->data);
}
SLIST_FOREACH(tag_opt, &tag->xml_tag_opt_head, xml_tag_opt__) {
printt(depth);
- io_printf(1, "opt name: [%s = %s]\n", &tag_opt->name,
+ log->debug("opt name: [%s = %s]\n", &tag_opt->name,
&tag_opt->value);
}
xml_print(&tag->xml_tag_head, depth + 1);
@@ -301,8 +300,8 @@
close = 1;
} else if (end == 1 && (tag->name.len == 0 || vrfy.len == 0 ||
strcmp((char *)tag->name.s, (char *)vrfy.s) != 0)) {
- io_printf(1, "tag: [%s] vrfy: [%s]\n", &tag->name, &vrfy);
- io_printf(1, "fail to close tag\n");
+ log->debug("tag: [%s] vrfy: [%s]\n", &tag->name, &vrfy);
+ log->debug("fail to close tag\n");
return(RFAIL);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lo...@us...> - 2009-08-22 00:33:28
|
Revision: 129
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=129&view=rev
Author: loos-br
Date: 2009-08-22 00:33:19 +0000 (Sat, 22 Aug 2009)
Log Message:
-----------
- update das funcoes io
- update das funcoes fmt
- update das funcoes xml
- update das definicoes de inteiro
- algumas funcoes de stats (ainda em desenvolvimento)
- alterada a forma de verificar os comandos, o numero de argumentos nao e mais utilizado
- salvando as alteracoes para nao acumular tantas modificacoes em um unico commit
Modified Paths:
--------------
branches/dbmod/Makefile
branches/dbmod/check-cmd.c
branches/dbmod/check-cmd.h
branches/dbmod/client.c
branches/dbmod/client.h
branches/dbmod/command.c
branches/dbmod/command.h
branches/dbmod/config.c
branches/dbmod/config.h
branches/dbmod/contacts-data.h
branches/dbmod/contacts.c
branches/dbmod/contacts.h
branches/dbmod/ctl.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/pgsql.c
branches/dbmod/db_modules/pgsql/pgsql.h
branches/dbmod/db_modules/pgsql/sql.c
branches/dbmod/db_modules/pgsql/sql.h
branches/dbmod/fmt.c
branches/dbmod/fmt.h
branches/dbmod/io.c
branches/dbmod/io.h
branches/dbmod/msg.c
branches/dbmod/msg.h
branches/dbmod/msn-proxy.c
branches/dbmod/msn-proxy.h
branches/dbmod/msnp12.h
branches/dbmod/msnp18.h
branches/dbmod/msnp8.h
branches/dbmod/ns.c
branches/dbmod/ns.h
branches/dbmod/protocol.c
branches/dbmod/protocol.h
branches/dbmod/sb-data.h
branches/dbmod/sb.c
branches/dbmod/sb.h
branches/dbmod/server.c
branches/dbmod/server.h
branches/dbmod/string.c
branches/dbmod/string.h
branches/dbmod/user.c
branches/dbmod/user.h
branches/dbmod/xml.c
branches/dbmod/xml.h
Added Paths:
-----------
branches/dbmod/base64.c
branches/dbmod/base64.h
branches/dbmod/obj-types.h
Modified: branches/dbmod/Makefile
===================================================================
--- branches/dbmod/Makefile 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/Makefile 2009-08-22 00:33:19 UTC (rev 129)
@@ -8,14 +8,15 @@
LDFLAGS=-L/usr/local/lib -levent
-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=base64.o 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=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 base64.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 obj-types.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
all: msn-proxy
Added: branches/dbmod/base64.c
===================================================================
--- branches/dbmod/base64.c (rev 0)
+++ branches/dbmod/base64.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2004, 2005, 2006, 2007, 2008
+ * 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.
+ */
+
+#include <strings.h>
+
+#include "base64.h"
+
+static const char rcsid[] = "$Id$";
+
+int
+find_ch(const char *str, char c) {
+ char *p;
+
+ p = (char *)str;
+ while (*p++) {
+ if (*p == c)
+ return(p - str);
+ }
+
+ return(0);
+}
+
+int
+b64decode(string *in, string *out) {
+ unsigned char a[4];
+ unsigned char b;
+ int i;
+ int j;
+
+ if (!in || in->len == 0)
+ return(-1);
+
+ for (i = 0; i < in->len; i += 4) {
+ for (j = 0; j < 4; j++) {
+ if ((i + j) < in->len && in->s[i + j] != B64PAD) {
+ a[j] = find_ch(base64, in->s[i + j]);
+ if (a[j] > 63)
+ return(-1);
+ } else
+ a[j] = 0;
+ }
+
+ b = (a[0] << 2) | (a[1] >> 4);
+ if (str_cat(out, &b, 1) == 0) exit(51);
+
+ if (in->s[i + 2] == B64PAD)
+ return(0);
+
+ b = (a[1] << 4) | (a[2] >> 2);
+ if (str_cat(out, &b, 1) == 0) exit(51);
+
+ if (in->s[i + 3] == B64PAD)
+ return(0);
+
+ b = (a[2] << 6) | a[3];
+ if (str_cat(out, &b, 1) == 0) exit(51);
+ }
+
+ return(0);
+}
+
+int
+b64encode(string *in, string *out) {
+ unsigned char a;
+ unsigned char b;
+ unsigned char c;
+ unsigned char o;
+ int i;
+
+ if (!in || in->len == 0)
+ return(-1);
+
+ for (i = 0; i < in->len; i += 3) {
+ a = in->s[i];
+ b = i + 1 < in->len ? in->s[i + 1] : 0;
+ c = i + 2 < in->len ? in->s[i + 2] : 0;
+
+ o = base64[a >> 2];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+
+ o = base64[((a & 3) << 4) | (b >> 4)];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+
+ if (i + 1 >= in->len)
+ o = B64PAD;
+ else
+ o = base64[((b & 15) << 2) | (c >> 6)];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+
+ if (i + 2 >= in->len)
+ o = B64PAD;
+ else
+ o = base64[c & 63];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+ }
+
+ return(0);
+}
+
+int
+b64mdecode(string *in, string *out) {
+ unsigned char a[4];
+ unsigned char o;
+ int i;
+ int j;
+
+ if (in->len == 0) {
+ if (str_copy(out, (unsigned char *)"", 1) == 0) exit(51);
+ return(-1);
+ }
+
+ for (i = 0; i < in->len; i += 4) {
+ for (j = 0; j < 4; j++) {
+ if ((i + j) < in->len) {
+ a[j] = find_ch(base64modified, in->s[i + j]);
+ if (a[j] > 63)
+ return(-1);
+ } else
+ a[j] = 0;
+ }
+
+ o = (a[0] << 2) | (a[1] >> 4);
+ if (o != 0) if (str_cat(out, &o, 1) == 0) exit(51);
+
+ o = (a[1] << 4) | (a[2] >> 2);
+ if (o != 0) if (str_cat(out, &o, 1) == 0) exit(51);
+
+ o = (a[2] << 6) | a[3];
+ if (o != 0) if (str_cat(out, &o, 1) == 0) exit(51);
+ }
+
+ return(0);
+}
+
+/*
+ * modified base64 for utf-7 use
+ */
+int
+b64mencode(string *in, string *out) {
+ unsigned char a;
+ unsigned char b;
+ unsigned char c;
+ unsigned char o;
+ int i;
+
+ if (in->len == 0) {
+ if (str_copy(out, (unsigned char *)"", 1) == 0) exit(51);
+ return(-1);
+ }
+
+ for (i = 0; i < in->len; i += 3) {
+
+ a = in->s[i];
+ b = i + 1 < in->len ? in->s[i + 1] : 0;
+ c = i + 2 < in->len ? in->s[i + 2] : 0;
+
+ o = base64modified[a >> 2];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+
+ o = base64modified[((a & 3) << 4) | (b >> 4)];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+
+ if (i + 1 >= in->len)
+ return(0);
+
+ o = base64modified[((b & 15) << 2) | (c >> 6)];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+
+ if (i + 2 >= in->len)
+ return(0);
+
+ o = base64modified[c & 63];
+ if (str_cat(out, &o, 1) == 0) exit(51);
+ }
+
+ return(0);
+}
Property changes on: branches/dbmod/base64.c
___________________________________________________________________
Added: svn:keywords
+ Id
Added: branches/dbmod/base64.h
===================================================================
--- branches/dbmod/base64.h (rev 0)
+++ branches/dbmod/base64.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -0,0 +1,39 @@
+/*
+ * 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$
+ */
+
+#ifndef BASE64_H
+#define BASE64_H
+
+#include "string.h"
+
+static const char base64[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char base64modified[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
+#define B64PAD '='
+
+int find_ch(const char *str, char c);
+int b64decode(string *in, string *out);
+int b64encode(string *in, string *out);
+int b64mdecode(string *in, string *out);
+int b64mencode(string *in, string *out);
+
+#endif
+
Property changes on: branches/dbmod/base64.h
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/check-cmd.c
===================================================================
--- branches/dbmod/check-cmd.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/check-cmd.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -20,7 +20,6 @@
#include <stdio.h>
#include <string.h>
-#include "io.h"
#include "sb.h"
#include "client.h"
#include "server.h"
@@ -29,40 +28,17 @@
#include "protocol.h"
#include "msn-proxy.h"
+/* default */
CMD PRE_CMDS[] = {
- { "VER", 0, msn_get_ver },
- { NULL, 0, NULL }
+ { "VER", msn_get_ver },
+ { NULL, NULL }
};
-int check_ok(struct user_ *user, command *cmd, int args) { return(ROK); }
-
-int _check_args(command *cmd, int args) {
-
- if ( strcmp((char *)cmd->cmd.s, "BYE") == 0 && cmd->args_len >=1 ) {
- return(ROK);
- }
-
- if (args != cmd->args_len) {
- io_printf(1, "numero de args: [%d] != [%d]\n", args, cmd->args_len);
- print_command(cmd);
- return(RFAIL);
- }
- return(ROK);
-}
-
-int check_args(struct user_ *user, command *cmd, int args) {
- return(_check_args(cmd, args));
-}
-
-int check_sb_args(struct sb_ *sb, command *cmd, int args) {
- return(_check_args(cmd, args));
-}
-
int
check_cmd(struct user_ *user, command *cmd, int type) {
unsigned long erro = 0;
- CMDS_ *cmds_ = (CMDS_ *)0;
- CMD *cmds = (CMD *)0;
+ CMDS_ *cmds_ = NULL;
+ CMD *cmds = NULL;
char *label = "";
char *ep;
@@ -105,7 +81,9 @@
//io_printf(1, "%S: [%S] == [%s]\n", label, cmds->cmd, &cmd->cmd);
if (strncmp(cmds->cmd, (char *)cmd->cmd.s, cmd->cmd.len) == 0) {
//print_command(cmd);
- return(cmds->func(user, cmd, cmds->args));
+ if (cmds->func != NULL)
+ return(cmds->func(user, cmd));
+ return(ROK);
}
}
@@ -158,7 +136,9 @@
//io_printf(1, "%S: [%S] == [%s]\n", label, cmds->cmd, &cmd->cmd);
if (strncmp(cmds->cmd, (char *)cmd->cmd.s, cmd->cmd.len) == 0) {
//print_command(cmd);
- return(cmds->func(sb, cmd, cmds->args));
+ if (cmds->func != NULL)
+ return(cmds->func(sb, cmd));
+ return(ROK);
}
}
Modified: branches/dbmod/check-cmd.h
===================================================================
--- branches/dbmod/check-cmd.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/check-cmd.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -22,33 +22,28 @@
#define CHECK_CMD_H
typedef struct {
- char *cmd;
- int args;
- int (*func)(struct user_ *user, command *cmd, int args);
+ char *cmd;
+ int (*func)(struct user_ *user, command *cmd);
} CMD;
typedef struct {
- __uint32_t type;
+ unsigned int type;
char *label;
CMD *cmd;
} CMDS_;
typedef struct {
- char *cmd;
- int args;
- int (*func)(struct sb_ *sb, command *cmd, int args);
+ char *cmd;
+ int (*func)(struct sb_ *sb, command *cmd);
} SBCMD;
typedef struct {
- __uint32_t type;
+ unsigned int type;
char *label;
SBCMD *sbcmd;
} SBCMDS_;
-int check_ok(struct user_ *user, command *cmd, int args);
int check_cmd(struct user_ *user, command *cmd, int type);
int check_sb_cmd(struct sb_ *sb, command *cmd, int type);
-int check_args(struct user_ *user, command *cmd, int args);
-int check_sb_args(struct sb_ *sb, command *cmd, int args);
#endif
Modified: branches/dbmod/client.c
===================================================================
--- branches/dbmod/client.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/client.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -135,3 +135,24 @@
}
}
+void
+client_stat(struct client_ *client) {
+
+ log->debug("client fd.............: [%d]\n", client->fd);
+ if (client->xfr != NULL && client->xfr->len > 0)
+ log->debug("client xfr............: [%s]\n", client->xfr);
+
+ /* print commands stats */
+ commands_stats(&client->commands);
+
+ log->debug("client events.............: \n");
+
+#if 0
+ 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; /* - */
+#endif
+}
Modified: branches/dbmod/client.h
===================================================================
--- branches/dbmod/client.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/client.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -50,5 +50,6 @@
void real_client_disconnect(struct client_ *client);
void shift_client_commands(struct client_ *client, command *cmd);
int client_cleanup_commands(struct client_ *client);
+void client_stat(struct client_ *client);
#endif
Modified: branches/dbmod/command.c
===================================================================
--- branches/dbmod/command.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/command.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -19,8 +19,9 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
-#include "io.h"
+#include "io.h" /* XXX */
#include "return.h"
#include "command.h"
#include "protocol.h"
@@ -56,9 +57,9 @@
cmd->trid = 0;
}
-__uint32_t
+unsigned int
has_payload(command *cmd) {
- long rtrn;
+ unsigned int rtrn;
if (cmd->cmd.len == 0)
return(0);
@@ -96,7 +97,8 @@
if (cmd->args_len < 1)
return(0);
- rtrn = (__uint32_t)atoi((char *)cmd->args[cmd->args_len - 1]->s);
+/* XXX - strtoul*/
+ rtrn = (unsigned int)atoi((char *)cmd->args[cmd->args_len - 1]->s);
return(rtrn);
}
@@ -148,10 +150,10 @@
if (buf->len == 0) {
/* read buffer */
- buf->len = io_read(fd, (char *)buf->s, buf->a);
+ buf->len = read(fd, (char *)buf->s, buf->a);
if (buf->len == -1) {
- if (errno == EAGAIN)
+ if (errno == EAGAIN || errno == EINTR)
return(-2);
str_reset(buf);
@@ -162,9 +164,6 @@
buf->p = buf->s;
}
- if (buf->len == 0)
- return(0);
-
return(buf->len);
}
@@ -477,7 +476,7 @@
case 1:
- /* write command */
+ /* write command - XXX - async */
switch (io_write(tofd, (char *)cmd->obuf.s, cmd->obuf.len)) {
case -2:
@@ -529,3 +528,73 @@
memset(cmds->buf.s, 0, cmds->buf.a);
cmds->state = COMMAND;
}
+
+void
+commands_print_state(unsigned int state) {
+ int space = 0;
+
+ log->debug("<");
+ if (state & ARG) {
+ log->debug("ARG"); space++;
+ }
+ if (state & EOC) {
+ if (space) log->debug(" ");
+ log->debug("EOC"); space++;
+ }
+ if (state & COMMAND) {
+ if (space) log->debug(" ");
+ log->debug("COMMAND"); space++;
+ }
+ if (state & PAYLOAD) {
+ if (space) log->debug(" ");
+ log->debug("PAYLOAD"); space++;
+ }
+ log->debug(">\n");
+}
+
+void
+command_stats(command *cmd, char *debug) {
+
+ if (debug != NULL)
+ log->debug(" -- %S --\n", debug);
+
+ log->debug("command addr..........: [0x%x]\n", cmd);
+ log->debug("command ignore........: [%d]\n", cmd->ignore);
+ log->debug("command fase..........: [%d]\n", cmd->fase);
+ log->debug("command obuf..........: [%s]\n", &cmd->obuf); /* XXX */
+ log->debug("command trid..........: [%d]\n", cmd->trid);
+ log->debug("command cmd...........: [%s][%d]\n", &cmd->cmd, cmd->cmd.len);
+ log->debug("command args len......: [%d]\n", cmd->args_len);
+// log->debug("command cmd...........: [%s]\n", &cmd->cmd); /* XXX - args */
+ if (cmd->payload.len > 0) {
+ log->debug("command payload.......: [%s][%d]\n", &cmd->payload,
+ cmd->payload.len);
+ }
+ log->debug("command next..........: [0x%x]\n", cmd->next);
+}
+
+void
+commands_stats(commands *cmds) {
+
+ log->debug("-- commands information --\n");
+
+ log->debug("commands state........: ");
+ commands_print_state(cmds->state);
+
+ if (cmds->buf.len > 0) {
+ log->debug("commands input buf.s..: [%s]\n", &cmds->buf);
+ log->debug("commands input buf.p..: [%p]\n", &cmds->buf);
+ }
+
+ if (cmds->arg != NULL && cmds->arg->len > 0)
+ log->debug("commands next arg.....: [%s]\n", cmds->arg);
+
+ log->debug("commands payload size.: [%d]\n", cmds->payload_size);
+
+ if (cmds->tmp)
+ command_stats(cmds->tmp, "temporary command");
+ if (cmds->cmd)
+ command_stats(cmds->cmd, "first commmand");
+
+ log->debug("commands on queue\n");
+}
Modified: branches/dbmod/command.h
===================================================================
--- branches/dbmod/command.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/command.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -31,7 +31,6 @@
#define ARG 0x0004
#define EOC 0x0008
#define SENDMASK 0xff00
-#define SENDDELAY 0x0100
typedef struct _command {
int ignore;
@@ -48,9 +47,8 @@
typedef struct _commands {
string buf; /* io command buffer */
string *arg; /* tmp pointer to last arg */
- __uint32_t wait; /* trid to wait */
- __uint32_t state; /* command state */
- __uint32_t payload_size; /* payload size */
+ size_t payload_size; /* payload size */
+ unsigned int state; /* command state */
struct _command *tmp; /* tmp pointer to ongoing command */
struct _command *cmd; /* linked list to ready commands */
struct _command *cmd_last; /* pointer to last entry on list */
@@ -59,7 +57,7 @@
#define HAS_CMD(p) (p->commands.cmd != NULL)
command *command_alloc(void);
-__uint32_t has_payload(command *cmd);
+unsigned int has_payload(command *cmd);
string **args_alloc(void *ptr, size_t len);
string *command_add_arg(command *cmd);
void has_trid(command *cmd);
@@ -72,5 +70,7 @@
void commands_add_command(commands *cmds, command *cmd);
int send_command(int tofd, command *cmd, string *email, const char *to);
int read_command(commands *cmds, int fd, void (*sched_write)(), void *ev_write);
+void commands_print_state(unsigned int state);
+void commands_stats(commands *cmds);
#endif
Modified: branches/dbmod/config.c
===================================================================
--- branches/dbmod/config.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/config.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -285,9 +285,9 @@
log->debug("ACLs\n");
log->debug("connect : %S\n",
(defaults->connect == YES) ? "ALLOW" : "DENY");
- log->debug("log messages : %S\n",
+ log->debug("save contacts : %S\n",
+ (defaults->save_contacts == YES) ? "YES" : "NO");
+ log->debug("save messages : %S\n",
(defaults->save_msg == YES) ? "YES" : "NO");
- log->debug("save_contacts : %S\n",
- (defaults->save_contacts == YES) ? "YES" : "NO");
log->debug("\n");
}
Modified: branches/dbmod/config.h
===================================================================
--- branches/dbmod/config.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/config.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -26,10 +26,6 @@
#include "tree.h"
#include "string.h"
-#if 0
-
-#include "mysql.h"
-#endif
#include "syslog.h"
#ifndef READONLY
Modified: branches/dbmod/contacts-data.h
===================================================================
--- branches/dbmod/contacts-data.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/contacts-data.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -35,8 +35,8 @@
string dn; /* display name */
string c; /* email */
string o; /* object */
- unsigned long deny; /* commands and data */
- unsigned long lists; /* lists information */
+ unsigned int deny; /* commands and data */
+ unsigned int lists; /* lists information */
struct contact_ *save; /* update data */
unsigned long long flags; /* client flags */
unsigned long long flags2; /* client flags */
Modified: branches/dbmod/contacts.c
===================================================================
--- branches/dbmod/contacts.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/contacts.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -20,7 +20,6 @@
#include <string.h>
#include "db.h"
-#include "io.h"
#include "fmt.h"
#include "xml.h"
#include "return.h"
@@ -73,35 +72,48 @@
case NEW: update = "new"; break;
default: update = "";
}
- io_printf(1, "debug contact: update: [%S]\n", update);
- io_printf(1, "debug contact: c: [%s]\n", &contact->c);
- io_printf(1, "debug contact: dn: [%s]\n", &contact->dn);
- io_printf(1, "debug contact: chat: [%S]\n",
+ log->debug("debug contact: update: [%S]\n", update);
+ log->debug("debug contact: c: [%s]\n", &contact->c);
+ log->debug("debug contact: dn: [%s]\n", &contact->dn);
+ log->debug("debug contact: chat: [%S]\n",
(contact->chat == YES) ? "YES" : "NO");
- io_printf(1, "debug contact: deny: [");
+ log->debug("debug contact: deny: [");
if (contact->deny & CONTACT_DENY) {
- io_printf(1, "CONTACT_DENY");
+ log->debug("CONTACT_DENY");
++i;
}
if (contact->deny & CONTACT_BLOCKED) {
- if (i) io_printf(1, ", ");
- io_printf(1, "CONTACT_BLOCKED");
+ if (i) log->debug(", ");
+ log->debug("CONTACT_BLOCKED");
}
- io_printf(1, "]\n");
+ log->debug("]\n");
- io_printf(1, "debug contact: info: [%s]\n", &contact->info);
- io_printf(1, "debug contact: flags: [%l]\n", contact->flags);
- io_printf(1, "debug contact: flags2: [%l]\n", contact->flags2);
- io_printf(1, "debug contact: lists: [%d]\n", contact->lists);
- io_printf(1, "debug contact: status: [%s]\n", &contact->status);
- io_printf(1, "debug contact: object: [%s]\n", &contact->o);
+ log->debug("debug contact: info: [%s]\n", &contact->info);
+ log->debug("debug contact: flags: ");
+ msn_print_cap(contact->flags, contact->flags2);
+
+ log->debug("debug contact: lists: ");
+ msn_print_lists(contact->lists);
+
+ log->debug("debug contact: status: [%s]\n", &contact->status);
+ log->debug("debug contact: object: [%s]\n", &contact->o);
+
if (contact->save)
contact_print(contact->save);
}
void
+contacts_stats(struct user_ *user) {
+ struct contact_ *contact;
+
+ log->debug("-- contacts information --\n");
+ RB_FOREACH(contact, contacts, &user->contacts)
+ contact_print(contact);
+}
+
+void
contacts_free(struct user_ *user) {
struct contact_ *contact;
struct contact_ *next;
@@ -206,7 +218,7 @@
}
int
-msnp13_save_contact(struct user_ *user, command *cmd, int args) {
+msnp13_save_contact(struct user_ *user, command *cmd) {
struct xml_tag_opt_ *tag_opt;
struct xml_tags xml_tag_head;
struct xml_tag_ *tag_domain;
@@ -297,7 +309,7 @@
}
int
-msnp12_save_contact(struct user_ *user, command *cmd, int args) {
+msnp12_save_contact(struct user_ *user, command *cmd) {
struct contact_ *save;
struct contact_ c;
unsigned long tmp;
@@ -341,7 +353,7 @@
/* "F=" == contact display name */
buf.len -= 2;
buf.s += 2;
- if (msn_decode(&buf, &c.dn) == RFAIL) {
+ if (msn_decode(&buf, &c.dn) == -1) {
contact_free(&c);
return(RFAIL);
}
@@ -349,7 +361,7 @@
/* "C=" == contact uid */
buf.len -= 2;
buf.s += 2;
- if (msn_decode(&buf, &c.uid) == RFAIL) {
+ if (msn_decode(&buf, &c.uid) == -1) {
contact_free(&c);
return(RFAIL);
}
@@ -378,7 +390,7 @@
/* save contact group */
if (i < cmd->args_len) {
- if (msn_decode(cmd->args[i], &c.group) == RFAIL) {
+ if (msn_decode(cmd->args[i], &c.group) == -1) {
contact_free(&c);
return(RFAIL);
}
@@ -406,7 +418,7 @@
}
int
-msnp8_save_contact(struct user_ *user, command *cmd, int args) {
+msnp8_save_contact(struct user_ *user, command *cmd) {
struct contact_ *save;
struct contact_ c;
char *ep;
@@ -425,14 +437,14 @@
c.c.s = cmd->args[0]->s;
/* save contact display name */
- if (msn_decode(cmd->args[1], &c.dn) == RFAIL) {
+ if (msn_decode(cmd->args[1], &c.dn) == -1) {
contact_free(&c);
return(RFAIL);
}
/* save contact group */
if (cmd->args_len == 4) {
- if (msn_decode(cmd->args[3], &c.group) == RFAIL) {
+ if (msn_decode(cmd->args[3], &c.group) == -1) {
contact_free(&c);
return(RFAIL);
}
@@ -442,8 +454,8 @@
errno = 0;
c.lists = strtoul((char *)cmd->args[2]->s, &ep, 10);
if (errno != 0 || (ep && *ep != 0)) {
- io_printf(1, "ep (%S}\n", ep);
- io_printf(1, "ep (%d}\n", *ep);
+ log->debug("lists ep (%S}\n", ep);
+ log->debug("lists ep (%d}\n", *ep);
contact_free(&c);
return(RFAIL);
}
@@ -475,7 +487,7 @@
str_zero(&tmp);
/* decode group name */
- if (msn_decode(group, &tmp) == RFAIL)
+ if (msn_decode(group, &tmp) == -1)
return(RFAIL);
/* save group on database */
@@ -489,19 +501,19 @@
}
int
-msnp12_save_contactgroup(struct user_ *user, command *cmd, int args) {
+msnp12_save_contactgroup(struct user_ *user, command *cmd) {
if (user->commands & SAVE_CONTACTS) return(ROK);
return(msn_save_contactgroup(&user->email, cmd->args[0], cmd->args[1]));
}
int
-msnp8_save_contactgroup(struct user_ *user, command *cmd, int args) {
+msnp8_save_contactgroup(struct user_ *user, command *cmd) {
if (user->commands & SAVE_CONTACTS) return(ROK);
return(msn_save_contactgroup(&user->email, cmd->args[1], cmd->args[0]));
}
int
-msnp13_contact_initial_state(struct user_ *user, command *cmd, int args) {
+msnp13_contact_initial_state(struct user_ *user, command *cmd) {
struct contact_ *contact;
struct contact_ *save;
struct contact_ find;
@@ -532,7 +544,7 @@
if (contact == NULL)
contact = save;
- if (d->len > 0 && msn_decode(d, &save->dn) == RFAIL) {
+ if (d->len > 0 && msn_decode(d, &save->dn) == -1) {
contact_free(save);
free(save);
contact->save = NULL;
@@ -579,7 +591,7 @@
}
int
-msn_contact_initial_state(struct user_ *user, command *cmd, int args) {
+msn_contact_initial_state(struct user_ *user, command *cmd) {
struct contact_ *contact;
struct contact_ *save;
struct contact_ find;
@@ -610,7 +622,7 @@
if (contact == NULL)
contact = save;
- if (d->len > 0 && msn_decode(d, &save->dn) == RFAIL) {
+ if (d->len > 0 && msn_decode(d, &save->dn) == -1) {
contact_free(save);
free(save);
contact->save = NULL;
@@ -648,7 +660,7 @@
}
int
-msn_contact_logoff(struct user_ *user, command *cmd, int args) {
+msn_contact_logoff(struct user_ *user, command *cmd) {
struct contact_ *contact;
struct contact_ *save;
struct contact_ find;
@@ -701,7 +713,7 @@
}
int
-msnp18_contact_change(struct user_ *user, command *cmd, int args) {
+msnp18_contact_change(struct user_ *user, command *cmd) {
struct contact_ *contact;
struct contact_ *save;
struct contact_ find;
@@ -744,7 +756,7 @@
if (save == NULL)
return(ROK);
- if (d->len > 0 && msn_decode(d, &save->dn) == RFAIL) {
+ if (d->len > 0 && msn_decode(d, &save->dn) == -1) {
contact_free(save);
free(save);
contact->save = NULL;
@@ -782,7 +794,7 @@
}
int
-msnp13_contact_change(struct user_ *user, command *cmd, int args) {
+msnp13_contact_change(struct user_ *user, command *cmd) {
struct contact_ *contact;
struct contact_ *save;
struct contact_ find;
@@ -813,7 +825,7 @@
if (save == NULL)
return(ROK);
- if (d->len > 0 && msn_decode(d, &save->dn) == RFAIL) {
+ if (d->len > 0 && msn_decode(d, &save->dn) == -1) {
contact_free(save);
free(save);
contact->save = NULL;
@@ -860,7 +872,7 @@
}
int
-msnp8_contact_change(struct user_ *user, command *cmd, int args) {
+msnp8_contact_change(struct user_ *user, command *cmd) {
struct contact_ *contact;
struct contact_ *save;
struct contact_ find;
@@ -891,7 +903,7 @@
if (save == NULL)
return(ROK);
- if (d->len > 0 && msn_decode(d, &save->dn) == RFAIL) {
+ if (d->len > 0 && msn_decode(d, &save->dn) == -1) {
contact_free(save);
free(save);
contact->save = NULL;
@@ -929,22 +941,22 @@
}
int
-msn_contact_change(struct user_ *user, command *cmd, int args) {
+msn_contact_change(struct user_ *user, command *cmd) {
switch (user->version) {
case MSNP18:
- return msnp18_contact_change(user, cmd, args);
+ return msnp18_contact_change(user, cmd);
case MSNP15:
case MSNP13:
case MSNP12:
- return msnp13_contact_change(user, cmd, args);
+ return msnp13_contact_change(user, cmd);
default:
- return msnp8_contact_change(user, cmd, args);
+ return msnp8_contact_change(user, cmd);
}
}
int
-msnp12_client_syn_rewrite(struct user_ *user, command *cmd, int args) {
+msnp12_client_syn_rewrite(struct user_ *user, command *cmd) {
string *arg1;
string *arg2;
@@ -981,7 +993,7 @@
}
int
-msnp8_client_syn_rewrite(struct user_ *user, command *cmd, int args) {
+msnp8_client_syn_rewrite(struct user_ *user, command *cmd) {
string *arg1;
char *ep;
@@ -1024,7 +1036,7 @@
}
int
-msnp8_server_syn_rewrite(struct user_ *user, command *cmd, int args) {
+msnp8_server_syn_rewrite(struct user_ *user, command *cmd) {
string *arg1;
if (user->version != MSNP8)
Modified: branches/dbmod/contacts.h
===================================================================
--- branches/dbmod/contacts.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/contacts.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -35,23 +35,24 @@
void contact_zero(struct contact_ *contact);
void contact_free(struct contact_ *contact);
void contact_print(struct contact_ *contact);
+void contacts_stats(struct user_ *user);
void contacts_free(struct user_ *user);
struct contact_ *contact_add(struct user_ *user, string *c);
struct contact_ *contact_find(struct user_ *user, string *c);
struct contact_ *contact_update(struct user_ *user, string *c);
-int msnp13_save_contact(struct user_ *user, command *cmd, int args);
-int msnp12_save_contact(struct user_ *user, command *cmd, int args);
-int msnp8_save_contact(struct user_ *user, command *cmd, int args);
+int msnp13_save_contact(struct user_ *user, command *cmd);
+int msnp12_save_contact(struct user_ *user, command *cmd);
+int msnp8_save_contact(struct user_ *user, command *cmd);
int msn_save_contactgroup(string *email, string *group, string *gid);
-int msnp12_save_contactgroup(struct user_ *user, command *cmd, int args);
-int msnp8_save_contactgroup(struct user_ *user, command *cmd, int args);
-int msnp13_contact_initial_state(struct user_ *user, command *cmd, int args);
-int msn_contact_initial_state(struct user_ *user, command *cmd, int args);
-int msn_contact_logoff(struct user_ *user, command *cmd, int args);
-int msn_contact_change(struct user_ *user, command *cmd, int args);
-int msnp12_client_syn_rewrite(struct user_ *user, command *cmd, int args);
-int msnp8_client_syn_rewrite(struct user_ *user, command *cmd, int args);
-int msnp8_server_syn_rewrite(struct user_ *user, command *cmd, int args);
+int msnp12_save_contactgroup(struct user_ *user, command *cmd);
+int msnp8_save_contactgroup(struct user_ *user, command *cmd);
+int msnp13_contact_initial_state(struct user_ *user, command *cmd);
+int msn_contact_initial_state(struct user_ *user, command *cmd);
+int msn_contact_logoff(struct user_ *user, command *cmd);
+int msn_contact_change(struct user_ *user, command *cmd);
+int msnp12_client_syn_rewrite(struct user_ *user, command *cmd);
+int msnp8_client_syn_rewrite(struct user_ *user, command *cmd);
+int msnp8_server_syn_rewrite(struct user_ *user, command *cmd);
int loaduser(struct ctl_ *ctl, struct xml_tags *xml_tag_head);
int ctl_disconnect_user(struct ctl_ *ctl, struct xml_tags *xml_tag_head);
Modified: branches/dbmod/ctl.c
===================================================================
--- branches/dbmod/ctl.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/ctl.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -114,9 +114,9 @@
return;
}
- len = io_read(ctl->fd, (char *)buf, sizeof(buf));
+ len = read(ctl->fd, (char *)buf, sizeof(buf));
if (len == -1) {
- if (errno == EINTR) {
+ if (errno == EAGAIN || errno == EINTR) {
/* AGAIN */
ctl_sched_read(ctl);
return;
Modified: branches/dbmod/db.h
===================================================================
--- branches/dbmod/db.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/db.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -46,7 +46,7 @@
int (*sql_contact_save_all)();
int (*sql_connection_denied)();
int (*sql_save_contactgroup)();
- __uint32_t (*sql_insert_sb)();
+ unsigned int (*sql_insert_sb)();
int (*modLoad)();
void (*modUnload)();
Modified: branches/dbmod/db_modules/mysql/mysql.c
===================================================================
--- branches/dbmod/db_modules/mysql/mysql.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/db_modules/mysql/mysql.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -58,21 +58,21 @@
return(mysql_fetch_row(res));
}
-u_int64_t
+unsigned long long
db_count(MYSQL_RES *res) {
if(res == NULL)
return 0;
return(mysql_num_rows(res));
}
-u_int64_t
+unsigned long long
db_affected_rows(MYSQL *mysql) {
if(mysql == NULL)
return 0;
return(mysql_affected_rows(mysql));
}
-u_int64_t
+unsigned long long
db_last_id(MYSQL *mysql) {
if(mysql == NULL)
return 0;
Modified: branches/dbmod/db_modules/mysql/mysql.h
===================================================================
--- branches/dbmod/db_modules/mysql/mysql.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/db_modules/mysql/mysql.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -76,9 +76,9 @@
};
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);
+unsigned long long db_count(MYSQL_RES *res);
+unsigned long long db_affected_rows(MYSQL *mysql);
+unsigned long long 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);
Modified: branches/dbmod/db_modules/mysql/sql.c
===================================================================
--- branches/dbmod/db_modules/mysql/sql.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/db_modules/mysql/sql.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -250,7 +250,7 @@
return(ROK);
}
-__uint32_t
+unsigned int
sql_insert_sb(struct user_ *user) {
string sql;
char fmt [] = "INSERT INTO sb (email, since) VALUES ('%q', NOW())";
@@ -267,7 +267,7 @@
}
str_free(&sql);
- return((__uint32_t)db_last_id(&mysql.mysql));
+ return((unsigned int)db_last_id(&mysql.mysql));
}
int
@@ -1145,7 +1145,7 @@
if (row[0]) {
tmp.s = (unsigned char *)row[0];
tmp.len = strlen(row[0]);
- if (msn_encode(&tmp, warndn, 0) == RFAIL) goto error;
+ if (msn_encode(&tmp, warndn) == -1) goto error;
}
/* warnmsg */
@@ -1153,7 +1153,7 @@
if (row[1]) {
tmp.s = (unsigned char *)row[1];
tmp.len = strlen(row[1]);
- if (msn_encode(&tmp, warnmsg, PAYLOAD) == RFAIL) goto error;
+ if (msn_encode_payload(&tmp, warnmsg) == -1) goto error;
}
/* warnemail */
@@ -1161,7 +1161,7 @@
if (row[2]) {
tmp.s = (unsigned char *)row[2];
tmp.len = strlen(row[2]);
- if (msn_encode(&tmp, warnemail, 0) == RFAIL) goto error;
+ if (msn_encode(&tmp, warnemail) == -1) goto error;
}
/* msgfont */
@@ -1169,7 +1169,7 @@
if (row[3]) {
tmp.s = (unsigned char *)row[3];
tmp.len = strlen(row[3]);
- if (msn_encode(&tmp, msgfont, 0) == RFAIL) goto error;
+ if (msn_encode(&tmp, msgfont) == -1) goto error;
}
/* msgcolor */
@@ -1177,7 +1177,7 @@
if (row[4]) {
tmp.s = (unsigned char *)row[4];
tmp.len = strlen(row[4]);
- if (msn_encode(&tmp, msgcolor, 0) == RFAIL) goto error;
+ if (msn_encode(&tmp, msgcolor) == -1) goto error;
}
res = db_free(res);
Modified: branches/dbmod/db_modules/mysql/sql.h
===================================================================
--- branches/dbmod/db_modules/mysql/sql.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/db_modules/mysql/sql.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -30,7 +30,7 @@
int sql_users_update(struct user_ *user);
int sql_set_status(struct user_ *user);
int sql_update_user_dn(struct user_ *user);
-__uint32_t sql_insert_sb(struct user_ *user);
+unsigned int sql_insert_sb(struct user_ *user);
int sql_remove_sb(int id);
int sql_log_join(int sb_id, string *email, string *dn);
int sql_log_stop2(struct sb_ *sb, string *email, string *contact_email);
Modified: branches/dbmod/db_modules/pgsql/pgsql.c
===================================================================
--- branches/dbmod/db_modules/pgsql/pgsql.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/db_modules/pgsql/pgsql.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -57,7 +57,7 @@
return(PQgetvalue(res, row, column));
}
-__uint32_t
+unsigned int
db_count(PGresult *res) {
return(PQntuples(res));
}
Modified: branches/dbmod/db_modules/pgsql/pgsql.h
===================================================================
--- branches/dbmod/db_modules/pgsql/pgsql.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/db_modules/pgsql/pgsql.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -70,7 +70,7 @@
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);
+unsigned int db_count(PGresult *res);
extern struct pgsql_ pgsql;
Modified: branches/dbmod/db_modules/pgsql/sql.c
===================================================================
--- branches/dbmod/db_modules/pgsql/sql.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/db_modules/pgsql/sql.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -250,13 +250,13 @@
return(ROK);
}
-__uint32_t
+unsigned int
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()";
+ unsigned int 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);
@@ -271,7 +271,7 @@
rtrn = 0;
if (db_count(res) > 0)
- rtrn = (__uint32_t)atoi(db_row(res, 0, 0));
+ rtrn = (unsigned int)atoi(db_row(res, 0, 0));
res = db_free(res);
return(rtrn);
@@ -1133,31 +1133,31 @@
str_zero(&tmp);
tmp.s = (unsigned char *)db_row(res, 0, 0);
tmp.len = strlen((char *)tmp.s);
- if (msn_encode(&tmp, warndn, 0) == RFAIL) goto error;
+ if (msn_encode(&tmp, warndn) == -1) goto error;
/* warnmsg */
str_zero(&tmp);
tmp.s = (unsigned char *)db_row(res, 0, 1);
tmp.len = strlen((char *)tmp.s);
- if (msn_encode(&tmp, warnmsg, PAYLOAD) == RFAIL) goto error;
+ if (msn_encode_payload(&tmp, warnmsg) == -1) goto error;
/* warnemail */
str_zero(&tmp);
tmp.s = (unsigned char *)db_row(res, 0, 2);
tmp.len = strlen((char *)tmp.s);
- if (msn_encode(&tmp, warnemail, 0) == RFAIL) goto error;
+ if (msn_encode(&tmp, warnemail) == -1) goto error;
/* msgfont */
str_zero(&tmp);
tmp.s = (unsigned char *)db_row(res, 0, 3);
tmp.len = strlen((char *)tmp.s);
- if (msn_encode(&tmp, msgfont, 0) == RFAIL) goto error;
+ if (msn_encode(&tmp, msgfont) == -1) goto error;
/* msgcolor */
str_zero(&tmp);
tmp.s = (unsigned char *)db_row(res, 0, 4);
tmp.len = strlen((char *)tmp.s);
- if (msn_encode(&tmp, msgcolor, 0) == RFAIL) goto error;
+ if (msn_encode(&tmp, msgcolor) == -1) goto error;
res = db_free(res);
return(ROK);
Modified: branches/dbmod/db_modules/pgsql/sql.h
===================================================================
--- branches/dbmod/db_modules/pgsql/sql.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/db_modules/pgsql/sql.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -30,7 +30,7 @@
int sql_users_update(struct user_ *user);
int sql_set_status(struct user_ *user);
int sql_update_user_dn(struct user_ *user);
-__uint32_t sql_insert_sb(struct user_ *user);
+unsigned int sql_insert_sb(struct user_ *user);
int sql_remove_sb(int id);
int sql_log_join(int sb_id, string *email, string *dn);
int sql_log_stop2(struct sb_ *sb, string *email, string *contact_email);
Modified: branches/dbmod/fmt.c
===================================================================
--- branches/dbmod/fmt.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/fmt.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -17,6 +17,7 @@
static const char rcsid[] = "$Id$";
#include <stdarg.h>
+#include <string.h>
#include "string.h"
#include "fmt.h"
@@ -30,13 +31,13 @@
}
unsigned int
-fmt_str(register unsigned char *s, register const char *t) {
+fmt_str(register unsigned char *s, register const char *t, register size_t size) {
register unsigned int len;
char ch;
len = 0;
- if (s) { while ((ch = t[len])) s[len++] = ch; }
- else while (t[len]) len++;
+ if (s) { while ((ch = t[len]) && size-- > 0) s[len++] = ch; }
+ else while (t[len] && size-- > 0) len++;
return len;
}
@@ -72,10 +73,46 @@
}
unsigned int
-fmt_ulong(register unsigned char *s, register unsigned long u) {
+fmt_bin(register unsigned char *s, register const char *t, register size_t size) {
+ register unsigned int len;
+
+ len = 0;
+ if (s) {
+ while (size-- > 0) { s[len] = t[len]; ++len; }
+ }
+ else while (size-- > 0) len++;
+ return len;
+}
+
+unsigned int
+fmt_uhex(register unsigned char *s, register unsigned int x) {
+ register unsigned char byte;
register unsigned int len;
- register unsigned long q;
+ register unsigned int q;
+ q = x;
+ len = 2;
+ while (q > 255) { len += 2; q >>= 8; }
+ if (s) {
+ s += len;
+ do {
+ byte = (x % 256) & 0x0f;
+ *--s = (byte > 9) ? ('a' + byte - 10) : ('0' + byte);
+
+ byte = (x % 256) >> 4;
+ *--s = (byte > 9) ? ('a' + byte - 10) : ('0' + byte);
+
+ x >>= 8;
+ } while(x);
+ }
+ return len;
+}
+
+unsigned int
+fmt_uint(register unsigned char *s, register unsigned int u) {
+ register unsigned int len;
+ register unsigned int q;
+
len = 1;
q = u;
while (q > 9) { ++len; q /= 10; }
@@ -87,9 +124,9 @@
}
unsigned int
-fmt_u64(register unsigned char *s, register __uint64_t u) {
- register unsigned int len;
- register __uint64_t q;
+fmt_u64(register unsigned char *s, register unsigned long long u) {
+ register unsigned int len;
+ register unsigned long long q;
len = 1;
q = u;
@@ -101,17 +138,30 @@
return len;
}
+
unsigned int
+fmt_printf(unsigned char *s, const char *fmt, ...) {
+ va_list ap;
+ unsigned int len = 0;
+
+ va_start(ap, fmt);
+ len = fmt_vprintf(s, fmt, ap);
+ va_end(ap);
+
+ return(len);
+}
+
+unsigned int
fmt_vprintf(unsigned char *s, const char *fmt, va_list ap) {
- unsigned int len;
- unsigned int i;
- string *p;
- char *S;
- char *q;
- int f;
- unsigned char c;
- unsigned long d;
- __uint64_t l;
+ unsigned int len;
+ unsigned int i;
+ string *p;
+ char *S;
+ char *q;
+ int f;
+ unsigned int d;
+ unsigned char c;
+ unsigned long long l;
f = 0;
len = 0;
@@ -119,45 +169,75 @@
while (*fmt) {
switch (*fmt) {
+ /*
+ * get the "%%" case
+ */
case '%':
if (f == 0)
f++;
else if (f == 1) {
- i = fmt_str(s, "%"); len += i; if (s) s += i;
+ i = fmt_str(s, "%", 1); len += i; if (s) s += i;
f = 0;
}
break;
+ /*
+ * "%S" null-terminated strings - standart C strings
+ */
case 'S':
if (f == 1) {
S = va_arg(ap, char *);
if (S) {
- i = fmt_str(s, S); len += i; if (s) s += i;
+ i = fmt_str(s, S, strlen(S)); len += i; if (s) s += i;
} else {
- i = fmt_str(s, "(null)"); len += i; if (s) s += i;
+ i = fmt_str(s, "(null)", 6); len += i; if (s) s += i;
}
f = 0;
break;
}
+ /*
+ * "%s" private string type - do NOT use for null-terminated
+ * strings
+ */
case 's':
if (f == 1) {
p = va_arg(ap, string *);
if (p && p->len > 0 && p->s) {
- i = fmt_str(s, (char *)p->s); len += i; if (s) s += i;
+ i = fmt_str(s, (char *)p->s, p->len); len += i; if (s) s += i;
} else {
- i = fmt_str(s, "(null)"); len += i; if (s) s += i;
+ i = fmt_str(s, "(null)", 6); len += i; if (s) s += i;
}
f = 0;
break;
}
+ /*
+ * "%b" binary type
+ */
+ case 'b':
+
+ if (f == 1) {
+ p = va_arg(ap, string *);
+ if (p && p->len > 0 && p->s) {
+ i = fmt_bin(s, (char *)p->s, p->len); len += i; if (s) s += i;
+ } else {
+ i = fmt_bin(s, "(null)", 6); len += i; if (s) s += i;
+ }
+
+ f = 0;
+ break;
+ }
+
+ /*
+ * "%c" - (char)
+ */
case 'c':
if (f == 1) {
@@ -168,6 +248,9 @@
break;
}
+ /*
+ * "%q" - escape_sql_value(char *)
+ */
case 'q':
if (f == 1) {
@@ -182,28 +265,51 @@
break;
}
+ /*
+ * "%d" - (unsigned int) - should be a 32bit unsigned integer
+ */
case 'd':
if (f == 1) {
- d = va_arg(ap, unsigned long);
- i = fmt_ulong(s, d); len += i; if (s) s += i;
+ d = va_arg(ap, unsigned int);
+ i = fmt_uint(s, d); len += i; if (s) s += i;
f = 0;
break;
}
+ /*
+ * "%l" - (unsigned long long) - for 64bit integers
+ */
case 'l':
if (f == 1) {
- l = va_arg(ap, __uint64_t);
+ l = va_arg(ap, unsigned long long);
i = fmt_u64(s, l); len += i; if (s) s += i;
f = 0;
break;
}
+ /*
+ * "%x" - (unsigned int) - as hex
+ */
+ case 'x':
+
+ if (f == 1) {
+
+ d = va_arg(ap, unsigned int);
+ i = fmt_uhex(s, d); len += i; if (s) s += i;
+
+ f = 0;
+ break;
+ }
+
+ /*
+ * unknown option - default to skip - do nothing
+ */
default:
f = 0;
@@ -215,16 +321,3 @@
if (s) *s = 0;
return(len);
}
-
-unsigned int
-fmt_printf(unsigned char *s, const char *fmt, ...) {
- va_list ap;
- unsigned int len = 0;
-
- va_start(ap, fmt);
- len = fmt_vprintf(s, fmt, ap);
- va_end(ap);
-
- return(len);
-}
-
Modified: branches/dbmod/fmt.h
===================================================================
--- branches/dbmod/fmt.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/fmt.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -24,10 +24,12 @@
#include <sys/types.h>
#include <stdarg.h>
-unsigned int fmt_str(register unsigned char *s, register const char *t);
+unsigned int fmt_str(register unsigned char *s, register const char *t,
+ register size_t size);
unsigned int fmt_sql(register unsigned char *s, register const char *t);
-unsigned int fmt_ulong(register unsigned char *s, register unsigned long u);
-unsigned int fmt_u64(register unsigned char *s, register __uint64_t);
+unsigned int fmt_uhex(register unsigned char *s, register unsigned int x);
+unsigned int fmt_uint(register unsigned char *s, register unsigned int u);
+unsigned int fmt_u64(register unsigned char *s, register unsigned long long);
unsigned int fmt_vprintf(char unsigned *s, const char *fmt, va_list ap);
unsigned int fmt_printf(char unsigned *s, const char *fmt, ...);
Modified: branches/dbmod/io.c
===================================================================
--- branches/dbmod/io.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/io.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2009, Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -26,32 +26,17 @@
#include "io.h"
#include "fmt.h"
#include "string.h"
-#include "msn-proxy.h"
int
-io_read(const int fd, register char *buf, register int len) {
- register int r;
-
- for (;;) {
-
- r = read(fd, buf, len);
- if (r == -1) { if (errno == EINTR) continue; }
- return r;
- }
-}
-
-int
io_write(register int fd, register const char *buf, register int len) {
register int w;
while(len) {
w = write(fd, buf, len);
if (w == -1) {
- if (errno == EAGAIN) return(-2);
- if (errno == EINTR) continue;
+ if (errno == EAGAIN || errno == EINTR) continue;
return(-1);
}
- if (w == 0) ; /* luser's fault */
buf += w;
len -= w;
}
@@ -59,55 +44,27 @@
}
int
-timeoutread(int t, int fd, char *buf, int len) {
- fd_set rfds;
- struct timeval tv;
+io_printf(int fd, const char *fmt, ...) {
+ va_list ap;
+ int len = 0;
- tv.tv_sec = t;
- tv.tv_usec = 0;
+ va_start(ap, fmt);
+ len = io_vprintf(fd, fmt, ap);
+ va_end(ap);
- FD_ZERO(&rfds);
- FD_SET(fd,&rfds);
-
- if (select(fd + 1,&rfds,(fd_set *) 0,(fd_set *) 0,&tv) == -1)
- return(-1);
- if (FD_ISSET(fd,&rfds))
- return(read(fd,buf,len));
-
- errno = ETIMEDOUT;
- return(-1);
+ return(len);
}
int
-timeoutwrite(int t, int fd, char *buf, int len) {
- fd_set wfds;
- struct timeval tv;
-
- tv.tv_sec = t;
- tv.tv_usec = 0;
-
- FD_ZERO(&wfds);
- FD_SET(fd,&wfds);
-
- if (select(fd + 1,(fd_set *) 0,&wfds,(fd_set *) 0,&tv) == -1)
- return(-1);
- if (FD_ISSET(fd,&wfds))
- return(write(fd,buf,len));
-
- errno = ETIMEDOUT;
- return(-1);
-}
-
-int
io_vprintf(int fd, const char *fmt, va_list ap) {
- string str;
- string *s;
- char *S;
- int len = 0;
- int f = 0;
- unsigned char c;
- unsigned long d;
- __uint64_t l;
+ string str;
+ string *s;
+ char *S;
+ int len = 0;
+ int f = 0;
+ unsigned int d;
+ unsigned char c;
+ unsigned long long l;
while (*fmt) {
switch (*fmt) {
@@ -168,32 +125,36 @@
break;
}
- case 'p':
+ case 'd':
if (f == 1) {
- s = va_arg(ap, string *);
- if (s && s->p) {
- if (io_write(fd, (char *)s->p, s->len) == -1)
- return(-1);
- len += s->len;
- } else {
- if (io_write(fd, "(null)", 6) == -1)
- return(-1);
- len += 6;
+ d = va_arg(ap, unsigned int);
+
+ str_zero(&str);
+ str.len = fmt_uint((unsigned char *)0, d);
+ if (str_ready(&str, str.len + 1) == 0) exit(51);
+ str.len = fmt_uint(str.s, d);
+
+ len += str.len;
+ if (io_write(fd, (char *)str.s, str.len) == -1) {
+ str_free(&str);
+ return(-1);
}
+ str_free(&str);
+
f = 0;
break;
}
- case 'd':
+ case 'l':
if (f == 1) {
- d = va_arg(ap, unsigned long);
+ l = va_arg(ap, unsigned long long);
str_zero(&str);
- str.len = fmt_ulong((unsigned char *)0, d);
- if (str_ready(&str, str.len + 1) == 0) die_nomem();
- str.len = fmt_ulong(str.s, d);
+ str.len = fmt_u64((unsigned char *)0, l);
+ if (str_ready(&str, str.len + 1) == 0) exit(51);
+ str.len = fmt_u64(str.s, l);
len += str.len;
if (io_write(fd, (char *)str.s, str.len) == -1) {
@@ -206,15 +167,15 @@
break;
}
- case 'l':
+ case 'x':
if (f == 1) {
- l = va_arg(ap, __uint64_t);
+ d = va_arg(ap, unsigned int);
str_zero(&str);
- str.len = fmt_u64((unsigned char *)0, l);
- if (str_ready(&str, str.len + 1) == 0) die_nomem();
- str.len = fmt_u64(str.s, l);
+ str.len = fmt_uhex((unsigned char *)0, d);
+ if (str_ready(&str, str.len + 1) == 0) exit(51);
+ str.len = fmt_uhex(str.s, d);
len += str.len;
if (io_write(fd, (char *)str.s, str.len) == -1) {
@@ -237,15 +198,3 @@
}
return(len);
}
-
-int
-io_printf(int fd, const char *fmt, ...) {
- va_list ap;
- int len = 0;
-
- va_start(ap, fmt);
- len = io_vprintf(fd, fmt, ap);
- va_end(ap);
-
- return(len);
-}
Modified: branches/dbmod/io.h
===================================================================
--- branches/dbmod/io.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/io.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -27,10 +27,7 @@
#define STDOUT 1
#define STDERR 2
-int io_read(register int fd, register char *buf, register int len);
int io_write(register int fd, register const char *buf, register int len);
-int timeoutread(int t, int fd, char *buf, int len);
-int timeoutwrite(int t, int fd, char *buf, int len);
int io_printf(int fd, const char *fmt, ...);
int io_vprintf(int fd, const char *fmt, va_list ap);
Modified: branches/dbmod/msg.c
===================================================================
--- branches/dbmod/msg.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/msg.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -372,7 +372,7 @@
if (msg->body.len == 0)
return(ROK);
- if (msn_decode(&msg->body, &tmp) == RFAIL)
+ if (msn_decode(&msg->body, &tmp) == -1)
return(RFAIL);
email = cmd->args[0];
@@ -449,7 +449,7 @@
return(RFAIL);
}
- if (msn_decode(dn_, &dn) == RFAIL) {
+ if (msn_decode(dn_, &dn) == -1) {
str_free(&tmp);
str_free(&to);
return(RFAIL);
@@ -481,16 +481,16 @@
}
int
-msn_sb_server_msg(struct sb_ *sb, command *cmd, int args) {
+msn_sb_server_msg(struct sb_ *sb, command *cmd) {
return(msn_msg_decode(sb, cmd, SERVER));
}
int
-msn_sb_client_msg(struct sb_ *sb, command *cmd, int args) {
+msn_sb_client_msg(struct sb_ *sb, command *cmd) {
return(msn_msg_decode(sb, cmd, CLIENT));
}
-int msn_ns_client_uum (struct user_ *user, command *cmd, int args) {
+int msn_ns_client_uum (struct user_ *user, command *cmd) {
return(msn_msg_decode_umm(user, cmd));
}
Modified: branches/dbmod/msg.h
===================================================================
--- branches/dbmod/msg.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/msg.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -48,8 +48,8 @@
int msn_msg_header_decode(msg_ *msg, string *payload);
int msn_msg_decode(struct sb_ *sb, command *cmd, int type);
int msg_decode_utf8(struct sb_ *sb, command *cmd, msg_ *msg, int type);
-int msn_sb_server_msg(struct sb_ *sb, command *cmd, int args);
-int msn_sb_client_msg(struct sb_ *sb, command *cmd, int args);
-int msn_ns_client_uum (struct user_ *user, command *cmd, int args);
+int msn_sb_server_msg(struct sb_ *sb, command *cmd);
+int msn_sb_client_msg(struct sb_ *sb, command *cmd);
+int msn_ns_client_uum (struct user_ *user, command *cmd);
#endif
Modified: branches/dbmod/msn-proxy.c
===================================================================
--- branches/dbmod/msn-proxy.c 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/msn-proxy.c 2009-08-22 00:33:19 UTC (rev 129)
@@ -185,7 +185,7 @@
signal_add(&ev_sigterm, NULL);
signal_set(&ev_sigint, SIGINT, sigdie, &ev_sigint);
signal_add(&ev_sigint, NULL);
- signal_set(&ev_sighup, SIGHUP, users_stats, &ev_sighup);
+ signal_set(&ev_sighup, SIGHUP, msnproxy_stats, &ev_sighup);
signal_add(&ev_sighup, NULL);
/* set SIGALRM to reload ACL defaults */
@@ -206,6 +206,18 @@
db_mod_init();
}
+void
+msnproxy_stats(int sig, short event, void *ev_) {
+
+ (void) ev_;
+ (void) sig;
+ (void) event;
+
+ log->debug("\n-- msn-proxy statistics --\n");
+ print_defaults(&config.defaults);
+ users_stats();
+}
+
int
main(int argc, char **argv) {
int bg;
Modified: branches/dbmod/msn-proxy.h
===================================================================
--- branches/dbmod/msn-proxy.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/msn-proxy.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -47,35 +47,31 @@
#define DISCONNECT 0x0000a000
#define SERVER 0x0000b000
#define CLIENT 0x0000c000
-#define PRE_AUTH 0x0000d000
-#define USR_TWN_I 0x0000e000
-#define USR_TWN_S 0x0000f000
-#define CONNECTED 0x00010000
-#define SERVER_CMD 0x00020000
-#define SERVER_SB_CMD 0x00030000
-#define SERVER_PRE_CMD 0x00040000
-#define SERVER_POST_CMD 0x00050000
-#define SERVER_SB_POST_CMD 0x00060000
-#define CLIENT_CMD 0x00070000
-#define CLIENT_SB_CMD 0x00080000
-#define CLIENT_PRE_CMD 0x00090000
-#define CLIENT_POST_CMD 0x000a0000
-#define CLIENT_SB_POST_CMD 0x000b0000
-#define HEADER 0x000c0000
-#define VALUE 0x000d0000
-#define BODY 0x000e0000
-#define START_VALUE 0x000f0000
-#define TYPE_P2P 0x00100000
-#define TYPE_TEXTUTF8 0x00200000
-#define TYPE_MSGSCONTROL 0x00300000
-#define TYPE_CLIENTCAPS 0x00400000
-#define TYPE_DATACAST 0x00500000
-#define TYPE_FILETRANSF 0x00600000
-#define TYPE_EMOTICON 0x00700000
-#define TYPE_KEEPALIVE 0x00800000
-#define NEW 0x00900000
-#define NONE 0x00a00000
-#define INFO 0x00b00000
+#define SERVER_CMD 0x0000d000
+#define SERVER_SB_CMD 0x0000e000
+#define SERVER_PRE_CMD 0x0000f000
+#define SERVER_POST_CMD 0x00010000
+#define SERVER_SB_POST_CMD 0x00020000
+#define CLIENT_CMD 0x00030000
+#define CLIENT_SB_CMD 0x00040000
+#define CLIENT_PRE_CMD 0x00050000
+#define CLIENT_POST_CMD 0x00060000
+#define CLIENT_SB_POST_CMD 0x00070000
+#define HEADER 0x00080000
+#define VALUE 0x00090000
+#define BODY 0x000a0000
+#define START_VALUE 0x000b0000
+#define TYPE_P2P 0x000c0000
+#define TYPE_TEXTUTF8 0x000d0000
+#define TYPE_MSGSCONTROL 0x000e0000
+#define TYPE_CLIENTCAPS 0x000f0000
+#define TYPE_DATACAST 0x00100000
+#define TYPE_FILETRANSF 0x00200000
+#define TYPE_EMOTICON 0x00300000
+#define TYPE_KEEPALIVE 0x00400000
+#define NEW 0x00500000
+#define NONE 0x00600000
+#define INFO 0x00700000
#define P2P_INVITING 0x00000800
#define P2P_COMPLETE 0x00000900
@@ -119,6 +115,7 @@
void cleanup(void);
void sigdie(int sig, short event, void *ev_);
void sig_read_defaults(int sig, short event, void *ev_);
+void msnproxy_stats(int sig, short event, void *ev_);
extern struct config_ config;
Modified: branches/dbmod/msnp12.h
===================================================================
--- branches/dbmod/msnp12.h 2009-08-13 15:12:50 UTC (rev 128)
+++ branches/dbmod/msnp12.h 2009-08-22 00:33:19 UTC (rev 129)
@@ -19,111 +19,111 @@
*/
CMD SERVER_MSNP12_PRE_CMDS[] = {
- { "CVR", 6, check_args },
- { "USR", 0, server_msnp12_pre_usr },
- { "VER", 0, msn_get_ver },
- { "XFR", 0, xfr_proxy },
- { NULL, 0, NULL }
+ { "CVR", NULL },
+ { "USR", server_msnp12_pre_usr },
+ { "VER", msn_get_ver },
+ { "XFR", xfr_proxy },
+ { NULL, NULL }
};
CMD SERVER_MSNP12_POST_CMDS[] = {
- { "XFR", 0, xfr_ns_post_proxy },
- { NULL, 0, NULL }
+ { "XFR", xfr_ns_post_proxy },
+ { NULL, NULL }
};
CMD SERVER_MSNP12_CMDS[] = {
- { "ADC", 0, check_ok }, /* XXX */
- { "ADG", 0, check_ok }, /* XXX */
- { "BLP", 1, check_args },
- { "BPR", 0, check_ok },
- { "CHG", 0, check_ok },
- { "CHL", 2, check_args },
- { "FLN", 0, msn_contact_logoff },
- { "GCF", 0, check_ok },
- { "GTC", 1, check_args },
- { "ILN", 0, msn_co...
[truncated message content] |
|
From: <lo...@us...> - 2009-08-13 15:12:59
|
Revision: 128
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=128&view=rev
Author: loos-br
Date: 2009-08-13 15:12:50 +0000 (Thu, 13 Aug 2009)
Log Message:
-----------
mais algumas alteracoes para a chegada do postgres e dos novos recursos
Modified Paths:
--------------
branches/dbmod/check-cmd.c
branches/dbmod/command.c
branches/dbmod/db_modules/pgsql/php/ajax.inc.php
branches/dbmod/db_modules/pgsql/php/al.inc.php
branches/dbmod/db_modules/pgsql/php/bl.inc.php
branches/dbmod/db_modules/pgsql/php/chat-to.php
branches/dbmod/db_modules/pgsql/php/chat.php
branches/dbmod/db_modules/pgsql/php/class.ctl.php
branches/dbmod/db_modules/pgsql/php/conf.php
branches/dbmod/db_modules/pgsql/php/default.array.cmd.inc.php
branches/dbmod/db_modules/pgsql/php/default.array.option.inc.php
branches/dbmod/db_modules/pgsql/php/default.array.status.inc.php
branches/dbmod/db_modules/pgsql/php/fl.inc.php
branches/dbmod/db_modules/pgsql/php/group.inc.php
branches/dbmod/db_modules/pgsql/php/header.inc.php
branches/dbmod/db_modules/pgsql/php/index.php
branches/dbmod/db_modules/pgsql/php/pgsql.inc.php
branches/dbmod/db_modules/pgsql/php/save_contact_op.php
branches/dbmod/db_modules/pgsql/php/save_default_op.php
branches/dbmod/db_modules/pgsql/php/save_msg.php
branches/dbmod/db_modules/pgsql/php/save_user_op.php
branches/dbmod/db_modules/pgsql/php/user.inc.php
branches/dbmod/db_modules/pgsql/php/user.php
branches/dbmod/db_modules/pgsql/php/view-to.php
branches/dbmod/db_modules/pgsql/php/view.php
branches/dbmod/msn-proxy.c
branches/dbmod/msnp18.h
branches/dbmod/user.c
branches/dbmod/user.h
Added Paths:
-----------
branches/dbmod/db_modules/mysql/php/
branches/dbmod/db_modules/pgsql/php/
Removed Paths:
-------------
branches/dbmod/php/
Property Changed:
----------------
branches/dbmod/db_modules/pgsql/php/ajax.inc.php
branches/dbmod/db_modules/pgsql/php/al.inc.php
branches/dbmod/db_modules/pgsql/php/bl.inc.php
branches/dbmod/db_modules/pgsql/php/chat-to.php
branches/dbmod/db_modules/pgsql/php/chat.php
branches/dbmod/db_modules/pgsql/php/class.ctl.php
branches/dbmod/db_modules/pgsql/php/conf.php
branches/dbmod/db_modules/pgsql/php/default.array.cmd.inc.php
branches/dbmod/db_modules/pgsql/php/default.array.option.inc.php
branches/dbmod/db_modules/pgsql/php/default.array.status.inc.php
branches/dbmod/db_modules/pgsql/php/fl.inc.php
branches/dbmod/db_modules/pgsql/php/group.inc.php
branches/dbmod/db_modules/pgsql/php/header.inc.php
branches/dbmod/db_modules/pgsql/php/index.php
branches/dbmod/db_modules/pgsql/php/pgsql.inc.php
branches/dbmod/db_modules/pgsql/php/save_contact_op.php
branches/dbmod/db_modules/pgsql/php/save_default_op.php
branches/dbmod/db_modules/pgsql/php/save_msg.php
branches/dbmod/db_modules/pgsql/php/save_user_op.php
branches/dbmod/db_modules/pgsql/php/user.inc.php
branches/dbmod/db_modules/pgsql/php/user.php
branches/dbmod/db_modules/pgsql/php/view-to.php
branches/dbmod/db_modules/pgsql/php/view.php
Modified: branches/dbmod/check-cmd.c
===================================================================
--- branches/dbmod/check-cmd.c 2009-08-06 13:24:44 UTC (rev 127)
+++ branches/dbmod/check-cmd.c 2009-08-13 15:12:50 UTC (rev 128)
@@ -90,11 +90,13 @@
erro = strtoul((char *)cmd->cmd.s, &ep, 10);
if (errno == 0 && *cmd->cmd.s && (ep && *ep == 0)) {
- /* ignore the 241, 508, 509 and 511 commands */
- if (erro != 511 && erro != 509 && erro != 508 && erro != 241 && erro != 205) {
- log->debug("===> warning error received\n");
- return(ROK);
- }
+ /*
+ * just let the error pass through
+ * let the client disconnect gracefully (if needed - some errors are
+ * just ignored or don't imply the disconnection)
+ */
+ log->debug("===> warning error received\n");
+ return(ROK);
}
/* dispatch command */
Modified: branches/dbmod/command.c
===================================================================
--- branches/dbmod/command.c 2009-08-06 13:24:44 UTC (rev 127)
+++ branches/dbmod/command.c 2009-08-13 15:12:50 UTC (rev 128)
@@ -64,7 +64,6 @@
return(0);
if (strcasecmp((char *)cmd->cmd.s, "205") != 0 &&
- 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 &&
Modified: branches/dbmod/db_modules/pgsql/php/ajax.inc.php
===================================================================
--- branches/pgsql/php/ajax.inc.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/ajax.inc.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: ajax.inc.php,v 1.2 2008-01-22 14:29:43 loos-br Exp $
+ * $Id$
*/
?>
Property changes on: branches/dbmod/db_modules/pgsql/php/ajax.inc.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/al.inc.php
===================================================================
--- branches/pgsql/php/al.inc.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/al.inc.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: al.inc.php,v 1.2.2.2 2008-05-24 15:30:26 loos-br Exp $
+ * $Id$
*/
require('default.array.cmd.inc.php');
Property changes on: branches/dbmod/db_modules/pgsql/php/al.inc.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/bl.inc.php
===================================================================
--- branches/pgsql/php/bl.inc.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/bl.inc.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: bl.inc.php,v 1.2.2.2 2008-05-24 15:30:29 loos-br Exp $
+ * $Id$
*/
require('default.array.cmd.inc.php');
Property changes on: branches/dbmod/db_modules/pgsql/php/bl.inc.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/chat-to.php
===================================================================
--- branches/pgsql/php/chat-to.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/chat-to.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: chat-to.php,v 1.3.2.1 2008-05-19 20:15:28 loos-br Exp $
+ * $Id$
*/
require('pgsql.inc.php');
Property changes on: branches/dbmod/db_modules/pgsql/php/chat-to.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/chat.php
===================================================================
--- branches/pgsql/php/chat.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/chat.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: chat.php,v 1.3.2.1 2008-05-19 20:15:29 loos-br Exp $
+ * $Id$
*/
require('pgsql.inc.php');
Property changes on: branches/dbmod/db_modules/pgsql/php/chat.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/class.ctl.php
===================================================================
--- branches/pgsql/php/class.ctl.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/class.ctl.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,22 @@
<?php
+/*
+ * 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: class.ctl.php,v 1.1 2008-04-23 01:22:32 loos-br Exp $
+ * $Id$
*/
class ctl {
Property changes on: branches/dbmod/db_modules/pgsql/php/class.ctl.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/conf.php
===================================================================
--- branches/pgsql/php/conf.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/conf.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: conf.php,v 1.2.2.2 2008-05-24 15:30:29 loos-br Exp $
+ * $Id$
*/
require('default.array.option.inc.php');
Property changes on: branches/dbmod/db_modules/pgsql/php/conf.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/default.array.cmd.inc.php
===================================================================
--- branches/pgsql/php/default.array.cmd.inc.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/default.array.cmd.inc.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: default.array.cmd.inc.php,v 1.5.2.2 2008-10-15 16:40:12 loos-br Exp $
+ * $Id$
*/
$arrayCMD = array(
Property changes on: branches/dbmod/db_modules/pgsql/php/default.array.cmd.inc.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/default.array.option.inc.php
===================================================================
--- branches/pgsql/php/default.array.option.inc.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/default.array.option.inc.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: default.array.option.inc.php,v 1.3.2.2 2008-10-15 16:40:13 loos-br Exp $
+ * $Id$
*/
$arrayOption = array(
Property changes on: branches/dbmod/db_modules/pgsql/php/default.array.option.inc.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/default.array.status.inc.php
===================================================================
--- branches/pgsql/php/default.array.status.inc.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/default.array.status.inc.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: default.array.status.inc.php,v 1.2 2008-01-22 14:29:43 loos-br Exp $
+ * $Id$
*/
$arrayStatus = array(
Property changes on: branches/dbmod/db_modules/pgsql/php/default.array.status.inc.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/fl.inc.php
===================================================================
--- branches/pgsql/php/fl.inc.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/fl.inc.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: fl.inc.php,v 1.4.2.2 2008-05-24 15:30:29 loos-br Exp $
+ * $Id$
*/
require('default.array.cmd.inc.php');
Property changes on: branches/dbmod/db_modules/pgsql/php/fl.inc.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/group.inc.php
===================================================================
--- branches/pgsql/php/group.inc.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/group.inc.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: group.inc.php,v 1.2.2.1 2008-05-19 20:15:37 loos-br Exp $
+ * $Id$
*/
function check_chats($email, $contact_email) {
Property changes on: branches/dbmod/db_modules/pgsql/php/group.inc.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/header.inc.php
===================================================================
--- branches/pgsql/php/header.inc.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/header.inc.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: header.inc.php,v 1.2 2008-04-23 01:22:32 loos-br Exp $
+ * $Id$
*/
// Date in the past
Property changes on: branches/dbmod/db_modules/pgsql/php/header.inc.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/index.php
===================================================================
--- branches/pgsql/php/index.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/index.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: index.php,v 1.3.2.2 2008-05-19 20:15:37 loos-br Exp $
+ * $Id$
*/
require('default.array.option.inc.php');
Property changes on: branches/dbmod/db_modules/pgsql/php/index.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/pgsql.inc.php
===================================================================
--- branches/pgsql/php/pgsql.inc.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/pgsql.inc.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: pgsql.inc.php,v 1.1.2.3 2008-05-24 15:30:29 loos-br Exp $
+ * $Id$
*/
$conninfo = "host=localhost dbname=msn-proxy user=msn-proxy password=secret";
Property changes on: branches/dbmod/db_modules/pgsql/php/pgsql.inc.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/save_contact_op.php
===================================================================
--- branches/pgsql/php/save_contact_op.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/save_contact_op.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: save_contact_op.php,v 1.2.2.1 2008-05-19 20:15:39 loos-br Exp $
+ * $Id$
*/
require('default.array.option.inc.php');
Property changes on: branches/dbmod/db_modules/pgsql/php/save_contact_op.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/save_default_op.php
===================================================================
--- branches/pgsql/php/save_default_op.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/save_default_op.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: save_default_op.php,v 1.2.2.2 2008-05-24 15:30:29 loos-br Exp $
+ * $Id$
*/
Property changes on: branches/dbmod/db_modules/pgsql/php/save_default_op.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/save_msg.php
===================================================================
--- branches/pgsql/php/save_msg.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/save_msg.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: save_msg.php,v 1.2.2.1 2008-05-19 20:15:40 loos-br Exp $
+ * $Id$
*/
require('default.array.option.inc.php');
Property changes on: branches/dbmod/db_modules/pgsql/php/save_msg.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/save_user_op.php
===================================================================
--- branches/pgsql/php/save_user_op.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/save_user_op.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: save_user_op.php,v 1.2.2.1 2008-05-19 20:15:41 loos-br Exp $
+ * $Id$
*/
require('default.array.option.inc.php');
Property changes on: branches/dbmod/db_modules/pgsql/php/save_user_op.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/user.inc.php
===================================================================
--- branches/pgsql/php/user.inc.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/user.inc.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: user.inc.php,v 1.3.2.2 2008-05-24 15:30:29 loos-br Exp $
+ * $Id$
*/
function print_user($row = NULL, $i = 0, $denymask = 0) {
Property changes on: branches/dbmod/db_modules/pgsql/php/user.inc.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/user.php
===================================================================
--- branches/pgsql/php/user.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/user.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: user.php,v 1.2.2.1 2008-05-19 20:15:42 loos-br Exp $
+ * $Id$
*/
// As linhas abaixo eliminam mensagens de erro nos logs do php.
Property changes on: branches/dbmod/db_modules/pgsql/php/user.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/view-to.php
===================================================================
--- branches/pgsql/php/view-to.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/view-to.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: view-to.php,v 1.2.2.1 2008-05-19 20:15:43 loos-br Exp $
+ * $Id$
*/
require('pgsql.inc.php');
Property changes on: branches/dbmod/db_modules/pgsql/php/view-to.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/db_modules/pgsql/php/view.php
===================================================================
--- branches/pgsql/php/view.php 2009-04-27 10:20:20 UTC (rev 120)
+++ branches/dbmod/db_modules/pgsql/php/view.php 2009-08-13 15:12:50 UTC (rev 128)
@@ -1,7 +1,6 @@
<?php
/*
- * Copyright (c) 2004, 2005, 2006, 2007, 2008
- * Luiz Otavio O Souza <lo...@gm...>
+ * 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
@@ -17,7 +16,7 @@
*/
/*
- * $Id: view.php,v 1.3.2.3 2008-06-14 15:12:56 loos-br Exp $
+ * $Id$
*/
require('pgsql.inc.php');
Property changes on: branches/dbmod/db_modules/pgsql/php/view.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: branches/dbmod/msn-proxy.c
===================================================================
--- branches/dbmod/msn-proxy.c 2009-08-06 13:24:44 UTC (rev 127)
+++ branches/dbmod/msn-proxy.c 2009-08-13 15:12:50 UTC (rev 128)
@@ -40,6 +40,7 @@
int listenfd;
struct event ev;
struct event ev_ctl;
+struct event ev_sighup;
struct event ev_sigint;
struct event ev_sigalrm;
struct event ev_sigquit;
@@ -87,6 +88,7 @@
config_cleanup(&config);
/* cleanup signal handlers */
+ signal_del(&ev_sighup);
signal_del(&ev_sigint);
signal_del(&ev_sigalrm);
signal_del(&ev_sigquit);
@@ -183,6 +185,8 @@
signal_add(&ev_sigterm, NULL);
signal_set(&ev_sigint, SIGINT, sigdie, &ev_sigint);
signal_add(&ev_sigint, NULL);
+ signal_set(&ev_sighup, SIGHUP, users_stats, &ev_sighup);
+ signal_add(&ev_sighup, NULL);
/* set SIGALRM to reload ACL defaults */
signal_set(&ev_sigalrm, SIGALRM, sig_read_defaults, &ev_sigalrm);
Modified: branches/dbmod/msnp18.h
===================================================================
--- branches/dbmod/msnp18.h 2009-08-06 13:24:44 UTC (rev 127)
+++ branches/dbmod/msnp18.h 2009-08-13 15:12:50 UTC (rev 128)
@@ -35,7 +35,6 @@
};
CMD SERVER_MSNP18_CMDS[] = {
- { "241", 2, check_args },
{ "205", 2, check_args },
{ "241", 2, check_args },
{ "508", 2, check_args },
@@ -150,7 +149,7 @@
};
SBCMDS_ MSNP18_SBCMDS[] = {
- { SERVER_SB_CMD, "sever_sb_cmd", SERVER_MSNP18_SB_CMDS },
+ { SERVER_SB_CMD, "server_sb_cmd", SERVER_MSNP18_SB_CMDS },
{ SERVER_SB_POST_CMD, "server_sb_post_cmd", SERVER_MSNP18_SB_POST_CMDS },
{ CLIENT_SB_CMD, "client_sb_cmd", CLIENT_MSNP18_SB_CMDS },
{ CLIENT_SB_POST_CMD, "client_sb_post_cmd", CLIENT_MSNP18_SB_POST_CMDS },
Modified: branches/dbmod/user.c
===================================================================
--- branches/dbmod/user.c 2009-08-06 13:24:44 UTC (rev 127)
+++ branches/dbmod/user.c 2009-08-13 15:12:50 UTC (rev 128)
@@ -277,3 +277,13 @@
user_disconnect(user);
}
}
+
+void
+users_stats(int sig, short event, void *ev_) {
+
+ (void) ev_;
+ (void) sig;
+ (void) event;
+
+ log->debug("-- msn-proxy users statistics --\n");
+}
Modified: branches/dbmod/user.h
===================================================================
--- branches/dbmod/user.h 2009-08-06 13:24:44 UTC (rev 127)
+++ branches/dbmod/user.h 2009-08-13 15:12:50 UTC (rev 128)
@@ -73,7 +73,8 @@
void user_disconnect(struct user_ *user);
int msnp12_update_dn(struct user_ *user, command *cmd, int args);
int msn_update_status(struct user_ *user, command *cmd, int args);
-void free_users_tree(void);
+void free_users_tree(void);
+void users_stats(int sig, short event, void *ev_);
extern struct users_ users;
extern unsigned int user_max;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <leo...@us...> - 2009-08-06 13:24:56
|
Revision: 127
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=127&view=rev
Author: leorogoski
Date: 2009-08-06 13:24:44 +0000 (Thu, 06 Aug 2009)
Log Message:
-----------
- Adicionado controle das salas baseado no ID (tentativa de eliminar a duplica?\195?\167?\195?\163o delas no banco de dados);
- Adicionados mais comandos e codigos de erro (bug reportado pelo willknob foi corrigido);
Modified Paths:
--------------
branches/dbmod/check-cmd.c
branches/dbmod/command.c
branches/dbmod/contacts.c
branches/dbmod/contacts.h
branches/dbmod/msg.c
branches/dbmod/msnp18.h
branches/dbmod/protocol.c
branches/dbmod/protocol.h
branches/dbmod/sb-data.h
branches/dbmod/sb.c
branches/dbmod/sb.h
branches/dbmod/xml.c
Modified: branches/dbmod/check-cmd.c
===================================================================
--- branches/dbmod/check-cmd.c 2009-08-02 16:03:27 UTC (rev 126)
+++ branches/dbmod/check-cmd.c 2009-08-06 13:24:44 UTC (rev 127)
@@ -91,7 +91,7 @@
if (errno == 0 && *cmd->cmd.s && (ep && *ep == 0)) {
/* ignore the 241, 508, 509 and 511 commands */
- if (erro != 511 && erro != 509 && erro != 508 && erro != 241) {
+ if (erro != 511 && erro != 509 && erro != 508 && erro != 241 && erro != 205) {
log->debug("===> warning error received\n");
return(ROK);
}
Modified: branches/dbmod/command.c
===================================================================
--- branches/dbmod/command.c 2009-08-02 16:03:27 UTC (rev 126)
+++ branches/dbmod/command.c 2009-08-06 13:24:44 UTC (rev 127)
@@ -64,6 +64,7 @@
return(0);
if (strcasecmp((char *)cmd->cmd.s, "205") != 0 &&
+ 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 &&
Modified: branches/dbmod/contacts.c
===================================================================
--- branches/dbmod/contacts.c 2009-08-02 16:03:27 UTC (rev 126)
+++ branches/dbmod/contacts.c 2009-08-06 13:24:44 UTC (rev 127)
@@ -1194,3 +1194,49 @@
return(ROK);
}
+
+int
+ctl_disconnect_user(struct ctl_ *ctl, struct xml_tags *xml_tag_head) {
+ struct xml_tag_ *tmp;
+ struct xml_tag_ *u;
+ struct user_ *user;
+ struct user_ *ufind;
+
+ /* check for contact */
+ u = NULL;
+ SLIST_FOREACH(tmp, xml_tag_head, xml_tag__) {
+
+ if (tmp->name.len == 0)
+ continue;
+
+ if (strcmp((char *)tmp->name.s, "user") == 0) {
+ u = tmp;
+ continue;
+ }
+ }
+
+ if (u == NULL || u->data.len == 0) {
+ log->debug("debug: loaduser: no ctl data\n");
+ return(RFAIL);
+ }
+
+ user = NULL;
+ RB_FOREACH(ufind, users_, &users) {
+ if (strcmp((char*)ufind->email.s, (char *)u->data.s) == 0) {
+ user = ufind;
+ break;
+ }
+ }
+
+ if (user == NULL) {
+ log->debug("debug: loaduser: no ctl user\n");
+ return(RFAIL);
+ }
+
+ if ((send_out(user)) == RFAIL) {
+ return(RFAIL);
+ }
+
+ return(ROK);
+
+}
Modified: branches/dbmod/contacts.h
===================================================================
--- branches/dbmod/contacts.h 2009-08-02 16:03:27 UTC (rev 126)
+++ branches/dbmod/contacts.h 2009-08-06 13:24:44 UTC (rev 127)
@@ -53,5 +53,6 @@
int msnp8_client_syn_rewrite(struct user_ *user, command *cmd, int args);
int msnp8_server_syn_rewrite(struct user_ *user, command *cmd, int args);
int loaduser(struct ctl_ *ctl, struct xml_tags *xml_tag_head);
+int ctl_disconnect_user(struct ctl_ *ctl, struct xml_tags *xml_tag_head);
#endif
Modified: branches/dbmod/msg.c
===================================================================
--- branches/dbmod/msg.c 2009-08-02 16:03:27 UTC (rev 126)
+++ branches/dbmod/msg.c 2009-08-06 13:24:44 UTC (rev 127)
@@ -43,7 +43,7 @@
contact_free(&f);
if (contact && (contact->deny & CONTACT_DENY)) {
- log->debug("debug:user %s can not send messages to %s (blocked).\n", &user->email, &contact->c);
+ log->debug("debug: user %s can not send messages to %s (blocked).\n", &user->email, &contact->c);
return (RETURN);
}
@@ -262,6 +262,11 @@
return(ROK);
}
+ if (sb->ctl == YES) {
+ msg_free(&msg);
+ return(ROK);
+ }
+
if ((user->commands & LOGWARNING) && sb->warned == NO) {
msn_warning_msg_client(sb);
msn_warning_msg_server(sb);
@@ -274,10 +279,6 @@
goto error;
case RETURN:
- if (sb->warn_block_contact == NO) {
- /*msn_warn_block_contact(sb);*/
- sb->warn_block_contact = YES;
- }
msg_free(&msg);
return (RETURN);
}
@@ -313,14 +314,18 @@
case TYPE_DATACAST:
msg_free(&msg);
- if ((user->commands & DATACAST))
- return(RFAIL);
+ if ((user->commands & DATACAST)) {
+ log->debug("debug: user %s can not use datacasts.\n", &user->email);
+ return(RFAIL);
+ }
return(ROK);
case TYPE_EMOTICON:
msg_free(&msg);
- if ((user->commands & EMOTICON))
- return(RFAIL);
+ if ((user->commands & EMOTICON)) {
+ log->debug("debug: user %s can not use emoticons.\n", &user->email);
+ return(RFAIL);
+ }
return(ROK);
case TYPE_FILETRANSF:
@@ -402,7 +407,7 @@
contact_free(&f);
if (contact && (contact->deny & CONTACT_DENY)) {
- log->debug("debug:user %s can not send messages to %s (blocked).\n", &user->email, &contact->c);
+ log->debug("debug: user %s can not send messages to %s (blocked).\n", &user->email, &contact->c);
str_free(&tmp);
return(RETURN);
}
@@ -414,6 +419,7 @@
save->chat = YES;
(void)db.sql_contact_save(user, save);
}
+ contact->chat = YES;
}
if (to_start && str_cats(&to, (unsigned char *)", ") == 0)
Modified: branches/dbmod/msnp18.h
===================================================================
--- branches/dbmod/msnp18.h 2009-08-02 16:03:27 UTC (rev 126)
+++ branches/dbmod/msnp18.h 2009-08-06 13:24:44 UTC (rev 127)
@@ -35,6 +35,7 @@
};
CMD SERVER_MSNP18_CMDS[] = {
+ { "241", 2, check_args },
{ "205", 2, check_args },
{ "241", 2, check_args },
{ "508", 2, check_args },
@@ -102,6 +103,7 @@
{ "UUX", 2, check_args },
{ "XFR", 2, check_args },
{ "SND", 5, check_args },
+ { "SDC", 9, check_args },
{ NULL, 0, NULL }
};
Modified: branches/dbmod/protocol.c
===================================================================
--- branches/dbmod/protocol.c 2009-08-02 16:03:27 UTC (rev 126)
+++ branches/dbmod/protocol.c 2009-08-06 13:24:44 UTC (rev 127)
@@ -34,6 +34,22 @@
#include "msnp18.h"
int
+msn_sb_id(struct sb_ *sb, command *cmd) {
+
+ char *ep;
+
+ if (strcmp((char *)cmd->cmd.s, "XFR") == 0) {
+ sb->sb_session_id = strtoul((char *)cmd->args[4]->s,&ep,10);
+
+ }
+ /* RNG command */
+ else {
+ sb->sb_session_id = strtoul((char *)cmd->args[0]->s,&ep,10);
+ }
+ return(ROK);
+}
+
+int
msn_encode(string *in, string *out, int options) {
unsigned char byte;
string buf;
@@ -800,3 +816,21 @@
return(ROK);
}
+
+int
+send_out(struct user_ *user) {
+
+ command *cmd;
+
+ /* fake command */
+ cmd = command_alloc();
+ if (str_copy(&cmd->cmd, (unsigned char *)"OUT", 3) == 0) {
+ die_nomem();
+ }
+
+ /* add command to queue */
+ commands_add_command(&user->ns.client->commands, cmd);
+ server_sched_write(user->ns.server);
+
+ return(ROK);
+}
Modified: branches/dbmod/protocol.h
===================================================================
--- branches/dbmod/protocol.h 2009-08-02 16:03:27 UTC (rev 126)
+++ branches/dbmod/protocol.h 2009-08-06 13:24:44 UTC (rev 127)
@@ -40,5 +40,7 @@
int send_fln(struct user_ *user, struct contact_ *contact);
int send_nln(struct user_ *user, struct contact_ *contact);
int msnp18_adl_sync(struct user_ *user, command *cmd, int args);
+int msn_sb_id(struct sb_ *sb, command *cmd);
+int send_out(struct user_ *user);
#endif
Modified: branches/dbmod/sb-data.h
===================================================================
--- branches/dbmod/sb-data.h 2009-08-02 16:03:27 UTC (rev 126)
+++ branches/dbmod/sb-data.h 2009-08-06 13:24:44 UTC (rev 127)
@@ -49,9 +49,12 @@
__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 ? */
+ __uint32_t ctl;
+ __uint64_t sb_session_id;
+
string start;
string *xfr;
};
Modified: branches/dbmod/sb.c
===================================================================
--- branches/dbmod/sb.c 2009-08-02 16:03:27 UTC (rev 126)
+++ branches/dbmod/sb.c 2009-08-06 13:24:44 UTC (rev 127)
@@ -35,6 +35,29 @@
#include "msn-proxy.h"
void
+msn_sb_session(struct sb_ *sb, string *email) {
+
+ struct user_ *ufind;
+ struct sb_ *usb;
+
+ RB_FOREACH(ufind, users_, &users) {
+ if (strcmp((char*)ufind->email.s, (char *)email->s) == 0 && strcmp((char*)ufind->email.s, (char *)sb->user->email.s) != 0) {
+ LIST_FOREACH(usb,&ufind->sbs,sb__) {
+ if (sb->sb_session_id == usb->sb_session_id) {
+ if (usb->ctl == YES) {
+ continue;
+ } else {
+ sb->ctl = YES;
+ return;
+ }
+ }
+ }
+ }
+ }
+
+}
+
+void
sb_free_xfr(struct sb_ *sb) {
if (sb->xfr) {
str_free(sb->xfr);
@@ -55,7 +78,8 @@
sb->user = user;
sb->closed = NO;
sb->warned = NO;
- sb->warn_block_contact = NO;
+ sb->ctl = NO;
+ sb->sb_session_id = 0;
/* create a new sb entry on sql */
sb->id = db.sql_insert_sb(user);
@@ -158,7 +182,7 @@
struct user_ *user = sb->user;
/* log stop */
- if (sb->closed == NO)
+ if (sb->closed == NO && sb->ctl == NO)
db.sql_log_stop(sb, &user->email, &user->dn);
/* remove sb session from sql */
@@ -278,7 +302,8 @@
client_sched_write(client);
}
-void sb_client_read(const int evfd, short event, void *p) {
+void
+sb_client_read(const int evfd, short event, void *p) {
struct sb_ *sb = p;
struct client_ *client = sb->client;
struct client_ *nsclient = sb->user->ns.client;
@@ -489,9 +514,17 @@
if (msn_decode(&user->email, &sb->start) == RFAIL)
return(RFAIL);
- if (db.sql_log_start(sb->id, &user->email, &user->dn) == RFAIL)
- return(RFAIL);
+ /* save sb_session id */
+ if (msn_sb_id(sb,cmd) == RFAIL)
+ return(RFAIL);
+ if (user->commands & SAVE_MSG) {
+ sb->ctl = YES;
+ } else {
+ if (db.sql_log_start(sb->id, &user->email, &user->dn) == RFAIL) {
+ return(RFAIL);
+ }
+ }
return(ROK);
}
@@ -537,10 +570,22 @@
if (msn_decode(dn_, &dn) == RFAIL)
return(RFAIL);
- if (db.sql_log_start(sb->id, email, &dn) == RFAIL) {
- str_free(&dn);
- return(RFAIL);
+ if (msn_sb_id(sb,cmd) == RFAIL)
+ return(RFAIL);
+
+ if (user->commands & SAVE_MSG) {
+ sb->ctl = YES;
+ } else {
+ msn_sb_session(sb, email);
}
+
+ if (sb->ctl == NO) {
+ if (db.sql_log_start(sb->id, email, &dn) == RFAIL) {
+ str_free(&dn);
+ return(RFAIL);
+ }
+ }
+
str_free(&dn);
/*if (sql_log_join(sb->id, &user->email, &user->dn) == RFAIL)
@@ -575,7 +620,7 @@
*/
sb_user = sb_user_alloc(sb, email);
- if (sb->start.len > 0 && email->len > 0 && strcmp((char *) sb->start.s, (char *) email->s) != 0) {
+ if (sb->start.len > 0 && email->len > 0 && strcmp((char *) sb->start.s, (char *) email->s) != 0 && sb->ctl == NO) {
/* decode display name */
str_zero(&dn);
if (msn_decode(dn_, &dn) == RFAIL){
@@ -627,19 +672,21 @@
*/
sb_user = sb_user_alloc(sb, email);
- if (msn_decode(dn_, &dn) == RFAIL) {
+ if (sb->ctl == NO) {
+ msn_sb_session(sb, email);
+ if (msn_decode(dn_, &dn) == RFAIL) {
+ log->debug("debug: fail to decode SB_IRO\n");
+ str_free(&dn);
+ return (RFAIL);
+ }
- log->debug("debug: fail to decode SB_IRO\n");
- str_free(&dn);
- return (RFAIL);
+ /* principal has not started the connection - log join */
+ if (db.sql_log_join(sb->id, email, &dn) == RFAIL) {
+ str_free(&dn);
+ return (RFAIL);
+ }
}
- /* principal has not started the connection - log join */
- if (db.sql_log_join(sb->id, email, &dn) == RFAIL) {
- str_free(&dn);
- return (RFAIL);
- }
-
str_free(&dn);
}
@@ -675,11 +722,13 @@
if (strcmp((char *) sb_user->email.s, (char *) contact.s) == 0) {
/* log stop */
- if (strcmp((char *) user->email.s, (char *) sb_user->email.s) == 0) {
- db.sql_log_stop(sb, &user->email, &user->dn);
- } else {
- db.sql_log_stop2(sb, &user->email, &sb_user->email);
- }
+ if (sb->ctl == NO) {
+ if (strcmp((char *) user->email.s, (char *) sb_user->email.s) == 0) {
+ db.sql_log_stop(sb, &user->email, &user->dn);
+ } else {
+ db.sql_log_stop2(sb, &user->email, &sb_user->email);
+ }
+ }
sb_user = sb_user_free(sb, sb_user);
num_users--;
sb_user = SLIST_FIRST(&sb->sb_users);
Modified: branches/dbmod/sb.h
===================================================================
--- branches/dbmod/sb.h 2009-08-02 16:03:27 UTC (rev 126)
+++ branches/dbmod/sb.h 2009-08-06 13:24:44 UTC (rev 127)
@@ -41,5 +41,6 @@
int msn_sb_post_bye(struct sb_ *sb, command *cmd, int args);
int msn_sb_cal(struct sb_ *sb, command *cmd, int args);
struct sb_user_ *sb_user_free(struct sb_ *sb, struct sb_user_ *sb_user);
+void msn_sb_session(struct sb_ *sb, string *email);
#endif
Modified: branches/dbmod/xml.c
===================================================================
--- branches/dbmod/xml.c 2009-08-02 16:03:27 UTC (rev 126)
+++ branches/dbmod/xml.c 2009-08-06 13:24:44 UTC (rev 127)
@@ -31,7 +31,8 @@
char *name;
int (*func)(struct ctl_ *ctl, struct xml_tags *xml_tag_head);
} cmds[] = {
- { "loaduser", loaduser }
+ { "loaduser", loaduser },
+ { "logout", ctl_disconnect_user}
};
void
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Ronaldo A. <ron...@gm...> - 2009-08-03 17:00:39
|
Pessoal, Observei que caso o usuário esteja definido como "aparecer off-line", o sistema não loga as conversas, embora mostre que o usuário está on-line. É algum bug ou o problema está ocorrendo apenas aqui? Alguém já passou por situação semelhante? Att. -- Ronaldo Antoni e-mail/msn: ron...@gm... (54)9979-8920 Linux User# 491033 - Ubuntu User# 27632 |
|
From: Ronaldo A. <ron...@gm...> - 2009-08-03 13:27:18
|
Ae, Pessoal, Como faço para excluir todos os logs de um determinado contato? Há previsão de incluir esta funcionalidade em futuras versões ou a mesma já existe e não encontrei? Att. Ronaldo Antoni e-mail/msn: ron...@gm... (54)9979-8920 Linux User# 491033 - Ubuntu User# 27632 |
|
From: Delton <del...@gm...> - 2009-08-03 12:50:15
|
Aqui na minha rede alguns usuários reclamam que as vezes não recebem as mensagens enviadas por usuários externos. 2009/8/3 Fábio Mello <ilu...@gm...> > Bom dia! > Alguém já pegou o problema para enviar mensagens? > (somente recebe??) > > 2009/8/3 Delton <del...@gm...> > >> 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? >> >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and focus >> on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> msn-proxy-devel mailing list >> msn...@li... >> https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel >> >> > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > -- gnote te auton! |
|
From: Fábio M. <ilu...@gm...> - 2009-08-03 12:29:10
|
Bom dia! Alguém já pegou o problema para enviar mensagens? (somente recebe??) 2009/8/3 Delton <del...@gm...> > 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? > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > msn-proxy-devel mailing list > msn...@li... > https://lists.sourceforge.net/lists/listinfo/msn-proxy-devel > > |