• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ read_history函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中read_history函数的典型用法代码示例。如果您正苦于以下问题:C++ read_history函数的具体用法?C++ read_history怎么用?C++ read_history使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了read_history函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: HHVM_FUNCTION

static bool HHVM_FUNCTION(readline_read_history,
                          const String& filename /* = null */) {
  if (filename.isNull()) {
    return read_history(nullptr) == 0;
  } else {
    return read_history(filename.data()) == 0;
  }
}
开发者ID:bsmr-misc-forks,项目名称:hhvm,代码行数:8,代码来源:ext_readline.cpp


示例2: HHVM_FUNCTION

static bool HHVM_FUNCTION(readline_read_history,
                          const Variant& filename /* = null */) {
  if (filename.isNull()) {
    return read_history(nullptr) == 0;
  } else {
    auto const filenameString = filename.toString();
    return read_history(filenameString.data()) == 0;
  }
}
开发者ID:mattflaschen,项目名称:hhvm,代码行数:9,代码来源:ext_readline.cpp


示例3: edit_init

int edit_init(void (*cmd_cb)(void *ctx, char *cmd),
	      void (*eof_cb)(void *ctx),
	      char ** (*completion_cb)(void *ctx, const char *cmd, int pos),
	      void *ctx, const char *history_file, const char *ps)
{
	edit_cb_ctx = ctx;
	edit_cmd_cb = cmd_cb;
	edit_eof_cb = eof_cb;
	edit_completion_cb = completion_cb;

	rl_attempted_completion_function = readline_completion;
	if (history_file) {
		read_history(history_file);
		stifle_history(100);
	}

	eloop_register_read_sock(STDIN_FILENO, edit_read_char, NULL, NULL);

	if (ps) {
		size_t blen = os_strlen(ps) + 3;
		char *ps2 = os_malloc(blen);
		if (ps2) {
			os_snprintf(ps2, blen, "%s> ", ps);
			rl_callback_handler_install(ps2, readline_cmd_handler);
			os_free(ps2);
			return 0;
		}
	}

	rl_callback_handler_install("> ", readline_cmd_handler);

	return 0;
}
开发者ID:0x000000FF,项目名称:wpa_supplicant_for_edison,代码行数:33,代码来源:edit_readline.c


示例4: console_init_history

static int console_init_history(const char *histfile)
{
   int ret = 0;

#ifdef HAVE_READLINE
   int max_history_length;

   using_history();

   /*
    * First truncate the history size to an reasonable size.
    */
   max_history_length = (me) ? me->history_length : 100;
   history_truncate_file(histfile, max_history_length);

   /*
    * Read the content of the history file into memory.
    */
   ret = read_history(histfile);

   /*
    * Tell the completer that we want a complete.
    */
   rl_completion_entry_function = dummy_completion_function;
   rl_attempted_completion_function = readline_completion;
   rl_filename_completion_desired = 0;
   stifle_history(max_history_length);
#endif

   return ret;
}
开发者ID:patito,项目名称:bareos,代码行数:31,代码来源:console.c


示例5: main

gint
main (gint argc, gchar **argv)
{
	cli_infos_t *cli_infos;

	setlocale (LC_ALL, "");

	cli_infos = cli_infos_init (argc - 1, argv + 1);

	/* Execute command, if connection status is ok */
	if (cli_infos) {
		if (cli_infos->mode == CLI_EXECUTION_MODE_INLINE) {
			loop_once (cli_infos, argc - 1, argv + 1);
		} else {
			gchar *filename;

			filename = configuration_get_string (cli_infos->config,
			                                     "HISTORY_FILE");

			read_history (filename);
			using_history ();
			loop_run (cli_infos);
			write_history (filename);
		}
	}

	cli_infos_free (cli_infos);

	return 0;
}
开发者ID:chrippa,项目名称:xmms2,代码行数:30,代码来源:main.c


示例6: lua_interactive

int lua_interactive (int argc, char * argv[])
{
    int error = 0;
    char * line;
    lua_State * L;
    char history_filename[256];

    snprintf(history_filename, 256, "%s/%s", 
             getenv("HOME"), LUA_HISTORY_FILENAME);

    L = luaL_newstate();
    lua_rt_init(L, argc, argv);

    read_history(history_filename);

    while (1) {
        line = readline("X) ");
        add_history(line);
        stifle_history(LUA_HISTORY_LINES);
        write_history(history_filename);

        error = luaL_dostring(L, line);
        if (error) {
            line = (char *) luaL_checkstring(L, -1);
            printf("%s\n", line);
        }
        fflush(stdout);
    }

    return 0;
}
开发者ID:endeav0r,项目名称:Rainbows-And-Pwnies-Tools,代码行数:31,代码来源:lua.c


示例7: lua_rl_init

/* Initialize readline library. */
static void lua_rl_init(lua_State *L)
{
  char *s;

  lua_rl_L = L;

  /* This allows for $if lua ... $endif in ~/.inputrc. */
  rl_readline_name = "lua";
  /* Break words at every non-identifier character except '.' and ':'. */
  rl_completer_word_break_characters = 
    (char *)"\t\r\n !\"#$%&'()*+,-/;<=>[email protected][\\]^`{|}~";
  rl_completer_quote_characters = "\"'";
#if RL_READLINE_VERSION < 0x0600
  rl_completion_append_character = '\0';
#endif
  rl_attempted_completion_function = lua_rl_complete;
  rl_initialize();

  /* Start using history, optionally set history size and load history file. */
  using_history();
  if ((s = getenv("LUA_HISTSIZE")) &&
      (lua_rl_histsize = atoi(s))) stifle_history(lua_rl_histsize);
  if (!(lua_rl_hist = getenv("LUA_HISTORY"))) {
    char *ss = (char*)malloc((strlen(getenv("HOME"))+13)*sizeof(char));
    strcpy(ss,getenv("HOME"));
    lua_rl_hist = strcat(ss, "/.luahistory");
  }
  read_history(lua_rl_hist);
}
开发者ID:0w,项目名称:torch,代码行数:30,代码来源:lua.c


示例8: load_history

/* Load the history list from the history file. */
void
load_history ()
{
  char *hf;

  /* Truncate history file for interactive shells which desire it.
     Note that the history file is automatically truncated to the
     size of HISTSIZE if the user does not explicitly set the size
     differently. */
  set_if_not ("HISTFILESIZE", get_string_value ("HISTSIZE"));
  stupidly_hack_special_variables ("HISTFILESIZE");

  /* Read the history in HISTFILE into the history list. */
  hf = get_string_value ("HISTFILE");

  if (hf && *hf)
    {
      struct stat buf;

      if (stat (hf, &buf) == 0)
	{
	  read_history (hf);
	  using_history ();
	  history_lines_in_file = where_history ();
	}
    }
}
开发者ID:cardmagic,项目名称:lucash,代码行数:28,代码来源:bashhist.c


示例9: readline_init

static void readline_init(void) {
    rl_readline_name = "augtool";
    rl_attempted_completion_function = readline_completion;
    rl_completion_entry_function = readline_path_generator;

    /* Set up persistent history */
    char *home_dir = get_home_dir(getuid());
    char *history_dir = NULL;

    if (home_dir == NULL)
        goto done;

    if (xasprintf(&history_dir, "%s/.augeas", home_dir) < 0)
        goto done;

    if (mkdir(history_dir, 0755) < 0 && errno != EEXIST)
        goto done;

    if (xasprintf(&history_file, "%s/history", history_dir) < 0)
        goto done;

    stifle_history(500);

    read_history(history_file);

 done:
    free(home_dir);
    free(history_dir);
}
开发者ID:camptocamp,项目名称:augeas-debian,代码行数:29,代码来源:augtool.c


示例10: clipit_init

/* Startup calls and initializations */
static void clipit_init() {
	/* Create clipboard */
	primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
	clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
	g_timeout_add(CHECK_INTERVAL, item_check, NULL);

	/* Read preferences */
	read_preferences();

	/* Read history */
	if (prefs.save_history)
		read_history();

	/* Bind global keys */
	keybinder_init();
	keybinder_bind(prefs.history_key, history_hotkey, NULL);
	keybinder_bind(prefs.actions_key, actions_hotkey, NULL);
	keybinder_bind(prefs.menu_key, menu_hotkey, NULL);
	keybinder_bind(prefs.search_key, search_hotkey, NULL);
	keybinder_bind(prefs.offline_key, offline_hotkey, NULL);

	/* Create status icon */
	if (!prefs.no_icon)
	{
#ifdef HAVE_APPINDICATOR
	create_app_indicator(1);
#else
	status_icon = gtk_status_icon_new_from_icon_name("clipit-trayicon");
	gtk_status_icon_set_tooltip((GtkStatusIcon*)status_icon, _("Clipboard Manager"));
	g_signal_connect((GObject*)status_icon, "button_press_event", (GCallback)status_icon_clicked, NULL);
#endif
	}
}
开发者ID:AlexandroCasanova,项目名称:ClipIt,代码行数:34,代码来源:main.c


示例11: jtag_load_history

static void
jtag_load_history( void )
{
    char *home = getenv( "HOME" );
    char *file;

    using_history();

    if (!home)
        return;

    file = malloc( strlen(home) + strlen(JTAGDIR) + strlen(HISTORYFILE) + 3 );	/* 2 x "/" and trailing \0 */
    if (!file)
        return;

    strcpy( file, home );
    strcat( file, "/" );
    strcat( file, JTAGDIR );
    strcat( file, "/" );
    strcat( file, HISTORYFILE );

    read_history( file );

    free( file );
}
开发者ID:tbnobody,项目名称:usbprog,代码行数:25,代码来源:jtag.c


示例12: main

int main( int argc, char **argv )
{
	char file[MAX_FILENAME_LEN + 1];
	char *line, *prompt="> ";
	int i;

	if ( argc == 2 )
		ystrncpy( file, argv[1], MAX_FILENAME_LEN );
	else
		yerror( "missing filename\n" );

	restores( file );
	prints();
	restorer( file );

	for( i = 0; i < status.datan; i++ )
		readdata( status.dataf[i], i );

	port = gp_open( "400x400" );
	using_history();
	stifle_history(1000);
	sprintf( historyfile, "%s/%s", getenv("HOME"), HISTORYFILE );
	if ( !access (historyfile, R_OK) )
		if ( read_history(historyfile) )
			perror( "reading history" );
	while (1) {
		line=readline( prompt );
		if ( line ) {
			add_history( line );
			parser( line );

		} else printf( "\n" );
	}
	return 0;
}
开发者ID:idaohang,项目名称:gpsr-1,代码行数:35,代码来源:cli.c


示例13: Yap_InitReadline

bool Yap_InitReadline(Term enable) {
  // don't call readline within emacs
  if (Yap_Embedded)
    return false;
  if (!(GLOBAL_Stream[StdInStream].status & Tty_Stream_f) ||
      getenv("INSIDE_EMACS") || enable != TermTrue) {
    if (GLOBAL_Flags)
      setBooleanGlobalPrologFlag(READLINE_FLAG, false);
    return false;
  }
  GLOBAL_Stream[StdInStream].u.irl.buf = NULL;
  GLOBAL_Stream[StdInStream].u.irl.ptr = NULL;
  GLOBAL_Stream[StdInStream].status |= Readline_Stream_f;
#if _WIN32
  rl_instream = stdin;
#endif
  // rl_outstream = stderr;
  using_history();
  const char *s = Yap_AbsoluteFile("~/.YAP.history", true);
  history_file = s;
  if (read_history(s) != 0) {
    FILE *f = fopen(s, "a");
    if (f) {
      fclose(f);
    }
  }
  rl_readline_name = "YAP Prolog";
  rl_attempted_completion_function = prolog_completion;
  // rl_prep_terminal(1);
  if (GLOBAL_Flags)
    setBooleanGlobalPrologFlag(READLINE_FLAG, true);
  return Yap_ReadlineOps(GLOBAL_Stream + StdInStream);
}
开发者ID:vscosta,项目名称:yap-6.3,代码行数:33,代码来源:readline.c


示例14: main

int main(int argc, char **argv)
{
  mudlle_init();

  define_string_vector("argv", (const char *const *)argv, argc);

#ifdef USE_READLINE
  bool is_tty = isatty(0);
  if (is_tty)
    {
      using_history();
      read_history(HISTORY_FILE);
      rl_bind_key('\t', rl_insert);

      if (atexit(history_exit))
        perror("atexit(history_exit)");
    }
#endif

  struct oport *out = make_file_oport(stdout);
  struct session_context context;
  session_start(&context,
                &(const struct session_info){
                  .mout        = out,
                  .merr        = out,
                  .maxseclevel = MAX_SECLEVEL });
开发者ID:MUME,项目名称:mudlle,代码行数:26,代码来源:mudlle-main.c


示例15: stopping

Console::Console(QString _name, CommandInterpreter *_interpreter) :
  stopping(false),
  name(_name),
  interpreter(_interpreter)
{
  QObject::connect(this, SIGNAL(read(QString)),
                   interpreter, SLOT(handleString(QString)));
  QObject::connect(interpreter, SIGNAL(write(QString)),
                   this, SLOT(write(QString)));
  QObject::connect(interpreter, SIGNAL(writeAsync(QString)),
                   this, SLOT(writeAsync(QString)));
  QObject::connect(interpreter, SIGNAL(exit()), this, SLOT(quit()));


  /** allow conditional parsing of the inputrc file */
  rl_readline_name = name.toAscii();
  /** tell the completer that we want a crack first. */
  rl_console = this;
  rl_attempted_completion_function = &Console::ConsoleCompletion;
  rl_event_hook = poll;
  rl_catch_signals = 0;
  // rl_set_keyboard_input_timeout(100000);

  using_history();
  historyFile = QDir::homePath() + QString("/.%1_history").arg(name);
  QFile file(historyFile);
  if (!file.exists()) {
    // create file
    file.open(QIODevice::ReadWrite);
    file.close();
  }
  read_history(historyFile.toAscii().constData());
  //    rl_bind_key('\t', readline_completion);
}
开发者ID:wesen,项目名称:fatfs,代码行数:34,代码来源:console.cpp


示例16: main

int main(int argc, char *argv[])
{
    read_history(history_file);
    load_tab_completion();
    signal(SIGINT, &sighandler); // Don't die on sigint

    FILE * fd_sig = fdopen(5, "r"); // get signals to read from fd5
    if(!fd_sig)
        exit(0);

    FILE * fd_out = fdopen(6, "w"); // output lines on fd6
    if(!fd_out)
        exit(0);

    if(argc > 1) // load the prompt if available
        prompt = argv[1];

    do 
    {
        read_command(fd_sig, fd_out);
    } while(command);
 
    free(command);
    command = NULL;
    fclose(fd_sig);
    fclose(fd_out);

    write_history(history_file);
    return 0;
}
开发者ID:sbbowers,项目名称:Coterminous-Conflux,代码行数:30,代码来源:readline_wrapper.cpp


示例17: cli_context_loop

void
cli_context_loop (cli_context_t *ctx, gint argc, gchar **argv)
{
	/* Execute command, if connection status is ok */
	if (argc == 0) {
		gchar *filename = configuration_get_string (ctx->config, "HISTORY_FILE");

		ctx->mode = CLI_EXECUTION_MODE_SHELL;

		/* print welcome message before initialising readline */
		if (configuration_get_boolean (ctx->config, "SHELL_START_MESSAGE")) {
			g_printf (_("Welcome to the XMMS2 CLI shell!\n"));
			g_printf (_("Type 'help' to list the available commands "
			            "and 'exit' (or CTRL-D) to leave the shell.\n"));
		}
		readline_resume (ctx);

		read_history (filename);
		using_history ();

		while (!cli_context_in_status (ctx, CLI_ACTION_STATUS_FINISH)) {
			cli_context_event_loop_select (ctx);
		}

		write_history (filename);
	} else {
		ctx->mode = CLI_EXECUTION_MODE_INLINE;
		cli_context_command_or_flag_dispatch (ctx, argc , argv);

		while (cli_context_in_status (ctx, CLI_ACTION_STATUS_BUSY) ||
		       cli_context_in_status (ctx, CLI_ACTION_STATUS_REFRESH)) {
			cli_context_event_loop_select (ctx);
		}
	}
}
开发者ID:randalboyle,项目名称:xmms2-devel,代码行数:35,代码来源:cli_context.c


示例18: linphonec_initialize_readline

/*
 * Use globals:
 *
 *	- char *histfile_name (also sets this)
 *      - char *last_in_history (allocates it)
 */
static int
linphonec_initialize_readline()
{
	/*rl_bind_key('\t', rl_insert);*/

	/* Allow conditional parsing of ~/.inputrc */
	rl_readline_name = "linphonec";

	/* Call idle_call() every second */
	rl_set_keyboard_input_timeout(LPC_READLINE_TIMEOUT);
	rl_event_hook=linphonec_idle_call;

	/* Set history file and read it */
	histfile_name = ms_strdup_printf ("%s/.linphonec_history",
		getenv("HOME"));
	read_history(histfile_name);

	/* Initialized last_in_history cache*/
	last_in_history[0] = '\0';

	/* Register a completion function */
	rl_attempted_completion_function = linephonec_readline_completion;

	/* printf("Readline initialized.\n"); */
        setlinebuf(stdout);
	return 0;
}
开发者ID:rogerhzh,项目名称:linphone_linux_XIA,代码行数:33,代码来源:linphonec.c


示例19: load_history

//------------------------------------------------------------------------------
static void load_history()
{
    char buffer[1024];
    get_history_file_name(buffer, sizeof(buffer));
    read_history(buffer);
    history_set_pos(history_length);
}
开发者ID:hello-xk,项目名称:kiwi,代码行数:8,代码来源:clink_rl.c


示例20: main

int main(int argc, char *argv[]) {

    if(argc <= 1){
        show_usage();
        return 0;
    }

    //surpress stderr, because dblib.c display ugly error message
    freopen("/dev/null", "w", stderr);
 
    dbinfo = (struct dbconfig *)malloc(sizeof(struct dbconfig));
    if (!set_cmd_option( argc, argv, dbinfo)){
        return 0;
    }
    if (!connect_db(dbinfo)){
        return 0;
    }

    //set hisotry file path
    history_file = (char *)malloc(256);
    strcpy(history_file, getenv("HOME"));
    strcat(history_file, MSSQL_HISTORY_FILE_NAME);
    read_history(history_file); //read history for incremental search (ctrl + r)

    rl_startup_hook = my_startup; //set up readline with original method binding
    my_readline();
}
开发者ID:hanhan1978,项目名称:mssql,代码行数:27,代码来源:mssql.c



注:本文中的read_history函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ read_id函数代码示例发布时间:2022-05-30
下一篇:
C++ read_groups函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap