Skip to content
Authors

File prod_pure.c

File List > prod_pure > src > prod_pure.c

Go to the documentation of this file

#include "prod_pure.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <pdgl_defs.h>

/*************************************************************************************************/
/************************** Defines **************************************************************/
/*************************************************************************************************/

/*************************************************************************************************/
/************************** Private Function Declarations ****************************************/
/*************************************************************************************************/

/*************************************************************************************************/
/************************** Local Variables ******************************************************/
/*************************************************************************************************/

/*************************************************************************************************/
/************************** Public Function Definitions ******************************************/
/*************************************************************************************************/

/* Docstring in header */
const char * prod_pure_resolve(const void *config)
{
    const char *retval = NULL;

    if (NULL != config)
    {
        const prod_pure_config_t *typed_cfg = (const prod_pure_config_t *)config;

        if ((0 < typed_cfg->repl_len) && (NULL != typed_cfg->repl_list))
        {
            size_t idx = rand() % typed_cfg->repl_len;

            retval = typed_cfg->repl_list[idx];
        }
    }
    return retval;
}

/* Docstring in header */
const char * prod_pure_terminate(const void *config)
{
    const char *retval = NULL;

    if (NULL != config)
    {
        const prod_pure_config_t *typed_cfg = (const prod_pure_config_t *)config;

        if ((0 < typed_cfg->term_len) && (NULL != typed_cfg->term_list))
        {
            size_t idx = rand() % typed_cfg->term_len;

            retval = typed_cfg->term_list[idx];
        }
    }
    return retval;
}

/*************************************************************************************************/
/************************** Private Function Definitions *****************************************/
/*************************************************************************************************/