linkd

Control plane daemon for unos
git clone git://git.finwo.net/app/linkd
Log | Files | Refs | README

registry.c (490B)


      1 #include <string.h>
      2 #include "registry.h"
      3 
      4 #define CLI_MAX 32
      5 
      6 static const char *cli_names[CLI_MAX];
      7 static cli_main_fn cli_fns[CLI_MAX];
      8 static int cli_count = 0;
      9 
     10 void cli_register(const char *name, cli_main_fn fn) {
     11   if (cli_count >= CLI_MAX) return;
     12   cli_names[cli_count] = name;
     13   cli_fns[cli_count] = fn;
     14   cli_count++;
     15 }
     16 
     17 cli_main_fn cli_find(const char *name) {
     18   for (int i = 0; i < cli_count; i++) {
     19     if (!strcmp(cli_names[i], name)) return cli_fns[i];
     20   }
     21   return NULL;
     22 }