Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

ctdbUpdateResource

Update the contents of an existing resource.

DECLARATION

CTDBRET ctdbDECL ctdbUpdateResource(CTHANDLE resource, pVOID data, VRLEN size);

DESCRIPTION

ctdbUpdateResource() update an existing resource. You must call ctdbAllocResource() with specific resource type and number that will uniquely identify the resource being updated. resource is a handle allocated by ctdbAllocResource(). The Resource data is any collection of data that you wish to store as a Resource. It can be a character string, a structure, or any variable type. size indicate the number of bytes occupied by data.

RETURN

ctdbUpdateResource() returns CTDBRET_OK on success.

EXAMPLE

CTDBRET UpdateMyResource(CTHANDLE Handle, ULONG type, ULONG number, pTEXT name, pVOID data, VRLEN size)

{

CTDBRET Retval;

CTHANDLE hRes = ctdbAllocResource(Handle, type, number, name);

if (hRes)

{

if ((Retval = ctdbUpdateResource(hRes, data, size)) != CTDBRET_OK)

printf("ctdbUpdateResource failed with error %d\n", Retval);

ctdbFreeResource(hRes);

}

else

{

printf("Failed to allocate resource handle\n");

Retval = CTDBRET_NOMEMORY;

}

return Retval;

}

SEE ALSO

ctdbAllocResource(), ctdbFreeResource(), ctdbAddResource(), ctdbDeleteResource(), ctdbFirstResource(), ctdbNextResource(), ctdbFindResource(), ctdbFindResourceByName(), ctdbGetResourceType(), ctdbSetResourceType(), ctdbGetResourceNumber(), ctdbSetResourceNumber(), ctdbGetResourceName(), ctdbSetResourceName(), ctdbGetResourceDataLength(), ctdbGetResourceData(), ctdbSetResourceData(), ctdbIsResourceLocked(), ctdbUnlockResource(), Locking

TOCIndex