您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ write_history函数代码示例

51自学网 2021-06-03 10:05:48
  C++
这篇教程C++ write_history函数代码示例写得很实用,希望能帮到您。

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

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

示例1: wrapper_for_write_history

static voidwrapper_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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例10: main

gintmain (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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例16: cli_context_loop

voidcli_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,


示例17: save_history_dotfile

static void save_history_dotfile(void){    char *dotfile = g_strconcat(g_get_home_dir(), "/.fsp_history", NULL);    stifle_history(100); /* arbitrarily restrict history file to 100 entries */    write_history(dotfile);    g_free(dotfile);}
开发者ID:BorderCloud,项目名称:4store,代码行数:7,


示例18: Rstd_savehistory

void attribute_hidden Rstd_savehistory(SEXP call, SEXP op, SEXP args, SEXP env){    SEXP sfile;    char file[PATH_MAX];    const char *p;    sfile = CAR(args);    if (!isString(sfile) || LENGTH(sfile) < 1)	errorcall(call, _("invalid '%s' argument"), "file");    p = R_ExpandFileName(translateChar(STRING_ELT(sfile, 0)));    if(strlen(p) > PATH_MAX - 1)	errorcall(call, _("'file' argument is too long"));    strcpy(file, p);#if defined(HAVE_LIBREADLINE) && defined(HAVE_READLINE_HISTORY_H)    if(R_Interactive && UsingReadline) {	int err;	err = write_history(file);	if(err) error(_("problem in saving the history file '%s'"), file);	/* Note that q() uses stifle_history, but here we do not want	 * to truncate the active history when saving during a session */#ifdef HAVE_HISTORY_TRUNCATE_FILE	R_setupHistory(); /* re-read the history size */	err = history_truncate_file(file, R_HistorySize);	if(err) warning(_("problem in truncating the history file"));#endif    } else errorcall(call, _("no history available to save"));#else    errorcall(call, _("no history available to save"));#endif}
开发者ID:lovmoy,项目名称:r-source,代码行数:30,


示例19: _save_history_file

static void_save_history_file (void){  char *hfile = _get_history_file ();  write_history (hfile);  free (hfile);}
开发者ID:clarete,项目名称:bitu,代码行数:7,


示例20: append_history

void append_history(char *path, char *cmd){	if (!path || !cmd) return;	add_history(cmd);	write_history(path);}
开发者ID:piaoyunsoft,项目名称:libimobiledevice,代码行数:7,


示例21: save_history

//------------------------------------------------------------------------------void save_history(){    int max_history;    char buffer[512];    get_history_file_name(buffer, sizeof(buffer));    // Get max history size.    max_history = get_clink_setting_int("history_file_lines");    max_history = (max_history == 0) ? INT_MAX : max_history;    if (max_history < 0)    {        unlink(buffer);        return;    }    // Write new history to the file, and truncate to our maximum.    if (append_history(g_new_history_count, buffer) != 0)    {        write_history(buffer);    }    if (max_history != INT_MAX)    {        history_truncate_file(buffer, max_history);    }    g_new_history_count = 0;}
开发者ID:cristianBGonzalez,项目名称:clink,代码行数:30,


示例22: save_history

//------------------------------------------------------------------------------void save_history(){    int max_history;    char buffer[1024];    const char* c;    if (get_clink_setting_int("persist_history") == 0)    {        return;    }    get_history_file_name(buffer, sizeof(buffer));    // Get max history size.    c = rl_variable_value("history-size");    max_history = (c != NULL) ? atoi(c) : 1000;    // Write new history to the file, and truncate to our maximum.    if (append_history(g_new_history_count, buffer) != 0)    {        write_history(buffer);    }    history_truncate_file(buffer, max_history);}
开发者ID:HTshandou,项目名称:clink,代码行数:26,


示例23: 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,


示例24: edit_deinit

void edit_deinit(const char *history_file,		 int (*filter_cb)(void *ctx, const char *cmd)){	rl_callback_handler_remove();	readline_free_completions();	eloop_unregister_read_sock(STDIN_FILENO);	if (history_file) {		/* Save command history, excluding lines that may contain		 * passwords. */		HIST_ENTRY *h;		history_set_pos(0);		while ((h = current_history())) {			char *p = h->line;			while (*p == ' ' || *p == '/t')				p++;			if (filter_cb && filter_cb(edit_cb_ctx, p)) {				h = remove_history(where_history());				if (h) {					os_free(h->line);					free(h->data);					os_free(h);				} else					next_history();			} else				next_history();		}		write_history(history_file);	}}
开发者ID:MultiNet-80211,项目名称:Hostapd,代码行数:31,


示例25: finishInput

finishInput(int exitstatus, void *arg)#endif{#ifdef USE_READLINE	if (useHistory)	{		char	   *home;		char	   *psql_history;		home = getenv("HOME");		if (home)		{			psql_history = (char *) malloc(strlen(home) + 1 +										   strlen(PSQLHISTORY) + 1);			if (psql_history)			{				int			hist_size;				hist_size = GetVariableNum(pset.vars, "HISTSIZE", -1, -1, true);				if (hist_size >= 0)					stifle_history(hist_size);				sprintf(psql_history, "%s/%s", home, PSQLHISTORY);				write_history(psql_history);				free(psql_history);			}		}	}#endif}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:31,


示例26: readline_exit

static void readline_exit(void){	char *path = expand_tilde(HISTORY_FILENAME);	if (path) {		write_history(path);		free(path);	}}
开发者ID:Batov,项目名称:libusb_chrome_api,代码行数:8,


示例27: deinit_readline

voiddeinit_readline(void){	str history = mal_clients->history;	if (history) {		write_history(history);	}}
开发者ID:jaiminpan,项目名称:Monetdb,代码行数:8,


示例28: f_write_history

static int f_write_history(lua_State *L){	const char* file = lua_tostring(L,1);	if(write_history(file) != 0)		luaL_error(L, "writing history from file %s failed", file);	lua_pushboolean(L, 1);	return 1;}
开发者ID:dustingooding,项目名称:rttlua_completion,代码行数:8,


示例29: cleanup_exit

static void cleanup_exit(int code) {   if (chardev || sockdev)      show("", ON_NEW_LINE);   if (history_active)      (void)write_history(historyfilename);   exit(code);}
开发者ID:aropop,项目名称:pico,代码行数:8,


示例30: halcmd_save_history

void halcmd_save_history(){    char path[PATH_MAX];    snprintf(path,sizeof(path),"%s/%s", getenv("HOME"), HALCMD_HISTORY);    if ((write_history (path)))        perror(path);    history_truncate_file (path, MAX_HISTORY);}
开发者ID:ArcEye,项目名称:machinekit,代码行数:8,



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


C++ write_image函数代码示例
C++ write_header函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。