Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"en-US,en;q\u003d0.5", "gen_ut":1624197194, "reponame":"libwebsockets", "desc":"libwebsockets lightweight C networking library", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets", "f":3, "items": [ {"schema":"libjg2-1", "cid":"a4080709b208c7cb024eb44d4490b921", "oid":{ "oid": "2012270bebe9b5c52d25f0ad7deb58f6fbb7066f", "alias": [ "refs/heads/main","refs/heads/master"]},"blobname": "include/libwebsockets/lws-dll2.h", "blob": "/*\n * libwebsockets - small server side websockets and web server implementation\n *\n * Copyright (C) 2010 - 2019 Andy Green \u003candy@warmcat.com\u003e\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \u0022Software\u0022), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \u0022AS IS\u0022, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/** \u005cdefgroup ll linked-lists\n* ##Linked list apis\n*\n* simple single and doubly-linked lists\n*/\n///@{\n\n/**\n * lws_start_foreach_ll(): linkedlist iterator helper start\n *\n * \u005cparam type: type of iteration, eg, struct xyz *\n * \u005cparam it: iterator var name to create\n * \u005cparam start: start of list\n *\n * This helper creates an iterator and starts a while (it) {\n * loop. The iterator runs through the linked list starting at start and\n * ends when it gets a NULL.\n * The while loop should be terminated using lws_start_foreach_ll().\n */\n#define lws_start_foreach_ll(type, it, start)\u005c\n{ \u005c\n\ttype it \u003d start; \u005c\n\twhile (it) {\n\n/**\n * lws_end_foreach_ll(): linkedlist iterator helper end\n *\n * \u005cparam it: same iterator var name given when starting\n * \u005cparam nxt: member name in the iterator pointing to next list element\n *\n * This helper is the partner for lws_start_foreach_ll() that ends the\n * while loop.\n */\n\n#define lws_end_foreach_ll(it, nxt) \u005c\n\t\tit \u003d it-\u003enxt; \u005c\n\t} \u005c\n}\n\n/**\n * lws_start_foreach_ll_safe(): linkedlist iterator helper start safe against delete\n *\n * \u005cparam type: type of iteration, eg, struct xyz *\n * \u005cparam it: iterator var name to create\n * \u005cparam start: start of list\n * \u005cparam nxt: member name in the iterator pointing to next list element\n *\n * This helper creates an iterator and starts a while (it) {\n * loop. The iterator runs through the linked list starting at start and\n * ends when it gets a NULL.\n * The while loop should be terminated using lws_end_foreach_ll_safe().\n * Performs storage of next increment for situations where iterator can become invalidated\n * during iteration.\n */\n#define lws_start_foreach_ll_safe(type, it, start, nxt)\u005c\n{ \u005c\n\ttype it \u003d start; \u005c\n\twhile (it) { \u005c\n\t\ttype next_##it \u003d it-\u003enxt;\n\n/**\n * lws_end_foreach_ll_safe(): linkedlist iterator helper end (pre increment storage)\n *\n * \u005cparam it: same iterator var name given when starting\n *\n * This helper is the partner for lws_start_foreach_ll_safe() that ends the\n * while loop. It uses the precreated next_ variable already stored during\n * start.\n */\n\n#define lws_end_foreach_ll_safe(it) \u005c\n\t\tit \u003d next_##it; \u005c\n\t} \u005c\n}\n\n/**\n * lws_start_foreach_llp(): linkedlist pointer iterator helper start\n *\n * \u005cparam type: type of iteration, eg, struct xyz **\n * \u005cparam it: iterator var name to create\n * \u005cparam start: start of list\n *\n * This helper creates an iterator and starts a while (it) {\n * loop. The iterator runs through the linked list starting at the\n * address of start and ends when it gets a NULL.\n * The while loop should be terminated using lws_start_foreach_llp().\n *\n * This helper variant iterates using a pointer to the previous linked-list\n * element. That allows you to easily delete list members by rewriting the\n * previous pointer to the element's next pointer.\n */\n#define lws_start_foreach_llp(type, it, start)\u005c\n{ \u005c\n\ttype it \u003d \u0026(start); \u005c\n\twhile (*(it)) {\n\n#define lws_start_foreach_llp_safe(type, it, start, nxt)\u005c\n{ \u005c\n\ttype it \u003d \u0026(start); \u005c\n\ttype next; \u005c\n\twhile (*(it)) { \u005c\n\t\tnext \u003d \u0026((*(it))-\u003enxt); \u005c\n\n/**\n * lws_end_foreach_llp(): linkedlist pointer iterator helper end\n *\n * \u005cparam it: same iterator var name given when starting\n * \u005cparam nxt: member name in the iterator pointing to next list element\n *\n * This helper is the partner for lws_start_foreach_llp() that ends the\n * while loop.\n */\n\n#define lws_end_foreach_llp(it, nxt) \u005c\n\t\tit \u003d \u0026(*(it))-\u003enxt; \u005c\n\t} \u005c\n}\n\n#define lws_end_foreach_llp_safe(it) \u005c\n\t\tit \u003d next; \u005c\n\t} \u005c\n}\n\n#define lws_ll_fwd_insert(\u005c\n\t___new_object,\t/* pointer to new object */ \u005c\n\t___m_list,\t/* member for next list object ptr */ \u005c\n\t___list_head\t/* list head */ \u005c\n\t\t) {\u005c\n\t\t___new_object-\u003e___m_list \u003d ___list_head; \u005c\n\t\t___list_head \u003d ___new_object; \u005c\n\t}\n\n#define lws_ll_fwd_remove(\u005c\n\t___type,\t/* type of listed object */ \u005c\n\t___m_list,\t/* member for next list object ptr */ \u005c\n\t___target,\t/* object to remove from list */ \u005c\n\t___list_head\t/* list head */ \u005c\n\t) { \u005c\n lws_start_foreach_llp(___type **, ___ppss, ___list_head) { \u005c\n if (*___ppss \u003d\u003d ___target) { \u005c\n *___ppss \u003d ___target-\u003e___m_list; \u005c\n break; \u005c\n } \u005c\n } lws_end_foreach_llp(___ppss, ___m_list); \u005c\n\t}\n\n\n/*\n * doubly linked-list\n */\n\n/*\n * lws_dll2_owner / lws_dll2 : more capable version of lws_dll. Differences:\n *\n * - there's an explicit lws_dll2_owner struct which holds head, tail and\n * count of members.\n *\n * - list members all hold a pointer to their owner. So user code does not\n * have to track anything about exactly what lws_dll2_owner list the object\n * is a member of.\n *\n * - you can use lws_dll unless you want the member count or the ability to\n * not track exactly which list it's on.\n *\n * - layout is compatible with lws_dll (but lws_dll apis will not update the\n * new stuff)\n */\n\n\nstruct lws_dll2;\nstruct lws_dll2_owner;\n\ntypedef struct lws_dll2 {\n\tstruct lws_dll2\t\t*prev;\n\tstruct lws_dll2\t\t*next;\n\tstruct lws_dll2_owner\t*owner;\n} lws_dll2_t;\n\ntypedef struct lws_dll2_owner {\n\tstruct lws_dll2\t\t*tail;\n\tstruct lws_dll2\t\t*head;\n\n\tuint32_t\t\tcount;\n} lws_dll2_owner_t;\n\nLWS_VISIBLE LWS_EXTERN int\nlws_dll2_is_detached(const struct lws_dll2 *d);\n\nstatic LWS_INLINE const struct lws_dll2_owner *\nlws_dll2_owner(const struct lws_dll2 *d) { return d-\u003eowner; }\n\nstatic LWS_INLINE struct lws_dll2 *\nlws_dll2_get_head(struct lws_dll2_owner *owner) { return owner-\u003ehead; }\n\nstatic LWS_INLINE struct lws_dll2 *\nlws_dll2_get_tail(struct lws_dll2_owner *owner) { return owner-\u003etail; }\n\nLWS_VISIBLE LWS_EXTERN void\nlws_dll2_add_head(struct lws_dll2 *d, struct lws_dll2_owner *owner);\n\nLWS_VISIBLE LWS_EXTERN void\nlws_dll2_add_tail(struct lws_dll2 *d, struct lws_dll2_owner *owner);\n\nLWS_VISIBLE LWS_EXTERN void\nlws_dll2_remove(struct lws_dll2 *d);\n\nLWS_VISIBLE LWS_EXTERN int\nlws_dll2_foreach_safe(struct lws_dll2_owner *owner, void *user,\n\t\t int (*cb)(struct lws_dll2 *d, void *user));\n\nLWS_VISIBLE LWS_EXTERN void\nlws_dll2_clear(struct lws_dll2 *d);\n\nLWS_VISIBLE LWS_EXTERN void\nlws_dll2_owner_clear(struct lws_dll2_owner *d);\n\nLWS_VISIBLE LWS_EXTERN void\nlws_dll2_add_before(struct lws_dll2 *d, struct lws_dll2 *after);\n\nLWS_VISIBLE LWS_EXTERN void\nlws_dll2_add_sorted(lws_dll2_t *d, lws_dll2_owner_t *own,\n\t\t int (*compare)(const lws_dll2_t *d, const lws_dll2_t *i));\n\nLWS_VISIBLE LWS_EXTERN void\nlws_dll2_add_sorted_priv(lws_dll2_t *d, lws_dll2_owner_t *own, void *priv,\n\t\t\t int (*compare3)(void *priv, const lws_dll2_t *d,\n\t\t\t\t\t const lws_dll2_t *i));\n\nLWS_VISIBLE LWS_EXTERN void *\n_lws_dll2_search_sz_pl(lws_dll2_owner_t *own, const char *name, size_t namelen,\n\t\t size_t dll2_ofs, size_t ptr_ofs);\n\n/*\n * Searches objects in an owner list linearly and returns one with a given\n * member C-string matching a supplied length-provided string if it exists, else\n * NULL.\n */\n\n#define lws_dll2_search_sz_pl(own, name, namelen, type, membd2list, membptr) \u005c\n\t\t((type *)_lws_dll2_search_sz_pl(own, name, namelen, \u005c\n\t\t\t\t offsetof(type, membd2list), \u005c\n\t\t\t\t offsetof(type, membptr)))\n\n#if defined(_DEBUG)\nvoid\nlws_dll2_describe(struct lws_dll2_owner *owner, const char *desc);\n#else\n#define lws_dll2_describe(x, y)\n#endif\n\n/*\n * these are safe against the current container object getting deleted,\n * since the hold his next in a temp and go to that next. ___tmp is\n * the temp.\n */\n\n#define lws_start_foreach_dll_safe(___type, ___it, ___tmp, ___start) \u005c\n{ \u005c\n\t___type ___it \u003d ___start; \u005c\n\twhile (___it) { \u005c\n\t\t___type ___tmp \u003d (___it)-\u003enext;\n\n#define lws_end_foreach_dll_safe(___it, ___tmp) \u005c\n\t\t___it \u003d ___tmp; \u005c\n\t} \u005c\n}\n\n#define lws_start_foreach_dll(___type, ___it, ___start) \u005c\n{ \u005c\n\t___type ___it \u003d ___start; \u005c\n\twhile (___it) {\n\n#define lws_end_foreach_dll(___it) \u005c\n\t\t___it \u003d (___it)-\u003enext; \u005c\n\t} \u005c\n}\n\n///@}\n\n","s":{"c":1624197194,"u": 533}} ],"g": 3830,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 1, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}