libenigma
Enigma machine utility library
Loading...
Searching...
No Matches
score.c File Reference
#include "score.h"
#include "common.h"
#include "io.h"
#include <stdio.h>
#include <stdlib.h>

Functions

int enigma_score_print (const EnigmaScoreList *list)
 Print the scores in an EnigmaScoreList.
 
int enigma_score_list_sort (EnigmaScoreList *list)
 Sort an array of EnigmaScore by score in descending order.
 
Enigmaenigma_score_get_enigma (EnigmaScore *score)
 Get the enigma field in the given EnigmaScore.
 
float enigma_score_get_score (EnigmaScore *score)
 Get the score field in the given EnigmaScore.
 
int enigma_score_get_flags (EnigmaScore *score)
 Get the flags field in the given EnigmaScore.
 
int enigma_score_set_enigma (EnigmaScore *score, Enigma *enigma)
 Set the enigma field in the given EnigmaScore.
 
int enigma_score_set_score (EnigmaScore *score, float value)
 Set the score field in the given EnigmaScore.
 
int enigma_score_set_flags (EnigmaScore *score, int flags)
 Set the flags field in the given EnigmaScore.
 
EnigmaScoreenigma_score_list_get_scores (EnigmaScoreList *list)
 Get the scores array from the given EnigmaScoreList.
 
EnigmaScoreenigma_score_list_get_score (EnigmaScoreList *list, int index)
 Get the score at the given index from the given EnigmaScoreList.
 
int enigma_score_list_get_score_count (EnigmaScoreList *list)
 Get the score count from the given EnigmaScoreList.
 
int enigma_score_list_get_max_scores (EnigmaScoreList *list)
 Get the maximum number of scores from the given EnigmaScoreList.
 
int enigma_score_list_set_score (EnigmaScoreList *list, int index, EnigmaScore *score)
 Set the score at the given index in the given EnigmaScoreList.
 
int enigma_score_list_set_score_count (EnigmaScoreList *list, int count)
 Set the score count in the given EnigmaScoreList.
 
int enigma_score_list_set_max_scores (EnigmaScoreList *list, int max)
 Set the maximum number of scores in the given EnigmaScoreList.
 

Detailed Description

This file contains functions related to plaintext scoring.

Function Documentation

◆ enigma_score_get_enigma()

Enigma * enigma_score_get_enigma ( EnigmaScore score)

Get the enigma field in the given EnigmaScore.

Parameters
scoreThe EnigmaScore instance
Returns
The enigma field, or NULL if score is NULL

◆ enigma_score_get_flags()

int enigma_score_get_flags ( EnigmaScore score)

Get the flags field in the given EnigmaScore.

Parameters
scoreThe EnigmaScore instance
Returns
The flags field, or ENIGMA_FAILURE if score is NULL

◆ enigma_score_get_score()

float enigma_score_get_score ( EnigmaScore score)

Get the score field in the given EnigmaScore.

Parameters
scoreThe EnigmaScore instance
Returns
The score field, or ENIGMA_FAILURE if score is NULL

◆ enigma_score_list_get_max_scores()

int enigma_score_list_get_max_scores ( EnigmaScoreList list)

Get the maximum number of scores from the given EnigmaScoreList.

Parameters
listThe EnigmaScoreList instance
Returns
int The maximum number of scores

◆ enigma_score_list_get_score()

EnigmaScore * enigma_score_list_get_score ( EnigmaScoreList list,
int  index 
)

Get the score at the given index from the given EnigmaScoreList.

Parameters
listThe EnigmaScoreList instance
indexThe index of the score to get
Returns
EnigmaScore* The score at the given index

◆ enigma_score_list_get_score_count()

int enigma_score_list_get_score_count ( EnigmaScoreList list)

Get the score count from the given EnigmaScoreList.

Parameters
listThe EnigmaScoreList instance
Returns
int The score count

◆ enigma_score_list_get_scores()

EnigmaScore * enigma_score_list_get_scores ( EnigmaScoreList list)

Get the scores array from the given EnigmaScoreList.

Parameters
listThe EnigmaScoreList instance
Returns
EnigmaScore* The scores array

◆ enigma_score_list_set_max_scores()

int enigma_score_list_set_max_scores ( EnigmaScoreList list,
int  max 
)

Set the maximum number of scores in the given EnigmaScoreList.

Parameters
listThe EnigmaScoreList instance
maxThe new maximum number of scores
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_score_list_set_score()

int enigma_score_list_set_score ( EnigmaScoreList list,
int  index,
EnigmaScore score 
)

Set the score at the given index in the given EnigmaScoreList.

Parameters
listThe EnigmaScoreList instance
indexThe index of the score to set
scoreThe EnigmaScore instance to set
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_score_list_set_score_count()

int enigma_score_list_set_score_count ( EnigmaScoreList list,
int  count 
)

Set the score count in the given EnigmaScoreList.

Parameters
listThe EnigmaScoreList instance
countThe new score count
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_score_list_sort()

int enigma_score_list_sort ( EnigmaScoreList list)

Sort an array of EnigmaScore by score in descending order.

Parameters
listThe array of EnigmaScore to sort.
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure.

◆ enigma_score_print()

int enigma_score_print ( const EnigmaScoreList list)

Print the scores in an EnigmaScoreList.

Parameters
listPointer to the EnigmaScoreList structure.
Returns
ENIGMA_SUCCESS on success, or ENIGMA_FAILURE on failure.

◆ enigma_score_set_enigma()

int enigma_score_set_enigma ( EnigmaScore score,
Enigma enigma 
)

Set the enigma field in the given EnigmaScore.

Parameters
scoreThe EnigmaScore instance
enigmaThe Enigma instance to set
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_score_set_flags()

int enigma_score_set_flags ( EnigmaScore score,
int  flags 
)

Set the flags field in the given EnigmaScore.

Parameters
scoreThe EnigmaScore instance
flagsThe flags value to set
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure

◆ enigma_score_set_score()

int enigma_score_set_score ( EnigmaScore score,
float  value 
)

Set the score field in the given EnigmaScore.

Parameters
scoreThe EnigmaScore instance
valueThe score value to set
Returns
ENIGMA_SUCCESS on success, ENIGMA_FAILURE on failure