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

C++ chomp函数代码示例

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

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



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

示例1: create_send_msg

char* create_send_msg(char *message, const char *user_name)
{
    chomp(message);

    int to_send_len = 4 + strlen(user_name) + 
                      2 + strlen(message) +
                      1;
    char hex_len[5];
    int_to_hex_4(to_send_len, hex_len);

    char *to_send = malloc(to_send_len);
    snprintf(to_send, to_send_len, "%s%s: %s", hex_len, user_name, message);

    return to_send;
}
开发者ID:emdeha,项目名称:peer-to-peer,代码行数:15,代码来源:str_utils.c


示例2: readOneSequence

FASTQ readOneSequence(FILE *fin){
  FASTQ sequence;
  char *dummy;

  do{
    sequence.name=readOneLine(fin);
  }while(sequence.name[0]!='@' && sequence.name[0]!='\0');
  sequence.dna=readOneLine(fin);
  dummy=readOneLine(fin);
  /*if(strcmp(dummy, "+\n")!=0 && !feof(stdin)){*/
  if(dummy[0]!='+' && !feof(stdin)){
      fprintf(stderr, "This file does not seem to be the fastq format. EXIT\n");
      exit(3);
  }
  free(dummy);
  sequence.quality=readOneLine(fin);
  chomp(sequence.name);
  chomp(sequence.dna);
  chomp(sequence.quality);
  sequence.length=strlen(sequence.dna);
  sequence.dnaShow=NULL;
  sequence.qualityShow=NULL;
  return sequence;
}
开发者ID:uhmin,项目名称:fastq-tools,代码行数:24,代码来源:fastqQtrim.c


示例3: fopen

StructuredDataset *StructuredSVM::LoadDataset(const char *fname, bool getLock) {
  if(params.debugLevel > 0) fprintf(stderr, "Reading dataset %s...", fname);
  
  if(getLock) Lock();

  FILE *fin = fopen(fname, "r");
  if(!fin) {
    fprintf(stderr, "Couldn't open dataset file %s\n", fname);
    Unlock();
    return NULL;
  }

  StructuredDataset *d = new StructuredDataset();
  char *line = new char[1000000];
  
  Json::Reader reader;
  while(fgets(line, 999999, fin) && strlen(line) > 1) {
    chomp(line);
    Json::Value r;
    if(!reader.parse(line, r)) {
      fprintf(stderr, "Error parsing dataset example %s\n", line);
      delete d;
      fclose(fin);
      return NULL;
    }
    StructuredExample *ex = new StructuredExample;
    ex->x = NewStructuredData();
    ex->y = NewStructuredLabel(ex->x);
    if(r.isMember("y_latent")) ex->y_latent = NewStructuredLabel(ex->x);
    if(!r.isMember("x") || !r.isMember("y") || 
       !ex->x->load(r["x"], this) || !ex->y->load(r["y"], this) ||
       (r.isMember("y_latent") && !ex->y_latent->load(r["y_latent"], this))) { 
      fprintf(stderr, "Error parsing values for dataset example %s\n", line);
      delete ex;
      delete d;
      fclose(fin);
      return NULL;
    }
    d->AddExample(ex);
  }
  fclose(fin);
  if(getLock) Unlock();
  delete [] line;

  if(params.debugLevel > 0) fprintf(stderr, "done\n");

  return d;
}
开发者ID:Yinxiaoli,项目名称:code,代码行数:48,代码来源:structured_svm.cpp


示例4: set_quality

static int set_quality (char *value)
{
#if defined(DEBUG)
	syslog(LOG_NOTICE, "check_password: Setting quality to [%s]", value);
#endif
#if defined(LDEBUG)
  char* msg = chomp(value);
  printf("check_password: Setting quality to [%s]\n", msg);
  ber_memfree(msg);
#endif

	/* No need to require more quality than we can check for. */
	if (!isdigit(*value) || (int) (value[0] - '0') > 4) return DEFAULT_QUALITY;
	return (int) (value[0] - '0');

}
开发者ID:HouzuoGuo,项目名称:ppolicy-check-password,代码行数:16,代码来源:check_password.c


示例5: time

char *time_from_now(int secs)
{
	int seconds = secs;
	char buf[128] = { 0 };
	struct timeval tv;
	
	seconds += time(NULL);

	tv.tv_sec = seconds;
	tv.tv_usec = 0;

	strcpy(buf, ctime((time_t *) &tv));
	chomp(buf); // LF Bye!
	
	return strdup(buf);
}
开发者ID:haxworx,项目名称:WebFoolKit,代码行数:16,代码来源:cookie.c


示例6: ts

void Log::fatal(std::string domain, std::string msg)
{
	std::string str = ts() + "Fatal [" + domain + "] - " + chomp(msg);
	if (inPythonScript) {
		PyErr_SetString(PyExc_RuntimeError, str.c_str());
	}
	else {
		std::cerr << str << std::endl;
		#ifdef _WIN32
			wMessageBox("Tsunagari - Fatal", str);
		#endif
		#ifdef __APPLE__
			macMessageBox("Tsunagari - Fatal", str.c_str());
		#endif
	}
}
开发者ID:dreamsxin,项目名称:Tsunagari,代码行数:16,代码来源:log.cpp


示例7: valid_word

static validator valid_word (char *word)
{
	struct {
		char * parameter;
		validator dealer;
	} list[] = { { "min_points", set_quality },
		{ "use_cracklib", set_cracklib },
		{ "min_upper", set_digit },
		{ "min_lower", set_digit },
		{ "min_digit", set_digit },
		{ "min_punct", set_digit },
    { "max_consecutive_per_class", set_digit},
		{ NULL, NULL } };
	int index = 0;

#if defined(DEBUG)
	syslog(LOG_NOTICE, "check_password: Validating parameter [%s]", word);
#endif
#if defined(LDEBUG)
  char* msg = chomp(word);
  printf("check_password: Validating parameter [%s]\n", msg);
  ber_memfree(msg);
#endif

	while (list[index].parameter != NULL) {
		if (strlen(word) == strlen(list[index].parameter) &&
				strcmp(list[index].parameter, word) == 0) {
#if defined(DEBUG)
			syslog(LOG_NOTICE, "check_password: Parameter accepted.");
#endif
#if defined(LDEBUG)
			printf("check_password: Parameter accepted.\n");
#endif
			return list[index].dealer;
		}
		index++;
	}

#if defined(DEBUG)
	syslog(LOG_NOTICE, "check_password: Parameter rejected.");
#endif
#if defined(LDEBUG)
	printf("check_password: Parameter rejected.\n");
#endif

	return NULL;
}
开发者ID:HouzuoGuo,项目名称:ppolicy-check-password,代码行数:47,代码来源:check_password.c


示例8: reflist_new

static RefList *read_stream_reflections(FILE *fh)
{
	char *rval = NULL;
	int first = 1;
	RefList *out;

	out = reflist_new();

	do {

		char line[1024];
		signed int h, k, l;
		float intensity, sigma, fs, ss, pk, bg;
		int r;
		Reflection *refl;

		rval = fgets(line, 1023, fh);
		if ( rval == NULL ) continue;
		chomp(line);

		if ( strcmp(line, REFLECTION_END_MARKER) == 0 ) return out;

		r = sscanf(line, "%i %i %i %f %f %f %f %f %f",
		           &h, &k, &l, &intensity, &sigma, &pk, &bg, &fs, &ss);
		if ( (r != 9) && (!first) ) {
			reflist_free(out);
			return NULL;
		}

		first = 0;
		if ( r == 9 ) {

			refl = add_refl(out, h, k, l);
			set_intensity(refl, intensity);
			set_detector_pos(refl, 0.0, fs, ss);
			set_esd_intensity(refl, sigma);
			set_redundancy(refl, 1);
			set_peak(refl, pk);
			set_mean_bg(refl, bg);

		}

	} while ( rval != NULL );

	/* Got read error of some kind before finding PEAK_LIST_END_MARKER */
	return NULL;
}
开发者ID:keitaroyam,项目名称:CrystFEL,代码行数:47,代码来源:stream.c


示例9: io_read_choices

struct choices *
io_read_choices(int read_descriptions)
{
	char *line, *description, *field_separator;
	size_t line_size;
	ssize_t length;
	struct choice *choice;
	struct choices *choices;

	field_separator = getenv("IFS");
	if (field_separator == NULL) {
		field_separator = " ";
	}

	choices = malloc(sizeof(struct choices));
	if (choices == NULL) {
		err(1, "malloc");
	}

	SLIST_INIT(choices);

	for (;;) {
		line = NULL;
		description = "";
		line_size = 0;

		length = getline(&line, &line_size, stdin);
		if (length == -1) {
			break;
		}

		chomp(line, length);

		if (read_descriptions) {
			strtok_r(line, field_separator, &description);
		}

		choice = choice_new(line, description, 1);
		SLIST_INSERT_HEAD(choices, choice, choices);

		free(line);
	}

	free(line);

	return choices;
}
开发者ID:mattix,项目名称:pick,代码行数:47,代码来源:io.c


示例10: updateTech

static void updateTech(void)
{
	char buf[16000];
	char *p = buf;
	const char *ext;
	int type;
	int i;
	ext = ASAPInfo_GetOriginalModuleExt(edited_info, saved_module, saved_module_len);
	if (ext != NULL)
		p += sprintf(p, "Composed in %s\r\n", ASAPInfo_GetExtDescription(ext));
	i = ASAPInfo_GetSongs(edited_info);
	if (i > 1) {
		p += sprintf(p, "SONGS %d\r\n", i);
		i = ASAPInfo_GetDefaultSong(edited_info);
		if (i > 0)
			p += sprintf(p, "DEFSONG %d (song %d)\r\n", i, i + 1);
	}
	p += sprintf(p, ASAPInfo_GetChannels(edited_info) > 1 ? "STEREO\r\n" : "MONO\r\n");
	p += sprintf(p, ASAPInfo_IsNtsc(edited_info) ? "NTSC\r\n" : "PAL\r\n");
	type = ASAPInfo_GetTypeLetter(edited_info);
	if (type != 0)
		p += sprintf(p, "TYPE %c\r\n", type);
	p += sprintf(p, "FASTPLAY %d (%d Hz)\r\n", ASAPInfo_GetPlayerRateScanlines(edited_info), ASAPInfo_GetPlayerRateHz(edited_info));
	if (type == 'C')
		p += sprintf(p, "MUSIC %04X\r\n", ASAPInfo_GetMusicAddress(edited_info));
	if (type != 0) {
		p = appendAddress(p, "INIT %04X\r\n", ASAPInfo_GetInitAddress(edited_info));
		p = appendAddress(p, "PLAYER %04X\r\n", ASAPInfo_GetPlayerAddress(edited_info));
		p = appendAddress(p, "COVOX %04X\r\n", ASAPInfo_GetCovoxAddress(edited_info));
	}
	i = ASAPInfo_GetSapHeaderLength(edited_info);
	if (i >= 0) {
		while (p < buf + sizeof(buf) - 17 && i + 4 < saved_module_len) {
			int start = saved_module[i] + (saved_module[i + 1] << 8);
			int end;
			if (start == 0xffff) {
				i += 2;
				start = saved_module[i] + (saved_module[i + 1] << 8);
			}
			end = saved_module[i + 2] + (saved_module[i + 3] << 8);
			p += sprintf(p, "LOAD %04X-%04X\r\n", start, end);
			i += 5 + end - start;
		}
	}
	chomp(buf);
	SendDlgItemMessage(infoDialog, IDC_TECHINFO, WM_SETTEXT, 0, (LPARAM) buf);
}
开发者ID:vitamin-caig,项目名称:zxtune,代码行数:47,代码来源:info_dlg.c


示例11: load_workitems

/*
 * Load ip's/hosts in a linked list.
 */
void load_workitems(char *inputfile, workitem **wi_start, int reverse)
{
    FILE *f;
    workitem *curr, *head;
    char host[256];
    char line[256];
    int first = 1;

    head = NULL;

    f = fopen(params->inputfile, "r");
    if (f != NULL)
    {
        while (fgets(line, 255, f) != NULL)
        {
            memset(host, 0, sizeof(host));
            chomp(line);
            if (reverse)
            {
                strcpy(host, line);
            }
            else
            {
                strcat(host, line);
                strcat(host, ".");
                strcat(host, params->domain);
            }

            curr = (workitem *)malloc(sizeof(workitem));  /* free memory! */
            memset(curr, 0, sizeof(workitem));
            curr->wi = (char *)malloc(strlen(host) + 1);
            memset(curr->wi, 0, strlen(host) + 1);
            strcpy(curr->wi, host);

            curr->next = head;
            head = curr;
        }
        fclose(f);

        *wi_start = head;
    }
    else
    {
        printf("Error: File %s could not be opened\n", inputfile);
        exit -1;
    }
}
开发者ID:andregasser,项目名称:dnsninja,代码行数:50,代码来源:dnsninja.c


示例12: fi_get_one_url

int fi_get_one_url(char *buf)
{
	char tmp[1024];

	pthread_mutex_lock(&m_file_mutex);

	if (fgets(tmp, sizeof(tmp), m_fp)) {
		chomp(tmp);
		strcpy(buf, tmp);
		pthread_mutex_unlock(&m_file_mutex);
		return 0;
	}

	pthread_mutex_unlock(&m_file_mutex);

	return -1;
}
开发者ID:OZv,项目名称:fastwiki,代码行数:17,代码来源:fastwiki-image.cpp


示例13: while

char *treat_protein_name(char *protein_name_local, char *global_tmp_local){
  int i=0;
  char *cp1;

  i=0;
  while(isspace(global_tmp_local[i++])) {}
  i-=2; if(i<=0) i=0;
  cp1=global_tmp_local+i;
  if(strlen(cp1)+strlen(protein_name_local)>protein_name_length){
    protein_name_length+=MAXLETTER;
    protein_name_local=(char *)realloc(protein_name_local, (size_t)protein_name_length);
  }
  strcat(protein_name_local, cp1);
  strtok(protein_name_local,"[");
  chomp(protein_name_local);
  return protein_name_local;
}
开发者ID:uhmin,项目名称:sequence-analysis-tools-1,代码行数:17,代码来源:filterN_140630.c


示例14: process_args

static void process_args( WCHAR *cmdline, int *pargc, WCHAR ***pargv )
{
	WCHAR **argv, *p = msi_strdup(cmdline);
	int i, n;

	n = chomp( p );
	argv = HeapAlloc(GetProcessHeap(), 0, sizeof (WCHAR*)*(n+1));
	for( i=0; i<n; i++ )
	{
		argv[i] = p;
		p += lstrlenW(p) + 1;
	}
	argv[i] = NULL;

	*pargc = n;
	*pargv = argv;
}
开发者ID:mikekap,项目名称:wine,代码行数:17,代码来源:msiexec.c


示例15: parse_conf

static int parse_conf(char *file)
{
	FILE *fp;
	char line[LINE_SIZE] = "";
	char *x;

	fp = fopen(file, "r");
	if (!fp)
		return 1;

	/*
	 * If not standard finit.conf, then we want to show just the base name
	 * Loading configuration ............. vs
	 * Loading services configuration ....
	 */
	if (!string_match (file, FINIT_CONF)) {
		/* Remove leading path */
		x = strrchr(file, '/');
		if (!x) x = file;
		else	x++;

		/* Remove ending .conf */
		strlcpy(line, x, sizeof(line));
		x = strstr(line, ".conf");
		if (x) *x = 0;

		/* Add empty space. */
		strcat(line, " ");
	}

	if (!silent)
		print(0, "Loading %sconfiguration", line);
	while (!feof(fp)) {
		if (!fgets(line, sizeof(line), fp))
			continue;
		chomp(line);

		_d("conf: %s", line);
		parse_static(line);
		parse_dynamic(line, 0);
	}

	fclose(fp);

	return 0;
}
开发者ID:RFCreations,项目名称:finit,代码行数:46,代码来源:conf.c


示例16: get_proxy_authenticate

/*
 * Extract the Proxy-Authenticate header from the stream.
 * Consumes all headers.
 */
static int
get_proxy_authenticate (socket_descriptor_t sd,
		        int timeout,
			char **data,
			struct gc_arena *gc,
		        volatile int *signal_received)
{
  char buf[256];
  int ret = HTTP_AUTH_NONE;
  while (true)
    {
      if (!recv_line (sd, buf, sizeof (buf), timeout, true, NULL, signal_received))
	{
	  *data = NULL;
	  return HTTP_AUTH_NONE;
	}
      chomp (buf);
      if (!strlen(buf))
	return ret;
      if (ret == HTTP_AUTH_NONE && !strncmp(buf, "Proxy-Authenticate: ", 20))
	{
	  if (!strncmp(buf+20, "Basic ", 6))
	    {
	      msg (D_PROXY, "PROXY AUTH BASIC: '%s'", buf);
	      *data = string_alloc(buf+26, gc);
	      ret = HTTP_AUTH_BASIC;
	    }
#if PROXY_DIGEST_AUTH
	  else if (!strncmp(buf+20, "Digest ", 7))
	    {
	      msg (D_PROXY, "PROXY AUTH DIGEST: '%s'", buf);
	      *data = string_alloc(buf+27, gc);
	      ret = HTTP_AUTH_DIGEST;
	    }
#endif
#if NTLM
	  else if (!strncmp(buf+20, "NTLM", 4))
	    {
	      msg (D_PROXY, "PROXY AUTH HTLM: '%s'", buf);
	      *data = NULL;
	      ret = HTTP_AUTH_NTLM;
	    }
#endif
	}
    }
}
开发者ID:ThomasHabets,项目名称:openvpn,代码行数:50,代码来源:proxy.c


示例17: status_printf

void
status_printf(struct status_output *so, const char *format, ...)
{
    if (so && (so->flags & STATUS_OUTPUT_WRITE))
    {
        char buf[STATUS_PRINTF_MAXLEN+2]; /* leave extra bytes for CR, LF */
        va_list arglist;
        int stat;

        va_start(arglist, format);
        stat = vsnprintf(buf, STATUS_PRINTF_MAXLEN, format, arglist);
        va_end(arglist);
        buf[STATUS_PRINTF_MAXLEN - 1] = 0;

        if (stat < 0 || stat >= STATUS_PRINTF_MAXLEN)
        {
            so->errors = true;
        }

        if (so->msglevel >= 0 && !so->errors)
        {
            msg(so->msglevel, "%s", buf);
        }

        if (so->fd >= 0 && !so->errors)
        {
            int len;
            strcat(buf, "\n");
            len = strlen(buf);
            if (len > 0)
            {
                if (write(so->fd, buf, len) != len)
                {
                    so->errors = true;
                }
            }
        }

        if (so->vout && !so->errors)
        {
            chomp(buf);
            (*so->vout->func)(so->vout->arg, so->vout->flags_default, buf);
        }
    }
}
开发者ID:benjdag,项目名称:openvpn,代码行数:45,代码来源:status.c


示例18: updateStil

static void updateStil(void)
{
	char buf[16000];
	char *p = buf;
	int i;
	p = appendStil(p, "", ASTIL_GetTitle(astil));
	p = appendStil(p, "by ", ASTIL_GetAuthor(astil));
	p = appendStil(p, "Directory comment: ", ASTIL_GetDirectoryComment(astil));
	p = appendStil(p, "File comment: ", ASTIL_GetFileComment(astil));
	p = appendStil(p, "Song comment: ", ASTIL_GetSongComment(astil));
	for (i = 0; ; i++) {
		const ASTILCover *cover = ASTIL_GetCover(astil, i);
		int startSeconds;
		const char *s;
		if (cover == NULL)
			break;
		startSeconds = ASTILCover_GetStartSeconds(cover);
		if (startSeconds >= 0) {
			int endSeconds = ASTILCover_GetEndSeconds(cover);
			if (endSeconds >= 0)
				p += sprintf(p, "At %d:%02d-%d:%02d c", startSeconds / 60, startSeconds % 60, endSeconds / 60, endSeconds % 60);
			else
				p += sprintf(p, "At %d:%02d c", startSeconds / 60, startSeconds % 60);
		}
		else
			*p++ = 'C';
		s = ASTILCover_GetTitleAndSource(cover);
		p = appendStil(p, "overs: ", s[0] != '\0' ? s : "<?>");
		p = appendStil(p, "by ", ASTILCover_GetArtist(cover));
		p = appendStil(p, "Comment: ", ASTILCover_GetComment(cover));
	}
	*p = '\0';
	chomp(buf);
#if 1
	/* not compatible with Windows 9x */
	if (ASTIL_IsUTF8(astil)) {
		WCHAR wBuf[16000];
		if (MultiByteToWideChar(CP_UTF8, 0, buf, -1, wBuf, 16000) > 0) {
			SendDlgItemMessageW(infoDialog, IDC_STILINFO, WM_SETTEXT, 0, (LPARAM) wBuf);
			return;
		}
	}
#endif
	SendDlgItemMessage(infoDialog, IDC_STILINFO, WM_SETTEXT, 0, (LPARAM) buf);
}
开发者ID:vitamin-caig,项目名称:zxtune,代码行数:45,代码来源:info_dlg.c


示例19: handle_create_tap

int handle_create_tap()
{
	char name[CINDER_MAX_NAMELEN], id[12];
	char *retstr;
	unsigned int len;
	int ret, srcReserve, destReserve;

	printf("Please enter the name for the tap: ");
	retstr = fgets(name, sizeof(name), stdin);
	if (!retstr) {
		printf("Error reading name.\n");
		return -EINVAL;
	}
	name[CINDER_MAX_NAMELEN - 1] = 0;
	chomp(name);
	len = strlen(name) + 1;

	memset(id, 0, sizeof(id));
	printf("Please enter the source reserve id.\n");
	retstr = fgets(id, sizeof(id), stdin);
	if (!retstr) {
		printf("Error reading id.\n");
		return -EINVAL;
	}
	srcReserve = atoi(id);
	
	memset(id, 0, sizeof(id));
	printf("Please enter the destination reserve id.\n");
	retstr = fgets(id, sizeof(id), stdin);
	if (!retstr) {
		printf("Error reading id.\n");
		return -EINVAL;
	}
	destReserve = atoi(id);

	ret = create_tap(name, len, srcReserve, destReserve);

	if (ret < 0) {
		printf("Error creating tap: %d\n", ret);
	}
	else
		printf("Created tap with id %d\n", ret);

	return ret;
}
开发者ID:arjunroy,项目名称:cinder_userspace,代码行数:45,代码来源:util.c


示例20: parserOrder

void
parserOrder (struct irc * bot, char * rcv)
{
  int i, len;
  char * cmd, *next;
  char * cmds[7] = { "!say-to", "!say", "!cmd", "!hours", "!enter", "!exit", "!udpflood"}  ;
  
  if (*rcv == '!') { //is a command ?
    next = gettoken (&cmd, ' ', rcv);
    len = (int)(sizeof (cmds)/sizeof (char *));
    chomp (cmd);
    for (i = 0;i < len; i++) {
      if (strcmp (cmd, cmds[i]) == 0) {
        execOrder (bot, i, next);
      }
    }
  }
}
开发者ID:Alien-nick,项目名称:C,代码行数:18,代码来源:rexbot-0.4.1.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ chompAndTrim函数代码示例发布时间:2022-05-30
下一篇:
C++ choice函数代码示例发布时间: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