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

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

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

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

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

示例1: run_interactive_loop

void run_interactive_loop(geonames_by_token_func geonames_func,                          int max_results,                          process_geoname_id_func process_func) {    char q[MAX_QUERY_LENGTH];    debug("Ready to serve/n");    for (;;) {        int i;        vector_t tokens;        geoname_indices_t geonames;        if (!fgets(q, sizeof q, stdin))            break;        strlower(strtrim(q));        if (!*q) {            puts("");            continue;        }        tokens = strsplit(q, " /t");        geonames = process_query(tokens, max_results, geonames_func);        for (i = 0; i != vector_size(geonames); ++i)            process_func(geoname_idx(geonames, i));        puts("");        vector_free(tokens);        vector_free(geonames);    }}
开发者ID:hmich,项目名称:geonames,代码行数:34,


示例2: fopen

/* * Read from file <szGlobalExcludeFunctionFileName> * the names of global functions, which don't need to replace. * In this file are function's names on each string. * After '#' write comments */int LuaObfuscator::readAddonGlobalExcludeFunctions(const char *szGlobalExcludeFunctionFileName, StringList &FunctionsExclude){	const int N = 1024;	int res = 0;	char buf[N];	if (!szGlobalExcludeFunctionFileName || !szGlobalExcludeFunctionFileName[0])		return -1;	FILE *file = fopen(szGlobalExcludeFunctionFileName, "rt");	if (!file)		return -1;	FunctionsExclude.clear();	std::string str;	while (feof(file) && fgets(buf, N, file)) {		char *pName = strtrim(buf);		if (char *p = strchr(pName, '/n'))			*p = 0;		if (pName[0] && pName[0] != '#') {			str.assign(pName);			FunctionsExclude.push_back(str);		}	}	fclose(file);	return res;}
开发者ID:gracerpro,项目名称:luaob,代码行数:36,


示例3: deleteEntry

int deleteEntry(char *cmd, int argc, char **argv, agenda ag) {    char *valor;    if (argc != 1 || (strcmp(argv[0], "nome") != 0 &&                strcmp(argv[0], "sobrenome") != 0 &&                strcmp(argv[0], "endereco") != 0 &&                strcmp(argv[0], "telefone") != 0 &&                strcmp(argv[0], "email") != 0)) {        printf("A forma correta do comando e':/n apagar [nome|sobrenome|endereco|telefone|email]/n");        return 1;    }    valor = (char *) malloc(STRING_SIZE * sizeof(char));    if (valor == NULL) {        printf("Impossivel alocar memoria para armazenar valor/n");        exit(EXIT_FAILURE);    }    printf("%s: ", argv[0]);    fgets(valor, STRING_SIZE, stdin);    strtrim(valor);    removeLista(ag, argv[0], valor);    free(valor);    return 0;}
开发者ID:arturts,项目名称:agenda_ime_usp,代码行数:26,


示例4: dbfield_isnull

static intdbfield_isnull( Dbptr db ){	char	*fnull;	long	fsize;	char	*stringval;	int	isnull = 0;	dbquery( db, dbFIELD_SIZE, &fsize );	dbquery( db, dbNULL, &fnull );	allot( char *, stringval, fsize + 2 );	dbget( db, stringval );	strtrim( stringval );	if( ! strcmp( stringval, fnull ) ) {		isnull = 1;	} else {		isnull = 0;	}	return isnull;}
开发者ID:battistuz,项目名称:antelope_contrib,代码行数:28,


示例5: process_boolean

static int process_boolean(char *buffer, char *name, int namesize, int *val){    char name1[BUFSIZ];    char *ptr = NULL;    char *tok = strtok_r(buffer, "=", &ptr);    if (tok) {        strncpy(name1, tok, BUFSIZ - 1);        strtrim(name, name1, namesize - 1);        if (name[0] == '#')            return 0;        tok = strtok_r(NULL, "/0", &ptr);        if (tok) {            while (isspace(*tok))                tok++;            *val = -1;            if (isdigit(tok[0]))                *val = atoi(tok);            else if (!strncasecmp(tok, "true", sizeof("true") - 1))                *val = 1;            else if (!strncasecmp                     (tok, "false", sizeof("false") - 1))                *val = 0;            if (*val != 0 && *val != 1) {                ERR(NULL, "illegal value for boolean "                    "%s=%s", name, tok);                return -1;            }        }    }    return 1;}
开发者ID:perfinion,项目名称:selinux,代码行数:32,


示例6: save_draw

intsave_draw(ui_t *ui){    char field_value[80];    // Get panel information    save_info_t *info = save_info(ui);    // Get filter stats    sip_stats_t stats = sip_calls_stats();    mvwprintw(ui->win, 7, 3, "( ) all dialogs ");    mvwprintw(ui->win, 8, 3, "( ) selected dialogs [%d]", call_group_count(info->group));    mvwprintw(ui->win, 9, 3, "( ) filtered dialogs [%d]", stats.displayed);    // Print 'current SIP message' field label if required    if (info->msg != NULL)        mvwprintw(ui->win, 10, 3, "( ) current SIP message");    mvwprintw(ui->win, 7, 35, "( ) .pcap (SIP)");    mvwprintw(ui->win, 8, 35, "( ) .pcap (SIP + RTP)");    mvwprintw(ui->win, 9, 35, "( ) .txt");    // Get filename field value.    memset(field_value, 0, sizeof(field_value));    strcpy(field_value, field_buffer(info->fields[FLD_SAVE_FILE], 0));    strtrim(field_value);    mvwprintw(ui->win, 4, 60, "     ");    if (strstr(field_value, ".pcap")) {        info->saveformat = (setting_enabled(SETTING_CAPTURE_RTP))? SAVE_PCAP_RTP : SAVE_PCAP;    } else if (strstr(field_value, ".txt")) {        info->saveformat = SAVE_TXT;    } else {        if (info->saveformat == SAVE_PCAP || info->saveformat == SAVE_PCAP_RTP)            mvwprintw(ui->win, 4, 60, ".pcap");        else            mvwprintw(ui->win, 4, 60, ".txt ");    }    set_field_buffer(info->fields[FLD_SAVE_ALL], 0, (info->savemode == SAVE_ALL) ? "*" : " ");    set_field_buffer(info->fields[FLD_SAVE_SELECTED], 0,                     (info->savemode == SAVE_SELECTED) ? "*" : " ");    set_field_buffer(info->fields[FLD_SAVE_DISPLAYED], 0,                     (info->savemode == SAVE_DISPLAYED) ? "*" : " ");    set_field_buffer(info->fields[FLD_SAVE_MESSAGE], 0,                     (info->savemode == SAVE_MESSAGE) ? "*" : " ");    set_field_buffer(info->fields[FLD_SAVE_PCAP], 0, (info->saveformat == SAVE_PCAP) ? "*" : " ");    set_field_buffer(info->fields[FLD_SAVE_PCAP_RTP], 0, (info->saveformat == SAVE_PCAP_RTP) ? "*" : " ");    set_field_buffer(info->fields[FLD_SAVE_TXT], 0, (info->saveformat == SAVE_TXT) ? "*" : " ");    // Show disabled options with makers    if (!setting_enabled(SETTING_CAPTURE_RTP))        set_field_buffer(info->fields[FLD_SAVE_PCAP_RTP], 0, "-");    set_current_field(info->form, current_field(info->form));    form_driver(info->form, REQ_VALIDATION);    return 0;}
开发者ID:cruzccl,项目名称:sngrep,代码行数:60,


示例7: cli_error

	/***************************************************************	 * cli_error:	 ***************************************************************/int   cli_error(		/* Display only				*/    int   sts			/* <r> status value			*/   ,char  msg[]			/* <r> message to display		*/   )   {    int   k;    char  fmt[20];    char  *p;    struct descriptor  *dsc;    if (msg && msg[0])        fprintf(stderr,"/n*ERR* %s/n",msg);    dsc = cli_addr_cmdline_dsc();    if (p = dsc->dscA_pointer)       {        strtrim(p,0);        fprintf(stderr,"cmdline = '%s'/n",p);        k = cliNonblank_save - p;        if (k>=0 && k<dsc->dscW_length)           {            sprintf(fmt,"%%%ds^^^^/n",k+11);            fprintf(stderr,fmt,"");           }       }    fprintf(stderr,"/n");    return(sts);   }
开发者ID:petermilne,项目名称:mdsshell,代码行数:31,


示例8: main

/*---------------------------------------------------------------------------*/int main(int count, char *strings[]){	const int on=1;	int sd, port;	struct sockaddr_in addr;	char buffer[1024];	/*---Get parameters---*/	if ( count < 3  ||  count > 4)	{		printf("usage: %s [<listening-port>] <dest-addr> <dest-port>/n", strings[0]);		return 0;	}	if ( count == 4 )	{		port = atoi(strings[1]);		strings++;	}	else		port = DEFAULT_PORT;	/*---Create and configure socket---*/	sd = socket(PF_INET, SOCK_DGRAM, 0);	if ( sd < 0 )		panic("socket failed");	if ( setsockopt(sd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)) != 0 )		panic("set broadcast failed");	bzero(&addr, sizeof(addr));	addr.sin_family = AF_INET;	addr.sin_port = htons(port);	if ( inet_aton("128.1.1.1", &addr.sin_addr) == 0 )		panic("inet_aton failed (%s)", strings[1]);	if ( bind(sd, (struct sockaddr*)&addr, sizeof(addr)) != 0 )		panic("bind failed");	addr.sin_port = htons(atoi(strings[2]));	if ( inet_aton(strings[1], &addr.sin_addr) == 0 )		panic("inet_aton failed (%s)", strings[1]);	/*---Create child---*/	if ( fork() )		Receiver(sd);	else		shutdown(sd, 0);	/* close the input channel */	/*---Begin broadcast---*/	do	{		fgets(buffer, sizeof(buffer), stdin);		strtrim(buffer);		if ( sendto(sd, buffer, strlen(buffer)+1, 0, (struct sockaddr*)&addr, sizeof(addr)) < 0 )			perror("sendto");	}	while ( strcmp(buffer, "bye") != 0 );	/*---Wait for child termination & cleanup---*/	wait(0);	close(sd);	return 0;}
开发者ID:rahulnij,项目名称:cprograms,代码行数:59,


示例9: fswc_getopt_file

int fswc_getopt_file(fswc_getopt_t *s){	char line[1024];	char *arg, *val;	struct option *opt;		while(fgets(line, 1024, s->f))	{		s->line++;		strtrim(line, WHITESPACE);		arg = argdup(line, WHITESPACE, 0, 0);				if(!arg) continue;		if(*arg == '#') continue;				/* Find argument in the list. */		opt = (struct option *) s->long_opts;		while(opt->name)		{			if(!strcasecmp(opt->name, arg)) break;			opt++;		}				if(!opt->name)		{			ERROR("Unknown argument: %s", arg);			WARN("%s,%i: %s", s->filename, s->line, line);			free(arg);			return(-2);		}				if(opt->val == 'c')		{			ERROR("You can't use config from a configuration file.");			WARN("%s,%i: %s", s->filename, s->line, line);			free(arg);			return(-2);		}				if(opt->has_arg)		{			val = argdup(line, WHITESPACE, 1, 0);			optarg = val;		}				free(arg);				return(opt->val);	}		/* Have we reached the end of the file? */	if(feof(s->f)) return(-1);		/* No.. there has been an error. */	ERROR("fread: %s", strerror(errno));		return(-2);}
开发者ID:zzilla,项目名称:robocam,代码行数:58,


示例10: DirListing

/*DirListing - read the directory and output an HTML table. Used partially from source above*/void DirListing(FILE* FP, char* Path) {	struct dirent *dirent;	struct stat info;	char Filename[MAXPATH];	DIR* dir = opendir(Path);	fprintf(FP, "<html><head><title>Directory Lister</title></body>"		"<body><font size=+4>CS410 Web Server</font><br><hr width=/"100%%/"><br><center>"		"<table border cols=4 width=/"100%%/" bgcolor=/"009999/">");	fprintf(FP, "<caption><font size=+3>Directory of %s</font></caption>/n", Path);	if ( dir == 0 )	{		fprintf(FP, "</table><font color=/"white/" size=+2>%s</font></body></html>", strerror(errno));		return;	}	while ( (dirent = readdir(dir)) != 0 )	{		if ( strcmp(Path, "/") == 0 )			sprintf(Filename, "/%s", dirent->d_name);		else			sprintf(Filename, "%s/%s", Path, dirent->d_name);		fprintf(FP, "<tr>");		if ( stat(Filename, &info) == 0 )		{			fprintf(FP, "<td>%s</td>", dirent->d_name);			if ( S_ISDIR(info.st_mode) )			{				if ( strcmp(dirent->d_name, "..") == 0 )					fprintf(FP, "<td><a href=/"http://%s%s/">(parent)</a></td>", Host, dir_up(Path));				else					fprintf(FP, "<td><a href=/"http://%s%s/">%s</a></td>", Host, Filename, dirent->d_name);				fprintf(FP, "<td>Directory</td>");			}			else if ( S_ISREG(info.st_mode) )			{				fprintf(FP, "<td><a href=/"http://%s%s/">%s</a></td>", Host, Filename, dirent->d_name);				fprintf(FP, "<td>%d</td>", info.st_size);			}			else if ( S_ISLNK(info.st_mode) )				fprintf(FP, "<td>Link</td>");			else if ( S_ISCHR(info.st_mode) )				fprintf(FP, "<td>Character Device</td>");			else if ( S_ISBLK(info.st_mode) )				fprintf(FP, "<td>Block Device</td>");			else if ( S_ISFIFO(info.st_mode) )				fprintf(FP, "<td>FIFO</td>");			else if ( S_ISSOCK(info.st_mode) )				fprintf(FP, "<td>Socket</td>");			else				fprintf(FP, "<td>(unknown)</td>");			fprintf(FP, "<td>%s</td>", strtrim(ctime(&info.st_ctime)));		}		else			perror(Path);		fprintf(FP, "</tr>/n");	}	fprintf(FP, "</table></center></body></html>");}
开发者ID:i-cohen,项目名称:cs410-a3,代码行数:58,


示例11: strtrim

void String::strip(const char *chars){    size_t len = strtrim(chars, getText(), getLength());    if(!len) {        setLength(len);        return;    }    setLength(strchop(chars, getText(), len));}
开发者ID:dong777,项目名称:zkonvif,代码行数:9,


示例12: strtrim

char *t_Str::strip(const char *chars, char *str, size_t len){    len = strtrim(chars, str, len);    if(!len)        return str;    return ifind(chars, str, len);}   
开发者ID:embeddedspecialist,项目名称:RaspyMonitor,代码行数:9,


示例13: read_mtp

SEXPread_mtp(SEXP fname){    FILE *f;    char buf[MTP_BUF_SIZE], blank[1], *pres;    MTB  *mtb, thisRec;    int i, j, res, nMTB = MTB_INITIAL_ENTRIES;    PROTECT(fname = asChar(fname));#ifdef WIN32 /* force text-mode read */    if ((f = fopen(R_ExpandFileName(CHAR(fname)), "rt")) == NULL)#else    if ((f = fopen(R_ExpandFileName(CHAR(fname)), "r")) == NULL)#endif	error(_("unable to open file '%s': '%s'"), 	      CHAR(fname), strerror(errno));    if ((fgets(buf, MTP_BUF_SIZE, f) == NULL) ||	strncmp(buf, "Minitab Portable Worksheet ", 27) != 0)	error(_("file '%s' is not in Minitab Portable Worksheet format"),	      CHAR(fname));    pres = fgets(buf, MTP_BUF_SIZE, f);    if(pres != buf) error(_("file read error"));    UNPROTECT(1);    mtb = Calloc(nMTB, MTB);    for (i = 0; !feof(f); i++) {	if (i >= nMTB) {	    nMTB *= 2;	    mtb = Realloc(mtb, nMTB, MTB);	}	thisRec = mtb[i] = Calloc(1, MTBDATC);	if (sscanf(buf, "%%%7d%7d%7d%7d%c%8c", &(thisRec->type),		   &(thisRec->cnum), &(thisRec->len),		   &(thisRec->dtype), blank, thisRec->name) != 6)	    error(_("first record for entry %d is corrupt"), i+1);	thisRec->name[8] = '/0';	strtrim(thisRec->name);	/* trim trailing white space on name */	switch (thisRec->dtype) {	case 0:		/* numeric data */	    thisRec->dat.ndat = Calloc(thisRec->len, double);	    for (j = 0; j < thisRec->len; j++) {		res = fscanf(f, "%lg", thisRec->dat.ndat + j);		if(res == EOF) error(_("file read error"));	    }	    break;	default:	    if (thisRec->type == 4) { /* we have a matrix so dtype is number of columns */		thisRec->dat.ndat = Calloc(thisRec->len, double);		for (j = 0; j < thisRec->len; j++) {		    res = fscanf(f, "%lg", thisRec->dat.ndat + j);		    if(res == EOF) error(_("file read error"));		}	    } else {		error(_("non-numeric data types are not yet implemented"));	    }	}
开发者ID:cran,项目名称:foreign,代码行数:56,


示例14: ini_open

INIFILEHANDLE ini_open(const char *iniFile, const char *mode){	char lineBuf[1024];	LPINIFILE file;	LPINISECTION curSection = NULL;	FILE *fp;	fp = fopen(iniFile, mode);	if(fp == NULL)		return NULL;	file = ini_createIniStruct(iniFile);	strcpy(file->mode, mode);	while(fgets(lineBuf, 1023, fp))	{		char *p = strtrim(lineBuf);		int len = strlen(p);		if(strlen(p) <= 0)			continue;		else if(p[0] == '#')			continue;		else if((p[0] == '[') && (p[len - 1] == ']'))		{			p[len - 1] = '/0';			p = strtrim(&p[1]);			curSection = ini_addSection(file, p);		}		else		{			char *p2 = strchr(lineBuf, '=');			if(p2 == NULL)			{				ini_destryIniStruct(file);				file = NULL;				break;			}			*p2++ = '/0';			p = strtrim(p);			p2 = strtrim(p2);			ini_addItem(curSection, p, p2);		}	}	fclose(fp);	return (INIFILEHANDLE)file;}
开发者ID:chengs,项目名称:UEFI,代码行数:43,


示例15: parse_pmoption_repeat

/* Disgusting 8 variable function */static void parse_pmoption_repeat(int *flag, int *flag_com, char *line,								  const char *key, void (*repeatfn) (char *),								  void (*freefn) (void **), void **global_conf,								  int comment){	if ((comment && (*flag || *flag_com)) || (!comment && *flag)) {		return;	}	if (!(line = strchr(line, '='))) {		return;	}	if (*global_conf) {		freefn(global_conf);		*global_conf = NULL;	}	++line;	line = strtrim(line);	if (!strlen(line)) {		return;	}	char *ptr;	while (ptr = strchr(line, ' ')) {		*ptr = 0;		++ptr;		repeatfn(line);		line = ptr;		line = strtrim(line);	}	repeatfn(line);	if (comment) {		*flag_com = 1;	} else {		*flag = 1;	}}
开发者ID:rctay,项目名称:powaur,代码行数:43,


示例16: ps_strfilter_filename

char * ps_strfilter_filename (char *filename){	char * result = NULL;	if (filename!=NULL)	{		result = strtrim (filename);		for (unsigned int i=0;i<strlen (result);i++) 			if (result[i]==' ' || result[i]=='//' || result[i]=='/') result[i]='_';	}	return result;}
开发者ID:alexandruradovici,项目名称:photostorm,代码行数:11,


示例17: parse_column_sep

/* parser and renderer for seperator of two columns */int parse_column_sep() {	token = yylex();	if (token == NUMBER) {		token = yylex();	} else {		string = "0.5";	}	fprintf(ofile,"//end{column}/n//begin{column}{%s//textwidth}/n",strtrim(string));	structure_count = 0;	return 0;}
开发者ID:rju,项目名称:slp,代码行数:13,


示例18: opt_parse_line

static boolopt_parse_line(char *line, int n, char *fn){	int i;	const char *err = NULL;	char *token;	buffer b;	assert(line && fn);	b.ptr = line;	if((err = get_token(&b, 0))) {		fprintf(stderr, "%s/n", err);		return FALSE;	}	if(b.data == NULL)		return FALSE;	strtrim(b.data);	strtrim(b.ptr);	token = b.data;	b.data = b.ptr = b.ptr;	for(i = 0; opt_parsers[i].token; i++)		if(!strcmp(opt_parsers[i].token, token)) {			if(!(err = opt_parsers[i].func(&b)))				return FALSE;			break;		}	fprintf(stderr, _("%s: parse error at line %d: "), fn, n);	if(err)		fprintf(stderr, "%s/n", err);	else		fprintf(stderr, _("unknown token %s/n"), token);	return TRUE;}
开发者ID:mkroli,项目名称:abook,代码行数:41,


示例19: assert

repository_t *rsync_get_repository(driver_t * self, char *supfile,				   list_t * repositories_hierarchy){	FILE *file;	char *line, *path, *name, *extension;	repository_t *repository;	size_t n;	int nread;	assert(supfile);	if (!(extension = rindex(supfile, '.')) || strcmp(extension, ".rsync"))		return NULL;	supfile = xstrdup_printf("/etc/ports/%s", supfile);	file = fopen(supfile, "r");	if (file == NULL)		return NULL;	line = NULL;	repository = NULL;	while ((nread = getline(&line, &n, file)) >= 0) {		*(line + strlen(line) - 1) = 0;		strtrim(line);		if (line[0] == '#' || strlen(line) == 0 ||		    (!strstr(line, "destination") && strchr(line, '=')))			continue;		path = strtrim(xstrdup(strchr(line, '=') + 1));		if (!strncmp("/usr/ports/", path, 11))			name = xstrdup(path + 11);		else			name = xstrdup(strrchr(path, '/') + 1);		repository = repository_new(name, path, supfile, self,					    repositories_hierarchy);		break;	}	free(line);	fclose(file);	return repository;}
开发者ID:BackupTheBerlios,项目名称:ilenia-svn,代码行数:41,


示例20: fopen

/* Checks if we have .install file in PKGBUILD at cwd. * returns a newly allocated string for the .install file if we have * returns NULL if no */char *have_dotinstall(void){	FILE *fp;	char buf[PATH_MAX];	char *str, *dotinstall = NULL;	size_t len;	fp = fopen("PKGBUILD", "r");	if (!fp) {		error(PW_ERR_FOPEN, "PKGBUILD");		return NULL;	}	while (str = fgets(buf, PATH_MAX, fp)) {		str = strtrim(str);		len = strlen(str);		if (!len) {			continue;		}		if (!strncmp(str, "install", 7)) {			/* No error checking done here, if malformed, that's it */			str = strchr(str, '=');			if (!str) {				break;			}			++str;			str = strtrim(str);			if (!strlen(str)) {				break;			} else {				dotinstall = strdup(str);				break;			}		}	}	fclose(fp);	return dotinstall;}
开发者ID:Berticus,项目名称:powaur,代码行数:45,


示例21: dbf_read_record

static int dbf_read_record(TABDCA *dca, struct dbf *dbf){     /* read next record from xBASE data file */      int b, j, k, ret = 0;      char buf[DBF_FDLEN_MAX+1];      xassert(dbf->mode == 'R');      if (setjmp(dbf->jump))      {  ret = 1;         goto done;      }      /* check record flag */      b = read_byte(dbf);      if (b == 0x1A)      {  /* end of data */         ret = -1;         goto done;      }      if (b != 0x20)      {  xprintf("%s:0x%X: invalid record flag/n", dbf->fname,            dbf->offset);         longjmp(dbf->jump, 0);      }      /* read dummy RECNO field */      if (dbf->ref[0] > 0)         mpl_tab_set_num(dca, dbf->ref[0], dbf->count+1);      /* read fields */      for (k = 1; k <= dbf->nf; k++)      {  /* read k-th field */         for (j = 0; j < dbf->len[k]; j++)            buf[j] = (char)read_byte(dbf);         buf[dbf->len[k]] = '/0';         /* set field value */         if (dbf->type[k] == 'C')         {  /* character field */            if (dbf->ref[k] > 0)               mpl_tab_set_str(dca, dbf->ref[k], strtrim(buf));         }         else if (dbf->type[k] == 'N')         {  /* numeric field */            if (dbf->ref[k] > 0)            {  double num;               strspx(buf);               xassert(str2num(buf, &num) == 0);               mpl_tab_set_num(dca, dbf->ref[k], num);            }         }         else            xassert(dbf != dbf);      }      /* increase record count */      dbf->count++;done: return ret;}
开发者ID:CansenJIANG,项目名称:igraph,代码行数:52,


示例22: main

void main(void) {  char *test1 = strdup("  /t  /nTest programu/tOK... .../n/t/n    /n ");  char *test2 = strdup("");  char *test3 = strdup("   ");  char *test4 = strdup("abcd");  /* zde mozno nastavit ruzne testovaci retezce */  char *test = test1;  strtrim(test);  printf("'%s'/n",test);}
开发者ID:mormegil-cz,项目名称:fel-cvut,代码行数:13,


示例23: orbstat2pf

Pf *orbstat2pf( Orbstat *orbstat, int orbversion ) {	Pf	*pf;	char	*s;	struct in_addr in;	if( orbstat == (Orbstat *) NULL ) {		return (Pf *) NULL;	} 	pf = pfnew( PFARR );	if( orbversion > 0 ) {		pfput_int( pf, "orbversion", orbversion );	}		pfput_time( pf, "when", orbstat->when );	pfput_time( pf, "started", orbstat->started );	pfput_time( pf, "orb_start", orbstat->orb_start );	pfput_boolean( pf, "connections", orbstat->connections );	pfput_boolean( pf, "messages", orbstat->messages );	pfput_int( pf, "maxdata", orbstat->maxdata );	pfput_int( pf, "errors", orbstat->errors );	pfput_int( pf, "rejected", orbstat->rejected );	pfput_int( pf, "closes", orbstat->closes );	pfput_int( pf, "opens", orbstat->opens );	pfput_int( pf, "port", orbstat->port );	memcpy( &in, &orbstat->address, sizeof( struct in_addr ) );	pfput_string( pf, "address", inet_ntoa( in ) );	pfput_int( pf, "pid", orbstat->pid );	pfput_int( pf, "nsources", orbstat->nsources );	pfput_int( pf, "nclients", orbstat->nclients );	pfput_int( pf, "maxsrc", orbstat->maxsrc );	pfput_int( pf, "maxpkts", orbstat->maxpkts );	s = strdup( orbstat->version );	strtrim( s );	pfput_string( pf, "version", s );	free( s );	pfput_string( pf, "who", orbstat->who );	pfput_string( pf, "host", orbstat->host );	return pf;}
开发者ID:vonseg,项目名称:antelope_contrib,代码行数:51,


示例24: alpm_initialize

static alpm_handle_t *alpm_init(void) {  alpm_handle_t *alpm = NULL;  enum _alpm_errno_t alpm_errno = 0;  FILE *fp;  char line[PATH_MAX];  char *ptr, *section = NULL;  alpm = alpm_initialize("/", "/var/lib/pacman", &alpm_errno);  if (!alpm) {    alpm_strerror(alpm_errno);    return NULL;  }  db_local = alpm_get_localdb(alpm);  fp = fopen("/etc/pacman.conf", "r");  if (!fp) {    perror("fopen: /etc/pacman.conf");    return alpm;  }  while (fgets(line, PATH_MAX, fp)) {    strtrim(line);    if (strlen(line) == 0 || line[0] == '#') {      continue;    }    if ((ptr = strchr(line, '#'))) {      *ptr = '/0';    }    if (line[0] == '[' && line[strlen(line) - 1] == ']') {      ptr = &line[1];      if (section) {        free(section);      }      section = strdup(ptr);      section[strlen(section) - 1] = '/0';      if (strcmp(section, "options") != 0) {        alpm_register_syncdb(alpm, section, 0);      }    }  }  free(section);  fclose(fp);  return alpm;}
开发者ID:Acidburn0zzz,项目名称:expac,代码行数:50,


示例25: security_load_booleans

int security_load_booleans(char *path) {	FILE *boolf;	char buffer[BUFSIZ];	char name[BUFSIZ];	char name1[BUFSIZ];	int val;	int errors=0;	boolf = fopen(path ? path : selinux_booleans_path(),"r");	if (boolf == NULL) 		return -1;        while (fgets(buffer, sizeof(buffer), boolf)) {		char *tok=strtok(buffer,"=");		if (tok) {			strncpy(name1,tok, BUFSIZ-1);			strtrim(name,name1,BUFSIZ-1);			if ( name[0]=='#' ) continue;			tok=strtok(NULL,"/0");			if (tok) {				while (isspace(*tok)) tok++;				val = -1;				if (isdigit(tok[0]))					val=atoi(tok);				else if (!strncmp(tok, "true", sizeof("true")-1))					val = 1;				else if (!strncmp(tok, "false", sizeof("false")-1))					val = 0;				if (val != 0 && val != 1) {					fprintf(stderr,"illegal value for boolean %s=%s/n", name, tok);					errors++;					continue;				}				if (security_set_boolean(name, val) < 0) {					fprintf(stderr,"error setting boolean %s to value %d /n", name, val);					errors++;				}			}		}	}	fclose(boolf);	if (security_commit_booleans() < 0)		return -1;	if (errors)		errno = EINVAL;	return errors ? -1 : 0;}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:50,


示例26: add_endtag

static voidadd_endtag( void **vstack, char *tagname ){	char	*copy;	copy = strdup( tagname );	strtrim( copy );	pushstr( vstack, "</" );	pushstr( vstack, copy );	pushstr( vstack, ">" );	free( copy );}
开发者ID:vonseg,项目名称:antelope_contrib,代码行数:14,


示例27: cookie_expire_time

static long cookie_expire_time(const char *cookie_file, const char *domain,    const char *name) {  FILE *fp;  long expire;  char cdomain[256], cname[256];  fp = fopen(cookie_file, "r");  if (!fp) {    return 0L;  }  for (;;) {    char cookie[COOKIE_SIZE];    char *l = &cookie[0];    size_t len;    cdomain[0] = cname[0] = '/0';    expire = 0L;    if(!(fgets(l, COOKIE_SIZE, fp))) {      break;    }    len = strtrim(l);    if (len == 0) {      continue;    }    if (strncmp(l, "#HttpOnly_", 10) == 0) {      l += 10;    }    if (*l == '#' || *l == '/0') {      continue;    }    if (sscanf(l, "%s/t%*s/t%*s/t%*s/t%ld/t%s/t%*s", cdomain, &expire, cname) != 3) {      continue;    }    if (strcmp(domain, cdomain) == 0 && strcmp(name, cname) == 0) {      debug("cookie found (expires %ld)/n", expire);      break;    }  }  fclose(fp);  return expire;}
开发者ID:cinelli,项目名称:burp,代码行数:50,


示例28: get_item_from_line

/* 从配置文件读出key或value,数据返回到item_t指针 */int get_item_from_line(char *line, item_t * item){	char *p = NULL;	char *p2 = NULL;	int len = 0;	p = strtrim(line);	len = strlen(p);	if (len <= 0) {		return -1;	} else if (p[0] == '#') {		if (item->num > MAX_ITEM_COMMENT_NUM)			return 1;		if (item->comment == NULL) {			item->comment =				(char **)malloc(MAX_ITEM_COMMENT_NUM * sizeof(char *));			if (item->comment == NULL) {				printf("malloc error!/n");				return -1;			}		}		item->comment[item->num] = (char *)malloc(len + 1);		strcpy(item->comment[item->num], p);		item->num++;		return 1;	} else {		p2 = strchr(p, '=');		if (p2 == NULL) {			p2 = strchr(p, ' ');			if (p2 != NULL) {				*p2++ = '/0';			} else {				return -1;			}		} else {			*p2++ = '/0';		}		item->key = (char *)malloc(strlen(p) + 1);		item->value = (char *)malloc(strlen(p2) + 1);		strcpy(item->key, p);		strcpy(item->value, p2);	}	return 0;}
开发者ID:emcute0319,项目名称:Linux-C-Examples,代码行数:50,



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


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