static struct sol_str_slice get_node_name(const struct sol_fbp_node *node) { static const struct sol_str_table_ptr component_to_glyph[] = { SOL_STR_TABLE_PTR_ITEM("timer", "🕐 Timer"), SOL_STR_TABLE_PTR_ITEM("boolean/and", "∧ And"), SOL_STR_TABLE_PTR_ITEM("boolean/or", "∨ Or"), SOL_STR_TABLE_PTR_ITEM("boolean/not", "¬ Not"), SOL_STR_TABLE_PTR_ITEM("boolean/xor", "⊕ Xor"), { } }; const char *glyph; if (sol_str_table_ptr_lookup(component_to_glyph, node->component, &glyph)) return sol_str_slice_from_str(glyph); return node->name; }
{ } static const struct sol_message_digest_info _md5_info = { .digest_size = MD5_DIGEST_LENGTH, .context_size = sizeof(md5_ctx_t), .init = _sol_message_digest_md5_init, .ops = { .feed = _sol_message_digest_md5_feed, .read_digest = _sol_message_digest_md5_read_digest, .cleanup = _sol_message_digest_md5_cleanup } }; static const struct sol_str_table_ptr _available_digests[] = { SOL_STR_TABLE_PTR_ITEM("sha256", &_sha256_info), SOL_STR_TABLE_PTR_ITEM("md5", &_md5_info), { } }; SOL_API struct sol_message_digest * sol_message_digest_new(const struct sol_message_digest_config *config) { const struct sol_message_digest_info *dinfo; struct sol_message_digest *handle; struct sol_message_digest_common_new_params params; struct sol_str_slice algorithm; errno = EINVAL; SOL_NULL_CHECK(config, NULL); SOL_NULL_CHECK(config->on_digest_ready, NULL);
memcpy(copy_queue, values, len * sizeof(*copy_queue)); qsort(copy_queue, len, sizeof(*copy_queue), int_cmp); if (len % 2) ret = copy_queue[len / 2]; else ret = _normalize_mean(©_queue[len / 2 - 1], 2); free(copy_queue); return ret; } static const struct sol_str_table_ptr table[] = { SOL_STR_TABLE_PTR_ITEM("mean", _normalize_mean), SOL_STR_TABLE_PTR_ITEM("median", _normalize_median), { } }; // ============================================================================= static int _irange_buffer_do(struct irange_buffer_data *mdata) { int32_t result; if (!mdata->cur_len) return 0; result = mdata->normalize_cb(mdata->input_queue, mdata->cur_len);
SOL_ERR("Could not set serial attr: %s", sol_util_strerrora(errno)); goto attr_err; } free(portname); return 0; attr_err: close(mavlink->fd); err: free(portname); return -errno; } static const struct sol_str_table_ptr protocol_table[] = { SOL_STR_TABLE_PTR_ITEM("tcp", sol_mavlink_init_tcp), SOL_STR_TABLE_PTR_ITEM("serial", sol_mavlink_init_serial), { } }; static inline const void * sol_mavlink_parse_addr_protocol(const char *str, struct sol_str_slice *addr, int *port) { struct sol_vector tokens; struct sol_str_slice slice = sol_str_slice_from_str(str); const void *init; tokens = sol_str_slice_split(slice, ":", 0); if (tokens.len <= 1) { SOL_ERR("Invalid addr string, it must specify at least <prot>:<addr>"); return NULL;
return false; } static bool _normalize_any_false(const bool *const values, size_t len) { for (size_t i = 0; i < len; i++) if (values[i] == false) { return true; } return false; } static const struct sol_str_table_ptr table[] = { SOL_STR_TABLE_PTR_ITEM("all_true", _normalize_all_true), SOL_STR_TABLE_PTR_ITEM("all_false", _normalize_all_false), SOL_STR_TABLE_PTR_ITEM("any_true", _normalize_any_true), SOL_STR_TABLE_PTR_ITEM("any_false", _normalize_any_false), { } }; // ============================================================================= static int _boolean_buffer_do(struct boolean_buffer_data *mdata) { bool result; if (!mdata->cur_len) return 0;
SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry4, 0, 16, 0, 0); SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry5, 0, 16, 0, 0); SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry6, 0, 10, 0, 0); SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry7, 0, 32, 0, 0); SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry8, 0, 8, 0, 0); SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry9, 0, 32, 0, 0); SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry10, 0, 16, 0, 0); SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry11, 0, 16, 0, 0); SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry12, 0, 1, 0, 0); SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry13, 0, 1, 0, 0); SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry14, 0, 10, 0, 0); SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry15, 0, 32, 0, 0); SOL_MEMMAP_ENTRY_BIT_SIZE(map0_entry16, 0, 32, 0, 0); static const struct sol_str_table_ptr _memmap0_entries[] = { SOL_STR_TABLE_PTR_ITEM("_version", &map0_entry0), SOL_STR_TABLE_PTR_ITEM("boolean", &map0_entry1), SOL_STR_TABLE_PTR_ITEM("int_only_val", &map0_entry2), SOL_STR_TABLE_PTR_ITEM("byte", &map0_entry3), SOL_STR_TABLE_PTR_ITEM("int", &map0_entry4), SOL_STR_TABLE_PTR_ITEM("irange", &map0_entry5), SOL_STR_TABLE_PTR_ITEM("string", &map0_entry6), SOL_STR_TABLE_PTR_ITEM("double", &map0_entry7), SOL_STR_TABLE_PTR_ITEM("double_only_val", &map0_entry8), SOL_STR_TABLE_PTR_ITEM("drange", &map0_entry9), SOL_STR_TABLE_PTR_ITEM("int_def", &map0_entry10), SOL_STR_TABLE_PTR_ITEM("irange_def", &map0_entry11), SOL_STR_TABLE_PTR_ITEM("byte_def", &map0_entry12), SOL_STR_TABLE_PTR_ITEM("boolean_def", &map0_entry13), SOL_STR_TABLE_PTR_ITEM("string_def", &map0_entry14), SOL_STR_TABLE_PTR_ITEM("double_def", &map0_entry15),