예제 #1
0
 /// Create a domain from the input workspace
 void MultiDomainCreator::createDomain(
   boost::shared_ptr<API::FunctionDomain>& domain, 
   boost::shared_ptr<API::IFunctionValues>& ivalues, size_t i0)
 {
   if (m_workspacePropertyNames.size() != m_creators.size())
   {
     throw std::runtime_error("Cannot create JointDomain: number of workspaces does not match "
       "the number of creators");
   }
   auto jointDomain = new API::JointDomain;
   API::IFunctionValues_sptr values;
   i0 = 0;
   for(auto c = m_creators.begin(); c != m_creators.end(); ++c)
   {
     if (!(*c))
     {
       throw std::runtime_error("Missing domain creator");
     }
     API::FunctionDomain_sptr domain;
     (**c).createDomain(domain,values,i0);
     jointDomain->addDomain(domain);
     i0 += domain->size();
   }
   domain.reset(jointDomain);
   ivalues = values;
 }
예제 #2
0
bool RuleList::addURL(QString appName, QUrl url)
{
	// Add the domain for the current url
	addDomain(appName, url.host(), url.port());

	cacheThread.updateCache(appName, url);

	return true;
}
예제 #3
0
파일: main.c 프로젝트: moikop/ab
int loadTree(tdns *dns, char *configFile) {
    FILE *cfile;
    tdomain temp;
    char line[MAX_LINE];
    char Ipa[IP_MAX*2];
    char url[DOMAIN_TAG_MAX*2];
    char* buffer;
    char url_aux[DOMAIN_TAG_MAX*2];
    int error;

    cfile = fopen(configFile, "r");
    if(!cfile) {
        printf("No se pudo abrir el archivo de configuracion.\n");
        return RES_ERROR;
    }
    printf("loadTree: se pudo abrir el archivo de configuracion.\n");
    printf("loadTree: empiezo a recorrer el archivo de configuracion.\n");

    while(!feof(cfile)) {
        if (fgets(line, MAX_LINE-1, cfile)) {
            printf("loadTree: tomo una linea.\n");

            buffer = strtok(line," ");
            printf("loadTree: primer palabra = %s\n",buffer);
            strcpy(url, buffer);
            buffer = strtok(NULL," ");
            printf("loadTree: segunda palabra = %s\n",buffer);
            strcpy(Ipa, buffer);

            if(validateURL(url)!=RES_OK && validateIP(Ipa)!=RES_OK) {
                printf("loadTree: par url-ip no validos.\n");
                printf("loadTree: url = %s, ip = %s\n",url,Ipa);
                fclose(cfile);
                return RES_ERROR;
                /** De aca tiene que eliminar el TDA DNS**/
            }
            strcpy(url_aux,url);
            buffer = strtok(url_aux,DOT);
            strcpy(temp.domain,buffer);
            strcpy(temp.ip,Ipa);
            temp.offset = genoffset(url);
            AB_Crear(&(temp.subab),sizeof(tdomain));
            printf("loadTree: url = %s, ip = %s, offset = %c\n",url,Ipa,temp.offset);

            error = addDomain(dns,url,&temp);
            if(error!=RES_OK) {
                printf("loadTree: No se pudo agregar al arbol de DNS.\n");
                fclose(cfile);
                return error;
            }
        }
    }
    fclose(cfile);
    return RES_OK;
}
예제 #4
0
void ServiceBrowser::startBrowse()
{
	if (d->m_running) return;
	d->m_running=true;
	if (isAvailable()!=Working) return;
	if (d->m_domains->isRunning()) {
		QStringList::const_iterator itEnd  = d->m_domains->domains().end();
		for ( QStringList::const_iterator it = d->m_domains->domains().begin(); it != itEnd; ++it )
			addDomain(*it);
	} else d->m_domains->startBrowse();
}
예제 #5
0
파일: external.cpp 프로젝트: grote/oclingo
bool External::grounded(Grounder *g)
{
	head_->grounded(g);
	if (head_->fact()) { return true; }
	addDomain(g);
	Printer *printer = g->output()->printer<Printer>();
	printer->begin();
	if(head_.get()) { head_->accept(printer); }
	printer->endHead();
	foreach(Lit &lit, body_)
	{
		lit.grounded(g);
		if(!lit.fact()) { lit.accept(printer); }
		else if(lit.forcePrint()) { lit.accept(printer); }
	}
예제 #6
0
파일: inetLib.c 프로젝트: phoboz/vmx
void inetLibInit(void)
{
    addDomain(&inetdomain);
}
예제 #7
0
 void tuple_computer_base<VarCount, CounterT>::domain(tuple_set_type& domain)const
 {
     domain.clear();
     addDomain(domain);
 }
예제 #8
0
void ConfigManager::loadFromStream(SeekableReadStream &stream) {
	String domainName;
	String comment;
	Domain domain;
	int lineno = 0;

	_appDomain.clear();
	_gameDomains.clear();
	_miscDomains.clear();
	_transientDomain.clear();
	_domainSaveOrder.clear();

#ifdef ENABLE_KEYMAPPER
	_keymapperDomain.clear();
#endif

	// TODO: Detect if a domain occurs multiple times (or likewise, if
	// a key occurs multiple times inside one domain).

	while (!stream.eos() && !stream.err()) {
		lineno++;

		// Read a line
		String line = stream.readLine();

		if (line.size() == 0) {
			// Do nothing
		} else if (line[0] == '#') {
			// Accumulate comments here. Once we encounter either the start
			// of a new domain, or a key-value-pair, we associate the value
			// of the 'comment' variable with that entity.
			comment += line;
#ifdef _WIN32
			comment += "\r\n";
#else
			comment += "\n";
#endif
		} else if (line[0] == '[') {
			// It's a new domain which begins here.
			// Determine where the previously accumulated domain goes, if we accumulated anything.
			addDomain(domainName, domain);
			domain.clear();
			const char *p = line.c_str() + 1;
			// Get the domain name, and check whether it's valid (that
			// is, verify that it only consists of alphanumerics,
			// dashes and underscores).
			while (*p && (isalnum(*p) || *p == '-' || *p == '_'))
				p++;

			if (*p == '\0')
				error("Config file buggy: missing ] in line %d", lineno);
			else if (*p != ']')
				error("Config file buggy: Invalid character '%c' occurred in section name in line %d", *p, lineno);

			domainName = String(line.c_str() + 1, p);

			domain.setDomainComment(comment);
			comment.clear();

		} else {
			// This line should be a line with a 'key=value' pair, or an empty one.

			// Skip leading whitespaces
			const char *t = line.c_str();
			while (isspace(*t))
				t++;

			// Skip empty lines / lines with only whitespace
			if (*t == 0)
				continue;

			// If no domain has been set, this config file is invalid!
			if (domainName.empty()) {
				error("Config file buggy: Key/value pair found outside a domain in line %d", lineno);
			}

			// Split string at '=' into 'key' and 'value'. First, find the "=" delimeter.
			const char *p = strchr(t, '=');
			if (!p)
				error("Config file buggy: Junk found in line line %d: '%s'", lineno, t);

			// Extract the key/value pair
			String key(t, p);
			String value(p + 1);

			// Trim of spaces
			key.trim();
			value.trim();

			// Finally, store the key/value pair in the active domain
			domain[key] = value;

			// Store comment
			domain.setKVComment(key, comment);
			comment.clear();
		}
	}

	addDomain(domainName, domain); // Add the last domain found
}
예제 #9
0
void ConfigFile::load(SeekableReadStream &stream) {
	UString comment;

	ConfigDomain *domain = 0;

	int lineNumber = 0;
	int domainLineNumber = 0;
	while (!stream.eos()) {
		lineNumber++;

		// Read a line
		UString line = readStringLine(stream, kEncodingUTF8);

		// Parse it
		UString domainName;
		UString key, value, lineComment;
		parseConfigLine(line, domainName, key, value, lineComment, lineNumber);

		if (!domainName.empty()) {
			// New domain

			// Finish up the old domain
			addDomain(domain, domainLineNumber);

			// Check that the name is actually valid
			if (!isValidName(domainName))
				throw Exception("\"%s\" isn't a valid domain name (line %d)",
						domainName.c_str(), lineNumber);

			// Create the new domain
			domain = new ConfigDomain(domainName);

			domain->_prologue = comment;
			domain->_comment  = lineComment;

			comment.clear();
			lineComment.clear();

			domainLineNumber = lineNumber;
		}

		if (!key.empty()) {
			// New key

			if (!domain)
				throw Exception("Found a key outside a domain (line %d)", lineNumber);

			if (!isValidName(key))
				throw Exception("\"%s\" isn't a valid key name (line %d)",
						key.c_str(), lineNumber);

			// Add collected comments to the domain
			if (!comment.empty())
				addDomainKey(*domain, "", "", comment, lineNumber);

			// Add the key to the domain
			addDomainKey(*domain, key, value, lineComment, lineNumber);

			comment.clear();
			lineComment.clear();
		}

		// Collect comments, we don't yet know where those belong to.
		if (!lineComment.empty()) {
			if (!comment.empty())
				comment += '\n';
			comment += lineComment;
		}

		// Empty line, associate collected comments with the current domain
		if (domainName.empty() && key.empty() && value.empty() && lineComment.empty()) {
			if (!comment.empty() && !stream.eos()) {

				if (!domain) {
					// We have no domain yet, add it to the file's prologue
					if (!_prologue.empty())
						_prologue += '\n';
					_prologue += comment;
				} else
					addDomainKey(*domain, "", "", comment, lineNumber);

				comment.clear();
			}
		}

	}

	// Finish up the last domain
	addDomain(domain, domainLineNumber);

	// We still have comments, those apparently belong to the bottom of the file
	if (!comment.empty())
		_epilogue = comment;
}
예제 #10
0
파일: main.c 프로젝트: moikop/ab
int processData(tdns* dns,char** argv,char* cmd,FILE* logf) {

    tdomain data;
    tdomain td;
    char ip_origen[IP_MAX];
    char ip_destino[IP_MAX];
    char msg[300];

    if(strcmp(argv[1],CMD_SEND)==0) {
        if(urlExists(*dns,argv[2])!=RES_OK) return RES_ERROR;
        if(urlExists(*dns,argv[3])!=RES_OK) return RES_ERROR;
        getValue(dns,argv[2],&data);
        strcpy(ip_origen,data.ip);
        getValue(dns,argv[3],&data);
        strcpy(ip_destino,data.ip);
        encryptMsg(msg,data.offset);
        log(logf,CMD_SEND,argv[2],ip_origen,argv[3],ip_destino,argv[3],msg);
        printf("Mensaje encriptado: %s\n",msg);
    }
    else if(strcmp(argv[1],CMD_GETIP)==0) {
            printf("Entré en  getip\n");
        if(urlExists(*dns,argv[2])!=RES_OK) return RES_ERROR;
        if(urlExists(*dns,argv[3])!=RES_OK) return RES_ERROR;
        getValue(dns,argv[2],&data);
        strcpy(ip_origen,data.ip);
        getValue(dns,argv[3],&data);
        strcpy(ip_destino,data.ip);
        log(logf,CMD_GETIP,argv[2],ip_origen,argv[3],ip_destino,"","");
        printf("Origen: %s %s\nDestino: %s %s\n",argv[2],ip_origen,argv[3],ip_destino);
    }
    else if(strcmp(argv[1],CMD_ADDDOMAIN)==0) {
        if(urlExists(*dns,argv[2])==RES_OK) {
            printf("Ya existe %s.\n",argv[2]);
            return RES_ERROR;
        }
        strcpy(td.domain,argv[2]);
        strcpy(td.ip,argv[3]);
        genoffset(td.domain);
        getoffset(td.domain,&(td.offset));
        AB_Crear(&(td.subab),sizeof(tdomain));
        if(addDomain(dns,argv[2],&td)!=RES_OK) return RES_ERROR;
        log(logf,CMD_ADDDOMAIN,argv[2],argv[3],"","","","");
        printf("Se agrego %s con direccion ip %s.\n",argv[2],argv[3]);
    }
    else if(strcmp(argv[1],CMD_DELETEDOMAIN) == 0) {
        if(urlExists(*dns,argv[2])!=RES_OK) {
            printf("No existe %s para eliminar.\n",argv[2]);
            return RES_ERROR;
        }
        getValue(dns,argv[2],&data);
        printf("Dato obtenido: %s %s.\n",data.domain,data.ip);
        strcpy(ip_origen,data.ip);
        deleteDomain(dns,argv[2]);
        log(logf,CMD_DELETEDOMAIN,argv[2],ip_origen,"","","","");
        printf("Se elimino a %s con ip %s.\n",argv[2],ip_origen);
    } else {
        printf("Comando equivocado.\n");
        showHelp(argv[0]);
        return RES_ERROR;
    }
    return RES_OK;
}