文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>使用GNU ReadLine Library实现命令解析器

使用GNU ReadLine Library实现命令解析器

时间:2010-05-31  来源:creatory

使用GNU ReadLine Library实现命令解析器(历史记录,Tab自动补全等) #include <stdio.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/errno.h>
#include <readline/readline.h>
#include <readline/history.h>
extern char *getwd ();
extern char *xmalloc ();
/* The names of functions that actually do the manipulation. */
int com_list (char*);
int com_view (char*);
int com_rename (char*);
int com_stat (char*);
int com_pwd (char*);
int com_delete (char*);
int com_help (char*);
int com_cd (char*);
int com_quit (char*);
/* A structure which contains information on the commands this program
   can understand. */
typedef struct {
  char *name;        /* User printable name of the function. */
  Function *func;    /* Function to call to do the job. */
  char *doc;        /* Documentation for this function. */
} COMMAND;
COMMAND commands[] = {
  { "cd", com_cd, "Change to directory DIR" },
  { "delete", com_delete, "Delete FILE" },
  { "help", com_help, "Display this text" },
  { "?", com_help, "Synonym for `help'" },
  { "list", com_list, "List files in DIR" },
  { "ls", com_list, "Synonym for `list'" },
  { "pwd", com_pwd, "Print the current working directory" },
  { "quit", com_quit, "Quit using Fileman" },
  { "rename", com_rename, "Rename FILE to NEWNAME" },
  { "stat", com_stat, "Print out statistics on FILE" },
  { "view", com_view, "View the contents of FILE" },
  { (char *)NULL, (Function *)NULL, (char *)
相关阅读 更多 +
排行榜 更多 +
三角符文第一章下载

三角符文第一章下载

角色扮演 下载
嘀嘀动画官方正版下载

嘀嘀动画官方正版下载

趣味娱乐 下载
像素世界僵尸危机安卓版

像素世界僵尸危机安卓版

飞行射击 下载