Esempio n. 1
0
void PHIParent::invalidate( const QString &domain )
{
    qDebug( "invalidate '%s'", qPrintable( domain.isEmpty() ? QLatin1String( "all" ) : domain ) );
    PHISModuleFactory::instance( this )->invalidate();
    _lock.lockForWrite();
    _loadedModules=PHISModuleFactory::instance( this )->loadedModules();
    _moduleLoadErrors=PHISModuleFactory::instance( this )->loadErrors();
    if ( domain.isEmpty() ) {
        QString tmpDir;
        foreach( tmpDir, _tmpDirs ) clearTmpDir( tmpDir );
        _tmpDirs.clear();
        _dbSettings.clear();
        /*
        PHILicense *l;
        foreach ( l, _licenses ) delete l;
        _licenses.clear();
        _licenses.insert( "localhost", new PHILicense() );
        _validLicenses.clear();
        _validLicenses.insert( "localhost", true );
        */
    } else {
        clearTmpDir( _tmpDirs.value( domain ) );
        _tmpDirs.remove( domain );
        _dbSettings.remove( domain );
        /*
        if ( domain!="localhost" ) {
            PHILicense *l;
            l=_licenses.value( domain, 0 );
            delete l;
            _licenses.remove( domain );
            _validLicenses.remove( domain );
        }
        */
    }
    _lock.unlock();
    PHISPageCache::invalidate();
    // PHISItemCache::instance()->invalidate(); // done by PHISPageCache::invalidate()
}
Esempio n. 2
0
int main(int argc, char ** argv) {
	mutex = Mutex_Create(MUTEX_MODE_NORMAL);
	uuid_t uuid;
	struct FileDefinition * f;
	int c, daemon = 0;
	uuid_clear(uuid);
	int prev = 0;
	int limit = 0;
	while (true) {
		 /* getopt_long stores the option index here. */
		 int option_index = 0;
		 c = getopt_long (argc, argv, "c:f:w:t:u:d", options, &option_index);
		/* Detect the end of the options. */

		if (c != -1 && optind > prev) {
			limit = optind - 1;
		} else {
			limit = argc;
		}

		for (prev++; prev < limit; prev++) {
			printf("val = %s, len = %lu\n", argv[prev], strlen(argv[prev]));
			if (strlen(argv[prev]) == 0)
				continue;
			rzb_log (LOG_DEBUG,"Positional argument %d  %s",prev, argv[prev]);
			f = createFileDefinition(argv[prev],uuid);
			Mutex_Lock(mutex);
			pushFileList(f);
			Mutex_Unlock(mutex);
		}


		if (c == -1)
			 break;

		 switch (c) {
			case 'c':
			 rzb_log (LOG_DEBUG,"option -c with value `%s'", optarg);
			 break;

			case 'f':
				f = createFileDefinition(optarg,uuid);
				Mutex_Lock(mutex);
				pushFileList(f);
				Mutex_Unlock(mutex);
				rzb_log (LOG_DEBUG,"option -f with value `%s'", optarg);
			 break;

			case 'w':
				rzb_log (LOG_DEBUG,"option -w with value `%s'", optarg);
			 break;

			case 'd':
				daemon = 1;
			 break;

			case 'u':
				rzb_log (LOG_DEBUG,"option -u with value `%s'", optarg);
				uuid_parse(optarg,uuid);
			break;

			case 't':
				rzb_log (LOG_DEBUG,"option -t with value `%s'", optarg);
				UUID_Get_UUID(optarg,UUID_TYPE_DATA_TYPE,uuid);
			break;

			case '?':
				rzb_log (LOG_DEBUG,"no option with value `%s'", optarg);
			 /* getopt_long already printed an error message. */
			break;

			default:
				rzb_log (LOG_DEBUG,"no option with value `%s'", optarg);
			 //abort ();
		}
	}

	if (daemon)
		initListenerThread();
	//RZB_Init_API();
	if (!initNug()) {
		rzb_log(LOG_ERR, "initNug failed");
		exit(-1);
	}
	rzb_log(LOG_INFO, "Done initNug");
	struct FileDefinition * tmp;
	while (!endScan) {
		if (fileList == NULL) {
			if (daemon == 0)
				break;
			usleep(500000);
			continue;
		}

		clearTmpDir();
		Mutex_Lock(mutex);
		tmp = shiftFileList();
		if (strlen(tmp->path) == 0) {
			destroyFileDefinition(tmp);
			continue;
		}
		fprintf(stderr, "value = '%s'\n", tmp == NULL ? "NULL" : tmp->path);
		Mutex_Unlock(mutex);
		rzb_log(LOG_NOTICE, "Inspecting %s",tmp->path);
		if (testFile(tmp->path)) {
			inspectFile(tmp->path,tmp->uuid);
		}
		rzb_log(LOG_NOTICE, "Done inspecting %s",tmp->path);
		destroyFileDefinition(tmp);
		rzb_log(LOG_INFO, "FINISHED");
	}

	shutdownNug();
	Mutex_Destroy(mutex);

	rzb_log(LOG_INFO, "Done shutdownNug");
}