# My Digital Signal Controller Library # The objective of MyDSC library is to implement controllers with help digital signal processors, digital signal controllers or mixed signals processors.

Dependents:   mydsc_sampling_example mydsc_sampling_example mydsc-serial-example mydsc-nonblocking-example

Committer:
ghsalazar
Date:
Sat Mar 28 16:09:15 2020 +0000
Revision:
4:90c3f1288d41
Parent:
2:1f276b0dd807
Add error handling

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ghsalazar 1:2c47778e8a67 1 /** @file: mydsc_kvp.h
ghsalazar 1:2c47778e8a67 2 @author Gastón H. Salazar-Silva <gaston_salazar@yahoo.com>
ghsalazar 2:1f276b0dd807 3
ghsalazar 2:1f276b0dd807 4 @brief A very basic key-value pair system is implemented.
ghsalazar 1:2c47778e8a67 5 **/
ghsalazar 1:2c47778e8a67 6
ghsalazar 4:90c3f1288d41 7 #ifndef MYDSC_KVP_H
ghsalazar 4:90c3f1288d41 8 #define MYDSC_KVP_H
ghsalazar 4:90c3f1288d41 9
ghsalazar 4:90c3f1288d41 10 #include "mydsc_error.h"
ghsalazar 1:2c47778e8a67 11
ghsalazar 1:2c47778e8a67 12 #include <stdint.h>
ghsalazar 1:2c47778e8a67 13
ghsalazar 1:2c47778e8a67 14 #ifdef __cplusplus
ghsalazar 1:2c47778e8a67 15 extern "C" {
ghsalazar 1:2c47778e8a67 16 #endif
ghsalazar 1:2c47778e8a67 17
ghsalazar 2:1f276b0dd807 18 /// The structure sets a linked list up.
ghsalazar 1:2c47778e8a67 19 typedef struct mydsc_kvp_struct {
ghsalazar 1:2c47778e8a67 20 char *key;
ghsalazar 1:2c47778e8a67 21 char* (*get_function)(void);
ghsalazar 1:2c47778e8a67 22 int (*set_function)(char*);
ghsalazar 1:2c47778e8a67 23 struct mydsc_kvp_struct *next_kvp;
ghsalazar 1:2c47778e8a67 24 } mydsc_kvp_t;
ghsalazar 1:2c47778e8a67 25
ghsalazar 2:1f276b0dd807 26 /// Initialize the linked list, then puts a first key ("version")
ghsalazar 2:1f276b0dd807 27 /// @param pkv is a pointer to the linked list.
ghsalazar 1:2c47778e8a67 28 int mydsc_kvp_init(mydsc_kvp_t* pkv);
ghsalazar 2:1f276b0dd807 29
ghsalazar 2:1f276b0dd807 30 /// Returns the value associated with a key.
ghsalazar 2:1f276b0dd807 31 /// @param pkv is a pointer to the linked list.
ghsalazar 2:1f276b0dd807 32 /// @param key is a character string to look-up in the linked list.
ghsalazar 2:1f276b0dd807 33 /// @return The value associated to the key, as a character string.
ghsalazar 1:2c47778e8a67 34 char* mydsc_kvp_get_value(mydsc_kvp_t* pkv, char* key);
ghsalazar 2:1f276b0dd807 35
ghsalazar 2:1f276b0dd807 36 /// Sets or change the value associated with a key.
ghsalazar 2:1f276b0dd807 37 /// @param pkv is a pointer to the linked list.
ghsalazar 2:1f276b0dd807 38 /// @param key is a character string to look-up in the linked list.
ghsalazar 2:1f276b0dd807 39 /// @param value is the new setting, encoded as a character string.
ghsalazar 2:1f276b0dd807 40 /// @return an error encoded as a mydsc_kvp_errno_t.
ghsalazar 1:2c47778e8a67 41 int mydsc_kvp_set_value(mydsc_kvp_t* pkv, char* key, char* value);
ghsalazar 2:1f276b0dd807 42
ghsalazar 2:1f276b0dd807 43 /// Appends a new key-value pair into the linked list.
ghsalazar 2:1f276b0dd807 44 /// @param pkv is a pointer to the linked list.
ghsalazar 2:1f276b0dd807 45 /// @param key is a character string to look-up in the linked list.
ghsalazar 2:1f276b0dd807 46 /// @param get_function is a pointer to a function.
ghsalazar 2:1f276b0dd807 47 /// @param set_function is a pointer to a function.
ghsalazar 2:1f276b0dd807 48 /// @return an error encoded as a mydsc_kvp_errno_t.
ghsalazar 1:2c47778e8a67 49 int mydsc_kvp_append(mydsc_kvp_t* pkv, char* key,
ghsalazar 1:2c47778e8a67 50 char* (*get_function)(void),
ghsalazar 1:2c47778e8a67 51 int (*set_function)(char*));
ghsalazar 1:2c47778e8a67 52
ghsalazar 1:2c47778e8a67 53 #ifdef __cplusplus
ghsalazar 1:2c47778e8a67 54 }
ghsalazar 1:2c47778e8a67 55 #endif
ghsalazar 1:2c47778e8a67 56
ghsalazar 4:90c3f1288d41 57 #endif // MYDSC_KVP_H