Nyx Node
Loading...
Searching...
No Matches
nyx_node.h
1/* NyxNode
2 * Author: Jérôme ODIER <jerome.odier@lpsc.in2p3.fr>
3 * SPDX-License-Identifier: GPL-2.0-only (Mongoose backend) or GPL-3.0+
4 */
5
6/*--------------------------------------------------------------------------------------------------------------------*/
7
8#ifndef NYX_NODE_H
9#define NYX_NODE_H
10
11/*--------------------------------------------------------------------------------------------------------------------*/
12
13#include <stddef.h>
14#include <stdint.h>
15#include <stdbool.h>
16
17/*--------------------------------------------------------------------------------------------------------------------*/
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/*--------------------------------------------------------------------------------------------------------------------*/
24
25#ifndef ARDUINO
26# pragma clang diagnostic push
27# pragma ide diagnostic ignored "OCUnusedMacroInspection"
28# pragma ide diagnostic ignored "UnreachableCallsOfFunction"
29#endif
30
31/*--------------------------------------------------------------------------------------------------------------------*/
32
33double nan(const char *tag);
34
35/*--------------------------------------------------------------------------------------------------------------------*/
36
37#if !defined(__GNUC__) && !defined(__clang__) && !defined(__attribute__)
38# define __attribute__(x)
39#endif
40
41/*--------------------------------------------------------------------------------------------------------------------*/
42
43#define __NYX_NOTNULL__ \
44 /* do nothing */
45
46#define __NYX_NULLABLE__ \
47 /* do nothing */
48
49#define __NYX_ZEROABLE__ \
50 /* do nothing */
51
52#define __NYX_UNUSED__ \
53 __attribute__ ((unused))
54
55#define __NYX_INLINE__ \
56 __attribute__ ((always_inline)) static inline
57
58/*--------------------------------------------------------------------------------------------------------------------*/
59/* MEMORY */
60/*--------------------------------------------------------------------------------------------------------------------*/
65/*--------------------------------------------------------------------------------------------------------------------*/
66
67#define buff_t /*-*/ void *
68#define BUFF_t const void *
69
70#define str_t /*-*/ char *
71#define STR_t const char *
72
73/*--------------------------------------------------------------------------------------------------------------------*/
74
75#define buffof(p) \
76 ((buff_t *) (p))
77
78/*--------------------------------------------------------------------------------------------------------------------*/
79
84void nyx_memory_initialize(void);
85
86/*--------------------------------------------------------------------------------------------------------------------*/
87
92bool nyx_memory_finalize(void);
93
94/*--------------------------------------------------------------------------------------------------------------------*/
95
100__NYX_ZEROABLE__ size_t nyx_memory_free(
101 __NYX_NULLABLE__ buff_t buff
102);
103
104/*--------------------------------------------------------------------------------------------------------------------*/
105
110__NYX_NULLABLE__ buff_t nyx_memory_alloc(
111 __NYX_ZEROABLE__ size_t size
112);
113
114/*--------------------------------------------------------------------------------------------------------------------*/
115
120__NYX_NULLABLE__ buff_t nyx_memory_realloc(
121 __NYX_NULLABLE__ buff_t buff,
122 __NYX_ZEROABLE__ size_t size
123);
124
125/*--------------------------------------------------------------------------------------------------------------------*/
126
131__NYX_NULLABLE__ str_t nyx_string_dup(
132 __NYX_NULLABLE__ STR_t s
133);
134
135/*--------------------------------------------------------------------------------------------------------------------*/
136
141__NYX_NULLABLE__ str_t nyx_string_ndup(
142 __NYX_NULLABLE__ STR_t s,
143 __NYX_ZEROABLE__ size_t n
144);
145
146/*--------------------------------------------------------------------------------------------------------------------*/
147/* LOGGER */
148/*--------------------------------------------------------------------------------------------------------------------*/
154/*--------------------------------------------------------------------------------------------------------------------*/
155
160typedef enum nyx_log_level_e
161{
162 NYX_LOG_LEVEL_NONE = 100,
163 NYX_LOG_LEVEL_FATAL = 101,
164 NYX_LOG_LEVEL_ERROR = 102,
165 NYX_LOG_LEVEL_WARN = 103,
166 NYX_LOG_LEVEL_INFO = 104,
167 NYX_LOG_LEVEL_DEBUG = 105,
168 NYX_LOG_LEVEL_TRACE = 106,
169
171
172/*--------------------------------------------------------------------------------------------------------------------*/
173
180 nyx_log_level_t level
181);
182
183/*--------------------------------------------------------------------------------------------------------------------*/
184
189void __attribute__((format(printf, 5, 6))) nyx_log(
190 nyx_log_level_t level,
191 STR_t file,
192 STR_t func,
193 int line,
194 STR_t fmt,
195 ...
196);
197
198/*--------------------------------------------------------------------------------------------------------------------*/
199
207#define NYX_LOG_FATAL(fmt, ...) \
208 do { nyx_log(NYX_LOG_LEVEL_FATAL, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(1)
209
210/*--------------------------------------------------------------------------------------------------------------------*/
211
218#define NYX_LOG_ERROR(fmt, ...) \
219 do { nyx_log(NYX_LOG_LEVEL_ERROR, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
220
221/*--------------------------------------------------------------------------------------------------------------------*/
222
229#define NYX_LOG_INFO(fmt, ...) \
230 do { nyx_log(NYX_LOG_LEVEL_INFO, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
231
232/*--------------------------------------------------------------------------------------------------------------------*/
233
240#define NYX_LOG_DEBUG(fmt, ...) \
241 do { nyx_log(NYX_LOG_LEVEL_DEBUG, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
242
243/*--------------------------------------------------------------------------------------------------------------------*/
244
251#define NYX_LOG_VERBOSE(fmt, ...) \
252 do { nyx_log(NYX_LOG_LEVEL_VERBOSE, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); } while(0)
253
254/*--------------------------------------------------------------------------------------------------------------------*/
255/* UTILITIES */
256/*--------------------------------------------------------------------------------------------------------------------*/
262/*--------------------------------------------------------------------------------------------------------------------*/
263
272uint32_t nyx_hash(
273 __NYX_ZEROABLE__ size_t size,
274 __NYX_NULLABLE__ BUFF_t buff,
275 uint32_t seed
276);
277
278/*--------------------------------------------------------------------------------------------------------------------*/
279
289 uint8_t result_mac[6],
290 uint8_t mac0,
291 uint8_t mac1,
292 STR_t node_id
293);
294
295/*--------------------------------------------------------------------------------------------------------------------*/
296
305__NYX_NULLABLE__ str_t nyx_base64_encode(
306 __NYX_NULLABLE__ size_t *result_len,
307 __NYX_ZEROABLE__ size_t size,
308 __NYX_NULLABLE__ BUFF_t buff
309);
310
311/*--------------------------------------------------------------------------------------------------------------------*/
312
321__NYX_NULLABLE__ buff_t nyx_base64_decode(
322 __NYX_NULLABLE__ size_t *result_size,
323 __NYX_ZEROABLE__ size_t len,
324 __NYX_NULLABLE__ STR_t str
325);
326
327/*--------------------------------------------------------------------------------------------------------------------*/
328
337__NYX_NULLABLE__ buff_t nyx_zlib_deflate(
338 __NYX_NULLABLE__ size_t *result_size,
339 __NYX_ZEROABLE__ size_t size,
340 __NYX_NULLABLE__ BUFF_t buff
341);
342
343/*--------------------------------------------------------------------------------------------------------------------*/
344
353__NYX_NULLABLE__ buff_t nyx_zlib_inflate(
354 __NYX_NOTNULL__ size_t *result_size,
355 __NYX_ZEROABLE__ size_t size,
356 __NYX_NULLABLE__ BUFF_t buff
357);
358
359/*--------------------------------------------------------------------------------------------------------------------*/
360
370 __NYX_NULLABLE__ size_t *result_len,
371 __NYX_ZEROABLE__ size_t size,
372 __NYX_NULLABLE__ BUFF_t buff
373);
374
375/*--------------------------------------------------------------------------------------------------------------------*/
376
386 __NYX_NOTNULL__ size_t *result_size,
387 __NYX_ZEROABLE__ size_t len,
388 __NYX_NULLABLE__ STR_t str
389);
390
391/*--------------------------------------------------------------------------------------------------------------------*/
392/* OBJECT */
393/*--------------------------------------------------------------------------------------------------------------------*/
399/*--------------------------------------------------------------------------------------------------------------------*/
400
401#define NYX_OBJECT_MAGIC UINT32_C(0x65656565)
402
403/*--------------------------------------------------------------------------------------------------------------------*/
404
405#define NYX_FLAGS_DISABLED UINT64_C(0x0000000000000001) // Flag indicating that the object is disabled.
406 /* 0b0000000000000000000000000000000_0000000000000000000000000000000_01 */
407
408#define NYX_FLAGS_BLOB_MASK UINT64_C(0x00000001FFFFFFFC) // Mask indicating the Nyx blob emission per client.
409 /* 0b0000000000000000000000000000000_1111111111111111111111111111111_00 */
410
411#define NYX_FLAGS_STREAM_MASK UINT64_C(0xFFFFFFFE00000000) // Mask indicating the Nyx stream emission per client.
412 /* 0b1111111111111111111111111111111_0000000000000000000000000000000_00 */
413
414/*--------------------------------------------------------------------------------------------------------------------*/
415
430
431/*--------------------------------------------------------------------------------------------------------------------*/
432
437struct nyx_dict_s;
438
439/*--------------------------------------------------------------------------------------------------------------------*/
440
446typedef struct nyx_object_s
447{
448 /*----------------------------------------------------------------------------------------------------------------*/
449
450 uint32_t magic;
451 uint64_t flags;
452
453 nyx_type_t type;
454
455 /*----------------------------------------------------------------------------------------------------------------*/
456
457 __NYX_NULLABLE__ struct nyx_node_s *node;
458
459 __NYX_NULLABLE__ struct nyx_object_s *parent;
460
461 /*----------------------------------------------------------------------------------------------------------------*/
462
463 union {
464
465 __NYX_NULLABLE__ void *_ptr;
466
467 __NYX_NULLABLE__ bool (* _int)(
468 struct nyx_dict_s *vector,
469 struct nyx_dict_s *prop,
470 int new_value,
471 int old_value
472 );
473
474 __NYX_NULLABLE__ bool (* _uint)(
475 struct nyx_dict_s *vector,
476 struct nyx_dict_s *prop,
477 unsigned int new_value,
478 unsigned int old_value
479 );
480
481 __NYX_NULLABLE__ bool (* _long)(
482 struct nyx_dict_s *vector,
483 struct nyx_dict_s *prop,
484 long new_value,
485 long old_value
486 );
487
488 __NYX_NULLABLE__ bool (* _ulong)(
489 struct nyx_dict_s *vector,
490 struct nyx_dict_s *prop,
491 unsigned long new_value,
492 unsigned long old_value
493 );
494
495 __NYX_NULLABLE__ bool (* _double)(
496 struct nyx_dict_s *vector,
497 struct nyx_dict_s *prop,
498 double new_value,
499 double old_value
500 );
501
502 __NYX_NULLABLE__ bool (* _str)(
503 struct nyx_dict_s *vector,
504 struct nyx_dict_s *prop,
505 STR_t new_value,
506 STR_t old_value
507 );
508
509 __NYX_NULLABLE__ bool (* _buffer)(
510 struct nyx_dict_s *vector,
511 struct nyx_dict_s *prop,
512 size_t size,
513 BUFF_t buff
514 );
515
516 __NYX_NULLABLE__ void (* _vector)(
517 struct nyx_dict_s *vector,
518 bool modified
519 );
520
521 } in_callback;
522
523 /*----------------------------------------------------------------------------------------------------------------*/
524
525 __NYX_NULLABLE__ void *ctx;
526
527 /*----------------------------------------------------------------------------------------------------------------*/
528
530
531/*--------------------------------------------------------------------------------------------------------------------*/
532
542 __NYX_ZEROABLE__ size_t size,
543 __NYX_NULLABLE__ BUFF_t buff
544);
545
546/*--------------------------------------------------------------------------------------------------------------------*/
547
556 __NYX_NULLABLE__ STR_t string
557);
558
559/*--------------------------------------------------------------------------------------------------------------------*/
560
568 __NYX_NULLABLE__ nyx_object_t *object
569);
570
571/*--------------------------------------------------------------------------------------------------------------------*/
572
582 __NYX_NULLABLE__ const nyx_object_t *object1,
583 __NYX_NULLABLE__ const nyx_object_t *object2
584);
585
586/*--------------------------------------------------------------------------------------------------------------------*/
587
597 __NYX_NULLABLE__ const nyx_object_t *object
598);
599
600/*--------------------------------------------------------------------------------------------------------------------*/
601
611 __NYX_NULLABLE__ const nyx_object_t *object
612);
613
614/*--------------------------------------------------------------------------------------------------------------------*/
615/* NULL */
616/*--------------------------------------------------------------------------------------------------------------------*/
623/*--------------------------------------------------------------------------------------------------------------------*/
624
629typedef struct
630{
631 nyx_object_t base;
632
633} nyx_null_t;
634
635/*--------------------------------------------------------------------------------------------------------------------*/
636
644nyx_null_t *nyx_null_new(void);
645
646/*--------------------------------------------------------------------------------------------------------------------*/
647
654void nyx_null_free(
655 /*-*/ nyx_null_t *object
656);
657
658/*--------------------------------------------------------------------------------------------------------------------*/
659
669 const nyx_null_t *object
670);
671
672/*--------------------------------------------------------------------------------------------------------------------*/
673/* NUMBER */
674/*--------------------------------------------------------------------------------------------------------------------*/
681/*--------------------------------------------------------------------------------------------------------------------*/
682
687typedef struct
688{
689 nyx_object_t base;
690
691 double value;
692
694
695/*--------------------------------------------------------------------------------------------------------------------*/
696
704nyx_number_t *nyx_number_new(void);
705
706/*--------------------------------------------------------------------------------------------------------------------*/
707
714void nyx_number_free(
715 /*-*/ nyx_number_t *object
716);
717
718/*--------------------------------------------------------------------------------------------------------------------*/
719
727double nyx_number_get(
728 const nyx_number_t *object
729);
730
731/*--------------------------------------------------------------------------------------------------------------------*/
732
741bool nyx_number_set(
742 /*-*/ nyx_number_t *object,
743 double value
744);
745
746
747/*--------------------------------------------------------------------------------------------------------------------*/
748
757str_t nyx_number_to_string(
758 const nyx_number_t *object
759);
760
761/*--------------------------------------------------------------------------------------------------------------------*/
762
770__NYX_INLINE__ nyx_number_t *nyx_number_from(double value)
771{
772 nyx_number_t *result = nyx_number_new();
773
774 nyx_number_set(result, value);
775
776 return result;
777}
778
779/*--------------------------------------------------------------------------------------------------------------------*/
780/* BOOLEAN */
781/*--------------------------------------------------------------------------------------------------------------------*/
788/*--------------------------------------------------------------------------------------------------------------------*/
789
794typedef struct
795{
796 nyx_object_t base;
797
798 bool value;
799
801
802/*--------------------------------------------------------------------------------------------------------------------*/
803
810nyx_boolean_t *nyx_boolean_new(void);
811
812/*--------------------------------------------------------------------------------------------------------------------*/
813
820void nyx_boolean_free(
821 /*-*/ nyx_boolean_t *object
822);
823
824/*--------------------------------------------------------------------------------------------------------------------*/
825
833bool nyx_boolean_get(
834 const nyx_boolean_t *object
835);
836
837/*--------------------------------------------------------------------------------------------------------------------*/
838
847bool nyx_boolean_set(
848 /*-*/ nyx_boolean_t *object,
849 bool value
850);
851
852/*--------------------------------------------------------------------------------------------------------------------*/
853
862str_t nyx_boolean_to_string(
863 const nyx_boolean_t *object
864);
865
866/*--------------------------------------------------------------------------------------------------------------------*/
867
875__NYX_INLINE__ nyx_boolean_t *nyx_boolean_from(bool value)
876{
877 nyx_boolean_t *result = nyx_boolean_new();
878
879 nyx_boolean_set(result, value);
880
881 return result;
882}
883
884/*--------------------------------------------------------------------------------------------------------------------*/
885/* STRING */
886/*--------------------------------------------------------------------------------------------------------------------*/
893/*--------------------------------------------------------------------------------------------------------------------*/
894
899typedef struct
900{
901 nyx_object_t base;
902
903 bool managed;
904 size_t length;
906
908
909/*--------------------------------------------------------------------------------------------------------------------*/
910
917nyx_string_t *nyx_string_new(void);
918
919/*--------------------------------------------------------------------------------------------------------------------*/
920
927void nyx_string_free(
928 /*-*/ nyx_string_t *object
929);
930
931/*--------------------------------------------------------------------------------------------------------------------*/
932
940STR_t nyx_string_get(
941 const nyx_string_t *object
942);
943
944/*--------------------------------------------------------------------------------------------------------------------*/
945
950void nyx_string_get_buff(
951 const nyx_string_t *object,
952 __NYX_NULLABLE__ size_t *result_size,
953 __NYX_NULLABLE__ buff_t *result_buff
954);
955
956/*--------------------------------------------------------------------------------------------------------------------*/
957
967bool nyx_string_set(
968 /*-*/ nyx_string_t *object,
969 STR_t value,
970 bool managed
971);
972
973/*--------------------------------------------------------------------------------------------------------------------*/
974
985bool nyx_string_set_buff(
986 /*-*/ nyx_string_t *object,
987 size_t size,
988 BUFF_t buff,
989 bool managed
990);
991
992/*--------------------------------------------------------------------------------------------------------------------*/
993
1001size_t nyx_string_length(
1002 const nyx_string_t *object
1003);
1004
1005/*--------------------------------------------------------------------------------------------------------------------*/
1006
1015str_t nyx_string_to_string(
1016 const nyx_string_t *object
1017);
1018
1019/*--------------------------------------------------------------------------------------------------------------------*/
1020
1030 const nyx_string_t *object
1031);
1032
1033/*--------------------------------------------------------------------------------------------------------------------*/
1034
1044{
1045 nyx_string_t *result = nyx_string_new();
1046
1047 nyx_string_set(result, nyx_string_dup(value), true);
1048
1049 return result;
1050}
1051
1052/*--------------------------------------------------------------------------------------------------------------------*/
1053
1063{
1064 nyx_string_t *result = nyx_string_new();
1065
1066 nyx_string_set(result, value, true);
1067
1068 return result;
1069}
1070
1071/*--------------------------------------------------------------------------------------------------------------------*/
1072
1082{
1083 nyx_string_t *result = nyx_string_new();
1084
1085 nyx_string_set(result, value, false);
1086
1087 return result;
1088}
1089
1090/*--------------------------------------------------------------------------------------------------------------------*/
1091
1101__NYX_INLINE__ nyx_string_t *nyx_string_from_buff_managed(size_t size, BUFF_t buff)
1102{
1103 nyx_string_t *result = nyx_string_new();
1104
1105 nyx_string_set_buff(result, size, buff, true);
1106
1107 return result;
1108}
1109
1110/*--------------------------------------------------------------------------------------------------------------------*/
1111
1121__NYX_INLINE__ nyx_string_t *nyx_string_from_buff_unmanaged(size_t size, BUFF_t buff)
1122{
1123 nyx_string_t *result = nyx_string_new();
1124
1125 nyx_string_set_buff(result, size, buff, false);
1126
1127 return result;
1128}
1129
1130/*--------------------------------------------------------------------------------------------------------------------*/
1131/* DICT */
1132/*--------------------------------------------------------------------------------------------------------------------*/
1139/*--------------------------------------------------------------------------------------------------------------------*/
1140
1146typedef struct nyx_dict_s
1147{
1148 nyx_object_t base;
1149
1150 struct nyx_dict_node_s *head;
1151 struct nyx_dict_node_s *tail;
1152
1153} nyx_dict_t;
1154
1155/*--------------------------------------------------------------------------------------------------------------------*/
1156
1161typedef struct
1162{
1163 size_t idx;
1164
1165 struct nyx_dict_node_s *head;
1166
1168
1169/*--------------------------------------------------------------------------------------------------------------------*/
1170
1176#define NYX_DICT_ITER(dict) \
1177 ((nyx_dict_iter_t) {.idx = 0, .head = ((nyx_dict_t *) (dict))->head})
1178
1179/*--------------------------------------------------------------------------------------------------------------------*/
1180
1187nyx_dict_t *nyx_dict_new(void);
1188
1189/*--------------------------------------------------------------------------------------------------------------------*/
1190
1197void nyx_dict_free(
1198 /*-*/ nyx_dict_t *object
1199);
1200
1201/*--------------------------------------------------------------------------------------------------------------------*/
1202
1209void nyx_dict_clear(
1210 /*-*/ nyx_dict_t *object
1211);
1212
1213/*--------------------------------------------------------------------------------------------------------------------*/
1214
1222void nyx_dict_del(
1223 /*-*/ nyx_dict_t *object,
1224 STR_t key
1225);
1226
1227/*--------------------------------------------------------------------------------------------------------------------*/
1228
1248bool nyx_dict_iterate(
1249 nyx_dict_iter_t *iter,
1250 STR_t *key,
1251 nyx_object_t **object
1252);
1253
1254/*--------------------------------------------------------------------------------------------------------------------*/
1255
1264nyx_object_t *nyx_dict_get(
1265 const nyx_dict_t *object,
1266 STR_t key
1267);
1268
1269/*--------------------------------------------------------------------------------------------------------------------*/
1270
1280bool nyx_dict_set(
1281 /*-*/ nyx_dict_t *object,
1282 STR_t key,
1283 void *value
1284);
1285
1286/*--------------------------------------------------------------------------------------------------------------------*/
1287
1295size_t nyx_dict_size(
1296 const nyx_dict_t *object
1297);
1298
1299/*--------------------------------------------------------------------------------------------------------------------*/
1300
1309str_t nyx_dict_to_string(
1310 const nyx_dict_t *object
1311);
1312
1313/*--------------------------------------------------------------------------------------------------------------------*/
1314
1323__NYX_INLINE__ bool nyx_dict_get_boolean(const nyx_dict_t *object, STR_t key)
1324{
1325 nyx_object_t *value = nyx_dict_get(object, key);
1326
1327 return value != NULL && value->type == NYX_TYPE_BOOLEAN ? nyx_boolean_get((nyx_boolean_t *) value)
1328 : false
1329 ;
1330}
1331
1332/*--------------------------------------------------------------------------------------------------------------------*/
1333
1342__NYX_INLINE__ double nyx_dict_get_number(const nyx_dict_t *object, STR_t key)
1343{
1344 nyx_object_t *value = nyx_dict_get(object, key);
1345
1346 return value != NULL && value->type == NYX_TYPE_NUMBER ? nyx_number_get((nyx_number_t *) value)
1347 : nan("1")
1348 ;
1349}
1350
1351/*--------------------------------------------------------------------------------------------------------------------*/
1352
1361__NYX_INLINE__ STR_t nyx_dict_get_string(const nyx_dict_t *object, STR_t key)
1362{
1363 nyx_object_t *value = nyx_dict_get(object, key);
1364
1365 return value != NULL && value->type == NYX_TYPE_STRING ? nyx_string_get((nyx_string_t *) value)
1366 : NULL
1367 ;
1368}
1369
1370/*--------------------------------------------------------------------------------------------------------------------*/
1371/* LIST */
1372/*--------------------------------------------------------------------------------------------------------------------*/
1379/*--------------------------------------------------------------------------------------------------------------------*/
1380
1386typedef struct nyx_list_s
1387{
1388 nyx_object_t base;
1389
1390 struct nyx_list_node_s *head;
1391 struct nyx_list_node_s *tail;
1392
1393} nyx_list_t;
1394
1395/*--------------------------------------------------------------------------------------------------------------------*/
1396
1401typedef struct
1402{
1403 size_t idx;
1404
1405 struct nyx_list_node_s *head;
1406
1408
1409/*--------------------------------------------------------------------------------------------------------------------*/
1410
1416#define NYX_LIST_ITER(list) \
1417 ((nyx_list_iter_t) {.idx = 0, .head = ((nyx_list_t *) (list))->head})
1418
1419/*--------------------------------------------------------------------------------------------------------------------*/
1420
1427nyx_list_t *nyx_list_new(void);
1428
1429/*--------------------------------------------------------------------------------------------------------------------*/
1430
1437void nyx_list_free(
1438 /*-*/ nyx_list_t *object
1439);
1440
1441/*--------------------------------------------------------------------------------------------------------------------*/
1442
1449void nyx_list_clear(
1450 /*-*/ nyx_list_t *object
1451);
1452
1453/*--------------------------------------------------------------------------------------------------------------------*/
1454
1462void nyx_list_del(
1463 /*-*/ nyx_list_t *object,
1464 size_t idx
1465);
1466
1467/*--------------------------------------------------------------------------------------------------------------------*/
1468
1488bool nyx_list_iterate(
1489 nyx_list_iter_t *iter,
1490 size_t *idx,
1491 nyx_object_t **object
1492);
1493
1494/*--------------------------------------------------------------------------------------------------------------------*/
1495
1504nyx_object_t *nyx_list_get(
1505 const nyx_list_t *object,
1506 size_t idx
1507);
1508
1509/*--------------------------------------------------------------------------------------------------------------------*/
1510
1515bool nyx_list_set(
1516 /*-*/ nyx_list_t *object,
1517 size_t idx,
1518 void *value
1519);
1520
1521/*--------------------------------------------------------------------------------------------------------------------*/
1522
1531__NYX_INLINE__ bool nyx_list_push(nyx_list_t *object, void *value)
1532{
1533 return nyx_list_set(object, (size_t) -1, value);
1534}
1535
1536/*--------------------------------------------------------------------------------------------------------------------*/
1537
1545size_t nyx_list_size(
1546 const nyx_list_t *object
1547);
1548
1549/*--------------------------------------------------------------------------------------------------------------------*/
1550
1559str_t nyx_list_to_string(
1560 const nyx_list_t *object
1561);
1562
1563/*--------------------------------------------------------------------------------------------------------------------*/
1564
1573__NYX_INLINE__ bool nyx_list_get_boolean(const nyx_list_t *object, size_t idx)
1574{
1575 nyx_object_t *boolean = nyx_list_get(object, idx);
1576
1577 return boolean != NULL && boolean->type == NYX_TYPE_BOOLEAN ? nyx_boolean_get((nyx_boolean_t *) boolean)
1578 : false
1579 ;
1580}
1581
1582/*--------------------------------------------------------------------------------------------------------------------*/
1583
1592__NYX_INLINE__ double nyx_list_get_number(const nyx_list_t *object, size_t idx)
1593{
1594 nyx_object_t *number = nyx_list_get(object, idx);
1595
1596 return number != NULL && number->type == NYX_TYPE_NUMBER ? nyx_number_get((nyx_number_t *) number)
1597 : nan("1")
1598 ;
1599}
1600
1601/*--------------------------------------------------------------------------------------------------------------------*/
1602
1611__NYX_INLINE__ STR_t nyx_list_get_string(const nyx_list_t *object, size_t idx)
1612{
1613 nyx_object_t *string = nyx_list_get(object, idx);
1614
1615 return string != NULL && string->type == NYX_TYPE_STRING ? nyx_string_get((nyx_string_t *) string)
1616 : NULL
1617 ;
1618}
1619
1620/*--------------------------------------------------------------------------------------------------------------------*/
1621/* XMLDOC */
1622/*--------------------------------------------------------------------------------------------------------------------*/
1623#if !defined(ARDUINO)
1624/*--------------------------------------------------------------------------------------------------------------------*/
1630/*--------------------------------------------------------------------------------------------------------------------*/
1631
1637typedef enum
1638{
1639 NYX_XML_ELEM = 300,
1640 NYX_XML_ATTR = 301,
1641 NYX_XML_COMMENT = 302,
1642 NYX_XML_CDATA = 303,
1643 NYX_XML_TEXT = 304,
1644
1645} nyx_xml_type_t;
1646
1647/*--------------------------------------------------------------------------------------------------------------------*/
1648
1654typedef struct nyx_xmldoc_s
1655{
1656 str_t name;
1657 nyx_xml_type_t type;
1658 str_t data;
1659
1660 struct nyx_xmldoc_s *next;
1661 struct nyx_xmldoc_s *parent;
1662
1663 struct nyx_xmldoc_s *children;
1664 struct nyx_xmldoc_s *attributes;
1665
1666 bool self_closing;
1667
1668} nyx_xmldoc_t;
1669
1670/*--------------------------------------------------------------------------------------------------------------------*/
1671
1681 __NYX_ZEROABLE__ size_t size,
1682 __NYX_NULLABLE__ BUFF_t buff
1683);
1684
1685/*--------------------------------------------------------------------------------------------------------------------*/
1686
1695 __NYX_NULLABLE__ STR_t string
1696);
1697
1698/*--------------------------------------------------------------------------------------------------------------------*/
1699
1707 __NYX_NULLABLE__ nyx_xmldoc_t *xmldoc
1708);
1709
1710/*--------------------------------------------------------------------------------------------------------------------*/
1711
1720str_t nyx_xmldoc_to_string(
1721 const nyx_xmldoc_t *xmldoc
1722);
1723
1724/*--------------------------------------------------------------------------------------------------------------------*/
1725#endif
1726/*--------------------------------------------------------------------------------------------------------------------*/
1727/* TRANSFORM */
1728/*--------------------------------------------------------------------------------------------------------------------*/
1729#if !defined(ARDUINO)
1730/*--------------------------------------------------------------------------------------------------------------------*/
1736/*--------------------------------------------------------------------------------------------------------------------*/
1737
1745 __NYX_NULLABLE__ const nyx_xmldoc_t *xmldoc
1746);
1747
1748/*--------------------------------------------------------------------------------------------------------------------*/
1749
1757 __NYX_NULLABLE__ const nyx_object_t *object
1758);
1759
1760/*--------------------------------------------------------------------------------------------------------------------*/
1761#endif
1762/*--------------------------------------------------------------------------------------------------------------------*/
1763/* NYX */
1764/*--------------------------------------------------------------------------------------------------------------------*/
1770/*--------------------------------------------------------------------------------------------------------------------*/
1771
1772#define NYX_INDI_VERSION "1.7"
1773
1774/*--------------------------------------------------------------------------------------------------------------------*/
1775
1780typedef enum
1781{
1786
1787} nyx_state_t;
1788
1789/*--------------------------------------------------------------------------------------------------------------------*/
1790
1795STR_t nyx_state_to_str(
1796 nyx_state_t state
1797);
1798
1799/*--------------------------------------------------------------------------------------------------------------------*/
1800
1805nyx_state_t nyx_str_to_state(
1806 STR_t state
1807);
1808
1809/*--------------------------------------------------------------------------------------------------------------------*/
1810
1815typedef enum
1816{
1820
1821} nyx_perm_t;
1822
1823/*--------------------------------------------------------------------------------------------------------------------*/
1824
1829STR_t nyx_perm_to_str(
1830 nyx_perm_t perm
1831);
1832
1833/*--------------------------------------------------------------------------------------------------------------------*/
1834
1839nyx_perm_t nyx_str_to_perm(
1840 STR_t perm
1841);
1842
1843/*--------------------------------------------------------------------------------------------------------------------*/
1844
1856
1857/*--------------------------------------------------------------------------------------------------------------------*/
1858
1863STR_t nyx_rule_to_str(
1864 nyx_rule_t rule
1865);
1866
1867/*--------------------------------------------------------------------------------------------------------------------*/
1868
1873nyx_rule_t nyx_str_to_rule(
1874 STR_t rule
1875);
1876
1877/*--------------------------------------------------------------------------------------------------------------------*/
1878
1883typedef enum
1884{
1887
1888} nyx_onoff_t;
1889
1890/*--------------------------------------------------------------------------------------------------------------------*/
1891
1896STR_t nyx_onoff_to_str(
1897 nyx_onoff_t onoff
1898);
1899
1900/*--------------------------------------------------------------------------------------------------------------------*/
1901
1906nyx_onoff_t nyx_str_to_onoff(
1907 STR_t onoff
1908);
1909
1910/*--------------------------------------------------------------------------------------------------------------------*/
1911
1916typedef struct
1917{
1918 __NYX_NULLABLE__ STR_t group;
1919 __NYX_NULLABLE__ STR_t label;
1920 __NYX_NULLABLE__ STR_t hints;
1921 __NYX_NULLABLE__ STR_t message;
1922 __NYX_ZEROABLE__ double timeout;
1923
1924} nyx_opts_t;
1925
1926/*--------------------------------------------------------------------------------------------------------------------*/
1927
1932typedef struct
1933{
1934 /*----------------------------------------------------------------------------------------------------------------*/
1935
1936 enum
1937 {
1938 NYX_VARIANT_TYPE_INT = 1000,
1939 NYX_VARIANT_TYPE_UINT = 1001,
1940 NYX_VARIANT_TYPE_LONG = 1002,
1941 NYX_VARIANT_TYPE_ULONG = 1003,
1942 NYX_VARIANT_TYPE_DOUBLE = 1004,
1943
1944 } type;
1945
1946 /*----------------------------------------------------------------------------------------------------------------*/
1947
1948 union
1949 {
1950 int32_t _int;
1951 uint32_t _uint;
1952 int64_t _long;
1953 uint64_t _ulong;
1954 double _double;
1955
1956 } value;
1957
1958 /*----------------------------------------------------------------------------------------------------------------*/
1959
1960} nyx_variant_t;
1961
1962/*--------------------------------------------------------------------------------------------------------------------*/
1963
1968__NYX_INLINE__ nyx_variant_t NYX_VARIANT_FROM_INT(int32_t value)
1969{
1970 #ifndef __cplusplus
1971 return (nyx_variant_t) {NYX_VARIANT_TYPE_INT, {._int = value}};
1972 #else
1973 return (nyx_variant_t) {nyx_variant_t::NYX_VARIANT_TYPE_INT, {._int = value}};
1974 #endif
1975}
1976
1977/*--------------------------------------------------------------------------------------------------------------------*/
1978
1983__NYX_INLINE__ nyx_variant_t NYX_VARIANT_FROM_UINT(uint32_t value)
1984{
1985 #ifndef __cplusplus
1986 return (nyx_variant_t) {NYX_VARIANT_TYPE_UINT, {._uint = value}};
1987 #else
1988 return (nyx_variant_t) {nyx_variant_t::NYX_VARIANT_TYPE_UINT, {._uint = value}};
1989 #endif
1990}
1991
1992/*--------------------------------------------------------------------------------------------------------------------*/
1993
1998__NYX_INLINE__ nyx_variant_t NYX_VARIANT_FROM_LONG(int64_t value)
1999{
2000 #ifndef __cplusplus
2001 return (nyx_variant_t) {NYX_VARIANT_TYPE_LONG, {._long = value}};
2002 #else
2003 return (nyx_variant_t) {nyx_variant_t::NYX_VARIANT_TYPE_LONG, {._long = value}};
2004 #endif
2005}
2006
2007/*--------------------------------------------------------------------------------------------------------------------*/
2008
2013__NYX_INLINE__ nyx_variant_t NYX_VARIANT_FROM_ULONG(uint64_t value)
2014{
2015 #ifndef __cplusplus
2016 return (nyx_variant_t) {NYX_VARIANT_TYPE_ULONG, {._ulong = value}};
2017 #else
2018 return (nyx_variant_t) {nyx_variant_t::NYX_VARIANT_TYPE_ULONG, {._ulong = value}};
2019 #endif
2020}
2021
2022/*--------------------------------------------------------------------------------------------------------------------*/
2023
2028__NYX_INLINE__ nyx_variant_t NYX_VARIANT_FROM_DOUBLE(double value)
2029{
2030 #ifndef __cplusplus
2031 return (nyx_variant_t) {NYX_VARIANT_TYPE_DOUBLE, {._double = value}};
2032 #else
2033 return (nyx_variant_t) {nyx_variant_t::NYX_VARIANT_TYPE_DOUBLE, {._double = value}};
2034 #endif
2035}
2036
2037/*--------------------------------------------------------------------------------------------------------------------*/
2044/*--------------------------------------------------------------------------------------------------------------------*/
2045
2050nyx_dict_t *nyx_number_prop_new(
2051 STR_t name,
2052 __NYX_NULLABLE__ STR_t label,
2053 STR_t format,
2054 nyx_variant_t min,
2055 nyx_variant_t max,
2056 nyx_variant_t step,
2057 nyx_variant_t value
2058);
2059
2060/*--------------------------------------------------------------------------------------------------------------------*/
2061
2074__NYX_INLINE__ nyx_dict_t *nyx_number_prop_new_int(STR_t name,__NYX_NULLABLE__ STR_t label, STR_t format, int32_t min, int32_t max, int32_t step, int32_t value)
2075{
2076 return nyx_number_prop_new(name, label, format, NYX_VARIANT_FROM_INT(min), NYX_VARIANT_FROM_INT(max), NYX_VARIANT_FROM_INT(step), NYX_VARIANT_FROM_INT(value));
2077}
2078
2079/*--------------------------------------------------------------------------------------------------------------------*/
2080
2093__NYX_INLINE__ nyx_dict_t *nyx_number_prop_new_uint(STR_t name,__NYX_NULLABLE__ STR_t label, STR_t format, uint32_t min, uint32_t max, uint32_t step, uint32_t value)
2094{
2095 return nyx_number_prop_new(name, label, format, NYX_VARIANT_FROM_UINT(min), NYX_VARIANT_FROM_UINT(max), NYX_VARIANT_FROM_UINT(step), NYX_VARIANT_FROM_UINT(value));
2096}
2097
2098/*--------------------------------------------------------------------------------------------------------------------*/
2099
2112__NYX_INLINE__ nyx_dict_t *nyx_number_prop_new_long(STR_t name,__NYX_NULLABLE__ STR_t label, STR_t format, int64_t min, int64_t max, int64_t step, int64_t value)
2113{
2114 return nyx_number_prop_new(name, label, format, NYX_VARIANT_FROM_LONG(min), NYX_VARIANT_FROM_LONG(max), NYX_VARIANT_FROM_LONG(step), NYX_VARIANT_FROM_LONG(value));
2115}
2116
2117/*--------------------------------------------------------------------------------------------------------------------*/
2118
2131__NYX_INLINE__ nyx_dict_t *nyx_number_prop_new_ulong(STR_t name,__NYX_NULLABLE__ STR_t label, STR_t format, uint64_t min, uint64_t max, uint64_t step, uint64_t value)
2132{
2133 return nyx_number_prop_new(name, label, format, NYX_VARIANT_FROM_ULONG(min), NYX_VARIANT_FROM_ULONG(max), NYX_VARIANT_FROM_ULONG(step), NYX_VARIANT_FROM_ULONG(value));
2134}
2135
2136/*--------------------------------------------------------------------------------------------------------------------*/
2137
2150__NYX_INLINE__ nyx_dict_t *nyx_number_prop_new_double(STR_t name,__NYX_NULLABLE__ STR_t label, STR_t format, double min, double max, double step, double value)
2151{
2152 return nyx_number_prop_new(name, label, format, NYX_VARIANT_FROM_DOUBLE(min), NYX_VARIANT_FROM_DOUBLE(max), NYX_VARIANT_FROM_DOUBLE(step), NYX_VARIANT_FROM_DOUBLE(value));
2153}
2154
2155/*--------------------------------------------------------------------------------------------------------------------*/
2156
2160bool nyx_number_prop_set(
2161 nyx_dict_t *prop,
2162 nyx_variant_t value
2163);
2164
2165/*--------------------------------------------------------------------------------------------------------------------*/
2166
2170nyx_variant_t nyx_number_prop_get(
2171 const nyx_dict_t *prop
2172);
2173
2174/*--------------------------------------------------------------------------------------------------------------------*/
2175
2183__NYX_INLINE__ bool nyx_number_prop_set_int(nyx_dict_t *prop, int32_t value)
2184{
2185 return nyx_number_prop_set(prop, NYX_VARIANT_FROM_INT(value));
2186}
2187
2188/*--------------------------------------------------------------------------------------------------------------------*/
2189
2196__NYX_INLINE__ int32_t nyx_number_prop_get_int(const nyx_dict_t *prop)
2197{
2198 return nyx_number_prop_get(prop).value._int;
2199}
2200
2201/*--------------------------------------------------------------------------------------------------------------------*/
2202
2210__NYX_INLINE__ bool nyx_number_prop_set_uint(nyx_dict_t *prop, uint32_t value)
2211{
2212 return nyx_number_prop_set(prop, NYX_VARIANT_FROM_UINT(value));
2213}
2214
2215/*--------------------------------------------------------------------------------------------------------------------*/
2216
2223__NYX_INLINE__ uint32_t nyx_number_prop_get_uint(const nyx_dict_t *prop)
2224{
2225 return nyx_number_prop_get(prop).value._uint;
2226}
2227
2228/*--------------------------------------------------------------------------------------------------------------------*/
2229
2237__NYX_INLINE__ bool nyx_number_prop_set_long(nyx_dict_t *prop, int64_t value)
2238{
2239 return nyx_number_prop_set(prop, NYX_VARIANT_FROM_LONG(value));
2240}
2241
2242/*--------------------------------------------------------------------------------------------------------------------*/
2243
2250__NYX_INLINE__ int64_t nyx_number_prop_get_long(const nyx_dict_t *prop)
2251{
2252 return nyx_number_prop_get(prop).value._long;
2253}
2254
2255/*--------------------------------------------------------------------------------------------------------------------*/
2256
2264__NYX_INLINE__ bool nyx_number_prop_set_ulong(nyx_dict_t *prop, uint64_t value)
2265{
2266 return nyx_number_prop_set(prop, NYX_VARIANT_FROM_ULONG(value));
2267}
2268
2269/*--------------------------------------------------------------------------------------------------------------------*/
2270
2277__NYX_INLINE__ uint64_t nyx_number_prop_get_ulong(const nyx_dict_t *prop)
2278{
2279 return nyx_number_prop_get(prop).value._ulong;
2280}
2281
2282/*--------------------------------------------------------------------------------------------------------------------*/
2283
2291__NYX_INLINE__ bool nyx_number_prop_set_double(nyx_dict_t *prop, double value)
2292{
2293 return nyx_number_prop_set(prop, NYX_VARIANT_FROM_DOUBLE(value));
2294}
2295
2296/*--------------------------------------------------------------------------------------------------------------------*/
2297
2304__NYX_INLINE__ double nyx_number_prop_get_double(const nyx_dict_t *prop)
2305{
2306 return nyx_number_prop_get(prop).value._double;
2307}
2308
2309/*--------------------------------------------------------------------------------------------------------------------*/
2310
2323 STR_t device,
2324 STR_t name,
2325 nyx_state_t state,
2326 nyx_perm_t perm,
2327 nyx_dict_t *props[],
2328 __NYX_NULLABLE__ const nyx_opts_t *opts
2329);
2330
2331/*--------------------------------------------------------------------------------------------------------------------*/
2332
2337nyx_dict_t *nyx_number_set_vector_new(
2338 const nyx_dict_t *vector
2339);
2340
2341/*--------------------------------------------------------------------------------------------------------------------*/
2348/*--------------------------------------------------------------------------------------------------------------------*/
2349
2360 STR_t name,
2361 __NYX_NULLABLE__ STR_t label,
2362 __NYX_NULLABLE__ STR_t value
2363);
2364
2365/*--------------------------------------------------------------------------------------------------------------------*/
2366
2376 nyx_dict_t *prop,
2377 __NYX_NULLABLE__ STR_t value
2378);
2379
2380/*--------------------------------------------------------------------------------------------------------------------*/
2381
2389 const nyx_dict_t *prop
2390);
2391
2392/*--------------------------------------------------------------------------------------------------------------------*/
2393
2406 STR_t device,
2407 STR_t name,
2408 nyx_state_t state,
2409 nyx_perm_t perm,
2410 nyx_dict_t *props[],
2411 __NYX_NULLABLE__ const nyx_opts_t *opts
2412);
2413
2414/*--------------------------------------------------------------------------------------------------------------------*/
2415
2420nyx_dict_t *nyx_text_set_vector_new(
2421 const nyx_dict_t *vector
2422);
2423
2424/*--------------------------------------------------------------------------------------------------------------------*/
2431/*--------------------------------------------------------------------------------------------------------------------*/
2432
2442 STR_t name,
2443 __NYX_NULLABLE__ STR_t label,
2444 nyx_state_t value
2445);
2446
2447/*--------------------------------------------------------------------------------------------------------------------*/
2448
2457 nyx_dict_t *prop,
2458 nyx_state_t value
2459);
2460
2461/*--------------------------------------------------------------------------------------------------------------------*/
2462
2470 const nyx_dict_t *prop
2471);
2472
2473/*--------------------------------------------------------------------------------------------------------------------*/
2474
2486 STR_t device,
2487 STR_t name,
2488 nyx_state_t state,
2489 nyx_dict_t *props[],
2490 __NYX_NULLABLE__ const nyx_opts_t *opts
2491);
2492
2493/*--------------------------------------------------------------------------------------------------------------------*/
2494
2499nyx_dict_t *nyx_light_set_vector_new(
2500 const nyx_dict_t *vector
2501);
2502
2503/*--------------------------------------------------------------------------------------------------------------------*/
2510/*--------------------------------------------------------------------------------------------------------------------*/
2511
2521 STR_t name,
2522 __NYX_NULLABLE__ STR_t label,
2523 nyx_onoff_t value
2524);
2525
2526/*--------------------------------------------------------------------------------------------------------------------*/
2527
2536 nyx_dict_t *prop,
2537 nyx_onoff_t value
2538);
2539
2540/*--------------------------------------------------------------------------------------------------------------------*/
2541
2549 const nyx_dict_t *prop
2550);
2551
2552/*--------------------------------------------------------------------------------------------------------------------*/
2553
2567 STR_t device,
2568 STR_t name,
2569 nyx_state_t state,
2570 nyx_perm_t perm,
2571 nyx_rule_t rule,
2572 nyx_dict_t *props[],
2573 __NYX_NULLABLE__ const nyx_opts_t *opts
2574);
2575
2576/*--------------------------------------------------------------------------------------------------------------------*/
2577
2582nyx_dict_t *nyx_switch_set_vector_new(
2583 const nyx_dict_t *vector
2584);
2585
2586/*--------------------------------------------------------------------------------------------------------------------*/
2593/*--------------------------------------------------------------------------------------------------------------------*/
2594
2608 STR_t name,
2609 __NYX_NULLABLE__ STR_t label,
2610 __NYX_NULLABLE__ STR_t format,
2611 __NYX_ZEROABLE__ size_t size,
2612 __NYX_NULLABLE__ BUFF_t buff,
2613 bool managed
2614);
2615
2616/*--------------------------------------------------------------------------------------------------------------------*/
2617
2628 nyx_dict_t *prop,
2629 __NYX_ZEROABLE__ size_t size,
2630 __NYX_NULLABLE__ BUFF_t buff
2631);
2632
2633/*--------------------------------------------------------------------------------------------------------------------*/
2634
2645 nyx_dict_t *prop,
2646 __NYX_ZEROABLE__ size_t size,
2647 __NYX_NULLABLE__ BUFF_t buff
2648);
2649
2650/*--------------------------------------------------------------------------------------------------------------------*/
2651
2660 const nyx_dict_t *prop,
2661 __NYX_NULLABLE__ size_t *size,
2662 __NYX_NULLABLE__ buff_t *buff
2663);
2664
2665/*--------------------------------------------------------------------------------------------------------------------*/
2666
2679 STR_t device,
2680 STR_t name,
2681 nyx_state_t state,
2682 nyx_perm_t perm,
2683 nyx_dict_t *props[],
2684 __NYX_NULLABLE__ const nyx_opts_t *opts
2685);
2686
2687/*--------------------------------------------------------------------------------------------------------------------*/
2688
2693nyx_dict_t *nyx_blob_set_vector_new(
2694 const nyx_dict_t *vector
2695);
2696
2697/*--------------------------------------------------------------------------------------------------------------------*/
2704/*--------------------------------------------------------------------------------------------------------------------*/
2705
2716 STR_t name,
2717 __NYX_NULLABLE__ STR_t label
2718);
2719
2720/*--------------------------------------------------------------------------------------------------------------------*/
2721
2733 STR_t device,
2734 STR_t name,
2735 nyx_state_t state,
2736 nyx_dict_t *props[],
2737 __NYX_NULLABLE__ const nyx_opts_t *opts
2738);
2739
2740/*--------------------------------------------------------------------------------------------------------------------*/
2741
2752 const nyx_dict_t *vector,
2753 __NYX_ZEROABLE__ size_t n_fields,
2754 const size_t field_sizes[],
2755 const buff_t field_buffs[]
2756);
2757
2758/*--------------------------------------------------------------------------------------------------------------------*/
2759
2764nyx_dict_t *nyx_stream_set_vector_new(
2765 const nyx_dict_t *vector
2766);
2767
2768/*--------------------------------------------------------------------------------------------------------------------*/
2775/*--------------------------------------------------------------------------------------------------------------------*/
2776
2786 STR_t device,
2787 __NYX_NULLABLE__ STR_t message
2788);
2789
2790/*--------------------------------------------------------------------------------------------------------------------*/
2791
2802 STR_t device,
2803 __NYX_NULLABLE__ STR_t name,
2804 __NYX_NULLABLE__ STR_t message
2805);
2806
2807/*--------------------------------------------------------------------------------------------------------------------*/
2808/* NODE */
2809/*--------------------------------------------------------------------------------------------------------------------*/
2815/*--------------------------------------------------------------------------------------------------------------------*/
2816
2822typedef struct nyx_node_s nyx_node_t;
2823
2824/*--------------------------------------------------------------------------------------------------------------------*/
2825
2831typedef enum
2832{
2833 NYX_NODE_EVENT_OPEN = 1100,
2834 NYX_NODE_EVENT_MSG = 1101,
2835
2836} nyx_event_type_t;
2837
2838/*--------------------------------------------------------------------------------------------------------------------*/
2839
2851typedef void (* nyx_mqtt_handler_t)(
2852 nyx_node_t *node,
2853 nyx_event_type_t event_type,
2854 size_t topic_size,
2855 BUFF_t topic_buff,
2856 size_t message_size,
2857 BUFF_t message_buff
2858);
2859
2860/*--------------------------------------------------------------------------------------------------------------------*/
2861
2879 STR_t node_id,
2880 nyx_dict_t *vectors[],
2881
2882 __NYX_NULLABLE__ STR_t indi_url,
2883 __NYX_NULLABLE__ STR_t mqtt_url,
2884 __NYX_NULLABLE__ STR_t nss_url,
2885
2886 __NYX_NULLABLE__ STR_t mqtt_username,
2887 __NYX_NULLABLE__ STR_t mqtt_password,
2888
2889 __NYX_NULLABLE__ nyx_mqtt_handler_t mqtt_handler,
2890
2891 uint32_t retry_ms,
2892 bool enable_xml
2893);
2894
2895/*--------------------------------------------------------------------------------------------------------------------*/
2896
2904void nyx_node_finalize(
2905 nyx_node_t *node,
2906 bool free_vectors
2907 );
2908
2909/*--------------------------------------------------------------------------------------------------------------------*/
2910
2921void nyx_node_add_timer(
2922 const nyx_node_t *node,
2923 uint32_t interval_ms,
2924 void(* callback)(void *),
2925 void *arg
2926);
2927
2928/*--------------------------------------------------------------------------------------------------------------------*/
2929
2937void nyx_node_poll(
2938 const nyx_node_t *node,
2939 uint32_t timeout_ms
2940);
2941
2942/*--------------------------------------------------------------------------------------------------------------------*/
2943
2951 __NYX_NULLABLE__ nyx_object_t *object
2952);
2953
2954/*--------------------------------------------------------------------------------------------------------------------*/
2955
2966 const nyx_node_t *node,
2967 /*------------*/ STR_t device,
2968 __NYX_NULLABLE__ STR_t name,
2969 __NYX_NULLABLE__ STR_t message
2970);
2971
2972/*--------------------------------------------------------------------------------------------------------------------*/
2973
2984 const nyx_node_t *node,
2985 /*------------*/ STR_t device,
2986 __NYX_NULLABLE__ STR_t name,
2987 __NYX_NULLABLE__ STR_t message
2988);
2989
2990/*--------------------------------------------------------------------------------------------------------------------*/
2991
3002 const nyx_node_t *node,
3003 STR_t device,
3004 __NYX_NULLABLE__ STR_t message
3005);
3006
3007/*--------------------------------------------------------------------------------------------------------------------*/
3008
3020 const nyx_node_t *node,
3021 STR_t device,
3022 __NYX_NULLABLE__ STR_t name,
3023 __NYX_NULLABLE__ STR_t message
3024);
3025
3026/*--------------------------------------------------------------------------------------------------------------------*/
3027
3037void nyx_mqtt_sub(
3038 const nyx_node_t *node,
3039 STR_t topic,
3040 int qos
3041);
3042
3043/*--------------------------------------------------------------------------------------------------------------------*/
3044
3056 const nyx_node_t *node,
3057 STR_t topic,
3058 __NYX_ZEROABLE__ size_t message_size,
3059 __NYX_NULLABLE__ BUFF_t message_buff,
3060 int qos
3061);
3062
3063/*--------------------------------------------------------------------------------------------------------------------*/
3064
3080 const nyx_node_t *node,
3081 STR_t device,
3082 STR_t stream,
3083 __NYX_ZEROABLE__ size_t n_fields,
3084 const uint32_t field_hashes[],
3085 const size_t field_sizes[],
3086 const buff_t field_buffs[]
3087);
3088
3089/*--------------------------------------------------------------------------------------------------------------------*/
3091/*--------------------------------------------------------------------------------------------------------------------*/
3092
3093#ifndef ARDUINO
3094# pragma clang diagnostic pop
3095#endif
3096
3097/*--------------------------------------------------------------------------------------------------------------------*/
3098
3099#ifdef __cplusplus
3100}
3101#endif
3102
3103/*--------------------------------------------------------------------------------------------------------------------*/
3104
3105#endif /* NYX_NODE_H */
3106
3107/*--------------------------------------------------------------------------------------------------------------------*/
__NYX_INLINE__ nyx_boolean_t * nyx_boolean_from(bool value)
Returns a JSON boolean object holding the value of the provided argument.
Definition nyx_node.h:875
__NYX_INLINE__ double nyx_dict_get_number(const nyx_dict_t *object, STR_t key)
Gets a number value of the provided key.
Definition nyx_node.h:1342
__NYX_INLINE__ bool nyx_dict_get_boolean(const nyx_dict_t *object, STR_t key)
Gets a boolean value of the provided key.
Definition nyx_node.h:1323
__NYX_INLINE__ STR_t nyx_dict_get_string(const nyx_dict_t *object, STR_t key)
Gets a C string value of the provided key.
Definition nyx_node.h:1361
__NYX_INLINE__ bool nyx_list_push(nyx_list_t *object, void *value)
Pushes a JSON object in the provided JSON list object.
Definition nyx_node.h:1531
__NYX_INLINE__ double nyx_list_get_number(const nyx_list_t *object, size_t idx)
Gets a number value at the provided index.
Definition nyx_node.h:1592
__NYX_INLINE__ STR_t nyx_list_get_string(const nyx_list_t *object, size_t idx)
Gets a C string value at the provided index.
Definition nyx_node.h:1611
__NYX_INLINE__ bool nyx_list_get_boolean(const nyx_list_t *object, size_t idx)
Gets a boolean value at the provided index.
Definition nyx_node.h:1573
nyx_log_level_e
Nyx log levels.
Definition nyx_node.h:161
void nyx_set_log_level(nyx_log_level_t level)
Sets the log level threshold.
Definition log.c:41
enum nyx_log_level_e nyx_log_level_t
Nyx log levels.
#define STR_t
Alias for const char *.
Definition nyx_node.h:71
__NYX_NULLABLE__ buff_t nyx_memory_alloc(__NYX_ZEROABLE__ size_t size)
Similar to libc malloc except that a memory overflow causes the node to stop.
__NYX_ZEROABLE__ size_t nyx_memory_free(__NYX_NULLABLE__ buff_t buff)
Similar to libc free except that it returns the amount of memory freed.
#define buff_t
Alias for void *.
Definition nyx_node.h:67
#define BUFF_t
Alias for const void *.
Definition nyx_node.h:68
void nyx_memory_initialize(void)
Initialize the memory subsystem.
Definition object.c:37
bool nyx_memory_finalize(void)
Finalize the memory subsystem.
Definition object.c:50
__NYX_NULLABLE__ str_t nyx_string_dup(__NYX_NULLABLE__ STR_t s)
Similar to libc strdup.
__NYX_NULLABLE__ str_t nyx_string_ndup(__NYX_NULLABLE__ STR_t s, __NYX_ZEROABLE__ size_t n)
Similar to libc strndup.
__NYX_NULLABLE__ buff_t nyx_memory_realloc(__NYX_NULLABLE__ buff_t buff, __NYX_ZEROABLE__ size_t size)
Similar to libc realloc except that a memory overflow causes the node to stop.
#define str_t
Alias for char *.
Definition nyx_node.h:70
bool nyx_node_notify(__NYX_NULLABLE__ nyx_object_t *object)
Notifies the provided Nyx / INDI object to the clients.
nyx_event_type_t
TCP or MQTT event type.
Definition nyx_node.h:2832
void nyx_node_send_message(const nyx_node_t *node, STR_t device, __NYX_NULLABLE__ STR_t message)
Sends a human-oriented message to the clients.
void nyx_node_disable(const nyx_node_t *node, STR_t device, __NYX_NULLABLE__ STR_t name, __NYX_NULLABLE__ STR_t message)
Disables a device or a vector and notifies clients.
void nyx_mqtt_pub(const nyx_node_t *node, STR_t topic, __NYX_ZEROABLE__ size_t message_size, __NYX_NULLABLE__ BUFF_t message_buff, int qos)
If MQTT is enabled, publishes an MQTT message.
void nyx_nss_pub(const nyx_node_t *node, STR_t device, STR_t stream, __NYX_ZEROABLE__ size_t n_fields, const uint32_t field_hashes[], const size_t field_sizes[], const buff_t field_buffs[])
If Nyx-Stream is enabled, publishes an entry to a stream.
__NYX_NULLABLE__ nyx_node_t * nyx_node_initialize(STR_t node_id, nyx_dict_t *vectors[], __NYX_NULLABLE__ STR_t indi_url, __NYX_NULLABLE__ STR_t mqtt_url, __NYX_NULLABLE__ STR_t nss_url, __NYX_NULLABLE__ STR_t mqtt_username, __NYX_NULLABLE__ STR_t mqtt_password, __NYX_NULLABLE__ nyx_mqtt_handler_t mqtt_handler, uint32_t retry_ms, bool enable_xml)
Allocates and initializes a new Nyx node.
void nyx_node_send_del_property(const nyx_node_t *node, STR_t device, __NYX_NULLABLE__ STR_t name, __NYX_NULLABLE__ STR_t message)
Sends a del-property message to the clients.
void nyx_node_enable(const nyx_node_t *node, STR_t device, __NYX_NULLABLE__ STR_t name, __NYX_NULLABLE__ STR_t message)
Enables a device or a vector and notifies clients.
str_t nyx_null_to_string(const nyx_null_t *object)
Returns a string representing the provided JSON null object.
__NYX_INLINE__ nyx_number_t * nyx_number_from(double value)
Returns a JSON number object holding the value of the provided argument.
Definition nyx_node.h:770
bool nyx_blob_prop_set_unmanaged(nyx_dict_t *prop, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Sets the new value of the provided property object.
nyx_dict_t * nyx_blob_prop_new(STR_t name, __NYX_NULLABLE__ STR_t label, __NYX_NULLABLE__ STR_t format, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff, bool managed)
Allocates a new INDI / Nyx BLOB property.
void nyx_blob_prop_get(const nyx_dict_t *prop, __NYX_NULLABLE__ size_t *size, __NYX_NULLABLE__ buff_t *buff)
Gets the current value of the provided property object.
nyx_dict_t * nyx_blob_vector_new(STR_t device, STR_t name, nyx_state_t state, nyx_perm_t perm, nyx_dict_t *props[], __NYX_NULLABLE__ const nyx_opts_t *opts)
Allocates a new INDI / Nyx BLOB vector.
bool nyx_blob_prop_set_managed(nyx_dict_t *prop, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Sets the new value of the provided property object.
nyx_dict_t * nyx_light_prop_new(STR_t name, __NYX_NULLABLE__ STR_t label, nyx_state_t value)
Allocates a new INDI / Nyx light property.
bool nyx_light_prop_set(nyx_dict_t *prop, nyx_state_t value)
Sets the new value of the provided property object.
Definition indi_light.c:43
nyx_state_t nyx_light_prop_get(const nyx_dict_t *prop)
Gets the current value of the provided property object.
Definition indi_light.c:50
nyx_dict_t * nyx_light_vector_new(STR_t device, STR_t name, nyx_state_t state, nyx_dict_t *props[], __NYX_NULLABLE__ const nyx_opts_t *opts)
Allocates a new INDI / Nyx light vector.
nyx_dict_t * nyx_message_new(STR_t device, __NYX_NULLABLE__ STR_t message)
Allocates a new INDI / Nyx human-oriented message object.
nyx_dict_t * nyx_del_property_new(STR_t device, __NYX_NULLABLE__ STR_t name, __NYX_NULLABLE__ STR_t message)
Allocates a new INDI / Nyx delete-property message object.
__NYX_INLINE__ uint32_t nyx_number_prop_get_uint(const nyx_dict_t *prop)
Gets the current value of the provided property object.
Definition nyx_node.h:2223
__NYX_INLINE__ bool nyx_number_prop_set_double(nyx_dict_t *prop, double value)
Sets the new value of the provided property object.
Definition nyx_node.h:2291
__NYX_INLINE__ double nyx_number_prop_get_double(const nyx_dict_t *prop)
Gets the current value of the provided property object.
Definition nyx_node.h:2304
__NYX_INLINE__ int64_t nyx_number_prop_get_long(const nyx_dict_t *prop)
Gets the current value of the provided property object.
Definition nyx_node.h:2250
__NYX_INLINE__ int32_t nyx_number_prop_get_int(const nyx_dict_t *prop)
Gets the current value of the provided property object.
Definition nyx_node.h:2196
__NYX_INLINE__ nyx_dict_t * nyx_number_prop_new_ulong(STR_t name, __NYX_NULLABLE__ STR_t label, STR_t format, uint64_t min, uint64_t max, uint64_t step, uint64_t value)
Allocates a new INDI / Nyx uint64_t number property.
Definition nyx_node.h:2131
__NYX_INLINE__ bool nyx_number_prop_set_uint(nyx_dict_t *prop, uint32_t value)
Sets the new value of the provided property object.
Definition nyx_node.h:2210
__NYX_INLINE__ uint64_t nyx_number_prop_get_ulong(const nyx_dict_t *prop)
Gets the current value of the provided property object.
Definition nyx_node.h:2277
__NYX_INLINE__ bool nyx_number_prop_set_long(nyx_dict_t *prop, int64_t value)
Sets the new value of the provided property object.
Definition nyx_node.h:2237
__NYX_INLINE__ nyx_dict_t * nyx_number_prop_new_double(STR_t name, __NYX_NULLABLE__ STR_t label, STR_t format, double min, double max, double step, double value)
Allocates a new INDI / Nyx double number property.
Definition nyx_node.h:2150
__NYX_INLINE__ nyx_dict_t * nyx_number_prop_new_int(STR_t name, __NYX_NULLABLE__ STR_t label, STR_t format, int32_t min, int32_t max, int32_t step, int32_t value)
Allocates a new INDI / Nyx int32_t number property.
Definition nyx_node.h:2074
__NYX_INLINE__ bool nyx_number_prop_set_ulong(nyx_dict_t *prop, uint64_t value)
Sets the new value of the provided property object.
Definition nyx_node.h:2264
__NYX_INLINE__ nyx_dict_t * nyx_number_prop_new_uint(STR_t name, __NYX_NULLABLE__ STR_t label, STR_t format, uint32_t min, uint32_t max, uint32_t step, uint32_t value)
Allocates a new INDI / Nyx uint32_t number property.
Definition nyx_node.h:2093
__NYX_INLINE__ nyx_dict_t * nyx_number_prop_new_long(STR_t name, __NYX_NULLABLE__ STR_t label, STR_t format, int64_t min, int64_t max, int64_t step, int64_t value)
Allocates a new INDI / Nyx int64_t number property.
Definition nyx_node.h:2112
nyx_dict_t * nyx_number_vector_new(STR_t device, STR_t name, nyx_state_t state, nyx_perm_t perm, nyx_dict_t *props[], __NYX_NULLABLE__ const nyx_opts_t *opts)
Allocates a new INDI / Nyx number vector.
__NYX_INLINE__ bool nyx_number_prop_set_int(nyx_dict_t *prop, int32_t value)
Sets the new value of the provided property object.
Definition nyx_node.h:2183
nyx_dict_t * nyx_stream_vector_new(STR_t device, STR_t name, nyx_state_t state, nyx_dict_t *props[], __NYX_NULLABLE__ const nyx_opts_t *opts)
Allocates a new Nyx stream vector.
nyx_dict_t * nyx_stream_prop_new(STR_t name, __NYX_NULLABLE__ STR_t label)
Allocates a new Nyx Stream.
bool nyx_stream_pub(const nyx_dict_t *vector, __NYX_ZEROABLE__ size_t n_fields, const size_t field_sizes[], const buff_t field_buffs[])
If Nyx-Stream is enabled, publishes an entry to a stream.
bool nyx_switch_prop_set(nyx_dict_t *prop, nyx_onoff_t value)
Sets the new value of the provided property object.
Definition indi_switch.c:43
nyx_dict_t * nyx_switch_vector_new(STR_t device, STR_t name, nyx_state_t state, nyx_perm_t perm, nyx_rule_t rule, nyx_dict_t *props[], __NYX_NULLABLE__ const nyx_opts_t *opts)
Allocates a new INDI / Nyx switch vector.
nyx_dict_t * nyx_switch_prop_new(STR_t name, __NYX_NULLABLE__ STR_t label, nyx_onoff_t value)
Allocates a new INDI / Nyx switch property.
nyx_onoff_t nyx_switch_prop_get(const nyx_dict_t *prop)
Gets the current value of the provided property object.
Definition indi_switch.c:50
nyx_dict_t * nyx_text_prop_new(STR_t name, __NYX_NULLABLE__ STR_t label, __NYX_NULLABLE__ STR_t value)
Allocates a new INDI / Nyx text property.
STR_t nyx_text_prop_get(const nyx_dict_t *prop)
Gets the current value of the provided property object.
Definition indi_text.c:55
nyx_dict_t * nyx_text_vector_new(STR_t device, STR_t name, nyx_state_t state, nyx_perm_t perm, nyx_dict_t *props[], __NYX_NULLABLE__ const nyx_opts_t *opts)
Allocates a new INDI / Nyx text vector.
bool nyx_text_prop_set(nyx_dict_t *prop, __NYX_NULLABLE__ STR_t value)
Sets the new value of the provided property object.
nyx_perm_t
Vector permission hint.
Definition nyx_node.h:1816
nyx_state_t
Vector state hint.
Definition nyx_node.h:1781
nyx_onoff_t
Switch state.
Definition nyx_node.h:1884
nyx_rule_t
Switch vector rule hint.
Definition nyx_node.h:1850
@ NYX_PERM_RW
Read & write.
Definition nyx_node.h:1819
@ NYX_PERM_WO
Write only.
Definition nyx_node.h:1818
@ NYX_PERM_RO
Read only.
Definition nyx_node.h:1817
@ NYX_STATE_IDLE
State is idle.
Definition nyx_node.h:1782
@ NYX_STATE_BUSY
State is busy.
Definition nyx_node.h:1784
@ NYX_STATE_OK
State is ok.
Definition nyx_node.h:1783
@ NYX_STATE_ALERT
State is alert.
Definition nyx_node.h:1785
@ NYX_ONOFF_ON
Switch is ON.
Definition nyx_node.h:1885
@ NYX_ONOFF_OFF
Switch is OFF.
Definition nyx_node.h:1886
@ NYX_RULE_ONE_OF_MANY
Only one switch of many can be ON (e.g. radio buttons).
Definition nyx_node.h:1851
@ NYX_RULE_ANY_OF_MANY
Any number of switches can be ON (e.g. check boxes).
Definition nyx_node.h:1853
@ NYX_RULE_AT_MOST_ONE
At most one switch can be ON, but all switches can be off.
Definition nyx_node.h:1852
str_t nyx_object_to_cstring(__NYX_NULLABLE__ const nyx_object_t *object)
Returns a C string, without special character escaping, representing the provided JSON object.
nyx_type_t
JSON object types.
Definition nyx_node.h:421
void nyx_object_free(__NYX_NULLABLE__ nyx_object_t *object)
Frees memory of the provided JSON object.
__NYX_NULLABLE__ nyx_object_t * nyx_object_parse(__NYX_NULLABLE__ STR_t string)
Parses a JSON object from a C string.
bool nyx_object_equal(__NYX_NULLABLE__ const nyx_object_t *object1, __NYX_NULLABLE__ const nyx_object_t *object2)
Compares two JSON objects.
__NYX_NULLABLE__ nyx_object_t * nyx_object_parse_buff(__NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Parses a JSON object from a string buffer.
str_t nyx_object_to_string(__NYX_NULLABLE__ const nyx_object_t *object)
Returns a string, with special character escaping, representing the provided JSON object.
@ NYX_TYPE_DICT
Dict object.
Definition nyx_node.h:426
@ NYX_TYPE_LIST
List object.
Definition nyx_node.h:427
@ NYX_TYPE_BOOLEAN
Boolean object.
Definition nyx_node.h:423
@ NYX_TYPE_NUMBER
Number object.
Definition nyx_node.h:424
@ NYX_TYPE_NULL
Null object.
Definition nyx_node.h:422
@ NYX_TYPE_STRING
String object.
Definition nyx_node.h:425
__NYX_INLINE__ nyx_string_t * nyx_string_from_buff_unmanaged(size_t size, BUFF_t buff)
Returns a JSON string object holding the value of the provided buffer (unmanaged reference).
Definition nyx_node.h:1121
__NYX_INLINE__ nyx_string_t * nyx_string_from_managed(STR_t value)
Returns a JSON string object holding the value of the provided string (managed reference).
Definition nyx_node.h:1062
__NYX_INLINE__ nyx_string_t * nyx_string_from_buff_managed(size_t size, BUFF_t buff)
Returns a JSON string object holding the value of the provided buffer (managed reference).
Definition nyx_node.h:1101
__NYX_INLINE__ nyx_string_t * nyx_string_from_unmanaged(STR_t value)
Returns a JSON string object holding the value of the provided string (unmanaged reference).
Definition nyx_node.h:1081
__NYX_INLINE__ nyx_string_t * nyx_string_from_dup(STR_t value)
Returns a JSON string object holding the value of the provided string (managed duplication).
Definition nyx_node.h:1043
__NYX_NULLABLE__ nyx_object_t * nyx_xmldoc_to_object(__NYX_NULLABLE__ const nyx_xmldoc_t *xmldoc)
Converts an XML Nyx / INDI command to the JSON one.
__NYX_NULLABLE__ nyx_xmldoc_t * nyx_object_to_xmldoc(__NYX_NULLABLE__ const nyx_object_t *object)
Converts a JSON Nyx / INDI command to the XML one.
__NYX_NULLABLE__ buff_t nyx_zlib_inflate(__NYX_NOTNULL__ size_t *result_size, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Decompresses a buffer using the ZLib algorithm.
uint32_t nyx_hash(__NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff, uint32_t seed)
Hashes a buffer using the MurmurHash2 algorithm.
__NYX_NULLABLE__ buff_t nyx_zlib_base64_inflate(__NYX_NOTNULL__ size_t *result_size, __NYX_ZEROABLE__ size_t len, __NYX_NULLABLE__ STR_t str)
Decompresses a string using the ZLib+Base64 algorithm.
__NYX_NULLABLE__ buff_t nyx_zlib_deflate(__NYX_NULLABLE__ size_t *result_size, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Compresses a buffer using the ZLib algorithm.
__NYX_NULLABLE__ str_t nyx_base64_encode(__NYX_NULLABLE__ size_t *result_len, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Encodes a buffer using the Base64 algorithm.
__NYX_NULLABLE__ str_t nyx_zlib_base64_deflate(__NYX_NULLABLE__ size_t *result_len, __NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Compresses a buffer using the ZLib+Base64 algorithm.
__NYX_NULLABLE__ buff_t nyx_base64_decode(__NYX_NULLABLE__ size_t *result_size, __NYX_ZEROABLE__ size_t len, __NYX_NULLABLE__ STR_t str)
Decodes a string using the Base64 algorithm.
void nyx_generate_mac_addr(uint8_t result_mac[6], uint8_t mac0, uint8_t mac1, STR_t node_id)
Generates a MAC address based on a node identifier.
Definition addr.c:14
void nyx_xmldoc_free(__NYX_NULLABLE__ nyx_xmldoc_t *xmldoc)
Frees memory of the provided XML document.
__NYX_NULLABLE__ nyx_xmldoc_t * nyx_xmldoc_parse(__NYX_NULLABLE__ STR_t string)
Parses an XML document from a C string.
__NYX_NULLABLE__ nyx_xmldoc_t * nyx_xmldoc_parse_buff(__NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
Parses an XML document from a string buffer.
str_t nyx_string_to_cstring(const nyx_string_t *object)
Struct describing a JSON boolean object.
Definition nyx_node.h:795
bool value
Boolean payload.
Definition nyx_node.h:798
nyx_object_t base
Common object header for JSON objects.
Definition nyx_node.h:796
Struct describing a JSON dict iterator.
Definition nyx_node.h:1162
size_t idx
Current zero-based iteration index.
Definition nyx_node.h:1163
struct nyx_dict_node_s * head
Next JSON object to visit.
Definition nyx_node.h:1165
Struct describing a JSON dict object.
Struct describing a JSON list iterator.
Definition nyx_node.h:1402
struct nyx_list_node_s * head
Next JSON object to visit.
Definition nyx_node.h:1405
size_t idx
Current zero-based iteration index.
Definition nyx_node.h:1403
Struct describing a JSON list object.
Opaque struct describing a Nyx node.
Struct describing a JSON null object.
Definition nyx_node.h:630
nyx_object_t base
Common object header for JSON objects.
Definition nyx_node.h:631
Struct describing a JSON number object.
Definition nyx_node.h:688
double value
Number payload.
Definition nyx_node.h:691
nyx_object_t base
Common object header for JSON objects.
Definition nyx_node.h:689
Struct describing a JSON object.
Struct describing the options for INDI / Nyx vectors.
Definition nyx_node.h:1917
__NYX_ZEROABLE__ double timeout
Worst-case time [sec] to apply, 0 by default, N/A for RO.
Definition nyx_node.h:1922
__NYX_NULLABLE__ STR_t label
GUI label, if NULL, replaced by the device name.
Definition nyx_node.h:1919
__NYX_NULLABLE__ STR_t hints
GUI Markdown description.
Definition nyx_node.h:1920
__NYX_NULLABLE__ STR_t message
Free comment.
Definition nyx_node.h:1921
__NYX_NULLABLE__ STR_t group
GUI group membership, if NULL, replaced by "Main".
Definition nyx_node.h:1918
Struct describing a JSON string object.
Definition nyx_node.h:900
str_t value
C string payload.
Definition nyx_node.h:905
nyx_object_t base
Common object header for JSON objects.
Definition nyx_node.h:901
size_t length
C string length excluding NULL.
Definition nyx_node.h:904
bool managed
true if the value is freed with this object.
Definition nyx_node.h:903
Struct describing an XML document.