==> include/mesh/abi/name.h <==1/* @ajax/mesh-abi-name: Valid program names: [a-z0-9-]{1,15}.
2 *
3 * Part of alpha-c-mesh, a C port of alpha-rust-mesh (README.md says from where). */
4#ifndef MESH_ABI_NAME_H
5#define MESH_ABI_NAME_H
6
7#include <stdbool.h>
8#include <stddef.h>
9#include <stdint.h>
10#include "mesh/abi/base.h"
11
12/* A valid program name: [a-z0-9-]{1,15}. */
13static inline bool mesh_valid_name(const uint8_t *b, size_t n) {
14 if (n == 0 || n > MESH_NAME_MAX) return false;
15 for (size_t i = 0; i < n; i++) {
16 uint8_t c = b[i];
17 if (!((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '-')) return false;
18 }
19 return true;
20}
21
22#endif