コード例 #1
0
bool CDownload::makeAbsolutePath(const char* _myp, const char* _base,MyString& _dest)
{

	MyString p = _myp;
	MyString header5 = p.Left(5);
	MyString header17 = p.Left(17);
	MyString header8 = p.Left(8);
	MyString header7 = p.Left(7);

	bool	bAbsolute=  true;

	// OG 190110 Added \ for WinCE devices
	if ( ( p[0]=='\\') || ( p[0]=='/') || ( p[1]==':') || (!header5.CompareNoCase("http:")) )
		_dest = p; // absolute path
	else
		if (!header17.CompareNoCase("file://localhost/"))
		_dest = p.substr(17,p.length()-17); // absolute path for opera
	else
		if (!header8.CompareNoCase("file:///"))
#ifdef WIN32
		_dest = p.substr(8,p.length()-8); // absolute path
#else
	_dest = p.substr(7,p.length()-7); // keep the / on mac
#endif
	else
		if (!header7.CompareNoCase("file://"))
コード例 #2
0
ファイル: MyString.cpp プロジェクト: akmartinez1/CCSF
const MyString MyString::operator=(MyString &right)
{
   if (len != 0)
      delete [] str;
   str = new char[right.length() + 1];
   strcpy(str, right.getValue());
   len = right.length();
   return *this;
}
コード例 #3
0
ファイル: MyString.cpp プロジェクト: Jordior97/MyZork
void MyString::operator=(const MyString &other)
{
	if (max_size < other.length() + 1)
	{
		delete[] buffer;
		max_size = other.length() + 1;
		buffer = new char[max_size];
	}
	strcpy_s(buffer, max_size, other.buffer);
}
コード例 #4
0
static bool docker_add_env_walker (void*pv, const MyString &var, const MyString &val) {
	ArgList* runArgs = (ArgList*)pv;
	MyString arg;
	arg.reserve_at_least(var.length() + val.length() + 2);
	arg = var;
	arg += "=";
	arg += val;
	runArgs->AppendArg("-e");
	runArgs->AppendArg(arg);
	return true; // true to keep iterating
}
コード例 #5
0
ファイル: MyString.cpp プロジェクト: Jordior97/MyZork
void MyString::operator+=(const MyString &other)
{
	char *temp = nullptr;

	if (max_size < other.length() + length() + 1)
	{
		max_size = other.length() + length() + 1;
		temp = new char[max_size];
		strcpy_s(temp, max_size, buffer);
		delete[]buffer;
		strcat_s(temp, max_size, other.buffer);
		buffer = temp;
	}
	else
	{
		strcat_s(buffer, max_size, other.buffer);
	}
}
コード例 #6
0
ファイル: MyString.cpp プロジェクト: Jordior97/MyZork
MyString MyString::operator+(const MyString &other) const
{
	MyString newstring;
	newstring.max_size = length() + other.length() + 1;
	newstring.buffer = new char[newstring.max_size];
	strcpy_s(newstring.buffer, newstring.max_size, buffer);
	strcat_s(newstring.buffer, newstring.max_size, other.buffer);
	return newstring;
}
コード例 #7
0
ファイル: MyString.cpp プロジェクト: akmartinez1/CCSF
const MyString MyString::operator+=(MyString &right)
{
   char *temp = str;

   str = new char[strlen(str) + right.length() + 1];
   strcpy(str, temp);
   strcat(str, right.getValue());
   if (len != 0)
         delete [] temp;
   len = strlen(str);
   return *this;
}
コード例 #8
0
ファイル: ipv6_hostname.cpp プロジェクト: AlainRoy/htcondor
std::vector<condor_sockaddr> resolve_hostname_raw(const MyString& hostname) {
	//
	// For now, we can just document that you need the Punycoded DSN name.
	// If somebody complains about that, we can revisit this.  (If we
	// assume/require UTF-8 (int the config file), we can still readily
	// distinguish Sinfuls, since ':' and '?' won't be used by the UTF-8
	// IDNs.)
	//
	std::vector<condor_sockaddr> ret;
	for( int i = 0; i < hostname.length(); ++i ) {
		if( isalnum( hostname[i] ) || hostname[i] == '-' ) { continue; }
		if( hostname[i] == '.' && i + 1 < hostname.length()
			&& hostname[i+1] != '.' ) { continue; }

		dprintf( D_HOSTNAME, "resolve_hostname_raw(): argument '%s' is not a valid DNS name, returning no addresses.\n", hostname.c_str() );
		return ret;
	}

	addrinfo_iterator ai;
	int res  = ipv6_getaddrinfo(hostname.Value(), NULL, ai);
	if (res) {
		dprintf(D_HOSTNAME, "ipv6_getaddrinfo() could not look up %s: %s (%d)\n", 
			hostname.Value(), gai_strerror(res), res);
		return ret;
	}

	// To eliminate duplicate address, here we use std::set.
	// we also want to maintain the order given by getaddrinfo.
	std::set<condor_sockaddr> s;
	while (addrinfo* info = ai.next()) {
		condor_sockaddr addr(info->ai_addr);
		if (s.find(addr) == s.end()) {
			ret.push_back(addr);
			s.insert(addr);
		}
	}
	return ret;
}
コード例 #9
0
// If they're at the same address they must be the same, as they're immutable objects
// If they consist of the same character array, they must also be the same
bool MyString::operator==(MyString& lhs_string){
    // Same address check
    if (this == &lhs_string){
        return true;
    }

    if (string_length != lhs_string.length()){
        return false;
    }


    for (int i = 0; i < string_length + 1; ++i){
        if (cstring[i] != lhs_string[i]){
            std::cout << cstring[i] << " Doesn't equal " << lhs_string[i] << std::endl;
            return false;
        }
    }

    return true; // All conditions are met, the string is the same
}
コード例 #10
0
void HTTPServer::onUrlRequested ( MyString req, SOCKET sock )
{
	if ( req.find ( ".." ) !=-1 ||
	     req.find ( "/.ht" ) !=-1 || req.endsWith ( "~" ) ) {
		// evil hacker trying to read non-wwwhome or secret file
		errorReport ( sock, "403", "Forbidden",
		              "You don't have permission to access the requested URL." );
	} else {
		MyString path = req;
		MyFile f ( path );
		if ( f.isDirectory() && !path.endsWith ( "/" ) ) {
			// redirect browser if referring to directory without final '/'
			path += "/";
		}

		if ( f.isDirectory() ) {
#if defined(FULLDEBUG) || defined(DEBUG)
			mLog ( "Is a directory: " + path );
#endif
			// if directory, implicitly add 'index.html'
			string header;
			header =  ( string ) "HTTP/1.1 200 OK\r\n"
			          + "Content-Type: text/html\r\n";

			string length = "Content-Length: ";

			string html_header = "<html><body>";
			// out all files here
			string files;
			getDirFiles ( path, &files );

			string html_footer = "</body></html>\r\n\r\n";
			string data = html_header + files + html_footer;


			//count content-length.
			stringstream sstm;
			sstm << data.length();
			length += sstm.str() + "\r\n\r\n";

			data = header + length + html_header + files + html_footer;

			int n = write ( sock, data.c_str(), data.length() +1 );
			if ( n < 0 ) {
				mLog ( "ERROR writing to socket" );
				exit ( 1 );
			}
#ifdef FULLDEBUG
			mLog ( "Wrote: " + data );
#endif

		} else {
			try {
				// send files

				MyString temp;
				temp = ( string ) "HTTP/1.0 200 OK\r\n";
				temp += 		"Content-Type: " + guessContentType ( path ) + "\r\n";


				string data;
				parseFile ( sock, path, &data ); // send raw file

				//count content-length.
				string length = "Content-Length: ";
				stringstream sstm;
				sstm << data.length();
				length += sstm.str() + "\r\n\r\n";

				temp += length + data;

				int n = write ( sock, temp.c_str(), temp.length() );
				if ( n < 0 ) {
					mLog ( "ERROR writing to socket" );
					exit ( 1 );
				}
#if defined(DEBUG) || defined(FULLDEBUG)
				mLog ( "200 OK" );
#endif
			} catch ( ... ) {
				// file not found
				errorReport ( sock, "404", "Not Found",
				              "The requested URL was not found on this server." );
			}//try-catch
		}//else

	}//else
}
コード例 #11
0
ファイル: MyString.cpp プロジェクト: SummerWish/C_homework
/*
 从MyString构造
 
 eg:
 MyString a;
 MyString b(a);
 */
MyString::MyString(const MyString& str)
{
    _str = new char[str.length() + 1];
    my_strcpy(_str, str._str);
}
コード例 #12
0
// Mutators
// Set password assumes two identical password strings
bool User::setPassword( const MyString& new1, const MyString& new2){
	if (new1.length()<6 || !new1.compare(new2)) return false;
	mPassword.changeTo(new1);	// change password
	return true;
}