Exemplo n.º 1
0
static void Log_p(CTX, ksfp_t *sfp, int pos, kwb_t *wb)
{
	kRawPtr *self = (kRawPtr *) sfp[0].asObject;
	struct Log *log = (struct Log *) self->rawptr;
	int i;
	char *data = log_get_data(log);
	uint16_t klen, vlen;
	kwb_printf(wb, "{");
	for (i = 0; i < log->logsize; ++i) {
		char kbuf[64] = {};
		char vbuf[64] = {};
		char *next = log_iterator(log, data, i);
		klen = log_get_length(log, i*2+0);
		vlen = log_get_length(log, i*2+1);
		memcpy(kbuf, data,klen);
		memcpy(vbuf, data+klen, vlen);
		kwb_printf(wb, "'%s': '%s' ", kbuf, vbuf);
		data = next;
	}
	kwb_printf(wb, "}");
}
Exemplo n.º 2
0
static void Log_p(KonohaContext *kctx, KonohaStack *sfp, int pos, KUtilsWriteBuffer *wb, int level)
{
	kRawPtr *self = (kRawPtr *) sfp[0].asObject;
	struct Log *log = (struct Log *) self->rawptr;
	int i;
	char *data = log_get_data(log);
	uint16_t klen, vlen;
	KLIB Kwb_printf(kctx, wb, "{");
	for (i = 0; i < log->logsize; ++i) {
		char kbuf[64] = {};
		char vbuf[64] = {};
		char *next = log_iterator(log, data, i);
		klen = log_get_length(log, i*2+0);
		vlen = log_get_length(log, i*2+1);
		memcpy(kbuf, data,klen);
		memcpy(vbuf, data+klen, vlen);
		KLIB Kwb_printf(kctx, wb, "'%s': '%s' ", kbuf, vbuf);
		data = next;
	}
	KLIB Kwb_printf(kctx, wb, "}");
}
Exemplo n.º 3
0
static void server_read_callback(struct bufferevent *bev, void *ctx)
{
    struct range_stream *cs = (struct range_stream *) ctx;
    struct io *io = cs->io;
    debug_print(0, "read_cb bev=%p", bev);
    while (!range_stream_empty(cs)) {
        int log_size;
        struct Log *log = range_stream_get(cs, &log_size);
        if (log == NULL) {
            break;
        }
        char *data = log_get_data((struct Log *) log);
        debug_print(0, "%d %d %s", log->protocol, log->logsize, data);
        switch (log_data_protocol(log)) {
        case LOGPOOL_EVENT_READ:
            debug_print(1, "R %d %d, '%s'", log->klen, log->vlen, data);
            pool_add((struct Procedure*) log, bev, io->pool);
            break;
        case LOGPOOL_EVENT_WRITE:
#if LOGPOOL_DEBUG >= 1
            log_dump(stderr, "W ", (struct Log *) log, "\n", 0);
#endif
            pool_exec((struct Log *) log, log_size, io->pool);
            break;
        case LOGPOOL_EVENT_QUIT:
            debug_print(1, "Q %d, %d\n", log->klen, log->vlen);
            pool_delete_connection(io->pool, bev);
            bufferevent_free(bev);
            goto L_exit;
        case LOGPOOL_EVENT_NULL:
        default:
            /*TODO*/abort();
            break;
        }
    }
    L_exit:;
    return;
}