Change License from GPLv2 only to GPLv2+ ("or any later").
[platform/upstream/cryptsetup.git] / src / cryptsetup.h
1 /*
2  * cryptsetup - setup cryptographic volumes for dm-crypt
3  *
4  * Copyright (C) 2004, Christophe Saout <christophe@saout.de>
5  * Copyright (C) 2004-2007, Clemens Fruhwirth <clemens@endorphin.org>
6  * Copyright (C) 2009-2012, Red Hat, Inc. All rights reserved.
7  * Copyright (C) 2009-2012, Milan Broz
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23
24 #ifndef CRYPTSETUP_H
25 #define CRYPTSETUP_H
26
27 #define _LARGEFILE64_SOURCE
28 #define _FILE_OFFSET_BITS 64
29
30 #include <config.h>
31
32 #include <string.h>
33 #include <stdlib.h>
34 #include <stdarg.h>
35 #include <stdio.h>
36 #include <stdint.h>
37 #include <errno.h>
38 #include <unistd.h>
39 #include <inttypes.h>
40 #include <limits.h>
41 #include <ctype.h>
42 #include <fcntl.h>
43 #include <popt.h>
44 #include <sys/stat.h>
45
46 #include "lib/nls.h"
47 #include "lib/utils_crypt.h"
48 #include "lib/utils_loop.h"
49 #include "lib/utils_fips.h"
50
51 #include "libcryptsetup.h"
52
53 #define CONST_CAST(x) (x)(uintptr_t)
54 #define DEFAULT_CIPHER(type)    (DEFAULT_##type##_CIPHER "-" DEFAULT_##type##_MODE)
55 #define SECTOR_SIZE 512
56 #define ROUND_SECTOR(x) (((x) + SECTOR_SIZE - 1) / SECTOR_SIZE)
57
58 extern int opt_debug;
59 extern int opt_verbose;
60 extern int opt_batch_mode;
61 extern int opt_force_password;
62
63 /* Common tools */
64 void clogger(struct crypt_device *cd, int level, const char *file, int line,
65              const char *format, ...);
66 void tool_log(int level, const char *msg, void *usrptr __attribute__((unused)));
67 void quiet_log(int level, const char *msg, void *usrptr);
68
69 int yesDialog(const char *msg, void *usrptr __attribute__((unused)));
70 void show_status(int errcode);
71 const char *uuid_or_device(const char *spec);
72 void usage(poptContext popt_context, int exitcode, const char *error, const char *more);
73 void dbg_version_and_cmd(int argc, const char **argv);
74 int translate_errno(int r);
75
76 extern volatile int quit;
77 void set_int_block(int block);
78 void set_int_handler(int block);
79 void check_signal(int *r);
80 int tools_signals_blocked(void);
81
82 int tools_get_key(const char *prompt,
83                   char **key, size_t *key_size,
84                   size_t keyfile_offset, size_t keyfile_size_max,
85                   const char *key_file,
86                   int timeout, int verify, int pwquality,
87                   struct crypt_device *cd);
88
89 /* Log */
90 #define log_dbg(x...) clogger(NULL, CRYPT_LOG_DEBUG, __FILE__, __LINE__, x)
91 #define log_std(x...) clogger(NULL, CRYPT_LOG_NORMAL, __FILE__, __LINE__, x)
92 #define log_verbose(x...) clogger(NULL, CRYPT_LOG_VERBOSE, __FILE__, __LINE__, x)
93 #define log_err(x...) clogger(NULL, CRYPT_LOG_ERROR, __FILE__, __LINE__, x)
94
95 #endif /* CRYPTSETUP_H */