Example #1
0
//--------------------------------------------------------------------------------------------------
static parseTree::CompoundItem_t* ParseProcessesSubsection
(
    Lexer_t& lexer
)
//--------------------------------------------------------------------------------------------------
{
    auto subsectionNameTokenPtr = lexer.Pull(parseTree::Token_t::NAME);

    const std::string& subsectionName = subsectionNameTokenPtr->text;

    if (subsectionName == "run")
    {
        return ParseComplexSection(lexer, subsectionNameTokenPtr, ParseRunEntry);
    }
    else if (subsectionName == "envVars")
    {
        return ParseComplexSection(lexer, subsectionNameTokenPtr, ParseEnvVarsEntry);
    }
    else if (subsectionName == "faultAction")
    {
        return ParseFaultAction(lexer, subsectionNameTokenPtr);
    }
    else if (subsectionName == "priority")
    {
        return ParsePriority(lexer, subsectionNameTokenPtr);
    }
    else if (subsectionName == "maxCoreDumpFileBytes")
    {
        return ParseSimpleSection(lexer, subsectionNameTokenPtr, parseTree::Token_t::INTEGER);
    }
    else if (subsectionName == "maxFileBytes")
    {
        return ParseSimpleSection(lexer, subsectionNameTokenPtr, parseTree::Token_t::INTEGER);
    }
    else if (subsectionName == "maxFileDescriptors")
    {
        return ParseSimpleSection(lexer, subsectionNameTokenPtr, parseTree::Token_t::INTEGER);
    }
    else if (subsectionName == "maxLockedMemoryBytes")
    {
        return ParseSimpleSection(lexer, subsectionNameTokenPtr, parseTree::Token_t::INTEGER);
    }
    else if (subsectionName == "watchdogAction")
    {
        return ParseWatchdogAction(lexer, subsectionNameTokenPtr);
    }
    else if (subsectionName == "watchdogTimeout")
    {
        return ParseWatchdogTimeout(lexer, subsectionNameTokenPtr);
    }
    else
    {
        lexer.ThrowException("Unexpected subsection name '" + subsectionName
                             + "' in 'processes' section.");
        return NULL;
    }
}
Example #2
0
File: tkOption.c Project: das/tcltk
int
Tk_OptionObjCmd(
    ClientData clientData,	/* Main window associated with interpreter. */
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of Tcl_Obj arguments. */
    Tcl_Obj *const objv[])	/* Tcl_Obj arguments. */
{
    Tk_Window tkwin = clientData;
    int index, result;
    ThreadSpecificData *tsdPtr =
	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));

    static const char *const optionCmds[] = {
	"add", "clear", "get", "readfile", NULL
    };

    enum optionVals {
	OPTION_ADD, OPTION_CLEAR, OPTION_GET, OPTION_READFILE
    };

    if (objc < 2) {
	Tcl_WrongNumArgs(interp, 1, objv, "cmd arg ?arg ...?");
	return TCL_ERROR;
    }

    result = Tcl_GetIndexFromObj(interp, objv[1], optionCmds, "option", 0,
	    &index);
    if (result != TCL_OK) {
	return result;
    }

    result = TCL_OK;
    switch ((enum optionVals) index) {
    case OPTION_ADD: {
	int priority;

	if ((objc != 4) && (objc != 5)) {
	    Tcl_WrongNumArgs(interp, 2, objv, "pattern value ?priority?");
	    return TCL_ERROR;
	}

	if (objc == 4) {
	    priority = TK_INTERACTIVE_PRIO;
	} else {
	    priority = ParsePriority(interp, Tcl_GetString(objv[4]));
	    if (priority < 0) {
		return TCL_ERROR;
	    }
	}
	Tk_AddOption(tkwin, Tcl_GetString(objv[2]), Tcl_GetString(objv[3]),
		priority);
	break;
    }

    case OPTION_CLEAR: {
	TkMainInfo *mainPtr;

	if (objc != 2) {
	    Tcl_WrongNumArgs(interp, 2, objv, "");
	    return TCL_ERROR;
	}
	mainPtr = ((TkWindow *) tkwin)->mainPtr;
	if (mainPtr->optionRootPtr != NULL) {
	    ClearOptionTree(mainPtr->optionRootPtr);
	    mainPtr->optionRootPtr = NULL;
	}
	tsdPtr->cachedWindow = NULL;
	break;
    }

    case OPTION_GET: {
	Tk_Window window;
	Tk_Uid value;

	if (objc != 5) {
	    Tcl_WrongNumArgs(interp, 2, objv, "window name class");
	    return TCL_ERROR;
	}
	window = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin);
	if (window == NULL) {
	    return TCL_ERROR;
	}
	value = Tk_GetOption(window, Tcl_GetString(objv[3]),
		Tcl_GetString(objv[4]));
	if (value != NULL) {
	    Tcl_SetResult(interp, (char *) value, TCL_STATIC);
	}
	break;
    }

    case OPTION_READFILE: {
	int priority;

	if ((objc != 3) && (objc != 4)) {
	    Tcl_WrongNumArgs(interp, 2, objv, "fileName ?priority?");
	    return TCL_ERROR;
	}

	if (objc == 4) {
	    priority = ParsePriority(interp, Tcl_GetString(objv[3]));
	    if (priority < 0) {
		return TCL_ERROR;
	    }
	} else {
	    priority = TK_INTERACTIVE_PRIO;
	}
	result = ReadOptionFile(interp, tkwin, Tcl_GetString(objv[2]),
		priority);
	break;
    }
    }
    return result;
}