当前位置: 首页>>代码示例>>C++>>正文


C++ write_history函数代码示例

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


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

示例1: wrapper_for_write_history

static void
wrapper_for_write_history()
{
#if 1
    /* Alternative code, saves one disk access */
    if (history_is_stifled())
	unstifle_history();
    if (gnuplot_history_size >= 0)
	stifle_history (gnuplot_history_size);

    /* returns 0 on success */
    if (write_history(expanded_history_filename))
	fprintf (stderr, "Warning:  Could not write history file!!!\n");

    unstifle_history();
#else
    /* if writing was successful, truncate history
     *  to gnuplot_history_size lines
     */
    if (write_history(expanded_history_filename)) {
	if (gnuplot_history_size >= 0)
	    history_truncate_file(expanded_history_filename, gnuplot_history_size);
    }
#endif
}
开发者ID:dheerajrav,项目名称:gnuplot-context,代码行数:25,代码来源:plot.c

示例2: HHVM_FUNCTION

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

示例3: HHVM_FUNCTION

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

示例4: main

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

    setlocale(LC_ALL, "");

    parse_opts(argc, argv);

    aug = aug_init(root, loadpath, flags|AUG_NO_ERR_CLOSE);
    if (aug == NULL || aug_error(aug) != AUG_NOERROR) {
        fprintf(stderr, "Failed to initialize Augeas\n");
        if (aug != NULL)
            print_aug_error();
        exit(EXIT_FAILURE);
    }
    add_transforms(transforms, transformslen);
    if (print_version) {
        print_version_info();
        return EXIT_SUCCESS;
    }
    readline_init();
    if (optind < argc) {
        // Accept one command from the command line
        r = run_args(argc - optind, argv+optind);
    } else {
        r = main_loop();
    }
    if (history_file != NULL)
        write_history(history_file);

    return r == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
开发者ID:camptocamp,项目名称:augeas-debian,代码行数:31,代码来源:augtool.c

示例5: quit

static void quit(const char *line)
{
	gp_close( port );
	if ( write_history(historyfile) )
		perror( "writing history" );
	exit(EXIT_SUCCESS);
}
开发者ID:idaohang,项目名称:gpsr-1,代码行数:7,代码来源:cli.c

示例6: write_history

int Spider_Url_Rinse::uninitialize()
{
	write_history();
	evdns_base_free(m_evdnsbase, 0);
	event_base_free(m_evbase);
	return 0;
}
开发者ID:KGMSFT,项目名称:Spider,代码行数:7,代码来源:spider_url_rinse.cpp

示例7: readline

int CLI::shell()
{
	for (exitShell_ = false; !exitShell_; ) {
		char* cmdline = readline("desaster> ");
		if (!cmdline) {
			printf("\n");
			return 0;
		}

		if (!shellHistoryFilename_.empty())
			add_history(cmdline);

		try {
			evaluate(cmdline);
		} catch (MultipleCommandsMatchError& e) {
			printf("%s\n", e.what());
		} catch (NotFoundError& e) {
			printf("%s\n", e.what());
		}

		if (!shellHistoryFilename_.empty())
			write_history(shellHistoryFilename_.c_str());
	}

	return 0;
}
开发者ID:christianparpart,项目名称:desaster,代码行数:26,代码来源:CLI.cpp

示例8: QString

void Shell::saveShellHistory()
{
#ifdef CONFIG_READLINE
	// Only save history for interactive sessions
	if (_listenOnSocket)
		return;

	// Construct the path name of the history file
	QStringList pathList = QString(mt_history_file).split("/", QString::SkipEmptyParts);
	pathList.pop_back();
	QString path = pathList.join("/");

    // Create history path, if it does not exist
    if (!QDir::home().exists(path) && !QDir::home().mkpath(path))
        debugerr("Error creating path for saving the history");

    // Save the history for the next launch
    QString histFile = QDir::home().absoluteFilePath(mt_history_file);
    QByteArray ba = histFile.toLocal8Bit();
    int ret = write_history(ba.constData());
    if (ret)
        debugerr("Error #" << ret << " occured when trying to save the "
                 "history data to \"" << histFile << "\"");
#endif
}
开发者ID:wxdublin,项目名称:insight-vmi,代码行数:25,代码来源:shell_readline.cpp

示例9: console_update_history

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

#ifdef HAVE_READLINE
   int max_history_length,
       truncate_entries;

   /*
    * Calculate how much we should keep in the current history file.
    */
   max_history_length = (me) ? me->history_length : 100;
   truncate_entries = max_history_length - history_length;
   if (truncate_entries < 0) {
      truncate_entries = 0;
   }

   /*
    * First, try to truncate the history file, and if it
    * fails, the file is probably not present, and we
    * can use write_history to create it.
    */
   if (history_truncate_file(histfile, truncate_entries) == 0) {
      ret = append_history(history_length, histfile);
   } else {
      ret = write_history(histfile);
   }
#endif

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

示例10: 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

示例11: assert

void readline_constructor_impl::impl::stop()
{
  if (current_readline == NULL) {
    // We're already stopped
    return;
  }

  assert(detail::current_readline == this);
  stdin_reader_.cancel();
  redisplay_timer_.cancel();
  rl_callback_handler_remove();
  detail::current_readline = NULL;
  std::cout << std::endl;

  if (!history_file_.empty()) {
    boost::filesystem::create_directories(history_file_.parent_path());
    if (0 == write_history(history_file_.c_str())) {
      if (0 != history_truncate_file(
            history_file_.c_str(), history_length
          )) {
        throw relasio_error("error truncating history\n");
      }
    } else {
      throw relasio_error("error writing history\n");
    }
  }
}
开发者ID:jbytheway,项目名称:relasio,代码行数:27,代码来源:readline.cpp

示例12: fe_reset_input_mode

void fe_reset_input_mode ()
{
#if defined(HAVE_DYN_RL)
  char *p = getenv("SINGULARHIST");
  if ((p != NULL) && (fe_history_total_bytes != NULL))
  {
    if((*fe_history_total_bytes)()!=0)
      (*fe_write_history) (p);
  }
#endif
#if defined(HAVE_READLINE) && !defined(HAVE_FEREAD) && !defined(HAVE_DYN_RL)
  char *p = getenv("SINGULARHIST");
  if (p != NULL)
  {
    if(history_total_bytes()!=0)
      write_history (p);
  }
#endif
#if defined(HAVE_FEREAD)
  #ifndef HAVE_ATEXIT
  fe_reset_fe(NULL,NULL);
  #else
  fe_reset_fe();
  #endif
#endif
}
开发者ID:alexandermattes,项目名称:Singular,代码行数:26,代码来源:fereadl.c

示例13: 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

示例14: write_history_file

static PyObject *
write_history_file(PyObject *self, PyObject *args)
{
    PyObject *filename_obj = Py_None, *filename_bytes;
    char *filename;
    int err;
    if (!PyArg_ParseTuple(args, "|O:write_history_file", &filename_obj))
        return NULL;
    if (filename_obj != Py_None) {
        if (!PyUnicode_FSConverter(filename_obj, &filename_bytes))
            return NULL;
        filename = PyBytes_AsString(filename_bytes);
    } else {
        filename_bytes = NULL;
        filename = NULL;
    }
    errno = err = write_history(filename);
    if (!err && _history_length >= 0)
        history_truncate_file(filename, _history_length);
    Py_XDECREF(filename_bytes);
    errno = err;
    if (errno)
        return PyErr_SetFromErrno(PyExc_IOError);
    Py_RETURN_NONE;
}
开发者ID:3lnc,项目名称:cpython,代码行数:25,代码来源:readline.c

示例15: exit_clean

/*
 * Here's our exit function. Just make sure everything
 * is freed, and any open files are closed. Added exit
 * message if you have anything to say, if you don't 
 * you can pass it NULL and nothing will be printed.
 */
void exit_clean(int ret_no, const char *exit_message){
  /*This is a bit hacky, try to append_history.
   *if that doesn't work, write history, which creates
   *the file, then writes to it. Should suffice for now. 
   */
  if(history){
    if(append_history(1000, history_filename) != 0) 
      if(write_history(history_filename) != 0){
	write_to_log(SHELL_OOPS, "could not write history");
	perror("history");
      }
  }
  if(input)
    free(input);
  if(history_filename)
    free(history_filename);
  if(env)
    free(env);
  if(rc_file)
    fclose(rc_file);
  if(PS1 && specified_PS1 == 1)
    free(PS1);
  if(log_open)
    fclose(log_file);
  if(exit_message)
    fprintf(stderr,"%s", exit_message);
  exit(ret_no);
}
开发者ID:tangfu,项目名称:Cash,代码行数:34,代码来源:cash.c


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