initial commit
This commit is contained in:
47
include/api.h
Normal file
47
include/api.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include "ds.h"
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
void (*cb)(void *, int argc, char *argv[]);
|
||||
void *data;
|
||||
} wom_subcmd_t;
|
||||
|
||||
/**
|
||||
* @brief pointer to all registered subcommands
|
||||
*/
|
||||
extern ds_sll_t *subcmds;
|
||||
|
||||
/**
|
||||
* @brief register a new subcommand
|
||||
*
|
||||
* @param name name which should be used to call subcommand
|
||||
* @param cb function to run when name is called
|
||||
* @param data pointer to data to pass to the cb
|
||||
* @return 0 on success
|
||||
*/
|
||||
int register_subcmd(char *name, void (*cb)(void *, int argc, char *argv[]), void *data);
|
||||
|
||||
|
||||
/**
|
||||
* @brief list out all registered subcmds
|
||||
*
|
||||
* @return list of subcmds
|
||||
*/
|
||||
char **list_subcmds();
|
||||
|
||||
/**
|
||||
* @brief run subcmds mentioned in argv
|
||||
*
|
||||
* @param argc argc
|
||||
* @param argv argv
|
||||
*/
|
||||
void run_subcmds(int argc, char *argv[]);
|
||||
|
||||
/**
|
||||
* @brief unregister and free all subcmds
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int cleanup_subcmds();
|
Reference in New Issue
Block a user