libenigma
Enigma machine utility library
Loading...
Searching...
No Matches
reflector.h
Go to the documentation of this file.
1
6#ifndef ENIGMA_REFLECTOR_H
7#define ENIGMA_REFLECTOR_H
8
9#include "common.h"
10
14#define ENIGMA_REFLECTOR_COUNT 3
15
22typedef struct {
23 const char* name;
24 int indices[ENIGMA_ALPHA_SIZE];
26
32static const EnigmaReflector enigma_UKW_A = {
33 .name = "A",
34 .indices
35 = { 4, 9, 12, 25, 0, 1, 11, 23, 14, 19, 18, 17, 16, 15, 13, 10, 3, 2, 5, 6, 7, 8, 20, 21, 22 },
36};
37
43static const EnigmaReflector enigma_UKW_B = {
44 .name = "B",
45 .indices = { 24, 17, 20, 7, 16, 18, 11, 3, 15, 23, 13, 6, 14,
46 10, 12, 8, 4, 1, 5, 25, 2, 22, 21, 9, 0, 19 },
47};
48
54static const EnigmaReflector enigma_UKW_C = {
55 .name = "C",
56 .indices = { 5, 21, 15, 9, 8, 0, 14, 24, 4, 3, 17, 25, 23,
57 22, 6, 2, 19, 10, 20, 16, 18, 1, 13, 12, 7, 11 },
58};
59
63static const EnigmaReflector* enigma_reflectors[] = {
64 &enigma_UKW_A,
65 &enigma_UKW_B,
66 &enigma_UKW_C,
67};
68
70
71/* --- EnigmaReflector getters and setters --- */
76
77#endif
#define ENIGMA_ALPHA_SIZE
Defines the size of the alphabet used in the Enigma machine.
Definition: common.h:18
const int * enigma_reflector_get_indices(const EnigmaReflector *)
Get the indices of the reflector.
Definition: reflector.c:53
int enigma_reflector_set_indices(EnigmaReflector *, const int *)
Set the indices of the reflector.
Definition: reflector.c:86
int enigma_reflector_generate_indices(EnigmaReflector *, const char *)
Generate the indices for the reflector.
Definition: reflector.c:22
int enigma_reflector_set_name(EnigmaReflector *, const char *)
Set the name of the reflector.
Definition: reflector.c:71
const char * enigma_reflector_get_name(const EnigmaReflector *)
Get the name of the reflector.
Definition: reflector.c:39
Represents a reflector configuration for the Enigma machine.
Definition: reflector.h:22
const char * name
Name of the reflector.
Definition: reflector.h:23