static size_t response_header_callback(void *ptr, size_t size, size_t nmemb, void *userdata) { upyun_http_header_t** headers = userdata; char ccc_buf[1024] = {0}; memcpy(ccc_buf, ptr, size * nmemb); /* there wont be multilines, one line in each call. */ char* line = ptr; char* line_end = line + size * nmemb; skip_space(&line, line_end); char* name = get_token(&line, ":", line_end); if(name == NULL) return size * nmemb; skip_space(&line, line_end); if(line == line_end) return size * nmemb; char* value = get_token(&line, "\r\n", line_end); if(value == NULL) return size * nmemb; upyun_http_header_t* h = calloc(1, sizeof(upyun_http_header_t)); if(h == NULL) return size * nmemb; strncpy(h->name, name, UPYUN_MAX_HEADER_LEN); strncpy(h->value, value, UPYUN_MAX_HEADER_LEN); h->next = *headers; *headers = h; /* printf("New header:[%s]: [%s], %u, %u\n", h->name, h->value, size, */ /* nmemb); */ return size * nmemb; }
Cell read_pair(FILE *in) { int c; Cell car_obj; Cell cdr_obj; skip_space(in); c = getc(in); if (c == ')') { return null; } ungetc(c, in); car_obj = read(in); skip_space(in); c = getc(in); if (c == '.') { c = peek(in); if (!is_delimiter(c)) { fprintf(stderr, "dot not followed by delimiter\n"); exit(1); } cdr_obj = read(in); skip_space(in); c = getc(in); if (c != ')') { fprintf(stderr, "missing right paren\n"); exit(1); } return cons(car_obj, cdr_obj); } else { /* read list */ ungetc(c, in); cdr_obj = read_pair(in); return cons(car_obj, cdr_obj); } }
char* get_b_arg(struct expr_node **expr,char *p,int line_count) { struct expr_node *new_expr,*new_expr2,*new_expr3; char s1[MAXSTR]; p=get_arg(&new_expr,p,line_count); p=skip_space(p); if((*p=='\n')||(*p==',')) { *expr=new_expr; return p; } //if is_bool_op(p) if(is_bool_op(p,line_count)) { new_expr2=(struct expr_node*)malloc(sizeof(struct expr_node)); if(new_expr2==NULL) { sprintf(s1,"at line %d, error malloc exr_node",line_count);die(s1);} new_expr2->type=OP_BOOL; p=get_token(p); strncpy(new_expr2->str,my_token,MAXSTR); new_expr2->left=new_expr; new_expr2->right=NULL; p=skip_space(p); p=get_arg(&new_expr3,p,line_count); new_expr2->right=new_expr3; *expr=new_expr2; } return p; }
tree xml_html_parser::parse_doctype () { s += 9; tree dt= tuple ("doctype"); skip_space (); dt << parse_name (); skip_space (); if (test (s, "SYSTEM")) dt << parse_system (); else if (test (s, "PUBLIC")) dt << parse_public (); skip_space (); if (test (s, "[")) { s += 1; while (s) { skip_space (); if (test (s, "]")) { s += 1; break; } else if (test (s, "<!ELEMENT")) dt << parse_element (); else if (test (s, "<!ATTLIST")) dt << parse_cdata (); else if (test (s, "<!ENTITY")) parse_entity_decl (); else if (test (s, "<!NOTATION")) a << parse_notation (); else if (test (s, "<?")) dt << parse_pi (); else if (test (s, "<!--")) dt << parse_comment (); else if (s[0] == '&' || s[0] == '%') (void) parse_entity (); else s += 1; } } skip_space (); if (test (s, ">")) s += 1; return dt; }
static void map_cmd(const char **s) { if ( **s == '*' ) { range_from = 32; range_to = 255; map_to = 32; is_exclude = 0; (*s)++; skip_space(s); } else if ( **s == '~' ) { is_exclude = 1; map_to = 0; /*will be ignored */ (*s)++; skip_space(s); get_range(s); } else { is_exclude = 0; get_range(s); map_to = range_from; if ( **s == '>') { (*s)++; skip_space(s); map_to = get_add(s); } } }
int ft_atoi(const char *str) { int i; int mult; int ret; if (!str) return (0); else if (skip_space(str) < 0) return (0); i = skip_space(str); ret = 0; mult = 1; while (str[i] && is_char(str[i]) == 0 && i >= 0) { ret += ((str[i] - 48) * mult); mult *= 10; i--; } if (is_char(str[i]) >= 1 && is_char(str[i - 1]) == 1) return (0); else if (str[i] == '-' && ret > 0) ret *= -1; else if (str[i] == '\200') return (0); return (ret); }
int set_acceptance( char *line ) { unsigned char *lptr; unsigned char *endptr; /* unsigned char **endptr; */ unsigned int acm = 0xffffffff; unsigned int acc = 0xffffffff; Config_par_t cfg; volatile Command_par_t cmd; lptr = &line[0]; skip_space(lptr); acc = strtoul(lptr, &endptr, 0); lptr = endptr; skip_space(lptr); acm = strtoul(lptr, &endptr, 0); cmd.cmd = CMD_STOP; ioctl(can_fd, COMMAND, &cmd); /* high acceptance, low mask for 11 bit ID */ cfg.target = CONF_ACC; cfg.val1 = acm; cfg.val2 = acc; /* fprintf(stderr,"ACM=%04x\n", acm); */ ioctl(can_fd, CONFIG, &cfg); cmd.cmd = CMD_START; ioctl(can_fd, COMMAND, &cmd); }
/*...sadd_definition:0:*/ static void add_definition(const char *line) { LOOKUP *lookup; if ( (lookup = (LOOKUP *) malloc(sizeof(LOOKUP))) == NULL ) fatal("out of memory"); line = skip_space(line); if ( strncmp(line, "language_create", 15) || !isspace(line[15]) ) return; /* Is not a language definition line */ line = skip_space(line + 16); if ( (line = scan_quoted_str(line, lookup->name)) == NULL ) fatal("bad language name in initalisation file"); line = skip_space(line); if ( (line = scan_quoted_str(line, lookup->rc_st)) == NULL ) fatal("bad reserved Cmt.Start in initalisation file"); line = skip_space(line); if ( (line = scan_quoted_str(line, lookup->rc_end)) == NULL ) fatal("bad reserved Cmt.End in initalisation file"); line = skip_space(line); if ( (line = scan_quoted_str(line, lookup->reg_exp)) == NULL ) fatal("bad regular expression in initalisation file"); lookups[n_lookups++] = lookup; }
Variant JSONReader::parse_array() { if (!skip_char('[')) throw Exception(position(), "expected start of array"); Variant::Vector vector; skip_space(); while (!skip_char(']')) { vector.emplace_back(parse_value()); skip_space(); if (skip_char(',')) { skip_space(); if (at(']')) throw Exception(position(), "expected value instead of ] after ,"); } else if (!at(']')) { throw Exception(position(), "expected , or ]"); } } return Variant(std::move(vector)); }
static int parser_SetTextColor( char *psz_command, char *psz_end, commandparams_t *p_params ) { int r = 0, g = 0, b = 0; VLC_UNUSED(psz_end); skip_space( &psz_command ); if( isdigit( (unsigned char)*psz_command ) ) { if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC ) return VLC_EGENERIC; } skip_space( &psz_command ); if( isdigit( (unsigned char)*psz_command ) ) { if( parse_digit( &psz_command, &r ) == VLC_EGENERIC ) return VLC_EGENERIC; } skip_space( &psz_command ); if( isdigit( (unsigned char)*psz_command ) ) { if( parse_digit( &psz_command, &g ) == VLC_EGENERIC ) return VLC_EGENERIC; } skip_space( &psz_command ); if( isdigit( (unsigned char)*psz_command ) ) { if( parse_digit( &psz_command, &b ) == VLC_EGENERIC ) return VLC_EGENERIC; } p_params->fontstyle.i_font_color = (r<<16) | (g<<8) | (b<<0); return VLC_SUCCESS; }
int write_message( int format, /* if true - extended message format */ char *line /* write parameter line */ ) { unsigned char data[8] = {8, 7, 6, 5, 4, 3 , 2, 1}; unsigned char *lptr; int len = 0; /* unsigned char **endptr; */ unsigned char *endptr; canmsg_t tx; /* build transmit message */ /* May be some check is needed if we have a valid and useful message */ lptr = &line[0]; skip_space(lptr); tx.flags = 0; if(format == 1) { tx.flags |= MSG_EXT; } else { } if(*lptr == 'r' || *lptr == 'R') { tx.flags |= MSG_RTR; skip_word(lptr); } skip_space(lptr); tx.id = strtoul(lptr, &endptr, 0); tx.cob = 0; while( lptr != endptr) { lptr = endptr; tx.data[len] = (signed char)strtol(lptr, &endptr, 0); if(lptr != endptr) len++; if (len == 8 ) break; } tx.length = len; BDEBUG("Transmit %d, RTR=%s, len=%d\n", tx.id, ((tx.flags == 0) ? "F" : "T"), tx.length); len = write(can_fd, &tx, 1); if (len < 0) { /* Write Error */ printf("Write Error: %d\n", len); } if (len == 0) { /* Transmit Timeout */ printf("Write Error: Transmit fehlgeschlagen\n", len); } return 0; }
static void parse_line(char *ptr, char **varname, char **varval) { /* Skip over any leading spaces */ ptr = skip_space(ptr); /* The first no-space is the beginning of the variable name */ *varname = skip_space(ptr); *varval = NULL; /* Parse to the end of the variable name */ ptr = find_name_end(ptr); /* An equal sign is expected next, perhaps after some white space */ if (*ptr && *ptr != '=') { /* Some else follows the variable name. Terminate the variable * name and skip over any spaces. */ *ptr = '\0'; ptr = skip_space(ptr + 1); } /* Verify that the equal sign is present */ if (*ptr == '=') { /* Make sure that the variable name is terminated (this was already * done if the name was followed by white space. */ *ptr = '\0'; /* The variable value should follow =, perhaps separated by some * white space. */ ptr = skip_space(ptr + 1); if (*ptr) { /* Yes.. a variable follows. Save the pointer to the start * of the variable string. */ *varval = ptr; /* Find the end of the variable string and make sure that it * is terminated. */ ptr = find_value_end(ptr); *ptr = '\0'; } } }
static bool parse_pair(const char buffer[], char key[], char value[]) { const char *start; const char *end; key[0] = value[0] = '\0'; /* * parse key */ start = buffer; if ((start = skip_space(start, buffer)) == NULL) return false; end = start + strcspn(start, "=# \n\r\t\v"); /* skip blank buffer */ if (end - start <= 0) { if (*start == '=') elog(WARNING, "syntax error in \"%s\"", buffer); return false; } /* key found */ strncpy(key, start, end - start); key[end - start] = '\0'; /* find key and value split char */ if ((start = skip_space(end, buffer)) == NULL) return false; if (*start != '=') { elog(WARNING, "syntax error in \"%s\"", buffer); return false; } start++; /* * parse value */ if ((end = get_next_token(start, value, buffer)) == NULL) return false; if ((start = skip_space(end, buffer)) == NULL) return false; if (*start != '\0' && *start != '#') { elog(WARNING, "syntax error in \"%s\"", buffer); return false; } return true; }
static enum STATE read_tag ( FILE* file, struct xml_element* elem ) { int c = fgetc( file ); if ( c != '<' ) return PARSE_ERROR; c = fgetc( file ); if ( c == EOF ) return PARSE_ERROR; if( c == '?' || c == '!' ) return read_special_tag( file, elem ); bool close_tag = false; if ( c == '/' ) close_tag = true; else ungetc( c, file ); skip_space( file ); struct string str = init_str; c = fgetc( file ); if ( c == '>' ) return PARSE_ERROR; while ( c != '>' && c != '/' && !isspace(c) ) { if ( c == EOF || str_push_back( c, &str ) != OK ) { free( str.str ); return ( c == EOF ) ? PARSE_ERROR : MEMORY_ERROR; } c = fgetc( file ); } if ( close_tag ) { if ( c == '/' || strcmp( str.str, elem->father->name ) != 0 ) { free( str.str ); return PARSE_ERROR; } if ( c != '>') { skip_space( file ); if ( fgetc( file ) != '>' ) { free( str.str ); return PARSE_ERROR; } } free( str.str ); return CLOSE_TAG; } str_remove_trail_space( &str ); elem->name = str.str; ungetc( c, file ); return read_attr( file, elem ); }
string xml_html_parser::transcode (string s2) { s= parse_string (s2); string encoding; if (test (s, "<?")) { s += 2; string target= parse_name (); skip_space (); if (target == "xml") { // since html==true implies we can accept horribly broken HTML, the // presence of an XML prolog is not enough to clear the flag. /* html= false; */ while (s && !test (s, "?>")) { string attname= parse_name (); skip_space (); if (!test (s, "=")) break; s += 1; skip_space (); string val; if (test (s, "\"")) { s += 1; val= parse_until ("\""); skip_space (); } else if (test (s, "'")) { s += 1; val= parse_until ("'"); skip_space (); } if (attname == "encoding") { encoding= upcase_all (val); break; } } } } if (N(encoding) != 0) { // cout << "encoding was specified\n" ; string s3= convert (s2, encoding, "UTF-8"); if (N(s3) == 0) /* conversion from specified charset failed, do nothing (and pray) */ ; else return s3; } else { // cout << "guess encoding\n" ; if (check_encoding (s2, "UTF-8")) /* input encoding seems to be utf-8, do nothing */ ; else { string s3= convert (s2, "ISO-8859-1", "UTF-8"); if (N(s3) != 0) return s3; } } return s2; }
tree xml_html_parser::parse_public () { s += 6; tree st= tuple ("public"); skip_space (); st << parse_quoted (); skip_space (); st << parse_quoted (); return st; }
int parse_svr(config_t* pi, void * value, int offset, FILE* fp) { char* v = value; char* ipend; int ret; struct in_addr ip; int weight = 0; lbg_service_t* newone; offset = offset; fp = fp; v = skip_space(v); ipend = strchr(v,','); if(ipend){ *ipend = 0; ipend++; ret = inet_pton(AF_INET,v,(void*)&ip);/* host to net */ if (ret < 0){ return -1; } ipend[strlen(ipend)-1] = 0; ipend = skip_space(ipend); weight = atoi(ipend); if (weight <= 0){ return -2; } if(weight > 255) weight = 255; } else return -3; newone = malloc(sizeof(lbg_service_t)); if(newone){ newone->ip = (ip.s_addr);/* */ newone->weight = weight; newone->next = NULL; pi->server_num++; if(pi->head == NULL){ pi->head = newone; pi->end = newone; } else { pi->end->next = newone; pi->end = newone; } } return 0; }
int expression(void) { int value = 0; char op = 0, ch = 0; skip_space(); ch = str[idx]; if (ch == '\0') { return 0; } if (ch == '(') { idx += 1; /* read '(' */ value = expression(); skip_space(); idx += 1; /* read ')' */ skip_space(); if (is_operator()) { op = operator(); /*printf("%d|%c ", order++, op);*/ int v = expression(); return do_num(op, value, v); } else { return value; } } else if (ch == '_' || isdigit(ch)) { int num = number(); /*printf("%d|%d ", order++, num);*/ skip_space(); if (is_operator()) { op = operator(); /*printf("%d|%c ", order++, op);*/ value = expression(); return do_num(op, num, value); } else { return num; } } else { char var = variable(); /*printf("%d|%c ", order++, var);*/ skip_space(); if (is_operator()) { op = operator(); /*printf("%d|%c ", order++, op);*/ value = expression(); return do_var(op, var, value); } else { return vars[var - 'A']; } } }
struct mesh *obj_read(const char *file) { FILE *f; char line[512]; const char *str; struct mesh *mesh; int has_normals = 0; if (!(f = fopen(file, "r"))) return NULL; mesh = mesh_create(); while (!feof(f)) { if (!fgets(line, sizeof(line), f)) break; str = line; if (strncmp(str, "v ", 2) == 0) { /* Vertex command */ vector v; sscanf(str, "v %f %f %f", v, v + 1, v + 2); mesh_add_vertex(mesh, v); } else if (strncmp(str, "vn ", 3) == 0) { /* Normal command */ vector n; sscanf(str, "vn %f %f %f", n, n + 1, n + 2); mesh_add_normal(mesh, n); } else if (strncmp(str, "f ", 2) == 0) { /* Face command */ int vi, ti, ni; mesh_begin_face(mesh); str = skip_space(++str); /* Skip 'f ' */ while (*str) { vi = ti = ni = 0; if (sscanf(str, "%d/%d/%d", &vi, &ti, &ni) == 3) has_normals = 1; mesh_add_index(mesh, vi - 1, ni - 1); str = skip_non_space(str); str = skip_space(str); } mesh_end_face(mesh); } } fclose(f); if (!has_normals) mesh_compute_normals(mesh); return mesh; }
static enum STATE read_attr ( FILE* file, struct xml_element* elem ) { enum STATE state; skip_space( file ); int c = fgetc( file ); if ( c == EOF || c == '=' ) return PARSE_ERROR; if ( c == '/' ) { skip_space( file ); c = fgetc( file ); return ( c == '>' ) ? ISOLATED_TAG : PARSE_ERROR; } if ( c == '>' ) return OPEN_TAG; ungetc( c, file ); struct xml_attribute* attr = calloc( 1, sizeof( struct xml_attribute ) ); if ( !attr ) return MEMORY_ERROR; attr->father = elem; attr->status = IS_ATTRIBUTE_STATUS; state = read_attr_name( file, attr ); if ( state != OK ) { free( attr ); return state; } c = fgetc( file ); if ( c != '=' ) { free( attr->name ); free( attr ); return PARSE_ERROR; } skip_space( file ); state = read_attr_value( file, attr ); if ( state != OK ) { free( attr->name ); free( attr ); return state; } state = read_attr( file, elem ); attr->next = elem->attr; elem->attr = attr; if ( attr->next ) attr->next->prev = attr; return state; }
void bootcompile( void ) { for( skip_space(); flag; skip_space() ) { get_name(); find(); // if( !flag ) {printf( "not found \n"); exit(1);} if( !flag ) { writechar( 'Z' ); for(;;); } *--sp = (cell) &cptr; append(); } ascii_to_literal( "exit" ); find(); *--sp = (cell) &cptr ; append(); }
/* Return cstr on success, NULL on failure. */ struct cookie_str * parse_cookie_str(struct cookie_str *cstr, unsigned char *str) { memset(cstr, 0, sizeof(*cstr)); cstr->str = str; /* Parse name token */ while (*str != ';' && *str != '=' && !isspace(*str) && *str) str++; /* Bail out if name token is empty */ if (str == cstr->str) return NULL; cstr->nam_end = str; skip_space(str); switch (*str) { case '\0': case ';': /* No value token, so just set to empty value */ cstr->val_start = str; cstr->val_end = str; return cstr; case '=': /* Map 'a===b' to 'a=b' */ do str++; while (*str == '='); break; default: /* No spaces in the name token is allowed */ return NULL; } skip_space(str); /* Parse value token */ /* Start with empty value, so even 'a=' will work */ cstr->val_start = str; cstr->val_end = str; for (; *str != ';' && *str; str++) { /* Allow spaces in the value but leave out ending spaces */ if (!isspace(*str)) cstr->val_end = str + 1; } return cstr; }
/** * write_stuff - handle writing of MAC registers / eeprom */ static void write_stuff(char *line) { char dest; char *endp; u8 reg; u32 value; /* Skip over the "W " part of the command */ line = skip_space(line + 1); /* Figure out destination */ switch (line[0]) { case 'E': case 'M': dest = line[0]; break; default: invalid_usage: printf("ERROR: Invalid write usage\n"); usage(); return; } /* Get the register to write */ line = skip_space(line + 1); reg = simple_strtoul(line, &endp, 16); if (line == endp) goto invalid_usage; /* Get the value to write */ line = skip_space(endp); value = simple_strtoul(line, &endp, 16); if (line == endp) goto invalid_usage; /* Check for trailing cruft */ line = skip_space(endp); if (line[0]) goto invalid_usage; /* Finally, execute the command */ if (dest == 'E') { printf("Writing EEPROM register %02x with %02x\n", reg, value); write_eeprom_reg(value, reg); } else { printf("Writing MAC register %02x with %08x\n", reg, value); smc911x_reg_write(CONFIG_DRIVER_SMC911X_BASE + reg, value); } }
/* Parse string param="value", return value as new string or NULL if any * error. */ unsigned char * get_header_param(unsigned char *e, unsigned char *name) { unsigned char *n, *start; again: while (*e && c_toupper(*e++) != c_toupper(*name)); if (!*e) return NULL; n = name + 1; while (*n && c_toupper(*e) == c_toupper(*n)) e++, n++; if (*n) goto again; skip_space(e); if (*e++ != '=') return NULL; skip_space(e); start = e; if (!isquote(*e)) { skip_nonspace(e); } else { unsigned char uu = *e++; start++; while (*e != uu) { if (!*e) return NULL; e++; } } while (start < e && *start == ' ') start++; while (start < e && *(e - 1) == ' ') e--; if (start == e) return NULL; n = mem_alloc(e - start + 1); if (n) { int i = 0; while (start < e) { n[i++] = (*start < ' ') ? '.' : *start; start++; } n[i] = '\0'; } return n; }
/* * Copy :first-line|letter */ static void copy_first(const rchar **source_, rchar **target_, rcssmin_ctx_t *ctx) { const rchar *source = *source_, *next, *source_fork; rchar *target = *target_, *target_fork; *target++ = U(':'); *target_ = target; if (!IMATCH(first, &source, &target, ctx) || !(source < ctx->sentinel && target < ctx->tsentinel)) ABORT; source_fork = source; target_fork = target; if (!IMATCH(line, &source, &target, ctx)) { source = source_fork; target = target_fork; if (!IMATCH(letter, &source, &target, ctx) || !(source < ctx->sentinel && target < ctx->tsentinel)) ABORT; } next = skip_space(source, ctx); if (!(next < ctx->sentinel && target < ctx->tsentinel && (*next == U('{') || *next == U(',')))) ABORT; *target++ = U(' '); *target_ = target; *source_ = source; (void)copy_space_optional(source_, target_, ctx); }
static int proxy_probe_no_proxy(unsigned char *url, unsigned char *no_proxy) { unsigned char *slash = (unsigned char *)strchr((char *)url, '/'); if (slash) *slash = '\0'; while (no_proxy && *no_proxy) { unsigned char *jumper = (unsigned char *)strchr((char *)no_proxy, ','); skip_space(no_proxy); if (jumper) *jumper = '\0'; if (c_strcasestr((const char *)url, (const char *)no_proxy)) { if (jumper) *jumper = ','; if (slash) *slash = '/'; return 1; } no_proxy = jumper; if (jumper) { *jumper = ','; no_proxy++; } } if (slash) *slash = '/'; return 0; }
int set_bitrate( char *line ) { extern int o_bitrate; unsigned char *lptr; unsigned char *endptr; /* unsigned char **endptr; */ Config_par_t cfg; volatile Command_par_t cmd; /* default */ o_bitrate = 125; lptr = &line[0]; skip_space(lptr); o_bitrate = strtoul(lptr, &endptr, 0); cmd.cmd = CMD_STOP; ioctl(can_fd, COMMAND, &cmd); /* high acceptance, low mask for 11 bit ID */ cfg.target = CONF_TIMING; cfg.val1 = o_bitrate; /* fprintf(stderr,"ACM=%04x\n", acm); */ ioctl(can_fd, CONFIG, &cfg); cmd.cmd = CMD_START; ioctl(can_fd, COMMAND, &cmd); }
/******************************************************************* * get_temp_ibm reads temperatures from /proc/acpi/ibm/thermal and * returns the highest one found. *******************************************************************/ int get_temp_ibm() { int i=0, res, retval=0, ibm_temp, *tmp; ssize_t r; char *input; input = rbuf; if (unlikely(((ibm_temp = open(IBM_TEMP, O_RDONLY)) < 0) || ((r = read(ibm_temp, rbuf, 128)) < 14) || (close(ibm_temp) < 0))) { report(LOG_ERR, LOG_ERR, IBM_TEMP ": %s", strerror(errno)); errcnt++; return ERR_T_GET; } rbuf[r] = 0; skip_space(&input); if (likely(parse_keyword(&input, temperatures) != NULL)) { for (i = 0; ((tmp = parse_int(&input)) && (i < 16)); i++) { res = *tmp + config->sensors->bias[i]; if (res > retval) retval = res; free(tmp); } if (unlikely(i < 2)) { report(LOG_ERR, LOG_ERR, MSG_ERR_T_GET); errcnt++; retval = ERR_T_GET; } } else { report(LOG_ERR, LOG_ERR, MSG_ERR_T_PARSE(rbuf)); errcnt++; retval = ERR_T_GET; } return retval; }
int Dfa::get_next_token_longest(string &ret_token) { ret_token == ""; if(!skip_space()) return 1; const Node* node = _start; auto start_pos = _pos; while(_pos < _len){ char path_char = static_cast<char>(_str[_pos]); if(node->next(path_char) == nullptr){ if(node->is_end_node()){ ret_token = _str.substr(start_pos, _pos - start_pos); return 0; }else { _pos = start_pos; return -1; } } node = node->next(path_char); ++_pos; } if(node->is_end_node()){ ret_token = _str.substr(start_pos, _pos - start_pos); return 0; }else { _pos = start_pos; return -1; } }
static long get_hex(const char **s) { long v = 0; for(;;) { if ( (**s) >= '0' && (**s) <= '9' ) { v*=16; v+= (**s)-'0'; (*s)++; } else if ( (**s) >= 'a' && (**s) <= 'f' ) { v*=16; v+= (**s)-'a'+10; (*s)++; } else if ( (**s) >= 'A' && (**s) <= 'F' ) { v*=16; v+= (**s)-'A'+10; (*s)++; } else { break; } } skip_space(s); return v; }