示例#1
0
文件: lesson22.cpp 项目: alexrao/nehe
// isMultitextureSupported() Checks At Run-Time If Multitexturing Is Supported
bool initMultitexture(void) {

	char *extensions;	

	extensions=strdup((char *) glGetString(GL_EXTENSIONS));			// Fetch Extension String
	int len=strlen(extensions);

	for (int i=0; i<len; i++)										// Separate It By Newline Instead Of Blank
		if (extensions[i]==' ') extensions[i]='\n';

#ifdef EXT_INFO
	printf("supported GL extensions\n%s", extensions);
#endif

	if (isInString(extensions,"GL_ARB_multitexture")				// Is Multitexturing Supported?
		&& __ARB_ENABLE												// Override-Flag
		&& isInString(extensions,"GL_EXT_texture_env_combine"))		// Is texture_env_combining Supported?
	{	


#ifdef EXT_INFO
		printf("\nThe GL_ARB_multitexture extension will be used.\n");
#endif
		return true;
	}
	useMultitexture=false;											// We Can't Use It If It Isn't Supported!
	return false;
}
示例#2
0
bool Terrain::initMultitexture(void)
{
	char *extensions;	
	extensions=strdup((char *) glGetString(GL_EXTENSIONS));			// Fetch Extension String
	int len=strlen(extensions);
	for (int i=0; i<len; i++)										// Separate It By Newline Instead Of Blank
		if (extensions[i]==' ') extensions[i]='\n';

#ifdef EXT_INFO
	MessageBox(hWnd,extensions,"supported GL extensions",MB_OK | MB_ICONINFORMATION);
#endif

	if (isInString(extensions,"GL_ARB_multitexture")				// Is Multitexturing Supported?
		&& __ARB_ENABLE												// Override-Flag
		&& isInString(extensions,"GL_EXT_texture_env_combine"))		// Is texture_env_combining Supported?
	{	
		glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB,&maxTexelUnits);
		glMultiTexCoord1fARB	= (PFNGLMULTITEXCOORD1FARBPROC)		wglGetProcAddress("glMultiTexCoord1fARB");
		glMultiTexCoord2fARB	= (PFNGLMULTITEXCOORD2FARBPROC)		wglGetProcAddress("glMultiTexCoord2fARB");
		glActiveTextureARB		= (PFNGLACTIVETEXTUREARBPROC)		wglGetProcAddress("glActiveTextureARB");
		glClientActiveTextureARB= (PFNGLCLIENTACTIVETEXTUREARBPROC)	wglGetProcAddress("glClientActiveTextureARB");		
#ifdef EXT_INFO
	MessageBox(hWnd,"The GL_ARB_multitexture extension will be used.","feature supported!",MB_OK | MB_ICONINFORMATION);
#endif
		return true;
	}
	useMultitexture=false;											
	return false;
}
示例#3
0
/* Test all of the differences possibilites of command */
int commandType(void)
{
	static const command baseCommandType[NUMBER_COMMAND] =
	{
		{"add", 		C_ARITHMETIC},
		{"sub", 		C_ARITHMETIC},
		{"neg", 		C_ARITHMETIC},
		{"eq", 		C_ARITHMETIC},
		{"gt", 		C_ARITHMETIC},
		{"lt", 		C_ARITHMETIC},
		{"and", 		C_ARITHMETIC},
		{"or", 		C_ARITHMETIC},
		{"not", 		C_ARITHMETIC},
		{"push", 		C_PUSH},
		{"pop", 		C_POP},
		{"label", 		C_LABEL},
		{"if-goto",		C_IF},
		{"goto", 		C_GOTO},
		{"function", 	C_FUNCTION},
		{"return", 		C_RETURN},
		{"call", 		C_CALL}
	};
	int indexCommand;

	/* Test all commands */
	for(indexCommand = 0; indexCommand < NUMBER_COMMAND; ++indexCommand)
	{
		if(isInString(currentCommand, baseCommandType[indexCommand].name))
			return baseCommandType[indexCommand].type;
	}

	return C_ERROR;
}
int main(void)
{
	char string1[500], string2[500];
	char *ptr1 = NULL;
	char *ptr2 = NULL;
	int result;
	int i = 0, size1 = -1, size2 = -1;//size is the size of the first and second substring
	printf("Please type in the first string:\n");
	ptr1 = fgets(string1,100,stdin);
		while (*(ptr1 + i) != 0)//finds the size of the first array
		{
			i++;
			size1++;
		}
	
	printf("Please type in the second string:\n");
	ptr2 = fgets(string2,100,stdin);
	i=0;
		while (*(ptr2 + i) != 0)//finds the size of the second array
		{
			i++;
			size2+=1;
		}

	//printf("ptr1 = %sptr2 = %s",ptr1,ptr2);


	result = isSubString(ptr1, ptr2, size1);

	if (result == 1)
		printf("\nThe second string is a substring of the first string\n\n");
	else if (result == 0)
		printf("The second string is a NOT substring of the first string\n\n");
		/*not a substring*/

	result = isPrefix(ptr1, ptr2, size1);

	if (result == 1)
		printf("The second string is a prefix of the first string\n\n");
	else if (result == 0)
		printf("The second string is NOT a prefix of the first string\n\n");

	result = isPostFix(ptr1, ptr2, size1);

	if (result == 1)
		printf("The second string is a postfix of the first string\n\n");
	else
		printf("The second string NOT is a postfix of the first string\n\n");

	result =isInString(ptr1, ptr2, size1, size2);

	if (result == 1)
		printf("The second string is the same as the first string.\n\n");
	else if (result == 0)
		printf("The second string is NOT the same as the first string.\n\n");

	return 0;
}
示例#5
0
bool NEHE22::initMultitexture() {
    char *extensions;
    extensions=strdup((char *) glGetString(GL_EXTENSIONS));	// Fetch Extension String
    size_t len=strlen(extensions);
    for (int i=0; i<len; i++)	// Separate It By Newline Instead Of Blank
        if (extensions[i]==' ') extensions[i]='\n';
	
    if (isInString(extensions,"GL_ARB_multitexture")	// Is Multitexturing Supported?
        && __ARB_ENABLE	// Override Flag
        //&& isInString(extensions,"GL_EXT_texture_env_combine")	// texture-environment-combining supported?
		&& isInString(extensions,"GL_ARB_texture_env_combine")	// texture-environment-combining supported?
		){
        glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB,&maxTexelUnits);
		
		return true;
    }
	
    useMultitexture=false;	// We Can't Use It If It Isn't Supported!
    return false;
}
示例#6
0
Device::weakPasswordEnum Device::isPasswordWeak(const char *password, const char *username)
{
	// Variables...
	string tempPassword;
	size_t charPosition;
	bool contUpper = false;
	bool contLower = false;
	bool contUpperOrLower = false;
	bool contNumber = false;
	bool contSpecial = false;
	unsigned int loop = 0;
	unsigned int hitCount = 0;
	unsigned int position = 0;

	// Check length first
	if (config->minimumPasswordLength != 0)
	{
		if (config->minimumPasswordLength > strlen(password))
			return Device::passwordShort;
	}

	// Get password components
	for (loop = 0; loop < strlen(password); loop++)
	{
		// check for lowercase
		if ((password[loop] > 96) && (password[loop] < 123))
		{
			contLower = true;
			contUpperOrLower = true;
		}

		// check for upper
		else if ((password[loop] > 64) && (password[loop] < 91))
		{
			contUpper = true;
			contUpperOrLower = true;
		}

		// check for number
		else if ((password[loop] > 47) && (password[loop] < 58))
			contNumber = true;

		// check for special chars
		else
			contSpecial = true;
	}

	// Check password components
	if ((config->passwordsMustIncludeLowers == true) && (contLower == false))
		return passwordMakeup;
	if ((config->passwordsMustIncludeUppers == true) && (contUpper == false))
		return passwordMakeup;
	if ((config->passwordsMustIncludeEitherCase == true) && (contUpperOrLower == false))
		return passwordMakeup;
	if ((config->passwordsMustIncludeNumbers == true) && (contNumber == false))
		return passwordMakeup;
	if ((config->passwordsMustIncludeSpecials == true) && (contSpecial == false))
		return passwordMakeup;

	// Check Character Reuse...
	if (config->maximumRepeatedChars > 0)
	{
		for (loop = 0; loop < strlen(password); loop++)
		{
			position = loop + 1;
			hitCount = 0;
			while (password[position] != 0)
			{
				if (password[position] == password[loop])
				{
					hitCount++;
					if (hitCount > config->maximumRepeatedChars)
						return passwordRepeatChars;
				}
				position++;
			}
		}
	}

	// Check username in password...
	if ((config->differentFromHostname == true) && (username != 0))
	{
		if (isInString(password, username) == true)
			return passwordUsername;
	}

	if (general != 0)
	{
		// Check hostname in password...
		if ((config->differentFromHostname == true) && (!general->hostname.empty()))
		{
			if (isInString(password, general->hostname.c_str()) == true)
				return passwordHostname;
		}
	}

	// Check device information in password...
	if ((config->differentFromHostname == true) && (deviceModel != 0))
	{
		if (isInString(password, deviceModel) == true)
			return passwordDeviceInfo;
	}
	if ((config->differentFromHostname == true) && (deviceMake != 0))
	{
		if (isInString(password, deviceMake) == true)
			return passwordDeviceInfo;
	}

	// Check dictionary character substitutions...
	if (config->noDictionaryCharacterSubst == true)
	{
		// 1's
		if (strchr(password, '1') != 0)
		{
			tempPassword.assign(password);
			charPosition = tempPassword.find('1');
			while (charPosition != tempPassword.npos)
			{
				tempPassword.replace(charPosition, 1, 1, 'i');
				charPosition = tempPassword.find('1');
			}
			if (isDictionaryPassword(tempPassword.c_str()) == true)
				return passwordDictSubst;
			// Incl 3's
			if (strchr(password, '3') != 0)
			{
				charPosition = tempPassword.find('3');
				while (charPosition != tempPassword.npos)
				{
					tempPassword.replace(charPosition, 1, 1, 'e');
					charPosition = tempPassword.find('3');
				}
				if (isDictionaryPassword(tempPassword.c_str()) == true)
					return passwordDictSubst;
			}
			// Incl 5's
			if (strchr(password, '5') != 0)
			{
				charPosition = tempPassword.find('5');
				while (charPosition != tempPassword.npos)
				{
					tempPassword.replace(charPosition, 1, 1, 's');
					charPosition = tempPassword.find('5');
				}
				if (isDictionaryPassword(tempPassword.c_str()) == true)
					return passwordDictSubst;
			}
			// Incl 0's
			if (strchr(password, '0') != 0)
			{
				charPosition = tempPassword.find('0');
				while (charPosition != tempPassword.npos)
				{
					tempPassword.replace(charPosition, 1, 1, 'o');
					charPosition = tempPassword.find('0');
				}
				if (isDictionaryPassword(tempPassword.c_str()) == true)
					return passwordDictSubst;
			}
		}

		// 3's
		if (strchr(password, '3') != 0)
		{
			tempPassword.assign(password);
			charPosition = tempPassword.find('3');
			while (charPosition != tempPassword.npos)
			{
				tempPassword.replace(charPosition, 1, 1, 'e');
				charPosition = tempPassword.find('3');
			}
			if (isDictionaryPassword(tempPassword.c_str()) == true)
				return passwordDictSubst;
			// Incl 5's
			if (strchr(password, '5') != 0)
			{
				charPosition = tempPassword.find('5');
				while (charPosition != tempPassword.npos)
				{
					tempPassword.replace(charPosition, 1, 1, 's');
					charPosition = tempPassword.find('5');
				}
				if (isDictionaryPassword(tempPassword.c_str()) == true)
					return passwordDictSubst;
			}
			// Incl 0's
			if (strchr(password, '0') != 0)
			{
				charPosition = tempPassword.find('0');
				while (charPosition != tempPassword.npos)
				{
					tempPassword.replace(charPosition, 1, 1, 'o');
					charPosition = tempPassword.find('0');
				}
				if (isDictionaryPassword(tempPassword.c_str()) == true)
					return passwordDictSubst;
			}
		}

		// 5's
		if (strchr(password, '5') != 0)
		{
			tempPassword.assign(password);
			charPosition = tempPassword.find('5');
			while (charPosition != tempPassword.npos)
			{
				tempPassword.replace(charPosition, 1, 1, 's');
				charPosition = tempPassword.find('5');
			}
			if (isDictionaryPassword(tempPassword.c_str()) == true)
				return passwordDictSubst;
			// Incl 0's
			if (strchr(password, '0') != 0)
			{
				charPosition = tempPassword.find('0');
				while (charPosition != tempPassword.npos)
				{
					tempPassword.replace(charPosition, 1, 1, 'o');
					charPosition = tempPassword.find('0');
				}
				if (isDictionaryPassword(tempPassword.c_str()) == true)
					return passwordDictSubst;
			}
		}

		// 0's
		if (strchr(password, '0') != 0)
		{
			tempPassword.assign(password);
			charPosition = tempPassword.find('0');
			while (charPosition != tempPassword.npos)
			{
				tempPassword.replace(charPosition, 1, 1, 'o');
				charPosition = tempPassword.find('0');
			}
			if (isDictionaryPassword(tempPassword.c_str()) == true)
				return passwordDictSubst;
		}
	}

	// Check dictionary appends...
	if (config->noCommonDictionaryAppends == true)
	{
		// 1
		if (password[strlen(password) - 1] == '1')
		{
			tempPassword.assign(password);
			tempPassword.resize(tempPassword.length() - 1);
			if (isDictionaryPassword(tempPassword.c_str()) == true)
				return passwordDictAppend;
		}

		// 1!
		else if ((password[strlen(password) - 2] == '1') && (password[strlen(password) - 1] == '!'))
		{
			tempPassword.assign(password);
			tempPassword.resize(tempPassword.length() - 2);
			if (isDictionaryPassword(tempPassword.c_str()) == true)
				return passwordDictAppend;
		}

		// 12
		else if ((password[strlen(password) - 2] == '1') && (password[strlen(password) - 1] == '2'))
		{
			tempPassword.assign(password);
			tempPassword.resize(tempPassword.length() - 2);
			if (isDictionaryPassword(tempPassword.c_str()) == true)
				return passwordDictAppend;
		}

		// 123
		else if ((password[strlen(password) - 3] == '1') && (password[strlen(password) - 2] == '2') && (password[strlen(password) - 1] == '3'))
		{
			tempPassword.assign(password);
			tempPassword.resize(tempPassword.length() - 2);
			if (isDictionaryPassword(tempPassword.c_str()) == true)
				return passwordDictAppend;
		}

		// !
		if (password[strlen(password) - 1] == '!')
		{
			tempPassword.assign(password);
			tempPassword.resize(tempPassword.length() - 1);
			if (isDictionaryPassword(tempPassword.c_str()) == true)
				return passwordDictAppend;
		}
	}

	// Check for character sequences in password...
	if (config->noCharacterSequences == true)
	{
		if (strstr(password, "1234") != 0)
			return passwordCharSeq;
		if (isInString(password, "qwerty") == true)
			return passwordCharSeq;
		if (isInString(password, "abcd") == true)
			return passwordCharSeq;
	}

	return passwordPassed;
}