xref: /freebsd/contrib/sendmail/include/sm/ixlen.h (revision d39bd2c1388b520fcba9abed1932acacead60fba)
12fb4f839SGregory Neil Shapiro /*
22fb4f839SGregory Neil Shapiro  * Copyright (c) 2020 Proofpoint, Inc. and its suppliers.
32fb4f839SGregory Neil Shapiro  *	All rights reserved.
42fb4f839SGregory Neil Shapiro  *
52fb4f839SGregory Neil Shapiro  * By using this file, you agree to the terms and conditions set
62fb4f839SGregory Neil Shapiro  * forth in the LICENSE file which can be found at the top level of
72fb4f839SGregory Neil Shapiro  * the sendmail distribution.
82fb4f839SGregory Neil Shapiro  */
92fb4f839SGregory Neil Shapiro 
102fb4f839SGregory Neil Shapiro #ifndef _SM_IXLEN_H
112fb4f839SGregory Neil Shapiro # define _SM_IXLEN_H 1
122fb4f839SGregory Neil Shapiro 
132fb4f839SGregory Neil Shapiro #define SM_IS_MQ(ch) (((ch) & 0377) == METAQUOTE)
142fb4f839SGregory Neil Shapiro 
152fb4f839SGregory Neil Shapiro #if _FFR_8BITENVADDR
162fb4f839SGregory Neil Shapiro # define XLENDECL bool mq=false;	\
172fb4f839SGregory Neil Shapiro 	int xlen = 0;
182fb4f839SGregory Neil Shapiro # define XLENRESET mq=false, xlen = 0
192fb4f839SGregory Neil Shapiro # define XLEN(c) do { \
202fb4f839SGregory Neil Shapiro 		if (mq) { ++xlen; mq=false; } \
212fb4f839SGregory Neil Shapiro 		else if (SM_IS_MQ(c)) mq=true; \
222fb4f839SGregory Neil Shapiro 		else ++xlen; \
232fb4f839SGregory Neil Shapiro 	} while (0)
242fb4f839SGregory Neil Shapiro 
252fb4f839SGregory Neil Shapiro extern int ilenx __P((const char *));
262fb4f839SGregory Neil Shapiro extern int xleni __P((const char *));
272fb4f839SGregory Neil Shapiro 
282fb4f839SGregory Neil Shapiro # if USE_EAI
292fb4f839SGregory Neil Shapiro extern bool	asciistr __P((const char *));
30*d39bd2c1SGregory Neil Shapiro extern bool	asciinstr __P((const char *, size_t));
312fb4f839SGregory Neil Shapiro extern int	uxtext_unquote __P((const char *, char *, int));
322fb4f839SGregory Neil Shapiro extern char	*sm_lowercase  __P((const char *));
332fb4f839SGregory Neil Shapiro extern bool	utf8_valid  __P((const char *, size_t));
342fb4f839SGregory Neil Shapiro # endif
352fb4f839SGregory Neil Shapiro 
362fb4f839SGregory Neil Shapiro #else /* _FFR_8BITENVADDR */
372fb4f839SGregory Neil Shapiro # define XLENDECL int xlen = 0;
382fb4f839SGregory Neil Shapiro # define XLENRESET xlen = 0
392fb4f839SGregory Neil Shapiro # define XLEN(c) ++xlen
402fb4f839SGregory Neil Shapiro # define ilenx(str) strlen(str)
412fb4f839SGregory Neil Shapiro # define xleni(str) strlen(str)
422fb4f839SGregory Neil Shapiro #endif /* _FFR_8BITENVADDR */
432fb4f839SGregory Neil Shapiro 
442fb4f839SGregory Neil Shapiro #endif /* ! _SM_IXLEN_H */
45