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

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

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

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

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

示例1: Clear

void cTokenizer::Tokenize(bool trim){  Clear();  MYDEBUG("String wird in Token zerlegt");  char *buffer = NULL;  char *token = NULL;  char *tok_pointer;  buffer = strdup(String);  if(trim)    buffer = stripspace(buffer);  for(token = strtok_r(buffer, Delim, &tok_pointer);      token;      token = strtok_r(NULL, Delim, &tok_pointer))  {    MYDEBUG("Token gefunden: %s", token);    if(!trim)      Add(new cToken(token));    else      Add(new cToken(stripspace(token)));  }  free(buffer);}
开发者ID:suborb,项目名称:reelvdr,代码行数:25,


示例2: while

bool cNestedItemList::Parse(FILE *f, cList<cNestedItem> *List, int &Line){  char *s;  cReadLine ReadLine;  while ((s = ReadLine.Read(f)) != NULL) {        Line++;        char *p = strchr(s, '#');        if (p)           *p = 0;        s = skipspace(stripspace(s));        if (!isempty(s)) {           p = s + strlen(s) - 1;           if (*p == '{') {              *p = 0;              stripspace(s);              cNestedItem *Item = new cNestedItem(s, true);              List->Add(Item);              if (!Parse(f, Item->SubItems(), Line))                 return false;              }           else if (*s == '}')              break;           else              List->Add(new cNestedItem(s));           }        }  return true;}
开发者ID:RaZiegler,项目名称:vdr-yavdr,代码行数:28,


示例3: strchr

bool RoboTVChannels::read(FILE* f, cChannels* channels) {    cReadLine ReadLine;    for(char* line = ReadLine.Read(f); line != NULL; line = ReadLine.Read(f)) {        char* hash = strchr(line, '#');        if(hash != NULL) {            *hash = 0;        }        stripspace(line);        if(!isempty(line)) {            cChannel* c = new cChannel();            if(c->Parse(line)) {                channels->Add(c);            }            else {                delete c;                ERRORLOG("Invalid channel: %s", line);                return false;            }        }    }    channels->ReNumber();    return true;}
开发者ID:vitmod,项目名称:vdr-plugin-robotv,代码行数:29,


示例4: prepare_note_data

static void prepare_note_data(const unsigned char *object, struct note_data *d,		const unsigned char *old_note){	if (d->use_editor || !d->given) {		int fd;		struct strbuf buf = STRBUF_INIT;		/* write the template message before editing: */		d->edit_path = git_pathdup("NOTES_EDITMSG");		fd = open(d->edit_path, O_CREAT | O_TRUNC | O_WRONLY, 0600);		if (fd < 0)			die_errno(_("could not create file '%s'"), d->edit_path);		if (d->given)			write_or_die(fd, d->buf.buf, d->buf.len);		else if (old_note)			copy_obj_to_fd(fd, old_note);		strbuf_addch(&buf, '/n');		strbuf_add_commented_lines(&buf, note_template, strlen(note_template));		strbuf_addch(&buf, '/n');		write_or_die(fd, buf.buf, buf.len);		write_commented_object(fd, object);		close(fd);		strbuf_release(&buf);		strbuf_reset(&d->buf);		if (launch_editor(d->edit_path, &d->buf, NULL)) {			die(_("Please supply the note contents using either -m or -F option"));		}		stripspace(&d->buf, 1);	}}
开发者ID:kylebarney,项目名称:git,代码行数:35,


示例5: edit_branch_description

static int edit_branch_description(const char *branch_name){	FILE *fp;	int status;	struct strbuf buf = STRBUF_INIT;	struct strbuf name = STRBUF_INIT;	read_branch_desc(&buf, branch_name);	if (!buf.len || buf.buf[buf.len-1] != '/n')		strbuf_addch(&buf, '/n');	strbuf_commented_addf(&buf,		    "Please edit the description for the branch/n"		    "  %s/n"		    "Lines starting with '%c' will be stripped./n",		    branch_name, comment_line_char);	fp = fopen(git_path(edit_description), "w");	if ((fwrite(buf.buf, 1, buf.len, fp) < buf.len) || fclose(fp)) {		strbuf_release(&buf);		return error(_("could not write branch description template: %s"),			     strerror(errno));	}	strbuf_reset(&buf);	if (launch_editor(git_path(edit_description), &buf, NULL)) {		strbuf_release(&buf);		return -1;	}	stripspace(&buf, 1);	strbuf_addf(&name, "branch.%s.description", branch_name);	status = git_config_set(name.buf, buf.len ? buf.buf : NULL);	strbuf_release(&name);	strbuf_release(&buf);	return status;}
开发者ID:AViscatanius,项目名称:git,代码行数:35,


示例6: astring_printf

astring *image_info_astring(running_machine *machine, astring *string){	device_image_interface *image = NULL;	astring_printf(string, "%s/n/n", machine->gamedrv->description);#if 0	if (mess_ram_size > 0)	{		char buf2[RAM_STRING_BUFLEN];		astring_catprintf(string, "RAM: %s/n/n", ram_string(buf2, mess_ram_size));	}#endif	for (bool gotone = machine->m_devicelist.first(image); gotone; gotone = image->next(image))	{		const char *name = image->filename();		if (name != NULL)		{			const char *base_filename;			const char *info;			char *base_filename_noextension;			base_filename = image->basename();			base_filename_noextension = strip_extension(base_filename);			/* display device type and filename */			astring_catprintf(string, "%s: %s/n", image->image_config().devconfig().name(), base_filename);			/* display long filename, if present and doesn't correspond to name */			info = image->longname();			if (info && (!base_filename_noextension || mame_stricmp(info, base_filename_noextension)))				astring_catprintf(string, "%s/n", info);			/* display manufacturer, if available */			info = image->manufacturer();			if (info != NULL)			{				astring_catprintf(string, "%s", info);				info = stripspace(image->year());				if (info && *info)					astring_catprintf(string, ", %s", info);				astring_catprintf(string,"/n");			}			/* display playable information, if available */			info = image->playable();			if (info != NULL)				astring_catprintf(string, "%s/n", info);			if (base_filename_noextension != NULL)				free(base_filename_noextension);		}		else		{			astring_catprintf(string, "%s: ---/n", image->image_config().devconfig().name());		}	}	return string;}
开发者ID:johkelly,项目名称:MAME_hi,代码行数:60,


示例7: ram_string

void ui_menu_image_info::image_info_astring(running_machine &machine, astring &string){	string.printf("%s/n/n", machine.system().description);#if 0	if (mess_ram_size > 0)	{		char buf2[RAM_STRING_BUFLEN];		string.catprintf("RAM: %s/n/n", ram_string(buf2, mess_ram_size));	}#endif	image_interface_iterator iter(machine.root_device());	for (device_image_interface *image = iter.first(); image != NULL; image = iter.next())	{		const char *name = image->filename();		if (name != NULL)		{			const char *base_filename;			const char *info;			char *base_filename_noextension;			base_filename = image->basename();			base_filename_noextension = strip_extension(base_filename);			// display device type and filename			string.catprintf("%s: %s/n", image->device().name(), base_filename);			// display long filename, if present and doesn't correspond to name			info = image->longname();			if (info && (!base_filename_noextension || core_stricmp(info, base_filename_noextension)))				string.catprintf("%s/n", info);			// display manufacturer, if available			info = image->manufacturer();			if (info != NULL)			{				string.catprintf("%s", info);				info = stripspace(image->year());				if (info && *info)					string.catprintf(", %s", info);				string.catprintf("/n");			}			// display supported information, if available			switch(image->supported()) {				case SOFTWARE_SUPPORTED_NO : string.catprintf("Not supported/n"); break;				case SOFTWARE_SUPPORTED_PARTIAL : string.catprintf("Partially supported/n"); break;				default : break;			}			if (base_filename_noextension != NULL)				free(base_filename_noextension);		}		else		{			string.catprintf("%s: ---/n", image->device().name());		}	}}
开发者ID:Ander-son,项目名称:libretro-mame,代码行数:60,


示例8: parse_msg_arg

static int parse_msg_arg(const struct option *opt, const char *arg, int unset){	struct note_data *d = opt->value;	strbuf_grow(&d->buf, strlen(arg) + 2);	if (d->buf.len)		strbuf_addch(&d->buf, '/n');	strbuf_addstr(&d->buf, arg);	stripspace(&d->buf, 0);	d->given = 1;	return 0;}
开发者ID:kylebarney,项目名称:git,代码行数:13,


示例9: parse_msg_arg

static int parse_msg_arg(const struct option *opt, const char *arg, int unset){	struct msg_arg *msg = opt->value;	strbuf_grow(&(msg->buf), strlen(arg) + 2);	if (msg->buf.len)		strbuf_addch(&(msg->buf), '/n');	strbuf_addstr(&(msg->buf), arg);	stripspace(&(msg->buf), 0);	msg->given = 1;	return 0;}
开发者ID:flichtenheld,项目名称:git,代码行数:13,


示例10: main

int main(void){  char *name, *command, *path, *s1;    s1 = "user name is me";  name = stripspace(s1);  printf("%s/n", name);  path = malloc(50 * sizeof(char));  strcpy(path, "/bin/");  command = "ls";  strcat(path, command);  printf("%s/n", path);    exit(0);}
开发者ID:initpidzero,项目名称:circular_buffer,代码行数:15,


示例11: parse_file_arg

static int parse_file_arg(const struct option *opt, const char *arg, int unset){	struct msg_arg *msg = opt->value;	if (msg->buf.len)		strbuf_addch(&(msg->buf), '/n');	if (!strcmp(arg, "-")) {		if (strbuf_read(&(msg->buf), 0, 1024) < 0)			die_errno("cannot read '%s'", arg);	} else if (strbuf_read_file(&(msg->buf), arg, 1024) < 0)		die_errno("could not open or read '%s'", arg);	stripspace(&(msg->buf), 0);	msg->given = 1;	return 0;}
开发者ID:flichtenheld,项目名称:git,代码行数:16,


示例12: parse_file_arg

static int parse_file_arg(const struct option *opt, const char *arg, int unset){	struct note_data *d = opt->value;	if (d->buf.len)		strbuf_addch(&d->buf, '/n');	if (!strcmp(arg, "-")) {		if (strbuf_read(&d->buf, 0, 1024) < 0)			die_errno(_("cannot read '%s'"), arg);	} else		strbuf_read_file_or_die(&(d->buf), arg, 0);	stripspace(&d->buf, 0);	d->given = 1;	return 0;}
开发者ID:kylebarney,项目名称:git,代码行数:16,


示例13: cmd_stripspace

int cmd_stripspace(int argc, const char **argv, const char *prefix){	struct strbuf buf = STRBUF_INIT;	int strip_comments = 0;	if (argc > 1 && (!strcmp(argv[1], "-s") ||				!strcmp(argv[1], "--strip-comments")))		strip_comments = 1;	if (strbuf_read(&buf, 0, 1024) < 0)		die_errno("could not read the input");	stripspace(&buf, strip_comments);	write_or_die(1, buf.buf, buf.len);	strbuf_release(&buf);	return 0;}
开发者ID:Fabiano-lr,项目名称:git,代码行数:18,


示例14: template_untouched

/* * See if the user edited the message in the editor or left what * was in the template intact */static int template_untouched(struct strbuf *sb){	struct strbuf tmpl = STRBUF_INIT;	char *start;	if (cleanup_mode == CLEANUP_NONE && sb->len)		return 0;	if (!template_file || strbuf_read_file(&tmpl, template_file, 0) <= 0)		return 0;	stripspace(&tmpl, cleanup_mode == CLEANUP_ALL);	start = (char *)skip_prefix(sb->buf, tmpl.buf);	if (!start)		start = sb->buf;	strbuf_release(&tmpl);	return rest_is_empty(sb, start - sb->buf);}
开发者ID:AresDice,项目名称:git,代码行数:22,


示例15: prepare_to_commit

static void prepare_to_commit(void){	struct strbuf msg = STRBUF_INIT;	strbuf_addbuf(&msg, &merge_msg);	strbuf_addch(&msg, '/n');	write_merge_msg(&msg);	run_hook(get_index_file(), "prepare-commit-msg",		 git_path("MERGE_MSG"), "merge", NULL, NULL);	if (option_edit) {		if (launch_editor(git_path("MERGE_MSG"), NULL, NULL))			abort_commit(NULL);	}	read_merge_msg(&msg);	stripspace(&msg, option_edit);	if (!msg.len)		abort_commit(_("Empty commit message."));	strbuf_release(&merge_msg);	strbuf_addbuf(&merge_msg, &msg);	strbuf_release(&msg);}
开发者ID:NitzanDavari,项目名称:ios-perl,代码行数:20,


示例16: switch

eOSState cCMDDir::New(eKeys Key){  switch(Key)  {    case kOk:      if(!isempty(Dir))      {        char *buffer = NULL;        asprintf(&buffer, "%s/%s", CurrentDir(), stripspace(Dir));        MYDEBUG("Verzeichnis: Neu: Anlegen: %s", buffer);        cFileInfo *info = new cFileInfo(buffer);        if(info->isExists())        {          MYDEBUG("Verzeichnis existiert bereits");          OSD_WARNMSG(tr("Directory exists"));          FREENULL(buffer);          DELETENULL(info);          return osContinue;        }        if(cFileCMD::Mkdir(buffer))        {          MYDEBUG("Verzeichnis anlegen erfolgreich");          LastSelDir(buffer);          if(!Select)            OsdObject->SetState(mmsReInit);        }        FREENULL(buffer);        DELETENULL(info);      }    case kBack:      State = csNone;      Build();      return osContinue;      break;    default:      break;  }  return cOsdMenu::ProcessKey(Key);}
开发者ID:suborb,项目名称:reelvdr,代码行数:40,


示例17: message_is_empty

/* * Find out if the message starting at position 'start' in the strbuf * contains only whitespace and Signed-off-by lines. */static int message_is_empty(struct strbuf *sb, int start){	struct strbuf tmpl;	const char *nl;	int eol, i;	if (cleanup_mode == CLEANUP_NONE && sb->len)		return 0;	/* See if the template is just a prefix of the message. */	strbuf_init(&tmpl, 0);	if (template_file && strbuf_read_file(&tmpl, template_file, 0) > 0) {		stripspace(&tmpl, cleanup_mode == CLEANUP_ALL);		if (start + tmpl.len <= sb->len &&		    memcmp(tmpl.buf, sb->buf + start, tmpl.len) == 0)			start += tmpl.len;	}	strbuf_release(&tmpl);	/* Check if the rest is just whitespace and Signed-of-by's. */	for (i = start; i < sb->len; i++) {		nl = memchr(sb->buf + i, '/n', sb->len - i);		if (nl)			eol = nl - sb->buf;		else			eol = sb->len;		if (strlen(sign_off_header) <= eol - i &&		    !prefixcmp(sb->buf + i, sign_off_header)) {			i = eol;			continue;		}		while (i < eol)			if (!isspace(sb->buf[i++]))				return 0;	}	return 1;}
开发者ID:Jatinpurohit,项目名称:git,代码行数:43,


示例18: cmd_stripspace

int cmd_stripspace(int argc, const char **argv, const char *prefix){	struct strbuf buf = STRBUF_INIT;	int strip_comments = 0;	enum { INVAL = 0, STRIP_SPACE = 1, COMMENT_LINES = 2 } mode = STRIP_SPACE;	if (argc == 2) {		if (!strcmp(argv[1], "-s") ||		    !strcmp(argv[1], "--strip-comments")) {			strip_comments = 1;		} else if (!strcmp(argv[1], "-c") ||			   !strcmp(argv[1], "--comment-lines")) {			mode = COMMENT_LINES;		} else {			mode = INVAL;		}	} else if (argc > 1) {		mode = INVAL;	}	if (mode == INVAL)		usage(usage_msg);	if (strip_comments || mode == COMMENT_LINES)		git_config(git_default_config, NULL);	if (strbuf_read(&buf, 0, 1024) < 0)		die_errno("could not read the input");	if (mode == STRIP_SPACE)		stripspace(&buf, strip_comments);	else		comment_lines(&buf);	write_or_die(1, buf.buf, buf.len);	strbuf_release(&buf);	return 0;}
开发者ID:120011676,项目名称:git,代码行数:38,


示例19: prepare_to_commit

static void prepare_to_commit(struct commit_list *remoteheads){	struct strbuf msg = STRBUF_INIT;	strbuf_addbuf(&msg, &merge_msg);	strbuf_addch(&msg, '/n');	if (0 < option_edit)		strbuf_commented_addf(&msg, _(merge_editor_comment), comment_line_char);	write_merge_msg(&msg);	if (run_commit_hook(0 < option_edit, get_index_file(), "prepare-commit-msg",			    git_path("MERGE_MSG"), "merge", NULL))		abort_commit(remoteheads, NULL);	if (0 < option_edit) {		if (launch_editor(git_path("MERGE_MSG"), NULL, NULL))			abort_commit(remoteheads, NULL);	}	read_merge_msg(&msg);	stripspace(&msg, 0 < option_edit);	if (!msg.len)		abort_commit(remoteheads, _("Empty commit message."));	strbuf_release(&merge_msg);	strbuf_addbuf(&merge_msg, &msg);	strbuf_release(&msg);}
开发者ID:bmpvieira,项目名称:git,代码行数:23,


示例20: ctime_r

bool cSystemCardClient::ProcessECM(const cEcmInfo *ecm, unsigned char *data){  cCardClient *startCc=cc, *oldcc;  do {    if(cc) {      cTimeMs start;      int id=cc->msECM.Get(data,SCT_LEN(data),cw);      if(id==0 || (id>0 && cc->ProcessECM(ecm,data,cw))) {        int dur=start.Elapsed();        if(dur>2000) {          char bb[32];          time_t now=time(0);          ctime_r(&now,bb); stripspace(bb);          PRINTF(L_CC_CORE,"%s: lagged cw %d ms (%s)",bb,dur,cc->Name());          }        char buff[32];        snprintf(buff,sizeof(buff),"CC %s",cc->Name());        KeyOK(buff);        if(id>0) cc->msECM.Cache(id,true,cw);        return true;        }      if(id>0) {        PRINTF(L_CC_CORE,"client %s (%s:%d) ECM failed (%d ms)",cc->Name(),cc->hostname,cc->port,(int)start.Elapsed());        cc->msECM.Cache(id,false,cw);        }      if(id<0) {        PRINTF(L_CC_CORE,"client %s (%s:%d) ECM already cached as failed",cc->Name(),cc->hostname,cc->port);        }      }    if(!cc) PRINTF(L_CC_CORE,"cc-loop");    oldcc=cc;    cc=staticCcl.FindBySysId(ecm->caId,cc);    if(cc && cc!=startCc) PRINTF(L_CC_CORE,"now trying client %s (%s:%d)",cc->Name(),cc->hostname,cc->port);    } while(cc!=startCc && cc!=oldcc);  return false;}
开发者ID:Saner2oo2,项目名称:descrambler,代码行数:36,


示例21: astring_printf

astring *image_info_astring(running_machine &machine, astring *string){	device_image_interface *image = NULL;	astring_printf(string, "%s/n/n", machine.system().description);#if 0	if (mess_ram_size > 0)	{		char buf2[RAM_STRING_BUFLEN];		astring_catprintf(string, "RAM: %s/n/n", ram_string(buf2, mess_ram_size));	}#endif	for (bool gotone = machine.devicelist().first(image); gotone; gotone = image->next(image))	{		const char *name = image->filename();		if (name != NULL)		{			const char *base_filename;			const char *info;			char *base_filename_noextension;			base_filename = image->basename();			base_filename_noextension = strip_extension(base_filename);			/* display device type and filename */			astring_catprintf(string, "%s: %s/n", image->device().name(), base_filename);			/* display long filename, if present and doesn't correspond to name */			info = image->longname();			if (info && (!base_filename_noextension || mame_stricmp(info, base_filename_noextension)))				astring_catprintf(string, "%s/n", info);			/* display manufacturer, if available */			info = image->manufacturer();			if (info != NULL)			{				astring_catprintf(string, "%s", info);				info = stripspace(image->year());				if (info && *info)					astring_catprintf(string, ", %s", info);				astring_catprintf(string,"/n");			}			/* display supported information, if available */			switch(image->supported()) {				case SOFTWARE_SUPPORTED_NO : astring_catprintf(string, "Not supported/n"); break;				case SOFTWARE_SUPPORTED_PARTIAL : astring_catprintf(string, "Partialy supported/n"); break;				default : break;			}			if (base_filename_noextension != NULL)				free(base_filename_noextension);		}		else		{			astring_catprintf(string, "%s: ---/n", image->device().name());		}	}	return string;}
开发者ID:bdidier,项目名称:MAME-OS-X,代码行数:62,


示例22: ConfirmShutdown

//.........这里部分代码省略.........     && ((*cDBusShutdown::_shutdownHooksWrapper) != NULL) && (strlen(*cDBusShutdown::_shutdownHooksWrapper) > 0)) {       if (NextPlugin && (!Next || Next > NextPlugin)) {          Next = NextPlugin;          timer = NULL;          }       Delta = Next ? Next - Now : 0;       char *tmp;       if (Next && timer)          tmp = strdup(*cString::sprintf("%ld %ld %d /"%s/" %d", Next, Delta, timer->Channel()->Number(), *strescape(timer->File(), "///"$"), false));       else if (Next && Plugin)          tmp = strdup(*cString::sprintf("%ld %ld %d /"%s/" %d", Next, Delta, 0, Plugin->Name(), false));       else          tmp = strdup(*cString::sprintf("%ld %ld %d /"%s/" %d", Next, Delta, 0, "", false));       cString params = strescape(tmp, "///"");       cString shutdowncmd;       cString cmd = cString::sprintf("%s %s /"%s/"", *cDBusShutdown::_shutdownHooksWrapper, *cDBusShutdown::_shutdownHooksDir, *params);       if (access(*cDBusShutdown::_shutdownHooksWrapper, X_OK) != 0)          cmd = cString::sprintf("/bin/sh %s %s /"%s/"", *cDBusShutdown::_shutdownHooksWrapper, *cDBusShutdown::_shutdownHooksDir, *params);       isyslog("dbus2vdr: calling shutdown-hook-wrapper %s", *cmd);       tmp = NULL;       cExitPipe p;       int ret = -1;       if (p.Open(*cmd, "r")) {          int l = 0;          int c;          while ((c = fgetc(p)) != EOF) {                if (l % 20 == 0) {                   if (char *NewBuffer = (char *)realloc(tmp, l + 21))                      tmp = NewBuffer;                   else {                      esyslog("dbus2vdr: out of memory");                      break;                      }                   }                tmp[l++] = char(c);                }          if (tmp)             tmp[l] = 0;          ret = p.Close();          }       else          esyslog("dbus2vdr: can't open pipe for command '%s'", *cmd);       cString result(stripspace(tmp), true); // for automatic free       isyslog("dbus2vdr: result(%d) = %s", ret, *result);       if (ret != 0) {          if (*result) {             static const char *message = "ABORT_MESSAGE=/"";             if ((strlen(*result) > strlen(message)) && startswith(*result, message)) {                cString abort_message = tmp + strlen(message);                abort_message.Truncate(-1);                SendReply(Invocation, 992, *abort_message, ret, "");                return;                }             }          SendReply(Invocation, 999, "shutdown-hook returned a non-zero exit code", ret, "");          return;          }       if (*result) {          static const char *message = "TRY_AGAIN=/"";          if ((strlen(*result) > strlen(message)) && startswith(*result, message)) {             cString s_try_again = tmp + strlen(message);             s_try_again.Truncate(-1);             if ((strlen(*s_try_again) > 0) && isnumber(*s_try_again)) {                int try_again = strtol(s_try_again, NULL, 10);                if (try_again > 0) {                   SendReply(Invocation, 991, *s_try_again, 0, "");                   return;                   }                }             }          }       if (*result) {          static const char *message = "SHUTDOWNCMD=/"";          if ((strlen(*result) > strlen(message)) && startswith(*result, message)) {             shutdowncmd = tmp + strlen(message);             shutdowncmd.Truncate(-1);             }          }       if (*shutdowncmd && (strlen(*shutdowncmd) > 0)) {          SendReply(Invocation, 990, *shutdowncmd, 0, *params);          return;          }       }    SendReply(Invocation, 250, "vdr is ready for shutdown", 0, "");  };  static void ManualStart(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)  {    gboolean manual = FALSE;    time_t Delta = Setup.NextWakeupTime ? Setup.NextWakeupTime - cDBusShutdown::StartupTime : 0;    if (!Setup.NextWakeupTime || (abs(Delta) > 600)) // 600 comes from vdr's MANUALSTART constant in vdr.c       manual = TRUE;    g_dbus_method_invocation_return_value(Invocation, g_variant_new("(b)", manual));  };
开发者ID:flensrocker,项目名称:vdr-plugin-dbus2vdr,代码行数:101,


示例23: cmd_commit

//.........这里部分代码省略.........			pptr = &commit_list_insert(parent, pptr)->next;		}		fclose(fp);		strbuf_release(&m);		if (!stat(git_path("MERGE_MODE"), &statbuf)) {			if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0)				die_errno(_("could not read MERGE_MODE"));			if (!strcmp(sb.buf, "no-ff"))				allow_fast_forward = 0;		}		if (allow_fast_forward)			parents = reduce_heads(parents);	} else {		if (!reflog_msg)			reflog_msg = (whence == FROM_CHERRY_PICK)					? "commit (cherry-pick)"					: "commit";		pptr = &commit_list_insert(current_head, pptr)->next;	}	/* Finally, get the commit message */	strbuf_reset(&sb);	if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {		int saved_errno = errno;		rollback_index_files();		die(_("could not read commit message: %s"), strerror(saved_errno));	}	/* Truncate the message just before the diff, if any. */	if (verbose)		wt_status_truncate_message_at_cut_line(&sb);	if (cleanup_mode != CLEANUP_NONE)		stripspace(&sb, cleanup_mode == CLEANUP_ALL);	if (template_untouched(&sb) && !allow_empty_message) {		rollback_index_files();		fprintf(stderr, _("Aborting commit; you did not edit the message./n"));		exit(1);	}	if (message_is_empty(&sb) && !allow_empty_message) {		rollback_index_files();		fprintf(stderr, _("Aborting commit due to empty commit message./n"));		exit(1);	}	if (amend) {		const char *exclude_gpgsig[2] = { "gpgsig", NULL };		extra = read_commit_extra_headers(current_head, exclude_gpgsig);	} else {		struct commit_extra_header **tail = &extra;		append_merge_tag_headers(parents, &tail);	}	if (commit_tree_extended(&sb, active_cache_tree->sha1, parents, sha1,				 author_ident.buf, sign_commit, extra)) {		rollback_index_files();		die(_("failed to write commit object"));	}	strbuf_release(&author_ident);	free_commit_extra_headers(extra);	ref_lock = lock_any_ref_for_update("HEAD",					   !current_head					   ? NULL					   : current_head->object.sha1,					   0, NULL);
开发者ID:AresDice,项目名称:git,代码行数:67,


示例24: prepare_to_commit

//.........这里部分代码省略.........	 */	else if (whence == FROM_MERGE)		hook_arg1 = "merge";	else if (whence == FROM_CHERRY_PICK) {		hook_arg1 = "commit";		hook_arg2 = "CHERRY_PICK_HEAD";	}	if (squash_message) {		/*		 * If squash_commit was used for the commit subject,		 * then we're possibly hijacking other commit log options.		 * Reset the hook args to tell the real story.		 */		hook_arg1 = "message";		hook_arg2 = "";	}	s->fp = fopen(git_path(commit_editmsg), "w");	if (s->fp == NULL)		die_errno(_("could not open '%s'"), git_path(commit_editmsg));	/* Ignore status.displayCommentPrefix: we do need comments in COMMIT_EDITMSG. */	old_display_comment_prefix = s->display_comment_prefix;	s->display_comment_prefix = 1;	/*	 * Most hints are counter-productive when the commit has	 * already started.	 */	s->hints = 0;	if (clean_message_contents)		stripspace(&sb, 0);	if (signoff) {		/*		 * See if we have a Conflicts: block at the end. If yes, count		 * its size, so we can ignore it.		 */		int ignore_footer = 0;		int i, eol, previous = 0;		const char *nl;		for (i = 0; i < sb.len; i++) {			nl = memchr(sb.buf + i, '/n', sb.len - i);			if (nl)				eol = nl - sb.buf;			else				eol = sb.len;			if (starts_with(sb.buf + previous, "/nConflicts:/n")) {				ignore_footer = sb.len - previous;				break;			}			while (i < eol)				i++;			previous = eol;		}		append_signoff(&sb, ignore_footer, 0);	}	if (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len)		die_errno(_("could not write commit template"));	strbuf_release(&sb);
开发者ID:AresDice,项目名称:git,代码行数:67,


示例25: fopen

struct stormdata *read_stormdata_hurdat2(struct stormdata *storms,                                         struct storm_arg *args){	FILE *file;	int i;	char *line, *linecopy, buf[10240];	struct storm storm;	char *token[35];	char recID[4];    int points = 0;    int minute = 0;	int lasttype;	bool dateset = false;    bool syn_time = false;	struct pos pos;	file = fopen(args->input, "r");		if (!file) {		fprintf(stderr, "Couldn't open file '%s': %s/n",				args->input, strerror(errno));		exit(-1);	}		while ((line = fgets(buf, sizeof(buf), file))) {		/* Clean up the line */		line = stripspace(line);		linecopy = strdup(line);      // Need to make a copy here, as strtok() is a destructive operation				/* Begin parsing the line */		token[0] = strtok(linecopy, ",");		i = 1;		while ((token[i-1] != NULL) && (i<35)) {			token[i-1] = stripspace(token[i-1]);			token[i] = strtok(NULL, ",");			i++;		}                /* Preventing horrible explosions in case we can't read anything */        if (i == 1) {            fprintf(stderr, "Parsing error in file '%s': Could not parse the following input line:/n%s/n",                    args->input, line);            exit(-1);        }                /* Check if this is a header line; if it is, the first character of the line should be non-numeric */        if (isalpha(token[0][0]) && i==4) {            /***** Parse the header row *****/                                    /* Before we do anything, check whether we had already processed points             * for a storm; if we have, we should probably try to save it before we             * start processing the new storm             */            if (points > 0) {                save_storm(args, storms, &storm);            }            init_storm(&storm);                        /* Copy the cyclone identifier */            /* Split it into multiple parts */            strncpy(storm.header.basin, token[0], 2);            storm.header.basin[2] = '/0';            storm.header.id = substr_to_int(token[0], 2, 2);            storm.header.year = substr_to_int(token[0], 4, 4);                        /* Figure out the name */            strncpy(storm.header.name, token[1], strlen(token[1]));                        /* Mark that the initial date for the storm has not been set */            dateset = false;                        /* Reset row counter */            points = 0;                    } else if (isdigit(token[0][0]) && i>8) {            /***** Parse the data row *****/            /* For the first time stamp: Set initial map date             * NOTE: THIS IS NOT NECESSARILY THE DATE OF CYCLOGENESIS             */            if (!dateset) {                storm.header.year = substr_to_int(token[0], 0, 4);                storm.header.month = substr_to_int(token[0], 4, 2);                storm.header.day = substr_to_int(token[0], 6, 2);                dateset = true;            }                        /* Parse this date for our position point data */            /* year, month, day */            pos.year = substr_to_int(token[0], 0, 4);            pos.month = substr_to_int(token[0], 4, 2);            pos.day = substr_to_int(token[0], 6, 2);                        /* hour */            pos.hour = substr_to_int(token[1], 0, 2);            minute = substr_to_int(token[1], 2, 2);                        /* Check whether this is a synoptic time */            if ((pos.hour % 6 == 0) && minute == 0) {                /* This is a synoptic time *///.........这里部分代码省略.........
开发者ID:Luigi728,项目名称:wptc-track,代码行数:101,


示例26: isyslog

bool cDll::Load(bool Log){  if (Log)     isyslog("loading plugin: %s", fileName);  if (handle) {     esyslog("attempt to load plugin '%s' twice!", fileName);     return false;     }  handle = dlopen(fileName, RTLD_NOW);  const char *error = dlerror();  if (!error) {     void *(*creator)(void);     creator = (void *(*)(void))dlsym(handle, "VDRPluginCreator");     if (!(error = dlerror()))        plugin = (cPlugin *)creator();     }  if (!error) {     if (plugin && args) {        int argc = 0;        char *argv[MAXPLUGINARGS];        char *p = skipspace(stripspace(args));        char *q = NULL;        bool done = false;        while (!done) {              if (!q)                 q = p;              switch (*p) {                case '//': strcpy(p, p + 1);                           if (*p)                              p++;                           else {                              esyslog("ERROR: missing character after //");                              fprintf(stderr, "vdr: missing character after ///n");                              return false;                              }                           break;                case '"':                case '/'': if ((p = SkipQuote(p)) == NULL)                              return false;                           break;                default: if (!*p || isspace(*p)) {                            done = !*p;                            *p = 0;                            if (q) {                               if (argc < MAXPLUGINARGS - 1)                                  argv[argc++] = q;                               else {                                  esyslog("ERROR: plugin argument list too long");                                  fprintf(stderr, "vdr: plugin argument list too long/n");                                  return false;                                  }                               q = NULL;                               }                            }                         if (!done)                            p = *p ? p + 1 : skipspace(p + 1);                }              }        argv[argc] = NULL;        if (argc)           plugin->SetName(argv[0]);        optind = 0; // to reset the getopt() data        return !Log || !argc || plugin->ProcessArgs(argc, argv);        }     }  else {     esyslog("ERROR: %s", error);     esyslog("WARNING: failed to load plugin %s. Continuing anyway.", fileName);     fprintf(stderr, "vdr: %s/n", error);     }  return !error && plugin;}
开发者ID:signal2noise,项目名称:vdr-mirror,代码行数:72,


示例27: ui_sprintf_image_info

int ui_sprintf_image_info(char *buf){    char *dst = buf;    const struct IODevice *dev;    int id;    dst += sprintf(dst, "%s/n/n", Machine->gamedrv->description);    if (options.ram)    {        char buf2[RAM_STRING_BUFLEN];        dst += sprintf(dst, "RAM: %s/n/n", ram_string(buf2, options.ram));    }    for (dev = Machine->devices; dev->type < IO_COUNT; dev++)    {        for (id = 0; id < dev->count; id++)        {            mess_image *img = image_from_device_and_index(dev, id);            const char *name = image_filename(img);            if( name )            {                const char *base_filename;                const char *info;                char *base_filename_noextension;                base_filename = image_basename(img);                base_filename_noextension = strip_extension((char *) base_filename);                /* display device type and filename */                dst += sprintf(dst,"%s: %s/n", image_typename_id(img), base_filename);                /* display long filename, if present and doesn't correspond to name */                info = image_longname(img);                if (info && (!base_filename_noextension || mame_stricmp(info, base_filename_noextension)))                    dst += sprintf(dst,"%s/n", info);                /* display manufacturer, if available */                info = image_manufacturer(img);                if (info)                {                    dst += sprintf(dst,"%s", info);                    info = stripspace(image_year(img));                    if (info && *info)                        dst += sprintf(dst,", %s", info);                    dst += sprintf(dst,"/n");                }                /* display playable information, if available */                info = image_playable(img);                if (info)                    dst += sprintf(dst,"%s/n", info);                if (base_filename_noextension)                    free(base_filename_noextension);            }            else            {                dst += sprintf(dst,"%s: ---/n", image_typename_id(img));            }        }    }    return dst - buf;}
开发者ID:BirchJD,项目名称:xmame-0.103-RPi,代码行数:64,


示例28: create_note

static void create_note(const unsigned char *object, struct msg_arg *msg,			int append_only, const unsigned char *prev,			unsigned char *result){	char *path = NULL;	if (msg->use_editor || !msg->given) {		int fd;		/* write the template message before editing: */		path = git_pathdup("NOTES_EDITMSG");		fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);		if (fd < 0)			die_errno("could not create file '%s'", path);		if (msg->given)			write_or_die(fd, msg->buf.buf, msg->buf.len);		else if (prev && !append_only)			write_note_data(fd, prev);		write_or_die(fd, note_template, strlen(note_template));		write_commented_object(fd, object);		close(fd);		strbuf_reset(&(msg->buf));		if (launch_editor(path, &(msg->buf), NULL)) {			die("Please supply the note contents using either -m" /			    " or -F option");		}		stripspace(&(msg->buf), 1);	}	if (prev && append_only) {		/* Append buf to previous note contents */		unsigned long size;		enum object_type type;		char *prev_buf = read_sha1_file(prev, &type, &size);		strbuf_grow(&(msg->buf), size + 1);		if (msg->buf.len && prev_buf && size)			strbuf_insert(&(msg->buf), 0, "/n", 1);		if (prev_buf && size)			strbuf_insert(&(msg->buf), 0, prev_buf, size);		free(prev_buf);	}	if (!msg->buf.len) {		fprintf(stderr, "Removing note for object %s/n",			sha1_to_hex(object));		hashclr(result);	} else {		if (write_sha1_file(msg->buf.buf, msg->buf.len, blob_type, result)) {			error("unable to write note object");			if (path)				error("The note contents has been left in %s",				      path);			exit(128);		}	}	if (path) {		unlink_or_warn(path);		free(path);	}}
开发者ID:flichtenheld,项目名称:git,代码行数:66,


示例29: isyslog

bool cTheme::Load(const char *FileName, bool OnlyDescriptions){  if (!FileNameOk(FileName, true))     return false;  bool result = false;  if (!OnlyDescriptions)     isyslog("loading %s", FileName);  FILE *f = fopen(FileName, "r");  if (f) {     int line = 0;     result = true;     char *s;     const char *error = NULL;     cReadLine ReadLine;     while ((s = ReadLine.Read(f)) != NULL) {           line++;           char *p = strchr(s, '#');           if (p)              *p = 0;           s = stripspace(skipspace(s));           if (!isempty(s)) {              char *n = s;              char *v = strchr(s, '=');              if (v) {                 *v++ = 0;                 n = stripspace(skipspace(n));                 v = stripspace(skipspace(v));                 if (strstr(n, "Description") == n) {                    int lang = 0;                    char *l = strchr(n, '.');                    if (l)                       lang = I18nLanguageIndex(++l);                    if (lang >= 0) {                       free(descriptions[lang]);                       descriptions[lang] = strdup(v);                       }                    else                       error = "invalid language code";                    }                 else if (!OnlyDescriptions) {                    for (int i = 0; i < MaxThemeColors; i++) {                        if (colorNames[i]) {                           if (strcmp(n, colorNames[i]) == 0) {                              char *p = NULL;                              errno = 0;                              tColor c = strtoul(v, &p, 16);                              if (!errno && !*p)                                 colorValues[i] = c;                              else                                 error = "invalid color value";                              break;                              }                           }                        else {                           error = "unknown color name";                           break;                           }                        }                    }                 }              else                 error = "missing value";              }           if (error) {              result = false;              break;              }           }     if (!result)        esyslog("ERROR: error in %s, line %d%s%s", FileName, line, error ? ": " : "", error ? error : "");     fclose(f);     }  else     LOG_ERROR_STR(FileName);  return result;}
开发者ID:BackupTheBerlios,项目名称:macvdr-svn,代码行数:76,



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


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