Ejemplo n.º 1
0
int _CRTAPI1 main(int argc, char *argv[])	{

	DWORD 	dwT;

	LPTSTR 	strDriveLetters = (LPTSTR) malloc(sizeof(char) * BUFSIZE);
	LPTSTR 	strNext;

	if(strDriveLetters == NULL)	{
		printf("Error allocating buffer (%d)\n", GetLastError());
		exit(-1);
	}

	dwT = QueryDosDevice(NULL, strDriveLetters, BUFSIZE);

	if(dwT == 0)	{
		printf("Error getting device letters (%d)\n", GetLastError());
		exit(-2);
	}

	strNext = strDriveLetters;

	while(1)	{
		processDevice(strNext);

		// get the address of the next address
		strNext += strlen(strNext) + 1;

		// if the next string is the NUL string, then return NULL
		if(*strNext == '\0')	break;
   	}


	free(strDriveLetters);
	return 0;
}
Ejemplo n.º 2
0
int CheckPointDevice::process()
{
	// Variables...
	policyCollections *policyPointer = 0;
	string configDirectory;
	string tempFilename;
	struct stat *fileStats = 0;
	int returnCode = 0;
	bool addedPolicies = false;

	/*
		CheckPoint files to process...

		Key:
			* tables.C - Contains a list of the other files...

		Objects:
			* objects_5_0.C
			* objects.C_41
			* objects.C

		Rules:
			* *.W files
			* rules.C

		Rules + Comments:
			* rulebases_5_0.fws
			* rulebases.fws

		Users:
			* fwauth.NDB
	*/

	// Check if input is a directory (required)...
	fileStats = new (struct stat);
	memset(fileStats, 0, sizeof(struct stat));
	stat(config->inputSource, fileStats);
	if ((fileStats->st_mode & S_IFMT) != S_IFDIR)
	{
		delete fileStats;
		return deviceerror_inputnotadirectory;
	}
	delete fileStats;

	// Add Directory slash if it does not already exist
	configDirectory.assign(config->inputSource);
#if !defined(__WIN32__)
	if (configDirectory.c_str()[configDirectory.length() - 1] != '/')
		configDirectory.append("/");
#else
	if (configDirectory.c_str()[configDirectory.length() - 1] != '\\')
		configDirectory.append("\\");
#endif

	// Process CheckPoint Object Files...
	tempFilename.assign(configDirectory);
	tempFilename.append("objects_5_0.C");
	config->inputSource = tempFilename.c_str();
	returnCode = openInput();
	if (returnCode != 0)
	{
		tempFilename.assign(configDirectory);
		tempFilename.append("objects.C_41");
		config->inputSource = tempFilename.c_str();
		returnCode = openInput();
		if (returnCode != 0)
		{
			tempFilename.assign(configDirectory);
			tempFilename.append("objects.C");
			config->inputSource = tempFilename.c_str();
			returnCode = openInput();
		}
	}
	if (returnCode != 0)
		return deviceerror_objectsfilenotfound;
	returnCode = processDevice();
	fclose(inputFile);
	if (returnCode != 0)
		return returnCode;

	// Process CheckPoint Rules Files...

	// Try policy collection first...
	policyPointer = policies;
	while (policyPointer != 0)
	{
		tempFilename.assign(configDirectory);
		tempFilename.append(policyPointer->policyName);
		tempFilename.append(".W");
		config->inputSource = tempFilename.c_str();
		returnCode = openInput();
		if (returnCode == 0)
		{
			returnCode = ((CheckPointFilter *)filter)->processWRulesDevice(this, policyPointer->policyName.c_str(), policyPointer->active);
			fclose(inputFile);
			addedPolicies = true;
		}
		policyPointer = policyPointer->next;
		returnCode = 0;
	}

	// If policies still have not been added...
	if (addedPolicies == false)
	{
		tempFilename.assign(configDirectory);
		tempFilename.append("rules.C");
		config->inputSource = tempFilename.c_str();
		returnCode = openInput();
		if (returnCode == 0)
		{
			returnCode = ((CheckPointFilter *)filter)->processRRulesDevice(this);
			fclose(inputFile);
		}
	}

	// Process CheckPoint Rules With Comments Files...
	tempFilename.assign(configDirectory);
	tempFilename.append("rulebases_5_0.fws");
	config->inputSource = tempFilename.c_str();
	returnCode = openInput();
	if (returnCode != 0)
	{
		tempFilename.assign(configDirectory);
		tempFilename.append("rulebases.fws");
		config->inputSource = tempFilename.c_str();
		returnCode = openInput();
	}
	if (returnCode == 0)
	{
		returnCode = ((CheckPointFilter *)filter)->processFRulesDevice(this);
		fclose(inputFile);
	}
	else
		returnCode = 0;

	// Process Users...

	// Post processing defaults...
	setPostCommonDefaults();

	// Post device specific processing defaults...
	setPostDefaults();

	return returnCode;
}