Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 74 lines (57 sloc) 1.381 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
#ifndef CMD_H
#define CMD_H

#include <stdlib.h>
#include <hiredis/async.h>
#include <sys/queue.h>
#include <event.h>
#include <evhttp.h>

struct evhttp_request;
struct http_client;
struct server;
struct worker;
struct cmd;

typedef void (*formatting_fun)(redisAsyncContext *, void *, void *);
typedef enum {CMD_SENT,
CMD_PARAM_ERROR,
CMD_ACL_FAIL,
CMD_REDIS_UNAVAIL} cmd_response_t;

struct cmd {
int fd;

int count;
char **argv;
size_t *argv_len;

/* HTTP data */
char *mime; /* forced output content-type */
char *if_none_match; /* used with ETags */
char *jsonp; /* jsonp wrapper */
int keep_alive;
int mime_free; /* need to free mime buffer */

/* various flags */
int started_responding;
int is_websocket;
int http_version;

struct http_client *pub_sub_client;
redisAsyncContext *ac;
};

struct subscription {
struct server *s;
struct cmd *cmd;
};

struct cmd *
cmd_new(int count);

void
cmd_free(struct cmd *c);

cmd_response_t
cmd_run(struct worker *w, struct http_client *client,
const char *uri, size_t uri_len,
const char *body, size_t body_len);

int
cmd_select_format(struct http_client *client, struct cmd *cmd,
const char *uri, size_t uri_len, formatting_fun *f_format);

int
cmd_is_subscribe(struct cmd *cmd);

void
cmd_send(struct cmd *cmd, formatting_fun f_format);

void
cmd_setup(struct cmd *cmd, struct http_client *client);

#endif
Something went wrong with that request. Please try again.