"Fossies" - the Fresh Open Source Software Archive

Member "nss-mdns-0.10/src/avahi-test.c" (8 Feb 2007, 1632 Bytes) of package /linux/misc/dns/old/nss-mdns-0.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* $Id: avahi-test.c 114 2007-02-08 16:42:22Z lennart $ */
    2 
    3 /***
    4   This file is part of nss-mdns.
    5  
    6   nss-mdns is free software; you can redistribute it and/or modify it
    7   under the terms of the GNU Lesser General Public License as
    8   published by the Free Software Foundation; either version 2 of the
    9   License, or (at your option) any later version.
   10  
   11   nss-mdns is distributed in the hope that it will be useful, but
   12   WITHOUT ANY WARRANTY; without even the implied warranty of
   13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   14   General Public License for more details.
   15  
   16   You should have received a copy of the GNU Lesser General Public
   17   License along with nss-mdns; if not, write to the Free Software
   18   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   19   USA.
   20 ***/
   21 
   22 #include <sys/socket.h>
   23 #include <arpa/inet.h>
   24 #include <stdio.h>
   25 
   26 #include "avahi.h"
   27 
   28 int main(int argc, char *argv[]) {
   29     uint8_t data[64];
   30     char t[256];
   31     int r;
   32 
   33     if ((r = avahi_resolve_name(AF_INET, argc >= 2 ? argv[1] : "cocaine.local", data)) == 0)
   34         printf("AF_INET: %s\n", inet_ntop(AF_INET, data, t, sizeof(t)));
   35     else
   36         printf("AF_INET: failed (%i).\n", r);
   37 
   38 /*     if ((r = avahi_resolve_name(AF_INET6, argc >= 2 ? argv[1] : "cocaine.local", data)) == 0) */
   39 /*         printf("AF_INET6: %s\n", inet_ntop(AF_INET6, data, t, sizeof(t))); */
   40 /*     else */
   41 /*         printf("AF_INET6: failed (%i).\n", r); */
   42 
   43     if ((r = avahi_resolve_address(AF_INET, data, t, sizeof(t))) == 0)
   44         printf("REVERSE: %s\n", t);
   45     else
   46         printf("REVERSE: failed (%i).\n", r);
   47 
   48     return 0;
   49 }