use our usual functions.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
}
}
+void buffer_consume(buffer_t *buf, ssize_t len) {
+ if (len <= 0)
+ return;
+ if (len >= buf->len) {
+ buffer_reset(buf);
+ return;
+ }
+
+ memmove(buf->data, buf->data + len, buf->len + 1 - len);
+ buf->len -= len;
+}
DO_NEW(buffer_t, buffer);
DO_DELETE(buffer_t, buffer);
+static inline void buffer_reset(buffer_t *buf) {
+ buf->data[buf->len = 0] = '\0';
+}
+
static inline char *buffer_unwrap(buffer_t **buf) {
char *res = (*buf)->data;
(*buf)->data = NULL;
buffer_extendch(buf, 1, c);
}
+void buffer_consume(buffer_t *buf, ssize_t len);
+
#endif /* MUTT_LIB_LIB_BUFFER_H */
#include "policy.h"
+policy_request *pcyrq_init(policy_request *rq)
+{
+ p_clear(rq, 1);
+ buffer_init(&rq->buf);
+ return rq;
+}
+
+void policy_wipe(policy_request *rq)
+{
+ buffer_wipe(&rq->buf);
+}
#ifndef POSTLICYD_POLICY_H
#define POSTLICYD_POLICY_H
+#include "buffer.h"
+
enum protocol_state {
STATE_CONNECT,
STATE_HELO, /* or EHLO */
};
typedef struct policy_request {
- unsigned ready : 1;
unsigned state : 4;
unsigned esmtp : 1;
const char *encryption_cipher;
const char *encryption_keysize;
const char *etrn_domain;
+
+ buffer_t buf;
} policy_request;
+policy_request *pcyrq_init(policy_request *rq);
+void pcyrq_wipe(policy_request *rq);
+
+DO_NEW(policy_request, pcyrq);
+DO_DELETE(policy_request, pcyrq);
#endif