Subject: API change between 1.4.0 and 1.5.0

API change between 1.4.0 and 1.5.0

From: Guenter Knauf <>
Date: Fri, 15 Feb 2008 18:02:46 +0100

Hi all,
recently it came to my attention that there's an API breakage between c-ares 1.4.x and 1.5.x.
I had updated to 1.5.1 release, and when I wanted to build the php_ares extension compilation broke:

ares.c:1346: function call 'ares_parse_a_reply(const unsigned char *, int,
ares.c:1346: struct hostent **)' does not match
ares.c:1346: 'ares_parse_a_reply(const unsigned char *, int, struct hostent
ares.c:1346: **, struct addrttl *, int *)'

further examing this I found that this commit is guilty for that:

I think this is a very bad thing to just change API calls this way.
Now this change would require in each and every external code which comsumes c-ares that an ugly hack has to be inserted which detects the version number.
IMHO this is not acceptable. We must think of an admin who has no idea of such changes and who just wants to compile PHP with latest dependent libs, and kaboom!

I think its required that we introduce new APIs for that, and provide defines; f.e.:

int ares_parse_a_reply_ex(const unsigned char *abuf, int alen,
                       struct hostent **host,
                       struct addrttl *addrttls, int *naddrttls);
int ares_parse_aaaa_reply_ex(const unsigned char *abuf, int alen,
                       struct hostent **host,
                       struct addr6ttl *addrttls, int *naddrttls);

#define ares_parse_a_reply(b,l,h) ares_parse_a_reply_ex(b,l,h,NULL,NULL)
#define ares_parse_aaaa_reply(b,l,h) ares_parse_aaaa_reply_ex(b,l,h,NULL,NULL)

This way we would be backward-compatible to previous versions;
and I hope here that its valid to pass in NULL for the missing vars, havent checked yet the functions.


Received on 2008-02-15