VertexServer *VertexServer_new(void) { VertexServer *self = calloc(1, sizeof(VertexServer)); globalVertexServer = self; srand((clock() % INT_MAX)); self->pdb = PDB_new(); VertexServer_setupYajl(self); self->httpServer = HttpServer_new(); HttpServer_setPort_(self->httpServer, 8080); HttpServer_setHost_(self->httpServer, "127.0.0.1"); HttpServer_setDelegate_(self->httpServer, self); HttpServer_setRequestCallback_(self->httpServer, VertexServer_requestHandler); self->httpRequest = HttpServer_request(self->httpServer); self->httpResponse = HttpServer_response(self->httpServer); self->result = HttpResponse_content(self->httpResponse); self->actions = CHash_new(); CHash_setEqualFunc_(self->actions, (CHashEqualFunc *)Datum_equals_); CHash_setHash1Func_(self->actions, (CHashHashFunc *)Datum_hash1); CHash_setHash2Func_(self->actions, (CHashHashFunc *)Datum_hash2); self->ops = CHash_new(); CHash_setEqualFunc_(self->ops, (CHashEqualFunc *)Datum_equals_); CHash_setHash1Func_(self->ops, (CHashHashFunc *)Datum_hash1); CHash_setHash2Func_(self->ops, (CHashHashFunc *)Datum_hash2); return self; }
HttpRequest *HttpRequest_new(void) { HttpRequest *self = calloc(1, sizeof(HttpRequest)); self->post = Datum_new(); self->uri = Datum_new(); self->uriPath = Datum_new(); self->query = CHash_new(); CHash_setEqualFunc_(self->query, (CHashEqualFunc *)Datum_equals_); CHash_setHash1Func_(self->query, (CHashHashFunc *)Datum_hash1); CHash_setHash2Func_(self->query, (CHashHashFunc *)Datum_hash2); self->emptyDatum = Datum_new(); return self; }
CHash *CHash_clone(CHash *self) { CHash *other = CHash_new(); CHash_copy_(other, self); return other; }