updated verse to version r6p1
[blender.git] / extern / verse / dist / v_gen_pack_s_node.c
1 /*
2 ** This is automatically generated source code -- do not edit.
3 ** Changes are affected either by editing the corresponding protocol
4 ** definition file (v_cmd_def_X.c where X=node type), or by editing
5 ** the code generator itself, in v_cmd_gen.c.
6 */
7
8 #include <stdlib.h>
9 #include <stdio.h>
10
11 #include "v_cmd_gen.h"
12 #if !defined(V_GENERATE_FUNC_MODE)
13 #include "verse.h"
14 #include "v_cmd_buf.h"
15 #include "v_network_out_que.h"
16 #include "v_network.h"
17 #include "v_connection.h"
18 #include "v_util.h"
19
20 void verse_send_packet_ack(uint32 packet_id)
21 {
22         uint8 *buf;
23         unsigned int buffer_pos = 0;
24         VCMDBufHead *head;
25         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
26         buf = ((VCMDBuffer10 *)head)->buf;
27
28         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 7);  /* Pack the command. */
29 #if defined V_PRINT_SEND_COMMANDS
30 #endif
31         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], packet_id);
32         v_cmd_buf_set_unique_address_size(head, buffer_pos);
33         v_cmd_buf_set_size(head, buffer_pos);
34         v_noq_send_ack_nak_buf(v_con_get_network_queue(), head);
35         return;
36         v_cmd_buf_set_size(head, buffer_pos);
37         v_noq_send_buf(v_con_get_network_queue(), head);
38 }
39
40 unsigned int v_unpack_packet_ack(const char *buf, size_t buffer_length)
41 {
42         unsigned int buffer_pos = 0;
43         void (* func_packet_ack)(void *user_data, uint32 packet_id);
44         uint32 packet_id;
45         
46         func_packet_ack = v_fs_get_user_func(7);
47         if(buffer_length < 4)
48                 return -1;
49         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &packet_id);
50 #if defined V_PRINT_RECEIVE_COMMANDS
51 #endif
52         if(func_packet_ack != NULL)
53                 func_packet_ack(v_fs_get_user_data(7), packet_id);
54
55         return buffer_pos;
56 }
57
58 void verse_send_packet_nak(uint32 packet_id)
59 {
60         uint8 *buf;
61         unsigned int buffer_pos = 0;
62         VCMDBufHead *head;
63         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
64         buf = ((VCMDBuffer10 *)head)->buf;
65
66         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 8);  /* Pack the command. */
67 #if defined V_PRINT_SEND_COMMANDS
68 #endif
69         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], packet_id);
70         v_cmd_buf_set_unique_address_size(head, buffer_pos);
71         v_cmd_buf_set_size(head, buffer_pos);
72         v_noq_send_ack_nak_buf(v_con_get_network_queue(), head);
73         return;
74         v_cmd_buf_set_size(head, buffer_pos);
75         v_noq_send_buf(v_con_get_network_queue(), head);
76 }
77
78 unsigned int v_unpack_packet_nak(const char *buf, size_t buffer_length)
79 {
80         unsigned int buffer_pos = 0;
81         void (* func_packet_nak)(void *user_data, uint32 packet_id);
82         uint32 packet_id;
83         
84         func_packet_nak = v_fs_get_user_func(8);
85         if(buffer_length < 4)
86                 return -1;
87         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &packet_id);
88 #if defined V_PRINT_RECEIVE_COMMANDS
89 #endif
90         if(func_packet_nak != NULL)
91                 func_packet_nak(v_fs_get_user_data(8), packet_id);
92
93         return buffer_pos;
94 }
95
96 void verse_send_node_index_subscribe(uint32 mask)
97 {
98         uint8 *buf;
99         unsigned int buffer_pos = 0;
100         VCMDBufHead *head;
101         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
102         buf = ((VCMDBuffer10 *)head)->buf;
103
104         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 9);  /* Pack the command. */
105 #if defined V_PRINT_SEND_COMMANDS
106         printf("send: verse_send_node_index_subscribe(mask = %u );\n", mask);
107 #endif
108         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], mask);
109         if(mask == (uint32) ~0u)
110                 v_cmd_buf_set_unique_address_size(head, 5);
111         else
112                 v_cmd_buf_set_address_size(head, 5);
113         v_cmd_buf_set_size(head, buffer_pos);
114         v_noq_send_buf(v_con_get_network_queue(), head);
115 }
116
117 unsigned int v_unpack_node_index_subscribe(const char *buf, size_t buffer_length)
118 {
119         unsigned int buffer_pos = 0;
120         void (* func_node_index_subscribe)(void *user_data, uint32 mask);
121         uint32 mask;
122         
123         func_node_index_subscribe = v_fs_get_user_func(9);
124         if(buffer_length < 4)
125                 return -1;
126         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &mask);
127 #if defined V_PRINT_RECEIVE_COMMANDS
128         printf("receive: verse_send_node_index_subscribe(mask = %u ); callback = %p\n", mask, v_fs_get_user_func(9));
129 #endif
130         if(func_node_index_subscribe != NULL)
131                 func_node_index_subscribe(v_fs_get_user_data(9), mask);
132
133         return buffer_pos;
134 }
135
136 void verse_send_node_create(VNodeID node_id, VNodeType type, VNodeOwner owner)
137 {
138         uint8 *buf;
139         unsigned int buffer_pos = 0;
140         VCMDBufHead *head;
141         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
142         buf = ((VCMDBuffer10 *)head)->buf;
143
144         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 10); /* Pack the command. */
145 #if defined V_PRINT_SEND_COMMANDS
146         printf("send: verse_send_node_create(node_id = %u type = %u owner = %u );\n", node_id, type, owner);
147 #endif
148         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
149         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
150         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)owner);
151         if(node_id == (uint32) ~0u)
152                 v_cmd_buf_set_unique_address_size(head, 5);
153         else
154                 v_cmd_buf_set_address_size(head, 5);
155         v_cmd_buf_set_size(head, buffer_pos);
156         v_noq_send_buf(v_con_get_network_queue(), head);
157 }
158
159 void verse_send_node_destroy(VNodeID node_id)
160 {
161         uint8 *buf;
162         unsigned int buffer_pos = 0;
163         VCMDBufHead *head;
164         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
165         buf = ((VCMDBuffer10 *)head)->buf;
166
167         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 10); /* Pack the command. */
168 #if defined V_PRINT_SEND_COMMANDS
169         printf("send: verse_send_node_destroy(node_id = %u );\n", node_id);
170 #endif
171         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
172         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
173         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
174         if(node_id == (uint32) ~0u)
175                 v_cmd_buf_set_unique_address_size(head, 5);
176         else
177                 v_cmd_buf_set_address_size(head, 5);
178         v_cmd_buf_set_size(head, buffer_pos);
179         v_noq_send_buf(v_con_get_network_queue(), head);
180 }
181
182 unsigned int v_unpack_node_create(const char *buf, size_t buffer_length)
183 {
184         uint8 enum_temp;
185         unsigned int buffer_pos = 0;
186         void (* func_node_create)(void *user_data, VNodeID node_id, VNodeType type, VNodeOwner owner);
187         VNodeID node_id;
188         VNodeType type;
189         VNodeOwner owner;
190         
191         func_node_create = v_fs_get_user_func(10);
192         if(buffer_length < 4)
193                 return -1;
194         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
195         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
196         type = (VNodeType)enum_temp;
197         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
198         owner = (VNodeOwner)enum_temp;
199 #if defined V_PRINT_RECEIVE_COMMANDS
200         if(owner == (uint8) ~0u || type >= V_NT_NUM_TYPES)
201                 printf("receive: verse_send_node_destroy(node_id = %u ); callback = %p\n", node_id, v_fs_get_alias_user_func(10));
202         else
203                 printf("receive: verse_send_node_create(node_id = %u type = %u owner = %u ); callback = %p\n", node_id, type, owner, v_fs_get_user_func(10));
204 #endif
205         if(owner == (uint8) ~0u || type >= V_NT_NUM_TYPES)
206         {
207                 void (* alias_node_destroy)(void *user_data, VNodeID node_id);
208                 alias_node_destroy = v_fs_get_alias_user_func(10);
209                 if(alias_node_destroy != NULL)
210                         alias_node_destroy(v_fs_get_alias_user_data(10), node_id);
211                 return buffer_pos;
212         }
213         if(func_node_create != NULL)
214                 func_node_create(v_fs_get_user_data(10), node_id, (VNodeType) type, (VNodeOwner) owner);
215
216         return buffer_pos;
217 }
218
219 void verse_send_node_subscribe(VNodeID node_id)
220 {
221         uint8 *buf;
222         unsigned int buffer_pos = 0;
223         VCMDBufHead *head;
224         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
225         buf = ((VCMDBuffer10 *)head)->buf;
226
227         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 11); /* Pack the command. */
228 #if defined V_PRINT_SEND_COMMANDS
229         printf("send: verse_send_node_subscribe(node_id = %u );\n", node_id);
230 #endif
231         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
232         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
233         if(node_id == (uint32) ~0u)
234                 v_cmd_buf_set_unique_address_size(head, 5);
235         else
236                 v_cmd_buf_set_address_size(head, 5);
237         v_cmd_buf_set_size(head, buffer_pos);
238         v_noq_send_buf(v_con_get_network_queue(), head);
239 }
240
241 void verse_send_node_unsubscribe(VNodeID node_id)
242 {
243         uint8 *buf;
244         unsigned int buffer_pos = 0;
245         VCMDBufHead *head;
246         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
247         buf = ((VCMDBuffer10 *)head)->buf;
248
249         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 11); /* Pack the command. */
250 #if defined V_PRINT_SEND_COMMANDS
251         printf("send: verse_send_node_unsubscribe(node_id = %u );\n", node_id);
252 #endif
253         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
254         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
255         if(node_id == (uint32) ~0u)
256                 v_cmd_buf_set_unique_address_size(head, 5);
257         else
258                 v_cmd_buf_set_address_size(head, 5);
259         v_cmd_buf_set_size(head, buffer_pos);
260         v_noq_send_buf(v_con_get_network_queue(), head);
261 }
262
263 unsigned int v_unpack_node_subscribe(const char *buf, size_t buffer_length)
264 {
265         unsigned int buffer_pos = 0;
266         void (* func_node_subscribe)(void *user_data, VNodeID node_id);
267         VNodeID node_id;
268         uint8   alias_bool;
269
270         func_node_subscribe = v_fs_get_user_func(11);
271         if(buffer_length < 4)
272                 return -1;
273         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
274         if(buffer_length < buffer_pos + 1)
275                 return -1;
276         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
277 #if defined V_PRINT_RECEIVE_COMMANDS
278         if(!alias_bool)
279                 printf("receive: verse_send_node_unsubscribe(node_id = %u ); callback = %p\n", node_id, v_fs_get_alias_user_func(11));
280         else
281                 printf("receive: verse_send_node_subscribe(node_id = %u ); callback = %p\n", node_id, v_fs_get_user_func(11));
282 #endif
283         if(!alias_bool)
284         {
285                 void (* alias_node_unsubscribe)(void *user_data, VNodeID node_id);
286                 alias_node_unsubscribe = v_fs_get_alias_user_func(11);
287                 if(alias_node_unsubscribe != NULL)
288                         alias_node_unsubscribe(v_fs_get_alias_user_data(11), node_id);
289                 return buffer_pos;
290         }
291         if(func_node_subscribe != NULL)
292                 func_node_subscribe(v_fs_get_user_data(11), node_id);
293
294         return buffer_pos;
295 }
296
297 void verse_send_tag_group_create(VNodeID node_id, uint16 group_id, const char *name)
298 {
299         uint8 *buf;
300         unsigned int buffer_pos = 0;
301         VCMDBufHead *head;
302         head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
303         buf = ((VCMDBuffer10 *)head)->buf;
304
305         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 16); /* Pack the command. */
306 #if defined V_PRINT_SEND_COMMANDS
307         printf("send: verse_send_tag_group_create(node_id = %u group_id = %u name = %s );\n", node_id, group_id, name);
308 #endif
309         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
310         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
311         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16);
312         if(node_id == (uint32) ~0u || group_id == (uint16) ~0u)
313                 v_cmd_buf_set_unique_address_size(head, 7);
314         else
315                 v_cmd_buf_set_address_size(head, 7);
316         v_cmd_buf_set_size(head, buffer_pos);
317         v_noq_send_buf(v_con_get_network_queue(), head);
318 }
319
320 void verse_send_tag_group_destroy(VNodeID node_id, uint16 group_id)
321 {
322         uint8 *buf;
323         unsigned int buffer_pos = 0;
324         VCMDBufHead *head;
325         head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
326         buf = ((VCMDBuffer10 *)head)->buf;
327
328         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 16); /* Pack the command. */
329 #if defined V_PRINT_SEND_COMMANDS
330         printf("send: verse_send_tag_group_destroy(node_id = %u group_id = %u );\n", node_id, group_id);
331 #endif
332         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
333         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
334         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
335         if(node_id == (uint32) ~0u || group_id == (uint16) ~0u)
336                 v_cmd_buf_set_unique_address_size(head, 7);
337         else
338                 v_cmd_buf_set_address_size(head, 7);
339         v_cmd_buf_set_size(head, buffer_pos);
340         v_noq_send_buf(v_con_get_network_queue(), head);
341 }
342
343 unsigned int v_unpack_tag_group_create(const char *buf, size_t buffer_length)
344 {
345         unsigned int buffer_pos = 0;
346         void (* func_tag_group_create)(void *user_data, VNodeID node_id, uint16 group_id, const char *name);
347         VNodeID node_id;
348         uint16 group_id;
349         char name[16];
350         
351         func_tag_group_create = v_fs_get_user_func(16);
352         if(buffer_length < 6)
353                 return -1;
354         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
355         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id);
356         buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos);
357 #if defined V_PRINT_RECEIVE_COMMANDS
358         if(name[0] == 0)
359                 printf("receive: verse_send_tag_group_destroy(node_id = %u group_id = %u ); callback = %p\n", node_id, group_id, v_fs_get_alias_user_func(16));
360         else
361                 printf("receive: verse_send_tag_group_create(node_id = %u group_id = %u name = %s ); callback = %p\n", node_id, group_id, name, v_fs_get_user_func(16));
362 #endif
363         if(name[0] == 0)
364         {
365                 void (* alias_tag_group_destroy)(void *user_data, VNodeID node_id, uint16 group_id);
366                 alias_tag_group_destroy = v_fs_get_alias_user_func(16);
367                 if(alias_tag_group_destroy != NULL)
368                         alias_tag_group_destroy(v_fs_get_alias_user_data(16), node_id, group_id);
369                 return buffer_pos;
370         }
371         if(func_tag_group_create != NULL)
372                 func_tag_group_create(v_fs_get_user_data(16), node_id, group_id, name);
373
374         return buffer_pos;
375 }
376
377 void verse_send_tag_group_subscribe(VNodeID node_id, uint16 group_id)
378 {
379         uint8 *buf;
380         unsigned int buffer_pos = 0;
381         VCMDBufHead *head;
382         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
383         buf = ((VCMDBuffer10 *)head)->buf;
384
385         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 17); /* Pack the command. */
386 #if defined V_PRINT_SEND_COMMANDS
387         printf("send: verse_send_tag_group_subscribe(node_id = %u group_id = %u );\n", node_id, group_id);
388 #endif
389         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
390         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
391         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
392         if(node_id == (uint32) ~0u || group_id == (uint16) ~0u)
393                 v_cmd_buf_set_unique_address_size(head, 7);
394         else
395                 v_cmd_buf_set_address_size(head, 7);
396         v_cmd_buf_set_size(head, buffer_pos);
397         v_noq_send_buf(v_con_get_network_queue(), head);
398 }
399
400 void verse_send_tag_group_unsubscribe(VNodeID node_id, uint16 group_id)
401 {
402         uint8 *buf;
403         unsigned int buffer_pos = 0;
404         VCMDBufHead *head;
405         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
406         buf = ((VCMDBuffer10 *)head)->buf;
407
408         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 17); /* Pack the command. */
409 #if defined V_PRINT_SEND_COMMANDS
410         printf("send: verse_send_tag_group_unsubscribe(node_id = %u group_id = %u );\n", node_id, group_id);
411 #endif
412         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
413         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
414         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
415         if(node_id == (uint32) ~0u || group_id == (uint16) ~0u)
416                 v_cmd_buf_set_unique_address_size(head, 7);
417         else
418                 v_cmd_buf_set_address_size(head, 7);
419         v_cmd_buf_set_size(head, buffer_pos);
420         v_noq_send_buf(v_con_get_network_queue(), head);
421 }
422
423 unsigned int v_unpack_tag_group_subscribe(const char *buf, size_t buffer_length)
424 {
425         unsigned int buffer_pos = 0;
426         void (* func_tag_group_subscribe)(void *user_data, VNodeID node_id, uint16 group_id);
427         VNodeID node_id;
428         uint16 group_id;
429         uint8   alias_bool;
430
431         func_tag_group_subscribe = v_fs_get_user_func(17);
432         if(buffer_length < 6)
433                 return -1;
434         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
435         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id);
436         if(buffer_length < buffer_pos + 1)
437                 return -1;
438         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
439 #if defined V_PRINT_RECEIVE_COMMANDS
440         if(!alias_bool)
441                 printf("receive: verse_send_tag_group_unsubscribe(node_id = %u group_id = %u ); callback = %p\n", node_id, group_id, v_fs_get_alias_user_func(17));
442         else
443                 printf("receive: verse_send_tag_group_subscribe(node_id = %u group_id = %u ); callback = %p\n", node_id, group_id, v_fs_get_user_func(17));
444 #endif
445         if(!alias_bool)
446         {
447                 void (* alias_tag_group_unsubscribe)(void *user_data, VNodeID node_id, uint16 group_id);
448                 alias_tag_group_unsubscribe = v_fs_get_alias_user_func(17);
449                 if(alias_tag_group_unsubscribe != NULL)
450                         alias_tag_group_unsubscribe(v_fs_get_alias_user_data(17), node_id, group_id);
451                 return buffer_pos;
452         }
453         if(func_tag_group_subscribe != NULL)
454                 func_tag_group_subscribe(v_fs_get_user_data(17), node_id, group_id);
455
456         return buffer_pos;
457 }
458
459 void verse_send_tag_create(VNodeID node_id, uint16 group_id, uint16 tag_id, const char *name, VNTagType type, const VNTag *tag)
460 {
461         uint8 *buf;
462         unsigned int buffer_pos = 0;
463         VCMDBufHead *head;
464         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
465         buf = ((VCMDBuffer10 *)head)->buf;
466
467         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 18); /* Pack the command. */
468 #if defined V_PRINT_SEND_COMMANDS
469         printf("send: verse_send_tag_create(node_id = %u group_id = %u tag_id = %u name = %s type = %u tag = %p );\n", node_id, group_id, tag_id, name, type, tag);
470 #endif
471         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
472         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
473         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], tag_id);
474         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16);
475         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
476         if(type > VN_TAG_BLOB)
477         {
478                 v_cmd_buf_free(head);
479                 return;
480         }
481         switch(type)
482         {
483                 case VN_TAG_BOOLEAN :
484                         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((VNTag *)tag)->vboolean);
485                 break;
486                 case VN_TAG_UINT32 :
487                         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vuint32);
488                 break;
489                 case VN_TAG_REAL64 :
490                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64);
491                 break;
492                 case VN_TAG_STRING :
493                 {
494                         unsigned int i;
495                         for(i = 0; ((VNTag *)tag)->vstring[i] != 0 && i < VN_TAG_MAX_BLOB_SIZE; i++)
496                                 buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((VNTag *)tag)->vstring[i]);
497                         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);
498                 }
499                 break;
500                 case VN_TAG_REAL64_VEC3 :
501                 {
502                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[0]);
503                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[1]);
504                         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[2]);
505                 }
506                 break;
507                 case VN_TAG_LINK :
508                 {
509                         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vlink);
510                 }
511                 break;
512                 case VN_TAG_ANIMATION :
513                 {
514                         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.curve);
515                         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.start);
516                         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.end);
517                 }
518                 break;
519                 case VN_TAG_BLOB :
520                 {
521                         unsigned int i;
522                         if(((VNTag *)tag)->vblob.size > VN_TAG_MAX_BLOB_SIZE)
523                                 ((VNTag *)tag)->vblob.size = VN_TAG_MAX_BLOB_SIZE;
524                         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], ((VNTag *)tag)->vblob.size);
525                         for(i = 0; i < ((VNTag *)tag)->vblob.size; i++)
526                                 buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((uint8 *)((VNTag *)tag)->vblob.blob)[i]);
527                 }
528                 break;
529                 default :
530                         ;
531         }
532         if(node_id == (uint32) ~0u || group_id == (uint16) ~0u || tag_id == (uint16) ~0u)
533                 v_cmd_buf_set_unique_address_size(head, 9);
534         else
535                 v_cmd_buf_set_address_size(head, 9);
536         v_cmd_buf_set_size(head, buffer_pos);
537         v_noq_send_buf(v_con_get_network_queue(), head);
538 }
539
540 void verse_send_tag_destroy(VNodeID node_id, uint16 group_id, uint16 tag_id)
541 {
542         uint8 *buf;
543         unsigned int buffer_pos = 0;
544         VCMDBufHead *head;
545         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
546         buf = ((VCMDBuffer10 *)head)->buf;
547
548         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 18); /* Pack the command. */
549 #if defined V_PRINT_SEND_COMMANDS
550         printf("send: verse_send_tag_destroy(node_id = %u group_id = %u tag_id = %u );\n", node_id, group_id, tag_id);
551 #endif
552         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
553         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
554         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], tag_id);
555         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
556         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
557         if(node_id == (uint32) ~0u || group_id == (uint16) ~0u || tag_id == (uint16) ~0u)
558                 v_cmd_buf_set_unique_address_size(head, 9);
559         else
560                 v_cmd_buf_set_address_size(head, 9);
561         v_cmd_buf_set_size(head, buffer_pos);
562         v_noq_send_buf(v_con_get_network_queue(), head);
563 }
564
565 unsigned int v_unpack_tag_create(const char *buf, size_t buffer_length)
566 {
567         uint8 enum_temp;
568         unsigned int buffer_pos = 0;
569         void (* func_tag_create)(void *user_data, VNodeID node_id, uint16 group_id, uint16 tag_id, const char *name, VNTagType type, const VNTag *tag);
570         VNodeID node_id;
571         uint16 group_id;
572         uint16 tag_id;
573         char name[16];
574         VNTagType type;
575         const VNTag *tag;
576         
577         func_tag_create = v_fs_get_user_func(18);
578         if(buffer_length < 8)
579                 return -1;
580         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
581         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id);
582         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &tag_id);
583         buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos);
584         if(buffer_length < 1 + buffer_pos)
585                 return -1;
586         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
587         type = (VNTagType)enum_temp;
588 #if defined V_PRINT_RECEIVE_COMMANDS
589         if(type >= VN_TAG_TYPE_COUNT)
590                 printf("receive: verse_send_tag_destroy(node_id = %u group_id = %u tag_id = %u ); callback = %p\n", node_id, group_id, tag_id, v_fs_get_alias_user_func(18));
591         else
592                 printf("receive: verse_send_tag_create(node_id = %u group_id = %u tag_id = %u name = %s type = %u ); callback = %p\n", node_id, group_id, tag_id, name, type, v_fs_get_user_func(18));
593 #endif
594         if(type < VN_TAG_TYPE_COUNT)
595         {
596                 VNTag tag;
597                 unsigned int i;
598                 char string[VN_TAG_MAX_BLOB_SIZE];
599                 switch(type)
600                 {
601                         case VN_TAG_BOOLEAN :
602                                 buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &tag.vboolean);
603                         break;
604                         case VN_TAG_UINT32 :
605                                 buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vuint32);
606                         break;
607                         case VN_TAG_REAL64 :
608                                 buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64);
609                         break;
610                         case VN_TAG_STRING :
611                         {
612                                 tag.vstring = string;
613                                 buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], string, VN_TAG_MAX_BLOB_SIZE, buffer_length - buffer_pos);
614                         }
615                         break;
616                         case VN_TAG_REAL64_VEC3 :
617                         {
618                                 buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[0]);
619                                 buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[1]);
620                                 buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[2]);
621                         }
622                         break;
623                         case VN_TAG_LINK :
624                         {
625                                 buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vlink);
626                         }
627                         break;
628                         case VN_TAG_ANIMATION :
629                         {
630                                 buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.curve);
631                                 buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.start);
632                                 buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.end);
633                         }
634                         break;
635                         case VN_TAG_BLOB :
636                         {
637                                 buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &tag.vblob.size);
638                                 if(tag.vblob.size > VN_TAG_MAX_BLOB_SIZE)
639                                         tag.vblob.size = VN_TAG_MAX_BLOB_SIZE;
640                                 tag.vblob.blob = string;
641                                 for(i = 0; i < tag.vblob.size; i++)
642                                         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &string[i]);
643                         }
644                         break;
645                 default :
646                         ;
647                 }
648                 if(func_tag_create != NULL)
649                 func_tag_create(v_fs_get_user_data(18), node_id, group_id, tag_id, name, type, &tag);
650                 return buffer_pos;
651         }
652
653         if(type >= VN_TAG_TYPE_COUNT)
654         {
655                 void (* alias_tag_destroy)(void *user_data, VNodeID node_id, uint16 group_id, uint16 tag_id);
656                 alias_tag_destroy = v_fs_get_alias_user_func(18);
657                 if(alias_tag_destroy != NULL)
658                         alias_tag_destroy(v_fs_get_alias_user_data(18), node_id, group_id, tag_id);
659                 return buffer_pos;
660         }
661         if(func_tag_create != NULL)
662                 func_tag_create(v_fs_get_user_data(18), node_id, group_id, tag_id, name, (VNTagType) type, tag);
663
664         return buffer_pos;
665 }
666
667 void verse_send_node_name_set(VNodeID node_id, const char *name)
668 {
669         uint8 *buf;
670         unsigned int buffer_pos = 0;
671         VCMDBufHead *head;
672         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
673         buf = ((VCMDBuffer10 *)head)->buf;
674
675         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 19); /* Pack the command. */
676 #if defined V_PRINT_SEND_COMMANDS
677         printf("send: verse_send_node_name_set(node_id = %u name = %s );\n", node_id, name);
678 #endif
679         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
680         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 512);
681         if(node_id == (uint32) ~0u)
682                 v_cmd_buf_set_unique_address_size(head, 5);
683         else
684                 v_cmd_buf_set_address_size(head, 5);
685         v_cmd_buf_set_size(head, buffer_pos);
686         v_noq_send_buf(v_con_get_network_queue(), head);
687 }
688
689 unsigned int v_unpack_node_name_set(const char *buf, size_t buffer_length)
690 {
691         unsigned int buffer_pos = 0;
692         void (* func_node_name_set)(void *user_data, VNodeID node_id, const char *name);
693         VNodeID node_id;
694         char name[512];
695         
696         func_node_name_set = v_fs_get_user_func(19);
697         if(buffer_length < 4)
698                 return -1;
699         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
700         buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 512, buffer_length - buffer_pos);
701 #if defined V_PRINT_RECEIVE_COMMANDS
702         printf("receive: verse_send_node_name_set(node_id = %u name = %s ); callback = %p\n", node_id, name, v_fs_get_user_func(19));
703 #endif
704         if(func_node_name_set != NULL)
705                 func_node_name_set(v_fs_get_user_data(19), node_id, name);
706
707         return buffer_pos;
708 }
709
710 #endif
711