annotate dpip/dpip.h @ 2104:3e7e5395f0bc

non-ASCII keybindings Alexander Voigt has kindly done some testing, and it seems that this makes bindings to most keys on a German keyboard possible -- except those that need AltGr don't work yet.
author corvid <corvid@lavabit.com>
date Thu, 23 Jun 2011 19:24:11 +0000
parents 27911457287d
children
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 * Library for dealing with dpip tags (dillo plugin protocol tags).
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
4
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5 #ifndef __DPIP_H__
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
6 #define __DPIP_H__
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8 #ifdef __cplusplus
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 extern "C" {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 #endif /* __cplusplus */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11
1385
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
12 #include "../dlib/dlib.h"
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
13
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
14 /*
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
15 * Communication mode flags
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
16 */
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
17 #define DPIP_TAG 1 /* Dpip tags in the socket */
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
18 #define DPIP_LAST_TAG 2 /* Dpip mode-switching tag */
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
19 #define DPIP_RAW 4 /* Raw data in the socket */
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
20 #define DPIP_NONBLOCK 8 /* Nonblocking IO */
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
21
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
22 typedef enum {
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
23 DPIP_EAGAIN,
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
24 DPIP_ERROR,
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
25 DPIP_EOF
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
26 } DpipDshStatus;
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
27
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
28 /*
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
29 * Dpip socket handler type.
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
30 */
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
31 typedef struct _DpipSocketHandler Dsh;
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
32 struct _DpipSocketHandler {
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
33 int fd_in;
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
34 int fd_out;
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
35 /* FILE *in; --Unused. The stream functions block when reading. */
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
36 FILE *out;
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
37
1390
27911457287d Introduced the a_Dpip_dsh_tryflush() call
Jorge Arellano Cid <jcid@dillo.org>
parents: 1389
diff changeset
38 Dstr *wrbuf; /* write buffer */
27911457287d Introduced the a_Dpip_dsh_tryflush() call
Jorge Arellano Cid <jcid@dillo.org>
parents: 1389
diff changeset
39 Dstr *rdbuf; /* read buffer */
1385
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
40 int flush_sz; /* max size before flush */
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
41
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
42 int mode; /* mode flags: DPIP_TAG | DPIP_LAST_TAG | DPIP_RAW */
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
43 int status; /* status code: DPIP_EAGAIN | DPIP_ERROR | DPIP_EOF */
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
44 };
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
45
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
46
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
47 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
48 * Printf like function for building dpip commands.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
49 * It takes care of dpip escaping of its arguments.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
50 * NOTE : It ONLY accepts string parameters, and
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
51 * only one %s per parameter.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53 char *a_Dpip_build_cmd(const char *format, ...);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
54
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
55 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
56 * Task: given a tag and an attribute name, return its value.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
57 * (dpip character escaping is removed here)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
58 * Return value: the attribute value, or NULL if not present or malformed.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
59 */
1387
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1385
diff changeset
60 char *a_Dpip_get_attr(const char *tag, const char *attrname);
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1385
diff changeset
61 char *a_Dpip_get_attr_l(const char *tag, size_t tagsize, const char *attrname);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
62
1384
6c8346ed1073 Introduce basic shared-secret-based authentication
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
63 int a_Dpip_check_auth(const char *auth);
6c8346ed1073 Introduce basic shared-secret-based authentication
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
64
1385
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
65 /*
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
66 * Dpip socket API
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
67 */
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
68 Dsh *a_Dpip_dsh_new(int fd_in, int fd_out, int flush_sz);
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
69 int a_Dpip_dsh_write(Dsh *dsh, int flush, const char *Data, int DataSize);
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
70 int a_Dpip_dsh_write_str(Dsh *dsh, int flush, const char *str);
1390
27911457287d Introduced the a_Dpip_dsh_tryflush() call
Jorge Arellano Cid <jcid@dillo.org>
parents: 1389
diff changeset
71 int a_Dpip_dsh_tryflush(Dsh *dsh);
1389
c1c822f70582 Removed the write/fwrite mix in dpip. Introduced a_Dpip_dsh_trywrite()
Jorge Arellano Cid <jcid@dillo.org>
parents: 1388
diff changeset
72 int a_Dpip_dsh_trywrite(Dsh *dsh, const char *Data, int DataSize);
1388
eb35203124e4 Implemented the file dpi based on select() (removed its pthreads dependency)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1387
diff changeset
73 char *a_Dpip_dsh_read_token(Dsh *dsh, int blocking);
1385
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
74 void a_Dpip_dsh_close(Dsh *dsh);
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
75 void a_Dpip_dsh_free(Dsh *dsh);
eb98997886ec Introduced the new tokenizing dsh API to DPIP
Jorge Arellano Cid <jcid@dillo.org>
parents: 1384
diff changeset
76
1387
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1385
diff changeset
77 #define a_Dpip_dsh_printf(sh, flush, ...) \
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1385
diff changeset
78 D_STMT_START { \
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1385
diff changeset
79 Dstr *dstr = dStr_sized_new(128); \
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1385
diff changeset
80 dStr_sprintf(dstr, __VA_ARGS__); \
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1385
diff changeset
81 a_Dpip_dsh_write(sh, flush, dstr->str, dstr->len); \
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1385
diff changeset
82 dStr_free(dstr, 1); \
16cf380cd04c Convert dpid, file dpi and cookies dpi to dsh API
Jorge Arellano Cid <jcid@dillo.org>
parents: 1385
diff changeset
83 } D_STMT_END
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
84
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
85 #ifdef __cplusplus
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
86 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
87 #endif /* __cplusplus */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
88
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
89 #endif /* __DPIP_H__ */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
90