a simple cmdline implementation method--structure define
来源:互联网 发布:淘宝开店赚钱吗 编辑:程序博客网 时间:2024/06/10 20:15
structure define:
the major structure consist of cmdline_param_t and cmdline_instance_t.
//parameter of cmdline
typedef struct{
// --- Command line
unsigned int line_len; // Maximum length of the command line
// --- I/O
int non_blocking; // !0, if I/O in non blocking mode
int fd_in; // Input file descriptor
int fd_out; // Output file descriptor
// --- History
unsigned int histo_len; // History size
int auto_or_sp; // Auto-completion or spaces for TAB
#define CMDLINE_TAB_AUTO_COMPLETE 0 // Provide 'auto_complete' callback (may be NUL)
#define CMDLINE_TAB_SPACES 1 // Provide the number of 'spaces' for a TAB (may be 0)
union
{
void (*auto_complete)(void *ctx, // User context
const unsigned char *cmd_line, // Current displayed command line
unsigned int *cursor, // IN: Current cursor position
// OUT: New cursor position
unsigned char **completed_cmd_line);// New command line if any (NULL otherwise)
// Callback called upon TAB keystroke to trigger auto-completion
unsigned int spaces; // Number of spaces to display for a TAB
} tab;
char histo_shortcut; // Character to call an history entry (0 if not activated)
void *ctx; // Any user private information for future reference
} cmdline_param_t;
// Instance descriptor of cmdline
typedef struct
{
cmdline_param_t user; // User parameters
int dbg; // Debug level
unsigned char *cmd_line; // Command line
unsigned char *saved_cmd_line; // Saved command line
int echo_on; // !0, if echo activated
struct termios orig_term_settings; // Saved terminal settings
struct termios new_term_settings; // Saved terminal settings
int in_flag; // Flags of input descriptor
// Command line mngt
unsigned char stored_ungetc;
int state; // Current state of the FSM
int prev_state; // Previous FSM state
int cursor; // Cursor's position in the line
unsigned int line_sz; // Number of chars in the line
char eol; // Character for 'end of line'
// History mngt
int histo_on; // !0, if echo activated
unsigned char *histo; // History
int histo_cur; // Current display index
unsigned int histo_sz; // Number of occupied entries
unsigned int histo_insert; // Insertion index
// Function key
cmdline_fn_key_t function_key; // Callback called upon function keystroke
- a simple cmdline implementation method--structure define
- a simple cmdline implementation method--fuction
- Very simple A* algorithm implementation
- A Simple HTTP Server Implementation
- Dynamic Method Resolution && Providing a Method Implementation Dynamically
- OSCommerce3 Template Structure Implementation
- A Simple Implementation of Binary Search Tree in C++
- Matrix Factorization: A Simple Tutorial and Implementation in
- Dynamic 2D Imposters: A Simple, Efficient DirectX 9 Implementation
- Single Server With Multiple Clients : a Simple C++ Implementation
- A simple implementation of string split in C++
- A simple implementation of Bézier curve
- A Simple But Complete Implementation of Binary Search Tree
- Matrix Factorization: A Simple Tutorial and Implementation in Python
- Matrix Factorization: A Simple Tutorial and Implementation in Python
- Dynamic 2D Imposters: A Simple, Efficient DirectX 9 Implementation
- SVM简单实例-A simple implementation of SVM using Matlab
- Matrix Factorization: A Simple Tutorial and Implementation in Python
- Uninstall ParetoLogic PC Health Advisor
- php基础学习 函数 常用函数
- asp.net中用于显示包含html标记的服务器端控件 Literal
- 行为类型评定
- HDU-1016 prime ring problem
- a simple cmdline implementation method--structure define
- GNU风格--通用源码下载方法
- C++智能指针
- [转载]用 bat 批处理 实现自动telnet
- 心理成熟度测试
- 职业兴趣测评
- cvLoadImage()导致内存泄露的解决方法
- php时间函数
- fork函数注意的几点