release 0.92.3
[cntlm.git] / auth.h
blobf083afaa20b06a485d058a257a793fcb51279ebc
1 /*
2 * Credentials related structures and routines for the main module of CNTLM
4 * CNTLM is free software; you can redistribute it and/or modify it under the
5 * terms of the GNU General Public License as published by the Free Software
6 * Foundation; either version 2 of the License, or (at your option) any later
7 * version.
9 * CNTLM is distributed in the hope that it will be useful, but WITHOUT ANY
10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 * details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
16 * St, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Copyright (c) 2007 David Kubicek
22 #ifndef _AUTH_H
23 #define _AUTH_H
25 #include <stdint.h>
27 #include "utils.h"
30 * Although I always prefer structs with pointer refs, I need direct storage
31 * here to be able to alloc/free it in one go. It is used in a plist_t which
32 * frees its items, but not recursively.
34 struct auth_s {
35 char user[MINIBUF_SIZE];
36 char domain[MINIBUF_SIZE];
37 char workstation[MINIBUF_SIZE];
38 char passlm[MINIBUF_SIZE];
39 char passnt[MINIBUF_SIZE];
40 char passntlm2[MINIBUF_SIZE];
41 int hashntlm2;
42 int hashnt;
43 int hashlm;
44 uint32_t flags;
47 #define auth_strcpy(creds, var, value) \
48 if ((creds) && (value)) { \
49 strlcpy(((creds)->var), (value), MINIBUF_SIZE); \
52 #define auth_memcpy(creds, var, value, len) \
53 if ((creds) && (value)) { \
54 memcpy(((creds)->var), (value), MIN(len, MINIBUF_SIZE)); \
58 * No free_auth() required, just use free()
59 * new_auth() is also just a convenience malloc/memset() wrapper
61 extern struct auth_s *new_auth(void);
62 extern struct auth_s *copy_auth(struct auth_s *dst, struct auth_s *src, int fullcopy);
63 extern struct auth_s *dup_auth(struct auth_s *creds, int fullcopy);
64 extern void dump_auth(struct auth_s *creds);
66 #endif /* _AUTH_H */