예제 #1
0
/* Returns the variable with the given name in the query.
   If not found:
   	if the query is running, return NULL
   	otherwise create a new variable with the given name.
   	if there isn't enough memory, return NULL.
*/
PR_PUBLIC_API(RDF_Variable) RDF_GetVariable(RDF_Query q, char* name) {
	RDF_Variable newvar;
	RDF_VariableList newlist;
	RDF_VariableList current = q->variables;
	while (current != NULL) {
		if (stringEquals(current->element->id, name)) return current->element;
		if (current->next == NULL) break;
		else current = current->next;
	}
	if (q->queryRunning) return NULL;
	newvar = (RDF_Variable)getMem(sizeof(RDF_VariableStruc));
	if (newvar == NULL) return NULL;
	newvar->id = copyString(name);
	newvar->query = q;
	/* create a list containing the variable and append it to the front of the variable list */
	newlist = (RDF_VariableList)getMem(sizeof(RDF_VariableListStruc));
	if (newlist == NULL) {
		freeMem(newvar);
		return NULL;
	}
	newlist->element = newvar;
	newlist->next = q->variables;
	q->variables = newlist;
	return newvar;
}
struct addrinfo *getAddressInfo(char *hostName, char *port) {
    //printf("Getting Address Info of host: %s port: %s\n",hostName, port);
    //hostName = "localhost";
    struct addrinfo hints, *host_info_list;
    memset(&hints, 0, sizeof hints); //clear any hint
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_family = AF_INET;
    hints.ai_protocol = IPPROTO_TCP;
    hints.ai_flags = AI_PASSIVE;
    int result;
    if (stringEquals(hostName, "localhost")) {
        result = getaddrinfo(NULL, port, &hints, &host_info_list);
    }
    else {
        result = getaddrinfo(hostName, port, &hints, &host_info_list);
    }
    if (result != 0 || host_info_list == NULL) {
        fprintf(stderr, "Error Getting AddressInfo: %s\n", gai_strerror(result));
        printf("Unable to get the AddressInfo. Please check the hostname/ipAddress provided.\n");
        return NULL;
    }

//    if(host_info_list->ai_next!=NULL)
//        cerr << "More than one IPv4 addresses returned";

    struct addrinfo *tempAddrInfo = host_info_list;
    return tempAddrInfo;
}
예제 #3
0
int connectToClient(char *hostName, char *port) {

    //check if the host is trying to connect to itself
    if ((stringEquals(hostName, myHostName) || stringEquals(hostName, myIpAddress))
            && (stringEquals(port, myListenerPort))) {
        printf("You can't connect to yourself.\n");
        return -1;
    }

    //Check if hostname/ip and port is registered to server
    if (!isHostPresent(peerList, hostName, port)) {
        printf("The client you are trying to connect to is not registered with the server.\n");
        return -1;
    }

    //duplicate connection
    if (isHostPresent(connectionList, hostName, port)) {
        printf("You are already connected to %s/%s.\n", hostName, port);
        return -1;
    }

    //check if the user entered a ipAddress or hostName
    if (stringEquals(getIpfromHost(hostName), hostName)) {
        //if true the user entered an ipaddress
        hostName = getHostFromIp(hostName);
    }

    //printf("Connecting to %s/%s.\n", hostName, port);

    int clientSockfd = connectToHost(hostName, port); //"localhost" should be hostName #needtomodify
    if (clientSockfd == -1) {
        fprintf(stderr, "Error connecting to client\n");
    }
    else {
        //add the client to the connectionList
        struct host *client = (struct host *) malloc(sizeof(struct host));
        client->id = connectionIdGenerator++;
        client->sockfd = clientSockfd;
        client->ipAddress = getIpfromHost(hostName);
        client->hostName = hostName;
        client->port = port;
        addNode(&connectionList, client);
        printf("Connected to %s/%s\n", client->hostName, client->port);
    }
    return 0;
}
예제 #4
0
cpConstraint *cpSpaceSerializer::createConstraint(TiXmlElement *elm)
{
	cpConstraint *constraint = NULL;
	
	const char* type = elm->Attribute("type");
	
	if (stringEquals(type, "pin"))
		constraint = createPinJoint(elm);
	else if (stringEquals(type, "slide"))
		constraint = createSlideJoint(elm);
	else if (stringEquals(type, "pivot"))
		constraint = createPivotJoint(elm);
	else if (stringEquals(type, "groove"))
		constraint = createGrooveJoint(elm);
	else if (stringEquals(type, "motor"))
		constraint = createMotorJoint(elm);
	else if (stringEquals(type, "gear"))
		constraint = createGearJoint(elm);
	else if (stringEquals(type, "spring"))
		constraint = createSpringJoint(elm);
	else if (stringEquals(type, "rotaryLimit"))
		constraint = createRotaryLimitJoint(elm);
	else if (stringEquals(type, "ratchet"))
		constraint = createRatchetJoint(elm);
	else if (stringEquals(type, "rotarySpring"))
		constraint = createRotarySpringJoint(elm);
	else
		return NULL;
	
	CPSS_ID id = createValue<CPSS_ID>("id", elm);
	constraint->maxForce = createValue<cpFloat>("maxForce", elm);
	constraint->errorBias = createValue<cpFloat>("errorBias", elm);
	constraint->maxBias = createValue<cpFloat>("maxBias", elm);
	
	if (delegate)
	{
		if (!delegate->reading(constraint, id))
		{
			cpConstraintFree(constraint);
			constraint = NULL;
		}
	}
	
	return constraint;
}
예제 #5
0
int find_name_already(char * name, char ** list, int count)
{
    int i;
    for (i = 0; i < count; i++)
    {
        if (stringEquals(name, list[i]))
            return true;
    }
    return false;
}
예제 #6
0
int get_r_request(int * list, char* name, int type, int log_count)
{
    int i, count = 0;
    for (i = 0; i < log_count; i++)
    {
        if (stringEquals(logarray[i].name, name) && logarray[i].type == type &&
                isRoom(logarray[i].where))
            list[count++] = logarray[i].where;
    }
    return count;
}
예제 #7
0
파일: source.c 프로젝트: aajarven/c
int locate_string(char **stringArray, char * string)
{
    int i=0;
    while(stringArray[i]!=0){
        if(stringEquals(stringArray[i], string)){
            return i;
        }
        i++;
    }
    return -1;
}
예제 #8
0
int check_if_in_room(char *name, int log_count,int roomid)
{
    int where = OUTGALARY;
    int i;
    for (i = 0; i < log_count; i++)
        if (stringEquals(logarray[i].name, name))
            where = logarray[i].where;

    if (where == roomid)
        return true;
    return false;
}
예제 #9
0
cpShape *cpSpaceSerializer::createShape(TiXmlElement *elm)
{
	cpShape *shape;
	
	const char* type = elm->Attribute("type");
	
	if (stringEquals(type, "circle"))
		shape = createCircle(elm);
	else if (stringEquals(type, "segment"))
		shape = createSegment(elm);
	else if (stringEquals(type, "poly"))
		shape = createPoly(elm);
	else
		return NULL;
	
	CPSS_ID id = createValue<CPSS_ID>("id", elm);
    _shapeMap[id] = shape;
	
	shape->sensor = createValue<int>("sensor", elm);
	shape->e = createValue<cpFloat>("e", elm);
	shape->u = createValue<cpFloat>("u", elm);
	shape->surface_v = createPoint("surface_v", elm);
	shape->collision_type = createValue<cpCollisionType>("collision_type", elm);
	shape->group = createValue<cpGroup>("group", elm);
	shape->layers = createValue<cpLayers>("layers", elm);
	
	if (delegate)
	{
		if (!delegate->reading(shape, id))
		{
            if (shape->body != _space->staticBody)
                cpBodyFree(shape->body);

            cpShapeFree(shape);
			shape = NULL;
		}
	}
	return shape;
}
예제 #10
0
unsigned int path_to_inum(int fd, std::vector<std::string>& path, int inum, int pathPos) {
	//dout << path << " " << inum << std::endl;
	//Get the first directory name in the path
	char delim = '/';
	std::string dir;
	if(pathPos < path.size()) {
		//Read the inode which represents a directory
		//and look for a file whose name matches dir
		dir = path[pathPos];
		char buffer[BLOCK_SIZE] = {};
		unsigned int block = 0;
		ByteAndBlock* rtnVal;
		rtnVal = copyBlock(fd, inum, block); 
		lseek(fd, rtnVal->block * BLOCK_SIZE, SEEK_SET);
		read(fd, buffer, BLOCK_SIZE);

		while(rtnVal->bytesRead > 0) {
			for(int offset = 0; offset < rtnVal->bytesRead; offset += DIR_SIZE) {
				std::string name(buffer + offset + sizeof(unsigned int), DIR_SIZE - sizeof(unsigned int));
				if(stringEquals(dir, name)) {
					delete rtnVal;
					return path_to_inum(fd, path, read_long(buffer + offset, sizeof(int)), pathPos + 1);
				}

			}
			delete rtnVal;

			rtnVal = copyBlock(fd, inum, block++); 
			lseek(fd, rtnVal->block * BLOCK_SIZE, SEEK_SET);
			read(fd, buffer, BLOCK_SIZE);
		}
		delete rtnVal;
		return -1;
	} else {
		return inum;
	}

}
예제 #11
0
void
possiblyAccessldap(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
{
  /** try to get the values of u.s from the directory **/

	LDAP		*ld;
	LDAPMessage	*result=NULL, *entry;
	LDAPURLDesc	*ldURL=NULL;
	RDF_Resource	node;
	char		*attrs[2], **vals;
	int		err, i;
	char		*title = NULL;

	/*
		Note: a labeledURI is a url followed by an optional [space title-string]
         */

  if (!stringEquals(resourceID(s), resourceID(gCoreVocab->RDF_parent)) || (!inversep) || (!ldap_is_ldap_url(resourceID(u))))	return;

  ldap_url_parse(resourceID(u), &ldURL);
  if (ldURL == NULL)	return;
  ld = ldap_init (ldURL->lud_host, ldURL->lud_port);
  if (ld == NULL)
	{
	ldap_free_urldesc(ldURL);
	return;
	}
  if ((err = ldap_simple_bind_s(ld, NULL, NULL)) != LDAP_SUCCESS)
	{
	ldap_unbind(ld);
	ldap_free_urldesc(ldURL);
	return;
	}

  attrs[0] = "labeledURI";
  attrs[1] = NULL;

  err = ldap_search_s(ld, ldURL->lud_dn, LDAP_SCOPE_BASE, ldURL->lud_filter, attrs, 0, &result);
  if (err == LDAP_SUCCESS)
	{
	for (entry=ldap_first_entry(ld, result); entry!=NULL; entry=ldap_next_entry(ld, entry))
		{
		if ((vals = ldap_get_values(ld, entry, attrs[0])) != NULL)
		{
			for (i=0; vals[i] != NULL; i++)
			{
				/* vals[i] has a URL... add into RDF graph */

/*
				if (((title = strstr(vals[i], " ")) != NULL)
					&& (*(title+1) != '\0'))
				{
					*(++title) = '\0';
				}
				else
				{
					title = NULL;
				}
*/
				if ((node = RDF_Create(vals[i], true)) != NULL)
				{
					setResourceType(node, LDAP_RT);
					if (ldapContainerp(node) == true)
					{
						setContainerp(node, 1);
					}

					ldapDBAdd(rdf, node, gCoreVocab->RDF_parent,
							u, RDF_RESOURCE_TYPE);

					if (title != NULL)
					{
						ldapDBAdd(rdf, node, gCoreVocab->RDF_name,
							title, RDF_STRING_TYPE);
					}
				}
			}
			ldap_value_free(vals);
			}
		}
	}
  if (result != NULL)
	{
	ldap_msgfree(result);
	}
  ldap_unbind(ld);
  ldap_free_urldesc(ldURL);
}
예제 #12
0
static bool elementEquals(TiXmlNode *elm, const char* value)
{
	return stringEquals(elm->Value(), value);
}
void interpretPrompt(References* r, CPUStatus* cpu, int* status)
{
    // show prompt ready
    printf("> ");
    fflush(stdout);

    // get new command
    char* line = (char*) calloc(MAX_STRING_LENGTH, sizeof(char));
    if (line == NULL)
    {
        perror("calloc error in interpretPrompt\n");
        exit(EXIT_FAILURE);
    }
    if (fgets(line, MAX_STRING_LENGTH, stdin) == NULL)
    {
        perror("fgets error in interpretPrompt\n");
        exit(EXIT_FAILURE);
    }

    // remove endline
    removeEndLine(line);

    int assembleCode = 0;

    // interpreter commands
    if (stringEquals(line, "regs") == 0)
    {
        printRegisters(cpu);
        *status = RUN_COMMAND;
        free(line);
        return;
    } else if (stringEquals(line, "mem") == 0)
    {
        printMemory(cpu);
        *status = RUN_COMMAND;
        free(line);
        return;
    } else if (stringEquals(line, "exit") == 0)
    {
        *status = EXECUTE_HALT;
        free(line);
        return;
    } else if (stringEquals(line, "show") == 0)
    {
        printInstructions(r);
        *status = RUN_COMMAND;
        free(line);
        return;
    } else
    {
        // assemble One Pass
        assembleCode = onePass(r, cpu, line);
    }

    // execute interpreter
    if (assembleCode == ASSEMBLE_OK ||
        (assembleCode == ASSEMBLE_LABEL && r->currentAddress > 4))
    {
        interpret(r, cpu, status);
    }

    free(line);
}
예제 #14
0
파일: trace.cpp 프로젝트: huguesv/PTVS
 bool Equals(const void* pyString) const {
     return stringEquals(this, pyString);
 }
예제 #15
0
int runClient(char *port) {
    char *name = "Client";

    //initialize masterServer, peerList and hostlist
    peerList = NULL;
    connectionList = NULL;
    connectionIdGenerator = 2; //1 is received for the server
    masterServer = NULL;

    int listernerSockfd = -1;
    struct connectionInfo *serverInfo = startServer(port, "CLIENT");
    if (serverInfo == NULL) {
        fprintf(stderr, "Did not get serverInfo from startServer()\n");
        return -1;
    }
    listernerSockfd = serverInfo->listernerSockfd;

    int STDIN = 0; //0 represents STDIN

    FD_ZERO(&masterFDList); // clear the master and temp sets
    FD_ZERO(&tempFDList);

    FD_SET(STDIN, &masterFDList); // add STDIN to master FD list
    fdmax = STDIN;

    FD_SET(listernerSockfd, &masterFDList); //add the listener to master FD list and update fdmax
    if (listernerSockfd > fdmax)
        fdmax = listernerSockfd;


    int actionComplete = 1;
    while (1) //keep waiting for input, connections and data
    {

        //this is ti identify is an activity is in progress
        if (actionComplete == 1) {
            printf("$");
            fflush(stdout); //print the terminal symbol
        }
        actionComplete = 1;

        tempFDList = masterFDList; //make a copy of masterFDList and use it as select() modifies the list

        //int select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
        if (select(fdmax + 1, &tempFDList, NULL, NULL, NULL) ==
                -1) //select waits till it gets data in an fd in the list
        {
            fprintf(stderr, "Error in select\n");
            return -1;
        }

        // an FD has data so iterate through the list to find the fd with data
        int fd;
        for (fd = 0; fd <= 20; fd++) {
            if (FD_ISSET(fd, &tempFDList)) //found the FD with data
            {
                if (fd == STDIN) //data from commandLine(STDIN)
                {
                    size_t commandLength = 50;
                    char *command = (char *) malloc(commandLength);
                    getline(&command, &commandLength, stdin); //get line the variable if space is not sufficient
                    if (stringEquals(command, "\n")) //to handle the stray \n s
                        continue;
                    //printf("--Got data: %s--\n",command);
                    handleCommands(command, "CLIENT");
                }
                else if (fd == listernerSockfd) //new client trying to connect to listener
                {

                    struct sockaddr_storage clientaddr;
                    socklen_t addrlen = sizeof clientaddr;
                    int clientsockfd;
                    if ((clientsockfd = accept(listernerSockfd, (struct sockaddr *) &clientaddr, &addrlen)) == -1) {
                        fprintf(stderr, "Error accepting connection: %d %s\n", clientsockfd,
                                gai_strerror(clientsockfd));
                        return -1;
                    }
                    else {
                        //accept connection from client add it to the connectionList
                        struct host *client = (struct host *) malloc(sizeof(struct host));
                        struct sockaddr *hostAddress = (struct sockaddr *) &clientaddr;
                        client->id = connectionIdGenerator++;
                        client->sockfd = clientsockfd;
                        client->ipAddress = getIPAddress(hostAddress);
                        client->hostName = getHostFromIp(client->ipAddress);
                        client->port = getPort(hostAddress);
                        addNode(&connectionList, client);
                        FD_SET(client->sockfd, &masterFDList); // add fd to fdlist
                        if (client->sockfd > fdmax)
                            fdmax = client->sockfd;
                        printf("Accepted client: %s/%s.\n", client->hostName, client->port);

                    }

                }
                else if (masterServer != NULL && fd == masterServer->sockfd)// handle data from server
                {

                    struct packet *recvPacket = readPacket(fd);
                    if (recvPacket == NULL) {
                        printf("Master Server has terminated unexpectedly.\n");
                        int connectionId = getIDForFD(connectionList, fd);
                        terminateConnection(connectionId);
                        masterServer = NULL;
                        peerList = NULL;
                        continue;
                    }

//                    printf("Received packet: ");
//                    printPacket(recvPacket);
//                    printf("\n");

                    //received terminate from server
                    if (recvPacket->header->messageType == terminate) {
                        printf("Received TERMINATE command from server.\n");
                        int connectionId = getIDForFD(connectionList, fd);
                        terminateConnection(connectionId);
                        peerList = NULL;
                        masterServer = NULL;
                        continue;
                    }

                    if (recvPacket->header->messageType == hostList) {
                        //split the hostlist
                        int length = 0;
                        char **hostinfo = splitString(recvPacket->message, ' ', &length);
                        free(peerList);
                        peerList = NULL; //destroy the old peerList
                        int i;
                        for (i = 0; i < length; i = i + 2) {
                            if (i + 1 >= length)
                                fprintf(stderr, "Disproportionate terms in hostList sent by server.\n");

                            if (stringEquals(myIpAddress, hostinfo[i]) && stringEquals(myListenerPort, port)) {
                                //this is so that the client doesn't add itself in the peerList
                                continue;
                            }
                            //add all nodes
                            struct host *peer = (struct host *) malloc(sizeof(struct host));
                            peer->sockfd = -1; // we do not have a connection with it yet
                            peer->ipAddress = hostinfo[i];
                            peer->hostName = getHostFromIp(peer->ipAddress);
                            peer->port = hostinfo[i + 1];
                            addNode(&peerList, peer);
                        }
                        printf("New peerList received from server:\n");
                        printPeerList(peerList);
                        continue;
                    }

                    if (recvPacket->header->messageType == syncFiles) {
                        printf("Received a sync initiate request from Server.\n");
                        syncHostnameFiles();
                        continue;
                    }

                }
                else {

                    //handle data from the peers
                    struct packet *recvPacket = readPacket(fd);
                    if (recvPacket == NULL) {
                        //one of the clients terminated unexpectedly
                        int id = getIDForFD(connectionList, fd);
                        struct host *host = getHostByID(connectionList, id);
                        printf("%s/%s terminated unexpectedly. Removing it from the list.\n",
                               host->hostName, host->port, host->sockfd);
                        terminateConnection(id);
                        continue;
                    }
//                    printf("Received packet: ");
//                    printPacket(recvPacket);
//                    printf("\n");

                    //received terminate
                    if (recvPacket->header->messageType == terminate) {
                        int id = getIDForFD(connectionList, fd);
                        struct host *source = getHostByID(connectionList, id);
                        printf("Received TERMINATE command from %s/%s. Removing it.\n", source->hostName, source->port);
                        terminateConnection(id);
                        continue;
                    }//handle error message
                    else if (recvPacket->header->messageType == error) {
                        printf("Received error message: %s\n", recvPacket->message);
                        continue;
                    }//handle get request
                    else if (recvPacket->header->messageType == get) {
                        int connectionId = getIDForFD(connectionList, fd);
                        struct host *destination = getHostByID(connectionList, connectionId);
                        if (destination == NULL) {
                            fprintf(stderr, "Coudn't find the connection id.\n");
                            continue;
                        }
                        printf("Received a get request for file %s from client: %s/%s.\n",
                               recvPacket->header->fileName, destination->hostName, destination->port);
                        sendFile(connectionId, recvPacket->header->fileName);
                    }//hand a put packet
                    else if (recvPacket->header->messageType == put) {
                        int connectionId = getIDForFD(connectionList, fd);
                        receiveFileAsynchronously(connectionId, recvPacket);
                        actionComplete = 0; //action is not complete until a ok packet is received
                        continue;
                    }//handle a ok packet
                    else if (recvPacket->header->messageType == ok) {
                        int connectionId = getIDForFD(connectionList, fd);
                        okPacketHandler(connectionId, recvPacket);
                        actionComplete = 1; // activity completed
                        continue;
                    }

                }
            }
        }
    }
}
예제 #16
0
PRBool processNextLiteral(RDF_Query q, RDF_Literal literal) {
	if (literal->c != NULL) {
		RDF_SetVariableValue(literal->variable, RDF_NextValue(literal->c), literal->valueType);
		return (RDF_GetVariableValue(literal->variable) != NULL);
	} else {
		RDF_Resource u; /* unit is a resource except for the comparison case so don't set it yet. */
		RDF_Resource s = literal->s;
		void* v;
		if (literal->variable == NULL) {
			PRBool result = false;
			PRBool ans = false;
			int i;
			if (literal->bt) return false;
			/* find a value that satisfies predicate */
			for (i = 0; i < literal->valueCount; i++) {
				TermStruc valueTerm = *(literal->v + i);
				if (comparisonp(s)) {
					/* unit is a variable in all comparisons.
					   value may be a variable or a constant.
					*/
					switch (literal->valueType) {
						char *str, *pattern;
						int i, j;
					case RDF_STRING_TYPE:
						if (literal->u.type != RDF_VARIABLE_TERM_TYPE) return false; /* error */
						if (((RDF_Variable)literal->u.value)->type != RDF_STRING_TYPE) return false;
						str = (char*)RDF_GetVariableValue((RDF_Variable)literal->u.value);
						switch (valueTerm.type) {
						case RDF_VARIABLE_TERM_TYPE:
							pattern = (char*)RDF_GetVariableValue((RDF_Variable)valueTerm.value);
							break;
						case RDF_CONSTANT_TERM_TYPE:
							pattern = (char*)valueTerm.value;
							break;
						default:
							/* should blow up */
							return false;
							break;
						}
						if (s == gCoreVocab->RDF_stringEquals) {
							ans = stringEquals(pattern, str);
						} else if (s == gCoreVocab->RDF_substring) {
							ans = substring(pattern, str);
						} else if (s == gCoreVocab->RDF_notStringEquals) {
							ans = !stringEquals(pattern, str);
						} else if (s == gCoreVocab->RDF_notSubstring) {
							ans = !substring(pattern, str);
						} else return false; /* error */
						break;
					case RDF_INT_TYPE:
						if (literal->u.type != RDF_VARIABLE_TERM_TYPE) return false; /* error */
						if (((RDF_Variable)literal->u.value)->type != RDF_INT_TYPE) return false;
						i = (int)RDF_GetVariableValue((RDF_Variable)literal->u.value);
						switch (valueTerm.type) {
						case RDF_VARIABLE_TERM_TYPE:
							j = (int)RDF_GetVariableValue((RDF_Variable)valueTerm.value);
							break;
						case RDF_CONSTANT_TERM_TYPE:
							j = (int)valueTerm.value;
							break;
						default:
							/* should blow up */
							return false;
							break;
						}
						if (s == gCoreVocab->RDF_equals) {
							ans = (i == j);
						} else if (s == gCoreVocab->RDF_notEquals) {
							ans = (i != j);
						} else if (s == gCoreVocab->RDF_lessThan) {
							ans = (i < j);
						} else if (s == gCoreVocab->RDF_greaterThan) {
							ans = (i > j);
						} else if (s == gCoreVocab->RDF_lessThanOrEqual) {
							ans = (i <= j);
						} else if (s == gCoreVocab->RDF_greaterThanOrEqual) {
							ans = (i >= j);
						} else return false;
						break;
					default:
						return false;
						break;
					}
				}
				else {
					u = (RDF_Resource)((variableTermp(literal->u)) ? ((RDF_Variable)literal->u.value)->value : literal->u.value);
					/* special predicates */
					if (s == gCoreVocab->RDF_notInstanceOf) {
						ans = !RDF_HasAssertion(q->rdf, u, gCoreVocab->RDF_instanceOf, valueTerm.value, literal->valueType, true);
					} else if (s == gCoreVocab->RDF_notParent) {
						ans = !RDF_HasAssertion(q->rdf, u, gCoreVocab->RDF_parent, valueTerm.value, literal->valueType, true);
					} else ans = RDF_HasAssertion(q->rdf, u, s, valueTerm.value, literal->valueType, true);
				}
				literal->bt = true;
				/* result = ((literal->tv == true) ? ans : !ans); */
				result = ans;
				if (result) return result; /* otherwise try next value */
			}
			return result;
		} 
		u = (RDF_Resource)((variableTermp(literal->u)) ? ((RDF_Variable)literal->u.value)->value : literal->u.value);
		v = (variableTermp(*literal->v)) ? ((RDF_Variable)literal->v->value)->value : literal->v->value;
		if ((u == NULL) && variableTermp(literal->u) && resourceTermp(*literal->v)) {
			literal->c = RDF_GetSources(q->rdf, (RDF_Resource)v, s, literal->valueType,  true);
			if (literal->c == NULL) return false;
			RDF_SetVariableValue(literal->variable, RDF_NextValue(literal->c), literal->valueType);
			return (RDF_GetVariableValue(literal->variable) != NULL);
		} else if ((v == NULL) && variableTermp(*literal->v) && (u != NULL)) {
			literal->c = RDF_GetTargets(q->rdf, u, s, literal->valueType,  true); /* note arg order differs from java implementation */
			if (literal->c == NULL) return false;
			RDF_SetVariableValue(literal->variable, RDF_NextValue(literal->c), literal->valueType);
			return (RDF_GetVariableValue(literal->variable) != NULL);
		} else return false;			
	}
}