fplayer
C99 Falcon Sequence (fseq) file player for Light-O-Rama hardware (like xLights)
Loading...
Searching...
No Matches
crmap.c File Reference

Channel range map implementation. More...

#include "crmap.h"
#include <assert.h>
#include <stdlib.h>
#include <cjson/cJSON.h>
#include "std2/errcode.h"
#include "std2/fc.h"
Include dependency graph for crmap.c:

Data Structures

struct  cr_s
 Channel range node that maps sequence channel indices to unit and circuit numbers. More...
 

Functions

int CR_parseOne (const cJSON *item, struct cr_s *cr)
 Parses a single channel range map object into the given cr struct. The object is expected to have the following structure:
 
static int CR_parse (const char *s, struct cr_s **cr)
 Parses the given channel range map string into a linked list of struct cr_s nodes. The string is expected to be JSON formatted with the following structure:
 
int CMap_read (const char *fp, struct cr_s **cr)
 Reads a channel range map from the given file path. The channel range map is a linked list of channel range nodes that map sequence channel indices to unit and circuit numbers. The caller is responsible for freeing the returned channel range map using CMap_free.
 
void CMap_free (struct cr_s *cr)
 Frees the given channel range map by walking the linked list and freeing each node.
 
int CMap_lookup (const struct cr_s *cr, const uint32_t id, uint8_t *unit, uint16_t *circuit)
 Remaps the given sequence channel index to a unit and circuit number using the channel range mapping. The result is written to the given unit and circuit pointers.
 

Detailed Description

Channel range map implementation.

Function Documentation

◆ CMap_free()

void CMap_free ( struct cr_s * cr)

Frees the given channel range map by walking the linked list and freeing each node.

Parameters
crchannel range map to free
Here is the caller graph for this function:

◆ CMap_lookup()

int CMap_lookup ( const struct cr_s * cr,
uint32_t id,
uint8_t * unit,
uint16_t * circuit )

Remaps the given sequence channel index to a unit and circuit number using the channel range mapping. The result is written to the given unit and circuit pointers.

Parameters
crchannel range map to use for remapping
idsequence channel index to remap
unitpointer to write the unit number to
circuitpointer to write the circuit number to
Returns
non-zero on success, zero on failure
Here is the caller graph for this function:

◆ CMap_read()

int CMap_read ( const char * fp,
struct cr_s ** cr )

Reads a channel range map from the given file path. The channel range map is a linked list of channel range nodes that map sequence channel indices to unit and circuit numbers. The caller is responsible for freeing the returned channel range map using CMap_free.

Parameters
fpfile path to read from
crpointer to write the channel range map to
Returns
0 on success, or a negative error code on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CR_parse()

static int CR_parse ( const char * s,
struct cr_s ** cr )
static

Parses the given channel range map string into a linked list of struct cr_s nodes. The string is expected to be JSON formatted with the following structure:

[
{
"index": { "from": _, "to": _ },
"circuit": { "from": _, "to": _ },
"unit": _
}
]
Parameters
schannel range map string to parse
crpointer to write the channel range map to
Returns
0 on success, or a negative error code on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CR_parseOne()

int CR_parseOne ( const cJSON * item,
struct cr_s * cr )

Parses a single channel range map object into the given cr struct. The object is expected to have the following structure:

{
"index": { "from": _, "to": _ },
"circuit": { "from": _, "to": _ },
"unit": _
}
Parameters
itemcJSON object to parse
crpointer to write the parsed channel range map to
Returns
0 on success, or a negative error code on failure
Here is the caller graph for this function: