20 typedef void mes_functype(struct mechdata
**md_r
, int *maxprefix_io
, int *maxsuffix_io
);
21 typedef void mds_functype(struct mechdata
**md_r
);
23 typedef void menc_functype(struct mechdata
*md
, struct buffer
*);
24 typedef const char *mdec_functype(struct mechdata
*md
, struct buffer
*);
28 mes_functype
*encsetup
;
29 mds_functype
*decsetup
;
30 menc_functype
*encode
;
31 mdec_functype
*decode
;
34 extern const struct mechanism
*const mechanismlists
[];
36 /* setup function may call getarg_xxx functions and then
37 * reads/writes key material to/from fd
39 * setup_in function may increase maxprefix and maxsuffix
40 * code functions modify buffer in place
41 * decode function returns message to print
44 const char *getarg_string(void);
45 unsigned long getarg_ulong(void);
47 extern char programid
[];
49 void *buf_append(struct buffer
*buf
, size_t amount
);
50 void *buf_prepend(struct buffer
*buf
, size_t amount
);
51 void *buf_unappend(struct buffer
*buf
, size_t amount
); /* may give 0 */
52 void *buf_unprepend(struct buffer
*buf
, size_t amount
); /* may give 0 */
54 void sysfail(const char *msg
);
55 void fail(const char *msg
);
56 void sysdiag(const char *msg
);
57 void diag(const char *msg
);
60 void *xmalloc(size_t sz
);
61 void get_random(void *ptr
, size_t sz
);
62 void random_key(void *ptr
, size_t sz
);
64 void arg_assert_fail(const char *msg
);
65 #define arg_assert(v) (v ? (void)0 : arg_assert_fail(#v))
67 #define XMALLOC(variable) ((variable)= xmalloc(sizeof(*(variable))))
69 #define BUF_UNSOMEEND(var,buf,sz,whichend) \
70 do { var= whichend(buf,sz); if (!var) return "message truncated"; } while(0)
71 #define BUF_UNAPPEND(var,buf,sz) BUF_UNSOMEEND(var,buf,sz,buf_unappend)
72 #define BUF_UNPREPEND(var,buf,sz) BUF_UNSOMEEND(var,buf,sz,buf_unprepend)
74 #define STANDARD_MECHANISMLIST(mechstring,filename) \
75 const struct mechanism mechlist_##filename []= { \
76 STANDARD_MECHANISM(mechstring,filename) \
80 #define STANDARD_MECHANISM(mechstring,mechname) \
81 { mechstring, mes_##mechname, mds_##mechname, menc_##mechname, mdec_##mechname },