text
stringlengths
0
357
*
* @memberof dc_array_t
* @param array The array object.
* @param index Index of the item. Must be between 0 and dc_array_get_cnt()-1.
* @return Chat-id of the item at the given index.
* 0 if there is no chat-id bound to the given item,
*/
uint32_t dc_array_get_chat_id(const dc_array_t* array, size_t index)
{
if (array==NULL || array->magic!=DC_ARRAY_MAGIC || index>=array->count
|| array->type!=DC_ARRAY_LOCATIONS || array->array[index]==0 ) {
return 0;
}
return ((struct _dc_location*)array->array[index])->chat_id;
}
/**
* Return the contact-id of the item at the given index.
*
* @memberof dc_array_t
* @param array The array object.
* @param index Index of the item. Must be between 0 and dc_array_get_cnt()-1.
* @return Contact-id of the item at the given index.
* 0 if there is no contact-id bound to the given item,
*/
uint32_t dc_array_get_contact_id(const dc_array_t* array, size_t index)
{
if (array==NULL || array->magic!=DC_ARRAY_MAGIC || index>=array->count
|| array->type!=DC_ARRAY_LOCATIONS || array->array[index]==0 ) {
return 0;
}
return ((struct _dc_location*)array->array[index])->contact_id;
}
/**
* Return the marker-character of the item at the given index.
* Marker-character are typically bound to locations
* returned by dc_get_locations()
* and are typically created by on-character-messages
* which can also be an emoticon :)
*
* @memberof dc_array_t
* @param array The array object.
* @param index Index of the item. Must be between 0 and dc_array_get_cnt()-1.
* @return Marker-character of the item at the given index.
* NULL if there is no marker-character bound to the given item.
* The returned value must be free()'d after usage.
*/
char* dc_array_get_marker(const dc_array_t* array, size_t index)
{
if (array==NULL || array->magic!=DC_ARRAY_MAGIC || index>=array->count
|| array->type!=DC_ARRAY_LOCATIONS || array->array[index]==0 ) {
return 0;
}
return dc_strdup_keep_null(((struct _dc_location*)array->array[index])->marker);
}
/**
* Return the independent-state of the location at the given index.
* Independent locations do not belong to the track of the user.
*
* @memberof dc_array_t
* @param array The array object.
* @param index Index of the item. Must be between 0 and dc_array_get_cnt()-1.
* @return 0=Location belongs to the track of the user,
* 1=Location was reported independently.
*/
int dc_array_is_independent(const dc_array_t* array, size_t index)
{
if (array==NULL || array->magic!=DC_ARRAY_MAGIC || index>=array->count
|| array->type!=DC_ARRAY_LOCATIONS || array->array[index]==0 ) {
return 0;
}
return ((struct _dc_location*)array->array[index])->independent;
}
/**
* Check if a given ID is present in an array.
*
* @private @memberof dc_array_t
* @param array The array object to search in.
* @param needle The ID to search for.
* @param[out] ret_index If set, this will receive the index. Set to NULL if you're not interested in the index.
* @return 1=ID is present in array, 0=ID not found.
*/
int dc_array_search_id(const dc_array_t* array, uint32_t needle, size_t* ret_index)
{
if (array==NULL || array->magic!=DC_ARRAY_MAGIC) {
return 0;
}
uintptr_t* data = array->array;