]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink++.h
appname added, which is used by mdns as part of the service type
[meshlink] / src / meshlink++.h
index 494c6ebda8c7ac406984cae5d0a2da25e1e57a0a..2bc1f8b0d59cdf02b905efa8dbee58cc777a313b 100644 (file)
@@ -182,10 +182,11 @@ namespace meshlink {
                 *  @param nodes        A pointer to an array of pointers to meshlink::node, which should be allocated by the application.
                 *  @param nmemb        The maximum number of pointers that can be stored in the nodes array.
                 *
-                *  @return             The number of known nodes. This can be larger than nmemb, in which case not all nodes were stored in the nodes array.
+                *  @return             The number of known nodes, or -1 in case of an error.
+                *                      This can be larger than nmemb, in which case not all nodes were stored in the nodes array.
                 */
-               size_t get_all_nodes(node **nodes, size_t nmemb) {
-                       return meshlink_get_all_nodes(this, (meshlink_node_t **)nodes, nmemb);
+               node **get_all_nodes(node **nodes, size_t *nmemb) {
+                       return (node **)meshlink_get_all_nodes(this, (meshlink_node_t **)nodes, nmemb);
                }
 
                /// Sign data using the local node's MeshLink key.
@@ -299,6 +300,7 @@ namespace meshlink {
                 *  to hand the data over to the application's thread.
                 *  The callback should also not block itself and return as quickly as possible.
                 *
+                *  @param channel   A handle for the channel.
                 *  @param cb        A pointer to the function which will be called when another node sends data to the local node.
                 */
                void set_channel_accept_cb(channel *channel, channel_accept_cb_t cb) {
@@ -317,8 +319,8 @@ namespace meshlink {
                 *
                 *  @return             A handle for the channel, or NULL in case of an error.
                 */
-               channel *channel_open(node *node, uint16_t port, channel_receive_cb_t recv, const void *data, size_t len) {
-                       return (channel *)meshlink_channel_open(this, node, port, (meshlink_channel_receive_cb_t)recv, data, len);
+               channel *channel_open(node *node, uint16_t port, channel_receive_cb_t cb, const void *data, size_t len) {
+                       return (channel *)meshlink_channel_open(this, node, port, (meshlink_channel_receive_cb_t)cb, data, len);
                }
 
                /// Partially close a reliable stream channel.
@@ -371,11 +373,12 @@ namespace meshlink {
         *
         *  @param confbase The directory in which MeshLink will store its configuration files.
         *  @param name     The name which this instance of the application will use in the mesh.
+        *  @param appname  The application name which will be used in the mesh.
         *
         *  @return         This function will return a pointer to a meshlink::mesh if MeshLink has succesfully set up its configuration files, NULL otherwise.
         */
-       static mesh *open(const char *confbase, const char *name) {
-               return (mesh *)meshlink_open(confbase, name);
+       static mesh *open(const char *confbase, const char *name, const char* appname) {
+               return (mesh *)meshlink_open(confbase, name, appname);
        }
 
        /// Close the MeshLink handle.
@@ -386,6 +389,10 @@ namespace meshlink {
        static void close(mesh *mesh) {
                meshlink_close(mesh);
        }
+
+       static const char *strerror(errno_t err = meshlink_errno) {
+               return meshlink_strerror(err);
+       }
 };
 
 #endif // MESHLINKPP_H