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();
|
15
include/conf.h
Normal file
15
include/conf.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief attempt to find the config path
|
||||
*
|
||||
* @return the path
|
||||
*/
|
||||
char *conf_config_path(void);
|
||||
|
||||
/**
|
||||
* @brief attempt to find the state path
|
||||
*
|
||||
* @return the path
|
||||
*/
|
||||
char *conf_state_path(void);
|
20
include/lua/wom.h
Normal file
20
include/lua/wom.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <lauxlib.h>
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
|
||||
/**
|
||||
* @brief list of all functions
|
||||
*/
|
||||
extern struct luaL_Reg *womlib;
|
||||
|
||||
int wom_register_subcmd(lua_State *L);
|
||||
|
||||
/**
|
||||
* @brief push a lua table with all the subcmds onto the lua stack
|
||||
*
|
||||
* @param L the lua state
|
||||
* @return
|
||||
*/
|
||||
int wom_list_subcmds(lua_State *L);
|
26
include/lua/wom_fs.h
Normal file
26
include/lua/wom_fs.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <lauxlib.h>
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
|
||||
/**
|
||||
* @brief list of all filesystem functions
|
||||
*/
|
||||
extern struct luaL_Reg *womfslib;
|
||||
|
||||
/**
|
||||
* @brief create a fs iter for lua
|
||||
*
|
||||
* @param L the lua state
|
||||
* @return
|
||||
*/
|
||||
int wom_fs_dir(lua_State *L);
|
||||
|
||||
/**
|
||||
* @brief get the type of a directory in lua
|
||||
*
|
||||
* @param L the lua state
|
||||
* @return
|
||||
*/
|
||||
int wom_fs_type(lua_State *L);
|
11
include/subcmds.h
Normal file
11
include/subcmds.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* The funcs below are not in need of documentation because they follow the
|
||||
* subcmd pattern
|
||||
*/
|
||||
|
||||
void timer_subcmd(void *, int argc, char *argv[]);
|
||||
void subcmds_dev(void *, int argc, char *argv[]);
|
||||
void motd_subcmd(void *, int argc, char *argv[]);
|
||||
void subcmds_subcmd(void *, int argc, char *argv[]);
|
Reference in New Issue
Block a user