Finished first Version

- fixed doxygen comments
- changed license to MPLv2
- fixed some functions and removed not used ones
This commit is contained in:
prozessorkern
2019-06-23 22:17:15 +02:00
parent bf7f366cb6
commit 7344075ad1
3 changed files with 966 additions and 319 deletions

View File

@@ -1,35 +1,19 @@
/*
* MIT License
*
* Copyright (c) 2019 Stefan Strobel <stefan.strobel@shimatta.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
* THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/**
* @file shellmatta.h
* @brief API definition of the Shellmatta terminal implementation
* @author Stefan Strobel <stefan.strobel@shimatta.net>
* @file shellmatta.h
* @brief API definition of the Shellmatta terminal implementation
* @author Stefan Strobel <stefan.strobel@shimatta.net>
*/
/**
* @addtogroup shellmatta
* @addtogroup shellmatta_api
* @{
*/
@@ -39,6 +23,13 @@
#include <stdint.h>
#include <stdbool.h>
/* global defines */
/**
* @brief definition of a shellmatta handle
*/
typedef void* shellmatta_handle_t;
/**
* @brief definition of shellmatta return codes
*/
@@ -62,11 +53,19 @@ typedef enum
/**
* @brief shellmatta command function definition
* @param[in] handle pointer to the instance which is calling the cmd
* @param[in] arguments argument string called to run this command beginning
* with the command itself
* @param[in] length length of the argument string
*/
typedef shellmatta_retCode_t (*shellmatta_cmdFct_t)(int argc, char *argv[]);
typedef shellmatta_retCode_t (*shellmatta_cmdFct_t)(const shellmatta_handle_t handle,
const char *arguments,
uint32_t length);
/**
* @brief shellmatta write function definition
* @param[in] data data to be written to the output
* @param[in] length length of the data to be written
*/
typedef shellmatta_retCode_t (*shellmatta_write_t)(const char* data, uint32_t length);
@@ -88,11 +87,12 @@ typedef struct shellmatta_cmd
*/
typedef struct
{
uint8_t *buffer; /**< input buffer */
uint32_t magic; /**< magic number to check if initialized */
char *buffer; /**< input buffer */
uint32_t bufferSize; /**< size of the input buffer */
uint32_t inputCount; /**< offset of the current write operation */
uint32_t cursor; /**< offset where the cursor is at */
uint8_t *historyBuffer; /**< buffer to store the last commands */
char *historyBuffer; /**< buffer to store the last commands */
uint32_t historyBufferSize; /**< size of the history buffer */
uint32_t historyStart; /**< index of the oldest stored command */
uint32_t historyEnd; /**< index of the newest stored command */
@@ -100,27 +100,35 @@ typedef struct
bool historyReadUp; /**< flag to show the last history dir */
uint32_t tabCounter; /**< counts the tabulator key presses */
uint32_t escapeCounter; /**< counts the characters of an escape seq */
uint8_t escapeChars[4]; /**< buffer to save the escape characters */
char escapeChars[4]; /**< buffer to save the escape characters */
bool echoEnabled; /**< if true the input is printed */
bool dirty; /**< dirty flag to show changes */
const char *prompt; /**< prompt is printed after every command */
shellmatta_mode_t mode; /**< mode of the shell */
shellmatta_write_t write; /**< pointer to write function */
shellmatta_cmd_t *cmdList; /**< pointer to the first command */
bool cmdListIsConst; /**< true if the #cmdList was passed during
initialization */
} shellmatta_instance_t;
shellmatta_retCode_t shellmatta_doInit( shellmatta_instance_t *inst,
uint8_t *buffer,
uint32_t bufferSize,
uint8_t *historyBuffer,
uint32_t historyBufferSize,
const char *prompt,
shellmatta_write_t writeFct);
shellmatta_retCode_t shellmatta_addCmd(shellmatta_instance_t *inst, shellmatta_cmd_t *cmd);
void shellmatta_doTask(shellmatta_instance_t *inst, uint32_t time);
void shellmatta_processData(shellmatta_instance_t *inst, char *data, uint32_t size);
void shellmatta_printf(shellmatta_instance_t *inst, const char *fmt, ...);
void shellmatta_getArg(uint32_t cnt, uint8_t *arg);
shellmatta_handle_t *handle,
char *buffer,
uint32_t bufferSize,
char *historyBuffer,
uint32_t historyBufferSize,
const char *prompt,
const shellmatta_cmd_t *cmdList,
shellmatta_write_t writeFct);
shellmatta_retCode_t shellmatta_addCmd( shellmatta_handle_t handle,
shellmatta_cmd_t *cmd);
shellmatta_retCode_t shellmatta_processData(shellmatta_handle_t handle,
char *data,
uint32_t size);
shellmatta_retCode_t shellmatta_printf( shellmatta_handle_t handle,
const char *fmt,
...);
#endif