diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2013-02-03 15:12:07 +0100 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2013-02-03 15:12:07 +0100 |
commit | 7f6138ffd4935043382ce5f867ee9e177e0a9787 (patch) | |
tree | 7442b10e479bdcb397947c941bf377ce0e0772d9 /contrib/gai.c | |
parent | 5b0e1fdef9c55b9c8a54f5c146fc84dab3b82e63 (diff) | |
download | fetchmail-7f6138ffd4935043382ce5f867ee9e177e0a9787.tar.gz fetchmail-7f6138ffd4935043382ce5f867ee9e177e0a9787.tar.bz2 fetchmail-7f6138ffd4935043382ce5f867ee9e177e0a9787.zip |
Add new gai.c debug source.
Diffstat (limited to 'contrib/gai.c')
-rw-r--r-- | contrib/gai.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/contrib/gai.c b/contrib/gai.c new file mode 100644 index 00000000..28961382 --- /dev/null +++ b/contrib/gai.c @@ -0,0 +1,42 @@ +/* + * File: gai.c + * Author: Matthias Andree + * + * Created on 3. Februar 2013, 15:03 + * A short file to call getaddrinfo with the same arguments as checkalias. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <netdb.h> + +/* + * + */ +int main(int argc, char** argv) { + struct addrinfo hints; + struct addrinfo *res; + + if (argc != 2 || 0 == strcmp("-h", argv[1])) { + fprintf(stderr, "Usage: %s hostname\n", argv[0]); + exit(EXIT_FAILURE); + } + + memset(&hints, 0, sizeof hints); + hints.ai_family=AF_UNSPEC; + hints.ai_protocol=PF_UNSPEC; + hints.ai_socktype=SOCK_STREAM; + hints.ai_flags=AI_CANONNAME; + + int result = getaddrinfo(argv[1], NULL, &hints, &res); + if (result) { + fprintf(stderr, "getaddrinfo(\"%s\", ...AI_CANONNAME...) failed: %d (%s)\n", argv[1], result, gai_strerror(result)); + exit(EXIT_FAILURE); + } + + freeaddrinfo(res); + return (EXIT_SUCCESS); +} + |