t_enum_adapters.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : test_enumerate_adapters                                           *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *  Purpose:                                                                   *
00007 *                                                                             *
00008 *    Makes sure that the adapter enumerator function is working properly.     *
00009 *                                                                             *
00010 *******************************************************************************
00011 * Copyright (c) 2003-$now By Author.  This program is free software; you can  *
00012 * redistribute it and/or modify it under the terms of the GNU General Public  *
00013 * License as published by the Free Software Foundation; either version 2 of   *
00014 * the License or (at your option) any later version.  This is online at:      *
00015 *     http://www.fsf.org/copyleft/gpl.html                                    *
00016 * Please send any updates to: fred@gruntose.com                               *
00017 \*****************************************************************************/
00018 
00019 #include <basis/function.h>
00020 #include <basis/istring.h>
00021 #include <basis/string_array.h>
00022 #include <opsystem/application_shell.h>
00023 #include <loggers/console_logger.h>
00024 #include <data_struct/static_memory_gremlin.h>
00025 #include <sockets/tcpip_stack.h>
00026 
00027 #include <stdio.h>
00028 #include <string.h>
00029 
00030 class test_enum_adapaters : public application_shell
00031 {
00032 public:
00033   test_enum_adapaters() : application_shell(class_name()) {}
00034   IMPLEMENT_CLASS_NAME("test_enum_adapaters");
00035   virtual int execute();
00036 };
00037 
00038 int test_enum_adapaters::execute()
00039 {
00040   FUNCDEF("execute");
00041   tcpip_stack stack;
00042 
00043   string_array ips;
00044   bool did_it = stack.enumerate_adapters(ips);
00045   if (!did_it)
00046     deadly_error(class_name(), func, "could not enumerate adapters");
00047 
00048   for (int i = 0; i < ips.length(); i++) {
00049     log(isprintf("%d: ", i+1) + ips[i]);
00050   }
00051 
00052   log("enumerate_adapters:: works for those functions tested.");
00053   return 0;
00054 }
00055 
00056 HOOPLE_MAIN(test_enum_adapaters, )
00057 

Generated on Fri Nov 28 04:29:34 2008 for HOOPLE Libraries by  doxygen 1.5.1