Esempio n. 1
0
OCI_File * OCI_FileInit
(
    OCI_Connection *con,
    OCI_File       *file,
    OCILobLocator  *handle,
    ub4             type
)
{
    OCI_CALL_DECLARE_CONTEXT(TRUE)
    OCI_CALL_CONTEXT_SET_FROM_CONN(con)

    OCI_ALLOCATE_DATA(OCI_IPC_FILE, file, 1);

    if (OCI_STATUS)
    {
        file->type   = type;
        file->con    = con;
        file->handle = handle;
        file->offset = 1;

        /* reset file info */

        if (file->dir)
        {
            file->dir[0] = 0;
        }

        if (file->name)
        {
            file->name[0] = 0;
        }

        if (!file->handle)
        {
            /* allocate handle for non fetched file (local file object) */

            file->hstate = OCI_OBJECT_ALLOCATED;

            OCI_STATUS = OCI_DescriptorAlloc((dvoid *)file->con->env, (dvoid **)(void *)&file->handle, (ub4)OCI_DTYPE_LOB);
        }
        else if (OCI_OBJECT_ALLOCATED_ARRAY != file->hstate)
        {
            file->hstate = OCI_OBJECT_FETCHED_CLEAN;
        }
    }

    /* check for failure */

    if (!OCI_STATUS && file)
    {
        OCI_FileFree(file);
        file = NULL;
    }

    return file;
}
Esempio n. 2
0
OCI_Msg * OCI_API OCI_MsgCreate
(
    OCI_TypeInfo *typinf
)
{
    OCI_Msg *msg = NULL;
    boolean res  = TRUE;

    OCI_CHECK_INITIALIZED(NULL);

    OCI_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf, NULL);

    /* allocate message structure */

    msg = (OCI_Msg *) OCI_MemAlloc(OCI_IPC_MSG, sizeof(*msg), (size_t) 1, TRUE);

    if (msg != NULL)
    {
        msg->typinf = typinf;
        msg->ind    = OCI_IND_NULL;

        /* allocate message properties descriptor */

        res = (OCI_SUCCESS == OCI_DescriptorAlloc((dvoid * ) msg->typinf->con->env,
                                                  (dvoid **) &msg->proph,
                                                  OCI_DTYPE_AQMSG_PROPERTIES,
                                                  (size_t) 0, (dvoid **) NULL));

        if (res == TRUE)
        {
            /* allocate internal OCI_Object handle if payload is not RAW */

            if (msg->typinf->tcode != OCI_UNKNOWN)
            {
                msg->obj = OCI_ObjectCreate(typinf->con, typinf);

                res = (msg->obj != NULL);
            }
        }
    }
    else
    {
        res = FALSE;
    }

    /* check for failure */

    if (res == FALSE)
    {
        OCI_MsgFree(msg);
        msg = NULL;
    }

    return msg;
}
Esempio n. 3
0
OCI_Dequeue * OCI_API OCI_DequeueCreate
(
    OCI_TypeInfo *typinf,
    const mtext  *name
)
{
    OCI_Dequeue *dequeue = NULL;
    boolean res          = TRUE;

    OCI_CHECK_INITIALIZED(NULL);

    OCI_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf, NULL);
    OCI_CHECK_PTR(OCI_IPC_STRING, name, NULL);

    /* allocate dequeue structure */

    dequeue = (OCI_Dequeue *) OCI_MemAlloc(OCI_IPC_DEQUEUE, sizeof(*dequeue), (size_t) 1, TRUE);

    if (dequeue != NULL)
    {
        dequeue->typinf = typinf;
        dequeue->name   = mtsdup(name);

        /* allocate dequeue options descriptor */

        res = (OCI_SUCCESS == OCI_DescriptorAlloc((dvoid * ) dequeue->typinf->con->env,
                                                  (dvoid **) &dequeue->opth,
                                                  OCI_DTYPE_AQDEQ_OPTIONS,
                                                  (size_t) 0, (dvoid **) NULL));

        /* create local message for OCI_DequeueGet() */

        if (res == TRUE)
        {
            dequeue->msg = OCI_MsgCreate(dequeue->typinf);
        }

        res = (dequeue->msg != NULL);
    }
    else
    {
        res = FALSE;
    }

    /* check for failure */

    if (res == FALSE)
    {
        OCI_DequeueFree(dequeue);
        dequeue = NULL;
    }

    return dequeue;
}
Esempio n. 4
0
OCI_Msg * OCI_API OCI_MsgCreate
(
    OCI_TypeInfo *typinf
)
{
    OCI_Msg *msg = NULL;

    OCI_CALL_ENTER(OCI_Msg*, NULL)
    OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf)
    OCI_CALL_CONTEXT_SET_FROM_CONN(typinf->con)

    /* allocate message structure */

    msg = (OCI_Msg *) OCI_MemAlloc(OCI_IPC_MSG, sizeof(*msg), (size_t) 1, TRUE);
    OCI_STATUS = (NULL != msg);

    if (OCI_STATUS)
    {
        msg->typinf = typinf;
        msg->ind    = OCI_IND_NULL;

        /* allocate message properties descriptor */

        OCI_STATUS = OCI_DescriptorAlloc((dvoid *)msg->typinf->con->env, (dvoid **)&msg->proph, OCI_DTYPE_AQMSG_PROPERTIES);

        if (OCI_STATUS)
        {
            /* allocate internal OCI_Object handle if payload is not RAW */

            if (OCI_UNKNOWN != msg->typinf->typecode)
            {
                msg->obj = OCI_ObjectCreate(typinf->con, typinf);

                OCI_STATUS = (NULL != msg->obj);
            }
        }
    }

    /* check for failure */

    if (OCI_STATUS)
    {
        OCI_RETVAL = msg;
    }
    else if (msg)
    {
        OCI_MsgFree(msg);
        msg = NULL;
    }

    OCI_CALL_EXIT()
}
Esempio n. 5
0
OCI_Dequeue * OCI_API OCI_DequeueCreate
(
    OCI_TypeInfo *typinf,
    const otext  *name
)
{
    OCI_Dequeue *dequeue = NULL;

    OCI_LIB_CALL_ENTER(OCI_Dequeue*, dequeue)

    OCI_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf)
    OCI_CHECK_PTR(OCI_IPC_STRING, name)

    /* allocate dequeue structure */

    dequeue = (OCI_Dequeue *)OCI_MemAlloc(OCI_IPC_DEQUEUE, sizeof(*dequeue), (size_t)1, TRUE);

    if (dequeue)
    {
        dequeue->typinf = typinf;
        dequeue->name   = ostrdup(name);

        /* allocate dequeue options descriptor */

        call_status = OCI_SUCCESSFUL(OCI_DescriptorAlloc((dvoid *)dequeue->typinf->con->env,
                                                         (dvoid **) &dequeue->opth,
                                                         OCI_DTYPE_AQDEQ_OPTIONS,
                                                         (size_t) 0, (dvoid **) NULL));

        /* create local message for OCI_DequeueGet() */

        if (call_status)
        {
            dequeue->msg = OCI_MsgCreate(dequeue->typinf);
        }

        call_status = (NULL !=  dequeue->msg);
    }

    /* check for failure */

    if (call_status)
    {
        call_retval = dequeue;
    }
    else if (dequeue)
    {
        OCI_DequeueFree(dequeue);
    }

    OCI_LIB_CALL_EXIT()
}
Esempio n. 6
0
OCI_File * OCI_FileInit
(
    OCI_Connection *con,
    OCI_File      **pfile,
    OCILobLocator  *handle,
    ub4             type
)
{
    OCI_File *file = NULL;
    boolean res    = TRUE;

    OCI_CHECK(pfile == NULL, NULL);

    if (*pfile == NULL)
    {
        *pfile = (OCI_File *) OCI_MemAlloc(OCI_IPC_FILE, sizeof(*file), (size_t) 1, TRUE);
    }

    if (*pfile != NULL)
    {
        file = *pfile;

        file->type   = type;
        file->con    = con;
        file->handle = handle;
        file->offset = 1;

        /* reset file info */

        if (file->dir != NULL)
        {
            file->dir[0] = 0;
        }

        if (file->name != NULL)
        {
            file->name[0] = 0;
        }

        if (file->handle == NULL)
        {
            /* allocate handle for non fetched file (local file object) */

            file->hstate = OCI_OBJECT_ALLOCATED;

            res = (OCI_SUCCESS == OCI_DescriptorAlloc((dvoid *) file->con->env,
                                                      (dvoid **) (void *) &file->handle,
                                                      (ub4) OCI_DTYPE_LOB,
                                                      (size_t) 0, (dvoid **) NULL));
        }
        else if (file->hstate != OCI_OBJECT_ALLOCATED_ARRAY)
        {
            file->hstate = OCI_OBJECT_FETCHED_CLEAN;
        }
    }
    else
    {
        res = FALSE;
    }

    /* check for failure */

    if (res == FALSE)
    {
        OCI_FileFree(file);
        file = NULL;
    }

    return file;
}