int PNode_moveToPathCString_(PNode *self, const char *p) { int result; Datum *np = Datum_poolNewWithCString_(p); result = PNode_moveToPath_(self, np); return result; }
int VertexServer_api_queuePopTo(VertexServer *self) { PNode *fromNode = PDB_allocNode(self->pdb); PNode *toNode = PDB_allocNode(self->pdb); Datum *toPath = HttpRequest_queryValue_(self->httpRequest, "toPath"); long ttl = Datum_asLong(HttpRequest_queryValue_(self->httpRequest, "ttl")); if (PNode_moveToPathIfExists_(fromNode, HttpRequest_uriPath(self->httpRequest)) != 0) { VertexServer_setErrorCString_(self, "from path does not exist: "); VertexServer_appendError_(self, HttpRequest_uriPath(self->httpRequest)); return -1; } PNode_moveToPath_(toNode, toPath); //printf("to pid: %s\n", Datum_data(PNode_pid(toNode))); //printf("from pid: %s\n", Datum_data(PNode_pid(fromNode))); { PQuery *q = PNode_query(fromNode); VertexServer_setupPQuery_(self, q); PNode_startQuery(fromNode); Datum *k = PQuery_key(q); Datum *v = PNode_value(fromNode); if (k) { PNode_atPut_(toNode, k, v); PNode_moveToKey_(toNode, k); // insert queue time { long now = time(NULL); Datum *timeKey = Datum_poolNewWithCString_("_qtime"); Datum *timeValue = Datum_poolNew(); Datum_fromLong_(timeValue, now); PNode_atPut_(toNode, timeKey, timeValue); Datum_setCString_(timeKey, "_qexpire"); Datum_fromLong_(timeValue, now + (ttl == 0 ? 3600 : ttl)); PNode_atPut_(toNode, timeKey, timeValue); } //printf("queueing key %s\n", Datum_data(k)); yajl_gen_datum(self->yajl, k); PNode_removeAt_(fromNode, k); } else { yajl_gen_null(self->yajl); } } Datum_appendYajl_(self->result, self->yajl); return 0; }
int VertexServer_api_mkdir(VertexServer *self) { PNode_moveToPath_(PDB_allocNode(self->pdb), HttpRequest_uriPath(self->httpRequest)); return 0; }