The source code of the application follows :
/* \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Hyperion Pattern. Hyperion Pattern is a part of the Hyperion Project. ---------------------------------------------------------- Copyright (c) 2001 Pierre Rebours. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See hyp.license.txt file for more information about the license. Web: http://lagrandeporte.multimania.com/hyperion Email: pierre_rebours@yahoo.com ---------------------------------------------------------- CVS $Log$ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ */ #include<iostream> #include"hyp.kernel.h" int main(int argc, char *argv[ ]) { bool b_help=false; bool b_register=true; std::string server_name; std::ostream& log_stream=std::cout; hyp_ker::CCmdInfo cmd(argc,argv,'-'); if(cmd.GetSize()==0) b_help=true; for(int i=0;i<cmd.GetSize();i++) { hyp_ker::CCmdInfoLabelEnum e=cmd.GetValue(i); if(e.GetLabelName()=="-help") { b_help=true; } else if(e.GetLabelName()=="server") { hyp_ker::CCmdInfoLabel l=e.GetValue(0); server_name=l.GetValue(0); } else if(e.GetLabelName()=="-u") { b_register=false; } else if(e.GetLabelName()=="-clog") { log_stream=hyp_ker::clog; } } log_stream<<hyp_ker::GetLibraryVersion()<<"\n\n"; if(b_help) { log_stream<<"-server : Name of the component server\n" <<"--help : Dipslay the help\n" <<"--clog : Output is directed to the Hyperion CLOG file\n" <<"--r : Register the component\n" <<"--u : Unregister the component\n" <<"\n"; } hyp_ker::CDllUtility dll; if(server_name.empty()) { log_stream<<"Server name not specified\n"; return 1; } try{ dll.LoadLibrary(server_name,true); if(b_register) { hyp_ker::PTR_REGISTERSERVER RegisterServer=static_cast<hyp_ker::PTR_REGISTERSERVER> (dll.GetFunctionAddress(server_name,"hypDllRegisterServer")); hyp_THROW_ASSERT( hyp_ker::CException , hyp_ker::Succeeded(RegisterServer()) ); } else { hyp_ker::PTR_UNREGISTERSERVER UnregisterServer=static_cast<hyp_ker::PTR_UNREGISTERSERVER> (dll.GetFunctionAddress(server_name,"hypDllUnregisterServer")); hyp_THROW_ASSERT( hyp_ker::CException , hyp_ker::Succeeded(UnregisterServer()) ); } dll.UnloadAllLibraries(); } catch(hyp_ker::CSysException& excep) { log_stream<<"Error\n"<<excep; return -1; } if(b_register) log_stream<<"Registration done\n"; else log_stream<<"Unregistration done\n"; return 1; }
|
|