3 * Framework for checking consistency of keys
5 * (c) 2001 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 #ifndef CATACOMB_KEYCHECK_H
29 #define CATACOMB_KEYCHECK_H
35 /*----- Header files ------------------------------------------------------*/
41 /*----- Data structures ---------------------------------------------------*/
45 KCSEV_INFO
= KCSEV_ALL
,
51 typedef struct keycheck
{
52 unsigned sev
[KCSEV_MAX
];
53 int (*func
)(unsigned /*sev*/, const char */
*msg*/
, void */
*p*/
);
57 typedef struct keycheck_reportctx
{
62 /*----- Generic functions -------------------------------------------------*/
64 /* --- @keycheck_report@ --- *
66 * Arguments: @keycheck *kc@ = keycheck state
67 * @unsigned sev@ = severity of this report
68 * @const char *msg@ = message to send along
69 * @...@ = things to fill the message in with
71 * Returns: Zero to continue, or nonzero to stop and give up.
73 * Use: Reports a message to the user function.
76 extern int keycheck_report(keycheck */
*kc*/
, unsigned /*sev*/,
77 const char */
*msg*/
, ...);
79 /* --- @keycheck_init@ --- *
81 * Arguments: @keycheck *kc@ = pointer to block to initialize
82 * @int (*func)(unsigned sev, const char *msg, void *p)@ =
83 * handler function for problems
84 * @void *p@ = pointer to give to handler
88 * Use: Initializes a key checking context.
91 extern void keycheck_init(keycheck */
*kc*/
,
92 int (*/
*func*/
)(unsigned /*sev*/,
97 /* --- @keycheck_allclear@ --- *
99 * Arguments: @keycheck *kc@ = pointer to keycheck context
100 * @unsigned sev@ = minimum severity to care about
102 * Returns: Nonzero if no problems of @sev@ or above were noticed.
105 extern int keycheck_allclear(keycheck */
*kc*/
, unsigned /*sev*/);
107 /*----- A standard report function ----------------------------------------*/
109 /* --- @keycheck_stdreport@ --- *
111 * Arguments: @unsigned sev@ = problem severity
112 * @const char *msg@ = message to report
113 * @void *p@ = pointer to a @keycheck_reportctx@ structure
117 * Use: Reports a message to stderr.
120 extern int keycheck_stdreport(unsigned /*sev*/,
121 const char */
*msg*/
, void */
*p*/
);
123 /*----- Special support functions for large integers ----------------------*/
125 /* --- @keycheck_prime@ --- *
127 * Arguments: @keycheck *kc@ = keycheck state
128 * @unsigned sev@ = severity if not prime
129 * @mp *m@ = a number to check for primality
130 * @const char *name@ = name of this number
132 * Returns: Zero if OK, or return status from function.
134 * Use: Checks that a number is prime.
137 extern int keycheck_prime(keycheck */
*kc*/
, unsigned /*sev*/,
138 mp */
*m*/
, const char */
*name*/
);
140 /*----- That's all, folks -------------------------------------------------*/