libwebsockets
Lightweight C library for HTML5 websockets
lws-state.h
Go to the documentation of this file.
1  /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
25 struct lws_state_notify_link;
26 struct lws_state_manager;
27 
28 #if defined(LWS_WITH_SYS_STATE)
29 
30 typedef int (*lws_state_notify_t)(struct lws_state_manager *mgr,
31  struct lws_state_notify_link *link,
32  int current, int target);
33 
34 typedef struct lws_state_notify_link {
35  lws_dll2_t list;
36  lws_state_notify_t notify_cb;
37  const char *name;
38 } lws_state_notify_link_t;
39 
40 typedef struct lws_state_manager {
41  lws_dll2_owner_t notify_list;
42  struct lws_context *context;
43  void *parent;
44 #if defined(LWS_WITH_SYS_SMD)
45  lws_smd_class_t smd_class;
46 #endif
49  const char **state_names;
50  const char *name;
51  int state;
52 } lws_state_manager_t;
53 
66 lws_state_reg_notifier(lws_state_manager_t *mgr, lws_state_notify_link_t *nl);
67 
77 lws_state_reg_deregister(lws_state_notify_link_t *nl);
78 
90 lws_state_reg_notifier_list(lws_state_manager_t *mgr,
91  lws_state_notify_link_t * const *nl);
92 
104 lws_state_transition_steps(lws_state_manager_t *mgr, int target);
105 
115 lws_state_transition(lws_state_manager_t *mgr, int target);
116 
117 #else
118 
119 #endif
#define LWS_EXTERN
#define LWS_VISIBLE
uint32_t lws_smd_class_t
Definition: lws-smd.h:31