summaryrefslogtreecommitdiff
path: root/controlport/controlport.h (plain)
blob: ba647f84cbbe2233c68fef7bbba967710f25f7fa
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
#ifndef CONTROL_PORT_H
#define CONTROL_PORT_H

#include <stdlib.h>

typedef struct {
  int     argc; /* conventional argc/argv args */
  char  **argv;
  size_t *lenv; // len of each arg, useful if client sends null-containing args
} cp_arg_t;

typedef int (cp_cmd_f)(void *cp, cp_arg_t *arg, void *data);

typedef struct {
  char *name;
  cp_cmd_f *cmdf;
  char *help;
} cp_cmd_t;

void *cp_init(char *path, cp_cmd_t *cmds, void *data, int timeout);
void cp_add_cmd(void*, char *name, cp_cmd_f *cmdf, char *help, void *data);
int cp_run(void*);
void cp_shutdown(void*); /* callable from another thread */

/* these are used within command callbacks */
void cp_disconnect(void*);
void cp_add_reply(void *, void *buf, size_t len);

#endif