build - Separate out CFLAGS for kernel & module build
[dragonfly.git] / contrib / pam_passwdqc / pam_macros.h
blob764d682260c8aac21b2d90a8e13286c8fa11b1ca
1 /*
2 * These macros are partially based on Linux-PAM's <security/_pam_macros.h>,
3 * which were organized by Cristian Gafton and I believe are in the public
4 * domain.
5 */
7 #ifndef PAM_PASSWDQC_MACROS_H__
8 #define PAM_PASSWDQC_MACROS_H__
10 #include <string.h>
11 #include <stdlib.h>
13 static __inline void
14 pwqc_overwrite_string(char *x)
16 if (x)
17 memset(x, 0, strlen(x));
20 static __inline void
21 pwqc_drop_mem(void *x)
23 if (x) {
24 free(x);
25 x = NULL;
29 static __inline void
30 pwqc_drop_pam_reply(struct pam_response *reply, int replies)
32 if (reply) {
33 int reply_i;
35 for (reply_i = 0; reply_i < replies; ++reply_i) {
36 pwqc_overwrite_string(reply[reply_i].resp);
37 pwqc_drop_mem(reply[reply_i].resp);
39 pwqc_drop_mem(reply);
43 #endif /* PAM_PASSWDQC_MACROS_H__ */