12345678910111213141516171819202122232425 |
- //
- // Created by 李建 on 2023/12/6.
- //
- #include "command.h"
- #include <string.h>
- #define MAX_COMMANDS 16
- static sparrow_command sparrowCommandList[MAX_COMMANDS];
- static int commandListIndex = 0;
- void register_sparrow_command(sparrow_command cmd) {
- if(commandListIndex > MAX_COMMANDS - 1) return;
- sparrowCommandList[commandListIndex++] = cmd;
- }
- sparrow_command * find_sparrow_command(char * name) {
- for (int i =0;i < commandListIndex; i++) {
- if(strcmp(sparrowCommandList[i].name, name) == 0) {
- return &sparrowCommandList[i];
- }
- }
- return NULL;
- }
|