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

Functions

int enigma_rotor_generate_indices (EnigmaRotor *rotor, const char *alphabet)
 Generate the indices for the rotor.
 
const char * enigma_rotor_get_name (const EnigmaRotor *rotor)
 Get the name of the rotor.
 
const int * enigma_rotor_get_fwd_indices (const EnigmaRotor *rotor)
 Get the forward indices of the rotor.
 
const int * enigma_rotor_get_rev_indices (const EnigmaRotor *rotor)
 Get the reverse indices of the rotor.
 
const int * enigma_rotor_get_notches (const EnigmaRotor *rotor)
 Get the notches of the rotor.
 
int enigma_rotor_get_notches_count (const EnigmaRotor *rotor)
 Get the number of notches of the rotor.
 
int enigma_rotor_set_name (EnigmaRotor *rotor, const char *name)
 Set the name of the rotor.
 
int enigma_rotor_set_fwd_indices (EnigmaRotor *rotor, const int *indices)
 Set the forward indices of the rotor.
 
int enigma_rotor_set_rev_indices (EnigmaRotor *rotor, const int *indices)
 Set the reverse indices of the rotor.
 
int enigma_rotor_set_notches (EnigmaRotor *rotor, const int *notches, int count)
 Set the notches of the rotor.
 
int enigma_rotor_set_notches_count (EnigmaRotor *rotor, int count)
 Set the notches count of the rotor.
 

Detailed Description

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

Function Documentation

◆ enigma_rotor_generate_indices()

int enigma_rotor_generate_indices ( EnigmaRotor rotor,
const char *  alphabet 
)

Generate the indices for the rotor.

This function generates the indices for the rotor.

Parameters
rotorThe rotor to generate the indices for.
alphabetThe alphabet to generate the indices from.
Returns
ENIGMA_SUCCESS on success, or ENIGMA_FAILURE on failure.

◆ enigma_rotor_get_fwd_indices()

const int * enigma_rotor_get_fwd_indices ( const EnigmaRotor rotor)

Get the forward indices of the rotor.

This function gets the forward indices of the rotor.

Parameters
rotorThe rotor to get the forward indices of.
Returns
the forward indices of the rotor on success, or NULL on failure.

◆ enigma_rotor_get_name()

const char * enigma_rotor_get_name ( const EnigmaRotor rotor)

Get the name of the rotor.

This function gets the name of the rotor.

Parameters
rotorThe rotor to get the name of.
Returns
the name of the rotor on success, or NULL on failure.

◆ enigma_rotor_get_notches()

const int * enigma_rotor_get_notches ( const EnigmaRotor rotor)

Get the notches of the rotor.

This function gets the notches of the rotor.

Parameters
rotorThe rotor to get the notches of.
Returns
the notches of the rotor on success, or NULL on failure.

◆ enigma_rotor_get_notches_count()

int enigma_rotor_get_notches_count ( const EnigmaRotor rotor)

Get the number of notches of the rotor.

This function gets the number of notches of the rotor.

Parameters
rotorThe rotor to get the number of notches of.
Returns
the number of notches of the rotor on success, or ENIGMA_FAILURE on failure.

◆ enigma_rotor_get_rev_indices()

const int * enigma_rotor_get_rev_indices ( const EnigmaRotor rotor)

Get the reverse indices of the rotor.

This function gets the reverse indices of the rotor.

Parameters
rotorThe rotor to get the reverse indices of.
Returns
the reverse indices of the rotor on success, or NULL on failure.

◆ enigma_rotor_set_fwd_indices()

int enigma_rotor_set_fwd_indices ( EnigmaRotor rotor,
const int *  indices 
)

Set the forward indices of the rotor.

This function sets the forward indices of the rotor.

Parameters
rotorThe rotor to set the forward indices of.
indicesThe forward indices to set.
Returns
ENIGMA_SUCCESS on success, or ENIGMA_FAILURE on failure.

◆ enigma_rotor_set_name()

int enigma_rotor_set_name ( EnigmaRotor rotor,
const char *  name 
)

Set the name of the rotor.

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

Parameters
rotorThe rotor to set the name of.
nameThe name to set.
Returns
ENIGMA_SUCCESS on success, or ENIGMA_FAILURE on failure.

◆ enigma_rotor_set_notches()

int enigma_rotor_set_notches ( EnigmaRotor rotor,
const int *  notches,
int  count 
)

Set the notches of the rotor.

This function sets the notches of the rotor.

Parameters
rotorThe rotor to set the notches of.
notchesThe notches to set.
countThe number of notches.
Returns
ENIGMA_SUCCESS on success, or ENIGMA_FAILURE on failure.

◆ enigma_rotor_set_notches_count()

int enigma_rotor_set_notches_count ( EnigmaRotor rotor,
int  count 
)

Set the notches count of the rotor.

This function sets the notches count of the rotor.

Parameters
rotorThe rotor to set the notches count of.
countThe notches count to set.
Returns
ENIGMA_SUCCESS on success, or ENIGMA_FAILURE on failure.

◆ enigma_rotor_set_rev_indices()

int enigma_rotor_set_rev_indices ( EnigmaRotor rotor,
const int *  indices 
)

Set the reverse indices of the rotor.

This function sets the reverse indices of the rotor.

Parameters
rotorThe rotor to set the reverse indices of.
indicesThe reverse indices to set.
Returns
ENIGMA_SUCCESS on success, or ENIGMA_FAILURE on failure.