Changes in / [c180110:5cb21d1]
- Files:
-
- 1 added
- 3 deleted
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
rc180110 r5cb21d1 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) 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.h12 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.o 13 headers = $(wildcard $(_SRCDIR_)*.h $(_SRCDIR_)lib/*.h $(_SRCDIR_)protocols/*.h) 14 14 subdirs = lib protocols 15 15 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 16 OUTFILE = bitlbee 25 17 26 18 # Expansion of variables … … 102 94 mkdir -p $(DESTDIR)$(INCLUDEDIR) 103 95 $(INSTALL) -m 0644 config.h $(DESTDIR)$(INCLUDEDIR) 104 for i in $(headers); do $(INSTALL) -m 0644 $ (_SRCDIR_)$$i $(DESTDIR)$(INCLUDEDIR); done96 for i in $(headers); do $(INSTALL) -m 0644 $$i $(DESTDIR)$(INCLUDEDIR); done 105 97 mkdir -p $(DESTDIR)$(PCDIR) 106 98 $(INSTALL) -m 0644 bitlbee.pc $(DESTDIR)$(PCDIR) … … 149 141 install-systemd: systemd 150 142 ifdef SYSTEMDSYSTEMUNITDIR 151 ifeq ($(shell id -u),0)152 143 mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) 153 144 $(INSTALL) -m 0644 init/bitlbee.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) … … 155 146 $(INSTALL) -m 0644 $(_SRCDIR_)init/bitlbee.socket $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) 156 147 else 157 @echo Not root, so not installing systemd files. 158 endif 148 @echo SYSTEMDSYSTEMUNITDIR not set, not installing systemd unit files. 159 149 endif 160 150 -
bitlbee.c
rc180110 r5cb21d1 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 _WIN32130 129 if( !global.conf->nofork ) 131 130 { … … 151 150 } 152 151 } 153 #endif154 152 155 153 if( global.conf->runmode == RUNMODE_FORKDAEMON ) … … 159 157 ipc_master_listen_socket(); 160 158 161 #ifndef _WIN32162 159 if( ( fp = fopen( global.conf->pidfile, "w" ) ) ) 163 160 { … … 169 166 log_message( LOGLVL_WARNING, "Warning: Couldn't write PID to `%s'", global.conf->pidfile ); 170 167 } 171 #endif172 168 173 169 if( !global.conf->nofork ) … … 295 291 } 296 292 297 #ifndef _WIN32298 293 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 299 294 { … … 357 352 } 358 353 else 359 #endif360 354 { 361 355 log_message( LOGLVL_INFO, "Creating new connection with fd %d.", new_socket ); -
bitlbee.h
rc180110 r5cb21d1 35 35 #endif 36 36 37 /* Depend on Windows 2000 for now since we need getaddrinfo() */38 #define _WIN32_WINNT 0x050139 40 37 #define PACKAGE "BitlBee" 41 38 #define BITLBEE_VERSION "3.2.2" … … 60 57 #include <ctype.h> 61 58 #include <errno.h> 62 63 #ifndef _WIN3264 59 #include <syslog.h> 65 #endif66 67 60 #include <glib.h> 68 61 #include <gmodule.h> -
configure
rc180110 r5cb21d1 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 { 343 357 ns_initparse( NULL, 0, NULL ); 344 358 ns_parserr( NULL, ns_s_an, 0, NULL ); 345 359 } 346 360 ' 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 have 372 ns_* routines, so use this to make sure 373 the compiler uses it.*/ 374 return (int)(sizeof(nsh) + sizeof(rr)); 375 } 376 ' 347 377 348 378 detect_resolv_dynamic() 349 379 { 350 380 case "$arch" in 381 OpenBSD ) 382 # In FreeBSD res_*/dn_* routines are present in libc.so 383 LIBRESOLV=;; 351 384 FreeBSD ) 352 # In FreeBSD res_* routines are present in libc.so 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 353 389 LIBRESOLV=;; 354 390 * ) … … 385 421 } 386 422 423 detect_resolv_ns_dynamic() 424 { 425 case "$arch" in 426 FreeBSD ) 427 # In FreeBSD ns_ routines are present in libc.so 428 LIBRESOLV=;; 429 * ) 430 LIBRESOLV=-lresolv;; 431 esac 432 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) 433 ret=1 434 echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null 435 if [ "$?" = "0" ]; then 436 ret=0 437 fi 438 439 rm -f $TMPFILE 440 return $ret 441 } 442 443 detect_resolv_ns_static() 444 { 445 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) 446 ret=1 447 for i in $systemlibdirs; do 448 if [ -f $i/libresolv.a ]; then 449 echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null 450 if [ "$?" = "0" ]; then 451 ret=0 452 fi 453 fi 454 done 455 456 rm -f $TMPFILE 457 return $ret 458 } 459 460 detect_nameser_has_ns_types() 461 { 462 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) 463 ret=1 464 # since we aren't actually linking with ns_* routines 465 # we can just compile the test code 466 echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c - >/dev/null 2>/dev/null 467 if [ "$?" = "0" ]; then 468 ret=0 469 fi 470 471 rm -f $TMPFILE 472 return $ret 473 } 474 387 475 if [ "$ssl" = "auto" ]; then 388 476 detect_gnutls … … 396 484 elif [ "$ssl" = "nss" ]; then 397 485 detect_nss 398 elif [ "$ssl" = "sspi" ]; then399 echo400 486 elif [ "$ssl" = "openssl" ]; then 401 487 echo … … 440 526 echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings 441 527 528 if detect_nameser_has_ns_types; then 529 echo '#define NAMESER_HAS_NS_TYPES' >> config.h 530 fi 442 531 if detect_resolv_dynamic || detect_resolv_static; then 443 532 echo '#define HAVE_RESOLV_A' >> config.h 444 fi 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 445 540 446 541 STORAGES="xml" … … 511 606 # BI == built-in 512 607 echo '#define OTR_BI' >> config.h 513 echo "EFLAGS+=-L${otrprefix}/lib -lotr " >> Makefile.settings608 echo "EFLAGS+=-L${otrprefix}/lib -lotr -lgcrypt" >> Makefile.settings 514 609 echo "CFLAGS+=-I${otrprefix}/include" >> Makefile.settings 515 610 echo 'OTR_BI=otr.o' >> Makefile.settings … … 709 804 ;; 710 805 CYGWIN* ) 711 echo 'Cygwin is not officially supported.'712 806 ;; 713 807 Windows ) 808 echo 'Native windows compilation is not supported anymore, use cygwin instead.' 714 809 ;; 715 810 * ) -
debian/rules
rc180110 r5cb21d1 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 36 42 build: build-stamp 37 43 build-stamp: … … 39 45 40 46 mkdir -p debian/build-native 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)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) 42 48 $(MAKE) -C debian/build-native 43 49 44 50 ifeq ($(BITLBEE_LIBPURPLE),1) 45 51 mkdir -p debian/build-libpurple 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)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) 47 53 $(MAKE) -C debian/build-libpurple 48 54 endif -
doc/user-guide/Makefile
rc180110 r5cb21d1 17 17 18 18 %.html: %.db.xml 19 xsltproc -- output $@ http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl $<19 xsltproc --param generate.consistent.ids 1 --output $@ http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl $< 20 20 21 21 %.pdf: %.db.xml -
doc/user-guide/commands.xml
rc180110 r5cb21d1 1790 1790 1791 1791 <bitlbee-command name="blist"> 1792 <syntax>blist [all|online|offline|away] </syntax>1792 <syntax>blist [all|online|offline|away] [<pattern>]</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). 1798 1802 </para> 1799 1803 </description> -
help.c
rc180110 r5cb21d1 42 42 *help = h = g_new0 ( help_t, 1 ); 43 43 44 h->fd = open( helpfile, O_RDONLY 45 #ifdef _WIN32 46 | O_BINARY 47 #endif 48 ); 44 h->fd = open( helpfile, O_RDONLY ); 49 45 50 46 if( h->fd == -1 ) -
ipc.c
rc180110 r5cb21d1 28 28 #include "ipc.h" 29 29 #include "commands.h" 30 #ifndef _WIN3231 30 #include <sys/uio.h> 32 31 #include <sys/un.h> 33 #endif34 32 35 33 GSList *child_list = NULL; … … 843 841 } 844 842 845 #ifndef _WIN32846 843 char *ipc_master_save_state() 847 844 { … … 942 939 return 1; 943 940 } 944 #else945 int ipc_master_listen_socket()946 {947 /* FIXME: Open named pipe \\.\BITLBEE */948 return 0;949 }950 #endif951 941 952 942 int ipc_master_load_state( char *statefile ) -
irc.c
rc180110 r5cb21d1 27 27 #include "ipc.h" 28 28 #include "dcc.h" 29 #include "lib/ssl_client.h" 29 30 30 31 GSList *irc_connection_list; … … 171 172 nogaim_init(); 172 173 #endif 174 175 /* SSL library initialization also should be done after the fork, to 176 avoid shared CSPRNG state. This is required by NSS, which refuses to 177 work if a fork is detected */ 178 ssl_init(); 173 179 174 180 for( l = irc_plugins; l; l = l->next ) -
irc_commands.c
rc180110 r5cb21d1 365 365 cmd[2][strlen(cmd[2])-1] = '\0'; 366 366 367 ctcp = split_command_parts( cmd[2] + 1 );367 ctcp = split_command_parts( cmd[2] + 1, 0 ); 368 368 iu->f->ctcp( iu, ctcp ); 369 369 } -
irc_im.c
rc180110 r5cb21d1 637 637 irc_send_msg( iu, "PRIVMSG", ic->name, wrapped, ts ); 638 638 g_free( ts ); 639 g_free( wrapped ); 639 640 640 641 return TRUE; -
lib/Makefile
rc180110 r5cb21d1 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 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.o 16 16 17 17 LFLAGS += -r -
lib/events.h
rc180110 r5cb21d1 37 37 38 38 #include <sys/types.h> 39 #ifndef _WIN3240 39 #include <sys/socket.h> 41 40 #include <netdb.h> 42 41 #include <netinet/in.h> 43 #endif44 42 #include <glib.h> 45 43 #include <gmodule.h> -
lib/events_glib.c
rc180110 r5cb21d1 31 31 #include <string.h> 32 32 #include <sys/types.h> 33 #ifndef _WIN3234 33 #include <sys/socket.h> 35 34 #include <netdb.h> … … 37 36 #include <arpa/inet.h> 38 37 #include <unistd.h> 39 #else40 #include "sock.h"41 #define ETIMEDOUT WSAETIMEDOUT42 #define EINPROGRESS WSAEINPROGRESS43 #endif44 38 #include <fcntl.h> 45 39 #include <errno.h> -
lib/http_client.c
rc180110 r5cb21d1 292 292 293 293 cleanup: 294 /* Avoid g_source_remove warnings */ 295 req->inpa = 0; 296 294 297 if( req->ssl ) 295 298 ssl_disconnect( req->ssl ); -
lib/misc.c
rc180110 r5cb21d1 420 420 void random_bytes( unsigned char *buf, int count ) 421 421 { 422 #ifndef _WIN32423 422 static int use_dev = -1; 424 423 … … 470 469 471 470 if( !use_dev ) 472 #endif473 471 { 474 472 int i; … … 525 523 ns_msg nsh; 526 524 ns_rr rr; 527 int i,n, len, size;525 int n, len, size; 528 526 529 527 g_snprintf( name, sizeof( name ), "_%s._%s.%s", service, protocol, domain ); … … 538 536 while( ns_parserr( &nsh, ns_s_an, n, &rr ) == 0 ) 539 537 { 540 size = ns_rr_rdlen( rr ); 538 char name[NS_MAXDNAME]; 539 540 if( ns_rr_rdlen( rr ) < 7) 541 break; 542 541 543 buf = ns_rr_rdata( rr ); 542 544 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 ) 545 if( dn_expand(querybuf, querybuf + size, &buf[6], name, NS_MAXDNAME) == -1 ) 548 546 break; 547 548 len = strlen(name) + 1; 549 549 550 550 reply = g_malloc( sizeof( struct ns_srv_reply ) + 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 } 551 memcpy( reply->name, name, len ); 561 552 562 553 reply->prio = ( buf[0] << 8 ) | buf[1]; … … 682 673 white\ space in 'various ways'. Returns a NULL-terminated static 683 674 char** so watch out with nested use! Definitely not thread-safe. */ 684 char **split_command_parts( char *command )675 char **split_command_parts( char *command, int limit ) 685 676 { 686 677 static char *cmd[IRC_MAX_ARGS+1]; … … 692 683 k = 1; 693 684 for( s = command; *s && k < IRC_MAX_ARGS; s ++ ) 685 { 694 686 if( *s == ' ' && !q ) 695 687 { 696 688 *s = 0; 697 689 while( *++s == ' ' ); 698 if( *s == '"' || *s == '\'')690 if( k != limit && (*s == '"' || *s == '\'') ) 699 691 { 700 692 q = *s; … … 704 696 { 705 697 cmd[k++] = s; 698 if (limit && k > limit) { 699 break; 700 } 706 701 s --; 707 702 } … … 722 717 q = *s = 0; 723 718 } 719 } 724 720 725 721 /* Full zero-padding for easier argc checking. */ -
lib/misc.h
rc180110 r5cb21d1 38 38 }; 39 39 40 #ifndef NAMESER_HAS_NS_TYPES 41 42 #define NS_MAXDNAME 1025 43 #define NS_INT16SZ 2 44 #define NS_INT32SZ 4 45 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 =4 87 } ns_sect; 88 89 typedef struct __ns_msg 90 { 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 = 65536 111 } ns_class; 112 113 114 /* TODO : fill out the rest */ 115 typedef enum __ns_type { 116 ns_t_srv = 33 117 } ns_type; 118 119 #endif /* NAMESER_HAS_NS_INITPARSE */ 120 40 121 G_MODULE_EXPORT void strip_linefeed( gchar *text ); 41 122 G_MODULE_EXPORT char *add_cr( char *text ); … … 67 148 G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl ); 68 149 G_MODULE_EXPORT int md5_verify_password( char *password, char *hash ); 69 G_MODULE_EXPORT char **split_command_parts( char *command );150 G_MODULE_EXPORT char **split_command_parts( char *command, int limit ); 70 151 G_MODULE_EXPORT char *get_rfc822_header( const char *text, const char *header, int len ); 71 152 -
lib/proxy.c
rc180110 r5cb21d1 26 26 #include <string.h> 27 27 #include <sys/types.h> 28 #ifndef _WIN3229 28 #include <sys/socket.h> 30 29 #include <netdb.h> … … 32 31 #include <arpa/inet.h> 33 32 #include <unistd.h> 34 #else35 #include "sock.h"36 #define ETIMEDOUT WSAETIMEDOUT37 #define EINPROGRESS WSAEINPROGRESS38 #endif39 33 #include <fcntl.h> 40 34 #include <errno.h> … … 76 70 len = sizeof(error); 77 71 78 #ifndef _WIN3279 72 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0 || error) { 80 73 if ((phb->gai_cur = phb->gai_cur->ai_next)) { … … 101 94 return FALSE; 102 95 } 103 #endif104 96 freeaddrinfo(phb->gai); 105 97 sock_make_blocking(source); -
lib/proxy.h
rc180110 r5cb21d1 28 28 29 29 #include <sys/types.h> 30 #ifndef _WIN3231 30 #include <sys/socket.h> 32 31 #include <netdb.h> 33 32 #include <netinet/in.h> 34 #endif35 33 #include <glib.h> 36 34 #include <gmodule.h> -
lib/ssl_gnutls.c
rc180110 r5cb21d1 236 236 static void ssl_cache_add( struct scd *conn ) 237 237 { 238 size_t data_size ;238 size_t data_size = 0; 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 337 340 if( ( st = gnutls_handshake( conn->session ) ) < 0 ) 338 341 { -
protocols/account.c
rc180110 r5cb21d1 27 27 #include "bitlbee.h" 28 28 #include "account.h" 29 30 static const char* account_protocols_local[] = { 31 "gg", NULL 32 }; 29 33 30 34 static char *set_eval_nick_source( set_t *set, char *value ); … … 347 351 void account_on( bee_t *bee, account_t *a ) 348 352 { 353 GHashTableIter nicks; 354 gpointer k, v; 355 349 356 if( a->ic ) 350 357 { … … 360 367 if( a->ic && !( a->ic->flags & ( OPT_SLOW_LOGIN | OPT_LOGGED_IN ) ) ) 361 368 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 } 362 378 } 363 379 … … 465 481 return a->auto_reconnect_delay; 466 482 } 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
rc180110 r5cb21d1 59 59 int account_reconnect_delay( account_t *a ); 60 60 61 int protocol_account_islocal( const char* protocol ); 62 61 63 typedef enum 62 64 { … … 70 72 ACC_FLAG_STATUS_MESSAGE = 0x02, /* Supports status messages (without being away). */ 71 73 ACC_FLAG_HANDLE_DOMAINS = 0x04, /* Contact handles need a domain portion. */ 74 ACC_FLAG_LOCAL = 0x08, /* Contact list is local. */ 72 75 } account_flag_t; 73 76 -
protocols/jabber/iq.c
rc180110 r5cb21d1 352 352 /* Server is crap, but this is no disaster. */ 353 353 } 354 else if( strncmp( jd->me, c->text, strlen( jd->me ) ) != 0 )354 else if( jabber_compare_jid( jd->me, c->text ) == 0 ) 355 355 { 356 356 s = strchr( c->text, '/' ); -
protocols/jabber/jabber.h
rc180110 r5cb21d1 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 ); 291 292 char *jabber_normalize( const char *orig ); 292 293 -
protocols/jabber/jabber_util.c
rc180110 r5cb21d1 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; 308 330 } 309 331 -
protocols/msn/soap.h
rc180110 r5cb21d1 36 36 #include <string.h> 37 37 #include <sys/types.h> 38 #ifndef _WIN3239 38 #include <sys/socket.h> 40 39 #include <netinet/in.h> 41 40 #include <arpa/inet.h> 42 41 #include <unistd.h> 43 #endif44 42 #include "nogaim.h" 45 43 -
protocols/oscar/rxqueue.c
rc180110 r5cb21d1 9 9 #include <aim.h> 10 10 11 #ifndef _WIN3212 11 #include <sys/socket.h> 13 #endif14 12 15 13 /* -
protocols/oscar/txqueue.c
rc180110 r5cb21d1 9 9 #include "im.h" 10 10 11 #ifndef _WIN3212 11 #include <sys/socket.h> 13 #endif14 12 15 13 /* -
protocols/twitter/twitter.c
rc180110 r5cb21d1 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", " 20", set_eval_int, acc);325 s = set_add(&acc->set, "show_old_mentions", "0", 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 );604 cmd = split_command_parts(cmds, 2); 605 605 606 606 if (cmd[0] == NULL) { … … 617 617 618 618 goto eof; 619 } else if (g_strcasecmp(cmd[0], "favourite") == 0 && cmd[1]) { 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]) { 620 622 if ((id = twitter_message_id_from_command_arg(ic, cmd[1], NULL))) { 621 623 twitter_favourite_tweet(ic, id); … … 662 664 goto eof; 663 665 } 664 message = new = g_strdup_printf("@%s %s", bu->handle, message + (cmd[2] - cmd[0]));666 message = new = g_strdup_printf("@%s %s", bu->handle, cmd[2]); 665 667 in_reply_to = id; 666 668 allow_post = TRUE; -
protocols/yahoo/libyahoo2.c
rc180110 r5cb21d1 48 48 */ 49 49 50 #ifndef _WIN3251 50 #include <unistd.h> 52 #endif53 51 #include <errno.h> 54 52 #include <stdio.h> -
protocols/yahoo/yahoo_httplib.c
rc180110 r5cb21d1 38 38 39 39 #include <errno.h> 40 #ifndef _WIN3241 40 #include <unistd.h> 42 #endif43 41 #include <ctype.h> 44 42 #include "yahoo2.h" -
protocols/yahoo/yahoo_util.h
rc180110 r5cb21d1 65 65 void y_strfreev(char **vector); 66 66 67 #ifndef _WIN3268 67 int strncasecmp(const char *s1, const char *s2, size_t n); 69 68 int strcasecmp(const char *s1, const char *s2); … … 73 72 int snprintf(char *str, size_t size, const char *format, ...); 74 73 int vsnprintf(char *str, size_t size, const char *format, va_list ap); 75 #endif76 74 77 75 #endif -
root_commands.c
rc180110 r5cb21d1 32 32 void root_command_string( irc_t *irc, char *command ) 33 33 { 34 root_command( irc, split_command_parts( command ) );34 root_command( irc, split_command_parts( command, 0 ) ); 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 ;1087 int online = 0, away = 0, offline = 0, ismatch = 0; 1088 1088 GSList *l; 1089 GRegex *regex = NULL; 1090 GError *error = NULL; 1089 1091 char s[256]; 1090 1092 char *format; … … 1102 1104 online = away = 1; 1103 1105 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 1104 1115 if( strchr( irc->umode, 'b' ) != NULL ) 1105 1116 format = "%s\t%s\t%s"; … … 1118 1129 bee_user_t *bu = iu->bu; 1119 1130 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 ) 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 ) ) ) 1122 1137 continue; 1123 1138 1124 if( online == 1 ) 1125 { 1126 char st[256] = "Online"; 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 } 1127 1151 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 ++; 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 } 1170 1174 } 1171 1175 1172 1176 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 ); 1173 1180 } 1174 1181 -
sock.h
rc180110 r5cb21d1 2 2 #include <fcntl.h> 3 3 4 #ifndef _WIN325 4 #include <unistd.h> 6 5 #include <sys/socket.h> … … 12 11 #define sockerr_again() (errno == EINPROGRESS || errno == EINTR) 13 12 void closesocket( int fd ); 14 #else15 # include <winsock2.h>16 # include <ws2tcpip.h>17 # if !defined(BITLBEE_CORE) && defined(_MSC_VER)18 # pragma comment(lib,"bitlbee.lib")19 # endif20 # 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 WSAETIMEDOUT25 # define sleep(a) Sleep(a*1000)26 #endif -
storage_xml.c
rc180110 r5cb21d1 87 87 char *pass_b64 = NULL; 88 88 unsigned char *pass_cr = NULL; 89 int pass_len ;89 int pass_len, local = 0; 90 90 struct prpl *prpl = NULL; 91 91 account_t *acc; … … 100 100 protocol = xt_find_attr( node, "protocol" ); 101 101 if( protocol ) 102 { 102 103 prpl = find_protocol( protocol ); 104 local = protocol_account_islocal( protocol ); 105 } 103 106 104 107 if( !handle || !pass_b64 || !protocol || !prpl ) … … 114 117 if( tag ) 115 118 set_setstr( &acc->set, "tag", tag ); 119 if( local ) 120 acc->flags |= ACC_FLAG_LOCAL; 116 121 } 117 122 else -
tests/check_jabber_util.c
rc180110 r5cb21d1 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 97 107 Suite *jabber_util_suite (void) 98 108 { … … 110 120 suite_add_tcase (s, tc_core); 111 121 tcase_add_test (tc_core, check_buddy_add); 122 tcase_add_test (tc_core, check_compareJID); 112 123 return s; 113 124 } -
tests/check_util.c
rc180110 r5cb21d1 167 167 http_encode( s ); 168 168 fail_unless( strcmp( s, "ee%C3%ABee%21%21..." ) == 0 ); 169 END_TEST 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 } 169 213 END_TEST 170 214 … … 183 227 tcase_add_test (tc_core, test_word_wrap); 184 228 tcase_add_test (tc_core, test_http_encode); 229 tcase_add_test (tc_core, test_split_command_parts); 185 230 return s; 186 231 } -
unix.c
rc180110 r5cb21d1 32 32 #include "help.h" 33 33 #include "ipc.h" 34 #include "lib/ssl_client.h"35 34 #include "md5.h" 36 35 #include "misc.h" … … 82 81 #endif 83 82 84 /* Ugly Note: libotr and gnutls both use libgcrypt. libgcrypt85 has a process-global config state whose initialization happpens86 twice if libotr and gnutls are used together. libotr installs custom87 memory management functions for libgcrypt while our gnutls module88 uses the defaults. Therefore we initialize OTR after SSL. *sigh* */89 ssl_init();90 83 #ifdef OTR_BI 91 84 otr_init(); 92 85 #endif 93 /* And in case OTR is loaded as a plugin, it'll also get loaded after94 this point. */95 86 96 87 srand( time( NULL ) ^ getpid() );
Note: See TracChangeset
for help on using the changeset viewer.