Documentation

Documentation

Includes

tuya_cloud_types.h

#include "tuya_cloud_types.h"
#include "tuya_cloud_types.h"

Macros

Marco _UNI_POINTER_H

#define _UNI_POINTER_H


      

Marco LIST_HEAD_INIT(name)

#define LIST_HEAD_INIT(name) { &(name), &(name) }
/**
 * @brief define and initialize bidirection list head
 * 
 */

Marco LIST_HEAD(name)

#define LIST_HEAD(name) \
LIST_HEAD name = LIST_HEAD_INIT(name)


      

Marco INIT_LIST_HEAD(ptr)

#define INIT_LIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
/**
 * @brief bidirection list initialization
 * 
 */

Marco NEW_LIST_NODE(type, node)

#define NEW_LIST_NODE(type, node) \
{\
   node = (type *)Malloc(sizeof(type));\
}
/**
 * @brief create a new bidirection list, will call malloc
 * 
 */

Marco FREE_LIST(type, p, list_name)\ {\

#define FREE_LIST(type, p, list_name)\
{\
   type *posnode;\
   while(!tuya_list_empty(&(p)->list_name)) {\
   posnode = tuya_list_entry((&(p)->list_name)->next, type, list_name);\
   tuya_list_del((&(p)->list_name)->next);\
   Free(posnode);\
   }\
}
/**
 * @brief free all objects in the bidirection list
 * 
 */

Marco GetFirstNode(type,p,list_name,pGetNode)\ {\

#define GetFirstNode(type,p,list_name,pGetNode)\
{\
   pGetNode = NULL;\
   while(!tuya_list_empty(&(p)->list_name)){\
   pGetNode = tuya_list_entry((&(p)->list_name)->next, type, list_name);\
   break;\
   }\
}
/**
 * @brief get the first object of the bidirection list
 * 
 */

Marco DeleteNodeAndFree(pDelNode,list_name)\ {\

#define DeleteNodeAndFree(pDelNode,list_name)\
{\
   tuya_list_del(&(pDelNode->list_name));\
   Free(pDelNode);\
}
/**
 * @brief remove the object from bidirection list and free the memory
 * 
 * @note the pDelNode must be the object pointer
 */

Marco DeleteNode(pDelNode,list_name)\ {\

#define DeleteNode(pDelNode,list_name)\
{\
   tuya_list_del(&(pDelNode->list_name));\
}
/**
 * @brief remove the object from the bidirection list
 * 
 */

Marco FreeNode(pDelNode)\ {\

#define FreeNode(pDelNode)\
{\
   Free(pDelNode);\
}
/**
 * @brief free the object in bidirection list
 * 
 */

Marco tuya_list_entry(ptr, type, member)

#define tuya_list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(size_t)(&((type *)0)->member)))
/**
 * @brief cast the bidirection list node to object
 * 
 */

Marco tuya_list_for_each(pos, head)

#define tuya_list_for_each(pos, head) \
for (pos = (head)->next; (pos != NULL) && (pos != (head)); pos = pos->next)
/**
 * @brief traverse the bidirection list, cannot change the bidiretion list during traverse
 * 
 */

Marco tuya_list_for_each_safe(p, n, head)

#define tuya_list_for_each_safe(p, n, head) \
for (p = (head)->next; n = p->next, p != (head); p = n)
/**
 * @brief traverse the bidirection list, can change the bidiretion list during traverse
 * 
 */

Functions

Func tuya_list_empty

INT_T tuya_list_empty(IN CONST P_LIST_HEAD pHead);
/**
 * @brief check if the bidirection list is empty
 * 
 * @param[in] pHead the bidirection list
 * @return 0 means empty, others means empty
 */

Func tuya_list_add

VOID tuya_list_add(IN CONST P_LIST_HEAD pNew, IN CONST P_LIST_HEAD pHead);
/**
 * @brief add new list node into bidirection list
 * 
 * @param[in] pNew the new list node
 * @param[in] pHead the bidirection list
 * @return VOID 
 */

Func tuya_list_add_tail

VOID tuya_list_add_tail(IN CONST P_LIST_HEAD pNew, IN CONST P_LIST_HEAD pHead);
/**
 * @brief add new list node to the tail of the bidirection list
 * 
 * @param[in] pNew the new list node
 * @param[in] pHead the bidirection list
 * @return VOID 
 */

Func tuya_list_splice

VOID tuya_list_splice(IN CONST P_LIST_HEAD pList, IN CONST P_LIST_HEAD pHead);
/**
 * @brief splice two dibrection list
 * 
 * @param[in] pList the bidirection list need to splice
 * @param[in] pHead the bidirection list
 * @return VOID 
 */

Func tuya_list_del

VOID tuya_list_del(IN CONST P_LIST_HEAD pEntry);
/**
 * @brief remove a list node from bidirection list
 * 
 * @param[in] pEntry the list node need to remove
 * @return VOID 
 */

Func tuya_list_del_init

VOID tuya_list_del_init(IN CONST P_LIST_HEAD pEntry);
/**
 * @brief remove a list node from bidirection list and initialize it
 * 
 * @param[in] pEntry the list node need to remove and initialize
 * @return VOID 
 */

Vars

Consts

Types

Typedefs

Typedef LIST_HEAD,*P_LIST_HEAD;

typedef struct tuya_list_head 
{
   struct tuya_list_head *next, *prev;
}LIST_HEAD,*P_LIST_HEAD;
/**
 * @brief bidirection list head
 * 
 */