libenigma
Enigma machine utility library
Loading...
Searching...
No Matches
reflector.c File Reference
#include "reflector.h"
#include "common.h"
#include "io.h"
#include <ctype.h>
#include <stddef.h>
#include <string.h>

Functions

int enigma_reflector_generate_indices (EnigmaReflector *reflector, const char *alphabet)
 Generate the indices for the reflector.
 
const char * enigma_reflector_get_name (const EnigmaReflector *reflector)
 Get the name of the reflector.
 
const int * enigma_reflector_get_indices (const EnigmaReflector *reflector)
 Get the indices of the reflector.
 
int enigma_reflector_set_name (EnigmaReflector *reflector, const char *name)
 Set the name of the reflector.
 
int enigma_reflector_set_indices (EnigmaReflector *reflector, const int *indices)
 Set the indices of the reflector.
 

Detailed Description

This file contains functions for reflector manipulation and getters/setters for WASM.

Function Documentation

◆ enigma_reflector_generate_indices()

int enigma_reflector_generate_indices ( EnigmaReflector reflector,
const char *  alphabet 
)

Generate the indices for the reflector.

Parameters
reflectorThe reflector to generate the indices for.
alphabetThe alphabet to generate the indices from.
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure.

◆ enigma_reflector_get_indices()

const int * enigma_reflector_get_indices ( const EnigmaReflector reflector)

Get the indices of the reflector.

Parameters
reflectorThe reflector to get the indices of.
Returns
The indices of the reflector.

◆ enigma_reflector_get_name()

const char * enigma_reflector_get_name ( const EnigmaReflector reflector)

Get the name of the reflector.

Parameters
reflectorThe reflector to get the name of.
Returns
The name of the reflector.

◆ enigma_reflector_set_indices()

int enigma_reflector_set_indices ( EnigmaReflector reflector,
const int *  indices 
)

Set the indices of the reflector.

Parameters
reflectorThe reflector to set the indices of.
indicesThe indices to set.
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure.

◆ enigma_reflector_set_name()

int enigma_reflector_set_name ( EnigmaReflector reflector,
const char *  name 
)

Set the name of the reflector.

This function sets the name of the reflector (uses strdup, make sure to free this memory when done).

Parameters
reflectorThe reflector to set the name of.
nameThe name to set.
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure.