+ * There are two main things which need to be configured: stepping, and
+ * testing. (Filtering is done as part of stepping.)
+ *
+ * The functions here provide a toolkit for constructing stepping and testing
+ * routines. In a lot of cases, the functions can be used directly; in
+ * others, simple bits of glue need be written.
+ *
+ * Two types of functions are defined: steppers and testers, but their
+ * interfaces are substantially similar. Each is given a request code, a
+ * context block and an event block. It is meant to update its context and
+ * the event block and return an event code.
+ *
+ * A call with a request of @PGEN_BEGIN@ asks the stepper or tester to
+ * initialize itself using the information in its event block and context. A
+ * return of @PGEN_FAIL@ reports an immediate failure; @PGEN_ABORT@ reports a
+ * fatal problem; @PGEN_DONE@ reports immediate success. @PGEN_TRY@ reports
+ * successful initialization and requests test iterations.
+ *
+ * A call to a stepper with a request of @PGEN_TRY@ asks it to step to the
+ * next possible candidate, replacing the value @m@ in the event block with
+ * the new candidate. A call to a tester with a request of @PGEN_TRY@
+ * runs one pass of the test. It should return @PGEN_FAIL@ to report a
+ * failure, @PGEN_PASS@ to report a success and request another iteration,
+ * @PGEN_DONE@ to report final acceptance and @PGEN_ABORT@ to terminate the
+ * search unsuccessfully. Note that even if the search is aborted, a
+ * shutdown request is still made.
+ *
+ * A call with a request of @PGEN_DONE@ closes down the stepper or tester.
+ * After a successful initialization (i.e., a return of something other than
+ * @PGEN_ABORT@), a shutdown call is guaranteed. The return code is ignored.
+ */
+
+typedef int pgen_proc(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+
+/*----- Simple handler functions ------------------------------------------*/
+
+/* --- @pgen_filter@ --- *
+ *
+ * A prime generation context contains the information required for the
+ * simple prime filter and tester presented here.
+ */
+
+typedef struct pgen_filterctx {
+ unsigned step; /* Step size (set by client) */
+ pfilt f; /* The rapid prime filter */
+} pgen_filterctx;
+
+extern int pgen_filter(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+
+/* --- @pgen_jump@ --- *