Пример #1
0
/* Initialize the module internal functions.
 *
 * The function reproduces the initialization performed by PostgreSQL
 * to be able to call the functions in pg_status.c
 *
 * The function should be called only once in the process lifetime.
 * so is called at module initialization. After the function is called,
 * set_ps_display() can be used.
 */
void
spt_setup(void)
{
#ifndef WIN32
    int argc = 0;
    char **argv = NULL;

    if (!get_argc_argv(&argc, &argv)) {
        spt_debug("setup failed");
        goto exit;
    }

    save_ps_display_args(argc, argv);

    /* Set up the first title to fully initialize the code */
    char *init_title = join_argv(argc, argv);
    init_ps_display(init_title);
    free(init_title);
#else
    /* On Windows save_ps_display_args is a no-op
     * This is a good news, because Py_GetArgcArgv seems not usable.
     */
    LPTSTR init_title = GetCommandLine();
    init_ps_display(init_title);
#endif

exit:
    /* clear the exception. Propagating it to the module init would make a
     * fatal error. What we want instead is just to create a no-op module. */
    PyErr_Clear();
}
/* Initialize the module internal functions.
 *
 * The function reproduces the initialization performed by PostgreSQL
 * to be able to call the functions in pg_status.c
 *
 * Return 0 in case of success, else -1. In case of failure with an error that
 * shouldn't be ignored, also set a Python exception.
 *
 * The function should be called only once in the process lifetime.
 * so is called at module initialization. After the function is called,
 * set_ps_display() can be used.
 */
int
spt_setup(void)
{
    int rv = -1;

#ifndef WIN32
    int argc = 0;
    char **argv = NULL;
    char *init_title;

    if (0 > get_argc_argv(&argc, &argv)) {
        spt_debug("get_argc_argv failed");
        goto exit;
    }

    save_ps_display_args(argc, argv);

    /* Set up the first title to fully initialize the code */
    if (!(init_title = join_argv(argc, argv))) { goto exit; }
    init_ps_display(init_title);
    free(init_title);

#else
    /* On Windows save_ps_display_args is a no-op
     * This is a good news, because Py_GetArgcArgv seems not usable.
     */
    LPTSTR init_title = GetCommandLine();
    init_ps_display(init_title);
#endif

    rv = 0;

exit:
    return rv;
}
Пример #3
0
/* Initialize the module internal functions.
 *
 * The function reproduces the initialization performed by PostgreSQL
 * to be able to call the functions in pg_status.c
 *
 * The function should be called only once in the process lifetime.
 * so is called at module initialization. After the function is called,
 * set_ps_display() can be used.
 */
void
spt_setup(void)
{
#ifndef WIN32
    int argc = 0;
    char **argv = NULL;

    if (!get_argc_argv(&argc, &argv)) {
        spt_debug("setup failed");
        return;
    }

    save_ps_display_args(argc, argv);

    /* Set up the first title to fully initialize the code */
    char *init_title = join_argv(argc, argv);
    init_ps_display(init_title);
    free(init_title);
#else
    /* On Windows save_ps_display_args is a no-op
     * This is a good news, because Py_GetArgcArgv seems not usable.
     */
    LPTSTR init_title = GetCommandLine();
    init_ps_display(init_title);
#endif

}