Changeset 632627e
- Timestamp:
- 2014-07-24T03:51:07Z (10 years ago)
- Branches:
- master
- Children:
- f93fd2d
- Parents:
- 59e66ff
- git-author:
- jcopenha <jcopenha@…> (24-07-14 03:51:07)
- git-committer:
- dequis <dx@…> (24-07-14 03:51:07)
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
configure
r59e66ff r632627e 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 ns_initparse( NULL, 0, NULL ); 372 ns_parserr( NULL, ns_s_an, 0, NULL ); 373 } 374 ' 347 375 348 376 detect_resolv_dynamic() 349 377 { 350 378 case "$arch" in 379 OpenBSD ) 380 # In FreeBSD res_*/dn_* routines are present in libc.so 381 LIBRESOLV=;; 351 382 FreeBSD ) 352 # In FreeBSD res_* routines are present in libc.so 383 # In FreeBSD res_*/dn_* routines are present in libc.so 384 LIBRESOLV=;; 385 CYGWIN* ) 386 # In Cygwin res_*/dn_* routines are present in libc.so 353 387 LIBRESOLV=;; 354 388 * ) … … 385 419 } 386 420 421 detect_resolv_ns_dynamic() 422 { 423 case "$arch" in 424 FreeBSD ) 425 # In FreeBSD ns_ routines are present in libc.so 426 LIBRESOLV=;; 427 * ) 428 LIBRESOLV=-lresolv;; 429 esac 430 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) 431 ret=1 432 echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - $LIBRESOLV >/dev/null 2>/dev/null 433 if [ "$?" = "0" ]; then 434 ret=0 435 fi 436 437 rm -f $TMPFILE 438 return $ret 439 } 440 441 detect_resolv_ns_static() 442 { 443 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) 444 ret=1 445 for i in $systemlibdirs; do 446 if [ -f $i/libresolv.a ]; then 447 echo "$RESOLV_NS_TESTCODE" | $CC -o $TMPFILE -x c - -Wl,$i/libresolv.a >/dev/null 2>/dev/null 448 if [ "$?" = "0" ]; then 449 ret=0 450 fi 451 fi 452 done 453 454 rm -f $TMPFILE 455 return $ret 456 } 457 458 detect_nameser_has_ns_types() 459 { 460 TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX) 461 case "$arch" in 462 FreeBSD ) 463 # In FreeBSD ns_ routines are present in libc.so 464 LIBRESOLV=;; 465 * ) 466 LIBRESOLV=-lresolv;; 467 esac 468 ret=1 469 if detect_resolv_ns_dynamic; then 470 echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c $LIBRESOLV - >/dev/null 2>/dev/null 471 if [ "$?" = "0" ]; then 472 ret=0 473 fi 474 elif detect_resolv_ns_static; then 475 for i in $systemlibdirs; do 476 if [ -f $i/libresolv.a ]; then 477 echo "$RESOLV_NS_TYPES_TESTCODE" | $CC -o $TMPFILE -x c - >/dev/null 2>/dev/null 478 if [ "$?" = "0" ]; then 479 ret=0 480 fi 481 fi 482 done 483 fi 484 485 rm -f $TMPFILE 486 return $ret 487 } 488 387 489 if [ "$ssl" = "auto" ]; then 388 490 detect_gnutls … … 440 542 echo 'SSL_CLIENT=ssl_'$ssl'.o' >> Makefile.settings 441 543 544 if detect_nameser_has_ns_types; then 545 echo '#define NAMESER_HAS_NS_TYPES' >> config.h 546 fi 442 547 if detect_resolv_dynamic || detect_resolv_static; then 443 548 echo '#define HAVE_RESOLV_A' >> config.h 444 fi 549 if detect_resolv_ns_dynamic || detect_resolv_ns_static; then 550 echo '#define HAVE_RESOLV_A_WITH_NS' >> config.h 551 fi 552 else 553 echo 'Insufficient resolv routines. Jabber server must be set explicitly' 554 fi 555 445 556 446 557 STORAGES="xml" -
lib/Makefile
r59e66ff r632627e 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/misc.c
r59e66ff r632627e 525 525 ns_msg nsh; 526 526 ns_rr rr; 527 int i,n, len, size;527 int n, len, size; 528 528 529 529 g_snprintf( name, sizeof( name ), "_%s._%s.%s", service, protocol, domain ); … … 538 538 while( ns_parserr( &nsh, ns_s_an, n, &rr ) == 0 ) 539 539 { 540 size = ns_rr_rdlen( rr ); 540 char name[NS_MAXDNAME]; 541 542 if( ns_rr_rdlen( rr ) < 7) 543 break; 544 541 545 buf = ns_rr_rdata( rr ); 542 546 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 ) 547 if( dn_expand(querybuf, querybuf + size, &buf[6], name, NS_MAXDNAME) == -1 ) 548 548 break; 549 550 len = strlen(name) + 1; 549 551 550 552 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 } 553 memcpy( reply->name, name, len ); 561 554 562 555 reply->prio = ( buf[0] << 8 ) | buf[1]; -
lib/misc.h
r59e66ff r632627e 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 );
Note: See TracChangeset
for help on using the changeset viewer.