diff -Nur src/protocols/yahoo.old/dns.c src/protocols/yahoo/dns.c --- src/protocols/yahoo.old/dns.c 1970-01-01 08:00:00.000000000 +0800 +++ src/protocols/yahoo/dns.c 2006-08-18 09:52:02.000000000 +0800 @@ -0,0 +1,216 @@ +/* + * DNS Library + * + * Copyright (C) 1999 - 2005 Thorsten Lockert + * + * Written by Thorsten Lockert + * Funding provided by Troll Phone Networks AS + * + * Modified by William Emmanuel S. Yu + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + +/*! \file + * + * \brief DNS Support + * + * \author Thorsten Lockert + */ + +#include +#include +#include +#include +#include +#include + +#include "enum.h" + +#define MAX_SIZE 4096 + +typedef struct { + unsigned id :16; /* query identification number */ +#if __BYTE_ORDER == __BIG_ENDIAN + /* fields in third byte */ + unsigned qr: 1; /* response flag */ + unsigned opcode: 4; /* purpose of message */ + unsigned aa: 1; /* authoritive answer */ + unsigned tc: 1; /* truncated message */ + unsigned rd: 1; /* recursion desired */ + /* fields in fourth byte */ + unsigned ra: 1; /* recursion available */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ad: 1; /* authentic data from named */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned rcode :4; /* response code */ +#endif +#if __BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __PDP_ENDIAN + /* fields in third byte */ + unsigned rd :1; /* recursion desired */ + unsigned tc :1; /* truncated message */ + unsigned aa :1; /* authoritive answer */ + unsigned opcode :4; /* purpose of message */ + unsigned qr :1; /* response flag */ + /* fields in fourth byte */ + unsigned rcode :4; /* response code */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned ad: 1; /* authentic data from named */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ra :1; /* recursion available */ +#endif + /* remaining bytes */ + unsigned qdcount :16; /* number of question entries */ + unsigned ancount :16; /* number of answer entries */ + unsigned nscount :16; /* number of authority entries */ + unsigned arcount :16; /* number of resource entries */ +} dns_HEADER; + +struct dn_answer { + unsigned short rtype; + unsigned short class; + unsigned int ttl; + unsigned short size; +} __attribute__ ((__packed__)); + +static int skip_name(char *s, int len) +{ + int x = 0; + + while (x < len) { + if (*s == '\0') { + s++; + x++; + break; + } + if ((*s & 0xc0) == 0xc0) { + s += 2; + x += 2; + break; + } + x += *s + 1; + s += *s + 1; + } + if (x >= len) + return -1; + return x; +} + +/*--- dns_parse_answer: Parse DNS lookup result, call callback */ +static int dns_parse_answer(void *context, + int class, int type, char *answer, int len, + int (*callback)(void *context, char *answer, int len, char *fullanswer)) +{ + char *fullanswer = answer; + struct dn_answer *ans; + dns_HEADER *h; + int res; + int x; + + h = (dns_HEADER *)answer; + answer += sizeof(dns_HEADER); + len -= sizeof(dns_HEADER); + + for (x = 0; x < ntohs(h->qdcount); x++) { + if ((res = skip_name(answer, len)) < 0) { + ast_log(LOG_WARNING, "Couldn't skip over name\n"); + return -1; + } + answer += res + 4; /* Skip name and QCODE / QCLASS */ + len -= res + 4; + if (len < 0) { + ast_log(LOG_WARNING, "Strange query size\n"); + return -1; + } + } + + for (x = 0; x < ntohs(h->ancount); x++) { + if ((res = skip_name(answer, len)) < 0) { + ast_log(LOG_WARNING, "Failed skipping name\n"); + return -1; + } + answer += res; + len -= res; + ans = (struct dn_answer *)answer; + answer += sizeof(struct dn_answer); + len -= sizeof(struct dn_answer); + if (len < 0) { + ast_log(LOG_WARNING, "Strange result size\n"); + return -1; + } + if (len < 0) { + ast_log(LOG_WARNING, "Length exceeds frame\n"); + return -1; + } + + if (ntohs(ans->class) == class && ntohs(ans->rtype) == type) { + if (callback) { + if ((res = callback(context, answer, ntohs(ans->size), fullanswer)) < 0) { + ast_log(LOG_WARNING, "Failed to parse result\n"); + return -1; + } + if (res > 0) + return 1; + } + } + answer += ntohs(ans->size); + len -= ntohs(ans->size); + } + return 0; +} + +#if defined(res_ninit) +#define HAS_RES_NINIT +#else +AST_MUTEX_DEFINE_STATIC(res_lock); +#if 0 +#warning "Warning, res_ninit is missing... Could have reentrancy issues" +#endif +#endif + +/*--- ast_search_dns: Lookup record in DNS */ +int ast_search_dns(void *context, + const char *dname, int class, int type, + int (*callback)(void *context, char *answer, int len, char *fullanswer)) +{ +#ifdef HAS_RES_NINIT + struct __res_state dnsstate; +#endif + char answer[MAX_SIZE]; + int res, ret = -1; + +#ifdef HAS_RES_NINIT +#ifdef MAKE_VALGRIND_HAPPY + memset(&dnsstate, 0, sizeof(dnsstate)); +#endif + res_ninit(&dnsstate); + res = res_nsearch(&dnsstate, dname, class, type, (unsigned char *)answer, sizeof(answer)); +#else + ast_mutex_lock(&res_lock); + res_init(); + res = res_search(dname, class, type, answer, sizeof(answer)); +#endif + if (res > 0) { + if ((res = dns_parse_answer(context, class, type, answer, res, callback)) < 0) { + ast_log(LOG_WARNING, "DNS Parse error for %s\n", dname); + ret = -1; + } + else if (ret == 0) { + ast_log(LOG_DEBUG, "No matches found in DNS for %s\n", dname); + ret = 0; + } + else + ret = 1; + } +#ifdef HAS_RES_NINIT + res_nclose(&dnsstate); +#else +#ifndef __APPLE__ + res_close(); +#endif + ast_mutex_unlock(&res_lock); +#endif + return ret; +} diff -Nur src/protocols/yahoo.old/enum.c src/protocols/yahoo/enum.c --- src/protocols/yahoo.old/enum.c 1970-01-01 08:00:00.000000000 +0800 +++ src/protocols/yahoo/enum.c 2006-08-18 09:51:59.000000000 +0800 @@ -0,0 +1,611 @@ +/* + * Asterisk -- An open source telephony toolkit. + * + * Copyright (C) 1999 - 2005, Digium, Inc. + * + * Mark Spencer + * + * Funding provided by nic.at + * + * Modified by William Emmanuel S. Yu + * + * See http://www.asterisk.org for more information about + * the Asterisk project. Please do not directly contact + * any of the maintainers of this project for assistance; + * the project provides a web site, mailing lists and IRC + * channels for your use. + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + +/*! \file + * + * \brief ENUM Support for Asterisk + * + */ + +#include +#include +#include +#include +#if __APPLE_CC__ >= 1495 +#include +#endif +#include +#include +#include +#include +#include +#include +#include + +#include "enum.h" + +#ifdef __APPLE__ +#undef T_NAPTR +#define T_NAPTR 35 +#endif + +#ifdef __APPLE__ +#undef T_TXT +#define T_TXT 16 +#endif + +/* The IETF Enum standard root, managed by the ITU */ +#define TOPLEV "e164.arpa." + +/* Linked list from config file */ +static struct enum_search { + char toplev[512]; + struct enum_search *next; +} *toplevs; + +static int enumver = 0; + +struct naptr { + unsigned short order; + unsigned short pref; +} __attribute__ ((__packed__)); + +/*--- parse_ie: Parse NAPTR record information elements */ +static unsigned int parse_ie(unsigned char *data, unsigned int maxdatalen, unsigned char *src, unsigned int srclen) +{ + unsigned int len, olen; + + len = olen = (unsigned int) src[0]; + src++; + srclen--; + + if (len > srclen) { + ast_log(LOG_WARNING, "ENUM parsing failed: Wanted %d characters, got %d\n", len, srclen); + return -1; + } + + if (len > maxdatalen) + len = maxdatalen; + memcpy(data, src, len); + + return olen + 1; +} + +/*--- parse_naptr: Parse DNS NAPTR record used in ENUM ---*/ +static int parse_naptr(unsigned char *dst, int dstsize, char *tech, int techsize, unsigned char *answer, int len, unsigned char *naptrinput) +{ + char tech_return[80]; + char *oanswer = (char *) answer; + char flags[512] = ""; + char services[512] = ""; + char *p; + char regexp[512] = ""; + char repl[512] = ""; + char temp[512] = ""; + char delim; + char *delim2; + char *pattern, *subst, *d; + int res; + int regexp_len, size, backref; + int d_len = sizeof(temp) - 1; + regex_t preg; + regmatch_t pmatch[9]; + + tech_return[0] = '\0'; + + dst[0] = '\0'; + + if (len < sizeof(struct naptr)) { + ast_log(LOG_WARNING, "NAPTR record length too short\n"); + return -1; + } + answer += sizeof(struct naptr); + len -= sizeof(struct naptr); + if ((res = parse_ie((unsigned char *)flags, sizeof(flags) - 1, answer, len)) < 0) { + ast_log(LOG_WARNING, "Failed to get flags from NAPTR record\n"); + return -1; + } else { + answer += res; + len -= res; + } + if ((res = parse_ie((unsigned char *)services, sizeof(services) - 1, answer, len)) < 0) { + ast_log(LOG_WARNING, "Failed to get services from NAPTR record\n"); + return -1; + } else { + answer += res; + len -= res; + } + if ((res = parse_ie((unsigned char *)regexp, sizeof(regexp) - 1, answer, len)) < 0) { + ast_log(LOG_WARNING, "Failed to get regexp from NAPTR record\n"); + return -1; + } else { + answer += res; + len -= res; + } + + if ((res = dn_expand((unsigned char *)oanswer, (unsigned char *)answer + len, (unsigned char *)answer, repl, sizeof(repl) - 1)) < 0) { + ast_log(LOG_WARNING, "Failed to expand hostname\n"); + return -1; + } + + if (tolower(flags[0]) != 'u') { + ast_log(LOG_WARNING, "NAPTR Flag must be 'U' or 'u'.\n"); + return -1; + } + + p = strstr(services, "e2u+"); + if (p == NULL) + p = strstr(services, "E2U+"); + if (p){ + p = p + 4; + if (strchr(p, ':')){ + p = strchr(p, ':') + 1; + } + ast_copy_string(tech_return, p, sizeof(tech_return)); + } else { + + p = strstr(services, "+e2u"); + if (p == NULL) + p = strstr(services, "+E2U"); + if (p) { + *p = 0; + p = strchr(services, ':'); + if (p) + *p = 0; + ast_copy_string(tech_return, services, sizeof(tech_return)); + } + } + + /* DEDBUGGING STUB + ast_copy_string(regexp, "!^\\+43(.*)$!\\1@bla.fasel!", sizeof(regexp) - 1); + */ + + regexp_len = strlen(regexp); + if (regexp_len < 7) { + ast_log(LOG_WARNING, "Regex too short to be meaningful.\n"); + return -1; + } + + + delim = regexp[0]; + delim2 = strchr(regexp + 1, delim); + if ((delim2 == NULL) || (regexp[regexp_len-1] != delim)) { + ast_log(LOG_WARNING, "Regex delimiter error (on \"%s\").\n",regexp); + return -1; + } + + pattern = regexp + 1; + *delim2 = 0; + subst = delim2 + 1; + regexp[regexp_len-1] = 0; + +/* + * now do the regex wizardry. + */ + + if (regcomp(&preg, pattern, REG_EXTENDED | REG_NEWLINE)) { + ast_log(LOG_WARNING, "NAPTR Regex compilation error (regex = \"%s\").\n",regexp); + return -1; + } + + if (preg.re_nsub > 9) { + ast_log(LOG_WARNING, "NAPTR Regex compilation error: too many subs.\n"); + regfree(&preg); + return -1; + } + + if (regexec(&preg, (char *) naptrinput, 9, pmatch, 0)) { + ast_log(LOG_WARNING, "NAPTR Regex match failed.\n"); + regfree(&preg); + return -1; + } + regfree(&preg); + + d = temp; + d_len--; + while (*subst && (d_len > 0)) { + if ((subst[0] == '\\') && isdigit(subst[1]) && (pmatch[subst[1]-'0'].rm_so != -1)) { + backref = subst[1]-'0'; + size = pmatch[backref].rm_eo - pmatch[backref].rm_so; + if (size > d_len) { + ast_log(LOG_WARNING, "Not enough space during NAPTR regex substitution.\n"); + return -1; + } + memcpy(d, naptrinput + pmatch[backref].rm_so, size); + d += size; + d_len -= size; + subst += 2; + } else if (isprint(*subst)) { + *d++ = *subst++; + d_len--; + } else { + ast_log(LOG_WARNING, "Error during regex substitution.\n"); + return -1; + } + } + *d = 0; + ast_copy_string((char *)dst, temp, dstsize); + dst[dstsize - 1] = '\0'; + + if (*tech != '\0'){ /* check if it is requested NAPTR */ + if (!strncasecmp(tech, "ALL", techsize)){ + return 1; /* return or count any RR */ + } + if (!strncasecmp(tech_return, tech, sizeof(tech_return)txt = NULL; + c->txtlen = 0; + return 0; + } + + /* skip over first byte, as for some reason it's a vertical tab character */ + answer += 1; + len -= 1; + + /* answer is not null-terminated, but should be */ + /* this is safe to do, as answer has extra bytes on the end we can + safely overwrite with a null */ + answer[len] = '\0'; + /* now increment len so that len includes the null, so that we can + compare apples to apples */ + len +=1; + + /* finally, copy the answer into c->txt */ + ast_copy_string(c->txt, answer, len < c->txtlen ? len : (c->txtlen)); + + /* just to be safe, let's make sure c->txt is null terminated */ + c->txt[(c->txtlen)-1] = '\0'; + + return 1; +} + +/*--- enum_callback: Callback from ENUM lookup function */ +static int enum_callback(void *context, char *answer, int len, char *fullanswer) +{ + struct enum_context *c = (struct enum_context *)context; + void *p = NULL; + int res; + + res = parse_naptr((unsigned char *) c->dst, c->dstlen, c->tech, c->techlen, (unsigned char *)answer, len, (unsigned char *)c->naptrinput); + + if (res < 0) { + ast_log(LOG_WARNING, "Failed to parse naptr :(\n"); + return -1; + } else if (res > 0 && !ast_strlen_zero(c->dst)){ /* ok, we got needed NAPTR */ + if (c->options & ENUMLOOKUP_OPTIONS_COUNT){ /* counting RRs */ + c->position++; + snprintf(c->dst, c->dstlen, "%d", c->position); + } else { + p = realloc(c->naptr_rrs, sizeof(struct enum_naptr_rr)*(c->naptr_rrs_count+1)); + if (p) { + c->naptr_rrs = (struct enum_naptr_rr*)p; + memcpy(&c->naptr_rrs[c->naptr_rrs_count].naptr, answer, sizeof(struct naptr)); + c->naptr_rrs[c->naptr_rrs_count].result = strdup(c->dst); + c->naptr_rrs[c->naptr_rrs_count].tech = strdup(c->tech); + c->naptr_rrs[c->naptr_rrs_count].sort_pos = c->naptr_rrs_count; + c->naptr_rrs_count++; + } + c->dst[0] = 0; + } + return 0; + } + + if (c->options & ENUMLOOKUP_OPTIONS_COUNT) { /* counting RRs */ + snprintf(c->dst, c->dstlen, "%d", c->position); + } + + return 0; +} + +/*--- ast_get_enum: ENUM lookup */ +int ast_get_enum(const char *number, char *dst, int dstlen, char *tech, int techlen, char* suffix, char* options) +{ + struct enum_context context; + char tmp[259 + 512]; + char naptrinput[512]; + int pos = strlen(number) - 1; + int newpos = 0; + int ret = -1; + struct enum_search *s = NULL; + int version = -1; + /* for ISN rewrite */ + char *p1 = NULL; + char *p2 = NULL; + int k = 0; + int i = 0; + int z = 0; + + if (number[0] == 'n') { + strncpy(naptrinput, number+1, sizeof(naptrinput)); + } else { + strncpy(naptrinput, number, sizeof(naptrinput)); + } + + context.naptrinput = naptrinput; /* The number */ + context.dst = dst; /* Return string */ + context.dstlen = dstlen; + context.tech = tech; + context.techlen = techlen; + context.options = 0; + context.position = 1; + context.naptr_rrs = NULL; + context.naptr_rrs_count = 0; + + if (options != NULL){ + if (*options == 'c'){ + context.options = ENUMLOOKUP_OPTIONS_COUNT; + context.position = 0; + } else { + context.position = atoi(options); + if (context.position < 1) + context.position = 1; + } + } + + if (pos > 128) + pos = 128; + + /* ISN rewrite */ + p1 = strchr(number, '*'); + + if (number[0] == 'n') { /* do not perform ISN rewrite ('n' is testing flag) */ + p1 = NULL; + k = 1; /* strip 'n' from number */ + } + + if (p1 != NULL) { + p2 = p1+1; + while (p1 > number){ + p1--; + tmp[newpos++] = *p1; + tmp[newpos++] = '.'; + } + if (*p2) { + while(*p2 && newpos < 128){ + tmp[newpos++] = *p2; + p2++; + } + tmp[newpos++] = '.'; + } + + } else { + while (pos >= k) { + if (isdigit(number[pos])) { + tmp[newpos++] = number[pos]; + tmp[newpos++] = '.'; + } + pos--; + } + } + +/* + if (chan && ast_autoservice_start(chan) < 0) + return -1; +*/ + for (;;) { + if (version != enumver) { + /* Ooh, a reload... */ + s = toplevs; + version = enumver; + } else { + s = s->next; + } + if (suffix != NULL) { + strncpy(tmp + newpos, suffix, sizeof(tmp) - newpos - 1); + } else if (s) { + strncpy(tmp + newpos, s->toplev, sizeof(tmp) - newpos - 1); + } + if (!s) + break; + ret = ast_search_dns(&context, tmp, C_IN, T_NAPTR, enum_callback); + if (ret > 0) + break; + if (suffix != NULL) + break; + } + if (ret < 0) { + ast_log(LOG_DEBUG, "No such number found: %s (%s)\n", tmp, strerror(errno)); + ret = 0; + } + + if (context.naptr_rrs_count >= context.position && ! (context.options & ENUMLOOKUP_OPTIONS_COUNT)) { + /* sort array by NAPTR order/preference */ + for (k=0; k context.naptr_rrs[i].sort_pos) + || (ntohs(context.naptr_rrs[k].naptr.order) > ntohs(context.naptr_rrs[i].naptr.order) + && context.naptr_rrs[k].sort_pos < context.naptr_rrs[i].sort_pos)){ + z = context.naptr_rrs[k].sort_pos; + context.naptr_rrs[k].sort_pos = context.naptr_rrs[i].sort_pos; + context.naptr_rrs[i].sort_pos = z; + continue; + } + if (ntohs(context.naptr_rrs[k].naptr.order) == ntohs(context.naptr_rrs[i].naptr.order)) { + if ((ntohs(context.naptr_rrs[k].naptr.pref) < ntohs(context.naptr_rrs[i].naptr.pref) + && context.naptr_rrs[k].sort_pos > context.naptr_rrs[i].sort_pos) + || (ntohs(context.naptr_rrs[k].naptr.pref) > ntohs(context.naptr_rrs[i].naptr.pref) + && context.naptr_rrs[k].sort_pos < context.naptr_rrs[i].sort_pos)){ + z = context.naptr_rrs[k].sort_pos; + context.naptr_rrs[k].sort_pos = context.naptr_rrs[i].sort_pos; + context.naptr_rrs[i].sort_pos = z; + } + } + } + } + for (k=0; k 128) + pos = 128; + while (pos >= 0) { + tmp[newpos++] = number[pos--]; + tmp[newpos++] = '.'; + } + +/* + if (chan && ast_autoservice_start(chan) < 0) + return -1; +*/ + for (;;) { + if (version != enumver) { + /* Ooh, a reload... */ + s = toplevs; + version = enumver; + } else { + s = s->next; + } + if (s) { + strncpy(tmp + newpos, s->toplev, sizeof(tmp) - newpos - 1); + } + if (!s) + break; + + ret = ast_search_dns(&context, tmp, C_IN, T_TXT, txt_callback); + if (ret > 0) + break; + } + if (ret < 0) { + ast_log(LOG_DEBUG, "No such number found: %s (%s)\n", tmp, strerror(errno)); + ret = 0; + } +/* + if (chan) + ret |= ast_autoservice_stop(chan); +*/ + return ret; +} + +/*--- enum_newtoplev: Add enum tree to linked list ---*/ +static struct enum_search *enum_newtoplev(char *s) +{ + struct enum_search *tmp; + + tmp = malloc(sizeof(struct enum_search)); + if (tmp) { + memset(tmp, 0, sizeof(struct enum_search)); + ast_copy_string(tmp->toplev, s, sizeof(tmp->toplev)); + } + return tmp; +} + +/*--- ast_enum_init: Initialize the ENUM support subsystem */ +int ast_enum_init(void) +{ + toplevs = enum_newtoplev(TOPLEV); + return 0; +} + +int ast_enum_reload(void) +{ + return ast_enum_init(); +} diff -Nur src/protocols/yahoo.old/enum.h src/protocols/yahoo/enum.h --- src/protocols/yahoo.old/enum.h 1970-01-01 08:00:00.000000000 +0800 +++ src/protocols/yahoo/enum.h 2006-08-18 09:51:59.000000000 +0800 @@ -0,0 +1,46 @@ +/* + * ENUM DNS Library - Taken from the Asterisk DNS and ENUM code + * + * Created by William Emmanuel S. Yu + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + +#ifndef _ENUM_H + +#if !defined __need_FILE && !defined __need___FILE +# define _ENUM_H 1 + +#include + +#define LOG_WARNING 3 +#define LOG_DEBUG 5 + +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) +#define __builtin_expect(exp, c) (exp) +#define force_inline inline +#else +#define force_inline inline __attribute__((always_inline)) +#endif + +#define ast_log(level, args ...) fprintf(stderr,args) +#define ast_copy_string(strA, strB, n) strncpy(strA,strB,n) + +static force_inline int ast_strlen_zero(const char *s) +{ + return (!s || (*s == '\0')); +} + +int ast_search_dns(void *context, + const char *dname, int class, int type, + int (*callback)(void *context, char *answer, int len, char *fullanswer)); +int ast_enum_init(void); +int ast_get_enum(const char *number, char *dst, int dstlen, + char *tech, int techlen, char* suffix, char* options); + +#endif /* included. */ + +#endif /* !_ENUM_H */ + diff -Nur src/protocols/yahoo.old/Makefile.am src/protocols/yahoo/Makefile.am --- src/protocols/yahoo.old/Makefile.am 2006-08-18 09:51:48.000000000 +0800 +++ src/protocols/yahoo/Makefile.am 2006-08-18 09:52:27.000000000 +0800 @@ -4,6 +4,8 @@ pkgdir = $(libdir)/gaim YAHOOSOURCES = \ + enum.c \ + dns.c \ crypt.c \ yahoo.h \ yahoo_auth.c \ --- src/protocols/yahoo.old/Makefile.in 2005-08-12 10:22:07.000000000 +0800 +++ src/protocols/yahoo/Makefile.in 2006-08-18 14:50:51.000000000 +0800 @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.9.5 from Makefile.am. +# Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -15,8 +15,6 @@ @SET_MAKE@ -SOURCES = $(libyahoo_a_SOURCES) $(libyahoo_la_SOURCES) - srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ @@ -54,15 +52,15 @@ ARFLAGS = cru libyahoo_a_AR = $(AR) $(ARFLAGS) libyahoo_a_LIBADD = -am__libyahoo_a_SOURCES_DIST = crypt.c yahoo.h yahoo_auth.c \ - yahoo_auth.h yahoochat.h yahoo.c yahoochat.c util.c \ - yahoo_filexfer.h yahoo_filexfer.c yahoo_friend.h \ +am__libyahoo_a_SOURCES_DIST = enum.c dns.c enum.h crypt.c yahoo.h \ + yahoo_auth.c yahoo_auth.h yahoochat.h yahoo.c yahoochat.c \ + util.c yahoo_filexfer.h yahoo_filexfer.c yahoo_friend.h \ yahoo_friend.c yahoo_picture.c yahoo_picture.h yahoo_profile.c \ ycht.c ycht.h -am__objects_1 = libyahoo_a-crypt.$(OBJEXT) \ - libyahoo_a-yahoo_auth.$(OBJEXT) libyahoo_a-yahoo.$(OBJEXT) \ - libyahoo_a-yahoochat.$(OBJEXT) libyahoo_a-util.$(OBJEXT) \ - libyahoo_a-yahoo_filexfer.$(OBJEXT) \ +am__objects_1 = libyahoo_a-enum.$(OBJEXT) libyahoo_a-dns.$(OBJEXT) \ + libyahoo_a-crypt.$(OBJEXT) libyahoo_a-yahoo_auth.$(OBJEXT) \ + libyahoo_a-yahoo.$(OBJEXT) libyahoo_a-yahoochat.$(OBJEXT) \ + libyahoo_a-util.$(OBJEXT) libyahoo_a-yahoo_filexfer.$(OBJEXT) \ libyahoo_a-yahoo_friend.$(OBJEXT) \ libyahoo_a-yahoo_picture.$(OBJEXT) \ libyahoo_a-yahoo_profile.$(OBJEXT) libyahoo_a-ycht.$(OBJEXT) @@ -78,14 +76,14 @@ pkgLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(pkg_LTLIBRARIES) libyahoo_la_LIBADD = -am__libyahoo_la_SOURCES_DIST = crypt.c yahoo.h yahoo_auth.c \ - yahoo_auth.h yahoochat.h yahoo.c yahoochat.c util.c \ - yahoo_filexfer.h yahoo_filexfer.c yahoo_friend.h \ +am__libyahoo_la_SOURCES_DIST = enum.c dns.c enum.h crypt.c yahoo.h \ + yahoo_auth.c yahoo_auth.h yahoochat.h yahoo.c yahoochat.c \ + util.c yahoo_filexfer.h yahoo_filexfer.c yahoo_friend.h \ yahoo_friend.c yahoo_picture.c yahoo_picture.h yahoo_profile.c \ ycht.c ycht.h -am__objects_2 = crypt.lo yahoo_auth.lo yahoo.lo yahoochat.lo util.lo \ - yahoo_filexfer.lo yahoo_friend.lo yahoo_picture.lo \ - yahoo_profile.lo ycht.lo +am__objects_2 = enum.lo dns.lo crypt.lo yahoo_auth.lo yahoo.lo \ + yahoochat.lo util.lo yahoo_filexfer.lo yahoo_friend.lo \ + yahoo_picture.lo yahoo_profile.lo ycht.lo @STATIC_YAHOO_FALSE@am_libyahoo_la_OBJECTS = $(am__objects_2) libyahoo_la_OBJECTS = $(am_libyahoo_la_OBJECTS) @STATIC_YAHOO_FALSE@am_libyahoo_la_rpath = -rpath $(pkgdir) @@ -107,7 +105,6 @@ CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ -ALLOCA = @ALLOCA@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ @@ -125,8 +122,6 @@ BINRELOC_LIBS = @BINRELOC_LIBS@ BUILD_GEVOLUTION_FALSE = @BUILD_GEVOLUTION_FALSE@ BUILD_GEVOLUTION_TRUE = @BUILD_GEVOLUTION_TRUE@ -BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ -CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -137,7 +132,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ -DATADIRNAME = @DATADIRNAME@ DEBUG_CFLAGS = @DEBUG_CFLAGS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ @@ -185,14 +179,10 @@ EXTERNAL_LIBZEPHYR_TRUE = @EXTERNAL_LIBZEPHYR_TRUE@ F77 = @F77@ FFLAGS = @FFLAGS@ -GENCAT = @GENCAT@ -GLIBC2 = @GLIBC2@ -GLIBC21 = @GLIBC21@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ -GMSGFMT = @GMSGFMT@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GOBJECT_QUERY = @GOBJECT_QUERY@ @@ -200,41 +190,24 @@ GTKSPELL_LIBS = @GTKSPELL_LIBS@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_LIBS = @GTK_LIBS@ -HAVE_ASPRINTF = @HAVE_ASPRINTF@ HAVE_DOXYGEN_FALSE = @HAVE_DOXYGEN_FALSE@ HAVE_DOXYGEN_TRUE = @HAVE_DOXYGEN_TRUE@ -HAVE_POSIX_PRINTF = @HAVE_POSIX_PRINTF@ -HAVE_SNPRINTF = @HAVE_SNPRINTF@ -HAVE_WPRINTF = @HAVE_WPRINTF@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INSTOBJEXT = @INSTOBJEXT@ -INTLBISON = @INTLBISON@ -INTLLIBS = @INTLLIBS@ -INTLOBJS = @INTLOBJS@ -INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ KRB4_CFLAGS = @KRB4_CFLAGS@ KRB4_LDFLAGS = @KRB4_LDFLAGS@ KRB4_LIBS = @KRB4_LIBS@ LDADD = @LDADD@ LDFLAGS = @LDFLAGS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ LIBOBJS = @LIBOBJS@ LIBPERL_A = @LIBPERL_A@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ -MKINSTALLDIRS = @MKINSTALLDIRS@ -MSGFMT = @MSGFMT@ -MSGMERGE = @MSGMERGE@ NSS_CFLAGS = @NSS_CFLAGS@ NSS_LIBS = @NSS_LIBS@ OBJEXT = @OBJEXT@ @@ -252,7 +225,6 @@ PKG_CONFIG = @PKG_CONFIG@ PLUGINS_FALSE = @PLUGINS_FALSE@ PLUGINS_TRUE = @PLUGINS_TRUE@ -POSUB = @POSUB@ PRPLS_FALSE = @PRPLS_FALSE@ PRPLS_TRUE = @PRPLS_TRUE@ RANLIB = @RANLIB@ @@ -298,8 +270,6 @@ TK_LIBS = @TK_LIBS@ USE_GNUTLS_FALSE = @USE_GNUTLS_FALSE@ USE_GNUTLS_TRUE = @USE_GNUTLS_TRUE@ -USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ -USE_NLS = @USE_NLS@ USE_NSS_FALSE = @USE_NSS_FALSE@ USE_NSS_TRUE = @USE_NSS_TRUE@ USE_PERL_FALSE = @USE_PERL_FALSE@ @@ -309,7 +279,6 @@ USE_TK_FALSE = @USE_TK_FALSE@ USE_TK_TRUE = @USE_TK_TRUE@ VERSION = @VERSION@ -XGETTEXT = @XGETTEXT@ XSS_LIBS = @XSS_LIBS@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ @@ -324,6 +293,7 @@ ac_ct_F77 = @ac_ct_F77@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ +ac_pt_PKG_CONFIG = @ac_pt_PKG_CONFIG@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ @@ -375,6 +345,9 @@ pkgdir = $(libdir)/gaim YAHOOSOURCES = \ + enum.c \ + dns.c \ + enum.h \ crypt.c \ yahoo.h \ yahoo_auth.c \ @@ -484,7 +457,11 @@ -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dns.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enum.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libyahoo_a-crypt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libyahoo_a-dns.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libyahoo_a-enum.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libyahoo_a-util.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libyahoo_a-yahoo.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libyahoo_a-yahoo_auth.Po@am__quote@ @@ -525,6 +502,34 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +libyahoo_a-enum.o: enum.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libyahoo_a_CFLAGS) $(CFLAGS) -MT libyahoo_a-enum.o -MD -MP -MF "$(DEPDIR)/libyahoo_a-enum.Tpo" -c -o libyahoo_a-enum.o `test -f 'enum.c' || echo '$(srcdir)/'`enum.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libyahoo_a-enum.Tpo" "$(DEPDIR)/libyahoo_a-enum.Po"; else rm -f "$(DEPDIR)/libyahoo_a-enum.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='enum.c' object='libyahoo_a-enum.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libyahoo_a_CFLAGS) $(CFLAGS) -c -o libyahoo_a-enum.o `test -f 'enum.c' || echo '$(srcdir)/'`enum.c + +libyahoo_a-enum.obj: enum.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libyahoo_a_CFLAGS) $(CFLAGS) -MT libyahoo_a-enum.obj -MD -MP -MF "$(DEPDIR)/libyahoo_a-enum.Tpo" -c -o libyahoo_a-enum.obj `if test -f 'enum.c'; then $(CYGPATH_W) 'enum.c'; else $(CYGPATH_W) '$(srcdir)/enum.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libyahoo_a-enum.Tpo" "$(DEPDIR)/libyahoo_a-enum.Po"; else rm -f "$(DEPDIR)/libyahoo_a-enum.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='enum.c' object='libyahoo_a-enum.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libyahoo_a_CFLAGS) $(CFLAGS) -c -o libyahoo_a-enum.obj `if test -f 'enum.c'; then $(CYGPATH_W) 'enum.c'; else $(CYGPATH_W) '$(srcdir)/enum.c'; fi` + +libyahoo_a-dns.o: dns.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libyahoo_a_CFLAGS) $(CFLAGS) -MT libyahoo_a-dns.o -MD -MP -MF "$(DEPDIR)/libyahoo_a-dns.Tpo" -c -o libyahoo_a-dns.o `test -f 'dns.c' || echo '$(srcdir)/'`dns.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libyahoo_a-dns.Tpo" "$(DEPDIR)/libyahoo_a-dns.Po"; else rm -f "$(DEPDIR)/libyahoo_a-dns.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dns.c' object='libyahoo_a-dns.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libyahoo_a_CFLAGS) $(CFLAGS) -c -o libyahoo_a-dns.o `test -f 'dns.c' || echo '$(srcdir)/'`dns.c + +libyahoo_a-dns.obj: dns.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libyahoo_a_CFLAGS) $(CFLAGS) -MT libyahoo_a-dns.obj -MD -MP -MF "$(DEPDIR)/libyahoo_a-dns.Tpo" -c -o libyahoo_a-dns.obj `if test -f 'dns.c'; then $(CYGPATH_W) 'dns.c'; else $(CYGPATH_W) '$(srcdir)/dns.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libyahoo_a-dns.Tpo" "$(DEPDIR)/libyahoo_a-dns.Po"; else rm -f "$(DEPDIR)/libyahoo_a-dns.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dns.c' object='libyahoo_a-dns.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libyahoo_a_CFLAGS) $(CFLAGS) -c -o libyahoo_a-dns.obj `if test -f 'dns.c'; then $(CYGPATH_W) 'dns.c'; else $(CYGPATH_W) '$(srcdir)/dns.c'; fi` + libyahoo_a-crypt.o: crypt.c @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libyahoo_a_CFLAGS) $(CFLAGS) -MT libyahoo_a-crypt.o -MD -MP -MF "$(DEPDIR)/libyahoo_a-crypt.Tpo" -c -o libyahoo_a-crypt.o `test -f 'crypt.c' || echo '$(srcdir)/'`crypt.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libyahoo_a-crypt.Tpo" "$(DEPDIR)/libyahoo_a-crypt.Po"; else rm -f "$(DEPDIR)/libyahoo_a-crypt.Tpo"; exit 1; fi --- src/protocols/yahoo.old/yahoo.c 2005-08-04 08:57:44.000000000 +0800 +++ src/protocols/yahoo/yahoo.c 2006-08-18 16:16:09.000000000 +0800 @@ -50,6 +50,10 @@ extern char *yahoo_crypt(const char *, const char *); /* #define YAHOO_DEBUG */ +#define ENUM_SUPPORT +#ifdef ENUM_SUPPORT +#include "enum.h" +#endif static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *, GaimGroup *); static void yahoo_login_page_cb(void *user_data, const char *buf, size_t len); @@ -3287,6 +3291,30 @@ char *group = NULL; char *group2 = NULL; +#ifdef ENUM_SUPPORT + #define MAXSIZE 256 + + char *tech; + char *result; + + /* check if first character is a '+'. if yes then do enum resolution. */ + tech = (char *) g_malloc (sizeof (char) * MAXSIZE); + result = (char *) g_malloc (sizeof (char) * MAXSIZE); + + if (buddy->name[0] == '+') { + ast_copy_string (tech, "yahoo", MAXSIZE); + bzero(result, MAXSIZE); + ast_enum_init(); + ast_get_enum (buddy->name, result, MAXSIZE, tech, MAXSIZE, "e164.arpa", NULL); + if (strlen (result) > 1) + ast_copy_string (buddy->name, result, strlen(result)); + } + g_free (result); + g_free (tech); + + #undef MAXSIZE +#endif + if (!yd->logged_in) return;