Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

addr.c

Go to the documentation of this file.
00001 /*
00002  * addr.c
00003  *
00004  * Copyright (c) 2001 Dug Song <dugsong@monkey.org>
00005  *
00006  * $Id: addr.c,v 1.3 2002/03/29 06:07:08 dugsong Exp $
00007  */
00008 
00009 #include "config.h"
00010 
00011 #include <sys/types.h>
00012 
00013 #include <err.h>
00014 #include <stdio.h>
00015 #include <stdlib.h>
00016 #include <unistd.h>
00017 
00018 #include "dnet.h"
00019 #include "mod.h"
00020 
00021 void
00022 addr_usage(void)
00023 {
00024         fprintf(stderr, "Usage: dnet addr <address> ...\n");
00025         exit(1);
00026 }
00027 
00028 int
00029 addr_main(int argc, char *argv[])
00030 {
00031         struct addr addr;
00032         int c, len;
00033         
00034         if (argc == 1 || *(argv[1]) == '-')
00035                 addr_usage();
00036         
00037         for (c = 1; c < argc; c++) {
00038                 if (addr_aton(argv[c], &addr) < 0)
00039                         addr_usage();
00040                 
00041                 len = addr.addr_bits / 8;
00042                 
00043                 if (write(STDOUT_FILENO, addr.addr_data8, len) != len)
00044                         err(1, "write");
00045         }
00046         exit(0);
00047 }
00048 
00049 struct mod mod_addr = {
00050         "addr",
00051         MOD_TYPE_DATA,
00052         addr_main
00053 };

Generated on Sun May 14 14:51:11 2006 by  doxygen 1.4.2