55#include <net_mosq.h>
66#include <send_mosq.h>
77#include <callbacks.h>
8+ #ifndef WITH_SYS_TREE
9+ # define WITH_SYS_TREE
10+ #endif
11+ #include <sys_tree.h>
812
913extern char * last_sub ;
1014extern int last_qos ;
@@ -24,73 +28,6 @@ struct mosquitto *context__init(void)
2428 return m ;
2529}
2630
27- void db__msg_store_free (struct mosquitto__base_msg * store )
28- {
29- int i ;
30-
31- mosquitto_free (store -> data .source_id );
32- mosquitto_free (store -> data .source_username );
33- if (store -> dest_ids ){
34- for (i = 0 ; i < store -> dest_id_count ; i ++ ){
35- mosquitto_free (store -> dest_ids [i ]);
36- }
37- mosquitto_free (store -> dest_ids );
38- }
39- mosquitto_free (store -> data .topic );
40- mosquitto_property_free_all (& store -> data .properties );
41- mosquitto_free (store -> data .payload );
42- mosquitto_free (store );
43- }
44-
45- int db__message_store (const struct mosquitto * source , struct mosquitto__base_msg * stored , uint32_t * message_expiry_interval , enum mosquitto_msg_origin origin )
46- {
47- int rc = MOSQ_ERR_SUCCESS ;
48-
49- UNUSED (origin );
50-
51- if (source && source -> id ){
52- stored -> data .source_id = mosquitto_strdup (source -> id );
53- }else {
54- stored -> data .source_id = mosquitto_strdup ("" );
55- }
56- if (!stored -> data .source_id ){
57- rc = MOSQ_ERR_NOMEM ;
58- goto error ;
59- }
60-
61- if (source && source -> username ){
62- stored -> data .source_username = mosquitto_strdup (source -> username );
63- if (!stored -> data .source_username ){
64- rc = MOSQ_ERR_NOMEM ;
65- goto error ;
66- }
67- }
68- if (source ){
69- stored -> source_listener = source -> listener ;
70- }
71- if (message_expiry_interval ){
72- stored -> data .expiry_time = time (NULL ) + (* message_expiry_interval );
73- }else {
74- stored -> data .expiry_time = 0 ;
75- }
76-
77- stored -> dest_ids = NULL ;
78- stored -> dest_id_count = 0 ;
79- db .msg_store_count ++ ;
80- db .msg_store_bytes += stored -> data .payloadlen ;
81-
82- if (!stored -> data .store_id ){
83- stored -> data .store_id = ++ db .last_db_id ;
84- }
85-
86- HASH_ADD (hh , db .msg_store , data .store_id , sizeof (stored -> data .store_id ), stored );
87-
88- return MOSQ_ERR_SUCCESS ;
89- error :
90- db__msg_store_free (stored );
91- return rc ;
92- }
93-
9431int log__printf (struct mosquitto * mosq , unsigned int priority , const char * fmt , ...)
9532{
9633 UNUSED (mosq );
@@ -159,60 +96,13 @@ int sub__add(struct mosquitto *context, const struct mosquitto_subscription *sub
15996 return MOSQ_ERR_SUCCESS ;
16097}
16198
162- int db__message_insert_incoming (struct mosquitto * context , uint64_t cmsg_id , struct mosquitto__base_msg * msg , bool persist )
163- {
164- UNUSED (context );
165- UNUSED (cmsg_id );
166- UNUSED (msg );
167- UNUSED (persist );
168-
169- return MOSQ_ERR_SUCCESS ;
170- }
171-
172- int db__message_insert_outgoing (struct mosquitto * context , uint64_t cmsg_id , uint16_t mid , uint8_t qos , bool retain , struct mosquitto__base_msg * stored , uint32_t subscription_identifier , bool update , bool persist )
173- {
174- UNUSED (context );
175- UNUSED (cmsg_id );
176- UNUSED (mid );
177- UNUSED (qos );
178- UNUSED (retain );
179- UNUSED (stored );
180- UNUSED (subscription_identifier );
181- UNUSED (update );
182- UNUSED (persist );
183-
184- return MOSQ_ERR_SUCCESS ;
185- }
186-
187- void db__msg_store_ref_dec (struct mosquitto__base_msg * * store )
188- {
189- UNUSED (store );
190- }
191-
192- void db__msg_store_ref_inc (struct mosquitto__base_msg * store )
193- {
194- store -> ref_count ++ ;
195- }
196-
19799void callback__on_disconnect (struct mosquitto * mosq , int rc , const mosquitto_property * props )
198100{
199101 UNUSED (mosq );
200102 UNUSED (rc );
201103 UNUSED (props );
202104}
203105
204- void db__msg_add_to_inflight_stats (struct mosquitto_msg_data * msg_data , struct mosquitto__client_msg * msg )
205- {
206- UNUSED (msg_data );
207- UNUSED (msg );
208- }
209-
210- void db__msg_add_to_queued_stats (struct mosquitto_msg_data * msg_data , struct mosquitto__client_msg * msg )
211- {
212- UNUSED (msg_data );
213- UNUSED (msg );
214- }
215-
216106void context__add_to_by_id (struct mosquitto * context )
217107{
218108 if (context -> in_by_id == false){
@@ -261,3 +151,103 @@ void mosquitto_log_printf(int level, const char *fmt, ...)
261151 UNUSED (level );
262152 UNUSED (fmt );
263153}
154+ struct mosquitto__subhier * sub__add_hier_entry (struct mosquitto__subhier * parent , struct mosquitto__subhier * * sibling , const char * topic , uint16_t len )
155+ {
156+ UNUSED (parent );
157+ UNUSED (sibling );
158+ UNUSED (topic );
159+ UNUSED (len );
160+
161+ return NULL ;
162+ }
163+ void plugin_persist__handle_client_msg_add (struct mosquitto * context , const struct mosquitto__client_msg * cmsg )
164+ {
165+ UNUSED (context );
166+ UNUSED (cmsg );
167+ }
168+ void plugin_persist__handle_client_msg_delete (struct mosquitto * context , const struct mosquitto__client_msg * cmsg )
169+ {
170+ UNUSED (context );
171+ UNUSED (cmsg );
172+ }
173+ void plugin_persist__handle_client_msg_update (struct mosquitto * context , const struct mosquitto__client_msg * cmsg )
174+ {
175+ UNUSED (context );
176+ UNUSED (cmsg );
177+ }
178+ void plugin_persist__handle_client_msg_clear (struct mosquitto * context , uint8_t direction )
179+ {
180+ UNUSED (context );
181+ UNUSED (direction );
182+ }
183+ void plugin_persist__handle_base_msg_delete (struct mosquitto__base_msg * msg )
184+ {
185+ UNUSED (msg );
186+ }
187+ void plugin_persist__handle_subscription_delete (struct mosquitto * context , char * sub )
188+ {
189+ UNUSED (context );
190+ UNUSED (sub );
191+ }
192+ int sub__messages_queue (const char * source_id , const char * topic , uint8_t qos , int retain , struct mosquitto__base_msg * * base_msg )
193+ {
194+ UNUSED (source_id );
195+ UNUSED (topic );
196+ UNUSED (qos );
197+ UNUSED (retain );
198+ * base_msg = NULL ;
199+ return 0 ;
200+ }
201+ void metrics__int_inc (enum mosq_metric_type m , int64_t value )
202+ {
203+ UNUSED (m ); UNUSED (value );
204+ }
205+ void metrics__int_dec (enum mosq_metric_type m , int64_t value )
206+ {
207+ UNUSED (m ); UNUSED (value );
208+ }
209+ int send__publish (struct mosquitto * mosq , uint16_t mid , const char * topic , uint32_t payloadlen , const void * payload , uint8_t qos , bool retain , bool dup , uint32_t subscription_identifier , const mosquitto_property * store_props , uint32_t expiry_interval )
210+ {
211+ UNUSED (mosq );
212+ UNUSED (mid );
213+ UNUSED (topic );
214+ UNUSED (payloadlen );
215+ UNUSED (payload );
216+ UNUSED (qos );
217+ UNUSED (retain );
218+ UNUSED (dup );
219+ UNUSED (subscription_identifier );
220+ UNUSED (store_props );
221+ UNUSED (expiry_interval );
222+
223+ return MOSQ_ERR_SUCCESS ;
224+ }
225+
226+ int send__pubcomp (struct mosquitto * mosq , uint16_t mid , const mosquitto_property * properties )
227+ {
228+ UNUSED (mosq );
229+ UNUSED (mid );
230+ UNUSED (properties );
231+
232+ return MOSQ_ERR_SUCCESS ;
233+ }
234+
235+ int send__pubrec (struct mosquitto * mosq , uint16_t mid , uint8_t reason_code , const mosquitto_property * properties )
236+ {
237+ UNUSED (mosq );
238+ UNUSED (mid );
239+ UNUSED (reason_code );
240+ UNUSED (properties );
241+
242+ return MOSQ_ERR_SUCCESS ;
243+ }
244+
245+ int send__pubrel (struct mosquitto * mosq , uint16_t mid , const mosquitto_property * properties )
246+ {
247+ UNUSED (mosq );
248+ UNUSED (mid );
249+ UNUSED (properties );
250+
251+ return MOSQ_ERR_SUCCESS ;
252+ }
253+
0 commit comments