⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmdline.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation, The Open Group.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec Corporation; The Open Group.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions:// // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================//// Author: Bob Blair (bblair@bmc.com)//// Modified By: Gerarda Marquez (gmarquez@us.ibm.com)//              -- PEP 43//              Alagaraja Ramasubramanian, IBM (alags_raj@in.ibm.com) - PEP-167//              Amit K Arora, IBM (amitarora@in.ibm.com) - Bug#2333, #2351//              Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) - Bug#3370//              David Dillard, VERITAS Software Corp.//                  (david.dillard@veritas.com)//              Jim Wunderlich (Jim_Wunderlich@prodigy.net)////%/////////////////////////////////////////////////////////////////////////////////// process the command line, getting the repository location and// the include path list and the other options////// bug 4573 - cimmof include file search path processing is inadequate//// Bug 4573 changed the behavior of the processing for locating specified//  include files. The new procssing is based on the include file processing //  behaviour used by the C compiler.////      The search path for included files previously was://          1. try to open the file in the current working directory.//          2. process the include path array from the cimof(l) cmdline//             processing which always include "dot" as a default search//             path and then any paths specified on the command line //             with the -I option.////      The search path for included files now is://          1. try to open the file in the same directory as the current//             file being processed.//          2. process the include path array from the cimof(l) cmdline//             processing which only includes paths specified on the //             command line with the -I option.//////////////#include <Pegasus/Common/Config.h>#include <fstream>#include <cstdlib>#include <iostream>#include <Pegasus/Common/String.h>#include <Pegasus/Common/FileSystem.h>#include <Pegasus/Common/PegasusVersion.h>PEGASUS_USING_STD;PEGASUS_USING_PEGASUS;#include <Pegasus/Compiler/mofCompilerOptions.h>#include "cmdlineExceptions.h"#include "cmdline.h"#include "cmdlineExceptions.h"#include <Pegasus/getoopt/getoopt.h>#include <Pegasus/Common/String.h>#ifdef PEGASUS_OS_OS400#include <qycmutiltyUtility.H>#include <qycmutilu2.H>#endif#define DEFAULT_SERVER_AND_PORT "localhost:5988"ostream &cimmofl_warning(ostream &os) {  String warn = "Warning: Use of cimmofl can corrupt the CIM Server Repository.\n";  warn.append ("         cimmofl should only be used under very controlled situations.\n");  warn.append ("         cimmof is the recommended OpenPegasus MOF compiler.\n\n");  MessageLoaderParms parms("Compiler.cmdline.cimmof.cmdline.CIMMOFL_USAGE_WARNING",warn);  os << MessageLoader::getMessage(parms);  return os;}ostream &help(ostream &os, int progtype) {//l10n menu  //PEP167 change  String help;#ifdef PEGASUS_OS_HPUX  if(progtype == 1)  {      help.append("Usage: ").append("cimmofl");  }  else  {      help.append("Usage: ").append("cimmof ");  }  help.append( " -h | --help\n" );  if(progtype == 1)      help.append("       cimmofl");  else      help.append("       cimmof ");  help.append(" --version\n");  if(progtype == 1)      help.append("       cimmofl");  else      help.append("       cimmof ");  help.append( " [ -w ] [ -uc ] [ -aE | -aV | -aEV ] [ -I path ]\n");  help.append( "              [ -n namespace | --namespace namespace ]");  if(progtype == 1)  {    help.append("\n               [ -R repositorydir ] [ --CIMRepository repositorydir ]");    help.append("\n               [ -N repositoryname ] [ -M repositorymode]");  }  help.append( " [ mof_file ... ]\n");  help.append("Options : \n");  help.append( "    -h, --help      - Display this help message \n");  help.append( "    --version       - Display CIM Server version\n");  help.append( "    -w              - Suppress warning messages\n");  help.append( "    -I              - Specify an include path\n");  help.append( "    -n, --namespace - Override the default CIM Repository namespace\n");  help.append( "    -uc             - Allow update of an existing class definition\n");  help.append( "    -aE             - Allow Experimental Schema changes\n");  help.append( "    -aV             - Allow both Major and Down Revision Schema changes\n");  help.append( "    -aEV            - Allow both Experimental and Version Schema changes\n");  if(progtype == 1) {      help.append( "    -R, --CIMRepository - Specify the repository directory\n");      help.append( "    -N                  - Specify the repository name - defaults to \"repository\"\n");      help.append( "    -M                  - Repository mode [XML, BIN] - defaults to \"XML\"\n");  }#else  if(progtype == 1)      help.append("Usage: ").append("cimmofl");  else      help.append("Usage: ").append("cimmof ");  help.append( " -h | --help\n");  if(progtype == 1)      help.append("       cimmofl");  else      help.append("       cimmof ");  help.append(" --version\n");  if(progtype == 1)      help.append("       cimmofl");  else      help.append("       cimmof ");  help.append( " [ -w ] [-E ] [ -uc ] [ -aE | -aV | -aEV ] [ -I path ]\n");  help.append( "               [ -n namespace | --namespace namespace ] [ --xml ]\n");  help.append( "               [ --trace ]");#ifdef PEGASUS_OS_OS400  help.append("  [ -q ]");#endif  if(progtype == 1)  {      help.append("\n               [ -R repositorydir ] [ --CIMRepository repositorydir ]");      help.append("\n               [ -N repositoryname ] [ -M repositorymode]");  }#ifdef PEGASUS_OS_OS400  help.append( " mof_file...\n");#else  help.append( " [ mof_file... ]\n");#endif  help.append("Options :\n");  help.append( "    -h, --help          - Display this help message\n");  help.append( "    --version           - Display CIM Server version\n");  help.append( "    -E                  - Syntax check only\n");  help.append( "    -w                  - Suppress warning messages\n");  help.append( "    -I                  - Specify an include path\n");  help.append( "    -n, --namespace     - Override default CIM Repository namespace (root/cimv2)\n");  help.append( "    -uc                 - Allow update of an existing class definition\n");  help.append( "    -aE                 - Allow Experimental Schema changes\n");  help.append( "    -aV                 - Allow both Major and Down Revision Schema changes\n");  help.append( "    -aEV                - Allow both Experimental and Version Schema changes\n");#ifdef PEGASUS_OS_OS400  help.append( "    -q                  - Suppress all messages except command line usage errors\n");#endif  //PEP167 - Remove and disable 'f' and 'file' options. No longer required  //help.append( "  -ffile -- specify file containing a list of MOFs to compile.\n");  //help.append( " --file=file -- specify file containing list of MOFs.\n");  help.append( "    --xml               - Output XML only, to stdout. Do not update repository\n");  help.append( "    --trace             - Trace to file (default to stdout)\n");  // PEP167 - '-R', '--CIMRepository' disabled for cimmof ONLY.  if(progtype == 1) {      help.append( "    -R, --CIMRepository - Specify the repository directory\n");      help.append( "    -N                  - Specify the repository name - defaults to \"repository\"\n");      help.append( "    -M                  - Repository mode [XML, BIN] - defaults to \"XML\"\n");  }#endif  if (progtype == 1)   {      help.append(      "    -W                  - Suppress the usage warning (i.e., Warning:\n"      "                          Use of cimmofl can corrupt the CIM Server\n"      "                          Repository. cimmofl should only be used\n"      "                          under very controlled situations. cimmof\n"      "                          is the recommended OpenPegasus MOF\n"      "                          compiler.)\n");  }  if(progtype == 1)  {      help.append("\n\nWarning: Use of cimmofl can corrupt the CIM Server Repository.\n");      help.append("         cimmofl should only be used under very controlled situations.\n");      help.append("         cimmof is the recommended OpenPegasus MOF compiler.\n");  }// now localize the menu based on platform, use help as the default menu which// has been appropriately built above for the specific platformMessageLoaderParms parms ;if(progtype == 1){   parms = MessageLoaderParms("Compiler.cmdline.cimmofl.cmdline.MENU.STANDARD",help);   #ifdef PEGASUS_OS_HPUX      parms = MessageLoaderParms("Compiler.cmdline.cimmofl.cmdline.MENU.PEGASUS_OS_HPUX",help);   #endif   #ifdef PEGASUS_OS_OS400      parms = MessageLoaderParms("Compiler.cmdline.cimmofl.cmdline.MENU.PEGASUS_OS_OS400",help);   #endif}else{   parms = MessageLoaderParms("Compiler.cmdline.cimmof.cmdline.MENU.STANDARD",help);   #ifdef PEGASUS_OS_HPUX      parms = MessageLoaderParms("Compiler.cmdline.cimmof.cmdline.MENU.PEGASUS_OS_HPUX",help);   #endif   #ifdef PEGASUS_OS_OS400      parms = MessageLoaderParms("Compiler.cmdline.cimmof.cmdline.MENU.PEGASUS_OS_OS400",help);   #endif}  os << MessageLoader::getMessage(parms);  return os;}// If the 'f' flag is encountered, it names a file that contains the// names of files to be processed.  Open the file and stick them into// the filelist.static intprocess_filelist(const String &filename, mofCompilerOptions &cmdlinedata){  String line;  ifstream ifs;  Open(ifs, filename);  while (ifs != 0) {    GetLine(ifs, line);    if (line.size() > 0)      cmdlinedata.add_filespecs(line);  }  return 0;}/* flag value, type, islong?, needsValue? */static struct optspec optspecs[] ={    {(char*)"", FILESPEC, false, getoopt::NOARG},    {(char*)"h", HELPFLAG, false, getoopt::NOARG},    {(char*)"help", HELPFLAG, true, getoopt::NOARG},    {(char*)"version", VERSIONFLAG, true, getoopt::NOARG},    {(char*)"n", NAMESPACE, false, getoopt::MUSTHAVEARG},    {(char*)"namespace", NAMESPACE, true, getoopt::MUSTHAVEARG},    {(char*)"I", INCLUDEPATH, false, getoopt::MUSTHAVEARG},    //PEP167 - not required    //{(char*)"Include", INCLUDEPATH, true, getoopt::MUSTHAVEARG},    {(char*)"w", SUPPRESSFLAG, false, getoopt::NOARG},    {(char*)"u", UPDATEFLAG, false, getoopt::MUSTHAVEARG},    {(char*)"a", ALLOWFLAG, false, getoopt::MUSTHAVEARG},#ifndef PEGASUS_OS_HPUX    //PEP167 - 'f' and 'filelist' options disabled as per PEP    //{(char*)"f", FILELIST, false, getoopt::MUSTHAVEARG},    //{(char*)"filelist", FILELIST, true, getoopt::MUSTHAVEARG},    {(char*)"E", SYNTAXFLAG, false, getoopt::NOARG},    {(char*)"trace", TRACEFLAG, true, getoopt::OPTIONALARG},    {(char*)"xml", XMLFLAG, true, getoopt::NOARG},#endif#ifdef PEGASUS_OS_OS400    {(char*)"q", QUIETFLAG, false, getoopt::NOARG},#endif    {(char*)"", OPTEND_CIMMOF, false, getoopt::NOARG},    {(char*)"R", REPOSITORYDIR, false, getoopt::MUSTHAVEARG},    {(char*)"CIMRepository", REPOSITORYDIR, true, getoopt::MUSTHAVEARG},    {(char*)"N", REPOSITORYNAME, false, getoopt::MUSTHAVEARG},    {(char*)"M", REPOSITORYMODE, false, getoopt::MUSTHAVEARG},    {(char*)"W", NO_USAGE_WARNING, false, getoopt::NOARG},    {(char*)"", OPTEND_CIMMOFL, false, getoopt::NOARG}};//PEP167 change - 2nd argument char* addedstatic voidsetCmdLineOpts(getoopt &cmdline, int progtype) {  for (unsigned int i = 0; ; i++) {    const optspec &o = optspecs[i];    //PEP167 change    if(progtype == 1 && o.catagory == OPTEND_CIMMOF) continue;    else if(progtype == 1 && o.catagory == OPTEND_CIMMOFL) break;    else if(progtype == 0 && o.catagory == OPTEND_CIMMOF) break;    //if (o.flag == "") Bug#2314 - Incorrect comparison    if ((o.flag != 0) && (o.flag[0] == '\0'))      continue;    if (o.islong)      cmdline.addLongFlagspec(o.flag, (getoopt::argtype)o.needsvalue);    else      cmdline.addFlagspec(o.flag[0], o.needsvalue == getoopt::MUSTHAVEARG ?			  true : false);  }}//PEP167 change - 2nd argument char* addedstatic opttypescatagorize(const Optarg &arg, int progtype) {  for (unsigned int i = 0; ; i++) {    const optspec &o = optspecs[i];    //PEP167 change    if(progtype == 1 && o.catagory == OPTEND_CIMMOF) continue;    else if(progtype == 1 && o.catagory == OPTEND_CIMMOFL) break;    else if(progtype == 0 && o.catagory == OPTEND_CIMMOF) break;    if (arg.getName() == o.flag)      return o.catagory;  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -