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

📄 cmdline.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  if(progtype == 0)      return OPTEND_CIMMOF;  else      return OPTEND_CIMMOFL;}static voidapplyDefaults(mofCompilerOptions &cmdlinedata) {  if (cmdlinedata.is_local()) {#if defined(PEGASUS_USE_RELEASE_DIRS) && defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)    cmdlinedata.set_repository_name(ZOS_DEFAULT_PEGASUS_REPOSITORY);#else    char *peghome = getenv(PEGASUS_HOME);    if (peghome) {#if defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)	char home[256] = {0};	if (strlen(peghome) < 256)	{	    strcpy(home, peghome);	    EtoA(home);	}	cmdlinedata.set_repository(home);#else      cmdlinedata.set_repository(peghome);#endif    } else {#if defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)      // Default to the shipped OS/400 CIM directory so that      // the user doesn't need to set PEGASUS_HOME      cmdlinedata.set_repository(OS400_DEFAULT_PEGASUS_HOME);#endif    }#endif // end of #if defined(PEGASUS_USE_RELEASE_DIRS) && defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)  } else {    cmdlinedata.set_repository(DEFAULT_SERVER_AND_PORT);  }  cmdlinedata.reset_syntax_only();  cmdlinedata.reset_suppress_warnings();  cmdlinedata.reset_suppress_all_messages();  cmdlinedata.reset_trace();  cmdlinedata.set_namespacePath(ROOTCIMV2);  cmdlinedata.set_repository_name(REPOSITORY_NAME_DEFAULT);  cmdlinedata.set_repository_mode(REPOSITORY_MODE_DEFAULT);  cmdlinedata.set_erroros(PEGASUS_STD(cerr));  cmdlinedata.set_warningos(PEGASUS_STD(cerr));  cmdlinedata.reset_operationType();  cmdlinedata.reset_xmloutput();  cmdlinedata.reset_update_class();  cmdlinedata.reset_allow_experimental();  cmdlinedata.reset_allow_version();#ifdef PEGASUS_OS_OS400  cmdlinedata.reset_quiet();#endif}#if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)# define SEPCHAR '\\'# define SEPCHAR2 '/'#else# define SEPCHAR '/'# define SEPCHAR2 '/'#endif// This function looks at a string (which we suppose to be argv[0]// and decides if it represents cimmof or cimmoflintgetType(const char *name){#if defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM)    // Only the local compiler is shipped on OS/400, and    // it is called QYCMMOF.  Force the local return code.    return 1;#else  const char *pos;  const char *pos2;  pos = strrchr(name, SEPCHAR);  pos2 = strrchr(name, SEPCHAR2);  pos = (pos2 > pos) ? pos2 : pos;  if (!pos)    pos = name;  else    pos++;  if (*pos != 'c' && *pos != 'C') return -1;  pos++;  if (*pos != 'i' && *pos != 'I') return -1;  pos++;  if (*pos != 'm' && *pos != 'M') return -1;  pos++;  if (*pos != 'm' && *pos != 'M') return -1;  pos++;  if (*pos != 'o' && *pos != 'O') return -1;  pos++;  if (*pos != 'f' && *pos != 'F') return -1;  pos++;  if (*pos != 'l' && *pos != 'L') return 0;  return 1;#endif}extern "C++" int processCmdline(int, char **, mofCompilerOptions &, ostream&);intprocessCmdLine(int argc, char **argv, mofCompilerOptions &cmdlinedata,	       ostream &helpos = cerr) {  getoopt cmdline;  int type = -1;  setCmdLineOpts(cmdline, getType(argv[0]));  cmdline.parse(argc, argv);#ifdef PEGASUS_OS_OS400  String os400MarkerFile("/QIBM/USERDATA/OS400/CIM/QYCM53PTF");#endif  switch (getType(argv[0])) {  case 1: cmdlinedata.set_is_local();    #ifdef PEGASUS_OS_OS400    	// check if we are in qsh, if we are NOT running in a qsh environment then      // send and escape message,      // if we ARE then call ycmServerIsActive without the quiet option#pragma convert(37)      if( getenv("SHLVL") == NULL ){  // native mode	  if(!FileSystem::exists(os400MarkerFile) && ycmServerIsActive(YCMSERVER_ACTIVE, YCMCIMMOFL, 1)) {	      // previous call's message was suppressed,              // server is running, send escape message and return	      ycmSend_Message_Escape(CPFDF81_RC, "01", "QYCMMOFL", "*CTLBDY   ", 1);	      return CPFDF81_RC;	  }      }      else{ // qsh mode	  if(ycmServerIsActive(YCMSERVER_ACTIVE, YCMCIMMOFL)) {	      // server is running, the previous call sent a	      // diagnostic message, lets return	      return CPFDF81_RC;	  }      }#pragma convert(0)#endif    break;  default: cmdlinedata.reset_is_local();  }  applyDefaults(cmdlinedata);  if (cmdline.hasErrors()) {    //  throw an exception and hande it in the caller    //l10n    //String msg = "Command line errors:\n";    MessageLoaderParms parms("Compiler.cmdline.cimmof.CMDLINE_ERRORS",    						 "Command line errors:\n");    String msg = MessageLoader::getMessage(parms);    cmdline.printErrors(msg);    throw ArgumentErrorsException(msg);  }  MessageLoaderParms parms("Compiler.cmdline.cimmof.CMDLINE_ERRORS",                           "Too many options specified.\n");  for (unsigned int i = cmdline.first(); i < cmdline.last(); i++) {    const Optarg &arg = cmdline[i];    opttypes c = catagorize(arg, getType(argv[0]));    if(type == HELPFLAG || type == VERSIONFLAG)          throw ArgumentErrorsException(parms);    switch (c)      {      case VERSIONFLAG:        if(type != -1) throw ArgumentErrorsException(parms);        break;      case HELPFLAG:        if(type != -1) throw ArgumentErrorsException(parms);        break;      case INCLUDEPATH:cmdlinedata.add_include_path(arg.optarg());        break;      case SUPPRESSFLAG: cmdlinedata.set_suppress_warnings();        break;      case NAMESPACE: cmdlinedata.set_namespacePath(arg.optarg());        break;      case REPOSITORYDIR:  cmdlinedata.set_repository(arg.optarg());	break;      case REPOSITORYNAME:  cmdlinedata.set_repository_name(arg.optarg());	break;      case REPOSITORYMODE:	{	  cmdlinedata.set_repository_mode(arg.optarg());// prevent using binary repository since we do not support that in 2.5#ifdef PEGASUS_OS_OS400	  if (String::equalNoCase(arg.optarg(), "BIN"))	  {	      throw ArgumentErrorsException("ERROR: THE VALUE BIN IS NOT SUPPORTED FOR THE REPOSITORY MODE."); 	  }#endif	  if(String::equalNoCase(arg.optarg(), "XML") ||	     String::equalNoCase(arg.optarg(), "BIN")) {}	  else	    {	      //l10n	      //throw ArgumentErrorsException(	      //"Unknown value specified for option -M.");	      MessageLoaderParms parms("Compiler.cmdline.cimmof.UNKNOWN_VALUE_OPTION_A",				       "Unknown value specified for option -M.");	      throw ArgumentErrorsException(parms);	    }	}	break;      case UPDATEFLAG:        {          if (arg.optarg().size() == 1)          {              for (unsigned int i = 0; i < arg.optarg().size(); i++)              {                  if (arg.optarg()[i] == 'c')                      cmdlinedata.set_update_class();                  else                  {                  	//l10n                      //throw ArgumentErrorsException(                          //"Unknown value specified for option -u.");                      MessageLoaderParms parms("Compiler.cmdline.cimmof.UNKNOWN_VALUE_OPTION_U",					       "Unknown value specified for option -u.");                      throw ArgumentErrorsException(parms);                  }              }          }          else          {          	//l10n            //throw ArgumentErrorsException(              //  "Too many values specified for option -u.");            MessageLoaderParms parms("Compiler.cmdline.cimmof.TOO_MANY_VALUES_OPTION_U",				     "Too many values specified for option -u.");            throw ArgumentErrorsException(parms);          }        }        break;      case ALLOWFLAG:        {          if ((arg.optarg().size() <= 2) && (arg.optarg().size() != 0))          {              for (unsigned int i = 0; i < arg.optarg().size(); i++)              {                 if (arg.optarg()[i] == 'E')                     cmdlinedata.set_allow_experimental();                 else                 if (arg.optarg()[i] == 'V')                     cmdlinedata.set_allow_version();                 else                  {                  	//l10n                      //throw ArgumentErrorsException(                          //"Unknown value specified for option -a.");                      MessageLoaderParms parms("Compiler.cmdline.cimmof.UNKNOWN_VALUE_OPTION_A",					       "Unknown value specified for option -a.");                      throw ArgumentErrorsException(parms);                  }              }          }          else          {          	//l10n            //throw ArgumentErrorsException(                //"Too many values specified for option -a.");            MessageLoaderParms parms("Compiler.cmdline.cimmof.TOO_MANY_VALUES_OPTION_A",				     "Too many values specified for option -a.");            throw ArgumentErrorsException(parms);          }        }        break;#ifndef PEGASUS_OS_HPUX      case SYNTAXFLAG: cmdlinedata.set_syntax_only();		       cmdlinedata.set_operationType(				compilerCommonDefs::DO_NOT_ADD_TO_REPOSITORY);	break;      case TRACEFLAG:	{	  cmdlinedata.set_trace();	  const String &s = arg.optarg();	  if (s != "") {	    // ATTN: P3 BB Mar 2001  No way to close the trace stream	    // or to delete the ostream object.  It's OK for now because	    // the program terminates when we're done with the stream.#if defined(PEGASUS_OS_OS400)	    ofstream *tracefile = new ofstream(s.getCString(),PEGASUS_STD(_CCSID_T(1208)));#else	    ofstream *tracefile = new ofstream(s.getCString());#endif	    if (tracefile && *tracefile)	      cmdlinedata.set_traceos(*tracefile);	  }	}	break;      case XMLFLAG: cmdlinedata.set_xmloutput();	break;    //PEP167 commenting FILELIST option/*      case FILELIST: {	int stat = process_filelist(arg.optarg(), cmdlinedata);	// ATTN: P1 BB 2001 On Process filelist error should throw an exception	if (stat != 1) {	  return stat;	}	break;      }*/#endif#ifdef PEGASUS_OS_OS400      // If quiet mode is chosen then shut down stdout and stderr.      // This is used during product installation and PTF application.      // We must be absolutely quiet to avoid a terminal being      // activated in native mode.      case QUIETFLAG:        cmdlinedata.set_quiet();        // Redirect to /dev/null.        // Works for both qshell and native modes.        freopen("/dev/null","w",stdout);        freopen("/dev/null","w",stderr);        // Set the stderr stream to buffered with 32k.        // Allows utf-8 to be sent to stderr (P9A66750).        setvbuf(stderr, new char[32768], _IOLBF, 32768);	break;#endif      case FILESPEC: cmdlinedata.add_filespecs(arg.optarg());	break;      case OPTEND_CIMMOFL:      case OPTEND_CIMMOF: return -1;  // shouldn't happen	break;      case NO_USAGE_WARNING:        cmdlinedata.set_no_usage_warning();      }      type = c;  }  if(type == VERSIONFLAG)  {     cerr << "Version " << PEGASUS_PRODUCT_VERSION << endl;     return(-1);  }  else if(type == HELPFLAG)  {     help(helpos, getType(argv[0]));     return(-1);  }  if (String::equal(cmdlinedata.get_repository(), String::EMPTY)) {  	//l10n    //throw CmdlineNoRepository(          //"You must specify -R or set PEGASUS_HOME environment variable");    MessageLoaderParms parms("Compiler.cmdline.cimmof.MUST_SPECIFY_R_OR_HOME",    						 "You must specify -R or set PEGASUS_HOME environment variable");    throw CmdlineNoRepository(parms);  }#ifdef PEGASUS_OS_OS400  // Force a mof to be specified on OS/400  if (cmdlinedata.get_filespec_list().size() == 0) {  	//l10n    //throw ArgumentErrorsException(          //"You must specify some MOF files to process.");    MessageLoaderParms parms("Compiler.cmdline.cimmof.MUST_SPECIFY_MOF_FILES",    						 "You must specify some MOF files to process.");    throw ArgumentErrorsException(parms);  }#endif  return 0;}

⌨️ 快捷键说明

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