Exemplo n.º 1
0
Arquivo: rc.c Projeto: galexcode/w3m
int
set_param_option(char *option)
{
    Str tmp = Strnew();
    char *p = option, *q;

    while (*p && !IS_SPACE(*p) && *p != '=')
	Strcat_char(tmp, *p++);
    while (*p && IS_SPACE(*p))
	p++;
    if (*p == '=') {
	p++;
	while (*p && IS_SPACE(*p))
	    p++;
    }
    Strlower(tmp);
    if (set_param(tmp->ptr, p))
	goto option_assigned;
    q = tmp->ptr;
    if (!strncmp(q, "no", 2)) {	/* -o noxxx, -o no-xxx, -o no_xxx */
	q += 2;
	if (*q == '-' || *q == '_')
	    q++;
    }
    else if (tmp->ptr[0] == '-')	/* -o -xxx */
	q++;
    else
	return 0;
    if (set_param(q, "0"))
	goto option_assigned;
    return 0;
  option_assigned:
    return 1;
}
Exemplo n.º 2
0
Arquivo: rc.c Projeto: galexcode/w3m
static void
interpret_rc(FILE * f)
{
    Str line;
    Str tmp;
    char *p;

    for (;;) {
	line = Strfgets(f);
	Strchop(line);
	if (line->length == 0)
	    break;
	Strremovefirstspaces(line);
	if (line->ptr[0] == '#')	/* comment */
	    continue;
	tmp = Strnew();
	p = line->ptr;
	while (*p && !IS_SPACE(*p))
	    Strcat_char(tmp, *p++);
	while (*p && IS_SPACE(*p))
	    p++;
	Strlower(tmp);
	set_param(tmp->ptr, p);
    }
}
Exemplo n.º 3
0
char *KLineFile::readLine() {
    if (hot == NULL) {
        return NULL;
    }
    while (*hot && IS_SPACE(*hot))
        hot++;
    if (*hot == '\0') {
        return NULL;
    }
    char *p = hot;
    char *end = strchr(hot, '\n');
    if (end == NULL) {
        if (strlen(hot) < 1) {
            return NULL;
        }
        end = hot + strlen(hot) - 1;
        hot = NULL;
    }
    hot = end + 1;
    while (end != p && IS_SPACE(*end)) {
        *end = '\0';
        end--;
    }
    return p;
}
Exemplo n.º 4
0
static int	get_file_name_len(const char *str)
{
  int		len;
  const char	*save;

  save = str;
  while (IS_SPACE(*str))
    ++str;
  if (!(*str) || (IS_DELIM(*str)))
    return (return_error(MISS_NAME_DIR, END_CHAR));
  while ((*str) && !(IS_SPACE(*str)) && !(IS_DELIM(*str)))
    {
      if (IS_QUOTE(*str))
	{
	  if ((len = pass_quote(str)) == -1)
	    return (return_error(UNMATCH_QUOTE, *str));
	  str += len;
	}
      else if (*str == B_SLASH)
	{
	  if (!(*(++str)))
	    return (return_error(MISS_SLASH, END_CHAR));
	}
      ++str;
    }
  return (str - save);
}
Exemplo n.º 5
0
static int add_rule(rt_data_t *rdata, char *grplst, str *prefix, rt_info_t *rule)
{
	long int t;
	char *tmp;
	char *ep;
	int n;

	tmp=grplst;
	n=0;
	/* parse the grplst */
	while(tmp && (*tmp!=0)) {
		errno = 0;
		t = strtol(tmp, &ep, 10);
		if (ep == tmp) {
			LM_ERR("bad grp id '%c' (%d)[%s]\n",
				*ep, (int)(ep-grplst), grplst);
			goto error;
		}
		if ((!IS_SPACE(*ep)) && (*ep != SEP) && (*ep != SEP1) && (*ep!=0)) {
			LM_ERR("bad char %c (%d) [%s]\n",
					*ep, (int)(ep-grplst), grplst);
			goto error;
		}
		if (errno == ERANGE && (t== LONG_MAX || t== LONG_MIN)) {
			LM_ERR("out of bounds\n");
			goto error;
		}
		n++;
		/* add rule -> has prefix? */
		if (prefix->len) {
			/* add the routing rule */
			if ( add_prefix(rdata->pt, prefix, rule, (unsigned int)t)!=0 ) {
				LM_ERR("failed to add prefix route\n");
					goto error;
			}
		} else {
			if ( add_rt_info( &rdata->noprefix, rule, (unsigned int)t)!=0 ) {
				LM_ERR("failed to add prefixless route\n");
					goto error;
			}
		}
		/* keep parsing */
		if(IS_SPACE(*ep))
			EAT_SPACE(ep);
		if(ep && (*ep == SEP || *ep == SEP1))
			ep++;
		tmp = ep;
	}

	if(n==0) {
		LM_ERR("no id in grp list [%s]\n",
			grplst);
		goto error;
	}

	return 0;
error:
	return -1;
}
Exemplo n.º 6
0
//
//  Temp_Byte_Chars_May_Fail: C
// 
// NOTE: This function returns a temporary result, and uses an internal
// buffer.  Do not use it recursively.  Also, it will Trap on errors.
// 
// Prequalifies a string before using it with a function that
// expects it to be 8-bits.  It would be used for instance to convert
// a string that is potentially REBUNI-wide into a form that can be used
// with a Scan_XXX routine, that is expecting ASCII or UTF-8 source.
// (Many TO-XXX conversions from STRING re-use that scanner logic.)
// 
// Returns a temporary string and sets the length field.
// 
// If `allow_utf8`, the constructed result is converted to UTF8.
// 
// Checks or converts it:
// 
//     1. it is byte string (not unicode)
//     2. if unicode, copy and return as temp byte string
//     3. it's actual content (less space, newlines) <= max len
//     4. it does not contain other values ("123 456")
//     5. it's not empty or only whitespace
//
REBYTE *Temp_Byte_Chars_May_Fail(
    const REBVAL *val,
    REBINT max_len,
    REBCNT *length,
    REBOOL allow_utf8
) {
    REBCNT tail = VAL_LEN_HEAD(val);
    REBCNT index = VAL_INDEX(val);
    REBCNT len;
    REBUNI c;
    REBYTE *bp;
    REBSER *src = VAL_SERIES(val);

    if (index > tail) fail (Error(RE_PAST_END));

    Resize_Series(BYTE_BUF, max_len+1);
    bp = BIN_HEAD(BYTE_BUF);

    // Skip leading whitespace:
    for (; index < tail; index++) {
        c = GET_ANY_CHAR(src, index);
        if (!IS_SPACE(c)) break;
    }

    // Copy chars that are valid:
    for (; index < tail; index++) {
        c = GET_ANY_CHAR(src, index);
        if (c >= 0x80) {
            if (!allow_utf8) fail (Error(RE_INVALID_CHARS));

            len = Encode_UTF8_Char(bp, c);
            max_len -= len;
            bp += len;
        }
        else if (!IS_SPACE(c)) {
            *bp++ = (REBYTE)c;
            max_len--;
        }
        else break;
        if (max_len < 0)
            fail (Error(RE_TOO_LONG));
    }

    // Rest better be just spaces:
    for (; index < tail; index++) {
        c = GET_ANY_CHAR(src, index);
        if (!IS_SPACE(c)) fail (Error(RE_INVALID_CHARS));
    }

    *bp = '\0';

    len = bp - BIN_HEAD(BYTE_BUF);
    if (len == 0) fail (Error(RE_TOO_SHORT));

    if (length) *length = len;

    return BIN_HEAD(BYTE_BUF);
}
Exemplo n.º 7
0
/*
 * JamGetProp
 *
 *      Parse a text buffer of property name-value pairs and return
 *      the value of the property identified by <propName>. <buffer>
 *      is a NUL-terminated string containing text in the following format:
 *
 *              "Prop-Name1: prop value 1\nProp-Name2: prop value 2..."
 *
 * Return-value:
 *
 *      A pointer into the buffer of the first non-space character of
 *      the property value. <*length> returns the length of the property
 *      value, excluding any trailing white-space characters.
 *
 *      If the given property is not found in <buffer>, NULL is returned.
 */
char* JamGetProp(char* buffer, char* name, int* length) {
    char* p;
    char* retval;
    int len;

    for (p=buffer;*p;) {
        if (strncmp(p, name, strlen(name)) != 0) {
            while (*p) {
                if (*p == '\n') {
                    ++p;
                    break;
                }
                ++ p;
            }
            continue;
        }
        p += strlen(name);
        while (*p && *p != '\n' && IS_SPACE(*p)) {
            p++;
        }
        if (*p == ':') {
            p++;
        }
        while (*p && *p != '\n' && IS_SPACE(*p)) {
            p++;
        }
        retval = p;
        while (*p && *p != '\n') {
            p++;
        }
        while (p > retval && IS_SPACE(*p)) {
            p--;
        }
        len = (p - retval + 1);

        if (length == NULL) { /* DUP the string */
            char * newStr;
            if ((newStr = browser_malloc(len + 1)) == NULL) {
                return NULL;
            }
            strnzcpy(newStr, retval, len);
            newStr[len] = 0;
            for (p=newStr; *p; p++) {
                if (*p == '\r') {
                    *p = '\0';
                }
            }
            return newStr;
        } else {
            *length = len;
            return retval;
        }
    }
    return NULL;
}
Exemplo n.º 8
0
Arquivo: lang.c Projeto: stiletto/oops
/* change content of object, actually not send it */
MODULE_STATIC
int
output(int so, struct output_object *obj, struct request *rq, int *flags)
{
char		*content_type, *agent = NULL, *p, *charset_name, *new_conttype;
struct	charset	*cs = NULL;
struct	av	*ct_av = NULL;

    if ( !rq || !obj || !obj->body || !obj->headers )
	return(MOD_CODE_OK);
    ct_av = lookup_av_by_attr(obj->headers, "Content-Type");
    if ( !ct_av )
	return(MOD_CODE_OK);
    content_type = ct_av->val;
    if ( !content_type )
	return(MOD_CODE_OK);
    p = content_type;
    while( *p && IS_SPACE(*p) ) p++;
    if ( strncasecmp(p, "text/html", 9) && strncasecmp(p, "text/plain", 10) )
	return(MOD_CODE_OK);
    /* parse parameters and return if charset is already here */
    while ( (p = strchr(p, ';')) ) {
	p++;
	while( *p && IS_SPACE(*p) ) p++;
	if ( !strncasecmp(p, "charset=", 8) )
		return(MOD_CODE_OK);
    }

    if ( rq->av_pairs ) agent = attr_value(rq->av_pairs, "User-Agent");
    if ( !agent )
	return(MOD_CODE_OK);

    RDLOCK_LANG_CONFIG ;
    if ( agent && charsets )
	cs = lookup_charset_by_Agent(charsets, agent);
    if ( cs ) charset_name = cs->Name;
	else  charset_name = default_charset;
    if ( !charset_name || !*charset_name ) {
	UNLOCK_LANG_CONFIG ;
	return(MOD_CODE_OK);
    }
    /* set up charset */
    new_conttype = malloc(10+strlen(content_type)+strlen(charset_name)+1);
    if ( new_conttype ) {
	sprintf(new_conttype,"%s; charset=%s", content_type, charset_name);
	xfree(ct_av->val);
	ct_av->val = new_conttype;
	if ( cs ) {
	    recode_buff(obj->body, cs);
	}
    }
    UNLOCK_LANG_CONFIG ;

    return(MOD_CODE_OK);
}
inline static int add_header_av(char* avtext, struct mem_obj *obj)
{
    struct	av	*new_t = NULL, *next;
    char		*attr = avtext, *sp = avtext, *val, holder;
    char		*new_attr = NULL, *new_val = NULL;
    char		nullstr[1];

    if ( *sp == 0 ) return(-1);
    while( *sp && IS_SPACE(*sp) ) sp++;
    while( *sp && !IS_SPACE(*sp) && (*sp != ':') ) sp++;
    if ( !*sp ) {
        my_xlog(OOPS_LOG_NOTICE|OOPS_LOG_DBG|OOPS_LOG_INFORM, "add_header_av(): Invalid header string: '%s'\n", avtext);
        nullstr[0] = 0;
        sp = nullstr;
    }
    if ( *sp == ':' ) sp++;
    holder = *sp;
    *sp = 0;
    if ( !strlen(attr) ) return(-1);
    new_t = (struct av *)xmalloc(sizeof(*new_t), "add_header_av(): for av pair");
    if ( !new_t ) goto failed;
    new_attr = (char *)xmalloc( strlen(attr)+1, "add_header_av(): for new_attr" );
    if ( !new_attr ) goto failed;
    strcpy(new_attr, attr);
    *sp = holder;
    val = sp;
    while( *val && IS_SPACE(*val) ) val++;
    /*if ( !*val ) goto failed;*/
    new_val = (char *)xmalloc( strlen(val) + 1, "add_header_av(): for new_val");
    if ( !new_val ) goto failed;
    strcpy(new_val, val);
    new_t->attr = new_attr;
    new_t->val  = new_val;
    new_t->next = NULL;
    if ( !obj->headers ) {
        obj->headers = new_t;
    } else {
        next = obj->headers;
        while (next->next) next=next->next;
        next->next=new_t;
    }
    return(0);

failed:
    *sp = holder;
    if ( new_t ) free(new_t);
    if ( new_attr ) free(new_attr);
    if ( new_val ) free(new_val);
    return(-1);
}
Exemplo n.º 10
0
void trim(const char *str, char *buf) {
	strcpy(buf, str);
	char *tail, *head;
	for (tail = buf + strlen(buf) - 1; tail >= buf; tail--) {
		if (!IS_SPACE(*tail))
			break;
	}
	tail[1] = 0;
	for (head = buf; head <= tail; head++) {
		if (!IS_SPACE(*head))
			break;
	}
	if (head != buf)
		memcpy(buf, head, (tail - head + 2) * sizeof(char));
}
Exemplo n.º 11
0
static char *xml_meta_attr_value(ACL_XML3_ATTR *attr, char *data)
{
	ACL_XML3 *xml = attr->node->xml;
	int   ch;

	SKIP_SPACE(data);
	if (IS_QUOTE(*data))
		attr->quote = *data++;

	if (*data == 0)
		return data;

	if (attr->value == xml->addr)
		attr->value = data;

	while ((ch = *data) != 0) {
		if (attr->quote && ch == attr->quote) {
			attr->value_size = data - attr->value;
			*data++ = 0;
			break;
		} else if (IS_SPACE(ch)) {
			attr->value_size = data - attr->value;
			*data++ = 0;
			break;
		}

		data++;
	}

	return data;
}
Exemplo n.º 12
0
/** 先頭パラメータの発見

	@param[in] end buf末尾
	@param[in] p 解析の現在位置
	
	パラメータが0個と1個以上の判別のために状態を設けている.
*/
const wchar_t* COutlineErlang::ScanArgs1( const wchar_t* end, const wchar_t* p )
{
	assert( m_state == STATE_FUNC_ARGS1 );
	
	while( IS_SPACE( *p ) && p < end )
		p++;

	if( p >= end )
		return end;

	if( *p == /* ( */ L')' ){
		// no argument
		m_state = STATE_FUNC_ARGS_FIN;
		p++;
	}
	else if( IS_COMMENT( *p )){
		return end;
	}
	else {
		// argument found
		m_state = STATE_FUNC_ARGS;
		++m_argcount;
	}
	return p;
}
Exemplo n.º 13
0
    static int			/* 0 | ply depth of pv ending with '#' */
epd_pv_plies( EpdJob* ejp )
{
    register char*	p;
    register char*	q;
    int			plies;

    plies = 0;
    q = 0;
    p = epd_find_op_opnds(ejp, "pv");
    if( p ) {
	SKIP_SPACE(p);
	while( *p ) {
	    plies += 1;
	    while( *p && !IS_SPACE(*p) ) {
		q = p; ++p;
	    }
	    SKIP_SPACE(p);
	}
	if( !q || (q[0] != '#') ) {	/* no mate indicator at end ... */
	    plies = 0;			/* ... so we know nothing */
	}
    }
    return plies;
}
Exemplo n.º 14
0
static const char *xml_parse_left_tag(ACL_XML *xml, const char *data)
{
	int   ch;

	if (LEN(xml->curr_node->ltag) == 0) {
		SKIP_SPACE(data);
	}

	while ((ch = *data) != 0) {
		data++;
		if (ch == '>') {
			xml->curr_node->status = ACL_XML_S_LGT;
			xml_parse_check_self_closed(xml);
			if ((xml->curr_node->flag & ACL_XML_F_SELF_CL)
				&& xml->curr_node->last_ch == '/')
			{
				acl_vstring_truncate(xml->curr_node->ltag,
					LEN(xml->curr_node->ltag) - 1);
			}
			break;
		} else if (IS_SPACE(ch)) {
			xml->curr_node->status = ACL_XML_S_ATTR;
			xml->curr_node->last_ch = ch;
			break;
		} else {
			ACL_VSTRING_ADDCH(xml->curr_node->ltag, ch);
			xml->curr_node->last_ch = ch;
		}
	}

	ACL_VSTRING_TERMINATE(xml->curr_node->ltag);
	return (data);
}
void dxSAPSpace::cleanGeoms()
{
    int dirtySize = DirtyList.size();
    if( !dirtySize )
        return;

    // compute the AABBs of all dirty geoms, clear the dirty flags,
    // remove from dirty list, place into geom list
    lock_count++;

    int geomSize = GeomList.size();
    GeomList.setSize( geomSize + dirtySize ); // ensure space in geom list

    for( int i = 0; i < dirtySize; ++i ) {
        dxGeom* g = DirtyList[i];
        if( IS_SPACE(g) ) {
            ((dxSpace*)g)->cleanGeoms();
        }
        g->recomputeAABB();
        g->gflags &= (~(GEOM_DIRTY|GEOM_AABB_BAD));
        // remove from dirty list, add to geom list
        GEOM_SET_DIRTY_IDX( g, GEOM_INVALID_IDX );
        GEOM_SET_GEOM_IDX( g, geomSize + i );
        GeomList[geomSize+i] = g;
    }
    // clear dirty list
    DirtyList.setSize( 0 );

    lock_count--;
}
Exemplo n.º 16
0
static bool MimeUntypedText_uu_end_line_p(const char *line, int32_t length) {
#if 0
  /* A strictly conforming uuencode end line. */
  return (line[0] == 'e' &&
      line[1] == 'n' &&
      line[2] == 'd' &&
      (line[3] == 0 || IS_SPACE(line[3])));
#else
  /* ...but, why don't we accept any line that begins with the three
   letters "END" in any case: I've seen lots of partial messages
   that look like

    BEGIN----- Cut Here-----
    begin 644 foo.gif
    Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    END------- Cut Here-----

   so let's be lenient here.  (This is only for the untyped-text-plain
   case -- the uudecode parser itself is strict.)
   */
  return (line[0] == ' ' || line[0] == '\t' ||
          ((line[0] == 'e' || line[0] == 'E') &&
           (line[1] == 'n' || line[1] == 'N') &&
           (line[2] == 'd' || line[2] == 'D')));
#endif
}
Exemplo n.º 17
0
Arquivo: parser.c Projeto: badcodes/c
int gettag(FILE* html,char* tag)
{
    int c=0;
    char* p=tag;
    int lim=MAX_TAG-2;

    do {
        c=NEXT_CHAR(html);
        if (c==EOF) break;
    } while (c!='<');

    if (c==EOF) goto END_OF_FILE;

    SKIP_WS(html,c);

    do {
        if (lim--<0) break;
        *tag++=c;
        c=NEXT_CHAR(html);
    } while (!IS_SPACE(c));

    *tag='\0';
    return 1;
    END_OF_FILE:
    *tag='\0';
    return 0;

}
Exemplo n.º 18
0
Arquivo: parser.c Projeto: badcodes/c
int getproperty(FILE* html,char* property)
{
    int c=0;
    char* p=property;
    int outword=0;
    int lim=MAX_PROPERTY-2;

    SKIP_WS(html,c);
    do {
        if (IS_SPACE(c)) {outword=1;SKIP_WS(html,c);}
        if (c==EOF) goto END_OF_FILE;
        if (c=='=') break;
        if (outword) {property=p;outword=0;}
        *property++=c;
        if (lim--<0) break;
        c=NEXT_CHAR(html);
        if (c==EOF) goto END_OF_FILE;
    } while (c!='=');

    *property='\0';
    return 1;

    END_OF_FILE:
    *property='\0';
    return 0;
}
Exemplo n.º 19
0
Arquivo: devel.c Projeto: thewml/wml
/*--------------------------------------------------------------------------.
| The function numeric_arg () converts ARG to an int pointed to by VALUEP.  |
| If the conversion fails, print error message for macro MACRO.  Return     |
| TRUE iff conversion succeeds.                                             |
`--------------------------------------------------------------------------*/
static const char *
skip_space (const char *arg)
{
  while (IS_SPACE (*arg))
    arg++;
  return arg;
}
Exemplo n.º 20
0
Arquivo: anchor.c Projeto: yujiabe/w3m
char *
getAnchorText(Buffer *buf, AnchorList *al, Anchor *a)
{
    int hseq, i;
    Line *l;
    Str tmp = NULL;
    char *p, *ep;

    if (!a || a->hseq < 0)
	return NULL;
    hseq = a->hseq;
    l = buf->firstLine;
    for (i = 0; i < al->nanchor; i++) {
	a = &al->anchors[i];
	if (a->hseq != hseq)
	    continue;
	for (; l; l = l->next) {
	    if (l->linenumber == a->start.line)
		break;
	}
	if (!l)
	    break;
	p = l->lineBuf + a->start.pos;
	ep = l->lineBuf + a->end.pos;
	for (; p < ep && IS_SPACE(*p); p++) ;
	if (p == ep)
	    continue;
	if (!tmp)
	    tmp = Strnew_size(ep - p);
	else
	    Strcat_char(tmp, ' ');
	Strcat_charp_n(tmp, p, ep - p);
    }
    return tmp ? tmp->ptr : NULL;
}
Exemplo n.º 21
0
/** パラメータの発見

	@param[in] end buf末尾
	@param[in] p 解析の現在位置
	
	関数名の取得が完了し,パラメータ先頭の括弧を探す.
*/
const wchar_t* COutlineErlang::EnterArgs( const wchar_t* end, const wchar_t* p )
{
	assert( m_state == STATE_FUNC_CANDIDATE_FIN );

	while( IS_SPACE( *p ) && p < end )
		p++;
	
	if( p >= end )
		return end;

	if( IS_COMMENT( *p )){
		return end;
	}
	else if( *p == L'(' ){ // )
		m_state = STATE_FUNC_ARGS1;
		m_argcount = 0;
		m_parenthesis_ptr = 1;
		m_parenthesis[0] = *p;
		++p;

		return p;
	}

	// not a function
	m_state = STATE_NORMAL;
	return end;
}
Exemplo n.º 22
0
static char *xml_meta_attr_name(ACL_XML2_ATTR *attr, char *data)
{
    int   ch;
    ACL_XML2 *xml = attr->node->xml;

    SKIP_SPACE(data);
    if (*data == 0)
        return data;

    if (attr->name == xml->addr)
        attr->name = data;

    while ((ch = *data) != 0) {
        if (ch == '=') {
            if (attr->name_size == 0)
                attr->name_size = data - attr->name;
            *data++ = 0;
            break;
        }
        if (IS_SPACE(ch)) {
            attr->name_size = data - attr->name;
            *data++ = 0;
        } else
            data++;
    }

    return data;
}
Exemplo n.º 23
0
Arquivo: yvalue.c Projeto: Amaury/Ylib
/*
** yvalue_get()
** Read a value from a character string.
*/
yvalue_t yvalue_read(const char *str, yunit_t default_unit)
{
  yvalue_t res = {YUNIT_PT, 0.0};
  const char *pt;

  if (!str)
    return (res);
  for (pt = str + strlen(str);
       pt > str && IS_SPACE(*(pt - 1));
       --pt)
    ;
  if (!strcasecmp(pt - strlen("mm"), "mm") ||
      !strcasecmp(pt - strlen("millimeter"), "millimeter"))
    res.unit = YUNIT_MM;
  else if (!strcasecmp(pt - strlen("cm"), "cm") ||
	   !strcasecmp(pt - strlen("centimeter"), "centimeter"))
    res.unit = YUNIT_CM;
  else if (!strcasecmp(pt - strlen("in"), "in") ||
	   !strcasecmp(pt - strlen("inch"), "inch"))
    res.unit = YUNIT_IN;
  else if (!strcasecmp(pt - strlen("pt"), "pt") ||
	   !strcasecmp(pt - strlen("point"), "point"))
    res.unit = YUNIT_PT;
  else
    res.unit = default_unit;
  res.value = atof(str);
  return (res);
}
Exemplo n.º 24
0
static const char *
trim(const char *string)
{
    while (IS_SPACE(*string))
        string++;
    return string;
}
Exemplo n.º 25
0
static char *
html_quote_s(char *str)
{
    Str tmp = NULL;
    char *p, *q;
    bool space = true;

    for (p = str; *p; p++) {
	if (IS_SPACE(*p)) {
	    if (space)
		continue;
	    q = "&nbsp;";
	    space = true;
	}
	else {
	    q = html_quote_char(*p);
	    space = false;
	}
	if (q) {
	    if (tmp == NULL)
		tmp = Strnew_charp_n(str, (int)(p - str));
	    Strcat_charp(tmp, q);
	}
	else {
	    if (tmp)
		Strcat_char(tmp, *p);
	}
    }
    if (tmp)
	return tmp->ptr;
    return str;
}
Exemplo n.º 26
0
static const char *xml_parse_left_tag(ACL_XML2 *xml, const char *data)
{
    int   ch;

    if (xml->curr_node->ltag == xml->addr)
        SKIP_SPACE(data);

    if (*data == 0)
        return data;

    if (xml->curr_node->ltag == xml->addr)
        xml->curr_node->ltag = xml->ptr;

    while ((ch = *data) != 0) {
        if (ch == '>') {
            if (xml->len < MIN_LEN)
                return data;
            data++;
            xml->len--;
            xml->curr_node->ltag_size = xml->ptr -
                                        xml->curr_node->ltag;
            *xml->ptr++ = 0;

            xml_parse_check_self_closed(xml);

            if ((xml->curr_node->flag & ACL_XML2_F_SELF_CL)
                    && xml->curr_node->last_ch == '/')
            {
                size_t n = xml->curr_node->ltag_size;
                if (n >= 2)
                    xml->curr_node->ltag[n - 2] = 0;
                xml->curr_node->status = ACL_XML2_S_RGT;

            } else
                xml->curr_node->status = ACL_XML2_S_LGT;
            break;
        } else if (IS_SPACE(ch)) {
            if (xml->len < MIN_LEN)
                return data;
            data++;
            xml->len--;
            xml->curr_node->ltag_size = xml->ptr -
                                        xml->curr_node->ltag;
            *xml->ptr++ = 0;
            xml->curr_node->status = ACL_XML2_S_ATTR;
            xml->curr_node->last_ch = ch;
            break;
        } else {
            if (xml->len < MIN_LEN)
                return data;
            data++;
            xml->len--;
            *xml->ptr++ = ch;
            xml->curr_node->last_ch = ch;
        }
    }

    return data;
}
Exemplo n.º 27
0
static const char *xml_parse_left_tag(ACL_XML2 *xml, const char *data)
{
	int   ch;

	if (xml->curr_node->ltag == xml->dummy)
		SKIP_SPACE(data);

	if (*data == 0)
		return data;

	if (xml->curr_node->ltag == xml->dummy)
		xml->curr_node->ltag = END(xml);

	while ((ch = *data) != 0) {
		if (ch == '>') {
			if (NO_SPACE(xml))
				return data;
			xml->curr_node->ltag_size =
				END(xml) - xml->curr_node->ltag;
			ADD(xml, '\0');
			data++;

			xml_parse_check_self_closed(xml);

			if ((xml->curr_node->flag & ACL_XML2_F_SELF_CL)
				&& xml->curr_node->last_ch == '/')
			{
				if (xml->curr_node->ltag_size > 0) {
					size_t n;

					xml->curr_node->ltag_size--;
					n = xml->curr_node->ltag_size;
					xml->curr_node->ltag[n] = 0;
				}
				xml->curr_node->status = ACL_XML2_S_RGT;
			} else
				xml->curr_node->status = ACL_XML2_S_LGT;
			break;
		} else if (IS_SPACE(ch)) {
			if (NO_SPACE(xml))
				return data;
			data++;
			xml->curr_node->ltag_size =
				END(xml) - xml->curr_node->ltag;
			ADD(xml, '\0');
			xml->curr_node->status = ACL_XML2_S_ATTR;
			xml->curr_node->last_ch = ch;
			break;
		} else {
			if (NO_SPACE(xml))
				return data;
			data++;
			ADD(xml, ch);
			xml->curr_node->last_ch = ch;
		}
	}

	return data;
}
Exemplo n.º 28
0
static void
gst_asm_scan_identifier (GstASMScan * scan)
{
  gchar ch;
  gint i = 0;

  ch = THIS_CHAR (scan);
  /* real strips all spaces that are not inside quotes for identifiers */
  while ((IS_CHAR (ch) || IS_SPACE (ch))) {
    if (i < (MAX_RULE_LENGTH - 1) && !IS_SPACE (ch))
      scan->val[i++] = ch;
    ch = NEXT_CHAR (scan);
  }
  scan->val[i] = '\0';

  scan->token = GST_ASM_TOKEN_IDENTIFIER;
}
Exemplo n.º 29
0
/******************************************************************************
* Read property from file and overwritting the existing property
******************************************************************************/
int get_prop(char *pStr, char** ppKey, char** ppVal)
{
    int len = (int)strlen(pStr);
    char *end = pStr + len;
    char *key = NULL, *val = NULL;
    int stage = 0;

    if (!len)
    {
        return -1;    //no data
	}
    else if (pStr[0] == '#')
    {   /*ignore comment*/
		*ppKey = *ppVal = NULL;
		return 0;
    }
    else if (pStr[len-1] != '\n')
    {
        if (len >= PROPBUF_SIZE-1)
        {
            MNL_ERR("%s: buffer is not enough!!\n", __FUNCTION__);            
			return -1;
        }
        else
        {
            pStr[len-1] = '\n';
        }
    }
    key = pStr;
    while((*pStr != '=') && (pStr < end)) pStr++;
    if (pStr >= end)
	{
		MNL_ERR("%s: '=' is not found!!\n", __FUNCTION__);
        return -1;    //format error
	}

    *pStr++ = '\0';
    while(IS_SPACE(*pStr) && (pStr < end)) pStr++;    //skip space chars
    val = pStr;
    while(!IS_SPACE(*pStr) && (pStr < end)) pStr++;
    *pStr = '\0';
	*ppKey = key;
	*ppVal = val;
	return 0;

}
Exemplo n.º 30
0
void
extractMailcapEntry(char *mcap_entry, char **type, char **cmd)
{
    int j;

    while (*mcap_entry && IS_SPACE(*mcap_entry))
	mcap_entry++;
    for (j = 0;
	 mcap_entry[j] && mcap_entry[j] != ';' && !IS_SPACE(mcap_entry[j]);
	 j++) ;
    *type = allocStr(mcap_entry, j);
    if (mcap_entry[j] == ';')
	j++;
    while (mcap_entry[j] && IS_SPACE(mcap_entry[j]))
	j++;
    *cmd = allocStr(&mcap_entry[j], -1);
}