Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 6 files changed
  • 0 comments
  • 1 contributor
25  lop/lop_lowlevel.h
@@ -20,7 +20,7 @@
20 20
 #include "lop/lop_osc_types.h"
21 21
 
22 22
 /**
23  
- * \file lop_lowlevel.h The liblo headerfile defining the low-level API
  23
+ * \file lop_lowlevel.h The lop headerfile defining the low-level API
24 24
  * functions.
25 25
  */
26 26
 
@@ -35,11 +35,11 @@ extern "C" {
35 35
 #include "lop/lop_errors.h"
36 36
 
37 37
 /**
38  
- * \defgroup liblolowlevel Low-level OSC API
  38
+ * \defgroup loplowlevel Low-level OSC API
39 39
  *
40 40
  * Use these functions if you require more precise control over OSC message
41 41
  * contruction or handling that what is provided in the high-level functions
42  
- * described in liblo.
  42
+ * described in lop.
43 43
  * @{
44 44
  */
45 45
 
@@ -256,7 +256,22 @@ lop_arg **lop_message_get_argv(lop_message m);
256 256
  */
257 257
 size_t lop_message_length(lop_message m, const char *path);
258 258
 
259  
-
  259
+/**
  260
+ * \brief  Serialise the lop_message object to an area of memory and return a
  261
+ * pointer to the serialised form.  Opposite of lop_message_deserialise().
  262
+ *
  263
+ * \param m The message to be serialised
  264
+ * \param path The path the message will be sent to
  265
+ * \param to The address to serialise to, memory will be allocated if to is
  266
+ * NULL.
  267
+ * \param size If this pointer is non-NULL the size of the memory area
  268
+ * will be written here
  269
+ *
  270
+ * The returned form is suitable to be sent over a low level OSC transport,
  271
+ * having the correct endianess and bit-packed structure.
  272
+ */
  273
+void *lop_message_serialise(lop_message m, const char *path, void *to,
  274
+    size_t *size);
260 275
 
261 276
 /**
262 277
  * \brief  Deserialise a raw OSC message and return a new lop_message object.
@@ -277,7 +292,7 @@ lop_message lop_message_deserialise(void *data, size_t size, int *result);
277 292
  * \brief  Dispatch a raw block of memory containing an OSC message.
278 293
  *
279 294
  * This is useful when a raw block of memory is available that is
280  
- * structured as OSC, and you wish to use liblo to dispatch the
  295
+ * structured as OSC, and you wish to use lop to dispatch the
281 296
  * message to a handler function as if it had been received over the
282 297
  * network.
283 298
  *
6  lop/lop_osc_types.h
@@ -18,14 +18,14 @@
18 18
 #define LOP_OSC_TYPES_H
19 19
 
20 20
 /**
21  
- * \file lop_osc_types.h A liblo header defining OSC-related types and
  21
+ * \file lop_osc_types.h A lop header defining OSC-related types and
22 22
  * constants.
23 23
  */
24 24
 
25 25
 #include <stdint.h>
26 26
 
27 27
 /**
28  
- * \addtogroup liblo
  28
+ * \addtogroup lop
29 29
  * @{
30 30
  */
31 31
 
@@ -41,7 +41,7 @@ typedef struct {
41 41
 } lop_timetag;
42 42
 
43 43
 /**
44  
- * \brief An enumeration of the OSC types liblo can send and receive.
  44
+ * \brief An enumeration of the OSC types lop can send and receive.
45 45
  *
46 46
  * The value of the enumeration is the typechar used to tag messages
47 47
  */
4  lop/lop_types.h
@@ -18,7 +18,7 @@
18 18
 #define LOP_TYPES_H
19 19
 
20 20
 /**
21  
- * \file lop_types.h The liblo headerfile defining types used by this API.
  21
+ * \file lop_types.h The lop headerfile defining types used by this API.
22 22
  */
23 23
 
24 24
 #ifdef __cplusplus
@@ -71,6 +71,8 @@ typedef void *lop_server;
71 71
  */
72 72
 typedef void (*lop_err_handler)(int num, const char *msg, const char *where);
73 73
 
  74
+typedef void (*lop_send_handler)(const char *msg, size_t len, void *arg);
  75
+
74 76
 /**
75 77
  * \brief A callback function to receive notifcation of matching message
76 78
  * arriving in the server.
2  lop_types_internal.h
@@ -5,7 +5,7 @@
5 5
 
6 6
 #include "lop/lop_osc_types.h"
7 7
 
8  
-typedef void (*lop_err_handler)(int num, const char *msg, const char *path);
  8
+typedef void (*lop_err_handler)(int num, const char *msg, const char *where);
9 9
 typedef void (*lop_send_handler)(const char *msg, size_t len, void *arg);
10 10
 
11 11
 struct _lop_method;
24  message.c
@@ -134,7 +134,7 @@ int lop_message_add_varargs_internal(lop_message msg, const char *types,
134 134
 	    s = va_arg(ap, char *);
135 135
 #ifdef __GNUC__
136 136
 	    if (s == (char *)LOP_MARKER_A) {
137  
-		fprintf(stderr, "liblo error: lop_message_add called with "
  137
+		fprintf(stderr, "lop error: lop_message_add called with "
138 138
 			"invalid string pointer for arg %d, probably arg mismatch\n"
139 139
 		        "at %s:%d, exiting.\n", count, file, line);
140 140
 	    }
@@ -164,7 +164,7 @@ int lop_message_add_varargs_internal(lop_message msg, const char *types,
164 164
 	    s = va_arg(ap, char *);
165 165
 #ifdef __GNUC__
166 166
 	    if (s == (char *)LOP_MARKER_A) {
167  
-		fprintf(stderr, "liblo error: lop_message_add called with "
  167
+		fprintf(stderr, "lop error: lop_message_add called with "
168 168
 			"invalid symbol pointer for arg %d, probably arg mismatch\n"
169 169
 		        "at %s:%d, exiting.\n", count, file, line);
170 170
         va_end(ap);
@@ -202,7 +202,7 @@ int lop_message_add_varargs_internal(lop_message msg, const char *types,
202 202
 
203 203
 	default:
204 204
 		ret = -1; // unknown type
205  
-	    fprintf(stderr, "liblo warning: unknown type '%c' at %s:%d\n",
  205
+	    fprintf(stderr, "lop warning: unknown type '%c' at %s:%d\n",
206 206
 		    *(types-1), file, line);
207 207
 	    break;
208 208
 	}
@@ -211,7 +211,7 @@ int lop_message_add_varargs_internal(lop_message msg, const char *types,
211 211
     i = va_arg(ap, uint32_t);
212 212
     if (i != LOP_MARKER_A) {
213 213
 	ret = -2; // bad format/args
214  
-	fprintf(stderr, "liblo error: lop_message_add or lop_message_add_varargs called with "
  214
+	fprintf(stderr, "lop error: lop_message_add or lop_message_add_varargs called with "
215 215
 			"mismatching types and data at\n%s:%d, exiting.\n", file, line);
216 216
     va_end(ap);
217 217
     return ret;
@@ -219,7 +219,7 @@ int lop_message_add_varargs_internal(lop_message msg, const char *types,
219 219
     i = va_arg(ap, uint32_t);
220 220
     if (i != LOP_MARKER_B) {
221 221
 	ret = -2; // bad format/args
222  
-	fprintf(stderr, "liblo error: lop_message_add or lop_message_add_varargs called with "
  222
+	fprintf(stderr, "lop error: lop_message_add or lop_message_add_varargs called with "
223 223
 			"mismatching types and data at\n%s:%d, exiting.\n", file, line);
224 224
     }
225 225
 #endif
@@ -485,7 +485,7 @@ size_t lop_arg_size(lop_type type, void *data)
485 485
 	return lop_blobsize((lop_blob)data);
486 486
 
487 487
     default:
488  
-	fprintf(stderr, "liblo warning: unhandled OSC type '%c' at %s:%d\n", type, __FILE__, __LINE__);
  488
+	fprintf(stderr, "lop warning: unhandled OSC type '%c' at %s:%d\n", type, __FILE__, __LINE__);
489 489
 	return 0;
490 490
     }
491 491
 
@@ -658,7 +658,7 @@ void lop_arg_host_endian(lop_type type, void *data)
658 658
 	break;
659 659
 
660 660
     default:
661  
-	fprintf(stderr, "liblo warning: unhandled OSC type '%c' at %s:%d\n",
  661
+	fprintf(stderr, "lop warning: unhandled OSC type '%c' at %s:%d\n",
662 662
 		type, __FILE__, __LINE__);
663 663
 	break;
664 664
     }
@@ -692,7 +692,7 @@ void lop_arg_network_endian(lop_type type, void *data)
692 692
         break;
693 693
 
694 694
     default:
695  
-        fprintf(stderr, "liblo warning: unhandled OSC type '%c' at %s:%d\n",
  695
+        fprintf(stderr, "lop warning: unhandled OSC type '%c' at %s:%d\n",
696 696
                 type, __FILE__, __LINE__);
697 697
         break;
698 698
     }
@@ -882,7 +882,7 @@ void lop_message_pp(lop_message m)
882 882
     }
883 883
     putchar('\n');
884 884
     if (d != end) {
885  
-	fprintf(stderr, "liblo warning: type and data do not match (off by %d) in message %p\n",
  885
+	fprintf(stderr, "lop warning: type and data do not match (off by %d) in message %p\n",
886 886
             abs((char*)d - (char*)end), m);
887 887
     }
888 888
 }
@@ -987,7 +987,7 @@ void lop_arg_pp_internal(lop_type type, void *data, int bigendian)
987 987
 	break;
988 988
 
989 989
     default:
990  
-	fprintf(stderr, "liblo warning: unhandled type: %c\n", type);
  990
+	fprintf(stderr, "lop warning: unhandled type: %c\n", type);
991 991
 	break;
992 992
     }
993 993
 }
@@ -1035,7 +1035,7 @@ int lop_coerce(lop_type type_to, lop_arg *to, lop_type type_from, lop_arg *from)
1035 1035
 	    break;
1036 1036
 
1037 1037
 	default:
1038  
-	    fprintf(stderr, "liblo: bad coercion: %c -> %c\n", type_from,
  1038
+	    fprintf(stderr, "lop: bad coercion: %c -> %c\n", type_from,
1039 1039
 		    type_to);
1040 1040
 	    return 0;
1041 1041
 	}
@@ -1057,7 +1057,7 @@ lop_hires lop_hires_val(lop_type type, lop_arg *p)
1057 1057
     case LOP_DOUBLE:
1058 1058
 	return p->d;
1059 1059
     default:
1060  
-	fprintf(stderr, "liblo: hires val requested of non numerical type '%c' at %s:%d\n", type, __FILE__, __LINE__);
  1060
+	fprintf(stderr, "lop: hires val requested of non numerical type '%c' at %s:%d\n", type, __FILE__, __LINE__);
1061 1061
 	break;
1062 1062
     }
1063 1063
 
13  server.c
@@ -172,6 +172,16 @@ double lop_server_next_event_delay(lop_server s)
172 172
     return 100.0;
173 173
 }
174 174
 
  175
+static void lop_send_message(lop_server s, const char *path, lop_message msg)
  176
+{
  177
+    const size_t data_len = lop_message_length(msg, path);
  178
+    char *data = lop_message_serialise(msg, path, NULL, NULL);
  179
+
  180
+    s->send_h(data, data_len, s->send_h_arg);
  181
+
  182
+    free(data);
  183
+}
  184
+
175 185
 static void dispatch_method(lop_server s, const char *path,
176 186
     lop_message msg)
177 187
 {
@@ -292,8 +302,7 @@ static void dispatch_method(lop_server s, const char *path,
292 302
 		free(slnew->str);
293 303
 		free(slnew);
294 304
 	    }
295  
-#warning TODO
296  
-	    //lop_send_message(src, "#reply", reply);
  305
+	    lop_send_message(s, "#reply", reply);
297 306
 	    lop_message_free(reply);
298 307
 	}
299 308
     }

No commit comments for this range

Something went wrong with that request. Please try again.