Home | History | Annotate | Line # | Download | only in util
      1 /*	$NetBSD: name_mask.h,v 1.2 2026/05/09 18:49:23 christos Exp $	*/
      2 
      3 #ifndef _NAME_MASK_H_INCLUDED_
      4 #define _NAME_MASK_H_INCLUDED_
      5 
      6 /*++
      7 /* NAME
      8 /*	name_mask 3h
      9 /* SUMMARY
     10 /*	map names to bit mask
     11 /* SYNOPSIS
     12 /*	#include <name_mask.h>
     13 /* DESCRIPTION
     14 /* .nf
     15 
     16  /*
     17   * Utility library.
     18   */
     19 #include <vstring.h>
     20 
     21  /*
     22   * External interface.
     23   */
     24 typedef struct {
     25     const char *name;
     26     int     mask;
     27 } NAME_MASK;
     28 
     29 #define NAME_MASK_FATAL	(1<<0)
     30 #define NAME_MASK_ANY_CASE	(1<<1)
     31 #define NAME_MASK_RETURN	(1<<2)
     32 #define NAME_MASK_COMMA		(1<<3)
     33 #define NAME_MASK_PIPE		(1<<4)
     34 #define NAME_MASK_NUMBER	(1<<5)
     35 #define NAME_MASK_WARN		(1<<6)
     36 #define NAME_MASK_IGNORE	(1<<7)
     37 
     38 #define NAME_MASK_REQUIRED \
     39     (NAME_MASK_FATAL | NAME_MASK_RETURN | NAME_MASK_WARN | NAME_MASK_IGNORE)
     40 #define STR_NAME_MASK_REQUIRED	(NAME_MASK_REQUIRED | NAME_MASK_NUMBER)
     41 
     42 #define NAME_MASK_MATCH_REQ	NAME_MASK_FATAL
     43 
     44 #define NAME_MASK_NONE		0
     45 #define NAME_MASK_DEFAULT	(NAME_MASK_FATAL)
     46 #define NAME_MASK_DEFAULT_DELIM	", \t\r\n"
     47 
     48 #define name_mask_opt(tag, table, str, flags) \
     49 	name_mask_delim_opt((tag), (table), (str), \
     50 			    NAME_MASK_DEFAULT_DELIM, (flags))
     51 #define name_mask(tag, table, str) \
     52 	name_mask_opt((tag), (table), (str), NAME_MASK_DEFAULT)
     53 #define str_name_mask(tag, table, mask) \
     54 	str_name_mask_delim_opt(((VSTRING *) 0), (tag), (table), (mask), ", ", NAME_MASK_DEFAULT)
     55 
     56 extern int name_mask_delim_opt(const char *, const NAME_MASK *, const char *, const char *, int);
     57 extern const char *str_name_mask_delim_opt(VSTRING *, const char *, const NAME_MASK *, int, const char *, int);
     58 extern const char *str_name_mask_opt(VSTRING *, const char *, const NAME_MASK *, int, int);
     59 
     60  /*
     61   * "long" API
     62   */
     63 typedef struct {
     64     const char *name;
     65     long    mask;
     66 } LONG_NAME_MASK;
     67 
     68 #define long_name_mask_opt(tag, table, str, flags) \
     69 	long_name_mask_delim_opt((tag), (table), (str), NAME_MASK_DEFAULT_DELIM, (flags))
     70 #define long_name_mask(tag, table, str) \
     71 	long_name_mask_opt((tag), (table), (str), NAME_MASK_DEFAULT)
     72 #define str_long_name_mask(tag, table, mask) \
     73 	str_long_name_mask_opt(((VSTRING *) 0), (tag), (table), (mask), NAME_MASK_DEFAULT)
     74 
     75 extern long long_name_mask_delim_opt(const char *, const LONG_NAME_MASK *, const char *, const char *, int);
     76 extern const char *str_long_name_mask_opt(VSTRING *, const char *, const LONG_NAME_MASK *, long, int);
     77 
     78 /* LICENSE
     79 /* .ad
     80 /* .fi
     81 /*	The Secure Mailer license must be distributed with this software.
     82 /* AUTHOR(S)
     83 /*	Wietse Venema
     84 /*	IBM T.J. Watson Research
     85 /*	P.O. Box 704
     86 /*	Yorktown Heights, NY 10598, USA
     87 /*--*/
     88 
     89 #endif
     90