]> diplodocus.org Git - nmh/blobdiff - h/mh.h
dtimezone(): Explain abs(3) is undefined on INT_MIN.
[nmh] / h / mh.h
diff --git a/h/mh.h b/h/mh.h
index 5e75c0baf295b93c5e9849c11f6203dc5f90f9bf..6b7dec613a75a0c9984654c767482d3169fdc064 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -1,6 +1,4 @@
-
-/*
- * mh.h -- main header file for all of nmh
+/* mh.h -- main header file for all of nmh
  */
 
 #include <h/nmh.h>
  */
 #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        Nbby           8        /* number of bits/byte */
 
 #define MAXARGS            1000        /* max arguments to exec                */
 #define NFOLDERS    1000       /* max folder arguments on command line */
 #define DMAXFOLDER     4       /* typical number of digits             */
 #define MAXFOLDER   1000       /* message increment                    */
 
+/*
+ * This macro is for use by scan, for example, so that platforms with
+ * a small BUFSIZ can easily allocate larger buffers.
+ */
+#define NMH_BUFSIZ  max(BUFSIZ, 8192)
+
 #ifndef FALSE
-#define FALSE 0
+#define FALSE false
 #endif
 #ifndef TRUE
-#define TRUE 1
+#define TRUE true
 #endif
 typedef unsigned char  boolean;  /* not int so we can pack in a structure */
 
@@ -38,6 +41,45 @@ typedef unsigned char  boolean;  /* not int so we can pack in a structure */
 #define NMH_UNUSED(i) i
 #endif
 
+/* DIM gives the number of elements in the one-dimensional array a. */
+#define DIM(a) (sizeof (a) / sizeof (*(a)))
+
+/* LEN gives the strlen() of string constant s, excluding the
+ * terminating NUL. */
+#define LEN(s) (sizeof (s) - 1)
+
+/* FENDNULL fends off NULL by giving an empty string instead. */
+#define FENDNULL(s) ((s) ? (s) : "")
+
+/*
+ * char array that keeps track of size in both bytes and characters
+ * Usage note:
+ *    Don't store return value of charstring_buffer() and use later
+ *    after intervening push_back's; use charstring_buffer_copy()
+ *    instead.
+ */
+typedef struct charstring *charstring_t;
+
+charstring_t charstring_create (size_t);
+charstring_t charstring_copy (const charstring_t);
+void charstring_free (charstring_t);
+/* Append a single-byte character: */
+void charstring_push_back (charstring_t, const char);
+/* Append possibly multi-byte character(s): */
+void charstring_push_back_chars (charstring_t, const char [], size_t, size_t);
+void charstring_append (charstring_t, const charstring_t);
+void charstring_append_cstring (charstring_t, const char []);
+void charstring_clear (charstring_t);
+/* Don't store return value of charstring_buffer() and use later after
+   intervening push_back's; use charstring_buffer_copy() instead. */
+const char *charstring_buffer (const charstring_t);
+/* User is responsible for free'ing result of buffer copy. */
+char *charstring_buffer_copy (const charstring_t);
+size_t charstring_bytes (const charstring_t);
+size_t charstring_chars (const charstring_t);
+/* Length of the last character in the charstring. */
+int charstring_last_char_len (const charstring_t);
+
 /*
  * user context/profile structure
  */
@@ -126,44 +168,49 @@ extern struct swit anoyes[];      /* standard yes/no switches */
  * general folder attributes
  */
 #define READONLY   (1<<0)      /* No write access to folder    */
-#define        SEQMOD     (1<<1)       /* folder's sequences modifed   */
+#define        SEQMOD     (1<<1)       /* folder's sequences modified   */
 #define        ALLOW_NEW  (1<<2)       /* allow the "new" sequence     */
 #define        OTHERS     (1<<3)       /* folder has other files       */
-#define        MODIFIED   (1<<4)       /* msh in-core folder modified  */
 
-#define        FBITS "\020\01READONLY\02SEQMOD\03ALLOW_NEW\04OTHERS\05MODIFIED"
+#define        FBITS "\020\01READONLY\02SEQMOD\03ALLOW_NEW\04OTHERS"
 
 /*
  * first free slot for user defined sequences
  * and attributes
  */
-#define        FFATTRSLOT  5
+#define        FFATTRSLOT  4
 
 /*
  * internal messages attributes (sequences)
  */
 #define EXISTS        (0)      /* exists            */
-#define DELETED       (1)      /* deleted           */
-#define SELECTED      (2)      /* selected for use  */
-#define SELECT_EMPTY  (3)      /* "new" message     */
-#define        SELECT_UNSEEN (4)       /* inc/show "unseen" */
-
-#define        MBITS "\020\01EXISTS\02DELETED\03SELECTED\04NEW\05UNSEEN"
-
-/*
- * type for holding the sequence set of a message
- */
+#define SELECTED      (1)      /* selected for use  */
+#define SELECT_EMPTY  (2)      /* "new" message     */
+#define        SELECT_UNSEEN (3)       /* inc/show "unseen" */
+
+#define        MBITS "\020\01EXISTS\02SELECTED\03NEW\04UNSEEN"
+
+/* 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 (size_t /* initial size in bits, can be 0 */);
+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);
 unsigned int bvector_at (bvector_t, size_t);
-const unsigned long *bvector_bits (bvector_t);
-size_t bvector_maxsize (bvector_t);
+unsigned long bvector_first_bits (bvector_t);
 
 typedef struct svector *svector_t;
 
@@ -182,7 +229,6 @@ void ivector_free (ivector_t);
 int ivector_push_back (ivector_t, int);
 int ivector_at (ivector_t, size_t);
 int *ivector_atp (ivector_t, size_t);
-size_t ivector_size (ivector_t);
 
 /*
  * Primary structure of folder/message information
@@ -228,7 +274,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
@@ -254,7 +300,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))
@@ -280,9 +326,6 @@ struct msgs {
 #define set_unseen(mp,msgnum) \
         bvector_set (msgstat(mp, msgnum), SELECT_UNSEEN)
 
-/* for msh only */
-#define set_deleted(mp,msgnum)     bvector_set (msgstat(mp, msgnum), DELETED)
-
 #define in_sequence(mp,seqnum,msgnum) \
         bvector_at (msgstat(mp, msgnum), FFATTRSLOT + seqnum)
 #define clear_sequence(mp,seqnum,msgnum) \
@@ -297,7 +340,7 @@ struct msgs {
 #define make_seq_private(mp,seqnum) \
         bvector_set (mp->attrstats, FFATTRSLOT + seqnum)
 #define make_all_public(mp) \
-        mp->attrstats = bvector_create(0); bvector_clear_all (mp->attrstats)
+        mp->attrstats = bvector_create(); bvector_clear_all (mp->attrstats)
 
 /*
  * macros for folder attributes
@@ -310,8 +353,6 @@ struct msgs {
 #define other_files(mp)     ((mp)->msgflags & OTHERS)
 #define set_other_files(mp) ((mp)->msgflags |= OTHERS)
 
-#define        NULLMP  ((struct msgs *) 0)
-
 /*
  * m_getfld() message parsing
  */
@@ -333,7 +374,6 @@ struct msgs {
 #define BODY     3             /* Body  returned with more to come */
 #define FILEEOF  5             /* Reached end of input file        */
 
-struct m_getfld_state;
 typedef struct m_getfld_state *m_getfld_state_t;
 
 /*
@@ -342,8 +382,7 @@ typedef struct m_getfld_state *m_getfld_state_t;
 #define        MS_DEFAULT      0       /* default (one msg per file) */
 #define        MS_UNKNOWN      1       /* type not known yet         */
 #define        MS_MBOX         2       /* Unix-style "from" lines    */
-#define        MS_MMDF         3       /* string mmdlm2              */
-#define        MS_MSH          4       /* whacko msh                 */
+#define        MS_MMDF         3       /* string MMDF_DELIM          */
 
 #define        NOUSE   0               /* draft being re-used */
 
@@ -359,12 +398,6 @@ typedef struct m_getfld_state *m_getfld_state_t;
 /*
  * credentials management
  */
-struct nmh_creds {
-    char *host;
-    char *user;
-    char *password;
-};
-
 typedef struct nmh_creds *nmh_creds_t;
 
 /*
@@ -397,13 +430,6 @@ extern char *defpath;              /* pathname of user's profile      */
 extern char *ctxpath;          /* pathname of user's context      */
 extern struct node *m_defs;    /* list of profile/context entries */
 
-/* What style to use for generated Message-ID and Content-ID header
-   fields.  The localname style is pid.time@localname, where time is
-   in seconds.  The random style replaces the localname with some
-   (pseudo)random bytes and uses microsecond-resolution time. */
-int save_message_id_style (const char *);
-char *message_id (time_t, int);
-
 /*
  * These standard strings are defined in config.c.  They are the
  * only system-dependent parameters in nmh, and thus by redefining
@@ -416,6 +442,7 @@ extern char *components;
 extern char *context;
 extern char *current;
 extern char *credentials_file;
+extern int credentials_no_perm_check;
 extern char *defaultfolder;
 extern char *digestcomps;
 extern char *distcomps;
@@ -456,6 +483,7 @@ extern char *sendproc;
 extern char *showmimeproc;
 extern char *showproc;
 extern char *usequence;
+extern char *user_agent;
 extern char *version_num;
 extern char *version_str;
 extern char *whatnowproc;
@@ -464,4 +492,3 @@ extern char *whomproc;
 extern void (*done) (int) NORETURN;
 
 #include <h/prototypes.h>
-