Changes in / [5cb21d1:c180110]
- Files:
-
- 3 added
- 1 deleted
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r5cb21d1 rc180110 10 10 11 11 # Program variables 12 objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o $(OTR_BI) query.o root_commands.o set.o storage.o $(STORAGE_OBJS) unix.o conf.o log.o13 headers = $(wildcard $(_SRCDIR_)*.h $(_SRCDIR_)lib/*.h $(_SRCDIR_)protocols/*.h)12 objects = bitlbee.o dcc.o help.o ipc.o irc.o irc_im.o irc_channel.o irc_commands.o irc_send.o irc_user.o irc_util.o nick.o $(OTR_BI) query.o root_commands.o set.o storage.o $(STORAGE_OBJS) 13 headers = bitlbee.h commands.h conf.h config.h help.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h lib/events.h lib/ftutil.h lib/http_client.h lib/ini.h lib/json.h lib/json_util.h lib/md5.h lib/misc.h lib/proxy.h lib/sha1.h lib/ssl_client.h lib/url.h protocols/account.h protocols/bee.h protocols/ft.h protocols/nogaim.h 14 14 subdirs = lib protocols 15 15 16 OUTFILE = bitlbee 16 ifeq ($(TARGET),i586-mingw32msvc) 17 objects += win32.o 18 LDFLAGS+=-lws2_32 19 EFLAGS+=-lsecur32 20 OUTFILE=bitlbee.exe 21 else 22 objects += unix.o conf.o log.o 23 OUTFILE=bitlbee 24 endif 17 25 18 26 # Expansion of variables … … 94 102 mkdir -p $(DESTDIR)$(INCLUDEDIR) 95 103 $(INSTALL) -m 0644 config.h $(DESTDIR)$(INCLUDEDIR) 96 for i in $(headers); do $(INSTALL) -m 0644 $ $i $(DESTDIR)$(INCLUDEDIR); done104 for i in $(headers); do $(INSTALL) -m 0644 $(_SRCDIR_)$$i $(DESTDIR)$(INCLUDEDIR); done 97 105 mkdir -p $(DESTDIR)$(PCDIR) 98 106 $(INSTALL) -m 0644 bitlbee.pc $(DESTDIR)$(PCDIR) … … 141 149 install-systemd: systemd 142 150 ifdef SYSTEMDSYSTEMUNITDIR 151 ifeq ($(shell id -u),0) 143 152 mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) 144 153 $(INSTALL) -m 0644 init/bitlbee.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) … … 146 155 $(INSTALL) -m 0644 $(_SRCDIR_)init/bitlbee.socket $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) 147 156 else 148 @echo SYSTEMDSYSTEMUNITDIR not set, not installing systemd unit files. 157 @echo Not root, so not installing systemd files. 158 endif 149 159 endif 150 160 -
bitlbee.c
r5cb21d1 rc180110 127 127 global.listen_watch_source_id = b_input_add( global.listen_socket, B_EV_IO_READ, bitlbee_io_new_client, NULL ); 128 128 129 #ifndef _WIN32 129 130 if( !global.conf->nofork ) 130 131 { … … 150 151 } 151 152 } 153 #endif 152 154 153 155 if( global.conf->runmode == RUNMODE_FORKDAEMON ) … … 157 159 ipc_master_listen_socket(); 158 160 161 #ifndef _WIN32 159 162 if( ( fp = fopen( global.conf->pidfile, "w" ) ) ) 160 163 { … … 166 169 log_message( LOGLVL_WARNING, "Warning: Couldn't write PID to `%s'", global.conf->pidfile ); 167 170 } 171 #endif 168 172 169 173 if( !global.conf->nofork ) … … 291 295 } 292 296 297 #ifndef _WIN32 293 298 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 294 299 { … … 352 357 } 353 358 else 359 #endif 354 360 { 355 361 log_message( LOGLVL_INFO, "Creating new connection with fd %d.", new_socket ); -
bitlbee.h
r5cb21d1 rc180110 35 35 #endif 36 36 37 /* Depend on Windows 2000 for now since we need getaddrinfo() */ 38 #define _WIN32_WINNT 0x0501 39 37 40 #define PACKAGE "BitlBee" 38 41 #define BITLBEE_VERSION "3.2.2" … … 57 60 #include <ctype.h> 58 61 #include <errno.h> 62 63 #ifndef _WIN32 59 64 #include <syslog.h> 65 #endif 66 60 67 #include <glib.h> 61 68 #include <gmodule.h> -
configure
r5cb21d1 rc180110 341 341 int main() 342 342 { 343 344 res_query( NULL, 0, 0, NULL, 0);345 dn_expand( NULL, NULL, NULL, NULL, 0);346 dn_skipname( NULL, NULL);347 }348 '349 RESOLV_NS_TESTCODE='350 #include <sys/types.h>351 #include <netinet/in.h>352 #include <arpa/nameser.h>353 #include <resolv.h>354 355 int main()356 {357 343 ns_initparse( NULL, 0, NULL ); 358 344 ns_parserr( NULL, ns_s_an, 0, NULL ); 359 345 } 360 346 ' 361 RESOLV_NS_TYPES_TESTCODE='362 #include <sys/types.h>363 #include <netinet/in.h>364 #include <arpa/nameser.h>365 366 int main()367 {368 ns_msg nsh;369 ns_rr rr;370 371 /* Not all platforms we want to work on have372 ns_* routines, so use this to make sure373 the compiler uses it.*/374 return (int)(sizeof(nsh) + sizeof(rr));375 }376 '377 347 378 348 detect_resolv_dynamic() 379 349 { 380 350 case "$arch" in 381 OpenBSD )382 # In FreeBSD res_*/dn_* routines are present in libc.so383 LIBRESOLV=;;384 351 FreeBSD ) 385 # In FreeBSD res_*/dn_* routines are present in libc.so 386 LIBRESOLV=;; 387 CYGWIN* ) 388 # In Cygwin res_*/dn_* routines are present in libc.so 352 # In FreeBSD res_* routines are present in libc.so 389 353 LIBRESOLV=;; 390 354 * ) … … 421 385 } 422 386 423 detect_resolv_ns_dynamic()424 {425 case "$arch" in426 FreeBSD )427 # In FreeBSD ns_ routines are present in libc.so428 LIBRESOLV=;;429 * )430 LIBRESOLV=-lresolv;;431 esac432 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)433 ret=1434 echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null435 if [ "$?" = "0" ]; then436 ret=0437 fi438 439 rm -f $TMPFILE440 return $ret441 }442 443 detect_resolv_ns_static()444 {445 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)446 ret=1447 for i in $systemlibdirs; do448 if [ -f $i/libresolv.a ]; then449 echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null450 if [ "$?" = "0" ]; then451 ret=0452 fi453 fi454 done455 456 rm -f $TMPFILE457 return $ret458 }459 460 detect_nameser_has_ns_types()461 {462 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)463 ret=1464 # since we aren't actually linking with ns_* routines465 # we can just compile the test code466 echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c - >/dev/null 2>/dev/null467 if [ "$?" = "0" ]; then468 ret=0469 fi470 471 rm -f $TMPFILE472 return $ret473 }474 475 387 if [ "$ssl" = "auto" ]; then 476 388 detect_gnutls … … 484 396 elif [ "$ssl" = "nss" ]; then 485 397 detect_nss 398 elif [ "$ssl" = "sspi" ]; then 399 echo 486 400 elif [ "$ssl" = "openssl" ]; then 487 401 echo … … 526 440 echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings 527 441 528 if detect_nameser_has_ns_types; then529 echo '#define NAMESER_HAS_NS_TYPES' >> config.h530 fi531 442 if detect_resolv_dynamic || detect_resolv_static; then 532 443 echo '#define HAVE_RESOLV_A' >> config.h 533 if detect_resolv_ns_dynamic || detect_resolv_ns_static; then 534 echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h 535 fi 536 else 537 echo 'Insufficient resolv routines. Jabber server must be set explicitly' 538 fi 539 444 fi 540 445 541 446 STORAGES="xml" … … 606 511 # BI == built-in 607 512 echo '#define OTR_BI' >> config.h 608 echo "EFLAGS+=-L${otrprefix}/lib -lotr -lgcrypt" >> Makefile.settings513 echo "EFLAGS+=-L${otrprefix}/lib -lotr" >> Makefile.settings 609 514 echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings 610 515 echo 'OTR_BI=otr.o' >> Makefile.settings … … 804 709 ;; 805 710 CYGWIN* ) 711 echo 'Cygwin is not officially supported.' 806 712 ;; 807 713 Windows ) 808 echo 'Native windows compilation is not supported anymore, use cygwin instead.'809 714 ;; 810 715 * ) -
debian/rules
r5cb21d1 rc180110 34 34 endif 35 35 36 CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)37 CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)38 LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)39 40 CONFIGURE_OVERRIDES:=CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"41 42 36 build: build-stamp 43 37 build-stamp: … … 45 39 46 40 mkdir -p debian/build-native 47 ROOT=$$PWD; cd debian/build-native; $(BITLBEE_CONFIGURE_VERSION) $( CONFIGURE_OVERRIDES) $$ROOT/configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent --otr=$(BITLBEE_OTR) --skype=$(BITLBEE_SKYPE) $(BITLBEE_CONFIGURE_FLAGS)41 ROOT=$$PWD; cd debian/build-native; $(BITLBEE_CONFIGURE_VERSION) $(shell dpkg-buildflags --export=configure) $$ROOT/configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent --otr=$(BITLBEE_OTR) --skype=$(BITLBEE_SKYPE) $(BITLBEE_CONFIGURE_FLAGS) 48 42 $(MAKE) -C debian/build-native 49 43 50 44 ifeq ($(BITLBEE_LIBPURPLE),1) 51 45 mkdir -p debian/build-libpurple 52 ROOT=$$PWD; cd debian/build-libpurple; $(BITLBEE_CONFIGURE_VERSION) $( CONFIGURE_OVERRIDES) $$ROOT/configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --purple=1 $(BITLBEE_CONFIGURE_FLAGS)46 ROOT=$$PWD; cd debian/build-libpurple; $(BITLBEE_CONFIGURE_VERSION) $(shell dpkg-buildflags --export=configure) $$ROOT/configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --purple=1 $(BITLBEE_CONFIGURE_FLAGS) 53 47 $(MAKE) -C debian/build-libpurple 54 48 endif -
doc/user-guide/Makefile
r5cb21d1 rc180110 17 17 18 18 %.html: %.db.xml 19 xsltproc -- param generate.consistent.ids 1 --output $@ http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl $<19 xsltproc --output $@ http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl $< 20 20 21 21 %.pdf: %.db.xml -
doc/user-guide/commands.xml
r5cb21d1 rc180110 1790 1790 1791 1791 <bitlbee-command name="blist"> 1792 <syntax>blist [all|online|offline|away] [<pattern>]</syntax>1792 <syntax>blist [all|online|offline|away]</syntax> 1793 1793 <short-description>List all the buddies in the current channel</short-description> 1794 1794 … … 1796 1796 <para> 1797 1797 You can get a more readable buddy list using the <emphasis>blist</emphasis> command. If you want a complete list (including the offline users) you can use the <emphasis>all</emphasis> argument. 1798 </para>1799 1800 <para>1801 A perl-compatible regular expression can be supplied as <emphasis>pattern</emphasis> to filter the results (case-insensitive).1802 1798 </para> 1803 1799 </description> -
help.c
r5cb21d1 rc180110 42 42 *help = h = g_new0 ( help_t, 1 ); 43 43 44 h->fd = open( helpfile, O_RDONLY ); 44 h->fd = open( helpfile, O_RDONLY 45 #ifdef _WIN32 46 | O_BINARY 47 #endif 48 ); 45 49 46 50 if( h->fd == -1 ) -
ipc.c
r5cb21d1 rc180110 28 28 #include "ipc.h" 29 29 #include "commands.h" 30 #ifndef _WIN32 30 31 #include <sys/uio.h> 31 32 #include <sys/un.h> 33 #endif 32 34 33 35 GSList *child_list = NULL; … … 841 843 } 842 844 845 #ifndef _WIN32 843 846 char *ipc_master_save_state() 844 847 { … … 939 942 return 1; 940 943 } 944 #else 945 int ipc_master_listen_socket() 946 { 947 /* FIXME: Open named pipe \\.\BITLBEE */ 948 return 0; 949 } 950 #endif 941 951 942 952 int ipc_master_load_state( char *statefile ) -
irc.c
r5cb21d1 rc180110 27 27 #include "ipc.h" 28 28 #include "dcc.h" 29 #include "lib/ssl_client.h"30 29 31 30 GSList *irc_connection_list; … … 172 171 nogaim_init(); 173 172 #endif 174 175 /* SSL library initialization also should be done after the fork, to176 avoid shared CSPRNG state. This is required by NSS, which refuses to177 work if a fork is detected */178 ssl_init();179 173 180 174 for( l = irc_plugins; l; l = l->next ) -
irc_commands.c
r5cb21d1 rc180110 365 365 cmd[2][strlen(cmd[2])-1] = '\0'; 366 366 367 ctcp = split_command_parts( cmd[2] + 1 , 0);367 ctcp = split_command_parts( cmd[2] + 1 ); 368 368 iu->f->ctcp( iu, ctcp ); 369 369 } -
irc_im.c
r5cb21d1 rc180110 637 637 irc_send_msg( iu, "PRIVMSG", ic->name, wrapped, ts ); 638 638 g_free( ts ); 639 g_free( wrapped );640 639 641 640 return TRUE; -
lib/Makefile
r5cb21d1 rc180110 13 13 14 14 # [SH] Program variables 15 objects = arc.o base64.o $(EVENT_HANDLER) ftutil.o http_client.o ini.o json.o json_util.o md5.o misc.o oauth.o oauth2.o proxy.o sha1.o $(SSL_CLIENT) url.o xmltree.o ns_parse.o15 objects = arc.o base64.o $(EVENT_HANDLER) ftutil.o http_client.o ini.o json.o json_util.o md5.o misc.o oauth.o oauth2.o proxy.o sha1.o $(SSL_CLIENT) url.o xmltree.o 16 16 17 17 LFLAGS += -r -
lib/events.h
r5cb21d1 rc180110 37 37 38 38 #include <sys/types.h> 39 #ifndef _WIN32 39 40 #include <sys/socket.h> 40 41 #include <netdb.h> 41 42 #include <netinet/in.h> 43 #endif 42 44 #include <glib.h> 43 45 #include <gmodule.h> -
lib/events_glib.c
r5cb21d1 rc180110 31 31 #include <string.h> 32 32 #include <sys/types.h> 33 #ifndef _WIN32 33 34 #include <sys/socket.h> 34 35 #include <netdb.h> … … 36 37 #include <arpa/inet.h> 37 38 #include <unistd.h> 39 #else 40 #include "sock.h" 41 #define ETIMEDOUT WSAETIMEDOUT 42 #define EINPROGRESS WSAEINPROGRESS 43 #endif 38 44 #include <fcntl.h> 39 45 #include <errno.h> -
lib/http_client.c
r5cb21d1 rc180110 292 292 293 293 cleanup: 294 /* Avoid g_source_remove warnings */295 req->inpa = 0;296 297 294 if( req->ssl ) 298 295 ssl_disconnect( req->ssl ); -
lib/misc.c
r5cb21d1 rc180110 420 420 void random_bytes( unsigned char *buf, int count ) 421 421 { 422 #ifndef _WIN32 422 423 static int use_dev = -1; 423 424 … … 469 470 470 471 if( !use_dev ) 472 #endif 471 473 { 472 474 int i; … … 523 525 ns_msg nsh; 524 526 ns_rr rr; 525 int n, len, size;527 int i, n, len, size; 526 528 527 529 g_snprintf( name, sizeof( name ), "_%s._%s.%s", service, protocol, domain ); … … 536 538 while( ns_parserr( &nsh, ns_s_an, n, &rr ) == 0 ) 537 539 { 538 char name[NS_MAXDNAME]; 539 540 if( ns_rr_rdlen( rr ) < 7) 541 break; 542 540 size = ns_rr_rdlen( rr ); 543 541 buf = ns_rr_rdata( rr ); 544 542 545 if( dn_expand(querybuf, querybuf + size, &buf[6], name, NS_MAXDNAME) == -1 ) 543 len = 0; 544 for( i = 6; i < size && buf[i]; i += buf[i] + 1 ) 545 len += buf[i] + 1; 546 547 if( i > size ) 546 548 break; 547 548 len = strlen(name) + 1;549 549 550 550 reply = g_malloc( sizeof( struct ns_srv_reply ) + len ); 551 memcpy( reply->name, name, len ); 551 memcpy( reply->name, buf + 7, len ); 552 553 for( i = buf[6]; i < len && buf[7+i]; i += buf[7+i] + 1 ) 554 reply->name[i] = '.'; 555 556 if( i > len ) 557 { 558 g_free( reply ); 559 break; 560 } 552 561 553 562 reply->prio = ( buf[0] << 8 ) | buf[1]; … … 673 682 white\ space in 'various ways'. Returns a NULL-terminated static 674 683 char** so watch out with nested use! Definitely not thread-safe. */ 675 char **split_command_parts( char *command , int limit)684 char **split_command_parts( char *command ) 676 685 { 677 686 static char *cmd[IRC_MAX_ARGS+1]; … … 683 692 k = 1; 684 693 for( s = command; *s && k < IRC_MAX_ARGS; s ++ ) 685 {686 694 if( *s == ' ' && !q ) 687 695 { 688 696 *s = 0; 689 697 while( *++s == ' ' ); 690 if( k != limit && (*s == '"' || *s == '\''))698 if( *s == '"' || *s == '\'' ) 691 699 { 692 700 q = *s; … … 696 704 { 697 705 cmd[k++] = s; 698 if (limit && k > limit) {699 break;700 }701 706 s --; 702 707 } … … 717 722 q = *s = 0; 718 723 } 719 }720 724 721 725 /* Full zero-padding for easier argc checking. */ -
lib/misc.h
r5cb21d1 rc180110 38 38 }; 39 39 40 #ifndef NAMESER_HAS_NS_TYPES41 42 #define NS_MAXDNAME 102543 #define NS_INT16SZ 244 #define NS_INT32SZ 445 46 #define NS_GET16(s, cp) do { \47 register const unsigned char *t_cp = (const unsigned char*)(cp); \48 (s) = ((guint16)t_cp[0] << 8) \49 | ((guint16)t_cp[1]) \50 ; \51 (cp) += NS_INT16SZ; \52 } while(0)53 54 #define NS_GET32(s, cp) do { \55 register const unsigned char *t_cp = (const unsigned char*)(cp); \56 (s) = ((guint16)t_cp[0] << 24) \57 | ((guint16)t_cp[1] << 16) \58 | ((guint16)t_cp[2] << 8) \59 | ((guint16)t_cp[3]) \60 ; \61 (cp) += NS_INT32SZ; \62 } while(0)63 64 #define ns_rr_rdlen(rr) ((rr).rdlength + 0)65 #define ns_rr_rdata(rr) ((rr).rdata + 0)66 67 struct _ns_flagdata { int mask, shift; };68 69 typedef struct __ns_rr {70 char name[NS_MAXDNAME];71 guint16 type;72 guint16 rr_class;73 guint32 ttl;74 guint16 rdlength;75 const unsigned char* rdata;76 } ns_rr;77 78 typedef enum __ns_sect {79 ns_s_qd = 0,80 ns_s_zn = 0,81 ns_s_an = 1,82 ns_s_pr = 1,83 ns_s_ns = 2,84 ns_s_ud = 2,85 ns_s_ar = 3,86 ns_s_max =487 } ns_sect;88 89 typedef struct __ns_msg90 {91 const unsigned char* _msg;92 const unsigned char* _eom;93 guint16 _id;94 guint16 _flags;95 guint16 _counts[ns_s_max];96 const unsigned char* _sections[ns_s_max];97 ns_sect _sect;98 int _rrnum;99 const unsigned char* _msg_ptr;100 } ns_msg;101 102 typedef enum __ns_class {103 ns_c_invalid = 0,104 ns_c_in = 1,105 ns_c_2 = 2,106 ns_c_chaos = 3,107 ns_c_hs = 4,108 ns_c_none = 254,109 ns_c_any = 255,110 ns_c_max = 65536111 } ns_class;112 113 114 /* TODO : fill out the rest */115 typedef enum __ns_type {116 ns_t_srv = 33117 } ns_type;118 119 #endif /* NAMESER_HAS_NS_INITPARSE */120 121 40 G_MODULE_EXPORT void strip_linefeed( gchar *text ); 122 41 G_MODULE_EXPORT char *add_cr( char *text ); … … 148 67 G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl ); 149 68 G_MODULE_EXPORT int md5_verify_password( char *password, char *hash ); 150 G_MODULE_EXPORT char **split_command_parts( char *command , int limit);69 G_MODULE_EXPORT char **split_command_parts( char *command ); 151 70 G_MODULE_EXPORT char *get_rfc822_header( const char *text, const char *header, int len ); 152 71 -
lib/proxy.c
r5cb21d1 rc180110 26 26 #include <string.h> 27 27 #include <sys/types.h> 28 #ifndef _WIN32 28 29 #include <sys/socket.h> 29 30 #include <netdb.h> … … 31 32 #include <arpa/inet.h> 32 33 #include <unistd.h> 34 #else 35 #include "sock.h" 36 #define ETIMEDOUT WSAETIMEDOUT 37 #define EINPROGRESS WSAEINPROGRESS 38 #endif 33 39 #include <fcntl.h> 34 40 #include <errno.h> … … 70 76 len = sizeof(error); 71 77 78 #ifndef _WIN32 72 79 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0 || error) { 73 80 if ((phb->gai_cur = phb->gai_cur->ai_next)) { … … 94 101 return FALSE; 95 102 } 103 #endif 96 104 freeaddrinfo(phb->gai); 97 105 sock_make_blocking(source); -
lib/proxy.h
r5cb21d1 rc180110 28 28 29 29 #include <sys/types.h> 30 #ifndef _WIN32 30 31 #include <sys/socket.h> 31 32 #include <netdb.h> 32 33 #include <netinet/in.h> 34 #endif 33 35 #include <glib.h> 34 36 #include <gmodule.h> -
lib/ssl_gnutls.c
r5cb21d1 rc180110 236 236 static void ssl_cache_add( struct scd *conn ) 237 237 { 238 size_t data_size = 0;238 size_t data_size; 239 239 struct ssl_session *data; 240 240 char *hostname; … … 245 245 246 246 data = g_malloc( sizeof( struct ssl_session ) + data_size ); 247 if( gnutls_session_get_data( conn->session, data->data, &data _size ) != 0 )247 if( gnutls_session_get_data( conn->session, data->data, &data->size ) != 0 ) 248 248 { 249 249 g_free( data ); … … 335 335 int st, stver; 336 336 337 /* This function returns false, so avoid calling b_event_remove again */338 conn->inpa = -1;339 340 337 if( ( st = gnutls_handshake( conn->session ) ) < 0 ) 341 338 { -
protocols/account.c
r5cb21d1 rc180110 27 27 #include "bitlbee.h" 28 28 #include "account.h" 29 30 static const char* account_protocols_local[] = {31 "gg", NULL32 };33 29 34 30 static char *set_eval_nick_source( set_t *set, char *value ); … … 351 347 void account_on( bee_t *bee, account_t *a ) 352 348 { 353 GHashTableIter nicks;354 gpointer k, v;355 356 349 if( a->ic ) 357 350 { … … 367 360 if( a->ic && !( a->ic->flags & ( OPT_SLOW_LOGIN | OPT_LOGGED_IN ) ) ) 368 361 a->ic->keepalive = b_timeout_add( 120000, account_on_timeout, a->ic ); 369 370 if( a->flags & ACC_FLAG_LOCAL )371 {372 g_hash_table_iter_init(&nicks, a->nicks);373 while( g_hash_table_iter_next( &nicks, &k, &v ) )374 {375 a->prpl->add_buddy( a->ic, (char*) k, NULL );376 }377 }378 362 } 379 363 … … 481 465 return a->auto_reconnect_delay; 482 466 } 483 484 int protocol_account_islocal( const char* protocol )485 {486 const char** p = account_protocols_local;487 do {488 if( strcmp( *p, protocol ) == 0 )489 return 1;490 } while( *( ++p ) );491 return 0;492 } -
protocols/account.h
r5cb21d1 rc180110 59 59 int account_reconnect_delay( account_t *a ); 60 60 61 int protocol_account_islocal( const char* protocol );62 63 61 typedef enum 64 62 { … … 72 70 ACC_FLAG_STATUS_MESSAGE = 0x02, /* Supports status messages (without being away). */ 73 71 ACC_FLAG_HANDLE_DOMAINS = 0x04, /* Contact handles need a domain portion. */ 74 ACC_FLAG_LOCAL = 0x08, /* Contact list is local. */75 72 } account_flag_t; 76 73 -
protocols/jabber/iq.c
r5cb21d1 rc180110 352 352 /* Server is crap, but this is no disaster. */ 353 353 } 354 else if( jabber_compare_jid( jd->me, c->text ) == 0 )354 else if( strncmp( jd->me, c->text, strlen( jd->me ) ) != 0 ) 355 355 { 356 356 s = strchr( c->text, '/' ); -
protocols/jabber/jabber.h
r5cb21d1 rc180110 289 289 const struct jabber_away_state *jabber_away_state_by_name( char *name ); 290 290 void jabber_buddy_ask( struct im_connection *ic, char *handle ); 291 int jabber_compare_jid( const char *jid1, const char *jid2 );292 291 char *jabber_normalize( const char *orig ); 293 292 -
protocols/jabber/jabber_util.c
r5cb21d1 rc180110 306 306 imcb_ask( ic, buf, bla, jabber_buddy_ask_yes, jabber_buddy_ask_no ); 307 307 g_free( buf ); 308 }309 310 /* Compares just the bare portions of two Jabber IDs. */311 int jabber_compare_jid( const char *jid1, const char *jid2 )312 {313 int i;314 315 for( i = 0; ; i ++ )316 {317 if( jid1[i] == '\0' || jid1[i] == '/' || jid2[i] == '\0' || jid2[i] == '/' )318 {319 if( ( jid1[i] == '\0' || jid1[i] == '/' ) && ( jid2[i] == '\0' || jid2[i] == '/' ) )320 break;321 return FALSE;322 }323 if( tolower( jid1[i] ) != tolower( jid2[i] ) )324 {325 return FALSE;326 }327 }328 329 return TRUE;330 308 } 331 309 -
protocols/msn/soap.h
r5cb21d1 rc180110 36 36 #include <string.h> 37 37 #include <sys/types.h> 38 #ifndef _WIN32 38 39 #include <sys/socket.h> 39 40 #include <netinet/in.h> 40 41 #include <arpa/inet.h> 41 42 #include <unistd.h> 43 #endif 42 44 #include "nogaim.h" 43 45 -
protocols/oscar/rxqueue.c
r5cb21d1 rc180110 9 9 #include <aim.h> 10 10 11 #ifndef _WIN32 11 12 #include <sys/socket.h> 13 #endif 12 14 13 15 /* -
protocols/oscar/txqueue.c
r5cb21d1 rc180110 9 9 #include "im.h" 10 10 11 #ifndef _WIN32 11 12 #include <sys/socket.h> 13 #endif 12 14 13 15 /* -
protocols/twitter/twitter.c
r5cb21d1 rc180110 323 323 s = set_add(&acc->set, "show_ids", "true", set_eval_bool, acc); 324 324 325 s = set_add(&acc->set, "show_old_mentions", " 0", set_eval_int, acc);325 s = set_add(&acc->set, "show_old_mentions", "20", set_eval_int, acc); 326 326 327 327 s = set_add(&acc->set, "strip_newlines", "false", set_eval_bool, acc); … … 602 602 603 603 cmds = g_strdup(message); 604 cmd = split_command_parts(cmds , 2);604 cmd = split_command_parts(cmds); 605 605 606 606 if (cmd[0] == NULL) { … … 617 617 618 618 goto eof; 619 } else if ((g_strcasecmp(cmd[0], "favourite") == 0 || 620 g_strcasecmp(cmd[0], "favorite") == 0 || 621 g_strcasecmp(cmd[0], "fav") == 0) && cmd[1]) { 619 } else if (g_strcasecmp(cmd[0], "favourite") == 0 && cmd[1]) { 622 620 if ((id = twitter_message_id_from_command_arg(ic, cmd[1], NULL))) { 623 621 twitter_favourite_tweet(ic, id); … … 664 662 goto eof; 665 663 } 666 message = new = g_strdup_printf("@%s %s", bu->handle, cmd[2]);664 message = new = g_strdup_printf("@%s %s", bu->handle, message + (cmd[2] - cmd[0])); 667 665 in_reply_to = id; 668 666 allow_post = TRUE; -
protocols/yahoo/libyahoo2.c
r5cb21d1 rc180110 48 48 */ 49 49 50 #ifndef _WIN32 50 51 #include <unistd.h> 52 #endif 51 53 #include <errno.h> 52 54 #include <stdio.h> -
protocols/yahoo/yahoo_httplib.c
r5cb21d1 rc180110 38 38 39 39 #include <errno.h> 40 #ifndef _WIN32 40 41 #include <unistd.h> 42 #endif 41 43 #include <ctype.h> 42 44 #include "yahoo2.h" -
protocols/yahoo/yahoo_util.h
r5cb21d1 rc180110 65 65 void y_strfreev(char **vector); 66 66 67 #ifndef _WIN32 67 68 int strncasecmp(const char *s1, const char *s2, size_t n); 68 69 int strcasecmp(const char *s1, const char *s2); … … 72 73 int snprintf(char *str, size_t size, const char *format, ...); 73 74 int vsnprintf(char *str, size_t size, const char *format, va_list ap); 75 #endif 74 76 75 77 #endif -
root_commands.c
r5cb21d1 rc180110 32 32 void root_command_string( irc_t *irc, char *command ) 33 33 { 34 root_command( irc, split_command_parts( command , 0) );34 root_command( irc, split_command_parts( command ) ); 35 35 } 36 36 … … 1085 1085 static void cmd_blist( irc_t *irc, char **cmd ) 1086 1086 { 1087 int online = 0, away = 0, offline = 0 , ismatch = 0;1087 int online = 0, away = 0, offline = 0; 1088 1088 GSList *l; 1089 GRegex *regex = NULL;1090 GError *error = NULL;1091 1089 char s[256]; 1092 1090 char *format; … … 1104 1102 online = away = 1; 1105 1103 1106 if( cmd[2] )1107 regex = g_regex_new( cmd[2], G_REGEX_CASELESS, 0, &error );1108 1109 if( error )1110 {1111 irc_rootmsg( irc, error->message );1112 g_error_free( error );1113 }1114 1115 1104 if( strchr( irc->umode, 'b' ) != NULL ) 1116 1105 format = "%s\t%s\t%s"; … … 1129 1118 bee_user_t *bu = iu->bu; 1130 1119 1131 if( !regex || g_regex_match( regex, iu->nick, 0, NULL ) ) 1132 ismatch = 1; 1133 else 1134 ismatch = 0; 1135 1136 if( !bu || ( irc->root->last_channel && !irc_channel_wants_user( irc->root->last_channel, iu ) ) ) 1120 if( !bu || ( irc->root->last_channel && !irc_channel_wants_user( irc->root->last_channel, iu ) ) || 1121 ( bu->flags & ( BEE_USER_ONLINE | BEE_USER_AWAY ) ) != BEE_USER_ONLINE ) 1137 1122 continue; 1138 1123 1139 if( ( bu->flags & ( BEE_USER_ONLINE | BEE_USER_AWAY ) ) == BEE_USER_ONLINE ) 1140 { 1141 if( ismatch == 1 && online == 1 ) 1142 { 1143 char st[256] = "Online"; 1144 1145 if( bu->status_msg ) 1146 g_snprintf( st, sizeof( st ) - 1, "Online (%s)", bu->status_msg ); 1147 1148 g_snprintf( s, sizeof( s ) - 1, "%s %s", bu->handle, bu->ic->acc->tag ); 1149 irc_rootmsg( irc, format, iu->nick, s, st ); 1150 } 1124 if( online == 1 ) 1125 { 1126 char st[256] = "Online"; 1151 1127 1152 n_online ++; 1153 } 1154 1155 if( ( bu->flags & BEE_USER_ONLINE ) && ( bu->flags & BEE_USER_AWAY ) ) 1156 { 1157 if( ismatch == 1 && away == 1 ) 1158 { 1159 g_snprintf( s, sizeof( s ) - 1, "%s %s", bu->handle, bu->ic->acc->tag ); 1160 irc_rootmsg( irc, format, iu->nick, s, irc_user_get_away( iu ) ); 1161 } 1162 n_away ++; 1163 } 1164 1165 if( !(bu->flags & BEE_USER_ONLINE) ) 1166 { 1167 if( ismatch == 1 && offline == 1 ) 1168 { 1169 g_snprintf( s, sizeof( s ) - 1, "%s %s", bu->handle, bu->ic->acc->tag ); 1170 irc_rootmsg( irc, format, iu->nick, s, "Offline" ); 1171 } 1172 n_offline ++; 1173 } 1128 if( bu->status_msg ) 1129 g_snprintf( st, sizeof( st ) - 1, "Online (%s)", bu->status_msg ); 1130 1131 g_snprintf( s, sizeof( s ) - 1, "%s %s", bu->handle, bu->ic->acc->tag ); 1132 irc_rootmsg( irc, format, iu->nick, s, st ); 1133 } 1134 1135 n_online ++; 1136 } 1137 1138 for( l = irc->users; l; l = l->next ) 1139 { 1140 irc_user_t *iu = l->data; 1141 bee_user_t *bu = iu->bu; 1142 1143 if( !bu || ( irc->root->last_channel && !irc_channel_wants_user( irc->root->last_channel, iu ) ) || 1144 !( bu->flags & BEE_USER_ONLINE ) || !( bu->flags & BEE_USER_AWAY ) ) 1145 continue; 1146 1147 if( away == 1 ) 1148 { 1149 g_snprintf( s, sizeof( s ) - 1, "%s %s", bu->handle, bu->ic->acc->tag ); 1150 irc_rootmsg( irc, format, iu->nick, s, irc_user_get_away( iu ) ); 1151 } 1152 n_away ++; 1153 } 1154 1155 for( l = irc->users; l; l = l->next ) 1156 { 1157 irc_user_t *iu = l->data; 1158 bee_user_t *bu = iu->bu; 1159 1160 if( !bu || ( irc->root->last_channel && !irc_channel_wants_user( irc->root->last_channel, iu ) ) || 1161 bu->flags & BEE_USER_ONLINE ) 1162 continue; 1163 1164 if( offline == 1 ) 1165 { 1166 g_snprintf( s, sizeof( s ) - 1, "%s %s", bu->handle, bu->ic->acc->tag ); 1167 irc_rootmsg( irc, format, iu->nick, s, "Offline" ); 1168 } 1169 n_offline ++; 1174 1170 } 1175 1171 1176 1172 irc_rootmsg( irc, "%d buddies (%d available, %d away, %d offline)", n_online + n_away + n_offline, n_online, n_away, n_offline ); 1177 1178 if( regex )1179 g_regex_unref( regex );1180 1173 } 1181 1174 -
sock.h
r5cb21d1 rc180110 2 2 #include <fcntl.h> 3 3 4 #ifndef _WIN32 4 5 #include <unistd.h> 5 6 #include <sys/socket.h> … … 11 12 #define sockerr_again() (errno == EINPROGRESS || errno == EINTR) 12 13 void closesocket( int fd ); 14 #else 15 # include <winsock2.h> 16 # include <ws2tcpip.h> 17 # if !defined(BITLBEE_CORE) && defined(_MSC_VER) 18 # pragma comment(lib,"bitlbee.lib") 19 # endif 20 # include <io.h> 21 # define sock_make_nonblocking(fd) { int non_block = 1; ioctlsocket(fd, FIONBIO, &non_block); } 22 # define sock_make_blocking(fd) { int non_block = 0; ioctlsocket(fd, FIONBIO, &non_block); } 23 # define sockerr_again() (WSAGetLastError() == WSAEINTR || WSAGetLastError() == WSAEINPROGRESS || WSAGetLastError() == WSAEWOULDBLOCK) 24 # define ETIMEDOUT WSAETIMEDOUT 25 # define sleep(a) Sleep(a*1000) 26 #endif -
storage_xml.c
r5cb21d1 rc180110 87 87 char *pass_b64 = NULL; 88 88 unsigned char *pass_cr = NULL; 89 int pass_len , local = 0;89 int pass_len; 90 90 struct prpl *prpl = NULL; 91 91 account_t *acc; … … 100 100 protocol = xt_find_attr( node, "protocol" ); 101 101 if( protocol ) 102 {103 102 prpl = find_protocol( protocol ); 104 local = protocol_account_islocal( protocol );105 }106 103 107 104 if( !handle || !pass_b64 || !protocol || !prpl ) … … 117 114 if( tag ) 118 115 set_setstr( &acc->set, "tag", tag ); 119 if( local )120 acc->flags |= ACC_FLAG_LOCAL;121 116 } 122 117 else -
tests/check_jabber_util.c
r5cb21d1 rc180110 95 95 } 96 96 97 static void check_compareJID(int l)98 {99 fail_unless( jabber_compare_jid( "bugtest@google.com/B", "bugtest@google.com/A" ) );100 fail_if( jabber_compare_jid( "bugtest1@google.com/B", "bugtest@google.com/A" ) );101 fail_if( jabber_compare_jid( "bugtest@google.com/B", "bugtest1@google.com/A" ) );102 fail_if( jabber_compare_jid( "bugtest1@google.com/B", "bugtest2@google.com/A" ) );103 fail_unless( jabber_compare_jid( "bugtest@google.com/A", "bugtest@google.com/A" ) );104 fail_if( jabber_compare_jid( "", "bugtest@google.com/A" ) );105 }106 107 97 Suite *jabber_util_suite (void) 108 98 { … … 120 110 suite_add_tcase (s, tc_core); 121 111 tcase_add_test (tc_core, check_buddy_add); 122 tcase_add_test (tc_core, check_compareJID);123 112 return s; 124 113 } -
tests/check_util.c
r5cb21d1 rc180110 169 169 END_TEST 170 170 171 struct {172 int limit;173 char *command;174 char *expected[IRC_MAX_ARGS+1];175 } split_tests[] = {176 {177 0, "account add etc \"user name with spaces\" 'pass\\ word'",178 {"account", "add", "etc", "user name with spaces", "pass\\ word", NULL},179 },180 {181 0, "channel set group Close\\ friends",182 {"channel", "set", "group", "Close friends", NULL},183 },184 {185 2, "reply wilmer \"testing in C is a PITA\", you said.",186 {"reply", "wilmer", "\"testing in C is a PITA\", you said.", NULL},187 },188 {189 4, "one space two spaces limit limit",190 {"one", "space", "two", "spaces", "limit limit", NULL},191 },192 {193 0, NULL,194 {NULL}195 },196 };197 198 START_TEST(test_split_command_parts)199 int i;200 for (i = 0; split_tests[i].command; i++) {201 char *cmd = g_strdup(split_tests[i].command);202 char **split = split_command_parts(cmd, split_tests[i].limit);203 char **expected = split_tests[i].expected;204 205 int j;206 for (j = 0; split[j] && expected[j]; j++) {207 fail_unless (strcmp(split[j], expected[j]) == 0,208 "(%d) split_command_parts broken: split(\"%s\")[%d] -> %s (expected: %s)",209 i, split_tests[i].command, j, split[j], expected[j]);210 }211 g_free(cmd);212 }213 END_TEST214 215 171 Suite *util_suite (void) 216 172 { … … 227 183 tcase_add_test (tc_core, test_word_wrap); 228 184 tcase_add_test (tc_core, test_http_encode); 229 tcase_add_test (tc_core, test_split_command_parts);230 185 return s; 231 186 } -
unix.c
r5cb21d1 rc180110 32 32 #include "help.h" 33 33 #include "ipc.h" 34 #include "lib/ssl_client.h" 34 35 #include "md5.h" 35 36 #include "misc.h" … … 81 82 #endif 82 83 84 /* Ugly Note: libotr and gnutls both use libgcrypt. libgcrypt 85 has a process-global config state whose initialization happpens 86 twice if libotr and gnutls are used together. libotr installs custom 87 memory management functions for libgcrypt while our gnutls module 88 uses the defaults. Therefore we initialize OTR after SSL. *sigh* */ 89 ssl_init(); 83 90 #ifdef OTR_BI 84 91 otr_init(); 85 92 #endif 93 /* And in case OTR is loaded as a plugin, it'll also get loaded after 94 this point. */ 86 95 87 96 srand( time( NULL ) ^ getpid() );
Note: See TracChangeset
for help on using the changeset viewer.