Beispiel #1
0
bool cPluginSatip::ProcessArgs(int argc, char *argv[])
{
  debug1("%s", __PRETTY_FUNCTION__);
  // Implement command line argument processing here if applicable.
  static const struct option long_options[] = {
    { "devices",  required_argument, NULL, 'd' },
    { "trace",    required_argument, NULL, 't' },
    { "server",   required_argument, NULL, 's' },
    { "portrange",required_argument, NULL, 'p' },
    { "rcvbuf",   required_argument, NULL, 'r' },
    { "detach",   no_argument,       NULL, 'D' },
    { "single",   no_argument,       NULL, 'S' },
    { "noquirks", no_argument,       NULL, 'n' },
    { NULL,       no_argument,       NULL,  0  }
    };

  cString server;
  cString portrange;
  int c;
  while ((c = getopt_long(argc, argv, "d:t:s:p:r:DSn", long_options, NULL)) != -1) {
    switch (c) {
      case 'd':
           deviceCountM = strtol(optarg, NULL, 0);
           break;
      case 't':
           SatipConfig.SetTraceMode(strtol(optarg, NULL, 0));
           break;
      case 's':
           server = optarg;
           break;
      case 'D':
           SatipConfig.SetDetachedMode(true);
           break;
      case 'S':
           SatipConfig.SetUseSingleModelServers(true);
           break;
      case 'n':
           SatipConfig.SetDisableServerQuirks(true);
           break;
      case 'p':
           portrange = optarg;
           break;
      case 'r':
           SatipConfig.SetRtpRcvBufSize(strtol(optarg, NULL, 0));
           break;
      default:
           return false;
      }
    }
  if (!isempty(*portrange))
     ParsePortRange(portrange);
  // this must be done after all parameters are parsed
  if (!isempty(*server))
     ParseServer(*server);
  return true;
}
int LoadConfig( const u_char* conf, SSLConfig* cfg )
{
	ParseContext ctx;
	u_char* conf_copy = NULL;
	ConfigToken TopLevelTokens[] = { Token_Server, Token_EOF };
	ConfigToken token = Token_Unknown;

	error_buffer[0] = 0;

	conf_copy = (u_char*) malloc( strlen( conf ) + 1 );
	strcpy( conf_copy, conf );

	memset( &ctx, 0, sizeof(ctx) );
	ctx.input = conf_copy;
	ctx.config = cfg;

	do 
	{
		token = ParseOneOf( &ctx, TopLevelTokens, ARRAY_SIZE( TopLevelTokens ) );

		if( token == Token_Server ) 
		{
			if( ParseServer( &ctx ) == CONFIG_PARSE_ERROR ) token = CONFIG_PARSE_ERROR;
		}
	} while ( token == Token_Server );

	free( conf_copy ); conf_copy = ctx.input = NULL;

	/* make sure we have at least one server set up */
	if( token != CONFIG_PARSE_ERROR && ctx.config->server_cnt == 0 )
	{
		sprintf( error_buffer, "%s: at least one SSL server's configuration is expected", ERROR_PREFIX );
		token = CONFIG_PARSE_ERROR;
	}

	if( token == CONFIG_PARSE_ERROR ) 
	{
		if( strlen( error_buffer ) )
		{
			_dpd.fatalMsg( "%s(%d) => %s", *(_dpd.config_file), *(_dpd.config_line), error_buffer );
		}
		return CONFIG_PARSE_ERROR;
	}

	PrintSSLConfig( ctx.config );
	return 0;
}
Beispiel #3
0
const char* wxURI::ParseAuthority(const char* uri)
{
    // authority     = [ userinfo "@" ] host [ ":" port ]
    if ( uri[0] == '/' && uri[1] == '/' )
    {
        //skip past the two slashes
        uri += 2;

        // ############# DEVIATION FROM RFC #########################
        // Don't parse the server component for file URIs
        if(m_scheme != "file")
        {
            //normal way
            uri = ParseUserInfo(uri);
            uri = ParseServer(uri);
            return ParsePort(uri);
        }
    }

    return uri;
}
Beispiel #4
0
CDBUriConnParams::CDBUriConnParams(const string& params)
{
    string::size_type pos = 0;
    string::size_type cur_pos = 0;

    // Check for 'dbapi:' ...
    pos = params.find_first_of(":", pos);
    if (pos == string::npos) {
        DATABASE_DRIVER_ERROR("Invalid database locator format, should start with 'dbapi:'", 20001);
    }

    if (! NStr::StartsWith(params, "dbapi:", NStr::eNocase)) {
        DATABASE_DRIVER_ERROR("Invalid database locator format, should start with 'dbapi:'", 20001);
    }

    cur_pos = pos + 1;

    // Check for driver name ...
    pos = params.find("//", cur_pos);
    if (pos == string::npos) {
        DATABASE_DRIVER_ERROR("Invalid database locator format, should contain driver name", 20001);
    }

    if (pos != cur_pos) {
        string driver_name = params.substr(cur_pos, pos - cur_pos - 1);
        SetDriverName(driver_name);
    }

    cur_pos = pos + 2;

    // Check for user name and password ...
    pos = params.find_first_of(":@", cur_pos);
    if (pos != string::npos) {
        string user_name = params.substr(cur_pos, pos - cur_pos);

        if (params[pos] == '@') {
            SetUserName(user_name);

            cur_pos = pos + 1;

            ParseServer(params, cur_pos);
        } else {
            // Look ahead, we probably found a host name ...
            cur_pos = pos + 1;

            pos = params.find_first_of("@", cur_pos);

            if (pos != string::npos) {
                // Previous value was an user name ...
                SetUserName(user_name);

                string password = params.substr(cur_pos, pos - cur_pos);
                SetPassword(password);

                cur_pos = pos + 1;
            }

            ParseServer(params, cur_pos);
        }
    } else {
        ParseServer(params, cur_pos);
    }

}