]> diplodocus.org Git - nmh/blobdiff - h/mh.h
Added explicit dependency to build sbr/icalparse.h before running LEX.
[nmh] / h / mh.h
diff --git a/h/mh.h b/h/mh.h
index 0a62f586765377214889dc9fac0eca775861f1f6..22e3a0b5d3d2bc563875d2f23966bd49906275be 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -8,7 +8,7 @@
  */
 #define        NOTOK        (-1)       /* syscall()s return this on error */
 #define        OK             0        /*  ditto on success               */
-#define        DONE           1        /* trinary logic                   */
+#define        DONE           1        /* ternary logic                   */
 #define ALL           ""
 
 #define MAXARGS            1000        /* max arguments to exec                */
@@ -20,7 +20,7 @@
  * This macro is for use by scan, for example, so that platforms with
  * a small BUFSIZ can easily allocate larger buffers.
  */
-#define NMH_BUFSIZ  (BUFSIZ>=8192 ? BUFSIZ : 8192)
+#define NMH_BUFSIZ  max(BUFSIZ, 8192)
 
 #ifndef FALSE
 #define FALSE false
@@ -48,6 +48,18 @@ typedef unsigned char  boolean;  /* not int so we can pack in a structure */
  * terminating NUL. */
 #define LEN(s) (sizeof (s) - 1)
 
+/* FENDNULL fends off NULL by giving an empty string instead. */
+#define FENDNULL(s) ((s) ? (s) : "")
+
+/* PLURALS gives a pointer to the string "s" when n isn't 1, and to the
+ * empty string "" when it is.  Suitable for obtaining the plural `s'
+ * used for English nouns.  It treats -1 as plural, as does GNU gettext.
+ * Having output vary for plurals is annoying for those writing parsers;
+ * better to phrase the output such that no test is needed, e.g.
+ * "messages found: 42". */
+extern const char plurals[];
+#define PLURALS(n) (plurals + ((n) == 1))
+
 /*
  * char array that keeps track of size in both bytes and characters
  * Usage note:
@@ -187,14 +199,22 @@ extern struct swit anoyes[];      /* standard yes/no switches */
 
 #define        MBITS "\020\01EXISTS\02SELECTED\03NEW\04UNSEEN"
 
-/*
- * type for holding the sequence set of a message
- */
+/* A vector of bits for tracking the sequence membership of a single
+ * message.  Do not access the struct members; use vector.c.
+ * Do not move or copy this struct as it may contain a pointer to
+ * itself;  use bvector_copy(). */
+struct bvector {
+    unsigned long *bits;
+    size_t maxsize;
+    unsigned long tiny[2];   /* Default fixed-size storage for bits. */
+};
 typedef struct bvector *bvector_t;
 
 bvector_t bvector_create (void);
+void bvector_init(struct bvector *bv);
 void bvector_copy (bvector_t, bvector_t);
 void bvector_free (bvector_t);
+void bvector_fini(struct bvector *bv);
 void bvector_clear (bvector_t, size_t);
 void bvector_clear_all (bvector_t);
 void bvector_set (bvector_t, size_t);
@@ -263,7 +283,7 @@ struct msgs {
      * in a particular sequence.
      */
     size_t num_msgstats;
-    bvector_t *msgstats;       /* msg status */
+    struct bvector *msgstats;  /* msg status */
 
     /*
      * A FILE handle containing an open filehandle for the sequence file
@@ -289,7 +309,7 @@ struct msgs {
 /*
  * macros for message and sequence manipulation
  */
-#define msgstat(mp,n) (mp)->msgstats[(n) - mp->lowoff]
+#define msgstat(mp,n) ((mp)->msgstats + (n) - mp->lowoff)
 #define clear_msg_flags(mp,msgnum)   bvector_clear_all (msgstat(mp, msgnum))
 #define copy_msg_flags(mp,i,j)       bvector_copy (msgstat(mp,i), msgstat(mp,j))
 #define get_msg_flags(mp,ptr,msgnum) bvector_copy (ptr, msgstat(mp, msgnum))