@@ -51,6 +51,20 @@ static char* getStringFromList(K propValues,int row, const char** value, char* e
51
51
return errStr ;
52
52
}
53
53
54
+ static char * getCharArrayAsStringFromList (K propValues ,int row , const char * * value , char * errStr )
55
+ {
56
+ if ((int )(kK (propValues )[row ]-> t ) == KC )
57
+ {
58
+ // Don't use strndup because it's not supported on early OS X builds
59
+ char * str = malloc (kK (propValues )[row ]-> n + 1 );
60
+ memcpy (str , kC (kK (propValues )[row ]), kK (propValues )[row ]-> n );
61
+ str [kK (propValues )[row ]-> n ] = '\0' ;
62
+ * value = str ;
63
+ return 0 ;
64
+ }
65
+ return errStr ;
66
+ }
67
+
54
68
static char * getIntFromList (K propValues ,int row , int * value , char * errStr )
55
69
{
56
70
if ((int )(kK (propValues )[row ]-> t ) == - KI )
@@ -77,6 +91,7 @@ EXP K connX(K tcpconn,K pname, K opt){
77
91
return krr ("options" );
78
92
client = 0 ;
79
93
94
+ MQTTClient_willOptions will_opts = MQTTClient_willOptions_initializer ;
80
95
MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer ;
81
96
82
97
K propNames = (kK (opt )[0 ]);
@@ -115,6 +130,15 @@ EXP K connX(K tcpconn,K pname, K opt){
115
130
errStr = getIntFromList (propValues ,row ,& conn_opts .maxInflightMessages ,"maxInflightMessages type incorrect" );
116
131
else if (strcmp (kS (propNames )[row ],"cleanstart" )== 0 )
117
132
errStr = getIntFromList (propValues ,row ,& conn_opts .cleanstart ,"cleanstart type incorrect" );
133
+ else if (strcmp (kS (propNames )[row ],"lastWillTopic" )== 0 ){
134
+ conn_opts .will = & will_opts ;
135
+ errStr = getStringFromList (propValues ,row ,& will_opts .topicName ,"lastWillTopic type incorrect" );}
136
+ else if (strcmp (kS (propNames )[row ],"lastWillQos" )== 0 )
137
+ errStr = getIntFromList (propValues ,row ,& will_opts .qos ,"lastWillQos type incorrect" );
138
+ else if (strcmp (kS (propNames )[row ],"lastWillMessage" )== 0 )
139
+ errStr = getCharArrayAsStringFromList (propValues ,row ,& will_opts .message ,"lastWillMessage type incorrect" );
140
+ else if (strcmp (kS (propNames )[row ],"lastWillRetain" )== 0 )
141
+ errStr = getIntFromList (propValues ,row ,& will_opts .retained ,"lastWillRetain type incorrect" );
118
142
else
119
143
errStr = "Unsupported conn opt name in dictionary" ;
120
144
}
0 commit comments