1 /* $NetBSD: smtp_stream.h,v 1.4 2023/12/23 20:30:43 christos Exp $ */ 2 3 #ifndef _SMTP_STREAM_H_INCLUDED_ 4 #define _SMTP_STREAM_H_INCLUDED_ 5 6 /*++ 7 /* NAME 8 /* smtp_stream 3h 9 /* SUMMARY 10 /* smtp stream I/O support 11 /* SYNOPSIS 12 /* #include <smtp_stream.h> 13 /* DESCRIPTION 14 /* .nf 15 16 /* 17 * System library. 18 */ 19 #include <stdarg.h> 20 #include <setjmp.h> 21 22 /* 23 * Utility library. 24 */ 25 #include <vstring.h> 26 #include <vstream.h> 27 28 /* 29 * External interface. The following codes are meant for use in longjmp(), 30 * so they must all be non-zero. 31 */ 32 #define SMTP_ERR_EOF 1 /* unexpected client disconnect */ 33 #define SMTP_ERR_TIME 2 /* time out */ 34 #define SMTP_ERR_QUIET 3 /* silent cleanup (application) */ 35 #define SMTP_ERR_NONE 4 /* non-error case */ 36 #define SMTP_ERR_DATA 5 /* application data error */ 37 #define SMTP_ERR_LF 6 /* bare <LF> protocol error */ 38 39 extern void smtp_stream_setup(VSTREAM *, int, int, int); 40 extern void PRINTFLIKE(2, 3) smtp_printf(VSTREAM *, const char *,...); 41 extern void smtp_flush(VSTREAM *); 42 extern int smtp_fgetc(VSTREAM *); 43 extern int smtp_get(VSTRING *, VSTREAM *, ssize_t, int); 44 extern int smtp_get_noexcept(VSTRING *, VSTREAM *, ssize_t, int); 45 extern void smtp_fputs(const char *, ssize_t len, VSTREAM *); 46 extern void smtp_fwrite(const char *, ssize_t len, VSTREAM *); 47 extern void smtp_fread_buf(VSTRING *, ssize_t len, VSTREAM *); 48 extern void smtp_fputc(int, VSTREAM *); 49 extern int smtp_forbid_bare_lf; 50 51 extern void smtp_vprintf(VSTREAM *, const char *, va_list); 52 53 #define smtp_timeout_setup(stream, timeout) \ 54 smtp_stream_setup((stream), (timeout), 0, 0) 55 56 #define SMTP_GET_FLAG_NONE 0 57 #define SMTP_GET_FLAG_SKIP (1<<0) /* skip over excess input */ 58 #define SMTP_GET_FLAG_APPEND (1<<1) /* append instead of overwrite */ 59 60 /* LICENSE 61 /* .ad 62 /* .fi 63 /* The Secure Mailer license must be distributed with this software. 64 /* AUTHOR(S) 65 /* Wietse Venema 66 /* IBM T.J. Watson Research 67 /* P.O. Box 704 68 /* Yorktown Heights, NY 10598, USA 69 /* 70 /* Wietse Venema 71 /* Google, Inc. 72 /* 111 8th Avenue 73 /* New York, NY 10011, USA 74 /*--*/ 75 76 #endif 77