int main(int argc, char *argv[]) { TCLAP::CmdLine cmd("HmanCoder is simple haffman coder", ' ', "0.0.1"); TCLAP::SwitchArg ifX("x","extract","Extract input file to output file", cmd, false); TCLAP::ValueArg<std::string> iPath("i", "input", "Input file", true, "", "string"); TCLAP::ValueArg<std::string> oPath("o", "output", "Output file", true, "", "string"); cmd.add(iPath); cmd.add(oPath); cmd.parse(argc, argv); if (!ifX.getValue()) { HuffmanEncoder hman(iPath.getValue(), oPath.getValue()); hman.encode(); } else { HuffmanDecoder hman(iPath.getValue(), oPath.getValue()); hman.decode(); } }
int main(int argc, const char **argv) { set_debug_flags(NULL, D_ALWAYS); // initialize to read from config file myDistro->Init( argc, argv ); config(); // Set up the dprintf stuff... Termlog = true; dprintf_config("TEST_NETWORK_ADAPTER", get_param_functions()); const char *tmp; int status = 0; Options opts; if ( CheckArgs(argc, argv, opts) ) { exit( 1 ); } NetworkAdapterBase *net = NULL; if ( opts.m_if_name ) { printf( "Creating network adapter object for name %s\n", opts.m_if_name ); net = NetworkAdapterBase::createNetworkAdapter( opts.m_if_name ); } else { MyString sinful; sinful.formatstr( "<%s:1234>", opts.m_address ); printf( "Creating network adapter object for %s\n", sinful.Value() ); net = NetworkAdapterBase::createNetworkAdapter( sinful.Value() ); } if ( !net ) { printf( "Error creating adapter\n" ); exit(1); } // Initialize it if ( !net->getInitStatus() ) { printf( "Initialization of adaptor with address %s failed\n", opts.m_address ); delete net; exit(1); } // And, check for it's existence if ( !net->exists() ) { printf( "Adaptor with address %s not found\n", opts.m_address ); delete net; exit(1); } // Now, extract information from it tmp = net->hardwareAddress(); if ( !tmp || !strlen(tmp) ) tmp = "<NONE>"; printf( "hardware address: %s\n", tmp ); tmp = net->subnetMask(); if ( !tmp || !strlen(tmp) ) tmp = "<NONE>"; printf( "subnet: %s\n", tmp ); printf( "wakable: %s\n", net->isWakeable() ? "YES" : "NO" ); MyString tmpstr; net->wakeSupportedString( tmpstr ); printf( "wake support flags: %s\n", tmpstr.Value() ); net->wakeEnabledString( tmpstr ); printf( "wake enable flags: %s\n", tmpstr.Value() ); HibernatorBase *hibernator = new RealHibernator( ); if ( opts.m_method ) { printf( "Setting method to %s\n", opts.m_method ); hibernator->setMethod( opts.m_method ); } HibernationManager hman( hibernator ); if ( !hman.initialize( ) ) { fprintf( stderr, "Initialization of hibernation manager failed\n" ); status = 1; } hman.addInterface( *net ); ClassAd ad; hman.publish( ad ); ad.fPrint( stdout ); const char *method = hman.getHibernationMethod(); printf( "Hibernation method used: %s\n", method ); printf( "Can hibernate: %s\n", BoolString(hman.canHibernate()) ); printf( "Can wake: %s\n", BoolString(hman.canWake()) ); if ( hman.canHibernate() && opts.m_state != HibernatorBase::NONE ) { printf( "Setting state %s\n", hman.sleepStateToString(opts.m_state) ); if ( ! hman.switchToState( opts.m_state ) ) { printf( "Failed to switch states\n" ); status = 1; } } if ( status != 0 && opts.m_verbosity >= 1 ) { fprintf(stderr, "test_hibernation FAILED\n"); } delete net; return status; }