Example #1
0
int load_tkinter_funcs(void)
{
    /*
     * Load Tcl and Tk functions by searching all modules in current process.
     * Return 0 for success, non-zero for failure.
     */

    HMODULE hMods[1024];
    HANDLE hProcess;
    DWORD cbNeeded;
    unsigned int i;
    int found_tcl = 0;
    int found_tk = 0;

    /* First load tkinter module to make sure libraries are loaded */
    PyObject *pModule = PyImport_ImportModule(TKINTER_PKG);
    if (pModule == NULL) {
        return 1;
    }
    Py_DECREF(pModule);

    /* Returns pseudo-handle that does not need to be closed */
    hProcess = GetCurrentProcess();

    /* Iterate through modules in this process looking for Tcl / Tk names */
    if (EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) {
        for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
            if (!found_tcl) {
                found_tcl = get_tcl(hMods[i]);
                if (found_tcl == -1) {
                    return 1;
                }
            }
            if (!found_tk) {
                found_tk = get_tk(hMods[i]);
                if (found_tk == -1) {
                    return 1;
                }
            }
            if (found_tcl && found_tk) {
                return 0;
            }
        }
    }

    if (found_tcl == 0) {
        PyErr_SetString(PyExc_RuntimeError, "Could not find Tcl routines");
    } else {
        PyErr_SetString(PyExc_RuntimeError, "Could not find Tk routines");
    }
    return 1;
}
Example #2
0
/********************************************************************
* FUNCTION parse_index
* 
* Parse, and fill the indexQ for one val_value_t struct during
* processing of a text config file
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* The value name is the current token.
* Based on the value typdef, the res of the tokens
* comprising the value statement will be processed
*
* INPUTS:
*   tkc == token chain
*   obj == the object template to use for filling in 'val'
*   val == initialized value struct, without any value,
*          which will be filled in by this function
*   nsid == namespace ID to use for this value
*
* OUTPUTS:
*   indexQ filled in as tokens representing the index components
*   are parsed.  NEWLINE tokens are skipped as needed
*
* RETURNS:
*   status of the operation
*********************************************************************/
static status_t 
    parse_index (tk_chain_t  *tkc,
                 obj_template_t *obj,
                 val_value_t *val,
                 xmlns_id_t  nsid)
{
    obj_key_t     *indef, *infirst;
    val_value_t   *inval;
    status_t       res;

    infirst = obj_first_key(obj);

    /* first make value nodes for all the index values */
    for (indef = infirst; 
         indef != NULL; 
         indef = obj_next_key(indef)) {

        /* advance to the next non-NEWLINE token */
        res = get_tk(tkc);
        if (res != NO_ERR) {
            ncx_conf_exp_err(tkc, res, "index value");
            return res;
        }

        /* check if a valid token is given for the index value */
        if (TK_CUR_TEXT(tkc)) {
            inval = val_make_simval_obj(indef->keyobj,
                                        TK_CUR_VAL(tkc), 
                                        &res);
            if (!inval) {
                ncx_conf_exp_err(tkc, res, "index value");
                return res;
            } else {
                val_change_nsid(inval, nsid);
                val_add_child(inval, val);
            }
        } else {
            res = ERR_NCX_WRONG_TKTYPE;
            ncx_conf_exp_err(tkc, res, "index value");
            return res;
        }
    }

    /* generate the index chain in the indexQ */
    res = val_gen_index_chain(obj, val);
    if (res != NO_ERR) {
        ncx_print_errormsg(tkc, NULL, res);
    }

    return res;
        
} /* parse_index */
Example #3
0
/********************************************************************
* FUNCTION consume_tk
* 
* Consume a specified token type
* Skip over TK_TT_NEWLINE until a different type is found
*
* INPUTS:
*   tkc == token chain
*   ttyp == expected token type
*
* RETURNS:
*   status
*********************************************************************/
static status_t
    consume_tk (tk_chain_t  *tkc,
                tk_type_t  ttyp)
{
    status_t  res;

    res = get_tk(tkc);
    if (res != NO_ERR) {
        return res;
    } else {
        return (TK_CUR_TYP(tkc) == ttyp) ? 
            NO_ERR : ERR_NCX_WRONG_TKTYPE;
    }
    /*NOTREACHED*/
            
} /* consume_tk */
Example #4
0
int load_tkinter_funcs(void)
{
    // Load TCL and Tk functions by searching all modules in current process.
    // Return 0 for success, non-zero for failure.

    HMODULE hMods[1024];
    HANDLE hProcess;
    DWORD cbNeeded;
    unsigned int i;
    int found_tcl = 0;
    int found_tk = 0;

    // Returns pseudo-handle that does not need to be closed
    hProcess = GetCurrentProcess();

    // Iterate through modules in this process looking for TCL / Tk names
    if (EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) {
        for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
            if (!found_tcl) {
                found_tcl = get_tcl(hMods[i]);
                if (found_tcl == -1) {
                    return 1;
                }
            }
            if (!found_tk) {
                found_tk = get_tk(hMods[i]);
                if (found_tk == -1) {
                    return 1;
                }
            }
            if (found_tcl && found_tk) {
                return 0;
            }
        }
    }

    if (found_tcl == 0) {
        PyErr_SetString(PyExc_RuntimeError, "Could not find TCL routines");
    } else {
        PyErr_SetString(PyExc_RuntimeError, "Could not find Tk routines");
    }
    return 1;
}
Example #5
0
/********************************************************************
* FUNCTION parse_top
* 
* Parse, and fill one val_value_t struct
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
*
* INPUTS:
*   tkc == token chain
*   val == value iniitalized and could be already filled in
*   keepvals == TRUE to save existing values in 'val', as needed
*               FALSE to overwrite old values in 'val', as needed
*
* RETURNS:
*   status of the operation
*********************************************************************/
static status_t 
    parse_top (tk_chain_t  *tkc,
               val_value_t *val,
               boolean keepvals)
{
    status_t       res;
    boolean        done;

    res = NO_ERR;

    /* get the container name */
    done = FALSE;
    while (!done) {
        res = match_name(tkc, obj_get_name(val->obj));
        if (res == ERR_NCX_EOF) {
            if (LOGDEBUG) {
                log_debug("\nconf: object '%s' not found in file '%s'",
                          obj_get_name(val->obj), 
                          tkc->filename);
            }
            return NO_ERR;
        } else if (res != NO_ERR) {
            res = skip_object(tkc);
            if (res != NO_ERR) {
                return res;
            }
        } else {
            done = TRUE;
        }
    }

    /* get a left brace */
    res = consume_tk(tkc, TK_TT_LBRACE);
    if (res != NO_ERR) {
        ncx_conf_exp_err(tkc, res, "left brace to start object");
        return res;
    }

    done = FALSE;
    while (!done) {

        res = get_tk(tkc);
        if (res == ERR_NCX_EOF) {
            return NO_ERR;
        } else if (res != NO_ERR) {
            return res;
        }
        
        /* allow an empty parmset */
        if (TK_CUR_TYP(tkc)==TK_TT_RBRACE) {
            done = TRUE;
        } else {
            res = parse_parm(tkc, val, keepvals);
            if (res != NO_ERR) {
                done = TRUE;
            }
        }
    }

    return res;

}  /* parse_top */