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 PRINTF_LIKE(3, 4)
77 keycheck_report(keycheck */*kc*/, unsigned /*sev*/,
78 const char */*msg*/, ...);
80 /* --- @keycheck_init@ --- *
82 * Arguments: @keycheck *kc@ = pointer to block to initialize
83 * @int (*func)(unsigned sev, const char *msg, void *p)@ =
84 * handler function for problems
85 * @void *p@ = pointer to give to handler
89 * Use: Initializes a key checking context.
92 extern void keycheck_init(keycheck */*kc*/,
93 int (*/*func*/)(unsigned /*sev*/,
98 /* --- @keycheck_allclear@ --- *
100 * Arguments: @keycheck *kc@ = pointer to keycheck context
101 * @unsigned sev@ = minimum severity to care about
103 * Returns: Nonzero if no problems of @sev@ or above were noticed.
106 extern int keycheck_allclear(keycheck */*kc*/, unsigned /*sev*/);
108 /*----- A standard report function ----------------------------------------*/
110 /* --- @keycheck_stdreport@ --- *
112 * Arguments: @unsigned sev@ = problem severity
113 * @const char *msg@ = message to report
114 * @void *p@ = pointer to a @keycheck_reportctx@ structure
118 * Use: Reports a message to stderr.
121 extern int keycheck_stdreport(unsigned /*sev*/,
122 const char */*msg*/, void */*p*/);
124 /*----- Special support functions for large integers ----------------------*/
126 /* --- @keycheck_prime@ --- *
128 * Arguments: @keycheck *kc@ = keycheck state
129 * @unsigned sev@ = severity if not prime
130 * @mp *m@ = a number to check for primality
131 * @const char *name@ = name of this number
133 * Returns: Zero if OK, or return status from function.
135 * Use: Checks that a number is prime.
138 extern int keycheck_prime(keycheck */*kc*/, unsigned /*sev*/,
139 mp */*m*/, const char */*name*/);
141 /*----- That's all, folks -------------------------------------------------*/