Пример #1
0
bool EclCMDShell::parseCommandLineOptions(ArgvIterator &iter)
{
    if (iter.done())
    {
        usage();
        return false;
    }

    bool boolValue;
    for (; !iter.done(); iter.next())
    {
        const char * arg = iter.query();
        if (iter.matchFlag(optHelp, "help"))
            continue;
        else if (*arg!='-')
        {
            cmd.set(arg);
            iter.next();
            break;
        }
        else if (iter.matchFlag(boolValue, "--version"))
        {
            fprintf(stdout, "%s\n", BUILD_TAG);
            return false;
        }
    }
    return true;
}
Пример #2
0
    bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        //First 4 parameter's order is fixed.
        //TargetESPProcessName
        //TargetESPBindingPort | TargetESPServiceName
        //ESDLDefinitionId
        //ESDLServiceName
        for (int cur = 0; cur < 4 && !iter.done(); cur++)
        {
           const char *arg = iter.query();
           if (*arg != '-')
           {
               switch (cur)
               {
                case 0:
                    optTargetESPProcName.set(arg);
                    break;
                case 1:
                    optPortOrName.set(arg);
                    break;
                case 2:
                    optESDLDefID.set(arg);
                    break;
                case 3:
                    optESDLService.set(arg);
                    break;
                default:
                    fprintf(stderr, "\nUnrecognized positional argument detected : %s\n", arg);
                    usage();
                    return false;
               }
           }
           else
           {
               fprintf(stderr, "\nOption detected before required arguments: %s\n", arg);
               usage();
               return false;
           }

           iter.next();
        }

        for (; !iter.done(); iter.next())
        {
            if (parseCommandLineOption(iter))
                continue;

            if (matchCommandLineOption(iter, true)!=EsdlCmdOptionMatch)
                return false;
        }

        return true;
    }
Пример #3
0
    bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        //First 5 parameter order is fixed.
        for (int cur = 0; cur < 5 && !iter.done(); cur++)
        {
           const char *arg = iter.query();
           if (*arg != '-')
           {
               switch (cur)
               {
                case 0:
                    optTargetESPProcName.set(arg);
                    break;
                case 1:
                    optBindingName.set(arg);
                    break;
                case 2:
                    optService.set(arg);
                    break;
                case 3:
                    optVersionStr.set(arg);
                    break;
                case 4:
                    optMethod.set(arg);
                    break;
                default:
                    fprintf(stderr, "\nUnrecognized positional argument detected : %s\n", arg);
                    usage();
                    return false;
               }
           }
           else
           {
               fprintf(stderr, "\noption detected before required arguments: %s\n", arg);
               usage();
               return false;
           }

           iter.next();
        }

        for (; !iter.done(); iter.next())
        {
            if (parseCommandLineOption(iter))
                continue;

            if (matchCommandLineOption(iter, true)!=EsdlCmdOptionMatch)
                return false;
        }

        return true;
    }
Пример #4
0
    bool parseCommandLineOptions(ArgvIterator &iter)
    {
       if (iter.done())
       {
           usage();
           return false;
       }

       //First parameter is required
       //<filename.(ecm|esdl|xml)>       The ESDL file containing service definition\n"
       //Second parameter is now optional but can cause request to fail if not provided
       //<servicename>
       for (int cur = 0; cur < 2 && !iter.done(); cur++)
       {
          const char *arg = iter.query();
          if (*arg != '-')
          {
              switch (cur)
              {
               case 0:
                   optSource.set(arg);
                   break;
               case 1:
                   optESDLService.set(arg);
                   break;
              }
          }
          else
          {
              if (optSource.isEmpty())
              {
                  fprintf(stderr, "\nOption detected before required arguments: %s\n", arg);
                  usage();
                  return false;
              }
              else
              {
                  fprintf(stderr, "\nWarning: Target ESDL Service was not specified, this request will fail if ESDL definition contains multiple \n");
                  break;
              }
          }

          iter.next();
       }

       for (; !iter.done(); iter.next())
       {
           if (parseCommandLineOption(iter))
               continue;

           if (matchCommandLineOption(iter, true)!=EsdlCmdOptionMatch)
               return false;
       }

       return true;
    }
Пример #5
0
    bool parseCommandLineOptions(ArgvIterator &iter)
    {
       if (iter.done())
       {
           usage();
           return false;
       }

       //First x parameter's order is fixed.
       //<servicename>
       //<filename.ecm>       The ESDL file containing service definition\n"
       for (int cur = 0; cur < 2 && !iter.done(); cur++)
       {
          const char *arg = iter.query();
          if (*arg != '-')
          {
              switch (cur)
              {
               case 0:
                   optESDLService.set(arg);
                   break;
               case 1:
                   optSource.set(arg);
                   break;
               default:
                   fprintf(stderr, "\nUnrecognized positional argument detected : %s\n", arg);
                   usage();
                   return false;
              }
          }
          else
          {
              fprintf(stderr, "\nOption detected before required arguments: %s\n", arg);
              usage();
              return false;
          }

          iter.next();
       }

       for (; !iter.done(); iter.next())
       {
           if (parseCommandLineOption(iter))
               continue;

           if (matchCommandLineOption(iter, true)!=EsdlCmdOptionMatch)
               return false;
       }

       return true;
    }
Пример #6
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            const char *arg = iter.query();
            if (*arg!='-')
            {
                if (optTarget.isEmpty())
                    optTarget.set(arg);
                else if (optQueryId.isEmpty())
                    optQueryId.set(arg);
                else
                {
                    fprintf(stderr, "\nunrecognized argument %s\n", arg);
                    return false;
                }
                continue;
            }
            if (iter.matchOption(optPMID, ECLOPT_PMID) || iter.matchOption(optPMID, ECLOPT_PMID_S))
                continue;
            if (iter.matchFlag(optGlobalScope, ECLOPT_GLOBAL_SCOPE))
                continue;
            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                return false;
        }
        return true;
    }
Пример #7
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            const char *arg = iter.query();
            if (*arg!='-')
            {
                if (optTarget.isEmpty())
                    optTarget.set(arg);
                else
                {
                    fprintf(stderr, "\nunrecognized argument %s\n", arg);
                    return false;
                }
                continue;
            }
            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                return false;
        }
        return true;
    }
Пример #8
0
int EclCMDShell::callExternal(ArgvIterator &iter)
{
    const char *argv[100];
    StringBuffer cmdstr("ecl-");
    cmdstr.append(cmd.sget());
    int i=0;
    argv[i++]=cmdstr.str();
    if (optHelp)
        argv[i++]="help";
    for (; !iter.done(); iter.next())
        argv[i++]=iter.query();
    argv[i]=NULL;
    if (execvp(cmdstr.str(), const_cast<char **>(argv))==-1)
    {
        switch(errno)
        {
        case ENOENT:
            fprintf(stderr, "ecl '%s' command not found\n", cmd.sget());
            return 1;
        default:
            fprintf(stderr, "ecl '%s' command error %d\n", cmd.sget(), errno);
            return 1;
        }
    }
    return 0;
}
Пример #9
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            const char *arg = iter.query();
            if (*arg!='-')
            {
                if (optAlias.length())
                {
                    fprintf(stderr, "\nmultiple aliases not supported\n");
                    return false;
                }
                optAlias.set(arg);
                continue;
            }
            if (iter.matchOption(optQuerySet, ECLOPT_QUERYSET))
                continue;
            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                return false;
        }
        return true;
    }
Пример #10
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            const char *arg = iter.query();
            if (streq(arg, "-"))
            {
                optObj.set("stdin");
                continue;
            }
            if (*arg!='-')
            {
                if (optObj.value.length())
                {
                    fprintf(stderr, "\nmultiple targets (%s and %s) not currently supported\n", optObj.value.sget(), arg);
                    return false;
                }
                optObj.set(arg);
                continue;
            }
            if (iter.matchOption(optCluster, ECLOPT_CLUSTER))
                continue;
            if (iter.matchOption(optName, ECLOPT_NAME))
                continue;
            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                return false;
        }
        return true;
    }
Пример #11
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            const char *arg = iter.query();
            if (*arg!='-')
            {
                optQuerySetName.set(arg);
                break;
            }
            if (iter.matchOption(optPackageMap, ECLOPT_PACKAGEMAP))
                continue;
            switch (EclCmdCommon::matchCommandLineOption(iter))
            {
                case EclCmdOptionNoMatch:
                    fprintf(stderr, "\n%s option not recognized\n", arg);
                    return false;
                case EclCmdOptionCompletion:
                    return false;
                case EclCmdOptionMatch:
                    break;
            }
        }
        return true;
    }
Пример #12
0
int EclCMDShell::callExternal(ArgvIterator &iter)
{
    const char *argv[100];
    StringBuffer cmdstr("ecl-");
    cmdstr.append(cmd.sget());
    int i=0;
    argv[i++]=cmdstr.str();
    if (optHelp)
        argv[i++]="help";
    for (; !iter.done(); iter.next())
        argv[i++]=iter.query();
    argv[i]=NULL;
//TODO - add common routine or use existing in jlib
#ifdef _WIN32
    if (_spawnvp(_P_WAIT, cmdstr.str(), const_cast<char **>(argv))==-1)
#else
    if (execvp(cmdstr.str(), const_cast<char **>(argv))==-1)
#endif
    {
        switch(errno)
        {
        case ENOENT:
            fprintf(stderr, "ecl '%s' command not found\n", cmd.sget());
            return 1;
        default:
            fprintf(stderr, "ecl '%s' command error %d\n", cmd.sget(), errno);
            return 1;
        }
    }
    return 0;
}
Пример #13
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            const char *arg = iter.query();
            if (*arg!='-')
            {
                optPkgName.set(arg);
                return true;
            }
            else if (iter.matchOption(optCluster, ECLOPT_CLUSTER))
                continue;
            else if (iter.matchOption(optPkgName, ECLOPT_PACKAGE))
                continue;
            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                return false;
        }
        return true;
    }
Пример #14
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            const char *arg = iter.query();
            if (*arg!='-')
            {
                optFileName.set(arg);
                return true;
            }
            if (iter.matchOption(optQuerySet, ECLOPT_QUERYSET))
                continue;
            if (iter.matchFlag(optActivate, ECLOPT_ACTIVATE))
                continue;
            if (iter.matchFlag(optOverWrite, ECLOPT_OVERWRITE))
                continue;
            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                return false;
        }
        return true;
    }
Пример #15
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            const char *arg = iter.query();
            if (*arg!='-')
            {
                optFileName.set(arg);
                return true;
            }
            if (iter.matchOption(optProcess, ECLOPT_PROCESS))
                continue;
            if (iter.matchOption(optDaliIp, ECLOPT_DALIIP))
                continue;
            if (iter.matchFlag(optOverWrite, ECLOPT_OVERWRITE))
                continue;
            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                return false;
        }
        return true;
    }
Пример #16
0
    bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (int cur = 0; cur < 2 && !iter.done(); cur++)
        {
           const char *arg = iter.query();
           if (*arg != '-')
           {
               switch (cur)
               {
                case 0:
                    optESDLService.set(arg);
                    break;
                case 1:
                    optVersionStr.set(arg);
                    break;
               }
           }
           else
           {
               fprintf(stderr, "\nOption detected before required arguments: %s\n", arg);
               usage();
               return false;
           }

           iter.next();
        }

        for (; !iter.done(); iter.next())
        {
            if (parseCommandLineOption(iter))
                continue;

            if (matchCommandLineOption(iter, true)!=EsdlCmdOptionMatch)
                return false;
        }

        return true;
    }
Пример #17
0
bool EclCMDShell::parseCommandLineOptions(ArgvIterator &iter)
{
    if (iter.done())
    {
        usage();
        return false;
    }

    bool boolValue;
    for (; !iter.done(); iter.next())
    {
        const char * arg = iter.query();
        if (iter.matchFlag(optHelp, "help"))
            continue;
        if (*arg!='-')
        {
            cmd.set(arg);
            iter.next();
            break;
        }
        if (iter.matchFlag(boolValue, "--version"))
        {
            fprintf(stdout, "%s\n", BUILD_TAG);
            return false;
        }
        StringAttr tempArg;
        if (iter.matchOption(tempArg, "-brk"))
        {
#if defined(_WIN32) && defined(_DEBUG)
            unsigned id = atoi(tempArg.sget());
            if (id == 0)
                DebugBreak();
            else
                _CrtSetBreakAlloc(id);
#endif
        }
    }
    return true;
}
Пример #18
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            const char *arg = iter.query();
            if (*arg!='-')
            {
                if (optTarget.isEmpty())
                    optTarget.set(arg);
                else if (optFileName.isEmpty())
                    optFileName.set(arg);
                else
                {
                    fprintf(stderr, "\nunrecognized argument %s\n", arg);
                    return false;
                }
                continue;
            }
            if (iter.matchOption(optPackageMapId, ECLOPT_PMID))
                continue;
            if (iter.matchOption(optDaliIP, ECLOPT_DALIIP))
                continue;
            if (iter.matchOption(optSourceProcess, ECLOPT_SOURCE_PROCESS))
                continue;
            if (iter.matchFlag(optActivate, ECLOPT_ACTIVATE)||iter.matchFlag(optActivate, ECLOPT_ACTIVATE_S))
                continue;
            if (iter.matchFlag(optOverWrite, ECLOPT_OVERWRITE)||iter.matchFlag(optOverWrite, ECLOPT_OVERWRITE_S))
                continue;
            if (iter.matchFlag(optGlobalScope, ECLOPT_GLOBAL_SCOPE))
                continue;
            if (iter.matchFlag(optAllowForeign, ECLOPT_ALLOW_FOREIGN))
                continue;
            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                return false;
        }
        return true;
    }
Пример #19
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            const char *arg = iter.query();
            if (*arg!='-')
            {
                if (optTarget.isEmpty())
                    optTarget.set(arg);
                else if (optFileName.isEmpty())
                    optFileName.set(arg);
                else
                {
                    fprintf(stderr, "\nunrecognized argument %s\n", arg);
                    return false;
                }
                continue;
            }
            if (iter.matchFlag(optValidateActive, ECLOPT_ACTIVE))
                continue;
            if (iter.matchFlag(optCheckDFS, ECLOPT_CHECK_DFS))
                continue;
            if (iter.matchOption(optPMID, ECLOPT_PMID) || iter.matchOption(optPMID, ECLOPT_PMID_S))
                continue;
            if (iter.matchFlag(optGlobalScope, ECLOPT_GLOBAL_SCOPE))
                continue;
            StringAttr queryIds;
            if (iter.matchOption(queryIds, ECLOPT_QUERYID))
            {
                optQueryIds.appendList(queryIds.get(), ",");
                continue;
            }
            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                return false;
        }
        return true;
    }
Пример #20
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            if (parseCommandLineOption(iter))
                continue;

            if (matchCommandLineOption(iter, true)!=EsdlCmdOptionMatch)
                return false;
        }

        return true;
    }
Пример #21
0
int EclCMDShell::callExternal(ArgvIterator &iter)
{
    const char *argv[100];
    StringBuffer cmdstr("ecl-");
    cmdstr.append(cmd.str());
    int i=0;
    argv[i++]=cmdstr.str();
    if (optHelp)
        argv[i++]="help";
    for (; !iter.done(); iter.next())
        argv[i++]=iter.query();
    argv[i]=NULL;
//TODO - add common routine or use existing in jlib
    // First try in same dir as the ecl executable
    StringBuffer local;
    splitFilename(queryCurrentProcessPath(), &local, &local, NULL, NULL);
    local.append(cmdstr);
    errno = 0;
#ifdef _WIN32
    if (_spawnvp(_P_WAIT, local.str(), const_cast<char **>(argv))==-1)
        return 0;
    // If not found, try the path
    if (errno!=ENOENT || _spawnvp(_P_WAIT, cmdstr.str(), const_cast<char **>(argv))==-1)
#else
    if (execvp(local.str(), const_cast<char **>(argv))!=-1)
        return 0;
    // If not found, try the path
    if (errno!=ENOENT || execvp(cmdstr.str(), const_cast<char **>(argv))==-1)
#endif
    {
        switch(errno)
        {
        case ENOENT:
            fprintf(stderr, "ecl '%s' command not found\n", cmd.str());
            return 1;
        default:
            fprintf(stderr, "ecl '%s' command error %d\n", cmd.str(), errno);
            return 1;
        }
    }
    return 0;
}
Пример #22
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            const char *arg = iter.query();
            if (*arg!='-')
            {
                optQuerySetName.set(arg);
                return true;
            }
            if (iter.matchOption(optPackageMap, ECLOPT_PACKAGEMAP))
                continue;
            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                return false;
        }
        return true;
    }
Пример #23
0
    virtual bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        for (; !iter.done(); iter.next())
        {
            const char *arg = iter.query();
            if (*arg != '-')
            {
                if (optSource.isEmpty())
                    optSource.set(arg);
                else if (optService.isEmpty())
                    optService.set(arg);
                else if (optMethod.isEmpty())
                    optMethod.set(arg);
                else
                {
                    fprintf(stderr, "\nunrecognized argument: %s\n", arg);
                    usage();
                    return false;
                }
            }
            else
            {
                if (EsdlConvertCmd::parseCommandLineOption(iter))
                    continue;
                if (EsdlConvertCmd::matchCommandLineOption(iter, true)!=EsdlCmdOptionMatch)
                    return false;
            }
        }

        return true;
    }
Пример #24
0
    bool parseCommandLineOptions(ArgvIterator &iter)
    {
        if (iter.done())
        {
            usage();
            return false;
        }

        //First 3 parameter's order is fixed.
        //TargetESPProcessName
        //TargetESPBindingPort | TargetESPServiceName
        //ESDLDefinitionId
        //4th param is now optional, absence can cause failure
        //ESDLServiceName
        for (int cur = 0; cur < 4 && !iter.done(); cur++)
        {
           const char *arg = iter.query();
           if (*arg != '-')
           {
               switch (cur)
               {
                case 0:
                    optTargetESPProcName.set(arg);
                    break;
                case 1:
                    optPortOrName.set(arg);
                    break;
                case 2:
                    optESDLDefID.set(arg);
                    break;
                case 3:
                    optESDLService.set(arg);
                    break;
               }
           }
           else
           {
               if (cur < 3)
               {
                   fprintf(stderr, "\nOption detected before required arguments: %s\n", arg);
                   usage();
                   return false;
               }
               else
               {
                   fprintf(stderr, "\nWarning ESDL Service name not provided. Can cause failure if ESDL definition contains multiple services\n");
                   break;
               }
           }

           iter.next();
        }

        for (; !iter.done(); iter.next())
        {
            if (parseCommandLineOption(iter))
                continue;

            if (matchCommandLineOption(iter, true)!=EsdlCmdOptionMatch)
                return false;
        }

        return true;
    }