3 * $Id: keycheck.h,v 1.2 2004/04/08 01:36:15 mdw Exp $
5 * Framework for checking consistency of keys
7 * (c) 2001 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 #ifndef CATACOMB_KEYCHECK_H
31 #define CATACOMB_KEYCHECK_H
37 /*----- Header files ------------------------------------------------------*/
43 /*----- Data structures ---------------------------------------------------*/
47 KCSEV_INFO
= KCSEV_ALL
,
53 typedef struct keycheck
{
54 unsigned sev
[KCSEV_MAX
];
55 int (*func
)(unsigned /*sev*/, const char */
*msg*/
, void */
*p*/
);
59 typedef struct keycheck_reportctx
{
64 /*----- Generic functions -------------------------------------------------*/
66 /* --- @keycheck_report@ --- *
68 * Arguments: @keycheck *kc@ = keycheck state
69 * @unsigned sev@ = severity of this report
70 * @const char *msg@ = message to send along
71 * @...@ = things to fill the message in with
73 * Returns: Zero to continue, or nonzero to stop and give up.
75 * Use: Reports a message to the user function.
78 extern int keycheck_report(keycheck */
*kc*/
, unsigned /*sev*/,
79 const char */
*msg*/
, ...);
81 /* --- @keycheck_init@ --- *
83 * Arguments: @keycheck *kc@ = pointer to block to initialize
84 * @int (*func)(unsigned sev, const char *msg, void *p)@ =
85 * handler function for problems
86 * @void *p@ = pointer to give to handler
90 * Use: Initializes a key checking context.
93 extern void keycheck_init(keycheck */
*kc*/
,
94 int (*/
*func*/
)(unsigned /*sev*/,
99 /* --- @keycheck_allclear@ --- *
101 * Arguments: @keycheck *kc@ = pointer to keycheck context
102 * @unsigned sev@ = minimum severity to care about
104 * Returns: Nonzero if no problems of @sev@ or above were noticed.
107 extern int keycheck_allclear(keycheck */
*kc*/
, unsigned /*sev*/);
109 /*----- A standard report function ----------------------------------------*/
111 /* --- @keycheck_stdreport@ --- *
113 * Arguments: @unsigned sev@ = problem severity
114 * @const char *msg@ = message to report
115 * @void *p@ = pointer to a @keycheck_reportctx@ structure
119 * Use: Reports a message to stderr.
122 extern int keycheck_stdreport(unsigned /*sev*/,
123 const char */
*msg*/
, void */
*p*/
);
125 /*----- Special support functions for large integers ----------------------*/
127 /* --- @keycheck_prime@ --- *
129 * Arguments: @keycheck *kc@ = keycheck state
130 * @unsigned sev@ = severity if not prime
131 * @mp *m@ = a number to check for primality
132 * @const char *name@ = name of this number
134 * Returns: Zero if OK, or return status from function.
136 * Use: Checks that a number is prime.
139 extern int keycheck_prime(keycheck */
*kc*/
, unsigned /*sev*/,
140 mp */
*m*/
, const char */
*name*/
);
142 /*----- That's all, folks -------------------------------------------------*/