Vuo 2.4.2
Loading...
Searching...
No Matches
VuoOscInputDevice.c
Go to the documentation of this file.
1
10#include "type.h"
11#include "VuoOscInputDevice.h"
12
14#ifdef VUO_COMPILER
16 "title" : "OSC Input Device",
17 "description" : "Information about an OSC input device.",
18 "keywords" : [ ],
19 "version" : "1.0.0",
20 "dependencies" : [
21 "VuoInteger",
22 "VuoText"
23 ]
24 });
25#endif
27
40{
41 return (VuoOscInputDevice){
42 VuoJson_getObjectValue(VuoText, js, "name", NULL),
43 VuoJson_getObjectValue(VuoText, js, "ipAddress", NULL),
45 };
46}
47
52{
53 json_object *js = json_object_new_object();
54
55 if (value.name)
56 json_object_object_add(js, "name", VuoText_getJson(value.name));
57
58 if (value.ipAddress)
59 json_object_object_add(js, "ipAddress", VuoText_getJson(value.ipAddress));
60
61 json_object_object_add(js, "port", VuoInteger_getJson(value.port));
62
63 return js;
64}
65
70{
71 const char *nameOrDefault = value.name ? value.name : "Vuo OSC Server";
72
73 if (value.ipAddress && value.port)
74 return VuoText_format("<code>%s</code><br>receiving from %s port %lld", nameOrDefault, value.ipAddress, value.port);
75 else if (value.ipAddress)
76 return VuoText_format("<code>%s</code><br>receiving from %s on an automatically-selected port", nameOrDefault, value.ipAddress);
77 else if (value.port)
78 return VuoText_format("<code>%s</code><br>receiving from anywhere on port %lld", nameOrDefault, value.port);
79 else
80 return VuoText_format("<code>%s</code><br>receiving from anywhere on an automatically-selected port", nameOrDefault);
81}
82
86VuoOscInputDevice VuoOscInputDevice_make(const VuoText name, const VuoText ipAddress, const VuoInteger port)
87{
88 return (VuoOscInputDevice){name, ipAddress, VuoInteger_clamp(port, 0, 65535)};
89}
90
96{
97 if (!VuoText_areEqual(a.name, b.name))
98 return false;
99
100 if (!VuoText_areEqual(a.ipAddress, b.ipAddress))
101 return false;
102
103 if (a.port != b.port)
104 return false;
105
106 return true;
107}
108
113{
114 VuoType_returnInequality(VuoText, a.name, b.name);
115 VuoType_returnInequality(VuoText, a.ipAddress, b.ipAddress);
116 VuoType_returnInequality(VuoInteger, a.port, b.port);
117 return false;
118}