当前位置: 首页>>代码示例>>C++>>正文


C++ parse_token函数代码示例

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


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


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