Ejemplo n.º 1
0
int VertexServer_api_link(VertexServer *self)
{
	PNode *toNode   = PDB_allocNode(self->pdb);
	PNode *fromNode = PDB_allocNode(self->pdb);
	
	Datum *key      = HttpRequest_queryValue_(self->httpRequest, "key");
	Datum *fromPath = HttpRequest_uriPath(self->httpRequest);
	Datum *toPath   = HttpRequest_queryValue_(self->httpRequest, "toPath");

	if (PNode_moveToPathIfExists_(toNode, toPath) != 0) 
	{
		VertexServer_setErrorCString_(self, "to path does not exist: ");
		VertexServer_appendError_(self, toPath);
		return -1;
	}
		
	if (PNode_moveToPathIfExists_(fromNode, fromPath) != 0) 
	{
		VertexServer_setErrorCString_(self, "from path does not exist: ");
		VertexServer_appendError_(self, fromPath);
		return -1;
	}	

	PNode_atPut_(toNode, key, PNode_pid(fromNode));

	return 0;
}
Ejemplo n.º 2
0
int PNode_createMoveToKey_(PNode *self, Datum *key)
{
	Datum *v = PNode_at_(self, key);
	
	if (v)
	{
		Datum_copy_(self->parentPid, self->pid);
		PNode_setPid_(self, v);
		return 1;
	}
	else
	{
		PNode *n = PDB_allocNode(self->pdb);
		PNode_create(n);
		PNode_atPut_(self, key, PNode_pid(n));
		Datum_copy_(self->parentPid, self->pid);
		PNode_setPid_(self, PNode_pid(n));
	}
	
	return 0;
}
Ejemplo n.º 3
0
void PNode_show(PNode *self)
{
	Datum *k;
	
	printf("PNode pid %s\n", 
		Datum_data(PNode_pid(self)));
	
	PNode_first(self);
	
	while ((k = PNode_key(self)))
	{
		printf("	'%s' '%s'\n", 
			Datum_data(PNode_key(self)), 
			Datum_data(PNode_value(self)));
		PNode_next(self);
	}
}