Add an internal-representation no-op function.
[u/mdw/catacomb] / grand.h
diff --git a/grand.h b/grand.h
index 04925bb..160663e 100644 (file)
--- a/grand.h
+++ b/grand.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: grand.h,v 1.1 1999/12/10 23:16:01 mdw Exp $
+ * $Id: grand.h,v 1.4 2001/04/19 18:23:53 mdw Exp $
  *
  * Generic interface to random number generators
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: grand.h,v $
+ * Revision 1.4  2001/04/19 18:23:53  mdw
+ * Use unsigned integer rather than enum for flags.
+ *
+ * Revision 1.3  2001/02/03 16:07:33  mdw
+ * Give generic random objects separate namespaces for their supported misc
+ * ops.
+ *
+ * Revision 1.2  2000/06/17 11:23:11  mdw
+ * Typesetting fix.  Add a flags word to the generic generator.
+ *
  * Revision 1.1  1999/12/10 23:16:01  mdw
  * Generic interface.
  *
@@ -60,6 +70,7 @@ typedef struct grand_ops {
   /* --- Various important properties --- */
 
   const char *name;                    /* Generator's name */
+  unsigned f;                          /* Various flags */
   uint32 max;                          /* Maximum raw output */
 
   /* --- Maintenance methods --- */
@@ -75,12 +86,16 @@ typedef struct grand_ops {
    */
 
   uint32 (*raw)(grand */*r*/);         /* Uniform over %$[0, max)$% */
-  octet (*byte)(grand */*r*/);         /* Uniform over %$[0, 256)%$ */
+  octet (*byte)(grand */*r*/);         /* Uniform over %$[0, 256)$% */
   uint32 (*word)(grand */*r*/);                /* Uniform over %$[0, 2^{32})$% */
   uint32 (*range)(grand */*r*/, uint32 /*l*/); /* Uniform over %$[0, l)$% */
   void (*fill)(grand */*r*/, void */*p*/, size_t /*sz*/); /* Fill buffer */
 } grand_ops;
 
+/* --- Flag types --- */
+
+#define GRAND_CRYPTO 1u                        /* Cryptographically strong */
+
 /* --- Operation types --- */
 
 enum {
@@ -95,11 +110,11 @@ enum {
   GRAND_SEEDUINT32,                    /* @uint32 i@ */
   GRAND_SEEDBLOCK,                     /* @const void *p, size_t sz@ */
   GRAND_SEEDMP,                                /* @mp *m@ */
-  GRAND_SEEDRAND,                      /* @grand *g@ */
+  GRAND_SEEDRAND                       /* @grand *g@ */
 
   /* --- Generator-specific operations --- */
 
-  GRAND_SPECIFIC = 256u
+#define GRAND_SPECIFIC(ch) ((unsigned)(ch) << 8) 
 };
 
 #define GRAND_BADOP assert(((void)"bad grand_misc op", 0))