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

C++ parse_token函数代码示例

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

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



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

示例1: override_abs

static void override_abs(int fd, const char *devnode,
                         unsigned evcode, const char *value) {
        struct input_absinfo absinfo;
        int rc;
        char *next;

        rc = ioctl(fd, EVIOCGABS(evcode), &absinfo);
        if (rc < 0) {
                log_error_errno(errno, "Unable to EVIOCGABS device \"%s\"", devnode);
                return;
        }

        next = parse_token(value, &absinfo.minimum);
        next = parse_token(next, &absinfo.maximum);
        next = parse_token(next, &absinfo.resolution);
        next = parse_token(next, &absinfo.fuzz);
        next = parse_token(next, &absinfo.flat);
        if (!next) {
                log_error("Unable to parse EV_ABS override '%s' for '%s'", value, devnode);
                return;
        }

        log_debug("keyboard: %x overridden with %"PRIi32"/%"PRIi32"/%"PRIi32"/%"PRIi32"/%"PRIi32" for \"%s\"",
                  evcode,
                  absinfo.minimum, absinfo.maximum, absinfo.resolution, absinfo.fuzz, absinfo.flat,
                  devnode);
        rc = ioctl(fd, EVIOCSABS(evcode), &absinfo);
        if (rc < 0)
                log_error_errno(errno, "Unable to EVIOCSABS device \"%s\"", devnode);
}
开发者ID:nazgul77,项目名称:systemd,代码行数:30,代码来源:udev-builtin-keyboard.c


示例2: readstring

/*---------------------------------------------------------------------*/
string_t *
readstring( FILE *file ) {
   token_t *tok = parse_token( file );

   if( !tok ) {
      fprintf( stderr, "Premature end of file\n" );
      return 0L;
   } else {
      if( tok->tok == TOKEN_SYMBOL ) {
	 token_t *tok2 = parse_token( file );

	 if( !tok2 ) {
	    fprintf( stderr, "Premature end of file\n" );
	    return 0L;
	 } else {
	    if( tok2->tok == TOKEN_GUIL ) {
	       return make_string( tok->val );
	    } else {
	       fprintf( stderr, "Illegal string...%s\n", tok->val );
	       return 0L;
	    }
	 }
      } else {
	 return 0L;
      }
   }
}
开发者ID:TheTypoMaster,项目名称:hop,代码行数:28,代码来源:read.c


示例3: pvr2_ctrl_sym_to_value

/* Convert a symbolic value to a mask/value pair */
int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr,
			   const char *ptr,unsigned int len,
			   int *maskptr,int *valptr)
{
	int ret = -EINVAL;
	unsigned int cnt;

	*maskptr = 0;
	*valptr = 0;

	cnt = 0;
	while ((cnt < len) && ((ptr[cnt] <= 32) || (ptr[cnt] >= 127))) cnt++;
	len -= cnt; ptr += cnt;
	cnt = 0;
	while ((cnt < len) && ((ptr[len-(cnt+1)] <= 32) ||
			       (ptr[len-(cnt+1)] >= 127))) cnt++;
	len -= cnt;

	if (!len) return -EINVAL;

	LOCK_TAKE(cptr->hdw->big_lock); do {
		if (cptr->info->type == pvr2_ctl_int) {
			ret = parse_token(ptr,len,valptr,NULL,0);
			if ((ret >= 0) &&
			    ((*valptr < cptr->info->def.type_int.min_value) ||
			     (*valptr > cptr->info->def.type_int.max_value))) {
				ret = -ERANGE;
			}
			if (maskptr) *maskptr = ~0;
		} else if (cptr->info->type == pvr2_ctl_bool) {
			ret = parse_token(
				ptr,len,valptr,boolNames,
				sizeof(boolNames)/sizeof(boolNames[0]));
			if (ret == 1) {
				*valptr = *valptr ? !0 : 0;
			} else if (ret == 0) {
				*valptr = (*valptr & 1) ? !0 : 0;
			}
			if (maskptr) *maskptr = 1;
		} else if (cptr->info->type == pvr2_ctl_enum) {
			ret = parse_token(
				ptr,len,valptr,
				cptr->info->def.type_enum.value_names,
				cptr->info->def.type_enum.count);
			if ((ret >= 0) &&
			    ((*valptr < 0) ||
			     (*valptr >= cptr->info->def.type_enum.count))) {
				ret = -ERANGE;
			}
			if (maskptr) *maskptr = ~0;
		} else if (cptr->info->type == pvr2_ctl_bitmask) {
			ret = parse_tlist(
				ptr,len,maskptr,valptr,
				cptr->info->def.type_bitmask.bit_names,
				cptr->info->def.type_bitmask.valid_bits);
		}
	} while(0); LOCK_GIVE(cptr->hdw->big_lock);
	return ret;
}
开发者ID:ivucica,项目名称:linux,代码行数:60,代码来源:pvrusb2-ctrl.c


示例4: main

int main(int argc, char* argv[])
{
	assert(parse_token("it is used to token segmentation. is it easy?", " .?", on_token, NULL) == 9);
	assert(parse_token("/backup/tools/jdk1.5.0_18/bin/:/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/backup/tools/jdk1.5.0_18/bin/:/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin:/home/lixianjing/bin", ":", on_token, NULL) == 9);
	assert(parse_token("/backup/tools/jdk1.5.0_18/bin/", "/", on_token, NULL) == 4);

	return 0;
}
开发者ID:0ct0cat,项目名称:spexamples,代码行数:8,代码来源:parse_token.c


示例5: fkey_table_relation

/*
* write table index to keys[]
* internal function for process_keyfile()
*/
static int
fkey_table_relation (char *args)
{
	int ti=0, ki=0;
	char *s_func=NULL, *s_key=NULL;
	int slen=0, restidx=-1, sublen=-1;
	int ret = 1;

	slen = parse_token(args, "\x09= ", &restidx);

	/* special case separately: empty line */
	if (slen == 0) {
		return (0);
	}

	args[slen] = '\0';
	s_key = &args[0];
	if (restidx > 0) {
		s_func = &args[restidx];
		sublen = parse_token(s_func, "\x09 ", &restidx);
		s_func[sublen] = '\0';
	}

	if (slen < 3 || sublen < 1 || s_key[0] == '#') {
		/* comment lines covered also */
		return (0);
	}

	/* find ti and ki */
	ret=1;
	ti = index_func_fullname(s_func);
	if (ti < TLEN && table[ti].fkey != -1) {
		ki = index_key_string(s_key);
		if (ki < KLEN && ki >= RES_KLEN) {
			keys[ki].table_index = ti;
			ret = 0;
		} else {
			if (ki < RES_KLEN) {
				fprintf(stderr, "eda: key %s is reserved\n", s_key);
			} else {
				fprintf(stderr, "eda: key %s is unknown\n", s_key);
			}
		}
	} else {
		fprintf(stderr, "eda: function %s is unknown or cannot bind fkey\n", s_func);
	}

	return (ret);
}/* fkey_table_relation */
开发者ID:gamma62,项目名称:eda,代码行数:53,代码来源:rc.c


示例6: prim_fsize

void prim_fsize(PRIM_PROTOTYPE)
{
  FILE *fh;
  char *filename;
  int result; 
  long offset;
  CHECKOP(1);
  oper1 = POP();
  if (getuid() == 0 ) 
    abort_interp("Muck is running under root privs, file prims disabled.");
  if (mlev < LBOY) abort_interp("BOY primitive only.");  
  if (oper1->type != PROG_STRING) abort_interp("Arguement 1 is not a string.");
  if (!oper1->data.string) abort_interp("Arguement 1 is a null string.");
  filename = oper1->data.string->data;
#ifdef SECURE_FILE_PRIMS
  if (!(valid_name(filename)))
      abort_interp( "Invalid file name.");
  if ( strchr( filename, '$' ) == NULL )
    filename = set_directory(filename);
  else
    filename = parse_token( filename );
  if ( filename == NULL )
    abort_interp( "Invalid shortcut used." );
#endif
  fh = fopen(filename, "r");
  if (fh == NULL) { offset = -1; } else {
    fseek(fh, 0, SEEK_END);
    offset = ftell(fh);
    if(tp_log_files)
      log2filetime("logs/files", "#%d by %s FSIZE: %s \n", program, unparse_object(player, player), oper1->data.string->data); 
  }
  fclose(fh);
  CLEAR(oper1);
  PushInt(offset);
}
开发者ID:CyberLeo,项目名称:protomuck,代码行数:35,代码来源:p_file.c


示例7: prim_frm

void prim_frm(PRIM_PROTOTYPE)
{
  char *filename;
  CHECKOP(1);
  oper1 = POP();
  if (getuid() == 0 )
    abort_interp("Muck is running under root privs, file prims disabled.");
  if (mlev < LBOY) abort_interp("BOY primitive only.");
  if(oper1->type != PROG_STRING) abort_interp("Argument 1 is not a string.");
  if(!oper1->data.string) abort_interp("Argument 1 is a null string.");
  filename = oper1->data.string->data;
#ifdef SECURE_FILE_PRIMS
  if (!(valid_name(filename)))
      abort_interp( "Invalid file name.");
  if ( strchr( filename, '$' ) == NULL )
    filename = set_directory(filename);
  else
    filename = parse_token( filename );
  if ( filename == NULL )
    abort_interp( "Invalid shortcut used." );
#endif 
  result = unlink(filename);
    if(tp_log_files)
      log2filetime("logs/files", "#%d by %s FRM: %s \n", program, unparse_object(player, player), oper1->data.string->data);  
  CLEAR(oper1);
  PushInt(result);
}
开发者ID:CyberLeo,项目名称:protomuck,代码行数:27,代码来源:p_file.c


示例8: main

int
main(int argc, char **argv)
{
	char text[100], delims[10];
	scanf("%s %s", text, delims);
	parse_token(text, delims, token_print, NULL);
}
开发者ID:simplyzhao,项目名称:Code_Pearls,代码行数:7,代码来源:token_separate.c


示例9: strsep

KeyMap_t *parse_mapping(Display *ctrl_conn, char *mapping) {
	char *token;
	KeyMap_t *rval, *km, *nkm;

	rval = km = NULL;

	for (;;) {
		token = strsep(&mapping, ";");
		if (token == NULL)
			break;

		nkm = parse_token(ctrl_conn, token);

		if (nkm != NULL) {
			if (km == NULL)
				rval = km = nkm;
			else {
				km->next = nkm;
				km = nkm;
			}
		}
	}

	return rval;
}
开发者ID:viktornar,项目名称:knumcap,代码行数:25,代码来源:knumcap.c


示例10: xmlFile

void simple_parser::load(const std::string& fileName, bool makeLowercaseTags)
{
   std::ifstream xmlFile(fileName.c_str());

   if ( !xmlFile.is_open() )
      throw std::runtime_error("Cannot open file <" + fileName + ">!" );

   xmlFile.exceptions(std::ios::badbit);

   std::string tokenName;
   bool isComment;
   bool isInTag;
   for (;;)
   {
      isInTag = parse_token(xmlFile, tokenName, isComment);
      if ( xmlFile.eof() )
         break;

      if ( isInTag )
      {
         if ( isComment )
            continue;

         boost::shared_ptr<tree_node> pTmpMap(new tree_node());
         m_root.push_back(pTmpMap);

         recursive_parse_tag(tokenName, xmlFile, pTmpMap, makeLowercaseTags);
      }
   }
}
开发者ID:1901,项目名称:libmoost,代码行数:30,代码来源:simple_parser.hpp


示例11: parse_absolute_path

static int parse_absolute_path(http_parser_t *parser)
{
    char *path, *token;

    path = malloc(PATH_LEN);
    ASSERT(path != NULL);

    memset(path, 0, PATH_LEN);
    do {
        if (parser->parse_ptr - parser->data >= parser->len)
            return 1;

        if (parse_char(parser, '/'))
            break;

        token = parse_token(parser);
        if (!token)
            return 1;

        strlcat(path, "/", PATH_LEN);
        strlcat(path, token, PATH_LEN);
        free(token);
    } while (1);

    parser->req.path = path;
    return 0;
}
开发者ID:ketotek,项目名称:http-web-server,代码行数:27,代码来源:http.c


示例12: parse_directive

static int
parse_directive(char **conf)
{
	char *dir;
	int error;

	error = parse_token(conf, &dir);
	if (error)
		return (error);

	if (strcmp(dir, ".ask") == 0)
		error = parse_dir_ask(conf);
	else if (strcmp(dir, ".md") == 0)
		error = parse_dir_md(conf);
	else if (strcmp(dir, ".onfail") == 0)
		error = parse_dir_onfail(conf);
	else if (strcmp(dir, ".timeout") == 0)
		error = parse_dir_timeout(conf);
	else {
		printf("mountroot: invalid directive `%s'\n", dir);
		/* Ignore the rest of the line. */
		(void)parse_skipto(conf, '\n');
		error = EINVAL;
	}
	free(dir, M_TEMP);
	return (error);
}
开发者ID:ChristosKa,项目名称:freebsd,代码行数:27,代码来源:vfs_mountroot.c


示例13: parse_index

static
int parse_index(FILE * file)
{
    if (0 != parse_token(file, number_buffer, NUMBER_BUFFER_LEN))
        return -1;
    return to_number(number_buffer);
}
开发者ID:Pand9,项目名称:IPP-2015-1,代码行数:7,代码来源:parse.c


示例14: parse_dir_onfail

static int
parse_dir_onfail(char **conf)
{
	char *action;
	int error;

	error = parse_token(conf, &action);
	if (error)
		return (error);

	if (!strcmp(action, "continue"))
		root_mount_onfail = A_CONTINUE;
	else if (!strcmp(action, "panic"))
		root_mount_onfail = A_PANIC;
	else if (!strcmp(action, "reboot"))
		root_mount_onfail = A_REBOOT;
	else if (!strcmp(action, "retry"))
		root_mount_onfail = A_RETRY;
	else {
		printf("rootmount: %s: unknown action\n", action);
		error = EINVAL;
	}

	free(action, M_TEMP);
	return (0);
}
开发者ID:ChristosKa,项目名称:freebsd,代码行数:26,代码来源:vfs_mountroot.c


示例15: parse_message_header

static int parse_message_header(http_parser_t *parser)
{
    int field_num;
    http_header_field_t *field;

    field_num = add_field(parser);
    field = &parser->req.fields[field_num];

    field->valid = 0;
    parse_crlf(parser);
    field->name = parse_token(parser);
    if (!field)
        return 1;

    if (parse_char(parser, ':')) {
        free(field->name);
        return 1;
    }

    // optional
    while (parse_char(parser, ' ') == 0)
        ;
    field->value = parse_field_content(parser);
    if (!field->value)
        return 1;
    while (parse_char(parser, ' ') == 0)
        ;

    field->valid = 1;
    return 0;
}
开发者ID:ketotek,项目名称:http-web-server,代码行数:31,代码来源:http.c


示例16: parse_noise

int parse_noise(char *noise_param, int store)
{
    int ret = 0;
    char *tmp = strdup(noise_param);
    char * pch, *ech;

    pch = strchr(tmp, '[');
    if (NULL != pch) {
        pch++;
        ech = strchr(pch, ']');
        if (NULL != ech) {
            *ech = '\0';
            ech++;
            if ('\0' != *ech) {
                ret = 1;
            } else {
                ret = parse_token(pch, 1, store);
            }
        } else {
            ret = 1;
        }
    }
    free(tmp);
    return ret;
}
开发者ID:AT95,项目名称:ompi,代码行数:25,代码来源:test_common.c


示例17: crtc_parse

/**
 * Parse a string for a crtc.
 * \param crtc Crtc to write.
 * \param begin Start of the string to parse.
 * \param end End of the string to parse.
 * \return
 *  - ==0 on success
 *  - !=0 on error
 */
adv_error crtc_parse(adv_crtc* crtc, const char* begin, const char* end)
{
	crtc_reset(crtc);
	crtc_user_reset(crtc);

	parse_separator(" \t", &begin, end);

	if (begin != end && *begin == '"') {
		if (parse_quote(crtc->name, CRTC_NAME_MAX, &begin, end))
			return -1;
	} else {
		if (parse_token(crtc->name, CRTC_NAME_MAX, " \t", &begin, end))
			return -1;
	}

	parse_separator(" \t", &begin, end);
	if (begin == end) {
		snprintf(video_mode_parse_error_buffer, sizeof(video_mode_parse_error_buffer), "Missing modeline data");
		return -1;
	}

	if (parse_crtc(crtc, begin, end) != 0)
		return -1;

	return 0;
}
开发者ID:BirchJD,项目名称:advancemame-0.106.1-RPi,代码行数:35,代码来源:videoio.c


示例18: speech_get_token

// 解析response json , 获取token,验证scope信息
RETURN_CODE
speech_get_token(const char *api_key, const char *secret_key, const char *scope, char *token) {
    char url_pattern[] = "%s?grant_type=client_credentials&client_id=%s&client_secret=%s";
    char url[200];
    char *response = NULL;

    snprintf(url, 200, url_pattern, API_TOKEN_URL, api_key, secret_key);
    printf("url is: %s\n", url);
    CURL *curl = curl_easy_init();
    curl_easy_setopt(curl, CURLOPT_URL, url); // 注意返回值判读
    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 5);
    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 60); // 60s超时
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

    CURLcode res_curl = curl_easy_perform(curl);
    RETURN_CODE res = RETURN_OK;
    if (res_curl != CURLE_OK) {
        snprintf(g_demo_error_msg, BUFFER_ERROR_SIZE, "perform curl error:%d, %s.\n", res,
                 curl_easy_strerror(res_curl));
        res = ERROR_TOKEN_CURL;
    } else {
        res = parse_token(response, scope, token); // 解析token,结果保存在token里
        if (res == RETURN_OK) {
            printf("token: %s of %s\n", token, response);
        }
    }
    free(response);
    curl_easy_cleanup(curl);
    return res;
}
开发者ID:188816600,项目名称:speech-demo,代码行数:32,代码来源:token.c


示例19: readobj

/*---------------------------------------------------------------------*/
obj_t *
readobj( FILE *file ) {
   token_t *tok = parse_token( file );

   if( !tok ) {
      return 0L;
   } else {
      switch( tok->tok ) {
	 case TOKEN_OPENPAR:
	    return (obj_t *)readlist( file );
	    
	 case TOKEN_SYMBOL:
	    return (obj_t *)make_symbol( tok->val );
	    
	 case TOKEN_STRING:
	    return (obj_t *)make_string( tok->val );
	    
	 case TOKEN_INT:
	    return (obj_t *)make_integer( atol( tok->val ) );
	    
	 default:
	    fprintf( stderr, "Illegal %s: %s\n",
		     token_type( tok ),
		     tok->val );
	    return (obj_t *)NIL;
      }
   }
}
开发者ID:TheTypoMaster,项目名称:hop,代码行数:29,代码来源:read.c


示例20: ASVolume_parseGnomeIconString

void ASVolume_parseGnomeIconString (ASVolume *v)
{
	if (v) { 
		static char signature[] = ". GThemedIcon ";
		destroy_string (&(v->idString));

		if (v->icon) {
			ASImage *tmp = GIcon2ASImage (v->icon);
			gchar* str = g_icon_to_string (v->icon);

			show_activity ("volume added with icon \"%s\".", str);

			if (str) {
				if (strncmp (str, signature, sizeof(signature)-1) == 0)
					parse_token (&str [sizeof(signature)-1], &(v->idString));
				safefree (str);
			}

			if (tmp) {
				int l, t, r, b;
				get_asimage_closure (tmp, &l, &t, &r, &b, 10);
				v->iconIm = tile_asimage (Scr.asv, tmp, l, t, r+1-l, b+1-t, 0x4F7F7F7F, ASA_ASImage, 100, ASIMAGE_QUALITY_DEFAULT);
				safe_asimage_destroy (tmp);
			}					
		
			LOCAL_DEBUG_OUT ("Icon asim = %p", v->iconIm);
		}
		if (!v->idString)
			v->idString = mystrdup ("unknown");
	}
}
开发者ID:Remmy,项目名称:afterstep,代码行数:31,代码来源:main.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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