// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Command line arguments helpers
 *
 * Copyright (C) 2020-2024 Red Hat, Inc. All rights reserved.
 * Copyright (C) 2020-2024 Ondrej Kozina
 */

#ifndef CRYPTSETUP_ARGS_H
#define CRYPTSETUP_ARGS_H

#include "utils_arg_names.h"
#include "utils_arg_macros.h"

#define ADDKEY_ACTION		"luksAddKey"
#define BITLKDUMP_ACTION	"bitlkDump"
#define BENCHMARK_ACTION	"benchmark"
#define CHANGEKEY_ACTION	"luksChangeKey"
#define CLOSE_ACTION		"close"
#define CONVERTKEY_ACTION	"luksConvertKey"
#define CONFIG_ACTION		"config"
#define CONVERT_ACTION		"convert"
#define ERASE_ACTION		"erase"
#define FORMAT_ACTION		"luksFormat"
#define FVAULT2DUMP_ACTION	"fvault2Dump"
#define HEADERBACKUP_ACTION	"luksHeaderBackup"
#define HEADERRESTORE_ACTION	"luksHeaderRestore"
#define ISLUKS_ACTION		"isLuks"
#define KILLKEY_ACTION		"luksKillSlot"
#define LUKSDUMP_ACTION		"luksDump"
#define OPEN_ACTION		"open"
#define REENCRYPT_ACTION	"reencrypt"
#define REMOVEKEY_ACTION	"luksRemoveKey"
#define REPAIR_ACTION		"repair"
#define RESIZE_ACTION		"resize"
#define RESUME_ACTION		"luksResume"
#define STATUS_ACTION		"status"
#define SUSPEND_ACTION		"luksSuspend"
#define TCRYPTDUMP_ACTION	"tcryptDump"
#define TOKEN_ACTION		"token"
#define UUID_ACTION		"luksUUID"

/* avoid unshielded commas in ARG() macros later */
#define OPT_ALIGN_PAYLOAD_ACTIONS		{ FORMAT_ACTION, REENCRYPT_ACTION }
#define OPT_ALLOW_DISCARDS_ACTIONS		{ OPEN_ACTION }
#define OPT_DEFERRED_ACTIONS			{ CLOSE_ACTION }
#define OPT_DEVICE_SIZE_ACTIONS			{ OPEN_ACTION, RESIZE_ACTION, REENCRYPT_ACTION }
#define OPT_DISABLE_BLKID_ACTIONS		{ FORMAT_ACTION, REENCRYPT_ACTION }
#define OPT_DISABLE_VERACRYPT_ACTIONS		{ OPEN_ACTION, TCRYPTDUMP_ACTION }
#define OPT_ERASE_ACTIONS			{ ERASE_ACTION }
#define OPT_EXTERNAL_TOKENS_PATH_ACTIONS	{ RESIZE_ACTION, OPEN_ACTION, ADDKEY_ACTION, LUKSDUMP_ACTION, RESUME_ACTION, TOKEN_ACTION }
#define OPT_FORCE_OFFLINE_REENCRYPT_ACTIONS	{ REENCRYPT_ACTION }
#define OPT_HOTZONE_SIZE_ACTIONS		{ REENCRYPT_ACTION }
#define OPT_HW_OPAL_ACTIONS			{ FORMAT_ACTION }
#define OPT_HW_OPAL_ONLY_ACTIONS		OPT_HW_OPAL_ACTIONS
#define OPT_INTEGRITY_ACTIONS			{ FORMAT_ACTION }
#define OPT_INTEGRITY_NO_WIPE_ACTIONS		{ FORMAT_ACTION }
#define OPT_ITER_TIME_ACTIONS			{ BENCHMARK_ACTION, FORMAT_ACTION, ADDKEY_ACTION, CHANGEKEY_ACTION, CONVERTKEY_ACTION, REENCRYPT_ACTION }
#define OPT_IV_LARGE_SECTORS_ACTIONS		{ OPEN_ACTION }
#define OPT_KEEP_KEY_ACTIONS			{ REENCRYPT_ACTION }
#define OPT_KEY_DESCRIPTION_ACTIONS		{ TOKEN_ACTION }
#define OPT_KEY_SIZE_ACTIONS			{ OPEN_ACTION, BENCHMARK_ACTION, FORMAT_ACTION, REENCRYPT_ACTION, ADDKEY_ACTION }
#define OPT_KEY_SLOT_ACTIONS			{ OPEN_ACTION, REENCRYPT_ACTION, CONFIG_ACTION, FORMAT_ACTION, ADDKEY_ACTION, CHANGEKEY_ACTION, CONVERTKEY_ACTION, LUKSDUMP_ACTION, TOKEN_ACTION, RESUME_ACTION }
#define OPT_KEYSLOT_CIPHER_ACTIONS		{ FORMAT_ACTION, REENCRYPT_ACTION, ADDKEY_ACTION, CHANGEKEY_ACTION, CONVERTKEY_ACTION }
#define OPT_KEYSLOT_KEY_SIZE_ACTIONS		OPT_KEYSLOT_CIPHER_ACTIONS
#define OPT_LABEL_ACTIONS			{ CONFIG_ACTION, FORMAT_ACTION, REENCRYPT_ACTION }
#define OPT_LINK_VK_TO_KEYRING_ACTIONS		{ OPEN_ACTION, RESUME_ACTION }
#define OPT_LUKS2_KEYSLOTS_SIZE_ACTIONS		{ REENCRYPT_ACTION, FORMAT_ACTION }
#define OPT_LUKS2_METADATA_SIZE_ACTIONS		{ REENCRYPT_ACTION, FORMAT_ACTION }
#define OPT_NEW_KEYFILE_ACTIONS			{ ADDKEY_ACTION }
#define OPT_NEW_KEY_SLOT_ACTIONS		{ ADDKEY_ACTION }
#define OPT_NEW_TOKEN_ID_ACTIONS		{ ADDKEY_ACTION }
#define OPT_OFFSET_ACTIONS			{ OPEN_ACTION, REENCRYPT_ACTION, FORMAT_ACTION }
#define OPT_PBKDF_ACTIONS			{ BENCHMARK_ACTION, FORMAT_ACTION, ADDKEY_ACTION, CHANGEKEY_ACTION, CONVERTKEY_ACTION, REENCRYPT_ACTION }
#define OPT_PBKDF_FORCE_ITERATIONS_ACTIONS	{ FORMAT_ACTION, ADDKEY_ACTION, CHANGEKEY_ACTION, CONVERTKEY_ACTION, REENCRYPT_ACTION }
#define OPT_PERSISTENT_ACTIONS			{ OPEN_ACTION }
#define OPT_PRIORITY_ACTIONS			{ CONFIG_ACTION }
#define OPT_PROGRESS_JSON_ACTIONS		{ FORMAT_ACTION, REENCRYPT_ACTION }
#define OPT_REFRESH_ACTIONS			{ OPEN_ACTION }
#define OPT_SECTOR_SIZE_ACTIONS			{ OPEN_ACTION, REENCRYPT_ACTION, FORMAT_ACTION }
#define OPT_SERIALIZE_MEMORY_HARD_PBKDF_ACTIONS { OPEN_ACTION }
#define OPT_SHARED_ACTIONS			{ OPEN_ACTION }
#define OPT_SIZE_ACTIONS			{ OPEN_ACTION, RESIZE_ACTION }
#define OPT_SKIP_ACTIONS			{ OPEN_ACTION }
#define OPT_SUBSYSTEM_ACTIONS			{ CONFIG_ACTION, FORMAT_ACTION, REENCRYPT_ACTION }
#define OPT_TCRYPT_BACKUP_ACTIONS		{ OPEN_ACTION, TCRYPTDUMP_ACTION }
#define OPT_TCRYPT_HIDDEN_ACTIONS		{ OPEN_ACTION, TCRYPTDUMP_ACTION }
#define OPT_TCRYPT_SYSTEM_ACTIONS		{ OPEN_ACTION, TCRYPTDUMP_ACTION }
#define OPT_TEST_PASSPHRASE_ACTIONS		{ OPEN_ACTION }
#define OPT_TOKEN_REPLACE_ACTIONS		{ TOKEN_ACTION }
#define OPT_UNBOUND_ACTIONS			{ ADDKEY_ACTION, LUKSDUMP_ACTION, OPEN_ACTION, TOKEN_ACTION }
#define OPT_USE_RANDOM_ACTIONS			{ FORMAT_ACTION, REENCRYPT_ACTION }
#define OPT_USE_URANDOM_ACTIONS			{ FORMAT_ACTION, REENCRYPT_ACTION }
#define OPT_UUID_ACTIONS			{ FORMAT_ACTION, UUID_ACTION, REENCRYPT_ACTION }
#define OPT_VERACRYPT_PIM_ACTIONS		{ OPEN_ACTION, TCRYPTDUMP_ACTION }
#define OPT_VERACRYPT_QUERY_PIM_ACTIONS		{ OPEN_ACTION, TCRYPTDUMP_ACTION }

enum {
OPT_UNUSED_ID = 0, /* leave unused due to popt library */
#define ARG(A, B, C, D, E, F, G, H) A ## _ID,
#include "cryptsetup_arg_list.h"
#undef ARG
};

extern struct tools_arg tool_core_args[];

#endif
