2022-02-25 04:13:05 +00:00
|
|
|
#ifndef SHELLTERM_H
|
|
|
|
#define SHELLTERM_H
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2022-03-07 21:16:46 +00:00
|
|
|
#include <sys/ioctl.h>
|
2022-02-25 04:13:05 +00:00
|
|
|
#include <sys/select.h>
|
|
|
|
#include <termios.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include "sclient.h"
|
|
|
|
|
2022-03-21 22:47:46 +00:00
|
|
|
typedef enum {
|
|
|
|
TERM_BLACK,
|
|
|
|
TERM_RED,
|
|
|
|
TERM_GREEN,
|
|
|
|
TERM_YELLOW,
|
|
|
|
TERM_BLUE,
|
|
|
|
TERM_MAGENTA,
|
|
|
|
TERM_CYAN,
|
|
|
|
TERM_WHITE,
|
|
|
|
TERM_BRIGHT_BLACK,
|
|
|
|
TERM_BRIGHT_RED,
|
|
|
|
TERM_BRIGHT_GREEN,
|
|
|
|
TERM_BRIGHT_YELLOW,
|
|
|
|
TERM_BRIGHT_BLUE,
|
|
|
|
TERM_BRIGHT_MAGENTA,
|
|
|
|
TERM_BRIGHT_CYAN,
|
|
|
|
TERM_BRIGHT_WHITE
|
|
|
|
} TERM_COLOR;
|
|
|
|
|
2022-03-22 14:50:22 +00:00
|
|
|
#define PRINTTAG(color) shellT_printf("\r%s[~]%s ", shellT_getForeColor(color), shellT_getForeColor(TERM_BRIGHT_WHITE))
|
|
|
|
|
2022-03-22 00:47:18 +00:00
|
|
|
#define PRINTINFO(...) do { \
|
2022-03-22 14:50:22 +00:00
|
|
|
PRINTTAG(TERM_BRIGHT_YELLOW); \
|
2022-03-22 00:47:18 +00:00
|
|
|
shellT_printf(__VA_ARGS__); \
|
|
|
|
} while(0);
|
|
|
|
|
|
|
|
#define PRINTSUCC(...) do { \
|
2022-03-22 14:50:22 +00:00
|
|
|
PRINTTAG(TERM_BRIGHT_GREEN); \
|
|
|
|
shellT_printf(__VA_ARGS__); \
|
|
|
|
} while(0);
|
|
|
|
|
|
|
|
#define PRINTERROR(...) do { \
|
|
|
|
PRINTTAG(TERM_BRIGHT_RED); \
|
2022-03-22 00:47:18 +00:00
|
|
|
shellT_printf(__VA_ARGS__); \
|
|
|
|
} while(0);
|
2022-03-21 22:47:46 +00:00
|
|
|
|
2022-02-25 04:13:05 +00:00
|
|
|
void shellT_conioTerm(void);
|
|
|
|
void shellT_resetTerm(void);
|
2022-03-21 22:47:46 +00:00
|
|
|
const char *shellT_getForeColor(TERM_COLOR);
|
2022-02-25 04:13:05 +00:00
|
|
|
void shellT_printf(const char *format, ...);
|
|
|
|
|
|
|
|
/* waits for input for timeout (in ms). returns true if input is ready to be read, false if no events */
|
|
|
|
bool shellT_waitForInput(int timeout);
|
2022-03-02 16:38:16 +00:00
|
|
|
int shellT_readRawInput(uint8_t *buf, size_t max);
|
|
|
|
void shellT_writeRawOutput(uint8_t *buf, size_t sz);
|
2022-03-07 21:16:46 +00:00
|
|
|
void shellT_getTermSize(int *col, int *row);
|
2022-02-25 04:13:05 +00:00
|
|
|
char shellT_getch(void);
|
|
|
|
int shellT_kbget(void);
|
|
|
|
void shellT_printPrompt(void);
|
|
|
|
void shellT_setPrompt(char *prompt);
|
|
|
|
void shellT_addChar(tShell_client *client, int c); /* processes input, moving cursor, adding char to cmd, etc. */
|
|
|
|
|
|
|
|
#endif
|