Exemplo n.º 1
0
Arquivo: DRI.c Projeto: Agnarr/xserver
static XF86ConfBuffersPtr
xf86parseBuffers (void)
{
    int token;
    parsePrologue (XF86ConfBuffersPtr, XF86ConfBuffersRec)

    if (xf86getSubToken (&(ptr->buf_comment)) != NUMBER)
	Error ("Buffers count expected", NULL);
    ptr->buf_count = val.num;

    if (xf86getSubToken (&(ptr->buf_comment)) != NUMBER)
	Error ("Buffers size expected", NULL);
    ptr->buf_size = val.num;

    if ((token = xf86getSubToken (&(ptr->buf_comment))) == STRING) {
	ptr->buf_flags = val.str;
	if ((token = xf86getToken (NULL)) == COMMENT)
	    ptr->buf_comment = xf86addComment(ptr->buf_comment, val.str);
	else
	    xf86unGetToken(token);
    }

#ifdef DEBUG
    printf ("Buffers parsed\n");
#endif

    return ptr;
}
Exemplo n.º 2
0
Arquivo: Keyboard.c Projeto: aosm/X11
XF86ConfInputPtr
xf86parseKeyboardSection (void)
{
	char *s, *s1, *s2;
	int l;
	int token, ntoken;
	parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)

	while ((token = xf86getToken (KeyboardTab)) != ENDSECTION)
	{
		switch (token)
		{
		case COMMENT:
			ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
			break;
		case KPROTOCOL:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "Protocol");
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
							       xf86configStrdup("Protocol"),
							       val.str);
			break;
		case AUTOREPEAT:
			if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER)
				Error (AUTOREPEAT_MSG, NULL);
			s1 = xf86uLongToString(val.num);
			if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER)
				Error (AUTOREPEAT_MSG, NULL);
			s2 = xf86uLongToString(val.num);
			l = strlen(s1) + 1 + strlen(s2) + 1;
			s = xf86confmalloc(l);
			sprintf(s, "%s %s", s1, s2);
			xf86conffree(s1);
			xf86conffree(s2);
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
							       xf86configStrdup("AutoRepeat"), s);
			break;
		case XLEDS:
			if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER)
				Error (XLEDS_MSG, NULL);
			s = xf86uLongToString(val.num);
			l = strlen(s) + 1;
			while ((token = xf86getSubToken (&(ptr->inp_comment))) == NUMBER)
			{
				s1 = xf86uLongToString(val.num);
				l += (1 + strlen(s1));
				s = xf86confrealloc(s, l);
				strcat(s, " ");
				strcat(s, s1);
				xf86conffree(s1);
			}
			xf86unGetToken (token);
			break;
		case SERVERNUM:
			xf86parseWarning(OBSOLETE_MSG, xf86tokenString());
			break;
		case LEFTALT:
		case RIGHTALT:
		case SCROLLLOCK_TOK:
		case RIGHTCTL:
			xf86parseWarning(OBSOLETE_MSG, xf86tokenString());
				break;
			ntoken = xf86getToken (KeyMapTab);
			switch (ntoken)
			{
			case EOF_TOKEN:
				xf86parseError (UNEXPECTED_EOF_MSG);
				CLEANUP (ptr);
				return (NULL);
				break;

			default:
				Error (INVALID_KEYWORD_MSG, xf86tokenString ());
				break;
			}
			break;
		case VTINIT:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "VTInit");
			xf86parseWarning(MOVED_TO_FLAGS_MSG, "VTInit");
			break;
		case VTSYSREQ:
			xf86parseWarning(MOVED_TO_FLAGS_MSG, "VTSysReq");
			break;
		case XKBDISABLE:
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("XkbDisable"),
												NULL);
			break;
		case XKBKEYMAP:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "XKBKeymap");
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("XkbKeymap"),
												val.str);
			break;
		case XKBCOMPAT:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "XKBCompat");
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("XkbCompat"),
												val.str);
			break;
		case XKBTYPES:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "XKBTypes");
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("XkbTypes"),
												val.str);
			break;
		case XKBKEYCODES:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "XKBKeycodes");
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("XkbKeycodes"),
												val.str);
			break;
		case XKBGEOMETRY:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "XKBGeometry");
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("XkbGeometry"),
												val.str);
			break;
		case XKBSYMBOLS:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "XKBSymbols");
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("XkbSymbols"),
												val.str);
			break;
		case XKBRULES:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "XKBRules");
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("XkbRules"),
												val.str);
			break;
		case XKBMODEL:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "XKBModel");
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("XkbModel"),
												val.str);
			break;
		case XKBLAYOUT:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "XKBLayout");
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("XkbLayout"),
												val.str);
			break;
		case XKBVARIANT:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "XKBVariant");
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("XkbVariant"),
												val.str);
			break;
		case XKBOPTIONS:
			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
				Error (QUOTE_MSG, "XKBOptions");
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("XkbOptions"),
												val.str);
			break;
		case PANIX106:
			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
												xf86configStrdup("Panix106"), NULL);
			break;
		case EOF_TOKEN:
			Error (UNEXPECTED_EOF_MSG, NULL);
			break;
		default:
			Error (INVALID_KEYWORD_MSG, xf86tokenString ());
			break;
		}
	}

	ptr->inp_identifier = xf86configStrdup(CONF_IMPLICIT_KEYBOARD);
	ptr->inp_driver = xf86configStrdup("keyboard");
	ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
										xf86configStrdup("CoreKeyboard"), NULL);

#ifdef DEBUG
	printf ("Keyboard section parsed\n");
#endif

	return ptr;
}
Exemplo n.º 3
0
XF86ConfLayoutPtr
xf86parseLayoutSection(void)
{
    int has_ident = FALSE;
    int token;

    parsePrologue(XF86ConfLayoutPtr, XF86ConfLayoutRec)

        while ((token = xf86getToken(LayoutTab)) != ENDSECTION) {
        switch (token) {
        case COMMENT:
            ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str);
            break;
        case IDENTIFIER:
            if (xf86getSubToken(&(ptr->lay_comment)) != STRING)
                Error(QUOTE_MSG, "Identifier");
            if (has_ident == TRUE)
                Error(MULTIPLE_MSG, "Identifier");
            ptr->lay_identifier = val.str;
            has_ident = TRUE;
            break;
        case INACTIVE:
        {
            XF86ConfInactivePtr iptr;

            iptr = calloc(1, sizeof(XF86ConfInactiveRec));
            iptr->list.next = NULL;
            if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
                free(iptr);
                Error(INACTIVE_MSG);
            }
            iptr->inactive_device_str = val.str;
            ptr->lay_inactive_lst = (XF86ConfInactivePtr)
                xf86addListItem((glp) ptr->lay_inactive_lst, (glp) iptr);
        }
            break;
        case SCREEN:
        {
            XF86ConfAdjacencyPtr aptr;
            int absKeyword = 0;

            aptr = calloc(1, sizeof(XF86ConfAdjacencyRec));
            aptr->list.next = NULL;
            aptr->adj_scrnum = -1;
            aptr->adj_where = CONF_ADJ_OBSOLETE;
            aptr->adj_x = 0;
            aptr->adj_y = 0;
            aptr->adj_refscreen = NULL;
            if ((token = xf86getSubToken(&(ptr->lay_comment))) == NUMBER)
                aptr->adj_scrnum = val.num;
            else
                xf86unGetToken(token);
            token = xf86getSubToken(&(ptr->lay_comment));
            if (token != STRING) {
                free(aptr);
                Error(SCREEN_MSG);
            }
            aptr->adj_screen_str = val.str;

            token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab);
            switch (token) {
            case RIGHTOF:
                aptr->adj_where = CONF_ADJ_RIGHTOF;
                break;
            case LEFTOF:
                aptr->adj_where = CONF_ADJ_LEFTOF;
                break;
            case ABOVE:
                aptr->adj_where = CONF_ADJ_ABOVE;
                break;
            case BELOW:
                aptr->adj_where = CONF_ADJ_BELOW;
                break;
            case RELATIVE:
                aptr->adj_where = CONF_ADJ_RELATIVE;
                break;
            case ABSOLUTE:
                aptr->adj_where = CONF_ADJ_ABSOLUTE;
                absKeyword = 1;
                break;
            case EOF_TOKEN:
                free(aptr);
                Error(UNEXPECTED_EOF_MSG);
                break;
            default:
                xf86unGetToken(token);
                token = xf86getSubToken(&(ptr->lay_comment));
                if (token == STRING)
                    aptr->adj_where = CONF_ADJ_OBSOLETE;
                else
                    aptr->adj_where = CONF_ADJ_ABSOLUTE;
            }
            switch (aptr->adj_where) {
            case CONF_ADJ_ABSOLUTE:
                if (absKeyword)
                    token = xf86getSubToken(&(ptr->lay_comment));
                if (token == NUMBER) {
                    aptr->adj_x = val.num;
                    token = xf86getSubToken(&(ptr->lay_comment));
                    if (token != NUMBER) {
                        free(aptr);
                        Error(INVALID_SCR_MSG);
                    }
                    aptr->adj_y = val.num;
                }
                else {
                    if (absKeyword) {
                        free(aptr);
                        Error(INVALID_SCR_MSG);
                    }
                    else
                        xf86unGetToken(token);
                }
                break;
            case CONF_ADJ_RIGHTOF:
            case CONF_ADJ_LEFTOF:
            case CONF_ADJ_ABOVE:
            case CONF_ADJ_BELOW:
            case CONF_ADJ_RELATIVE:
                token = xf86getSubToken(&(ptr->lay_comment));
                if (token != STRING) {
                    free(aptr);
                    Error(INVALID_SCR_MSG);
                }
                aptr->adj_refscreen = val.str;
                if (aptr->adj_where == CONF_ADJ_RELATIVE) {
                    token = xf86getSubToken(&(ptr->lay_comment));
                    if (token != NUMBER) {
                        free(aptr);
                        Error(INVALID_SCR_MSG);
                    }
                    aptr->adj_x = val.num;
                    token = xf86getSubToken(&(ptr->lay_comment));
                    if (token != NUMBER) {
                        free(aptr);
                        Error(INVALID_SCR_MSG);
                    }
                    aptr->adj_y = val.num;
                }
                break;
            case CONF_ADJ_OBSOLETE:
                /* top */
                aptr->adj_top_str = val.str;

                /* bottom */
                if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
                    free(aptr);
                    Error(SCREEN_MSG);
                }
                aptr->adj_bottom_str = val.str;

                /* left */
                if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
                    free(aptr);
                    Error(SCREEN_MSG);
                }
                aptr->adj_left_str = val.str;

                /* right */
                if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
                    free(aptr);
                    Error(SCREEN_MSG);
                }
                aptr->adj_right_str = val.str;

            }
            ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr)
                xf86addListItem((glp) ptr->lay_adjacency_lst, (glp) aptr);
        }
            break;
        case INPUTDEVICE:
        {
            XF86ConfInputrefPtr iptr;

            iptr = calloc(1, sizeof(XF86ConfInputrefRec));
            iptr->list.next = NULL;
            iptr->iref_option_lst = NULL;
            if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
                free(iptr);
                Error(INPUTDEV_MSG);
            }
            iptr->iref_inputdev_str = val.str;
            while ((token = xf86getSubToken(&(ptr->lay_comment))) == STRING) {
                iptr->iref_option_lst =
                    xf86addNewOption(iptr->iref_option_lst, val.str, NULL);
            }
            xf86unGetToken(token);
            ptr->lay_input_lst = (XF86ConfInputrefPtr)
                xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr);
        }
            break;
        case OPTION:
            ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst);
            break;
        case EOF_TOKEN:
            Error(UNEXPECTED_EOF_MSG);
            break;
        default:
            Error(INVALID_KEYWORD_MSG, xf86tokenString());
            break;
        }
    }

    if (!has_ident)
        Error(NO_IDENT_MSG);

#ifdef DEBUG
    printf("Layout section parsed\n");
#endif

    return ptr;
}
Exemplo n.º 4
0
XF86ConfDevicePtr
xf86parseDeviceSection(void)
{
    int i;
    int has_ident = FALSE;
    int token;

    parsePrologue(XF86ConfDevicePtr, XF86ConfDeviceRec)

        /* Zero is a valid value for these */
        ptr->dev_chipid = -1;
    ptr->dev_chiprev = -1;
    ptr->dev_irq = -1;
    while ((token = xf86getToken(DeviceTab)) != ENDSECTION) {
        switch (token) {
        case COMMENT:
            ptr->dev_comment = xf86addComment(ptr->dev_comment, xf86_lex_val.str);
            break;
        case IDENTIFIER:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Identifier");
            if (has_ident == TRUE)
                Error(MULTIPLE_MSG, "Identifier");
            ptr->dev_identifier = xf86_lex_val.str;
            has_ident = TRUE;
            break;
        case VENDOR:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Vendor");
            ptr->dev_vendor = xf86_lex_val.str;
            break;
        case BOARD:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Board");
            ptr->dev_board = xf86_lex_val.str;
            break;
        case CHIPSET:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Chipset");
            ptr->dev_chipset = xf86_lex_val.str;
            break;
        case CARD:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Card");
            ptr->dev_card = xf86_lex_val.str;
            break;
        case DRIVER:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Driver");
            ptr->dev_driver = xf86_lex_val.str;
            break;
        case RAMDAC:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Ramdac");
            ptr->dev_ramdac = xf86_lex_val.str;
            break;
        case DACSPEED:
            for (i = 0; i < CONF_MAXDACSPEEDS; i++)
                ptr->dev_dacSpeeds[i] = 0;
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER) {
                Error(DACSPEED_MSG, CONF_MAXDACSPEEDS);
            }
            else {
                ptr->dev_dacSpeeds[0] = (int) (xf86_lex_val.realnum * 1000.0 + 0.5);
                for (i = 1; i < CONF_MAXDACSPEEDS; i++) {
                    if (xf86getSubToken(&(ptr->dev_comment)) == NUMBER)
                        ptr->dev_dacSpeeds[i] = (int)
                            (xf86_lex_val.realnum * 1000.0 + 0.5);
                    else {
                        xf86unGetToken(token);
                        break;
                    }
                }
            }
            break;
        case VIDEORAM:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "VideoRam");
            ptr->dev_videoram = xf86_lex_val.num;
            break;
        case BIOSBASE:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "BIOSBase");
            /* ignored */
            break;
        case MEMBASE:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "MemBase");
            ptr->dev_mem_base = xf86_lex_val.num;
            break;
        case IOBASE:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "IOBase");
            ptr->dev_io_base = xf86_lex_val.num;
            break;
        case CLOCKCHIP:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "ClockChip");
            ptr->dev_clockchip = xf86_lex_val.str;
            break;
        case CHIPID:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "ChipID");
            ptr->dev_chipid = xf86_lex_val.num;
            break;
        case CHIPREV:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "ChipRev");
            ptr->dev_chiprev = xf86_lex_val.num;
            break;

        case CLOCKS:
            token = xf86getSubToken(&(ptr->dev_comment));
            for (i = ptr->dev_clocks;
                 token == NUMBER && i < CONF_MAXCLOCKS; i++) {
                ptr->dev_clock[i] = (int) (xf86_lex_val.realnum * 1000.0 + 0.5);
                token = xf86getSubToken(&(ptr->dev_comment));
            }
            ptr->dev_clocks = i;
            xf86unGetToken(token);
            break;
        case MATCHSEAT:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "MatchSeat");
            ptr->match_seat = xf86_lex_val.str;
            break;
        case OPTION:
            ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
            break;
        case BUSID:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "BusID");
            ptr->dev_busid = xf86_lex_val.str;
            break;
        case IRQ:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(QUOTE_MSG, "IRQ");
            ptr->dev_irq = xf86_lex_val.num;
            break;
        case SCREEN:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "Screen");
            ptr->dev_screen = xf86_lex_val.num;
            break;
        case EOF_TOKEN:
            Error(UNEXPECTED_EOF_MSG);
            break;
        default:
            Error(INVALID_KEYWORD_MSG, xf86tokenString());
            break;
        }
    }

    if (!has_ident)
        Error(NO_IDENT_MSG);

#ifdef DEBUG
    printf("Device section parsed\n");
#endif

    return ptr;
}
Exemplo n.º 5
0
static XF86ConfDisplayPtr
xf86parseDisplaySubSection(void)
{
    int token;

    parsePrologue(XF86ConfDisplayPtr, XF86ConfDisplayRec)

        ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1;
    ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1;
    ptr->disp_frameX0 = ptr->disp_frameY0 = -1;
    while ((token = xf86getToken(DisplayTab)) != ENDSUBSECTION) {
        switch (token) {
        case COMMENT:
            ptr->disp_comment = xf86addComment(ptr->disp_comment, xf86_lex_val.str);
            break;
        case VIEWPORT:
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(VIEWPORT_MSG);
            ptr->disp_frameX0 = xf86_lex_val.num;
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(VIEWPORT_MSG);
            ptr->disp_frameY0 = xf86_lex_val.num;
            break;
        case VIRTUAL:
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(VIRTUAL_MSG);
            ptr->disp_virtualX = xf86_lex_val.num;
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(VIRTUAL_MSG);
            ptr->disp_virtualY = xf86_lex_val.num;
            break;
        case DEPTH:
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(NUMBER_MSG, "Display");
            ptr->disp_depth = xf86_lex_val.num;
            break;
        case BPP:
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(NUMBER_MSG, "Display");
            ptr->disp_bpp = xf86_lex_val.num;
            break;
        case VISUAL:
            if (xf86getSubToken(&(ptr->disp_comment)) != STRING)
                Error(QUOTE_MSG, "Display");
            ptr->disp_visual = xf86_lex_val.str;
            break;
        case WEIGHT:
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(WEIGHT_MSG);
            ptr->disp_weight.red = xf86_lex_val.num;
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(WEIGHT_MSG);
            ptr->disp_weight.green = xf86_lex_val.num;
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(WEIGHT_MSG);
            ptr->disp_weight.blue = xf86_lex_val.num;
            break;
        case BLACK_TOK:
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(BLACK_MSG);
            ptr->disp_black.red = xf86_lex_val.num;
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(BLACK_MSG);
            ptr->disp_black.green = xf86_lex_val.num;
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(BLACK_MSG);
            ptr->disp_black.blue = xf86_lex_val.num;
            break;
        case WHITE_TOK:
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(WHITE_MSG);
            ptr->disp_white.red = xf86_lex_val.num;
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(WHITE_MSG);
            ptr->disp_white.green = xf86_lex_val.num;
            if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
                Error(WHITE_MSG);
            ptr->disp_white.blue = xf86_lex_val.num;
            break;
        case MODES:
        {
            XF86ModePtr mptr;

            while ((token =
                    xf86getSubTokenWithTab(&(ptr->disp_comment),
                                           DisplayTab)) == STRING) {
                mptr = calloc(1, sizeof(XF86ModeRec));
                mptr->mode_name = xf86_lex_val.str;
                mptr->list.next = NULL;
                ptr->disp_mode_lst = (XF86ModePtr)
                    xf86addListItem((glp) ptr->disp_mode_lst, (glp) mptr);
            }
            xf86unGetToken(token);
        }
            break;
        case OPTION:
            ptr->disp_option_lst = xf86parseOption(ptr->disp_option_lst);
            break;

        case EOF_TOKEN:
            Error(UNEXPECTED_EOF_MSG);
            break;
        default:
            Error(INVALID_KEYWORD_MSG, xf86tokenString());
            break;
        }
    }

#ifdef DEBUG
    printf("Display subsection parsed\n");
#endif

    return ptr;
}
Exemplo n.º 6
0
XF86ConfMonitorPtr
xf86parseMonitorSection (void)
{
	int has_ident = FALSE;
	int token;
	parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)

		while ((token = xf86getToken (MonitorTab)) != ENDSECTION)
	{
		switch (token)
		{
		case COMMENT:
			ptr->mon_comment = xf86addComment(ptr->mon_comment, val.str);
			break;
		case IDENTIFIER:
			if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
				Error (QUOTE_MSG, "Identifier");
			if (has_ident == TRUE)
				Error (MULTIPLE_MSG, "Identifier");
			ptr->mon_identifier = xf86configStrdup(val.str);
			has_ident = TRUE;
			break;
		case VENDOR:
			if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
				Error (QUOTE_MSG, "Vendor");
			ptr->mon_vendor = xf86configStrdup(val.str);
			break;
		case MODEL:
			if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
				Error (QUOTE_MSG, "ModelName");
			ptr->mon_modelname = xf86configStrdup(val.str);
			break;
		case MODE:
			HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode,
						 XF86ConfModeLinePtr);
			break;
		case MODELINE:
			HANDLE_LIST (mon_modeline_lst, xf86parseModeLine,
						 XF86ConfModeLinePtr);
			break;
		case DISPLAYSIZE:
			if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
				Error (DISPLAYSIZE_MSG, NULL);
			ptr->mon_width = val.realnum;
			if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
				Error (DISPLAYSIZE_MSG, NULL);
			ptr->mon_height = val.realnum;
			break;

		case HORIZSYNC:
			if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
				Error (HORIZSYNC_MSG, NULL);
			do {
				ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum;
				switch (token = xf86getSubToken (&(ptr->mon_comment)))
				{
					case COMMA:
						ptr->mon_hsync[ptr->mon_n_hsync].hi =
						ptr->mon_hsync[ptr->mon_n_hsync].lo;
						break;
					case DASH:
						if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER ||
						    (float)val.realnum < ptr->mon_hsync[ptr->mon_n_hsync].lo)
							Error (HORIZSYNC_MSG, NULL);
						ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum;
						if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA)
							break;
						ptr->mon_n_hsync++;
						goto HorizDone;
					default:
						/* We cannot currently know if a '\n' was found,
						 * or this is a real error
						 */
						ptr->mon_hsync[ptr->mon_n_hsync].hi =
						ptr->mon_hsync[ptr->mon_n_hsync].lo;
						ptr->mon_n_hsync++;
						goto HorizDone;
				}
				if (ptr->mon_n_hsync >= CONF_MAX_HSYNC)
					Error ("Sorry. Too many horizontal sync intervals.", NULL);
				ptr->mon_n_hsync++;
			} while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER);
HorizDone:
			xf86unGetToken (token);
			break;

		case VERTREFRESH:
			if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
				Error (VERTREFRESH_MSG, NULL);
			do {
				ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum;
				switch (token = xf86getSubToken (&(ptr->mon_comment)))
				{
					case COMMA:
						ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
						ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
						break;
					case DASH:
						if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER ||
						    (float)val.realnum < ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo)
							Error (VERTREFRESH_MSG, NULL);
						ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum;
						if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA)
							break;
						ptr->mon_n_vrefresh++;
						goto VertDone;
					default:
						/* We cannot currently know if a '\n' was found,
						 * or this is a real error
						 */
						ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
						ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
						ptr->mon_n_vrefresh++;
						goto VertDone;
				}
				if (ptr->mon_n_vrefresh >= CONF_MAX_VREFRESH)
					Error ("Sorry. Too many vertical refresh intervals.", NULL);
				ptr->mon_n_vrefresh++;
			} while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER);
VertDone:
			xf86unGetToken (token);
			break;

		case GAMMA:
			if( xf86getSubToken (&(ptr->mon_comment)) != NUMBER )
			{
				Error (INVALID_GAMMA_MSG, NULL);
			}
			else
			{
				ptr->mon_gamma_red = ptr->mon_gamma_green =
					ptr->mon_gamma_blue = val.realnum;
				if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER )
				{
					ptr->mon_gamma_green = val.realnum;
					if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER )
					{
						ptr->mon_gamma_blue = val.realnum;
					}
					else
					{
						Error (INVALID_GAMMA_MSG, NULL);
					}
				}
				else
					xf86unGetToken (token);
			}
			break;
		case OPTION:
			ptr->mon_option_lst = xf86parseOption(ptr->mon_option_lst);
			break;
		case USEMODES:
		        {
				XF86ConfModesLinkPtr mptr;

				if ((token = xf86getSubToken (&(ptr->mon_comment))) != STRING)
					Error (QUOTE_MSG, "UseModes");

				/* add to the end of the list of modes sections 
				   referenced here */
				mptr = xf86confcalloc (1, sizeof (XF86ConfModesLinkRec));
				mptr->list.next = NULL;
				mptr->ml_modes_str = xf86configStrdup(val.str);
				mptr->ml_modes = NULL;
				ptr->mon_modes_sect_lst = (XF86ConfModesLinkPtr)
					xf86addListItem((GenericListPtr)ptr->mon_modes_sect_lst,
						    (GenericListPtr)mptr);
			}
			break;
		case EOF_TOKEN:
			Error (UNEXPECTED_EOF_MSG, NULL);
			break;
		default:
			xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
			CLEANUP (ptr);
			return NULL;
		}
	}

	if (!has_ident)
		Error (NO_IDENT_MSG, NULL);

#ifdef DEBUG
	printf ("Monitor section parsed\n");
#endif
	return ptr;
}
Exemplo n.º 7
0
XF86ConfModeLinePtr
xf86parseVerboseMode (void)
{
	int token, token2;
	int had_dotclock = 0, had_htimings = 0, had_vtimings = 0;
	parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec)

		if (xf86getSubToken (&(ptr->ml_comment)) != STRING)
		Error ("Mode name expected", NULL);
	ptr->ml_identifier = xf86configStrdup(val.str);
	while ((token = xf86getToken (ModeTab)) != ENDMODE)
	{
		switch (token)
		{
		case COMMENT:
			ptr->ml_comment = xf86addComment(ptr->ml_comment, val.str);
			break;
		case DOTCLOCK:
			if ((token = xf86getSubToken (&(ptr->ml_comment))) != NUMBER)
				Error (NUMBER_MSG, "DotClock");
			ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
			had_dotclock = 1;
			break;
		case HTIMINGS:
			if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
				ptr->ml_hdisplay = val.num;
			else
				Error ("Horizontal display expected", NULL);

			if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
				ptr->ml_hsyncstart = val.num;
			else
				Error ("Horizontal sync start expected", NULL);

			if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
				ptr->ml_hsyncend = val.num;
			else
				Error ("Horizontal sync end expected", NULL);

			if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
				ptr->ml_htotal = val.num;
			else
				Error ("Horizontal total expected", NULL);
			had_htimings = 1;
			break;
		case VTIMINGS:
			if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
				ptr->ml_vdisplay = val.num;
			else
				Error ("Vertical display expected", NULL);

			if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
				ptr->ml_vsyncstart = val.num;
			else
				Error ("Vertical sync start expected", NULL);

			if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
				ptr->ml_vsyncend = val.num;
			else
				Error ("Vertical sync end expected", NULL);

			if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
				ptr->ml_vtotal = val.num;
			else
				Error ("Vertical total expected", NULL);
			had_vtimings = 1;
			break;
		case FLAGS:
			token = xf86getSubToken (&(ptr->ml_comment));
			if (token != STRING)
				Error (QUOTE_MSG, "Flags");
			while (token == STRING)
			{
				token2 = xf86getStringToken (TimingTab);
				switch (token2)
				{
				case TT_INTERLACE:
					ptr->ml_flags |= XF86CONF_INTERLACE;
					break;
				case TT_PHSYNC:
					ptr->ml_flags |= XF86CONF_PHSYNC;
					break;
				case TT_NHSYNC:
					ptr->ml_flags |= XF86CONF_NHSYNC;
					break;
				case TT_PVSYNC:
					ptr->ml_flags |= XF86CONF_PVSYNC;
					break;
				case TT_NVSYNC:
					ptr->ml_flags |= XF86CONF_NVSYNC;
					break;
				case TT_CSYNC:
					ptr->ml_flags |= XF86CONF_CSYNC;
					break;
				case TT_PCSYNC:
					ptr->ml_flags |= XF86CONF_PCSYNC;
					break;
				case TT_NCSYNC:
					ptr->ml_flags |= XF86CONF_NCSYNC;
					break;
				case TT_DBLSCAN:
					ptr->ml_flags |= XF86CONF_DBLSCAN;
					break;
				case TT_CUSTOM:
					ptr->ml_flags |= XF86CONF_CUSTOM;
					break;
				case EOF_TOKEN:
					Error (UNEXPECTED_EOF_MSG, NULL);
					break;
				default:
					Error ("Unknown flag string", NULL);
					break;
				}
				token = xf86getSubToken (&(ptr->ml_comment));
			}
			xf86unGetToken (token);
			break;
		case HSKEW:
			if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
				Error ("Horizontal skew expected", NULL);
			ptr->ml_flags |= XF86CONF_HSKEW;
			ptr->ml_hskew = val.num;
			break;
		case VSCAN:
			if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
				Error ("Vertical scan count expected", NULL);
			ptr->ml_flags |= XF86CONF_VSCAN;
			ptr->ml_vscan = val.num;
			break;
		case EOF_TOKEN:
			Error (UNEXPECTED_EOF_MSG, NULL);
			break;
		default:
			Error ("Unexepcted token in verbose \"Mode\" entry\n", NULL);
		}
	}
	if (!had_dotclock)
		Error ("the dotclock is missing", NULL);
	if (!had_htimings)
		Error ("the horizontal timings are missing", NULL);
	if (!had_vtimings)
		Error ("the vertical timings are missing", NULL);

#ifdef DEBUG
	printf ("Verbose Mode parsed\n");
#endif
	return (ptr);
}
Exemplo n.º 8
0
XF86ConfModeLinePtr
xf86parseModeLine (void)
{
	int token;
	parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec)

	/* Identifier */
	if (xf86getSubToken (&(ptr->ml_comment)) != STRING)
		Error ("ModeLine identifier expected", NULL);
	ptr->ml_identifier = xf86configStrdup(val.str);

	/* DotClock */
	if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
		Error ("ModeLine dotclock expected", NULL);
	ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);

	/* HDisplay */
	if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
		Error ("ModeLine Hdisplay expected", NULL);
	ptr->ml_hdisplay = val.num;

	/* HSyncStart */
	if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
		Error ("ModeLine HSyncStart expected", NULL);
	ptr->ml_hsyncstart = val.num;

	/* HSyncEnd */
	if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
		Error ("ModeLine HSyncEnd expected", NULL);
	ptr->ml_hsyncend = val.num;

	/* HTotal */
	if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
		Error ("ModeLine HTotal expected", NULL);
	ptr->ml_htotal = val.num;

	/* VDisplay */
	if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
		Error ("ModeLine Vdisplay expected", NULL);
	ptr->ml_vdisplay = val.num;

	/* VSyncStart */
	if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
		Error ("ModeLine VSyncStart expected", NULL);
	ptr->ml_vsyncstart = val.num;

	/* VSyncEnd */
	if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
		Error ("ModeLine VSyncEnd expected", NULL);
	ptr->ml_vsyncend = val.num;

	/* VTotal */
	if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
		Error ("ModeLine VTotal expected", NULL);
	ptr->ml_vtotal = val.num;

	token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab);
	while ((token == TT_INTERLACE) || (token == TT_PHSYNC) ||
		   (token == TT_NHSYNC) || (token == TT_PVSYNC) ||
		   (token == TT_NVSYNC) || (token == TT_CSYNC) ||
		   (token == TT_PCSYNC) || (token == TT_NCSYNC) ||
		   (token == TT_DBLSCAN) || (token == TT_HSKEW) ||
		   (token == TT_VSCAN) || (token == TT_BCAST))
	{
		switch (token)
		{

		case TT_INTERLACE:
			ptr->ml_flags |= XF86CONF_INTERLACE;
			break;
		case TT_PHSYNC:
			ptr->ml_flags |= XF86CONF_PHSYNC;
			break;
		case TT_NHSYNC:
			ptr->ml_flags |= XF86CONF_NHSYNC;
			break;
		case TT_PVSYNC:
			ptr->ml_flags |= XF86CONF_PVSYNC;
			break;
		case TT_NVSYNC:
			ptr->ml_flags |= XF86CONF_NVSYNC;
			break;
		case TT_CSYNC:
			ptr->ml_flags |= XF86CONF_CSYNC;
			break;
		case TT_PCSYNC:
			ptr->ml_flags |= XF86CONF_PCSYNC;
			break;
		case TT_NCSYNC:
			ptr->ml_flags |= XF86CONF_NCSYNC;
			break;
		case TT_DBLSCAN:
			ptr->ml_flags |= XF86CONF_DBLSCAN;
			break;
		case TT_HSKEW:
			if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
				Error (NUMBER_MSG, "Hskew");
			ptr->ml_hskew = val.num;
			ptr->ml_flags |= XF86CONF_HSKEW;
			break;
		case TT_BCAST:
			ptr->ml_flags |= XF86CONF_BCAST;
			break;
		case TT_VSCAN:
			if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
				Error (NUMBER_MSG, "Vscan");
			ptr->ml_vscan = val.num;
			ptr->ml_flags |= XF86CONF_VSCAN;
			break;
		case TT_CUSTOM:
			ptr->ml_flags |= XF86CONF_CUSTOM;
			break;
		case EOF_TOKEN:
			Error (UNEXPECTED_EOF_MSG, NULL);
			break;
		default:
			Error (INVALID_KEYWORD_MSG, xf86tokenString ());
			break;
		}
		token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab);
	}
	xf86unGetToken (token);

#ifdef DEBUG
	printf ("ModeLine parsed\n");
#endif
	return (ptr);
}