예제 #1
0
void wxURL::SetDefaultProxy(const wxString& url_proxy)
{
    if ( !url_proxy )
    {
        if ( ms_proxyDefault )
        {
            ms_proxyDefault->Close();
            delete ms_proxyDefault;
            ms_proxyDefault = NULL;
        }
    }
    else
    {
        wxString tmp_str = url_proxy;
        int pos = tmp_str.Find(wxT(':'));
        if (pos == wxNOT_FOUND)
            return;

        wxString hostname = tmp_str(0, pos),
                 port = tmp_str(pos+1, tmp_str.Length()-pos);
        wxIPV4address addr;

        if (!addr.Hostname(hostname))
            return;
        if (!addr.Service(port))
            return;

        if (ms_proxyDefault)
            // Finally, when all is right, we connect the new proxy.
            ms_proxyDefault->Close();
        else
            ms_proxyDefault = new wxHTTP();
        ms_proxyDefault->Connect(addr, true); // Watcom needs the 2nd arg for some reason
    }
}
예제 #2
0
void wxURL::SetProxy(const wxString& url_proxy)
{
    if ( !url_proxy )
    {
        if ( m_proxy && m_proxy != ms_proxyDefault )
        {
            m_proxy->Close();
            delete m_proxy;
        }

        m_useProxy = false;
    }
    else
    {
        wxString tmp_str;
        wxString hostname, port;
        int pos;
        wxIPV4address addr;

        tmp_str = url_proxy;
        pos = tmp_str.Find(wxT(':'));
        // This is an invalid proxy name.
        if (pos == wxNOT_FOUND)
            return;

        hostname = tmp_str(0, pos);
        port = tmp_str(pos+1, tmp_str.Length()-pos);

        addr.Hostname(hostname);
        addr.Service(port);

        // Finally, create the whole stuff.
        if (m_proxy && m_proxy != ms_proxyDefault)
            delete m_proxy;
        m_proxy = new wxHTTP();
        m_proxy->Connect(addr, true); // Watcom needs the 2nd arg for some reason

        CleanData();
        // Reparse url.
        m_useProxy = true;
        ParseURL();
    }
}
예제 #3
0
void
StreamReader::readLines (vector<String> &lines)
{
	CHECK_CLOSE(_file);
	
	char *line = 0;
	size_t len;
	ssize_t result = 0;
	while ((result = getline(&line, &len, _file)) != -1) {
    	if (line == 0) 
    		continue;
    	if (strlen (line) == 0) 
    		continue;
		String tmp_str (line);
    	lines.push_back (tmp_str);
    }
}
예제 #4
0
String
StreamReader::readLine (void)
{
	if (_file == NULL)
		return "";
	
	char *line = 0;
	size_t len;
	ssize_t result = 0;
	String tmp;

	if((!feof(_file)) && ((result = getline(&line, &len, _file)) != -1))
	{
		String tmp_str (line);
		tmp = tmp_str;
	}
	
	return tmp;
}
예제 #5
0
bool RegexStore::patternMatch(std::u16string& in_string) {
	//No pattern matches when we don't have a valid pattern
	if (not is_compiled) {
    return false;
	}

  //Check for a match
  regmatch_t pmatch;
	std::string tmp_str(in_string.begin(), in_string.end());
  int match = regexec(&exp, tmp_str.c_str(), 1, &pmatch, 0);
	//Make sure that each character was matched and that the entire input string
	//was consumed by the pattern
  if (0 == match and 0 == pmatch.rm_so and in_string.size() == pmatch.rm_eo) {
		return true;
  }
  else {
		return false;
  }
}
예제 #6
0
_Tt_trace_parser::_Tt_trace_parser(int fd)
: trace_stream(), sink()
{
	// Read in the file into the trace_stream string...we can't
	// just read each character as we need it because the Lex
	// unput() macro needs to stuff back characters, and those
	// characters might be different from those read -- which
	// would require that the parse config file be opened read/write.

	int numread = 0;
	const int bufsize = 1000;	// Read in 1000 bytes at a time
	char buf[bufsize];

	do {
		numread = read(fd, buf, bufsize);
		_Tt_string tmp_str((const unsigned char*) buf, numread);
		trace_stream = trace_stream.cat(tmp_str);
	} while (numread == bufsize);

	trace_stream[trace_stream.len()] = '\0';

	tracer_init();
}