示例#1
0
void CSSRuleParser_OnFontFace(LCUI_CSSParserContext ctx,
			      void(*func)(const LCUI_CSSFontFace))
{
	FontFaceParserContext data;
	data = GetParserContext(ctx);
	data->callback = func;
}
示例#2
0
void CSSParser_FreeFontFaceRuleParser(LCUI_CSSParserContext ctx)
{
	FontFaceParserContext data;
	FontFaceParser_End(ctx);
	data = GetParserContext(ctx);
	SetParserContext(ctx, NULL);
	free(data->face);
	free(data);
}
示例#3
0
void
_DtTermPrimParserSaveSign
(
    Widget w
)
{
    ParserContext   context = GetParserContext(w);

    SetSign(context, (*GetInputChar(context) == '-') ? TermPARSER_SIGNnegative :
	    TermPARSER_SIGNpositive);
}
示例#4
0
/*
**
**  enterNum()
**
**  enterNum enters a numerical parameter.
**
*/
void
_DtTermPrimParserEnterNum
(
    Widget w
)
{
    ParserContext   context = GetParserContext(w);

    if ( context->workingNum < MAXINT>>4 ) 
        context->workingNum = context->workingNum * 10 +
	    (*context->inputChar - '0');
    context->workingNumIsDefault = False;
}
示例#5
0
/*
**
**  _DtTermPrimParserClrStrParm()
**
**  clrStrParm clears the string parameters.
**
*/
void
_DtTermPrimParserClrStrParm
(
    Widget w
)
{
    ParserContext   context = GetParserContext(w);

    context->stringParms[0].length = 0;
    (void) memset(context->stringParms[0].str, 0x00, STR_SIZE + 1);

    context->stringParms[1].length = 0;
    (void) memset(context->stringParms[1].str, 0x00, STR_SIZE + 1);
}
示例#6
0
static void FontFaceParser_End(LCUI_CSSParserContext ctx)
{
	FontFaceParserContext data;
	data = GetParserContext(ctx);
	if (data->face->font_family) {
		free(data->face->font_family);
		data->face->font_family = NULL;
	}
	if (data->face->src) {
		free(data->face->src);
		data->face->src = NULL;
	}
	data->key = KEY_NONE;
}
示例#7
0
static int FontFaceParser_ParseTail(LCUI_CSSParserContext ctx)
{
	FontFaceParserContext data;
	data = GetParserContext(ctx);
	if (data->callback) {
		data->callback(data->face);
	}
	FontFaceParser_End(ctx);
	CSSParser_EndParseRuleData(ctx);
	if (ctx->pos > 0) {
		return -1;
	}
	return 0;
}
示例#8
0
/*
**
**  _DtTermPrimParserNumParmPush()
**
**  _DtTermPrimParserNumParmPush() takes the number in workingNum and 
**   stores it in parm[parmNum].
**
*/
void
_DtTermPrimParserNumParmPush
(
    Widget w,
    int    parmNum
)
{
    ParserContext   context = GetParserContext(w);

    if ( parmNum < NUM_PARMS ) {
      context->parms[parmNum] = context->workingNum;
      context->workingNum     = 0;
      context->workingNumIsDefault = False;
    }
}
示例#9
0
/*
**
**  _DtTermPrimParserClearParm()
**
**  _DtTermPrimParserClearParm clears all common parameters.
**
*/
void
_DtTermPrimParserClearParm
(
    Widget w
)
{
    ParserContext  context = GetParserContext(w);
    int             i;

    for (i = 0; i < NUM_PARMS; i++) {
        context->parms[i] = 0;
    }
    context->workingNum = 0;
    context->workingNumIsDefault = True;
    context->sign = TermPARSER_SIGNnone;
}
示例#10
0
static int FontFaceParser_ParseValue(LCUI_CSSParserContext ctx)
{
	FontFaceParserContext data;
	switch (*ctx->cur) {
	case '}':
	case ';':
		break;
	default:
		CSSParser_GetChar(ctx);
		return 0;
	}
	CSSParser_EndBuffer(ctx);
	data = GetParserContext(ctx);
	switch (data->key) {
	case KEY_FONT_FAMILY:
		if (data->face->font_family) {
			free(data->face->font_family);
		}
		data->face->font_family = malloc(strsize(ctx->buffer));
		if (!data->face->font_family) {
			return -ENOMEM;
		}
		strtrim(data->face->font_family, ctx->buffer, " \"");
		break;
	case KEY_FONT_STYLE:
		FontFace_ParseFontStyle(data->face, ctx->buffer);
		break;
	case KEY_FONT_WEIGHT:
		FontFace_ParseFontWeight(data->face, ctx->buffer);
		break;
	case KEY_SRC:
		FontFace_ParseSrc(data->face, ctx->buffer,
				  ctx->style.dirname);
		break;
	default: break;
	}
	data->key = KEY_NONE;
	if (*ctx->cur != '}') {
		ctx->rule.state = FFP_STATE_KEY;
		return 0;
	}
	return FontFaceParser_ParseTail(ctx);
}
示例#11
0
static int FontFaceParser_ParseKeyEnd(LCUI_CSSParserContext ctx)
{
	FontFaceParserContext data;
	switch (*ctx->cur) {
	CASE_WHITE_SPACE:
		return 0;
	case ':':
		break;
	case '}':
		return FontFaceParser_ParseTail(ctx);
	default:
		FontFaceParser_End(ctx);
		return -1;
	}
	CSSParser_EndBuffer(ctx);
	data = GetParserContext(ctx);
	data->key = GetFontFaceKey(ctx->buffer);
	ctx->rule.state = FFP_STATE_VALUE;
	return 0;
}
示例#12
0
/*
** Parse the character, tell the calling routine if we are not
** in the start state.
*/
Boolean
_DtTermPrimParse
(
    Widget          w,
    unsigned char  *parseChar,
    int		    parseCharLen
)
{
    ParserContext   context = GetParserContext(w);
    StateEntry      thisEntry;
    StateEntry      thisPreParseEntry;

#ifdef    NOCODE
    /*
    ** This decision should be made somewhere else.
    */
    if (tp->t_modes.disp_func == 1)
    {
        in_disp_func();
        return(False);
    }
#endif /* NOCODE */

    if (parseCharLen == 1) {
	*context->inputChar = *parseChar;
    } else {
	(void) memmove(context->inputChar, parseChar, parseCharLen);
    }
    context->inputCharLen = parseCharLen;

    if (isDebugFSet('p', 1)) {
#ifdef	BBA
#pragma	BBA_IGNORE
#endif	/*BBA*/
	static unsigned char debugChar;
	static Boolean first = True;
	char *c;

	if (parseCharLen == 1) {
	    _DtTermProcessLock();
	    if (first) {
		if (!(c = getenv("dttermDebugParseChar"))) {
		    c = "0x03";
		}
		debugChar = strtol(c, (char **) 0, 0);
		first = False;
	    }
	    _DtTermProcessUnlock();

	    if (*parseChar == debugChar) {
		ParseTrap();
		return 0;
	    }
	}
    }
	
    /*
    ** Determine which state entry to use.
    */
    thisPreParseEntry = context->stateTable->statePreParseEntry;
    thisEntry = context->stateTable->stateEntry;

    /* first run through the preParse entry... */
    if (thisPreParseEntry && (parseCharLen == 1)) {
	while ((*parseChar < thisPreParseEntry->lower) ||
		(*parseChar > thisPreParseEntry->upper)) {
	    thisPreParseEntry++;
	}
	/* if we hit the end, ignore it... */
	if ((0x00 == thisPreParseEntry->lower) &&
		(0xff == thisPreParseEntry->upper)) {
	    thisPreParseEntry = (StateEntry) 0;
	}
    }

    /* if we hit a valid preParseEntry, then let's execute it and
     * return...
     */
    if (thisPreParseEntry) {
	/*
	** Now change states.  If the next state is NULL, stay in the
	** current state.  This is for parse entries that do not break us
	** out of the current parse thread.  If we need to bail out of the
	** current parse thread, then we have a new state specified and
	** will switch to it.  We do this before we execute the function
	** incase the function needs to change the state as well...
	*/
	if (thisPreParseEntry->nextState) {
	    context->stateTable = thisPreParseEntry->nextState;
	}

	/*
	** Execute the action associated with the entry.
	*/
	if (thisPreParseEntry->action) {
	    (*thisPreParseEntry->action)(w);
	}

	return(!context->stateTable->startState);
    }

    /* HACK ALERT!!!!
     *
     * We need two different search algorithms - the first to deal
     * with single byte characters, the second to deal with multi-byte
     * characters.  For now, we will match multi-byte character with
     * the parse entry that covers 0..255.  If we find that this will
     * not work for everything, we may need to rethink this.
     */
    if (parseCharLen == 1) {
	while ((*parseChar < thisEntry->lower) ||
		(*parseChar > thisEntry->upper))
	{
	    thisEntry++;
	}
    } else {
	while ((0x00 != thisEntry->lower) ||
		(0xff != thisEntry->upper))
	{
	    thisEntry++;
	}
    }
	
    /*
    ** Now change states.  We do this before we execute the function incase
    ** the function needs to change the state as well...
    */
    context->stateTable = thisEntry->nextState;

    /*
    ** Execute the action associated with the entry.
    */
    if (thisEntry->action) {
	(*thisEntry->action)(w);
    }

    return(!context->stateTable->startState);
}
示例#13
0
    }
    for (i = 0; i < 9; i++)
    {
        printf("    parm[%d]      : %d\n", i, context->parm[i]);
    }
    printf("    workingNum : %d\n", context->workingNum);
}

void
parseString
(
    Widget          w;
    unsigned char  *string
)
{
    ParserContext   context = GetParserContext(w);
    int i;

    _parserPrintContext(context);
    for (i = 0; i < strlen((char *)string); i++)
    {
        _DtTermPrimParse(context, string[i]);
        _parserPrintContext(context);
    }
}

/* the following is to allow for a single main function in the code... */
#define	parserMain	main
parserMain()
{
    parserContext   context;