2.5 / Cleanup

- remove Verse support. This will be brought back in The Future (probably jiri + me)
  This means 5k lines less in blenkernel.
- fix two small errors for global cleanup, now compiles properly with FFMPEG enabled too.
This commit is contained in:
Nathan Letwory 2009-01-04 18:16:34 +00:00
parent 3aeb63cad2
commit 9e7643aa7c
144 changed files with 28 additions and 27435 deletions

@ -57,7 +57,6 @@ OPTION(WITH_PLAYER "Build Player" OFF)
OPTION(WITH_GAMEENGINE "Enable Game Engine" ON)
OPTION(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
OPTION(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
OPTION(WITH_VERSE "Enable Verse (http://verse.blender.org)" OFF)
OPTION(WITH_ELBEEM "Enable Elbeem (Fluid Simulation)" ON)
OPTION(WITH_QUICKTIME "Enable Quicktime Support" OFF)
OPTION(WITH_OPENEXR "Enable OpenEXR Support (http://www.openexr.com)" ON)
@ -425,7 +424,6 @@ ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
#-----------------------------------------------------------------------------
# Common.
SET(VERSE_INC ${CMAKE_SOURCE_DIR}/extern/verse/dist)
SET(FTGL ${CMAKE_SOURCE_DIR}/extern/bFTGL)
SET(FTGL_INC ${FTGL}/include)

@ -46,12 +46,6 @@ if USE_SDK==True:
#BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
#BF_FFMPEG_LIB = 'avformat.a avcodec.a avutil.a'
WITH_BF_VERSE = False
BF_VERSE = "#extern/verse/dist"
BF_VERSE_LIBPATH = "${BF_BUILDDIR}/extern/verse/dist"
BF_VERSE_INCLUDE = BF_VERSE
BF_VERSE_LIBS = "libverse"
# python.org libs install in /library we want to use that for 2.5
#
# if you want py2.5 on leopard without installing

@ -2,10 +2,6 @@ import os
LCGDIR = os.getcwd()+"/../lib/irix-6.5-mips"
LIBDIR = LCGDIR
print LCGDIR
WITH_BF_VERSE = 'false'
BF_VERSE_INCLUDE = "#extern/verse/dist"
BF_PYTHON = LCGDIR+'/python'
BF_PYTHON_VERSION = '2.5'

@ -1,9 +1,6 @@
LCGDIR = '../lib/linux2'
LIBDIR = "${LCGDIR}"
WITH_BF_VERSE = False
BF_VERSE_INCLUDE = "#extern/verse/dist"
BF_PYTHON = '/usr'
BF_PYTHON_VERSION = '2.5'
WITH_BF_STATICPYTHON = False

@ -1,9 +1,6 @@
LCGDIR = '#../lib/windows'
LIBDIR = '${LCGDIR}'
WITH_BF_VERSE = False
BF_VERSE_INCLUDE = "#extern/verse/dist"
WITH_BF_YAFRAY = True
BF_PYTHON = LIBDIR + '/python'

@ -1,9 +1,6 @@
LCGDIR = '#../lib/windows'
LIBDIR = "${LCGDIR}"
WITH_BF_VERSE = False
BF_VERSE_INCLUDE = "#extern/verse/dist"
BF_PYTHON = LIBDIR + '/python'
BF_PYTHON_VERSION = '2.5'
BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'

@ -1,9 +1,6 @@
LCGDIR = '#../lib/windows'
LIBDIR = '${LCGDIR}'
WITH_BF_VERSE = False
BF_VERSE_INCLUDE = "#extern/verse/dist"
# enable ffmpeg support
WITH_BF_FFMPEG = True # -DWITH_FFMPEG
BF_FFMPEG = LIBDIR +'/ffmpeg'

3
extern/SConscript vendored

@ -14,9 +14,6 @@ if env['WITH_BF_BULLET']:
if env['WITH_BF_INTERNATIONAL']:
SConscript(['bFTGL/SConscript'])
if env['WITH_BF_VERSE']:
SConscript(['verse/dist/SConstruct'])
if env['WITH_BF_FFMPEG'] and env['BF_FFMPEG_LIB'] == '':
SConscript(['x264/SConscript'])
SConscript(['libmp3lame/SConscript'])

@ -1,28 +0,0 @@
# $Id$
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# The Original Code is Copyright (C) 2006, Blender Foundation
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): Jacques Beaurain.
#
# ***** END GPL LICENSE BLOCK *****
SUBDIRS(dist)

55
extern/verse/Makefile vendored

@ -1,55 +0,0 @@
#
# $Id$
#
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# The Original Code is Copyright (C) 2002 by Hans Lambermont
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): Jiri Hnidek
#
# ***** END GPL LICENSE BLOCK *****
LIBNAME = verse
SOURCEDIR = extern/$(LIBNAME)
DIR = $(OCGDIR)/$(SOURCEDIR)
DIRS = dist
include nan_subdirs.mk
include nan_compile.mk
include nan_link.mk
DISTDIR = dist
CP = ../../intern/tools/cpifdiff.sh
ifeq ($(OS),windows)
EXT = .exe
endif
install: all debug
@[ -d $(NAN_VERSE) ] || mkdir -p $(NAN_VERSE)
@[ -d $(NAN_VERSE)/include ] || mkdir -p $(NAN_VERSE)/include
@[ -d $(NAN_VERSE)/lib ] || mkdir -p $(NAN_VERSE)/lib
@[ -d $(OCGDIR)/bin ] || mkdir -p $(OCGDIR)/bin
@$(CP) $(DISTDIR)/*.h $(NAN_VERSE)/include
@$(CP) $(DIR)/libverse.a $(NAN_VERSE)/lib
ifeq ($(OS),darwin)
ranlib $(NAN_VERSE)/lib/libverse.a
endif
$(CCC) $(CCFLAGS) $(LDFLAGS) -o $(DIR)/verse$(EXT) $(DIR)/libverse.a $(LIBS) $(SLIBS) $(LLIBS) $(DADD) $(LOPTS)
@$(CP) $(DIR)/verse$(EXT) $(OCGDIR)/bin

@ -1,8 +0,0 @@
Known problems with Verse
2004-03-03
* The source code needs plenty of cleaning up in order to compile more
cleanly.
* License information needs to be added all over the place.
* Decent documentation is missing.

@ -1,90 +0,0 @@
# $Id$
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# The Original Code is Copyright (C) 2006, Blender Foundation
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): Jacques Beaurain.
#
# ***** END GPL LICENSE BLOCK *****
SUBDIRS(mkprot_cmd)
SET(SRC_MKPROT_OUT
v_gen_pack_init.c
v_gen_pack_a_node.c
v_gen_pack_b_node.c
v_gen_pack_c_node.c
v_gen_pack_g_node.c
v_gen_pack_m_node.c
v_gen_pack_o_node.c
v_gen_pack_s_node.c
v_gen_pack_t_node.c
)
SET(INC .)
SET(SRC
v_cmd_buf.c
v_connect.c
v_connection.c
v_encryption.c
v_func_storage.c
v_man_pack_node.c
v_network.c
v_network_in_que.c
v_network_out_que.c
v_pack.c
v_pack_method.c
v_prime.c
v_randgen.c
v_util.c
v_bignum.c
verse_ms.c
${SRC_MKPROT_OUT}
)
BLENDERLIB(verse "${SRC}" "${INC}")
ADD_DEPENDENCIES(verse mkprot)
#verselib = env.BlenderLib(libname='verse', sources=lib_source_files, includes=[], defines=defines, libtype=['core', 'intern'], priority = [5, 5])
SET(SRC_VERSE
vs_connection.c
vs_main.c
vs_node_audio.c
vs_node_bitmap.c
vs_node_curve.c
vs_node_geometry.c
vs_node_head.c
vs_node_material.c
vs_node_object.c
vs_node_particle.c
vs_node_storage.c
vs_node_text.c
vs_master.c
)
ADD_EXECUTABLE(verse_server ${SRC_VERSE})
IF(WIN32)
TARGET_LINK_LIBRARIES(verse_server verse ws2_32)
ELSE(WIN32)
TARGET_LINK_LIBRARIES(verse_server verse)
ENDIF(WIN32)
ADD_DEPENDENCIES(verse_server mkprot)
MESSAGE(STATUS "Configuring verse_server")

@ -1,15 +0,0 @@
Verse Maintainers
This file tries to list credits for the various parts of the
Verse core distribution, and also identify who maintains what.
We are deeply appreciative of any contributions and thank you
all for your time and interest in helping make Verse a better
thing.
* All code was originally written by Eskil Steenberg, and is
being maintained by him and Emil Brink. Contact us through
the project page at http://www.blender.org/modules/verse/.
* SCons build file by N. Letwory, http://www.jester-depot.net/.

@ -1,15 +0,0 @@
#
# Makefile for Verse core; API and reference server.
# This pretty much requires GNU Make, I think.
#
# This build is slightly complicated that part of the C code that
# needs to go into the API implementation is generated by building
# and running other C files (this is the protocol definition).
#
LIBNAME = verse
DIR = $(OCGDIR)/extern/$(LIBNAME)
include nan_compile.mk
# TARGETS = verse

@ -1,102 +0,0 @@
#
# Makefile for Verse core; API and reference server.
# Written by modifying the main GNU Makefile, for nmake.
#
# It is more hard-coded, relying on less intelligence in
# the make tool.
#
# This build is slightly complicated that part of the C code that
# needs to go into the API implementation is generated by building
# and running other C files (this is the protocol definition).
#
CC = cl
CFLAGS =
LDFLAGS = -pg
AR = ar
ARFLAGS = rus
RANLIB = ranlib
TARGETS = verse.lib verse.exe
# Automatically generated protocol things.
PROT_DEF = v_cmd_def_a.c v_cmd_def_b.c v_cmd_def_c.c v_cmd_def_g.c v_cmd_def_m.c v_cmd_def_o.c v_cmd_def_s.c v_cmd_def_t.c
PROT_TOOL = v_cmd_gen.c $(PROT_DEF)
PROT_OUT = v_gen_pack_init.c v_gen_unpack_func.h verse.h \
v_gen_pack_a_node.c v_gen_pack_b_node.c v_gen_pack_c_node.c v_gen_pack_g_node.c v_gen_pack_m_node.c v_gen_pack_o_node.c v_gen_pack_s_node.c v_gen_pack_t_node.c
# The API implementation is the protocol code plus a few bits.
LIBVERSE_SRC = v_gen_pack_init.c v_gen_unpack_func.h verse.h v_gen_pack_a_node.c v_gen_pack_b_node.c v_gen_pack_c_node.c v_gen_pack_g_node.c \
v_gen_pack_m_node.c v_gen_pack_o_node.c v_gen_pack_s_node.c v_gen_pack_t_node.c \
v_bignum.c v_cmd_buf.c v_connect.c \
v_connection.c v_connection.h v_encryption.c \
v_func_storage.c v_internal_verse.h v_man_pack_node.c \
v_network.c v_network.h v_network_in_que.c v_network_out_que.c \
v_pack.c v_pack.h v_pack_method.c v_prime.c v_randgen.c v_util.c
LIBVERSE_OBJ = v_gen_pack_init.obj v_gen_pack_a_node.obj v_gen_pack_b_node.obj v_gen_pack_c_node.obj v_gen_pack_g_node.obj \
v_gen_pack_m_node.obj v_gen_pack_o_node.obj v_gen_pack_s_node.obj v_gen_pack_t_node.obj \
v_bignum.obj v_cmd_buf.obj v_connect.obj \
v_connection.obj v_encryption.obj \
v_func_storage.obj v_man_pack_node.obj \
v_network.obj v_network_in_que.obj v_network_out_que.obj \
v_pack.obj v_pack_method.obj v_prime.obj v_randgen.obj v_util.obj
# The server is a simple 1:1 mapping, but in Windows nmake ... That doesn't help much. :/
VERSE_SRC = vs_connection.c vs_main.c vs_master.c vs_node_audio.c vs_node_bitmap.c vs_node_curve.c vs_node_geometry.c vs_node_head.c vs_node_material.c vs_node_object.c vs_node_particle.c vs_node_storage.c vs_node_text.c
VERSE_OBJ = vs_connection.obj vs_main.obj vs_master.obj vs_node_audio.obj vs_node_bitmap.obj vs_node_curve.obj vs_node_geometry.obj \
vs_node_head.obj vs_node_material.obj vs_node_object.obj vs_node_particle.obj vs_node_storage.obj vs_node_text.obj
# -----------------------------------------------------
ALL: verse.lib verse.exe
verse.exe: $(VERSE_OBJ) verse.lib resources\verse.res
cl /Fe$@ $** wsock32.lib
verse.lib: $(LIBVERSE_OBJ)
link /lib /nologo /out:$@ $**
# -----------------------------------------------------
# Here are the automatically generated pieces of the puzzle.
# Basically, we generate v_gen_pack_X_node.c files by compiling
# the v_cmd_def_X.c files together with some driver glue and
# running the result.
#
# The autogen outputs all depend on the tool.
$(PROT_OUT): mkprot.exe
mkprot.exe
# Build the protocol maker, from the definitions themselves.
mkprot.exe: $(PROT_TOOL) verse_header.h
$(CC) /DV_GENERATE_FUNC_MODE /Fe$@ $(PROT_TOOL)
# Clean away all the generated parts of the protocol implementation.
cleanprot: clean
del mkprot $(PROT_OUT) mkprot.exe
# -----------------------------------------------------
clean:
del *.obj $(TARGETS)
# -----------------------------------------------------
# Utter ugliness to create release archives. Needs to improve, but should work for a while.
dist:
RELEASE=$$( \
R=`grep V_RELEASE_NUMBER verse.h | tr -s ' \t' | tr -d '"\r' | cut -d' ' -f3` ; \
P=`grep V_RELEASE_PATCH verse.h | tr -s ' \t' | tr -d '"\r' | cut -d' ' -f3` ; \
L=`grep V_RELEASE_LABEL verse.h | tr -s ' \t' | tr -d '"\r' | cut -d' ' -f3` ; echo r$${R}p$$P$$L ) ; \
if [ $$RELEASE ]; then ( \
rm -rf /tmp/verse; \
mkdir -p /tmp/verse; \
cp -a * /tmp/verse; \
cd /tmp && zip verse-$$RELEASE.zip -r verse -x 'verse/*CVS*' -x 'verse/.*' ; \
); mv /tmp/verse-$$RELEASE.zip . \
;else \
echo "Couldn't auto-set RELEASE from verse.h, something is fishy" \
;fi

@ -1,173 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Verse README</title>
<style type="text/css">
h1.title {
text-align: center;
}
p.author {
text-align: center;
}
p.note {
background-color: #ffeeee;
margin-left: 5em;
margin-right: 5em;
border-style: solid;
border-color: black;
border-width: thin;
}
pre.shell {
background-color: #ddddff;
border-color: black;
padding: .5em;
border-style: solid;
border-color: black;
border-width: thin;
}
ul.variables {
list-style: none;
font-family: monospace;
}
</style>
</head>
<body>
<h1 class="title">Verse</h1>
<p>
This is the Verse protocol and sample server implementations.
</p>
<p>
For more information, see <a href="http://verse.blender.org/">the Verse web site</a>.
</p>
<h1>Building the Verse Core</h1>
<p class="note">
Note: This section is only of interest to developers, who wish to build the Verse core themselves.
If you have chosen a binary download, you will already have the server and can skip the rest
of this section.
</p>
<p>
Running "make" here will build the API library, "libverse.a" (and its
header file, "verse.h"). These two will then be used to build the
reference Verse server binary, called "verse".
</p>
<p>
If you are more comfortable with <a href="http://www.scons.org/">SCons</a>, and of course have it
installed on your system, you can type "scons" instead.
</p>
<h1>Starting the Server</h1>
<p>
The Verse server is a command-line program, without a graphical user interface.
You simply start it, and it will immediately begin listening for incoming
connections on a network socket. Here is how a typical invocation looks:
</p>
<pre class="shell">~> verse
</pre>
<p>
If you don't ask it to do otherwise, the Verse server will start listening for UDP packets
on its default port. The port number currently used by Verse is 4950.
</p>
<p class="note">
Note: This is not an official <a href="http://www.iana.org/">registered</a>, port number.
It is possible that it gets assigned to someone else, in case Verse will need to change.
</p>
<p>
You can use the following command line options to control the server's operation:
</p>
<dl>
<dt>-h</dt>
<dd>
Print a help text, that shows all understood options.
</dd>
<dt>-ms</dt>
<dd>
Enables master server communications to the default, built-in address. Use the -h option to learn
what this address is. Please note that master server communication is <strong>disabled</strong> by default.
</dd>
<dt>-ms:ip=IP</dt>
<dd>
Sets a new address to use for master server communication. This also implies -ms, i.e. the server
will try to register itself with the given master server. For details on the protocol used to do
this, please see the <a href="http://verse.blender.org/cms/Master_Server__v2.775.0.html">spec</a>.
</dd>
<dt>-ms:de=DESC</dt>
<dd>
Sets the description to use for this server, when registering with the the master server. This is
only used if master server communication is actually enabled. The description is expected to be a
human-readable string, like <code>"A test server, run on a cable modem, and offline during local daytime"</code>
or something.
</dd>
<dt>-ms:ta=TAGS</dt>
<dd>
Sets the tags to use for this server, when registering with the the master server. This is only used
if master server communication is actually enabled. The tags consists of a comma-separated list of
single words. Each word must begin with a letter, and contain only letters, digits, or underscore
characters. For instance: <code>home,r6p1,linux,sweden,open</code>.
</dd>
<dt>-port=N</dt>
<dd>
Use the indicated port number, rather than the default. Note that ports below 1024 are generally
off-limits to ordinary users. Running Verse on such a port is not recommended.
</dd>
<dt>-version</dt>
<dd>
Prints the version string of the server to the terminal, and then exits (successfully). See
<a href="#rellab">below</a> for information how the version string is constructed.
</dd>
</dl>
<p>
For example, here is how to start the server, register it with the default master server, and run
on port number equal to 16333:
</p>
<pre class="shell">~> ./server -ms -port=16333
</pre>
<p>
Here is a more complicated example, that uses an explicit master server address, and also sets both
the description and tags:
</p>
<pre class="shell">~> ./server -ms:ip=master.example.net -ms:de="A test server, for the documentation" -ms:ta=example,docs
</pre>
<p>
Options can occur in any order, with later options overriding earlier ones, in case of conflicts.
</p>
<h1><a name="rellab">Release Labeling</a></h1>
<p>
Verse uses a simple two-level numbering scheme to identify releases.
There is a "release number", and a "patch level" on each release. The
intent is that within a release, the API does not change and neither
should the network protocol. Between releases, we might improve the
API which will require application programmers to update their code
to stay in sync. We can do non-API-altering changes within a release
by increasing the patch level, for bug fixing and other things.
</p>
<p>
The symbols <code>V_RELEASE_NUMBER</code> and <code>V_RELEASE_PATCH</code>
are integer literals that hold the values for the API you have, and can be
used (and displayed) in application source code as you see fit. There is
also a string, <code>V_RELEASE_LABEL</code>, which is sometimes used.
</p>
<p>
To form a complete Verse version number, the above-mentioned symbols are
to be combined like so:
"r<i><code>&lt;V_RELEASE_NUMBER&gt;</code></i>p<i><code>&lt;V_RELEASE_PATCH&gt;&lt;V_RELEASE_LABEL&gt;</code></i>".
So, the following variable values:
<ul class="variables">
<li>V_RELEASE_VERSION = 2
<li>V_RELEASE_VERSION = 51
<li>V_RELEASE_LABEL = "foo"
</ul>
Would generate the version string "<code>r2p51foo</code>".
</p>
</body>
</html>

@ -1,146 +0,0 @@
#!/usr/bin/env python
#
# I think it is quite straight-forward to add new platforms,
# just look at the old makefile and at the existing platforms.
#
# This SConstruct creates a configuration file which can be
# used for tweaking a build.
#
# For more about SConstruct, see <http://www.scons.org/>.
#
import os
import os.path
import sys
import re
import time
import string
from distutils import sysconfig
Import('env')
defines = []
cflags = []
debug_flags = []
extra_flags = []
release_flags = []
warn_flags = []
platform_libs = []
platform_libpath = []
platform_linkflags = []
ourplatform = env['OURPLATFORM']
if ourplatform == 'win32-vc':
print "Building on win32"
defines += ['_WIN32']
warn_flags = ['/Wall']
platform_libs = ['ws2_32']
elif ourplatform == 'win32-mingw':
defines += ['_WIN32', 'WIN32']
platform_libs = ['shell32', 'kernel32', 'gdi32', 'user32', 'ws2_32']
elif ourplatform == 'linux2':
print "Building on linux2"
elif ourplatform == 'openbsd3':
print "Building on openbsd3"
root_build_dir = env['BF_BUILDDIR']
if env['VERSE_BUILD_BINARY'] == 'release':
cflags = extra_flags + release_flags + warn_flags
if ourplatform == 'win32-vc':
defines += ['NDEBUG']
else:
cflags = extra_flags + debug_flags + warn_flags
if ourplatform == 'win32-vc':
#defines += ['_DEBUG'] specifying this makes msvc want to link to python22_d.lib??
platform_linkflags += ['/DEBUG','/PDB:verse.pdb']
verse_env = env.Clone()
cmd_gen_files = (['v_cmd_gen.c',
'v_cmd_def_a.c',
'v_cmd_def_b.c',
'v_cmd_def_c.c',
'v_cmd_def_g.c',
'v_cmd_def_m.c',
'v_cmd_def_o.c',
'v_cmd_def_s.c',
'v_cmd_def_t.c'
])
cmd_gen_deps = (['v_gen_pack_init.c'])
proto_env = env.Clone()
proto_env.Append(CPPDEFINES=['V_GENERATE_FUNC_MODE'])
mkprot_tool = proto_env.Program(target = 'mkprot', source = cmd_gen_files)
mkprot_re = re.compile('v_cmd_def_([a-z]{1}).c')
def mkprot_emitter(target = None, source = None, env = None):
newtargets = list()
for s in source:
p, f = os.path.split(str(s))
m = mkprot_re.match(f)
if m:
newtargets.append("v_gen_pack_"+m.group(1)+"_node.c")
newtargets.extend(['verse.h'])
env.Depends(newtargets, mkprot_tool)
return (newtargets, source)
mkprot_bld = Builder(action = "\"" + mkprot_tool[0].abspath + "\" -src=\""+os.getcwd()+os.sep+"extern"+os.sep+"verse"+os.sep+"dist"+os.sep+os.sep+"\" -dst=\""+os.path.abspath(env['BF_BUILDDIR'])+os.sep+"extern"+os.sep+"verse"+os.sep+"dist"+os.sep+os.sep+"\"",
emitter = mkprot_emitter)
verse_env['BUILDERS']['Protocol'] = mkprot_bld
cmd_gen_deps.extend(verse_env.Protocol('do_mkprot', cmd_gen_files))
cmd_gen_deps.pop()
lib_source_files = (['v_cmd_buf.c',
'v_connect.c',
'v_connection.c',
'v_encryption.c',
'v_func_storage.c',
'v_man_pack_node.c',
'v_network.c',
'v_network_in_que.c',
'v_network_out_que.c',
'v_pack.c',
'v_pack_method.c',
'v_prime.c',
'v_randgen.c',
'v_util.c',
'v_bignum.c',
'verse_ms.c'
])
lib_source_files.extend(cmd_gen_deps)
server_source_files = (['vs_connection.c',
'vs_main.c',
'vs_master.c',
'vs_node_audio.c',
'vs_node_bitmap.c',
'vs_node_curve.c',
'vs_node_geometry.c',
'vs_node_head.c',
'vs_node_material.c',
'vs_node_object.c',
'vs_node_particle.c',
'vs_node_storage.c',
'vs_node_text.c'
])
verselib_env = verse_env.Clone()
verselib_env.Append(CPPDEFINES = defines)
verseserver_env = verse_env.Clone()
verseserver_env.Append(CPPDEFINES = defines)
verseserver_env.Append (LIBPATH = ['.'])
verseserver_env.Append (LIBS= ['verse'])
verseserver_env.Append (LIBS= platform_libs)
verselib_env.BlenderLib(libname='verse', sources=lib_source_files, includes=["."], defines = defines, libtype=['core', 'intern', 'player'], priority = [5, 5, 100])
verseserver_env.BlenderProg(builddir="#"+root_build_dir+os.sep, progname='verse', sources=server_source_files, libs=[],
libpath='#'+env['BF_BUILDDIR']+'/lib')

@ -1,39 +0,0 @@
/* A minimalist Verse example. Ask server for nodes, print information. */
#include <stdio.h>
#include <stdlib.h>
#include "verse.h" /* Bring in the Verse API. */
/* A callback for connection acception: will be called when server accepts this client. */
static void callback_accept_connect(void *user, uint32 avatar, void *address, void *connection, uint8 *host_id)
{
uint32 i, mask = 0;
printf("Connected to a Verse host!\n\nListing nodes:\n");
/* Build node subscription mask. */
for(i = 0; i < V_NT_NUM_TYPES; i++)
mask |= 1 << i;
verse_send_node_index_subscribe(mask); /* Request listing of all nodes. */
}
/* A callback for node creation: is called to report information about existing nodes, too. */
static void callback_node_create(void *user, VNodeID node_id, VNodeType type, VNodeOwner ownership)
{
printf(" Node #%u has type %u\n", node_id, type);
}
int main(void)
{
/* Register callbacks for interesting commands. */
verse_callback_set(verse_send_connect_accept, callback_accept_connect, NULL);
verse_callback_set(verse_send_node_create, callback_node_create, NULL);
/* Kick off program by connecting to Verse host on local machine. */
verse_send_connect("list-nodes", "<secret>", "localhost", NULL);
while(TRUE)
verse_callback_update(10000); /* Listen to network, get callbacks. */
return EXIT_SUCCESS; /* This is never reached. */
}

@ -1,52 +0,0 @@
# $Id$
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# The Original Code is Copyright (C) 2006, Blender Foundation
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): Jacques Beaurain.
#
# ***** END GPL LICENSE BLOCK *****
SET(SRC
../v_cmd_gen.c
../v_cmd_def_a.c
../v_cmd_def_b.c
../v_cmd_def_c.c
../v_cmd_def_g.c
../v_cmd_def_m.c
../v_cmd_def_o.c
../v_cmd_def_s.c
../v_cmd_def_t.c
)
ADD_DEFINITIONS(-DV_GENERATE_FUNC_MODE)
ADD_EXECUTABLE(mkprot ${SRC})
# Uncoment the following to get verse to generate the files using dependency
# tracking without having the generated files submitted in CVS.
#
#ADD_CUSTOM_COMMAND(TARGET mkprot
# POST_BUILD
# COMMAND mkprot -src=${CMAKE_CURRENT_SOURCE_DIR}/../ -dst=${CMAKE_CURRENT_SOURCE_DIR}/../
# MAIN_DEPENDENCY ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/mkprot
# WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}
#)
MESSAGE(STATUS "Configuring mkprot(verse)")

@ -1,11 +0,0 @@
#
# This builds a resource file for the Verse server, for the icon.
#
ALL: verse.res
verse.res: verse.rc
clean:
del *.res

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

@ -1 +0,0 @@
1 ICON verse.ico

Binary file not shown.

@ -1,860 +0,0 @@
/*
* Routines for big (thousands of bits) unsigned integers, and
* doing simple maths operations on them. Written by Emil Brink.
*
* Part of the Verse core, see license details elsewhere.
*
* Bignums are represented as vectors of VBigDig (unsigned short),
* where the first element holds the length of the number in such
* digits. So a 32-bit number would be { 2, low, high }; digits are
* in little-endian format.
*
* Verse's uint16 and uint32 types are *not* used, since there is no
* need to limit the bits. If your machine has 32-bit shorts and 64-
* bit ints, this code should cope.
*
* By using unsigned shorts, which are assumed to be half the size of
* an unsigned int, we can easily do intermediary steps in int-sized
* variables, and thus get space for manual carry-management.
*
* This is the second incarnation of this code, the first one used
* a fixed 2,048-bit VBigNum structure passed by value. It had to be
* replaced since it was too weak for the desired functionality. Now,
* there's roughly 1,5 weeks of time gone into this code, which still
* means it's optimized for simplicity rather than speed.
*
* There has been neither time nor interest to meditate over FFTs and
* Karatsubas. Reasonable improvements are of course welcome, although
* this code *should* not be a bottleneck. Famous last words...
*
* In general, these routines do not do a lot of error checking, they
* assume you know what you're doing. Numbers must have >0 digits.
* Shifts should not be overly large (1e3 bits: safe, ~2e9+: avoid).
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "v_randgen.h"
#include "v_bignum.h"
#define MAX_DIG ((1UL << V_BIGBITS) - 1)
/* ----------------------------------------------------------------------------------------- */
/* Some routines need temporary storage to hold a term or two (the multi-
* plier, for instance). Since we don't want to use malloc()/free(), let's
* just have a bunch of digits that it's possible to allocate from in a
* stack-like manner.
*/
static VBigDig heap[2048 + 32];
static unsigned int heap_pos;
/* Allocate a number of <n> digits, returning it un-initialized. */
static VBigDig * bignum_alloc(unsigned int n)
{
VBigDig *y;
if(heap_pos + n > sizeof heap / sizeof *heap)
{
printf("Out of memory in bignum heap -- unbalanced calls?\n");
return NULL;
}
y = heap + heap_pos;
heap_pos += n + 1;
*y = n;
return y;
}
/* Free a number previously allocated by bignum_allow() above. MUST match in sequences. */
static void bignum_free(const VBigDig *x)
{
heap_pos -= *x + 1;
}
/* ----------------------------------------------------------------------------------------- */
/* Set x from bits. External representation is big-endian byte array. */
void v_bignum_raw_import(VBigDig *x, const void *bits)
{
const unsigned char *bytes = bits;
int i;
for(i = *x++ - 1; i >= 0; i--)
{
x[i] = ((VBigDig) *bytes++) << 8;
x[i] |= *bytes++;
}
}
/* Set bits to value of x. External representation is big-endian byte array. */
void v_bignum_raw_export(const VBigDig *x, void *bits)
{
unsigned char *bytes = bits;
int i;
for(i = *x++ - 1; i >= 0; i--)
{
*bytes++ = x[i] >> 8;
*bytes++ = (unsigned char) x[i];
}
}
/* ----------------------------------------------------------------------------------------- */
/* Assigns x = 0. */
void v_bignum_set_zero(VBigDig *x)
{
memset(x + 1, 0, *x * sizeof *x);
}
/* Assigns x = 1. */
void v_bignum_set_one(VBigDig *x)
{
int i;
for(i = *x++ - 1, *x++ = 1; i > 0; i--)
*x++ = 0;
}
/* Assigns x = y. */
void v_bignum_set_digit(VBigDig *x, VBigDig y)
{
v_bignum_set_zero(x);
x[1] = y;
}
/* Assigns x = <string>, with string in decimal ASCII. Kind of slow. */
void v_bignum_set_string(VBigDig *x, const char *string)
{
unsigned int d;
v_bignum_set_zero(x);
for(; *string && isdigit(*string); string++)
{
v_bignum_mul_digit(x, 10);
d = *string - '0';
v_bignum_add_digit(x, d);
}
}
/* Assigns x = <string>, with string in hexadecimal ASCII. */
void v_bignum_set_string_hex(VBigDig *x, const char *string)
{
unsigned int d;
if(string[0] == '0' && (string[1] == 'x' || string[1] == 'X'))
string += 2;
v_bignum_set_zero(x);
for(; *string && isxdigit(*string); string++)
{
v_bignum_bit_shift_left(x, 4);
d = tolower(*string) - '0';
if(d > 9)
d -= ('a' - '0') - 10;
x[1] |= (d & 0xF);
}
}
/* Performs x = y, taking care to handle different precisions correctly by truncating. */
void v_bignum_set_bignum(VBigDig *x, const VBigDig *y)
{
int xs, ys, i, s;
xs = x[0];
ys = y[0];
if(xs == ys) /* For same sizes, just memcpy() and be done. */
{
memcpy(x + 1, y + 1, xs * sizeof *x);
return;
}
else if(ys > xs)
s = xs;
else
s = ys;
/* Copy as many digits as will fit, and clear any remaining high digits. */
for(i = 1; i <= s; i++)
x[i] = y[i];
for(; i <= xs; i++)
x[i] = 0;
}
/* Performs x = y[msb:msb-bits], right-adjusting the result. */
void v_bignum_set_bignum_part(VBigDig *x, const VBigDig *y, unsigned int msb, unsigned int bits)
{
unsigned int i, bit;
v_bignum_set_zero(x);
if(y == NULL || msb > (y[0] * (CHAR_BIT * sizeof *x)))
return;
for(i = 0; i < bits; i++)
{
bit = msb - (bits - 1) + i;
if(v_bignum_bit_test(y, bit))
v_bignum_bit_set(x, i);
}
}
/* Set x to a random bunch of bits. Should use a real random source. */
void v_bignum_set_random(VBigDig *x, VRandGen *gen)
{
unsigned int s = *x++;
if(gen != NULL)
v_randgen_get(gen, x, s * sizeof *x);
else
{
fprintf(stderr, "** Warning: Calling v_bignum_set_random() without VRandGen is potentially expensive\n");
if((gen = v_randgen_new()) != NULL)
{
v_randgen_get(gen, x, s * sizeof *x);
v_randgen_destroy(gen);
}
else
fprintf(stderr, __FILE__ ": Couldn't create random number generator\n");
}
}
/* Print x in hexadecimal, with 0x prefix but no linefeed. */
void v_bignum_print_hex(const VBigDig *x)
{
int i, s = *x;
printf("0x");
for(i = 0; i < s; i++)
printf("%04X", x[s - i]);
}
/* Print x in hexadecimal, with linefeed. */
void v_bignum_print_hex_lf(const VBigDig *x)
{
v_bignum_print_hex(x);
printf("\n");
}
/* ----------------------------------------------------------------------------------------- */
/* x = ~x. */
void v_bignum_not(VBigDig *x)
{
unsigned int i, s = *x++;
for(i = 0; i < s; i++)
x[i] = ~x[i];
}
int v_bignum_bit_test(const VBigDig *x, unsigned int bit)
{
unsigned int slot = bit / (CHAR_BIT * sizeof *x), m = 1 << (bit % (CHAR_BIT * sizeof *x));
if(slot < x[0])
return (x[slot + 1] & m) != 0;
return 0;
}
/* Compute x |= (1 << bit). */
void v_bignum_bit_set(VBigDig *x, unsigned int bit)
{
unsigned int slot, m;
if(bit >= (*x * (CHAR_BIT * sizeof *x)))
return;
slot = bit / (CHAR_BIT * sizeof *x);
m = 1 << (bit % (CHAR_BIT * sizeof *x));
x[1 + slot] |= m;
}
/* Returns index of most signifant '1' bit of x, or -1 if x == 0. */
int v_bignum_bit_msb(const VBigDig *x)
{
int i;
unsigned int s = *x++;
for(i = s - 1; i >= 0; i--)
{
if(x[i] != 0)
{
int bit = (i + 1) * (CHAR_BIT * sizeof *x) - 1;
VBigDig d = x[i], mask;
for(mask = 1 << (CHAR_BIT * sizeof *x - 1); mask != 0; mask >>= 1, bit--)
{
if(d & mask)
return bit;
}
}
}
return -1;
}
int v_bignum_bit_size(const VBigDig *x)
{
return *x * V_BIGBITS;
}
/* Perform x <<= count. */
void v_bignum_bit_shift_left(VBigDig *x, unsigned int count)
{
unsigned int t, carry, s = *x++;
register int i;
if(count >= CHAR_BIT * sizeof *x) /* Shift whole digits. */
{
unsigned int places = count / (CHAR_BIT * sizeof *x);
for(i = s - 1; i >= (int) places; i--)
x[i] = x[i - places];
for(; i >= 0; i--) /* Clear out the LSBs. */
x[i] = 0;
count -= places * (CHAR_BIT * sizeof *x);
if(count == 0)
return;
}
/* Shift bits. */
for(i = carry = 0; i < (int) s; i++)
{
t = (x[i] << count) | carry;
x[i] = t;
carry = t >> (CHAR_BIT * sizeof *x);
}
}
/* Perform x <<= 1. This is a frequent operation so it can have its own function. */
void v_bignum_bit_shift_left_1(VBigDig *x)
{
register unsigned int t, carry, s = *x++, i;
/* Shift bits. */
for(i = carry = 0; i < s; i++)
{
t = (x[i] << 1) | carry;
x[i] = t;
carry = t >> (CHAR_BIT * sizeof *x);
}
}
/* Perform x >>= count. */
void v_bignum_bit_shift_right(VBigDig *x, unsigned int count)
{
unsigned int t, carry, s = *x++;
int i;
/* Shift entire digits first. */
if(count >= CHAR_BIT * sizeof *x)
{
unsigned int places = count / (CHAR_BIT * sizeof *x);
if(places > s)
{
memset(x, 0, s * sizeof *x);
return;
}
for(i = 0; i < (int) (s - places); i++)
x[i] = x[i + places];
for(; i < (int) s; i++)
x[i] = 0;
count -= places * CHAR_BIT * sizeof *x;
if(count == 0)
return;
}
/* Shift any remaining bits. */
for(i = s - 1, carry = 0; i >= 0; i--)
{
t = x[i] << (CHAR_BIT * sizeof *x);
t >>= count;
t |= carry;
carry = (t & MAX_DIG) << (CHAR_BIT * sizeof *x);
x[i] = t >> (CHAR_BIT * sizeof *x);
}
}
/* ----------------------------------------------------------------------------------------- */
/* Return x == 0. */
int v_bignum_eq_zero(const VBigDig *x)
{
unsigned int i, s = *x++;
for(i = 0; i < s; i++)
if(x[i])
return 0;
return 1;
}
/* Return x == 1. */
int v_bignum_eq_one(const VBigDig *x)
{
unsigned int i, s = *x++;
if(x[0] != 1)
return 0;
for(i = 1; i < s; i++)
if(x[i])
return 0;
return 1;
}
/* Returns x == y, handling different lengths properly. */
int v_bignum_eq(const VBigDig *x, const VBigDig *y)
{
unsigned int i, xs, ys, cs;
if(x == y) /* Quick test thanks to pointer representation. */
return 1;
xs = *x++;
ys = *y++;
if(xs == ys) /* Same size? Then let's be quick about this. */
return memcmp(x, y, xs * sizeof *x) == 0;
else
{
cs = xs < ys ? xs : ys; /* Common size. */
if(memcmp(x, y, cs * sizeof *x) == 0)
{
const VBigDig *l;
if(cs == xs) /* y is longer. */
l = y, i = ys - 1;
else
l = x, i = xs - 1;
for(; i > cs; i--)
if(l[i])
return 0;
return 1;
}
}
return 0;
}
/* Returns x >= y. */
int v_bignum_gte(const VBigDig *x, const VBigDig *y)
{
unsigned int xs, ys;
int i, j, k;
if(x == y)
return 1;
/* Find indexes of highest-most used digit in each of the numbers. */
xs = *x++;
ys = *y++;
for(i = xs - 1; i >= 0; i--)
if(x[i] != 0)
break;
for(j = ys - 1; j >= 0; j--)
if(y[j] != 0)
break;
/* Both zero? */
if(i < 0 && j < 0)
return 1;
/* Quick answers exists for different-sized numbers. Find them. */
if(i < j)
return 0;
if(i > j)
return 1;
/* Compare digit by digit. */
for(k = i; k >= 0; k--)
{
if(x[k] < y[k])
return 0;
if(x[k] > y[k])
return 1;
}
return x[k] >= y[k];
}
/* ----------------------------------------------------------------------------------------- */
/* Computes x += y. */
void v_bignum_add_digit(VBigDig *x, VBigDig y)
{
unsigned int i, s = *x++, t;
t = x[0] + y;
x[0] = t;
if(t > MAX_DIG)
{
for(i = 1; i < s; i++)
{
if(++x[i])
break;
}
}
}
/* Computes x -= y. */
void v_bignum_sub_digit(VBigDig *x, VBigDig y)
{
unsigned int i, s = *x++, t;
t = x[0] - y;
x[0] = t;
if(t > MAX_DIG)
{
for(i = 1; i < s; i++)
{
x[i]--;
if(x[i] < MAX_DIG)
break;
}
}
}
/* Computes x *= y. */
void v_bignum_mul_digit(VBigDig *x, VBigDig y)
{
unsigned int i, s = *x++, carry, t;
for(i = carry = 0; i < s; i++)
{
t = x[i] * y + carry;
x[i] = t;
carry = t >> (CHAR_BIT * sizeof *x);
}
}
/* ----------------------------------------------------------------------------------------- */
/* Computes x += y. */
void v_bignum_add(VBigDig *x, const VBigDig *y)
{
unsigned int i, xs = *x++, ys = *y++, s, carry, t;
s = xs < ys ? xs : ys;
for(i = carry = 0; i < s; i++)
{
t = x[i] + y[i] + carry;
x[i] = t;
carry = t > MAX_DIG;
}
for(; carry && i < xs; i++)
{
t = x[i] + carry;
x[i] = t;
carry = t > MAX_DIG;
}
}
/* Computes x -= y. */
void v_bignum_sub(VBigDig *x, const VBigDig *y)
{
unsigned int i, xs = *x++, ys = *y++, s, carry, t;
if(x == y)
{
v_bignum_set_zero(x - 1);
return;
}
s = xs < ys ? xs : ys;
for(i = carry = 0; i < s; i++)
{
t = x[i] - y[i] - carry;
x[i] = t;
carry = t > MAX_DIG;
}
for(; carry && i < xs; i++)
{
t = x[i] - carry;
x[i] = t;
carry = t > MAX_DIG;
}
}
/* Compute x *= y, using as many digits as is necessary, then truncating the
* result down. This is Algorithm 14.12 from "Handbook of Applied Cryptography".
*/
void v_bignum_mul(VBigDig *x, const VBigDig *y)
{
int n = *x, t = *y, i, j;
VBigDigs uv = 0, c, w[2048];
memset(w, 0, (n + t + 1) * sizeof *w);
for(i = 0; i < t; i++)
{
c = 0;
for(j = 0; j < n; j++)
{
uv = w[i + j] + x[1 + j] * y[1 + i] + c;
w[i + j] = uv & ((1 << V_BIGBITS) - 1);
c = uv >> V_BIGBITS;
}
w[i + n + 1] = uv >> V_BIGBITS;
}
/* Write low words of w back into x. */
for(i = 0; i < *x; i++)
x[1 + i] = w[i];
}
/* Computes x /= y and remainder = x % y. */
void v_bignum_div(VBigDig *x, const VBigDig *y, VBigDig *remainder)
{
VBigDig *q, *work;
int msbx = v_bignum_bit_msb(x), msby = v_bignum_bit_msb(y), next;
/* Compare magnitudes of inputs, allows quick exits. */
if(msby > msbx)
{
if(remainder != NULL)
v_bignum_set_bignum(remainder, x);
v_bignum_set_zero(x);
return;
}
if(msby < 0)
{
v_bignum_set_zero(x);
return;
}
q = bignum_alloc(*x);
v_bignum_set_zero(q);
work = bignum_alloc(*x);
v_bignum_set_bignum_part(work, x, msbx, msby + 1);
for(next = msbx - (msby + 1); next >= -1; next--)
{
v_bignum_bit_shift_left_1(q);
if(v_bignum_gte(work, y))
{
q[1] |= 1;
v_bignum_sub(work, y);
}
v_bignum_bit_shift_left_1(work);
if(v_bignum_bit_test(x, next))
work[1] |= 1;
}
v_bignum_bit_shift_right(work, 1); /* Undo the last shift (when next==-1). */
if(remainder != NULL)
{
/* printf("div() got remainder ");
v_bignum_print_hex_lf(work);
*/
v_bignum_set_bignum(remainder, work);
}
bignum_free(work);
v_bignum_set_bignum(x, q);
bignum_free(q);
}
/* Computes x %= y. */
void v_bignum_mod(VBigDig *x, const VBigDig *y)
{
int digs;
VBigDig *tmp;
/* printf("computing ");
v_bignum_print_hex(x);
printf("L %% ");
v_bignum_print_hex(y);
*/
digs = *x > *y ? *x : *y;
tmp = bignum_alloc(digs);
v_bignum_div(x, y, tmp);
v_bignum_set_bignum(x, tmp);
bignum_free(tmp);
/* printf("L = ");
v_bignum_print_hex_lf(x);
*/
}
/* Initialize Barrett reduction by computing the "mu" helper value. Defined in
* Handbook of Applied Cryptography algorithm 14.42 as floor(b^2k / m).
*/
const VBigDig * v_bignum_reduce_begin(const VBigDig *m)
{
VBigDig *mu;
int k;
for(k = *m; m[k] == 0; k--)
;
/* printf("k=%d -> digits are 0..%u\n", k, k - 1);
printf("computing mu=floor(65536^%d/", 2 * k);
v_bignum_print_hex(m);
printf(")\n");
*/ mu = bignum_alloc(2 * k + 1);
/* b ^ 2k is just 65536 << 2k, i.e. set bit 16 * 2k. */
v_bignum_set_zero(mu);
v_bignum_bit_set(mu, V_BIGBITS * 2 * k);
/* v_bignum_print_hex_lf(mu);*/
v_bignum_div(mu, m, NULL);
return mu;
}
void v_bignum_reduce_end(const VBigDig *mu)
{
bignum_free(mu);
}
/* Compute x % m, using mu as the helper quantity mu, precomputed by the
* routine above.
*/
void v_bignum_reduce(VBigDig *x, const VBigDig *m, const VBigDig *mu)
{
VBigDig *q, *r1, *r2, *r;
int i, k;
for(k = *m; m[k] == 0; k--)
;
/* Step 1, compute the q helper. */
q = bignum_alloc(*x + *mu - (k - 1)); /* Tighter bound number length (was 2 * *x). */
v_bignum_set_bignum(q, x);
v_bignum_bit_shift_right(q, V_BIGBITS * (k - 1));
v_bignum_mul(q, mu);
v_bignum_bit_shift_right(q, V_BIGBITS * (k + 1));
/* Step 2, initialize. */
r1 = bignum_alloc(*x);
r2 = bignum_alloc(*x);
v_bignum_set_bignum(r1, x);
for(i = k + 1; i < *r1; i++)
r1[i + 1] = 0;
v_bignum_set_bignum(r2, q);
v_bignum_mul(r2, m);
for(i = k + 1; i < *r2; i++)
r2[i + 1] = 0;
r = x;
v_bignum_set_bignum(r, r1);
v_bignum_sub(r, r2);
/* Step 3, make sure r is positive. */
if(v_bignum_bit_test(r, V_BIGBITS * *r - 1))
{
VBigDig *term;
term = bignum_alloc(k + 1 * V_BIGBITS);
v_bignum_set_zero(term);
v_bignum_bit_set(term, V_BIGBITS * (k + 1));
v_bignum_add(r, term);
bignum_free(term);
}
/* Step 4, loop. */
while(v_bignum_gte(r, m))
v_bignum_sub(r, m);
bignum_free(r2);
bignum_free(r1);
bignum_free(q);
}
/* Compute x * x using the algorithm 14.16 from "Handbook of Applied Cryptography".
* Note that since 'w' needs to be double-precision (i.e., 32-bit), we cannot allocate
* it using bignum_alloc() cleanly. Thus the static limit, which should be enough here.
* NOTE: This very much assumes V_BIGBITS == 16.
*/
void v_bignum_square_half(VBigDig *x)
{
VBigDigs w[256], uv, c, ouv;
int t = *x / 2, i, j, high;
if(t == 0)
return;
for(; x[t] == 0; t--)
;
memset(w, 0, 2 * t * sizeof *w); /* Clear digits of w. */
/* printf("print %lu, ", ++count);
v_bignum_print_hex(x);
printf("*");
v_bignum_print_hex(x);
*/ for(i = 0; i < t; i++)
{
/* printf("computing w[%d]: %lX + %lX * %lX\n", 2 * i, w[2 * i], x[1 + i], x[1 + i]);*/
uv = w[2 * i] + x[1 + i] * x[1 + i];
/* printf("setting w[%d]=%X [before]\n", 2 * i, uv & 0xffff);*/
w[2 * i] = uv & 0xffff;
c = uv >> V_BIGBITS;
/* printf("uv before=%X, c=%X\n", uv, c);*/
high = 0;
for(j = i + 1; j < t; j++)
{
/* printf("computing uv=%X+2*%X*%X+%X\n", w[i + j], x[1 + j], x[1 + i], c);*/
uv = ((VBigDigs)x[1 + j]) * ((VBigDigs)x[1 + i]);
high = (uv & 0x80000000) != 0;
uv *= 2;
ouv = uv; /* Addition below might wrap and generate high bit. */
uv += w[i + j] + c;
/* printf("ouv=0x%lX uv=0x%lX\n", ouv, uv);*/
high |= uv < ouv;
/* printf("setting w[%d]=%lX [inner] uv=%lX high=%d c=%X\n", i + j, uv & 0xffff, uv, high, c);*/
w[i + j] = uv & 0xffff;
c = (uv >> V_BIGBITS) | (high << V_BIGBITS);
}
/* printf("setting w[%d] to %X [after]\n", i + t, (uv >> 16) | (high << 16));*/
w[i + t] = (uv >> V_BIGBITS) | (high << V_BIGBITS);
}
/* printf("w=0x");
for(i = *x - 1; i >= 0; i--)
printf("%04X.", w[i]);
printf("\n");
*/ /* Write low words of w back into x, trashing it with the square. */
for(i = 0; i < 2 * t; i++)
x[1 + i] = w[i];
for(; i < *x; i++)
x[1 + i] = 0;
/* printf("==");
v_bignum_print_hex_lf(x);
*/
}
/* Computes x = (x^y) % n, where ^ denotes exponentiation. */
void v_bignum_pow_mod(VBigDig *x, const VBigDig *y, const VBigDig *n)
{
VBigDig *tmp;
const VBigDig *mu;
int i, k;
/* printf("computing pow(");
v_bignum_print_hex(x);
printf("L,");
v_bignum_print_hex(y);
printf("L,");
v_bignum_print_hex(n);
printf("L)\n");
*/
tmp = bignum_alloc(2 * *x); /* Squaring needs twice the bits, or lossage occurs. */
v_bignum_set_bignum(tmp, x);
k = v_bignum_bit_msb(y);
mu = v_bignum_reduce_begin(n);
for(i = k - 1; i >= 0; i--)
{
v_bignum_square_half(tmp);
v_bignum_reduce(tmp, n, mu);
if(v_bignum_bit_test(y, i))
{
v_bignum_mul(tmp, x);
v_bignum_reduce(tmp, n, mu);
}
}
v_bignum_set_bignum(x, tmp);
v_bignum_reduce_end(mu);
bignum_free(tmp);
}
/* ----------------------------------------------------------------------------------------- */
#if defined STANDALONE
int main(void)
{
VBigDig VBIGNUM(x, 3648), VBIGNUM(y, 128), VBIGNUM(z, 128);
printf("MAX_DIG=%u\n", MAX_DIG);
v_bignum_set_string_hex(x, "0x433864FE0F8FAC180FF1BC3A5BFD0C5566F6B11679E27294EDCC43056EB73EE118415E0CD6E6519509476EB21341ED0328BA7B14E0ED80D5E100A4549C5202B57B4CF17A74987631B6BA896C0DBA2095A7EDE5B9C4B4EEFCD1B9EF8474BCB7FBD0F64B549625D444847ED1FCB7F8050EB4F22794F694A0FAC6DFFB781C264B227966840185F9216484F6A7954741CB11FC14DEC2937EAD2CE640FD9A4339706BDB5BC355079C2F2F7994669DFA5B20C50D957A676E67C86835037078323A0BDAD3686B8E638749F327A7AD433C0D18BCD2FC970D125914C7FBEE061290A0F0F3572E207");
v_bignum_set_bignum(y, x);
v_bignum_set_digit(z, 77);
printf("x:");
v_bignum_print_hex_lf(x);
printf("y:");
v_bignum_print_hex_lf(y);
printf("r:");
v_bignum_print_hex_lf(z);
v_bignum_pow_mod(x, y, z);
printf(" =");
v_bignum_print_hex_lf(x);
return 0;
}
#endif /* STANDALONE */

@ -1,89 +0,0 @@
/*
* Verse routines for big integer operations.
* Handy in heavy encryption done during connect.
*/
#include <limits.h>
#include "v_randgen.h"
/* ----------------------------------------------------------------------------------------- */
typedef unsigned short VBigDig; /* Type used to hold one digit of a bignum. */
typedef unsigned int VBigDigs; /* Should hold precisely two digits. */
#define V_BIGBITS (CHAR_BIT * sizeof (VBigDig))
/* Use this macro to initialize big number variables, like so:
* VBigDig BIGNUM(foo, 128), BIGNUM(bar, 256);
* Creates automatic variables 'foo' of 128 bits, and 'bar' of 256.
*
* Note that 'bits' must be a multiple of V_BIGBITS, completely
* arbitrary number sizes are not supported by this module.
*/
#define VBIGNUM(n, bits) n[1 + (bits / V_BIGBITS)] = { bits / V_BIGBITS }
/* ----------------------------------------------------------------------------------------- */
/* Import/export numbers from raw bits. The number x must have been allocated
* with the desired number of bits to read/write.
*/
extern void v_bignum_raw_import(VBigDig *x, const void *bits);
extern void v_bignum_raw_export(const VBigDig *x, void *bits);
/* Initializers. */
extern void v_bignum_set_zero(VBigDig *x);
extern void v_bignum_set_one(VBigDig *x);
extern void v_bignum_set_digit(VBigDig *x, VBigDig y);
extern void v_bignum_set_string(VBigDig *x, const char *string); /* Decimal. */
extern void v_bignum_set_string_hex(VBigDig *x, const char *string);
extern void v_bignum_set_bignum(VBigDig *x, const VBigDig *y);
/* x = <bits> most significant <bits> bits of <y>, starting at <msb>. Right-
* adjusted in x, so that e.g. y=0xcafebabec001 msb=47 bits=16 gives x=0xcafe.
*/
extern void v_bignum_set_bignum_part(VBigDig *x, const VBigDig *y,
unsigned int msb, unsigned int bits);
extern void v_bignum_set_random(VBigDig *x, VRandGen *gen);
/* Handy during debugging. */
extern void v_bignum_print_hex(const VBigDig *x);
extern void v_bignum_print_hex_lf(const VBigDig *x);
/* Bit operators. */
extern void v_bignum_not(VBigDig *x);
extern int v_bignum_bit_test(const VBigDig *x, unsigned int bit);
extern void v_bignum_bit_set(VBigDig *x, unsigned int bit);
extern int v_bignum_bit_msb(const VBigDig *x);
extern int v_bignum_bit_size(const VBigDig *x);
extern void v_bignum_bit_shift_left(VBigDig *x, unsigned int count);
extern void v_bignum_bit_shift_left_1(VBigDig *x);
extern void v_bignum_bit_shift_right(VBigDig *x, unsigned int count);
/* Comparators. */
extern int v_bignum_eq_zero(const VBigDig *x); /* x == 0. */
extern int v_bignum_eq_one(const VBigDig *x); /* x == 1. */
extern int v_bignum_eq(const VBigDig *x, const VBigDig *y); /* x == y. */
extern int v_bignum_gte(const VBigDig *x, const VBigDig *y); /* x >= y. */
/* Number vs single-digit arithmetic. */
extern void v_bignum_add_digit(VBigDig *x, VBigDig y); /* x += y. */
extern void v_bignum_sub_digit(VBigDig *x, VBigDig y); /* x -= y. */
extern void v_bignum_mul_digit(VBigDig *x, VBigDig y); /* x *= y. */
/* Arithmetic. */
extern void v_bignum_add(VBigDig *x, const VBigDig *y); /* x += y. */
extern void v_bignum_sub(VBigDig *x, const VBigDig *y); /* x -= y. */
extern void v_bignum_mul(VBigDig *x, const VBigDig *y); /* x *= y. */
extern void v_bignum_div(VBigDig *x, const VBigDig *y, VBigDig *remainder);
extern void v_bignum_mod(VBigDig *x, const VBigDig *y); /* x %= y. */
/* Barrett reducer for fast x % m computation. Requires precalcing step. */
extern const VBigDig * v_bignum_reduce_begin(const VBigDig *m);
extern void v_bignum_reduce(VBigDig *x, const VBigDig *m, const VBigDig *mu);
extern void v_bignum_reduce_end(const VBigDig *mu);
/* Compute x *= x, assuming x only uses half of its actual size. */
extern void v_bignum_square_half(VBigDig *x);
/* Compute pow(x, y, n) == (x raised to the y:th power) modulo n. */
extern void v_bignum_pow_mod(VBigDig *x, const VBigDig *y, const VBigDig *n);

@ -1,119 +0,0 @@
/*
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "verse_header.h"
#include "v_pack.h"
#include "v_cmd_buf.h"
static const size_t vcmdbuf_chunk_size[] = { 10000, 10000, 10000, 10000, 8000, 5000, 500 }; /* If you think memory is cheap, set this to a high value. */
/* Sizes of individual command buffers, indexable by VCMDBufSize values. Switch-killer. */
static const size_t vcmdbuf_size[] = {
sizeof (VCMDBuffer10), sizeof (VCMDBuffer20), sizeof (VCMDBuffer30), sizeof (VCMDBuffer80),
sizeof (VCMDBuffer160), sizeof (VCMDBuffer320), sizeof (VCMDBuffer1500)
};
#define VCMDBUF_INIT_CHUNK_FACTOR 0.5
static struct {
VCMDBufHead *buffers[VCMDBS_COUNT];
unsigned int available[VCMDBS_COUNT];
} VCMDBufData;
static boolean v_cmd_buf_initialized = FALSE;
void cmd_buf_init(void)
{
unsigned int i, j;
VCMDBufHead *buf, *b;
for(i = 0; i < VCMDBS_COUNT; i++)
{
VCMDBufData.buffers[i] = NULL;
VCMDBufData.available[i] = (unsigned int) (vcmdbuf_chunk_size[i] * VCMDBUF_INIT_CHUNK_FACTOR);
for(j = 0, buf = NULL; j < VCMDBufData.available[i]; j++, buf = b)
{
b = v_cmd_buf_allocate(i);
b->next = buf;
}
VCMDBufData.buffers[i] = buf;
}
v_cmd_buf_initialized = TRUE;
}
VCMDBufHead * v_cmd_buf_allocate(VCMDBufSize buf_size)
{
VCMDBufHead *output = NULL;
if(VCMDBufData.buffers[buf_size] != NULL)
{
output = VCMDBufData.buffers[buf_size];
VCMDBufData.buffers[buf_size] = output->next;
VCMDBufData.available[buf_size]--;
}
else
{
if(buf_size < sizeof vcmdbuf_size / sizeof *vcmdbuf_size)
output = malloc(vcmdbuf_size[buf_size]);
else
{
fprintf(stderr, "v_cmd_buf.c: Can't handle buffer size %d\n", buf_size);
return NULL;
}
output->buf_size = buf_size;
}
output->next = NULL;
output->packet = 0;
output->size = 0;
output->address_size = -1;
return output;
}
void v_cmd_buf_free(VCMDBufHead *head)
{
if(VCMDBufData.available[head->buf_size] < vcmdbuf_chunk_size[head->buf_size])
{
head->next = VCMDBufData.buffers[head->buf_size];
VCMDBufData.buffers[head->buf_size] = head;
VCMDBufData.available[head->buf_size]++;
}
else
free(head);
}
void v_cmd_buf_set_size(VCMDBufHead *head, unsigned int size)
{
head->size = size;
}
void v_cmd_buf_set_address_size(VCMDBufHead *head, unsigned int size)
{
unsigned int i;
head->address_size = size;
head->address_sum = 0;
for(i = 1; i < size + 1; i++)
head->address_sum += i * i * (uint32)(((VCMDBuffer1500 *)head)->buf[i - 1]);
}
void v_cmd_buf_set_unique_address_size(VCMDBufHead *head, unsigned int size)
{
static unsigned int i = 0;
head->address_size = size;
head->address_sum = i++;
}
boolean v_cmd_buf_compare(VCMDBufHead *a, VCMDBufHead *b)
{
if(a->address_sum != b->address_sum)
return FALSE;
if(a->address_size != b->address_size)
return FALSE;
return memcmp(((VCMDBuffer1500 *)a)->buf, ((VCMDBuffer1500 *)b)->buf, a->address_size) == 0;
}

@ -1,74 +0,0 @@
/*
**
*/
#include <stdlib.h>
#include "verse_header.h"
#include "v_pack.h"
#define V_NOQ_MAX_PACKET_SIZE 1500
typedef enum {
VCMDBS_10 = 0,
VCMDBS_20 = 1,
VCMDBS_30 = 2,
VCMDBS_80 = 3,
VCMDBS_160 = 4,
VCMDBS_320 = 5,
VCMDBS_1500 = 6,
VCMDBS_COUNT = 7
} VCMDBufSize;
typedef struct {
void *next;
uint32 packet;
unsigned int address_size;
unsigned int address_sum;
VCMDBufSize buf_size;
unsigned int size;
} VCMDBufHead;
typedef struct {
VCMDBufHead head;
uint8 buf[10];
} VCMDBuffer10;
typedef struct {
VCMDBufHead head;
uint8 buf[20];
} VCMDBuffer20;
typedef struct {
VCMDBufHead head;
uint8 buf[30];
} VCMDBuffer30;
typedef struct {
VCMDBufHead head;
uint8 buf[80];
} VCMDBuffer80;
typedef struct {
VCMDBufHead head;
uint8 buf[160];
} VCMDBuffer160;
typedef struct {
VCMDBufHead head;
uint8 buf[320];
} VCMDBuffer320;
typedef struct {
VCMDBufHead head;
uint8 buf[1500];
} VCMDBuffer1500;
extern VCMDBufHead *v_cmd_buf_allocate(VCMDBufSize buf_size);
extern void v_cmd_buf_free(VCMDBufHead *head);
extern void v_cmd_buf_set_size(VCMDBufHead *head, unsigned int size);
extern void v_cmd_buf_set_address_size(VCMDBufHead *head, unsigned int size);
extern void v_cmd_buf_set_unique_address_size(VCMDBufHead *head, unsigned int size);
extern boolean v_cmd_buf_compare(VCMDBufHead *a, VCMDBufHead *b);

@ -1,94 +0,0 @@
/*
* Command definitions for audio node commands.
*/
#include <stdlib.h>
#include <stdio.h>
#include "verse_header.h"
#include "v_cmd_gen.h"
#include "v_cmd_buf.h"
#if defined(V_GENERATE_FUNC_MODE)
void v_gen_audio_cmd_def(void)
{
v_cg_new_cmd(V_NT_AUDIO, "a_buffer_create", 160, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_BUFFER_ID, "buffer_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NAME, "name");
v_cg_add_param(VCGP_ENUM_NAME, "VNABlockType");
v_cg_add_param(VCGP_ENUM, "type");
v_cg_add_param(VCGP_REAL64, "frequency");
v_cg_alias(FALSE, "a_buffer_destroy", "if(name[0] == 0)", 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_AUDIO, "a_buffer_subscribe", 161, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_BUFFER_ID, "layer_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_alias(TRUE, "a_buffer_unsubscribe", NULL, 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_AUDIO, "a_block_set", 162, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "buffer_id");
v_cg_add_param(VCGP_UINT32, "block_index");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_ENUM_NAME, "VNABlockType");
v_cg_add_param(VCGP_ENUM, "type");
v_cg_add_param(VCGP_POINTER_TYPE, "VNABlock");
v_cg_add_param(VCGP_POINTER, "samples");
v_cg_add_param(VCGP_PACK_INLINE, "\tbuffer_pos += vnp_pack_audio_block(&buf[buffer_pos], type, samples);\n");
v_cg_add_param(VCGP_UNPACK_INLINE, "\tif(type <= VN_A_BLOCK_REAL64)\n\t{\n"
"\t\tVNABlock\tblock;\n"
"\t\tbuffer_pos += vnp_unpack_audio_block(&buf[buffer_pos], type, &block);\n"
"\t\tif(func_a_block_set != NULL)\n"
"\t\t\tfunc_a_block_set(v_fs_get_user_data(162), node_id, buffer_id, block_index, (VNABlockType) type, &block);\n"
"\t\treturn buffer_pos;\n"
"\t}\n");
v_cg_alias(FALSE, "a_block_clear", "if(type > VN_A_BLOCK_REAL64)", 3, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_AUDIO, "a_stream_create", 163, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "stream_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NAME, "name");
v_cg_alias(FALSE, "a_stream_destroy", "if(name[0] == 0)", 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_AUDIO, "a_stream_subscribe", 164, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "stream_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_alias(TRUE, "a_stream_unsubscribe", NULL, 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_AUDIO, "a_stream", 165, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "stream_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT32, "time_s");
v_cg_add_param(VCGP_UINT32, "time_f");
v_cg_add_param(VCGP_ENUM_NAME, "VNABlockType");
v_cg_add_param(VCGP_ENUM, "type");
v_cg_add_param(VCGP_REAL64, "frequency");
v_cg_add_param(VCGP_POINTER_TYPE, "VNABlock");
v_cg_add_param(VCGP_POINTER, "samples");
v_cg_add_param(VCGP_PACK_INLINE, "\tbuffer_pos += vnp_pack_audio_block(&buf[buffer_pos], type, samples);\n");
v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n\t\tVNABlock\tblock;\n\tbuffer_pos += vnp_unpack_audio_block(&buf[buffer_pos], type, &block);\n"
"\t\tif(func_a_stream != NULL)\n"
"\t\t\tfunc_a_stream(v_fs_get_user_data(165), node_id, stream_id, time_s, time_f, (VNABlockType) type, frequency, &block);\n"
"\t\treturn buffer_pos;\n"
"\t}\n");
v_cg_end_cmd();
}
#endif

@ -1,44 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include "verse_header.h"
#include "v_cmd_gen.h"
#include "v_cmd_buf.h"
#if defined(V_GENERATE_FUNC_MODE)
void v_gen_bitmap_cmd_def(void)
{
v_cg_new_cmd(V_NT_BITMAP, "b_dimensions_set", 80, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT16, "width");
v_cg_add_param(VCGP_UINT16, "height");
v_cg_add_param(VCGP_UINT16, "depth");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_BITMAP, "b_layer_create", 81, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NAME, "name");
v_cg_add_param(VCGP_ENUM_NAME, "VNBLayerType");
v_cg_add_param(VCGP_ENUM, "type");
v_cg_alias(FALSE, "b_layer_destroy", "if(name[0] == 0)", 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_BITMAP, "b_layer_subscribe", 82, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT8, "level");
v_cg_alias(FALSE, "b_layer_unsubscribe", "if(level == 255)", 2, NULL);
v_cg_end_cmd();
v_cg_new_manual_cmd(83, "b_tile_set", "void verse_send_b_tile_set(VNodeID node_id, VLayerID layer_id, "
"uint16 tile_x, uint16 tile_y, uint16 z, VNBLayerType type, const VNBTile *tile)",
NULL, NULL);
}
#endif

@ -1,35 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include "verse_header.h"
#include "v_cmd_gen.h"
#include "v_cmd_buf.h"
#if defined(V_GENERATE_FUNC_MODE)
void v_gen_curve_cmd_def(void)
{
v_cg_new_cmd(V_NT_CURVE, "c_curve_create", 128, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "curve_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NAME, "name");
v_cg_add_param(VCGP_UINT8, "dimensions");
v_cg_alias(FALSE, "c_curve_destroy", "if(name[0] == 0)", 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_CURVE, "c_curve_subscribe", 129, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "curve_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_alias(TRUE, "c_curve_unsubscribe", "if(!alias_bool)", 2, NULL);
v_cg_end_cmd();
v_cg_new_manual_cmd(130, "c_key_set", "void verse_send_c_key_set(VNodeID node_id, VLayerID curve_id, "
"uint32 key_id, uint8 dimensions, const real64 *pre_value, const uint32 *pre_pos, "
"const real64 *value, real64 pos, const real64 *post_value, const uint32 *post_pos)",
"c_key_destroy", "void verse_send_c_key_destroy(VNodeID node_id, VLayerID curve_id, "
"uint32 key_id)");
}
#endif

@ -1,183 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include "verse_header.h"
#include "v_cmd_gen.h"
#include "v_cmd_buf.h"
#if defined(V_GENERATE_FUNC_MODE)
void v_gen_geometry_cmd_def(void)
{
unsigned int order[] = { 0, 2 };
v_cg_new_cmd(V_NT_GEOMETRY, "g_layer_create", 48, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NAME, "name");
v_cg_add_param(VCGP_ENUM_NAME, "VNGLayerType");
v_cg_add_param(VCGP_ENUM, "type");
v_cg_add_param(VCGP_UINT32, "def_uint");
v_cg_add_param(VCGP_REAL64, "def_real");
v_cg_alias(FALSE, "g_layer_destroy", "if(name[0] == 0)", 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_layer_subscribe", 49, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_ENUM_NAME, "VNRealFormat");
v_cg_add_param(VCGP_ENUM, "type");
v_cg_alias(FALSE, "g_layer_unsubscribe", "if(type > VN_FORMAT_REAL64)", 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_vertex_set_xyz_real32", 50, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_UINT32, "vertex_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_REAL32, "x");
v_cg_add_param(VCGP_REAL32, "y");
v_cg_add_param(VCGP_REAL32, "z");
v_cg_alias(FALSE, "g_vertex_delete_real32", "if(x == V_REAL32_MAX || y == V_REAL32_MAX || z == V_REAL32_MAX)", 2, order);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_vertex_set_xyz_real64", 51, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_UINT32, "vertex_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_REAL64, "x");
v_cg_add_param(VCGP_REAL64, "y");
v_cg_add_param(VCGP_REAL64, "z");
v_cg_alias(FALSE, "g_vertex_delete_real64", "if(x == V_REAL64_MAX || y == V_REAL64_MAX || z == V_REAL64_MAX)", 2, order);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_vertex_set_uint32", 52, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_UINT32, "vertex_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT32, "value");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_vertex_set_real64", 53, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_UINT32, "vertex_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_REAL64, "value");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_vertex_set_real32", 54, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_UINT32, "vertex_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_REAL32, "value");
v_cg_end_cmd();
/*
v_cg_new_cmd(V_NT_GEOMETRY, "g_vertex_delete", VCGCT_NORMAL);
v_cg_add_param(VCGP_UINT32, "vertex_id");
v_cg_end_cmd();
*/
v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_corner_uint32", 55, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_UINT32, "polygon_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT32, "v0");
v_cg_add_param(VCGP_UINT32, "v1");
v_cg_add_param(VCGP_UINT32, "v2");
v_cg_add_param(VCGP_UINT32, "v3");
v_cg_alias(FALSE, "g_polygon_delete", "if(layer_id == 1 && v0 == ~0u)", 2, order);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_corner_real64", 56, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_UINT32, "polygon_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_REAL64, "v0");
v_cg_add_param(VCGP_REAL64, "v1");
v_cg_add_param(VCGP_REAL64, "v2");
v_cg_add_param(VCGP_REAL64, "v3");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_corner_real32", 57, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_UINT32, "polygon_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_REAL32, "v0");
v_cg_add_param(VCGP_REAL32, "v1");
v_cg_add_param(VCGP_REAL32, "v2");
v_cg_add_param(VCGP_REAL32, "v3");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_face_uint8", 58, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_UINT32, "polygon_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT8, "value");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_face_uint32", 59, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_UINT32, "polygon_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT32, "value");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_face_real64", 60, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_UINT32, "polygon_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_REAL64, "value");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_face_real32", 61, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_LAYER_ID, "layer_id");
v_cg_add_param(VCGP_UINT32, "polygon_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_REAL32, "value");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_crease_set_vertex", 62, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NAME, "layer");
v_cg_add_param(VCGP_UINT32, "def_crease");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_crease_set_edge", 63, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NAME, "layer");
v_cg_add_param(VCGP_UINT32, "def_crease");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_GEOMETRY, "g_bone_create", 64, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_UINT16, "bone_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NAME, "weight");
v_cg_add_param(VCGP_NAME, "reference");
v_cg_add_param(VCGP_UINT16, "parent");
v_cg_add_param(VCGP_REAL64, "pos_x");
v_cg_add_param(VCGP_REAL64, "pos_y");
v_cg_add_param(VCGP_REAL64, "pos_z");
v_cg_add_param(VCGP_NAME, "position_label");
v_cg_add_param(VCGP_NAME, "rotation_label");
v_cg_add_param(VCGP_NAME, "scale_label");
v_cg_alias(FALSE, "g_bone_destroy", "if(weight[0] == 0)", 2, NULL);
v_cg_end_cmd();
}
#endif

@ -1,273 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include "verse_header.h"
#include "v_cmd_gen.h"
#include "v_cmd_buf.h"
#if defined(V_GENERATE_FUNC_MODE)
void v_gen_material_cmd_def(void)
{
v_cg_new_cmd(V_NT_MATERIAL, "m_fragment_create", 68, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_FRAGMENT_ID, "frag_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_ENUM_NAME, "VNMFragmentType");
v_cg_add_param(VCGP_ENUM, "type");
v_cg_add_param(VCGP_POINTER_TYPE, "VMatFrag");
v_cg_add_param(VCGP_POINTER, "fragment");
v_cg_add_param(VCGP_PACK_INLINE, "\tswitch(type)\n"
"\t{\n"
"\tcase VN_M_FT_COLOR :\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->color.red);\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->color.green);\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->color.blue);\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_LIGHT :\n"
"\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->light.type);\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->light.normal_falloff);\n"
"\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], fragment->light.brdf);\n"
"\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->light.brdf_r, 16);\n"
"\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->light.brdf_g, 16);\n"
"\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->light.brdf_b, 16);\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_REFLECTION :\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->reflection.normal_falloff);\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_TRANSPARENCY :\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->transparency.normal_falloff);\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->transparency.refraction_index);\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_GEOMETRY :\n"
"\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->geometry.layer_r, 16);\n"
"\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->geometry.layer_g, 16);\n"
"\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->geometry.layer_b, 16);\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_VOLUME :\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.diffusion);\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.col_r);\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.col_g);\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.col_b);\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_VIEW :\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_TEXTURE :\n"
"\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], fragment->texture.bitmap);\n"
"\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->texture.layer_r, 16);\n"
"\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->texture.layer_g, 16);\n"
"\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->texture.layer_b, 16);\n"
"\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->texture.filtered);\n"
"\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->texture.mapping);\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_NOISE :\n"
"\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->noise.type);\n"
"\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->noise.mapping);\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_BLENDER :\n"
"\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->blender.type);\n"
"\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->blender.data_a);\n"
"\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->blender.data_b);\n"
"\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->blender.control);\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_CLAMP :\n"
"\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->clamp.min);\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->clamp.red);\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->clamp.green);\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->clamp.blue);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->clamp.data);\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_MATRIX :\n"
"\t\t{\n"
"\t\t\tunsigned int i;\n"
"\t\t\tfor(i = 0; i < 16; i++)\n"
"\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->matrix.matrix[i]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->matrix.data);\n"
"\t\t}\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_RAMP :\n"
"\t\tif(fragment->ramp.point_count == 0)\n"
"\t\t\treturn;\n"
"\t\t{\n"
"\t\t\tunsigned int i, pos;\n"
"\t\t\tdouble last;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->ramp.type);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->ramp.channel);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->ramp.mapping);\n"
"\t\t\tpos = buffer_pos;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], fragment->ramp.point_count);\n"
"\t\t\tlast = fragment->ramp.ramp[0].pos - 1;\n"
"\t\t\tfor(i = 0; i < fragment->ramp.point_count && fragment->ramp.ramp[i].pos > last && i < 48; i++)\n"
"\t\t\t{\n"
"\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].pos);\n"
"\t\t\t\tlast = fragment->ramp.ramp[i].pos;\n"
"\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].red);\n"
"\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].green);\n"
"\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].blue);\n"
"\t\t\t}\n\t\t\tif(i != fragment->ramp.point_count)\n"
"\t\t\t\tvnp_raw_pack_uint8(&buf[pos], i);\n"
"\t\t}\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_ANIMATION :\n"
"\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->animation.label, 16);\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_ALTERNATIVE :\n"
"\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->alternative.alt_a);\n"
"\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->alternative.alt_b);\n"
"\t\tbreak;\n"
"\tcase VN_M_FT_OUTPUT :\n"
"\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->output.label, 16);\n"
"\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->output.front);\n"
"\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->output.back);\n"
"\t\tbreak;\n"
"\t}\n");
v_cg_add_param(VCGP_UNPACK_INLINE, "\tif(type <= VN_M_FT_OUTPUT)\n"
"\t{\n"
"\t\tVMatFrag frag;\n"
"\t\tuint8 temp;\n"
"\t\tswitch(type)\n"
"\t\t{\n"
"\t\tcase VN_M_FT_COLOR :\n"
"\t\t\tif(buffer_pos + 3 * 8 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.color.red);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.color.green);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.color.blue);\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_LIGHT :\n"
"\t\t\tif(buffer_pos + 13 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n"
"\t\t\tfrag.light.type = (VNMLightType)temp;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.light.normal_falloff);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &frag.light.brdf);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.light.brdf_r, 16, buffer_length - buffer_pos);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.light.brdf_g, 16, buffer_length - buffer_pos);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.light.brdf_b, 16, buffer_length - buffer_pos);\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_REFLECTION :\n"
"\t\t\tif(buffer_pos + 8 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.reflection.normal_falloff);\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_TRANSPARENCY :\n"
"\t\t\tif(buffer_pos + 16 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.transparency.normal_falloff);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.transparency.refraction_index);\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_VOLUME :\n"
"\t\t\tif(buffer_pos + 32 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.diffusion);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.col_r);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.col_g);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.col_b);\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_VIEW :\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_GEOMETRY :\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.geometry.layer_r, 16, buffer_length - buffer_pos);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.geometry.layer_g, 16, buffer_length - buffer_pos);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.geometry.layer_b, 16, buffer_length - buffer_pos);\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_TEXTURE :\n"
"\t\t\tif(buffer_pos + 10 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &frag.texture.bitmap);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.texture.layer_r, 16, buffer_length - buffer_pos);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.texture.layer_g, 16, buffer_length - buffer_pos);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.texture.layer_b, 16, buffer_length - buffer_pos);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n"
"\t\t\tfrag.texture.filtered = (VNMNoiseType)temp;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.texture.mapping);\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_NOISE :\n"
"\t\t\tif(buffer_pos + 3 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n"
"\t\t\tfrag.noise.type = (VNMNoiseType)temp;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.noise.mapping);\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_BLENDER :\n"
"\t\t\tif(buffer_pos + 7 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n"
"\t\t\tfrag.blender.type = (VNMBlendType)temp;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.blender.data_a);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.blender.data_b);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.blender.control);\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_CLAMP :\n"
"\t\t\tif(buffer_pos + 27 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n"
"\t\t\tfrag.clamp.min = (VNMBlendType)temp;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.clamp.red);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.clamp.green);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.clamp.blue);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.clamp.data);\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_MATRIX :\n"
"\t\t\tif(buffer_pos + 8 * 16 + 2 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\telse\n"
"\t\t\t{\n"
"\t\t\t\tunsigned int i;\n"
"\t\t\t\tfor(i = 0; i < 16; i++)\n"
"\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.matrix.matrix[i]);\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.matrix.data);\n"
"\t\t\t}\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_RAMP :\n"
"\t\t\tif(buffer_pos + 5 + 4 * 8 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\telse\n"
"\t\t\t{\n"
"\t\t\t\tunsigned int i, pos;\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n"
"\t\t\t\tfrag.ramp.type = (VNMRampType)temp;\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n"
"\t\t\t\tfrag.ramp.channel = (VNMRampChannel)temp;\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.ramp.mapping);\n"
"\t\t\t\tpos = buffer_pos;\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &frag.ramp.point_count);\n"
"\t\t\t\tfor(i = 0; i < frag.ramp.point_count && buffer_pos + 8 * 4 <= buffer_length && i < 48; i++)\n"
"\t\t\t\t{\n"
"\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].pos);\n"
"\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].red);\n"
"\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].green);\n"
"\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].blue);\n"
"\t\t\t\t}if(i != frag.ramp.point_count)\n"
"\t\t\t\t\tfrag.ramp.point_count = i;\n"
"\t\t\t}\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_ANIMATION :\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.animation.label, 16, buffer_length - buffer_pos);\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_ALTERNATIVE :\n"
"\t\t\tif(buffer_pos + 4 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.alternative.alt_a);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.alternative.alt_b);\n"
"\t\t\tbreak;\n"
"\t\tcase VN_M_FT_OUTPUT :\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.output.label, 16, buffer_length - buffer_pos);\n"
"\t\t\tif(buffer_pos + 4 > buffer_length)\n"
"\t\t\t\treturn -1;\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.output.front);\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.output.back);\n"
"\t\t\tbreak;\n"
"\t\t}\n"
"\t\tif(func_m_fragment_create != NULL)\n"
"\t\t\tfunc_m_fragment_create(v_fs_get_user_data(68), node_id, frag_id, type, &frag);\n"
"\t\treturn buffer_pos;\n"
"\t}\n");
v_cg_alias(FALSE, "m_fragment_destroy", "if(type > VN_M_FT_OUTPUT)", 2, NULL);
v_cg_end_cmd();
}
#endif

@ -1,517 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include "verse_header.h"
#include "v_cmd_gen.h"
#include "v_cmd_buf.h"
#if defined(V_GENERATE_FUNC_MODE)
void v_gen_object_cmd_def(void)
{
v_cg_new_cmd(V_NT_OBJECT, "o_transform_pos_real32", 32, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT32, "time_s");
v_cg_add_param(VCGP_UINT32, "time_f");
v_cg_add_param(VCGP_POINTER_TYPE,"real32");
v_cg_add_param(VCGP_POINTER, "pos");
v_cg_add_param(VCGP_POINTER_TYPE,"real32");
v_cg_add_param(VCGP_POINTER, "speed");
v_cg_add_param(VCGP_POINTER_TYPE,"real32");
v_cg_add_param(VCGP_POINTER, "accelerate");
v_cg_add_param(VCGP_POINTER_TYPE,"real32");
v_cg_add_param(VCGP_POINTER, "drag_normal");
v_cg_add_param(VCGP_PACK_INLINE, "\t{\n"
"\t\tunsigned char mask = 0;\n"
"\t\tunsigned int cmd;\n"
"\t\tcmd = buffer_pos++;\n"
"\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], pos[0]);\n"
"\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], pos[1]);\n"
"\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], pos[2]);\n"
"\t\tif(speed != NULL && (speed[0] > 0.0000001 || speed[0] < -0.0000001 || speed[1] > 0.0000001 || speed[1] < -0.0000001 || speed[2] > 0.0000001 || speed[2] < -0.0000001))\n"
"\t\t{\n"
"\t\t\tmask |= 1;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], speed[0]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], speed[1]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], speed[2]);\n"
"\t\t}\n"
"\t\tif(accelerate != NULL && (accelerate[0] > 0.0000001 || accelerate[0] < -0.0000001 || accelerate[1] > 0.0000001 || accelerate[1] < -0.0000001 || accelerate[2] > 0.0000001 || accelerate[2] < -0.0000001))\n"
"\t\t{\n"
"\t\t\tmask |= 2;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], accelerate[0]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], accelerate[1]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], accelerate[2]);\n"
"\t\t}\n"
"\t\tif(drag_normal != NULL && (drag > 0.0000001 || drag < -0.0000001) && (drag_normal[0] > 0.0000001 || drag_normal[0] < -0.0000001 || drag_normal[1] > 0.0000001 || drag_normal[1] < -0.0000001 || drag_normal[2] > 0.0000001 || drag_normal[2] < -0.0000001))\n"
"\t\t{\n"
"\t\t\tmask |= 4;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag_normal[0]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag_normal[1]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag_normal[2]);\n"
"\t\t}\n"
"\t\tif(drag > 0.0000001 || drag < -0.0000001)\n"
"\t\t{\n"
"\t\t\tmask |= 8;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag);\n"
"\t\t}\n"
"\t\tvnp_raw_pack_uint8(&buf[cmd], mask);\n"
"\t}if(FALSE)\n");
v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n"
"\t\tfloat output[4][3];\n"
"\t\tunsigned int i, j;\n"
"\t\tchar mask, pow = 1;\n"
"\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);\n"
"\t\tfor(j = 0; j < 3; j++)\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &output[0][j]);\n"
"\t\tfor(i = 1; i < 4; i++)\n"
"\t\t{\n"
"\t\t\tif((mask & pow) != 0)\n"
"\t\t\t\tfor(j = 0; j < 3; j++)\n"
"\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &output[i][j]);\n"
"\t\t\telse\n"
"\t\t\t\tfor(j = 0; j < 3; j++)\n"
"\t\t\t\t\toutput[i][j] = 0;\n"
"\t\t\tpow *= 2;\n"
"\t\t}\n"
"\t\tif((mask & pow) != 0)\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &drag);\n"
"\t\telse\n"
"\t\t\tdrag = 0.0f;\n"
"\t\tif(func_o_transform_pos_real32 != NULL)\n"
"\t\t\tfunc_o_transform_pos_real32(v_fs_get_user_data(32), node_id, time_s, time_f, &output[0][0], &output[1][0], &output[2][0], &output[3][0], drag);\n"
"\t\treturn buffer_pos;\n"
"\t}\n");
v_cg_add_param(VCGP_REAL32, "drag");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_transform_rot_real32", 33, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT32, "time_s");
v_cg_add_param(VCGP_UINT32, "time_f");
v_cg_add_param(VCGP_POINTER_TYPE, "VNQuat32");
v_cg_add_param(VCGP_POINTER, "rot");
v_cg_add_param(VCGP_POINTER_TYPE, "VNQuat32");
v_cg_add_param(VCGP_POINTER, "speed");
v_cg_add_param(VCGP_POINTER_TYPE, "VNQuat32");
v_cg_add_param(VCGP_POINTER, "accelerate");
v_cg_add_param(VCGP_POINTER_TYPE, "VNQuat32");
v_cg_add_param(VCGP_POINTER, "drag_normal");
v_cg_add_param(VCGP_PACK_INLINE, "\t{\n"
"\t\tuint8 mask = 0;\n"
"\t\tunsigned int maskpos;\n"
"\t\tmaskpos = buffer_pos++;\t\t/* Remember location, and reserve a byte for the mask. */\n"
"\t\tbuffer_pos += vnp_pack_quat32(&buf[buffer_pos], rot);\n"
"\t\tif(v_quat32_valid(speed))\n"
"\t\t{\n"
"\t\t\tmask |= 1;\n"
"\t\t\tbuffer_pos += vnp_pack_quat32(&buf[buffer_pos], speed);\n"
"\t\t}\n"
"\t\tif(v_quat32_valid(accelerate))\n"
"\t\t{\n"
"\t\t\tmask |= 2;\n"
"\t\t\tbuffer_pos += vnp_pack_quat32(&buf[buffer_pos], accelerate);\n"
"\t\t}\n"
"\t\tif(v_quat32_valid(drag_normal))\n"
"\t\t{\n"
"\t\t\tmask |= 4;\n"
"\t\t\tbuffer_pos += vnp_pack_quat32(&buf[buffer_pos], drag_normal);\n"
"\t\t}\n"
"\t\tif(drag > 0.0000001 || drag < -0.0000001)\n"
"\t\t{\n"
"\t\t\tmask |= 8;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag);\n"
"\t\t}\n"
"\t\tvnp_raw_pack_uint8(&buf[maskpos], mask);\t/* Write the mask into start of command. */\n"
"\t}\n"
"\tif(FALSE)\n");
v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n"
"\t\tVNQuat32 trot, temp[3], *q[3];\n"
"\t\tunsigned int i;\n"
"\t\tuint8 mask, test;\n"
"\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);\n"
"\t\tbuffer_pos += vnp_unpack_quat32(&buf[buffer_pos], &trot);\n"
"\t\tfor(i = 0, test = 1; i < sizeof temp / sizeof *temp; i++, test <<= 1)\n"
"\t\t{\n"
"\t\t\tif(mask & test)\t\t/* Field present? */\n"
"\t\t\t{\n"
"\t\t\t\tbuffer_pos += vnp_unpack_quat32(&buf[buffer_pos], &temp[i]);\n"
"\t\t\t\tq[i] = &temp[i];\n"
"\t\t\t}\n"
"\t\t\telse\n"
"\t\t\t\tq[i] = NULL;\n"
"\t\t}\n"
"\t\tif(mask & test)\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &drag);\n"
"\t\telse\n"
"\t\t\tdrag = 0.0;\n"
"\t\tif(func_o_transform_rot_real32 != NULL)\n"
"\t\t\tfunc_o_transform_rot_real32(v_fs_get_user_data(33), node_id, time_s, time_f, &trot, q[0], q[1], q[2], drag);\n"
"\t\treturn buffer_pos;\n"
"\t}\n");
v_cg_add_param(VCGP_REAL32, "drag");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_transform_scale_real32", 34, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_REAL32, "scale_x");
v_cg_add_param(VCGP_REAL32, "scale_y");
v_cg_add_param(VCGP_REAL32, "scale_z");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_transform_pos_real64", 35, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT32, "time_s");
v_cg_add_param(VCGP_UINT32, "time_f");
v_cg_add_param(VCGP_POINTER_TYPE,"real64");
v_cg_add_param(VCGP_POINTER, "pos");
v_cg_add_param(VCGP_POINTER_TYPE,"real64");
v_cg_add_param(VCGP_POINTER, "speed");
v_cg_add_param(VCGP_POINTER_TYPE,"real64");
v_cg_add_param(VCGP_POINTER, "accelerate");
v_cg_add_param(VCGP_POINTER_TYPE,"real64");
v_cg_add_param(VCGP_POINTER, "drag_normal");
v_cg_add_param(VCGP_PACK_INLINE, "\t{\n"
"\t\tunsigned char mask = 0;\n"
"\t\tunsigned int cmd;\n"
"\t\tcmd = buffer_pos++;\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[0]);\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[1]);\n"
"\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[2]);\n"
"\t\tif(speed != NULL && (speed[0] > 0.0000001 || speed[0] < -0.0000001 || speed[1] > 0.0000001 || speed[1] < -0.0000001 || speed[2] > 0.0000001 || speed[2] < -0.0000001))\n"
"\t\t{\n"
"\t\t\tmask |= 1;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[0]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[1]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[2]);\n"
"\t\t}\n"
"\t\tif(accelerate != NULL && (accelerate[0] > 0.0000001 || accelerate[0] < -0.0000001 || accelerate[1] > 0.0000001 || accelerate[1] < -0.0000001 || accelerate[2] > 0.0000001 || accelerate[2] < -0.0000001))\n"
"\t\t{\n"
"\t\t\tmask |= 2;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accelerate[0]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accelerate[1]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accelerate[2]);\n"
"\t\t}\n"
"\t\tif(drag_normal != NULL && (drag > 0.0000001 || drag < -0.0000001) && (drag_normal[0] > 0.0000001 || drag_normal[0] < -0.0000001 || drag_normal[1] > 0.0000001 || drag_normal[1] < -0.0000001 || drag_normal[2] > 0.0000001 || drag_normal[2] < -0.0000001))\n"
"\t\t{\n"
"\t\t\tmask |= 4;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag_normal[0]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag_normal[1]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag_normal[2]);\n"
"\t\t}\n"
"\t\tif(drag > 0.0000001 || drag < -0.0000001)\n"
"\t\t{\n"
"\t\t\tmask |= 8;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag);\n"
"\t\t}\n"
"\t\tvnp_raw_pack_uint8(&buf[cmd], mask);\n"
"\t}if(FALSE)\n");
v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n"
"\t\tdouble output[4][3];\n"
"\t\tunsigned int i, j;\n"
"\t\tchar mask, pow = 1;\n"
"\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);\n"
"\t\tfor(j = 0; j < 3; j++)\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[0][j]);\n"
"\t\tfor(i = 1; i < 4; i++)\n"
"\t\t{\n"
"\t\t\tif((mask & pow) != 0)\n"
"\t\t\t\tfor(j = 0; j < 3; j++)\n"
"\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[i][j]);\n"
"\t\t\telse\n"
"\t\t\t\tfor(j = 0; j < 3; j++)\n"
"\t\t\t\t\toutput[i][j] = 0;\n"
"\t\t\tpow *= 2;\n"
"\t\t}\n"
"\t\tif((mask & pow) != 0)\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &drag);\n"
"\t\telse\n"
"\t\t\tdrag = 0.0;\n"
"\t\tif(func_o_transform_pos_real64 != NULL)\n"
"\t\t\tfunc_o_transform_pos_real64(v_fs_get_user_data(35), node_id, time_s, time_f, &output[0][0], &output[1][0], &output[2][0], &output[3][0], drag);\n"
"\t\treturn buffer_pos;\n"
"\t}\n");
v_cg_add_param(VCGP_REAL64, "drag");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_transform_rot_real64", 36, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT32, "time_s");
v_cg_add_param(VCGP_UINT32, "time_f");
v_cg_add_param(VCGP_POINTER_TYPE,"VNQuat64");
v_cg_add_param(VCGP_POINTER, "rot");
v_cg_add_param(VCGP_POINTER_TYPE,"VNQuat64");
v_cg_add_param(VCGP_POINTER, "speed");
v_cg_add_param(VCGP_POINTER_TYPE,"VNQuat64");
v_cg_add_param(VCGP_POINTER, "accelerate");
v_cg_add_param(VCGP_POINTER_TYPE,"VNQuat64");
v_cg_add_param(VCGP_POINTER, "drag_normal");
v_cg_add_param(VCGP_PACK_INLINE, "\t{\n"
"\t\tuint8 mask = 0;\n"
"\t\tunsigned int maskpos;\n"
"\t\tmaskpos = buffer_pos++;\t\t/* Remember location, and reserve a byte for the mask. */\n"
"\t\tbuffer_pos += vnp_pack_quat64(&buf[buffer_pos], rot);\n"
"\t\tif(v_quat64_valid(speed))\n"
"\t\t{\n"
"\t\t\tmask |= 1;\n"
"\t\t\tbuffer_pos += vnp_pack_quat64(&buf[buffer_pos], speed);\n"
"\t\t}\n"
"\t\tif(v_quat64_valid(accelerate))\n"
"\t\t{\n"
"\t\t\tmask |= 2;\n"
"\t\t\tbuffer_pos += vnp_pack_quat64(&buf[buffer_pos], accelerate);\n"
"\t\t}\n"
"\t\tif(v_quat64_valid(drag_normal))\n"
"\t\t{\n"
"\t\t\tmask |= 4;\n"
"\t\t\tbuffer_pos += vnp_pack_quat64(&buf[buffer_pos], drag_normal);\n"
"\t\t}\n"
"\t\tif(drag > 0.0000001 || drag < -0.0000001)\n"
"\t\t{\n"
"\t\t\tmask |= 8;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag);\n"
"\t\t}\n"
"\t\tvnp_raw_pack_uint8(&buf[maskpos], mask);\t/* Write the mask into start of command. */\n"
"\t}\n"
"\tif(FALSE)\n");
v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n"
"\t\tVNQuat64 trot, temp[3], *q[3];\n"
"\t\tunsigned int i;\n"
"\t\tuint8 mask, test;\n"
"\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);\n"
"\t\tbuffer_pos += vnp_unpack_quat64(&buf[buffer_pos], &trot);\n"
"\t\tfor(i = 0, test = 1; i < sizeof temp / sizeof *temp; i++, test <<= 1)\n"
"\t\t{\n"
"\t\t\tif(mask & test)\t\t/* Field present? */\n"
"\t\t\t{\n"
"\t\t\t\tbuffer_pos += vnp_unpack_quat64(&buf[buffer_pos], &temp[i]);\n"
"\t\t\t\tq[i] = &temp[i];\n"
"\t\t\t}\n"
"\t\t\telse\n"
"\t\t\t\tq[i] = NULL;\n"
"\t\t}\n"
"\t\tif(mask & test)\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &drag);\n"
"\t\telse\n"
"\t\t\tdrag = 0.0;\n"
"\t\tif(func_o_transform_rot_real64 != NULL)\n"
"\t\t\tfunc_o_transform_rot_real64(v_fs_get_user_data(36), node_id, time_s, time_f, &trot, q[0], q[1], q[2], drag);\n"
"\t\treturn buffer_pos;\n"
"\t}\n");
v_cg_add_param(VCGP_REAL64, "drag");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_transform_scale_real64", 37, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_REAL64, "scale_x");
v_cg_add_param(VCGP_REAL64, "scale_y");
v_cg_add_param(VCGP_REAL64, "scale_z");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_transform_subscribe", 38, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_ENUM_NAME, "VNRealFormat");
v_cg_add_param(VCGP_ENUM, "type");
v_cg_alias(TRUE, "o_transform_unsubscribe", NULL, 4, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_light_set", 39, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_REAL64, "light_r");
v_cg_add_param(VCGP_REAL64, "light_g");
v_cg_add_param(VCGP_REAL64, "light_b");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_link_set", 40, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_UINT16, "link_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NODE_ID, "link");
v_cg_add_param(VCGP_NAME, "label");
v_cg_add_param(VCGP_UINT32, "target_id");
v_cg_alias(TRUE, "o_link_destroy", NULL, 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_method_group_create", 41, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_UINT16, "group_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NAME, "name");
v_cg_alias(FALSE, "o_method_group_destroy", "if(name[0] == 0)", 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_method_group_subscribe", 42, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_UINT16, "group_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_alias(TRUE, "o_method_group_unsubscribe", NULL, 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_method_create", 43, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_UINT16, "group_id");
v_cg_add_param(VCGP_UINT16, "method_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_LONG_NAME, "name");
v_cg_add_param(VCGP_UINT8, "param_count");
v_cg_add_param(VCGP_POINTER_TYPE,"VNOParamType");
v_cg_add_param(VCGP_POINTER, "param_types");
v_cg_add_param(VCGP_POINTER_TYPE,"char *");
v_cg_add_param(VCGP_POINTER, "param_names");
v_cg_add_param(VCGP_PACK_INLINE, "\t{\n"
"\t\tunsigned int i, j, sum = 1;\n"
"\t\tfor(i = 0; i < param_count; i++)\n"
"\t\t{\n"
"\t\t\tsum += 3;\n"
"\t\t\tfor(j = 0; param_names[i][j] != 0; j++);\n"
"\t\t}\n"
"\t\tif(sum + buffer_pos > 1500)\n"
"\t\t\treturn;\n"
"\t\tfor(i = 0; i < param_count; i++)\n"
"\t\t{\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], param_types[i]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], param_names[i], 1500 - buffer_pos);\n"
"\t\t}\n"
"\t}\n");
v_cg_add_param(VCGP_UNPACK_INLINE, "\tif(param_count != 255)\n"
"\t{\n"
"\t\tunsigned int i, size, text = 0;\n"
"\t\tVNOParamType types[256];\n"
"\t\tuint8 t;\n"
"\t\tchar name_buf[1500], *names[256];\n"
"\t\tfor(i = 0; i < param_count; i++)\n"
"\t\t{\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &t);\n"
"\t\t\ttypes[i] = t;\n"
"\t\t\tnames[i] = &name_buf[text];\n"
"\t\t\tsize = vnp_raw_unpack_string(&buf[buffer_pos], names[i], 1500 - buffer_pos, buffer_length - buffer_pos);\n"
"\t\t\tbuffer_pos += size;\n"
"\t\t\ttext += size;\n"
"\t\t}\n"
"\t\tif(func_o_method_create != NULL)\n"
"\t\t\tfunc_o_method_create(v_fs_get_user_data(43), node_id, group_id, method_id, name, param_count, types, (const char **) names);\n"
"\t\treturn buffer_pos;\n"
"\t}\n");
v_cg_alias(FALSE, "o_method_destroy", "if(name[0] == 0)", 3, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_method_call", 44, VCGCT_UNIQUE);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_UINT16, "group_id");
v_cg_add_param(VCGP_UINT16, "method_id");
v_cg_add_param(VCGP_NODE_ID, "sender");
v_cg_add_param(VCGP_POINTER_TYPE, "VNOPackedParams");
v_cg_add_param(VCGP_POINTER, "params");
v_cg_add_param(VCGP_PACK_INLINE, "\t{\n"
"\t\tunsigned int i;\n"
"\t\tuint16 size;\n"
"\t\tvnp_raw_unpack_uint16(params, &size);\n"
"\t\tfor(i = 0; i < size; i++)\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((uint8 *)params)[i]);\n"
"\t\tfree((void *) params);\t/* Drop the const. */\n"
"\t}\n");
v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n"
"\t\tunsigned int i;\n"
"\t\tuint8 par[1500];\n"
"\t\tuint16 size;\n"
"\t\tvnp_raw_unpack_uint16(&buf[buffer_pos], &size);\n"
"\t\tfor(i = 0; i < size; i++)\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &par[i]);\n"
"\t\tif(func_o_method_call != NULL)\n"
"\t\t\tfunc_o_method_call(v_fs_get_user_data(44), node_id, group_id, method_id, sender, par);\n"
"\t\treturn buffer_pos;\n"
"\t}\n");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_anim_run", 45, VCGCT_UNIQUE);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_UINT16, "link_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT32, "time_s");
v_cg_add_param(VCGP_UINT32, "time_f");
v_cg_add_param(VCGP_UINT8, "dimensions");
v_cg_add_param(VCGP_POINTER_TYPE, "real64");
v_cg_add_param(VCGP_POINTER, "pos");
v_cg_add_param(VCGP_POINTER_TYPE, "real64");
v_cg_add_param(VCGP_POINTER, "speed");
v_cg_add_param(VCGP_POINTER_TYPE, "real64");
v_cg_add_param(VCGP_POINTER, "accel");
v_cg_add_param(VCGP_POINTER_TYPE, "real64");
v_cg_add_param(VCGP_POINTER, "scale");
v_cg_add_param(VCGP_POINTER_TYPE, "real64");
v_cg_add_param(VCGP_POINTER, "scale_speed");
v_cg_add_param(VCGP_PACK_INLINE, "\t{\n"
"\t\tunsigned char mask = 0;\n"
"\t\tunsigned int cmd, i;\n"
"\t\tcmd = buffer_pos++;\n"
"\t\tif(dimensions > 4)\n"
"\t\t\tdimensions = 4;\n"
"\t\tfor(i = 0; i < dimensions; i++)\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[i]);\n"
"\t\tif(speed != NULL)\n"
"\t\t{\n"
"\t\t\tmask |= 1;\n"
"\t\t\tfor(i = 0; i < dimensions; i++)\n"
"\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[i]);\n"
"\t\t}\n"
"\t\tif(accel != NULL)\n"
"\t\t{\n"
"\t\t\tmask |= 2;\n"
"\t\t\tfor(i = 0; i < dimensions; i++)\n"
"\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accel[i]);\n"
"\t\t}\n"
"\t\tif(scale != NULL)\n"
"\t\t{\n"
"\t\t\tmask |= 3;\n"
"\t\t\tfor(i = 0; i < dimensions; i++)\n"
"\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale[i]);\n"
"\t\t}\n"
"\t\tif(scale_speed != NULL)\n"
"\t\t{\n"
"\t\t\tmask |= 4;\n"
"\t\t\tfor(i = 0; i < dimensions; i++)\n"
"\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale_speed[i]);\n"
"\t\t}\n"
"\t\tvnp_raw_pack_uint8(&buf[cmd], mask);\n"
"\t}\n");
v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n"
"\t\tdouble output[5][4];\n"
"\t\tunsigned int i, j;\n"
"\t\tchar mask, pow = 1;\n"
"\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);\n"
"\t\tif(dimensions > 4)\n"
"\t\t\tdimensions = 4;\n"
"\t\tfor(j = 0; j < dimensions; j++)\n"
"\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[0][j]);\n"
"\t\tfor(i = 1; i < 5; i++)\n"
"\t\t{\n"
"\t\t\tif((mask & pow) != 0)\n"
"\t\t\t\tfor(j = 0; j < dimensions; j++)\n"
"\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[i][j]);\n"
"\t\t\telse\n"
"\t\t\t\tfor(j = 0; j < dimensions; j++)\n"
"\t\t\t\t\toutput[i][j] = 0;\n"
"\t\t\tpow *= 2;\n"
"\t\t}\n"
"\t\tif(func_o_anim_run != NULL)\n"
"\t\t\tfunc_o_anim_run(v_fs_get_user_data(45), node_id, link_id, time_s, time_f, dimensions, &output[0][0], &output[1][0], &output[2][0], &output[3][0], &output[4][0]);\n"
"\t\treturn buffer_pos;\n"
"\t}\n");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_OBJECT, "o_hide", 46, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_UINT8, "hidden");
v_cg_end_cmd();
}
#endif

@ -1,211 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include "verse_header.h"
#include "v_cmd_gen.h"
#include "v_cmd_buf.h"
#if defined(V_GENERATE_FUNC_MODE)
void v_gen_system_cmd_def(void)
{
v_cg_new_manual_cmd(0, "connect", "VSession verse_send_connect(const char *name, const char *pass, const char *address, const uint8 *expected_host_id)", NULL, NULL);
v_cg_new_manual_cmd(1, "connect_accept", "VSession verse_send_connect_accept(VNodeID avatar, const char *address, uint8 *host_id)", NULL, NULL);
v_cg_new_manual_cmd(2, "connect_terminate", "void verse_send_connect_terminate(const char *address, const char *bye)", NULL, NULL);
v_cg_new_manual_cmd(5, "ping", "void verse_send_ping(const char *address, const char *message)", NULL, NULL);
v_cg_new_cmd(V_NT_SYSTEM, "error_message", 6, VCGCT_UNIQUE);
v_cg_add_param(VCGP_LONG_NAME, "message");
v_cg_new_cmd(V_NT_SYSTEM, "packet_ack", 7, VCGCT_INVISIBLE_SYSTEM);
v_cg_add_param(VCGP_UINT32, "packet_id");
v_cg_add_param(VCGP_PACK_INLINE, "\tv_cmd_buf_set_unique_address_size(head, buffer_pos);\n"
"\tv_cmd_buf_set_size(head, buffer_pos);\n"
"\tv_noq_send_ack_nak_buf(v_con_get_network_queue(), head);\n"
"\treturn;\n");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_SYSTEM, "packet_nak", 8, VCGCT_INVISIBLE_SYSTEM);
v_cg_add_param(VCGP_UINT32, "packet_id");
v_cg_add_param(VCGP_PACK_INLINE, "\tv_cmd_buf_set_unique_address_size(head, buffer_pos);\n"
"\tv_cmd_buf_set_size(head, buffer_pos);\n"
"\tv_noq_send_ack_nak_buf(v_con_get_network_queue(), head);\n"
"\treturn;\n");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_SYSTEM, "node_index_subscribe", 9, VCGCT_NORMAL);
v_cg_add_param(VCGP_UINT32, "mask");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_SYSTEM, "node_create", 10, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_ENUM_NAME, "VNodeType");
v_cg_add_param(VCGP_ENUM, "type");
v_cg_add_param(VCGP_ENUM_NAME, "VNodeOwner");
v_cg_add_param(VCGP_ENUM, "owner");
v_cg_alias(FALSE, "node_destroy", "if(owner == (uint8) ~0u || type >= V_NT_NUM_TYPES)", 1, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_SYSTEM, "node_subscribe", 11, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_alias(TRUE, "node_unsubscribe", NULL, 1, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_SYSTEM, "tag_group_create", 16, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_UINT16, "group_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NAME, "name");
v_cg_alias(FALSE, "tag_group_destroy", "if(name[0] == 0)", 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_SYSTEM, "tag_group_subscribe", 17, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_UINT16, "group_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_alias(TRUE, "tag_group_unsubscribe", NULL, 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_SYSTEM, "tag_create", 18, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_UINT16, "group_id");
v_cg_add_param(VCGP_UINT16, "tag_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NAME, "name");
v_cg_add_param(VCGP_ENUM_NAME, "VNTagType");
v_cg_add_param(VCGP_ENUM, "type");
v_cg_add_param(VCGP_POINTER_TYPE, "VNTag");
v_cg_add_param(VCGP_POINTER, "tag");
v_cg_add_param(VCGP_PACK_INLINE, "\tif(type > VN_TAG_BLOB)\n"
"\t{\n"
"\t\tv_cmd_buf_free(head);\n"
"\t\treturn;\n"
"\t}\n"
"\tswitch(type)\n"
"\t{\n"
"\t\tcase VN_TAG_BOOLEAN :\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((VNTag *)tag)->vboolean);\n"
"\t\tbreak;\n"
"\t\tcase VN_TAG_UINT32 :\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vuint32);\n"
"\t\tbreak;\n"
"\t\tcase VN_TAG_REAL64 :\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64);\n"
"\t\tbreak;\n"
"\t\tcase VN_TAG_STRING :\n"
"\t\t{\n"
"\t\t\tunsigned int i;\n"
"\t\t\tfor(i = 0; ((VNTag *)tag)->vstring[i] != 0 && i < VN_TAG_MAX_BLOB_SIZE; i++)\n"
"\t\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((VNTag *)tag)->vstring[i]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);\n"
"\t\t}\n"
"\t\tbreak;\n"
"\t\tcase VN_TAG_REAL64_VEC3 :\n"
"\t\t{\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[0]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[1]);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[2]);\n"
"\t\t}\n"
"\t\tbreak;\n"
"\t\tcase VN_TAG_LINK :\n"
"\t\t{\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vlink);\n"
"\t\t}\n"
"\t\tbreak;\n"
"\t\tcase VN_TAG_ANIMATION :\n"
"\t\t{\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.curve);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.start);\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.end);\n"
"\t\t}\n"
"\t\tbreak;\n"
"\t\tcase VN_TAG_BLOB :\n"
"\t\t{\n"
"\t\t\tunsigned int i;\n"
"\t\t\tif(((VNTag *)tag)->vblob.size > VN_TAG_MAX_BLOB_SIZE)\n"
"\t\t\t\t((VNTag *)tag)->vblob.size = VN_TAG_MAX_BLOB_SIZE;\n"
"\t\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], ((VNTag *)tag)->vblob.size);\n"
"\t\t\tfor(i = 0; i < ((VNTag *)tag)->vblob.size; i++)\n"
"\t\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((uint8 *)((VNTag *)tag)->vblob.blob)[i]);\n"
"\t\t}\n"
"\t\tbreak;\n"
"\t\tdefault :\n"
"\t\t\t;\n"
"\t}\n");
v_cg_add_param(VCGP_UNPACK_INLINE, "\tif(type < VN_TAG_TYPE_COUNT)\n"
"\t{\n"
"\t\tVNTag tag;\n"
"\t\tunsigned int i;\n"
"\t\tchar string[VN_TAG_MAX_BLOB_SIZE];\n"
"\t\tswitch(type)\n"
"\t\t{\n"
"\t\t\tcase VN_TAG_BOOLEAN :\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &tag.vboolean);\n"
"\t\t\tbreak;\n"
"\t\t\tcase VN_TAG_UINT32 :\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vuint32);\n"
"\t\t\tbreak;\n"
"\t\t\tcase VN_TAG_REAL64 :\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64);\n"
"\t\t\tbreak;\n"
"\t\t\tcase VN_TAG_STRING :\n"
"\t\t\t{\n"
"\t\t\t\ttag.vstring = string;\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], string, VN_TAG_MAX_BLOB_SIZE, buffer_length - buffer_pos);\n"
"\t\t\t}\n"
"\t\t\tbreak;\n"
"\t\t\tcase VN_TAG_REAL64_VEC3 :\n"
"\t\t\t{\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[0]);\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[1]);\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[2]);\n"
"\t\t\t}\n"
"\t\t\tbreak;\n"
"\t\t\tcase VN_TAG_LINK :\n"
"\t\t\t{\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vlink);\n"
"\t\t\t}\n"
"\t\t\tbreak;\n"
"\t\t\tcase VN_TAG_ANIMATION :\n"
"\t\t\t{\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.curve);\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.start);\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.end);\n"
"\t\t\t}\n"
"\t\t\tbreak;\n"
"\t\t\tcase VN_TAG_BLOB :\n"
"\t\t\t{\n"
"\t\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &tag.vblob.size);\n"
"\t\t\t\tif(tag.vblob.size > VN_TAG_MAX_BLOB_SIZE)\n"
"\t\t\t\t\ttag.vblob.size = VN_TAG_MAX_BLOB_SIZE;\n"
"\t\t\t\ttag.vblob.blob = string;\n"
"\t\t\t\tfor(i = 0; i < tag.vblob.size; i++)\n"
"\t\t\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &string[i]);\n"
"\t\t\t}\n"
"\t\t\tbreak;\n"
"\t\tdefault :\n"
"\t\t\t;\n"
"\t\t}\n"
"\t\tif(func_tag_create != NULL)\n"
"\t\tfunc_tag_create(v_fs_get_user_data(18), node_id, group_id, tag_id, name, type, &tag);\n"
"\t\treturn buffer_pos;\n"
"\t}\n");
v_cg_alias(FALSE, "tag_destroy", "if(type >= VN_TAG_TYPE_COUNT)", 3, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_SYSTEM, "node_name_set", 19, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_LONG_NAME, "name");
v_cg_end_cmd();
}
#endif

@ -1,36 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include "verse_header.h"
#include "v_cmd_gen.h"
#include "v_cmd_buf.h"
#if defined(V_GENERATE_FUNC_MODE)
void v_gen_text_cmd_def(void)
{
v_cg_new_cmd(V_NT_TEXT, "t_language_set", 96, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_LONG_NAME, "language");
v_cg_end_cmd();
v_cg_new_cmd(V_NT_TEXT, "t_buffer_create", 97, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_BUFFER_ID, "buffer_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_add_param(VCGP_NAME, "name");
v_cg_alias(FALSE, "t_buffer_destroy", "if(name[0] == 0)", 2, NULL);
v_cg_end_cmd();
v_cg_new_cmd(V_NT_TEXT, "t_buffer_subscribe", 98, VCGCT_NORMAL);
v_cg_add_param(VCGP_NODE_ID, "node_id");
v_cg_add_param(VCGP_BUFFER_ID, "buffer_id");
v_cg_add_param(VCGP_END_ADDRESS, NULL);
v_cg_alias(TRUE, "t_buffer_unsubscribe", NULL, 2, NULL);
v_cg_end_cmd();
v_cg_new_manual_cmd(99, "t_text_set", "void verse_send_t_text_set(VNodeID node_id, VBufferID buffer_id, uint32 pos, uint32 length, const char *text)", NULL, NULL);
}
#endif

@ -1,939 +0,0 @@
/*
**
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "verse_header.h"
#include "v_cmd_buf.h"
#include "v_cmd_gen.h"
#if defined _WIN32
#include <direct.h>
#define chdir _chdir
#define snprintf _snprintf
#endif
#if defined V_GENERATE_FUNC_MODE
#define MAX_PARAMS_PER_CMD 32
static struct {
FILE *nodes[V_NT_NUM_TYPES_NETPACK];
FILE *init;
FILE *unpack;
FILE *verse_h;
FILE *internal_verse_h;
const char *func_name;
VNodeType type;
VCGCommandType command;
unsigned int param_count;
VCGParam param_type[MAX_PARAMS_PER_CMD];
const char *param_name[MAX_PARAMS_PER_CMD];
unsigned int cmd_id;
const char *alias_name;
const char *alias_qualifier;
unsigned int alias_param;
unsigned int *alias_param_array;
char alias_bool_switch;
} VCGData;
extern void v_gen_system_cmd_def(void);
extern void v_gen_object_cmd_def(void);
extern void v_gen_geometry_cmd_def(void);
extern void v_gen_material_cmd_def(void);
extern void v_gen_bitmap_cmd_def(void);
extern void v_gen_text_cmd_def(void);
extern void v_gen_curve_cmd_def(void);
extern void v_gen_audio_cmd_def(void);
static int v_cg_init(const char *src_path)
{
char buf[1024];
int i;
FILE *f;
VCGData.nodes[V_NT_OBJECT] = fopen("v_gen_pack_o_node.c", "w");
VCGData.nodes[V_NT_GEOMETRY] = fopen("v_gen_pack_g_node.c", "w");
VCGData.nodes[V_NT_MATERIAL] = fopen("v_gen_pack_m_node.c", "w");
VCGData.nodes[V_NT_BITMAP] = fopen("v_gen_pack_b_node.c", "w");
VCGData.nodes[V_NT_TEXT] = fopen("v_gen_pack_t_node.c", "w");
VCGData.nodes[V_NT_CURVE] = fopen("v_gen_pack_c_node.c", "w");
VCGData.nodes[V_NT_AUDIO] = fopen("v_gen_pack_a_node.c", "w");
VCGData.nodes[V_NT_SYSTEM] = fopen("v_gen_pack_s_node.c", "w");
VCGData.init = fopen("v_gen_pack_init.c", "w");
VCGData.unpack = fopen("v_gen_unpack_func.h", "w");
VCGData.verse_h = fopen("verse.h", "w");
VCGData.internal_verse_h = fopen("v_internal_verse.h", "w");
for(i = 0; i < V_NT_NUM_TYPES_NETPACK + 1; i++)
{
if(i == V_NT_NUM_TYPES_NETPACK)
f = VCGData.init;
else
f = VCGData.nodes[i];
fprintf(f,
"/*\n"
"** This is automatically generated source code -- do not edit.\n"
"** Changes are affected either by editing the corresponding protocol\n"
"** definition file (v_cmd_def_X.c where X=node type), or by editing\n"
"** the code generator itself, in v_cmd_gen.c.\n"
"*/\n\n");
fprintf(f, "#include <stdlib.h>\n");
fprintf(f, "#include <stdio.h>\n\n");
fprintf(f, "#include \"v_cmd_gen.h\"\n");
fprintf(f, "#if !defined(V_GENERATE_FUNC_MODE)\n");
fprintf(f, "#include \"verse.h\"\n");
fprintf(f, "#include \"v_cmd_buf.h\"\n");
fprintf(f, "#include \"v_network_out_que.h\"\n");
fprintf(f, "#include \"v_network.h\"\n");
fprintf(f, "#include \"v_connection.h\"\n");
fprintf(f, "#include \"v_util.h\"\n\n");
}
VCGData.cmd_id = 0;
fprintf(f, "#include \"v_gen_unpack_func.h\"\n\n");
fprintf(f,
"#include \"verse.h\"\n\n\n"
"extern void verse_send_packet_ack(uint32 packet_id);\n"
"extern void verse_send_packet_nak(uint32 packet_id);\n\n");
fprintf(VCGData.init, "void init_pack_and_unpack(void)\n{\n");
fprintf(VCGData.verse_h,
"/*\n"
"** Verse API Header file (for use with libverse.a).\n"
"** This is automatically generated code; do not edit.\n"
"*/\n\n"
"\n"
"#if !defined VERSE_H\n"
"\n"
"#if defined __cplusplus\t\t/* Declare as C symbols for C++ users. */\n"
"extern \"C\" {\n"
"#endif\n\n"
"#define\tVERSE_H\n\n");
/* Copy contents of "verse_header.h" into output "verse.h". */
snprintf(buf, sizeof buf, "%sverse_header.h", src_path);
f = fopen(buf, "r");
if(f != NULL)
{
while((i = fgetc(f)) != EOF)
fputc(i, VCGData.verse_h);
fclose(f);
}
else
{
fprintf(stderr, "mkprot: Couldn't find \"%s\" input file\n", buf);
return 0;
}
fprintf(VCGData.verse_h, "\n/* Command sending functions begin. ----------------------------------------- */\n\n");
return 1;
}
static void v_cg_close(void)
{
unsigned int i;
for(i = 0; i < V_NT_NUM_TYPES_NETPACK; i++)
{
fprintf(VCGData.nodes[i], "#endif\n\n");
}
fprintf(VCGData.init, "}\n#endif\n\n");
fprintf(VCGData.verse_h,
"\n#if defined __cplusplus\n"
"}\n"
"#endif\n");
fprintf(VCGData.verse_h, "\n#endif\t\t/* VERSE_H */\n");
}
void v_cg_new_cmd(VCGCommandType type, const char *name, unsigned int cmd_id, VCGCommandType command)
{
VCGData.param_count = 0;
VCGData.func_name = name;
VCGData.type = type;
VCGData.cmd_id = cmd_id;
VCGData.command = command;
/* printf("def: %u: %s\n", cmd_id, name);*/
}
void v_cg_new_manual_cmd(unsigned int cmd_id, const char *name, const char *def, const char *alias_name, const char *alias_def)
{
fprintf(VCGData.verse_h, "extern %s;\n", def);
if(alias_def != NULL)
fprintf(VCGData.verse_h, "extern %s;\n", alias_def);
fprintf(VCGData.init, "\tv_fs_add_func(%i, v_unpack_%s, (void *) verse_send_%s, ", cmd_id, name, name);
if(alias_name != NULL)
fprintf(VCGData.init, "(void *) verse_send_%s);\n", alias_name);
else
fprintf(VCGData.init, "NULL);\n");
fprintf(VCGData.unpack, "extern unsigned int v_unpack_%s(const char *data, size_t length);\n", name);
/* printf("def: %u: %s\n", cmd_id, name);*/
}
void v_cg_alias(char bool_switch, const char *name, const char *qualifier, unsigned int param, unsigned int *param_array)
{
VCGData.alias_name = name;
VCGData.alias_qualifier = qualifier;
VCGData.alias_param = param;
VCGData.alias_param_array = param_array;
VCGData.alias_bool_switch = bool_switch;
}
void v_cg_add_param(VCGParam type, const char *name)
{
if(VCGData.param_count == MAX_PARAMS_PER_CMD)
exit(1);
VCGData.param_type[VCGData.param_count] = type;
VCGData.param_name[VCGData.param_count] = name;
VCGData.param_count++;
}
static void v_cg_gen_func_params(FILE *f, boolean types, boolean alias)
{
unsigned int i;
unsigned int length, active;
length = VCGData.param_count;
if(alias)
length = VCGData.alias_param;
for(i = 0; i < length; i++)
{
if(alias && VCGData.alias_param_array != NULL)
active = VCGData.alias_param_array[i];
else
{
for(;(VCGData.param_type[i] == VCGP_PACK_INLINE || VCGData.param_type[i] == VCGP_UNPACK_INLINE || VCGData.param_type[i] == VCGP_POINTER_TYPE || VCGData.param_type[i] == VCGP_ENUM_NAME) && i < VCGData.param_count; i++);
if(i == VCGData.param_count)
break;
active = i;
}
if(active < VCGData.param_count && VCGData.param_type[active] != VCGP_END_ADDRESS)
{
switch(VCGData.param_type[active])
{
case VCGP_UINT8 :
fprintf(f, "uint8 %s", VCGData.param_name[active]);
break;
case VCGP_UINT16 :
fprintf(f, "uint16 %s", VCGData.param_name[active]);
break;
case VCGP_UINT32 :
fprintf(f, "uint32 %s", VCGData.param_name[active]);
break;
case VCGP_REAL32 :
fprintf(f, "real32 %s", VCGData.param_name[active]);
break;
case VCGP_REAL64 :
fprintf(f, "real64 %s", VCGData.param_name[active]);
break;
case VCGP_POINTER :
if(active != 0 && VCGData.param_type[active - 1] == VCGP_POINTER_TYPE)
fprintf(f, "const %s *%s", VCGData.param_name[active - 1], VCGData.param_name[active]);
else
fprintf(f, "const void *%s", VCGData.param_name[active]);
break;
case VCGP_NAME :
if(types)
fprintf(f, "char %s[16]", VCGData.param_name[active]);
else
fprintf(f, "const char *%s", VCGData.param_name[active]);
break;
case VCGP_LONG_NAME :
if(types)
fprintf(f, "char %s[512]", VCGData.param_name[active]);
else
fprintf(f, "const char *%s", VCGData.param_name[active]);
break;
case VCGP_NODE_ID :
fprintf(f, "VNodeID %s", VCGData.param_name[active]);
break;
case VCGP_LAYER_ID :
fprintf(f, "VLayerID %s", VCGData.param_name[active]);
break;
case VCGP_BUFFER_ID :
fprintf(f, "VBufferID %s", VCGData.param_name[active]);
break;
case VCGP_FRAGMENT_ID :
fprintf(f, "VNMFragmentID %s", VCGData.param_name[active]);
break;
case VCGP_ENUM :
/* if(types)
fprintf(f, "uint8 %s", VCGData.param_name[active]);
else
*/ fprintf(f, "%s %s", VCGData.param_name[active - 1], VCGData.param_name[active]);
break;
}
if(types)
fprintf(f, ";\n\t");
else
{
for(;(VCGData.param_type[active + 1] == VCGP_END_ADDRESS || VCGData.param_type[active + 1] == VCGP_PACK_INLINE || VCGData.param_type[active + 1] == VCGP_UNPACK_INLINE || VCGData.param_type[active + 1] == VCGP_POINTER_TYPE) && active < VCGData.param_count; active++);
if(active + 1 < length)
fprintf(f, ", ");
}
}
}
}
static void v_cg_create_print(FILE *f, boolean send, boolean alias)
{
unsigned int i, length, active;
const char *name;
if(VCGData.command == VCGCT_INVISIBLE_SYSTEM)
return;
name = VCGData.func_name;
if(alias)
name = VCGData.alias_name;
if(send)
fprintf(f, "\tprintf(\"send: verse_send_%s(", name);
else
fprintf(f, "\tprintf(\"receive: verse_send_%s(", name);
length = VCGData.param_count;
if(alias)
length = VCGData.alias_param;
for(i = 0; i < length; i++)
{
if(alias && VCGData.alias_param_array != NULL)
active = VCGData.alias_param_array[i];
else
active = i;
switch(VCGData.param_type[active])
{
case VCGP_NODE_ID :
fprintf(f, "%s = %%u ", VCGData.param_name[active]);
break;
case VCGP_UINT8 :
case VCGP_UINT16 :
case VCGP_UINT32 :
case VCGP_LAYER_ID :
case VCGP_BUFFER_ID :
case VCGP_ENUM :
case VCGP_FRAGMENT_ID :
fprintf(f, "%s = %%u ", VCGData.param_name[active]);
break;
case VCGP_REAL32 :
case VCGP_REAL64 :
fprintf(f, "%s = %%f ", VCGData.param_name[active]);
break;
case VCGP_POINTER :
if(send)
fprintf(f, "%s = %%p ", VCGData.param_name[active]);
break;
case VCGP_NAME :
case VCGP_LONG_NAME :
fprintf(f, "%s = %%s ", VCGData.param_name[active]);
break;
}
}
if(send)
fprintf(f, ");\\n\"");
else
fprintf(f, "); callback = %%p\\n\"");
for(i = 0; i < length; i++)
{
if(alias && VCGData.alias_param_array != NULL)
active = VCGData.alias_param_array[i];
else
active = i;
switch(VCGData.param_type[active])
{
case VCGP_NODE_ID :
fprintf(f, ", %s", VCGData.param_name[active]);
break;
case VCGP_POINTER :
if(!send)
break;
case VCGP_UINT8 :
case VCGP_UINT16 :
case VCGP_UINT32 :
case VCGP_LAYER_ID :
case VCGP_BUFFER_ID :
case VCGP_ENUM :
case VCGP_FRAGMENT_ID :
case VCGP_REAL32 :
case VCGP_REAL64 :
case VCGP_NAME :
case VCGP_LONG_NAME :
fprintf(f, ", %s", VCGData.param_name[active]);
break;
}
}
if(send)
fprintf(f, ");\n");
else if(alias)
fprintf(f, ", v_fs_get_alias_user_func(%u));\n", VCGData.cmd_id);
else
fprintf(f, ", v_fs_get_user_func(%u));\n", VCGData.cmd_id);
}
static unsigned int v_cg_compute_command_size(unsigned int start, boolean end)
{
unsigned int size = 0;
for(; start < VCGData.param_count; start++)
{
switch(VCGData.param_type[start])
{
case VCGP_UINT8 :
case VCGP_ENUM :
size++;
break;
case VCGP_UINT16 :
case VCGP_LAYER_ID :
case VCGP_BUFFER_ID :
case VCGP_FRAGMENT_ID :
size += 2;
break;
case VCGP_NODE_ID :
case VCGP_UINT32 :
case VCGP_REAL32 :
size += 4;
break;
case VCGP_REAL64 :
size += 8;
break;
case VCGP_NAME :
if(end)
return size;
size += 16;
break;
case VCGP_LONG_NAME :
if(end)
return size;
size += 512;
break;
case VCGP_POINTER :
case VCGP_PACK_INLINE :
case VCGP_UNPACK_INLINE :
if(end)
return size;
size += 1500;
break;
case VCGP_END_ADDRESS :
if(end)
return size;
}
}
return size;
}
void v_cg_set_command_address(FILE *f, boolean alias)
{
unsigned int i, j, count = 0, length, size = 1, *param, def[] ={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
for(i = 0; i < VCGData.param_count; i++)
if(VCGData.param_type[i] == VCGP_END_ADDRESS)
break;
if(i == VCGData.param_count)
return;
if(alias)
length = VCGData.alias_param;
else
length = VCGData.param_count;
if(alias && VCGData.alias_param_array != 0)
param = VCGData.alias_param_array;
else
param = def;
if(i == VCGData.param_count)
return;
fprintf(f, "\tif(");
for(i = j = 0; i < VCGData.param_count; i++)
{
switch(VCGData.param_type[i])
{
case VCGP_UINT8 :
case VCGP_ENUM :
size++;
break;
case VCGP_UINT16 :
case VCGP_LAYER_ID :
case VCGP_BUFFER_ID :
case VCGP_FRAGMENT_ID :
size += 2;
break;
case VCGP_NODE_ID :
case VCGP_UINT32 :
case VCGP_REAL32 :
size += 4;
break;
}
if(j < length && param[j] == i)
{
switch(VCGData.param_type[param[j]])
{
case VCGP_UINT8 :
case VCGP_ENUM :
break;
case VCGP_UINT16 :
case VCGP_LAYER_ID :
case VCGP_BUFFER_ID :
case VCGP_FRAGMENT_ID :
if(count++ != 0)
fprintf(f, " || ");
fprintf(f, "%s == (uint16) ~0u", VCGData.param_name[param[j]]);
break;
case VCGP_NODE_ID :
case VCGP_UINT32 :
case VCGP_REAL32 :
if(count++ != 0)
fprintf(f, " || ");
fprintf(f, "%s == (uint32) ~0u", VCGData.param_name[param[j]]);
break;
}
j++;
}
if(VCGData.param_type[i] == VCGP_END_ADDRESS)
{
fprintf(f, ")\n");
fprintf(f, "\t\tv_cmd_buf_set_unique_address_size(head, %u);\n", size);
fprintf(f, "\telse\n");
fprintf(f, "\t\tv_cmd_buf_set_address_size(head, %u);\n", size);
return;
}
}
fprintf(f, ")\n");
fprintf(f, "\t\tv_cmd_buf_set_unique_address_size(head, %u);\n", size);
fprintf(f, "\telse\n");
fprintf(f, "\t\tv_cmd_buf_set_address_size(head, %u);\n", size);
return;
}
static const char * v_cg_compute_buffer_size(void)
{
unsigned int size;
size = v_cg_compute_command_size(0, FALSE) + 1;
if(size <= 10)
return "VCMDBS_10";
else if(size <= 20)
return "VCMDBS_20";
else if(size <= 30)
return "VCMDBS_30";
else if(size <= 80)
return "VCMDBS_80";
else if(size <= 160)
return "VCMDBS_160";
else if(size <= 320)
return "VCMDBS_320";
return "VCMDBS_1500";
}
static void v_cg_gen_pack(boolean alias)
{
unsigned int i, j, size = 0, ad_size = 0;
boolean printed = FALSE;
boolean address = FALSE;
boolean no_param;
FILE *f;
f = VCGData.nodes[VCGData.type];
printf("generating function: verse_send_%s\n", VCGData.func_name);
if(alias)
fprintf(f, "void verse_send_%s(", VCGData.alias_name);
else
fprintf(f, "void verse_send_%s(", VCGData.func_name);
v_cg_gen_func_params(f, FALSE, alias);
fprintf(f, ")\n{\n\tuint8 *buf;\n");
fprintf(f, "\tunsigned int buffer_pos = 0;\n");
fprintf(f, "\tVCMDBufHead *head;\n");
fprintf(f, "\thead = v_cmd_buf_allocate(%s);/* Allocating the buffer */\n", v_cg_compute_buffer_size());
fprintf(f, "\tbuf = ((VCMDBuffer10 *)head)->buf;\n\n");
fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], %u);\t/* Pack the command. */\n", VCGData.cmd_id);
fprintf(f, "#if defined V_PRINT_SEND_COMMANDS\n");
v_cg_create_print(f, TRUE, alias);
fprintf(f, "#endif\n");
for(i = 0; i < VCGData.param_count; i++)
{
const char *param = VCGData.param_name[i];
no_param = FALSE;
if(alias)
{
if(i >= VCGData.alias_param && VCGData.alias_param_array == NULL)
no_param = TRUE;
if(VCGData.alias_param_array != NULL)
{
for(j = 0; j < VCGData.alias_param; j++)
if(VCGData.alias_param_array[j] == i)
break;
if(j == VCGData.alias_param)
no_param = TRUE;
}
}
if(no_param)
param = "-1";
switch(VCGData.param_type[i])
{
case VCGP_UINT8 :
fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], %s);\n", param);
break;
case VCGP_UINT16 :
fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], %s);\n", param);
break;
case VCGP_UINT32 :
fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], %s);\n", param);
break;
case VCGP_ENUM :
fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)%s);\n", param);
break;
}
if(VCGData.param_type[i] == VCGP_REAL32)
{
if(no_param)
param = "V_REAL32_MAX";
fprintf(f, "\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], %s);\n", param);
}
if(VCGData.param_type[i] == VCGP_REAL64)
{
if(no_param)
param = "V_REAL64_MAX";
fprintf(f, "\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], %s);\n", param);
}
if(no_param)
param = "NULL";
switch(VCGData.param_type[i])
{
case VCGP_NAME :
fprintf(f, "\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], %s, 16);\n", param);
break;
case VCGP_LONG_NAME :
fprintf(f, "\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], %s, 512);\n", param);
break;
}
if(no_param)
{
/* Horrible work-around, that prevents vertex/polygon deletes from misbehaving. */
if(strncmp(VCGData.alias_name, "g_vertex_delete_real", 20) == 0 && i == 1)
param = "0";
else if(strncmp(VCGData.alias_name, "g_polygon_delete", 16) == 0 && i == 1)
param = "1";
else
param = "-1";
}
switch(VCGData.param_type[i])
{
case VCGP_NODE_ID :
fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], %s);\n", param);
break;
case VCGP_LAYER_ID :
fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], %s);\n", param);
break;
case VCGP_BUFFER_ID :
fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], %s);\n", param);
break;
case VCGP_FRAGMENT_ID :
fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], %s);\n", param);
break;
}
if(!alias && VCGData.param_type[i] == VCGP_PACK_INLINE)
fprintf(f, "%s", VCGData.param_name[i]);
}
if(VCGData.alias_name != NULL && VCGData.alias_bool_switch)
{
if(alias)
fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);\n");
else
fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);\n");
}
v_cg_set_command_address(f, alias);
fprintf(f, "\tv_cmd_buf_set_size(head, buffer_pos);\n");
fprintf(f, "\tv_noq_send_buf(v_con_get_network_queue(), head);\n");
fprintf(f, "}\n\n");
}
static void v_cg_gen_unpack(void)
{
FILE *f;
unsigned int i;
boolean printed = FALSE;
f = VCGData.nodes[VCGData.type];
printf("generating function: v_unpack_%s\n", VCGData.func_name);
fprintf(f, "unsigned int v_unpack_%s(const char *buf, size_t buffer_length)\n", VCGData.func_name);
fprintf(f, "{\n");
for(i = 0; i < VCGData.param_count && VCGData.param_type[i] != VCGP_ENUM; i++);
if(i < VCGData.param_count)
fprintf(f, "\tuint8 enum_temp;\n");
fprintf(f, "\tunsigned int buffer_pos = 0;\n");
fprintf(f, "\tvoid (* func_%s)(void *user_data, ", VCGData.func_name);
v_cg_gen_func_params(f, FALSE, FALSE);
fprintf(f, ");\n\t");
v_cg_gen_func_params(f, TRUE, FALSE);
if(VCGData.alias_name != NULL && VCGData.alias_bool_switch)
fprintf(f, "uint8\talias_bool;\n");
fprintf(f, "\n\tfunc_%s = v_fs_get_user_func(%u);\n", VCGData.func_name, VCGData.cmd_id);
fprintf(f, "\tif(buffer_length < %u)\n\t\treturn -1;\n", v_cg_compute_command_size(0, TRUE));
for(i = 0; i < VCGData.param_count; i++)
{
switch(VCGData.param_type[i])
{
case VCGP_UINT8 :
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]);
break;
case VCGP_UINT16 :
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]);
break;
case VCGP_UINT32 :
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]);
break;
case VCGP_REAL32 :
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]);
break;
case VCGP_REAL64 :
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]);
break;
case VCGP_POINTER_TYPE :
break;
case VCGP_POINTER :
break;
case VCGP_NAME :
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], %s, 16, buffer_length - buffer_pos);\n", VCGData.param_name[i]);
if(i + 1 < VCGData.param_count)
fprintf(f, "\tif(buffer_length < %u + buffer_pos)\n\t\treturn -1;\n", v_cg_compute_command_size(i + 1, TRUE));
break;
case VCGP_LONG_NAME :
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], %s, 512, buffer_length - buffer_pos);\n", VCGData.param_name[i]);
if(i + 1 < VCGData.param_count)
fprintf(f, "\tif(buffer_length < %u + buffer_pos)\n\t\treturn -1;\n", v_cg_compute_command_size(i + 1, TRUE));
break;
case VCGP_NODE_ID :
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]);
break;
case VCGP_LAYER_ID :
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]);
break;
case VCGP_BUFFER_ID :
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]);
break;
case VCGP_FRAGMENT_ID :
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]);
break;
case VCGP_ENUM :
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);\n");
fprintf(f, "\t%s = (%s)enum_temp;\n", VCGData.param_name[i], VCGData.param_name[i - 1]);
break;
case VCGP_UNPACK_INLINE :
if(!printed)
{
fprintf(f, "#if defined V_PRINT_RECEIVE_COMMANDS\n");
if(VCGData.alias_name != NULL)
{
fprintf(f, "\t%s\n\t", VCGData.alias_qualifier);
v_cg_create_print(f, FALSE, TRUE);
fprintf(f, "\telse\n\t");
}
v_cg_create_print(f, FALSE, FALSE);
fprintf(f, "#endif\n");
printed = TRUE;
}
fprintf(f, "%s\n", VCGData.param_name[i++]);
break;
}
}
if(VCGData.alias_name != NULL && VCGData.alias_bool_switch)
{
fprintf(f, "\tif(buffer_length < buffer_pos + 1)\n");
fprintf(f, "\t\treturn -1;\n");
fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);\n");
}
if(!printed)
{
fprintf(f, "#if defined V_PRINT_RECEIVE_COMMANDS\n");
if(VCGData.alias_name != NULL)
{
if(VCGData.alias_qualifier != NULL)
fprintf(f, "\t%s\n\t", VCGData.alias_qualifier);
else
fprintf(f, "\tif(!alias_bool)\n\t");
v_cg_create_print(f, FALSE, TRUE);
fprintf(f, "\telse\n\t");
}
v_cg_create_print(f, FALSE, FALSE);
fprintf(f, "#endif\n");
printed = TRUE;
}
if(VCGData.alias_name != NULL)
{
unsigned int active;
if(VCGData.alias_bool_switch)
fprintf(f, "\tif(!alias_bool)\n");
else
fprintf(f, "\t%s\n", VCGData.alias_qualifier);
fprintf(f, "\t{\n");
fprintf(f, "\t\tvoid (* alias_%s)(void *user_data, ", VCGData.alias_name);
v_cg_gen_func_params(f, FALSE, TRUE);
fprintf(f, ");\n");
fprintf(f, "\t\talias_%s = v_fs_get_alias_user_func(%u);\n", VCGData.alias_name, VCGData.cmd_id);
fprintf(f, "\t\tif(alias_%s != NULL)\n", VCGData.alias_name);
fprintf(f, "\t\t\talias_%s(v_fs_get_alias_user_data(%u)", VCGData.alias_name, VCGData.cmd_id);
for(i = 0; i < VCGData.param_count && i < VCGData.alias_param; i++)
{
if(VCGData.alias_param_array != NULL)
active = VCGData.alias_param_array[i];
else
active = i;
if(VCGData.param_type[active] != VCGP_PACK_INLINE &&
VCGData.param_type[active] != VCGP_UNPACK_INLINE &&
VCGData.param_type[active] != VCGP_END_ADDRESS &&
VCGData.param_type[active] != VCGP_POINTER_TYPE)
{
if(VCGData.param_type[active] == VCGP_ENUM_NAME)
{
fprintf(f, ", (%s)%s", VCGData.param_name[active], VCGData.param_name[active + 1]);
i++;
}
else
fprintf(f, ", %s", VCGData.param_name[active]);
}
}
fprintf(f, ");\n\t\treturn buffer_pos;\n\t}\n");
}
fprintf(f, "\tif(func_%s != NULL)\n", VCGData.func_name);
fprintf(f, "\t\tfunc_%s(v_fs_get_user_data(%u)", VCGData.func_name, VCGData.cmd_id);
for(i = 0; i < VCGData.param_count; i++)
{
if(VCGData.param_type[i] != VCGP_PACK_INLINE && VCGData.param_type[i] != VCGP_UNPACK_INLINE && VCGData.param_type[i] != VCGP_END_ADDRESS && VCGData.param_type[i] != VCGP_POINTER_TYPE)
{
if(VCGData.param_type[i] == VCGP_ENUM_NAME)
{
fprintf(f, ", (%s) %s", VCGData.param_name[i], VCGData.param_name[i + 1]);
i++;
}
else
fprintf(f, ", %s", VCGData.param_name[i]);
}
}
fprintf(f, ");\n");
fprintf(f, "\n\treturn buffer_pos;\n");
fprintf(f, "}\n\n");
}
static void v_cg_gen_alias(void)
{
FILE *f;
unsigned int i;
f = VCGData.nodes[VCGData.type];
fprintf(f, "void verse_send_%s(", VCGData.alias_name);
v_cg_gen_func_params(f, FALSE, TRUE);
fprintf(f, ")\n{\n");
fprintf(f, "\tverse_send_%s(", VCGData.func_name);
for(i = 0; i < VCGData.param_count; i++)
if(VCGData.param_type[i] != VCGP_ENUM_NAME && VCGData.param_type[i] != VCGP_PACK_INLINE && VCGData.param_type[i] != VCGP_UNPACK_INLINE && VCGData.param_type[i] != VCGP_END_ADDRESS && VCGData.param_type[i] != VCGP_POINTER_TYPE)
fprintf(f, ", %s", VCGData.param_name[i]);
fprintf(f, "}\n\n");
}
static void v_cg_gen_init(void)
{
FILE *f;
f = VCGData.init;
fprintf(f, "\tv_fs_add_func(%i, v_unpack_%s, verse_send_%s, ", VCGData.cmd_id, VCGData.func_name, VCGData.func_name);
if(VCGData.alias_name != NULL)
fprintf(f, "verse_send_%s);\n", VCGData.alias_name);
else
fprintf(f, "NULL);\n");
}
static void v_cg_gen_verse_h(void)
{
FILE *f;
if(VCGData.command == VCGCT_INVISIBLE_SYSTEM)
f = VCGData.internal_verse_h;
else
f = VCGData.verse_h;
fprintf(f, "extern void verse_send_%s(", VCGData.func_name);
v_cg_gen_func_params(f, FALSE, FALSE);
fprintf(f, ");\n");
if(VCGData.alias_name != NULL)
{
fprintf(f, "extern void verse_send_%s(", VCGData.alias_name);
v_cg_gen_func_params(f, FALSE, TRUE);
fprintf(f, ");\n");
}
}
static void v_cg_gen_unpack_h(void)
{
fprintf(VCGData.unpack, "extern unsigned int v_unpack_%s(const char *data, size_t length);\n", VCGData.func_name);
}
void v_cg_end_cmd(void)
{
v_cg_gen_pack(FALSE);
if(VCGData.alias_name != NULL)
v_cg_gen_pack(TRUE);
v_cg_gen_unpack();
v_cg_gen_init();
v_cg_gen_verse_h();
v_cg_gen_unpack_h();
VCGData.alias_name = NULL;
}
int main(int argc, char *argv[])
{
const char *src = "";
int i;
for(i = 1; argv[i] != NULL; i++)
{
if(strcmp(argv[i], "-h") == 0)
{
printf("Verse protocol generation tool.\nUsage:\n");
printf(" -h\t\tPrint this usage information, and exit.\n");
printf(" -src=PATH\tSets source path prefix to PATH. It must be possible to find\n");
printf("\t\tthe \"verse_header.h\" input file by appending that name to PATH.\n");
printf("\t\tThus, PATH must end with a proper directory separator character.\n");
printf(" -dst=PATH\tSets output directory, where all output files are written.\n");
printf("\t\tIf used, use -src to point to where \"verse_header.h\" is.\n");
printf("\nThe -src and -dst options were added to simplify building of Verse-Blender.\n");
return EXIT_SUCCESS;
}
else if(strncmp(argv[i], "-src=", 5) == 0)
src = argv[i] + 5;
else if(strncmp(argv[i], "-dst=", 5) == 0)
{
if(chdir(argv[i] + 5) != 0)
fprintf(stderr, "%s: Couldn't set output directory to \"%s\"\n", argv[0], argv[i] + 5);
}
else
fprintf(stderr, "%s: Ignoring unknown option \"%s\"\n", argv[0], argv[i]);
}
printf("start\n");
if(!v_cg_init(src))
return EXIT_FAILURE;
v_gen_system_cmd_def();
fprintf(VCGData.verse_h, "\n");
v_gen_object_cmd_def();
fprintf(VCGData.verse_h, "\n");
v_gen_geometry_cmd_def();
fprintf(VCGData.verse_h, "\n");
v_gen_material_cmd_def();
fprintf(VCGData.verse_h, "\n");
v_gen_bitmap_cmd_def();
fprintf(VCGData.verse_h, "\n");
v_gen_text_cmd_def();
fprintf(VCGData.verse_h, "\n");
v_gen_curve_cmd_def();
fprintf(VCGData.verse_h, "\n");
v_gen_audio_cmd_def();
fprintf(VCGData.verse_h, "\n");
v_cg_close();
printf("end\n");
return EXIT_SUCCESS;
}
#endif

@ -1,42 +0,0 @@
/*
**
*/
/* Define this to at least build the code that regenerates the variable parts of the code. */
/*#define V_GENERATE_FUNC_MODE*/
typedef enum {
VCGP_UINT8,
VCGP_UINT16,
VCGP_UINT32,
VCGP_REAL32,
VCGP_REAL64,
VCGP_POINTER_TYPE,
VCGP_POINTER,
VCGP_NAME,
VCGP_LONG_NAME,
VCGP_NODE_ID,
VCGP_LAYER_ID,
VCGP_BUFFER_ID,
VCGP_FRAGMENT_ID,
VCGP_ENUM_NAME,
VCGP_ENUM,
VCGP_PACK_INLINE,
VCGP_UNPACK_INLINE,
VCGP_END_ADDRESS
} VCGParam;
typedef enum {
VCGCT_NORMAL,
VCGCT_UNIQUE,
VCGCT_ONCE,
VCGCT_INVISIBLE_SYSTEM, /* In the dark we are all invisible. */
VCGCT_ORDERED
} VCGCommandType;
extern void v_cg_new_cmd(VCGCommandType type, const char *name, unsigned int cmd_id, VCGCommandType command);
extern void v_cg_add_param(VCGParam type, const char *name);
extern void v_cg_alias(char bool_switch, const char *name, const char *qualifier,
unsigned int param, unsigned int *param_array);
extern void v_cg_end_cmd(void);
extern void v_cg_new_manual_cmd(unsigned int cmd_id, const char *name, const char *params, const char *alias_name, const char *alias_params);

@ -1,490 +0,0 @@
/*
**
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "v_cmd_gen.h"
#if !defined V_GENERATE_FUNC_MODE
#include "verse.h"
#include "v_cmd_buf.h"
#include "v_network_out_que.h"
#include "v_network.h"
#include "v_connection.h"
#include "v_encryption.h"
#include "v_util.h"
extern void verse_send_packet_ack(uint32 packet_id);
static void v_send_hidden_connect_contact(void) /* Stage 0: Clinets inital call to connect to host */
{
uint8 buf[V_ENCRYPTION_LOGIN_KEY_HALF_SIZE + 4 + 1 + 1], *key;
unsigned int i, buffer_pos = 0;
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], 0);/* Packing the packet id */
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);/* Packing the command */
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);/* Stage 0 */
key = v_con_get_my_key();
for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++)
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], key[V_ENCRYPTION_LOGIN_PUBLIC_START + i]);/* Packing the command */
for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++)
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], key[V_ENCRYPTION_LOGIN_N_START + i]);/* Packing the command */
v_n_send_data(v_con_get_network_address(), buf, buffer_pos);
}
static void v_send_hidden_connect_send_key(void) /* Stage 1: Hosts reply to any atempt to connect */
{
uint8 buf[V_ENCRYPTION_LOGIN_KEY_SIZE * 3 + 4 + 1 + 1 + 1 + 4 + 4], *host_id;
unsigned int i, buffer_pos = 0, s, f;
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], 0);/* Packing the packet id */
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);/* Packing the command */
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 1);/* Stage 1 */
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], V_RELEASE_NUMBER);/* version */
v_n_get_current_time(&s, &f);
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], s);/* time, seconds */
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], f);/* time, fraction */
host_id = v_con_get_host_id();
for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++)
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], host_id[V_ENCRYPTION_LOGIN_PUBLIC_START + i]);
for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++)
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], host_id[V_ENCRYPTION_LOGIN_N_START + i]);
v_n_send_data(v_con_get_network_address(), buf, buffer_pos);
}
static void v_send_hidden_connect_login(void) /* Stage 2: clients sends encrypted name and password */
{
uint8 buf[1500], *key, name_pass[V_ENCRYPTION_LOGIN_KEY_SIZE], encrypted_key[V_ENCRYPTION_LOGIN_KEY_SIZE];
const char *name, *pass;
unsigned int buffer_pos = 0, i;
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], 1);/* Packing the packet id */
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);/* Packing the command */
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 2);/* Stage 2 */
name = v_con_get_name();
/* Pad data area with randomness. */
for(i = 0; i < sizeof name_pass; i++)
name_pass[i] = rand() >> 13;
v_strlcpy(name_pass, name, V_ENCRYPTION_LOGIN_KEY_SIZE / 2);
pass = v_con_get_pass();
v_strlcpy(name_pass + V_ENCRYPTION_LOGIN_KEY_SIZE / 2, pass, V_ENCRYPTION_LOGIN_KEY_SIZE / 2);
/* Make sure last (MSB) byte is clear, to guarantee that data < key for RSA math. */
name_pass[sizeof name_pass - 1] = 0;
key = v_con_get_other_key();
v_e_connect_encrypt(encrypted_key, name_pass, &key[V_ENCRYPTION_LOGIN_PUBLIC_START], &key[V_ENCRYPTION_LOGIN_N_START]);
for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++)
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], encrypted_key[i]);
v_n_send_data(v_con_get_network_address(), buf, buffer_pos);
}
static void v_send_hidden_connect_accept(void) /* Host accepts Clients connectionatempt and sends over data encryption key */
{
uint8 buf[1500], *client_key, encrypted[V_ENCRYPTION_DATA_KEY_SIZE];
unsigned int i, buffer_pos = 0;
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], 1);/* Packing the packet id */
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 1);/* Packing the command */
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], verse_session_get_avatar());
client_key = v_con_get_other_key();
v_e_connect_encrypt(encrypted, v_con_get_data_key(), &client_key[V_ENCRYPTION_LOGIN_PUBLIC_START], &client_key[V_ENCRYPTION_LOGIN_N_START]);
for(i = 0; i < V_ENCRYPTION_DATA_KEY_SIZE; i++)
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], encrypted[i]);
v_n_send_data(v_con_get_network_address(), buf, buffer_pos);
}
static void v_send_hidden_connect_terminate(VNetworkAddress *address, unsigned int packet_id, const char *bye) /* Host accepts Clients connectionatempt and sends over data encryption key */
{
uint8 buf[1500];
unsigned int buffer_pos = 0;
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], packet_id);/* Packing the packet id */
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 2);/* Packing the command */
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], bye, 512); /* pack message */
v_e_data_encrypt_command(buf, sizeof (uint32), buf + sizeof (uint32), buffer_pos, v_con_get_data_key());
v_n_send_data(address, buf, buffer_pos);
}
VSession verse_send_connect(const char *name, const char *pass, const char *address, const uint8 *expected_key)
{
uint8 *my_key, *key = NULL;
unsigned int i;
VNetworkAddress a;
VSession *session;
if(v_n_set_network_address(&a, address))
{
#if defined(V_PRINT_SEND_COMMANDS)
char ip_string[32];
#endif
session = v_con_connect(a.ip, a.port, V_CS_CONTACT);
#if defined(V_PRINT_SEND_COMMANDS)
v_n_get_address_string(&a, ip_string);
printf("send: %p = verse_send_connect(name = %s, pass = %s, address = %s (%s), expected_key = %p)\n", session, name, pass, address, ip_string, expected_key);
#endif
v_con_set_name_pass(name, pass);
if(expected_key != NULL)
{
key = malloc((sizeof *key) * V_ENCRYPTION_LOGIN_KEY_HALF_SIZE);
for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_HALF_SIZE; i++)
key[i] = expected_key[i];
*v_con_get_expected_key() = key;
}
my_key = v_con_get_my_key();
v_e_connect_create_key(&my_key[V_ENCRYPTION_LOGIN_PRIVATE_START], &my_key[V_ENCRYPTION_LOGIN_PUBLIC_START], &my_key[V_ENCRYPTION_LOGIN_N_START]);
v_send_hidden_connect_contact();
v_con_inqueue_timer_update(); /* Reset timer in connection's in queue, above takes a while. */
return session;
}
else
{
#if defined(V_PRINT_SEND_COMMANDS)
printf("send: NULL = verse_send_connect(name = %s, pass = %s, address = %s (Unressolved DNS), key = %p);\n", name, pass, address, key);
#endif
return NULL;
}
}
void v_update_connection_pending(boolean resend)
{
VSession (* func_connect)(void *user_data, const char *name, const char *pass, const char *address, const uint8 *key) = NULL;
VSession (* func_connect_accept)(void *user_data, VNodeID avatar, char *address, uint8 *host_id);
void (* func_connect_terminate)(void *user_data, char *address, const char *bye);
char address_string[32];
switch(v_con_get_connect_stage())
{
case V_CS_CONTACT : /* client tries to contact host */
if(resend)
v_send_hidden_connect_contact();
break;
case V_CS_CONTACTED : /* Host replies with challange */
if(resend)
v_send_hidden_connect_send_key();
break;
case V_CS_PENDING_ACCEPT : /* Client sends login */
if(resend)
v_send_hidden_connect_login();
break;
case V_CS_PENDING_HOST_CALLBACK : /* Host got login waits for accept connect callback */
v_con_set_connect_stage(V_CS_PENDING_DECISION);
func_connect = v_fs_get_user_func(0);
v_n_get_address_string(v_con_get_network_address(), address_string);
#if defined(V_PRINT_RECEIVE_COMMANDS)
printf("receive: verse_send_connect(address = %s, name = %s, pass = %s, key = NULL); callback = %p\n", address_string, v_con_get_name(), v_con_get_pass(), func_connect);
#endif
if(func_connect != 0)
func_connect(v_fs_get_user_data(0), v_con_get_name(), v_con_get_pass(), address_string, NULL);
break;
case V_CS_PENDING_CLIENT_CALLBACK_ACCEPT : /* Host got login waits for accept connect callback */
v_con_set_connect_stage(V_CS_CONNECTED);
func_connect_accept = v_fs_get_user_func(1);
v_n_get_address_string(v_con_get_network_address(), address_string);
#if defined(V_PRINT_RECEIVE_COMMANDS)
printf("receive: func_connect_accept(avatar = %u, address = %s, name = %s, pass = %s, key = NULL); callback = %p\n",
verse_session_get_avatar(), address_string, v_con_get_name(), v_con_get_pass(), func_connect);
#endif
if(func_connect_accept != 0)
func_connect_accept(v_fs_get_user_data(1), verse_session_get_avatar(), address_string, NULL);
break;
case V_CS_PENDING_CLIENT_CALLBACK_TERMINATE : /* Host got login waits for accept connect callback */
v_con_set_connect_stage(V_CS_CONNECTED);
func_connect_terminate = v_fs_get_user_func(2);
v_n_get_address_string(v_con_get_network_address(), address_string);
#if defined(V_PRINT_RECEIVE_COMMANDS)
printf("receive: func_connect_terminate(address = %s, bye = %s); callback = %p\n", address_string, "no message", func_connect);
#endif
if(func_connect_terminate != 0)
func_connect_terminate(v_fs_get_user_data(2), address_string, "no message");
break;
default:
;
}
}
void v_unpack_connection(const char *buf, unsigned int buffer_length) /* un packing all stages of connect command */
{
unsigned int buffer_pos, i, pack_id;
uint32 seconds, fractions, pre;
uint8 /*key[V_ENCRYPTION_LOGIN_KEY_SIZE], */stage, cmd_id, version;
if(buffer_length < 5)
return;
buffer_pos = vnp_raw_unpack_uint32(buf, &pack_id);
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &cmd_id);
pre = v_con_get_connect_stage();
if(cmd_id == 0)
{
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &stage);
printf(" Handling connection, stage %u\n", stage);
if(stage == V_CS_IDLE && V_CS_IDLE == v_con_get_connect_stage()) /* reseved by host */
{
uint8 *other_key, *my_key;
verse_send_packet_ack(pack_id);
my_key = v_con_get_my_key();
v_con_set_data_key(v_e_data_create_key());
other_key = v_con_get_other_key();
for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++)
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &other_key[V_ENCRYPTION_LOGIN_PUBLIC_START + i]);/* Packing the command */
for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++)
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &other_key[V_ENCRYPTION_LOGIN_N_START + i]);/* Packing the command */
v_con_set_connect_stage(V_CS_CONTACTED);
v_send_hidden_connect_send_key();
return;
}
if(stage == V_CS_CONTACT && V_CS_CONTACT == v_con_get_connect_stage())
{
uint8 *other_key; /* *host_id, *my_key, a[V_ENCRYPTION_LOGIN_KEY_SIZE], b[V_ENCRYPTION_LOGIN_KEY_SIZE];*/
verse_send_packet_ack(pack_id);
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &version);
if(version != V_RELEASE_NUMBER)
{
/* char error_message[128];
func_connect_deny = v_fs_get_user_func(2);
#if defined(V_PRINT_RECEIVE_COMMANDS)
printf("receive: verse_send_connect_deny(Host is running version %u you are running version %u); callback = %p\n", (uint32)version, (uint32)V_RELEASE_NUMBER func_connect_deny);
#endif
if(func_connect_deny != NULL)
{
sprintf(error_message, "Host is running version %u you are running version %u", (uint32)version, (uint32)V_RELEASE_NUMBER);
func_connect_deny(v_fs_get_user_data(2), error_message);
}*/
return;
}
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &seconds);
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &fractions);
v_con_set_time(seconds, fractions);
other_key = v_con_get_other_key();
for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++)
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &other_key[V_ENCRYPTION_LOGIN_PUBLIC_START + i]);
for(i = 0; i < V_ENCRYPTION_DATA_KEY_SIZE; i++)
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &other_key[V_ENCRYPTION_LOGIN_N_START + i]);
v_con_set_connect_stage(V_CS_PENDING_ACCEPT);
v_send_hidden_connect_login();
return;
}
#if 0
for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_HALF_SIZE && encrypted_key[i] == 0; i++);
if(i < 0)
{
other_key = v_con_get_my_key();
v_e_connect_encrypt(decrypted_key, encrypted_key, &other_key[V_ENCRYPTION_LOGIN_PUBLIC_START + i], &other_key[V_ENCRYPTION_LOGIN_N_START + i]);
for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_HALF_SIZE && my_key[V_ENCRYPTION_LOGIN_PUBLIC_START + i] == decrypted_key[i]; i++);
if(i < 0) /* Host is not who it appers top be */
{
func_connect_deny = v_fs_get_user_func(2);
#if defined(V_PRINT_RECEIVE_COMMANDS)
printf("receive: verse_send_connect_deny(Host failed identity check); callback = %p\n", func_connect_deny);
#endif
if(func_connect_deny != NULL)
func_connect_deny(v_fs_get_user_data(2), "Host failed identity check");
return;
}
}
#endif
if(stage == V_CS_CONTACTED && V_CS_CONTACTED == v_con_get_connect_stage()) /* reseved by host */
{
char *host_id, unpack[V_ENCRYPTION_LOGIN_KEY_SIZE], data[V_ENCRYPTION_LOGIN_KEY_SIZE];
VNetworkAddress *address;
verse_send_packet_ack(pack_id);
address = v_con_get_network_address();
for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++)
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &data[i]);
host_id = v_con_get_host_id();
v_e_connect_encrypt(unpack, data, &host_id[V_ENCRYPTION_LOGIN_PRIVATE_START], &host_id[V_ENCRYPTION_LOGIN_N_START]);
v_con_set_name_pass(unpack, &unpack[V_ENCRYPTION_LOGIN_KEY_SIZE / 2]);
v_con_set_connect_stage(V_CS_PENDING_HOST_CALLBACK);
return;
}
}
if(cmd_id == 1 && V_CS_PENDING_ACCEPT == v_con_get_connect_stage()) /* reseved by client */
{
uint8 *my_key, key[V_ENCRYPTION_DATA_KEY_SIZE], decrypted[V_ENCRYPTION_DATA_KEY_SIZE];
uint32 avatar;
verse_send_packet_ack(pack_id);
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &avatar);
v_con_set_avatar(avatar);
for(i = 0; i < V_ENCRYPTION_DATA_KEY_SIZE; i++)
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &key[i]);
my_key = v_con_get_my_key();
v_e_connect_encrypt(decrypted, key, &my_key[V_ENCRYPTION_LOGIN_PRIVATE_START], &my_key[V_ENCRYPTION_LOGIN_N_START]);
v_con_set_data_key(decrypted);
v_con_set_connect_stage(V_CS_PENDING_CLIENT_CALLBACK_ACCEPT);
v_send_hidden_connect_send_key();
return;
}
if(cmd_id == 2 && V_CS_PENDING_ACCEPT == v_con_get_connect_stage()) /* reseved by client */
{
verse_send_packet_ack(pack_id);
/* buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 512, buffer_length - buffer_pos);
*/ v_con_set_connect_stage(V_CS_PENDING_CLIENT_CALLBACK_TERMINATE);
return;
}
}
VSession verse_send_connect_accept(VNodeID avatar, const char *address, uint8 *host_id)
{
VNetworkAddress a;
#if defined(V_PRINT_SEND_COMMANDS)
printf("send: verse_send_connect_accept(avatar = %u, address = %s, host_id = NULL);\n", avatar, address);
#endif
if(!v_n_set_network_address(&a, address))
return NULL;
if(v_co_switch_connection(a.ip, a.port))
{
if(v_con_get_connect_stage() != V_CS_PENDING_DECISION)
return NULL;
v_con_set_avatar(avatar);
v_con_set_connect_stage(V_CS_CONNECTED);
v_send_hidden_connect_accept();
return v_con_get_network_queue();
}
return NULL;
}
void v_callback_connect_terminate(const char *bye)
{
void (* func_connect_terminate)(void *user_data, char *address, const char *bye);
char address_string[32];
printf("terminate (%s)\n", bye);
func_connect_terminate = v_fs_get_user_func(2);
v_n_get_address_string(v_con_get_network_address(), address_string);
#if defined(V_PRINT_RECEIVE_COMMANDS)
printf("receive: verse_send_connect_terminate(address = %s, bye = %s); callback = %p\n", address_string, bye, func_connect_terminate);
#endif
if(func_connect_terminate != 0)
func_connect_terminate(v_fs_get_user_data(2), address_string, bye);
}
void verse_send_connect_terminate(const char *address, const char *bye)
{
VNetworkAddress a;
#if defined(V_PRINT_RECEIVE_COMMANDS)
printf("send: verse_send_connect_terminate(address = %s, bye = %s);\n", address, bye);
#endif
if(address == NULL)
v_send_hidden_connect_terminate(v_con_get_network_address(), v_noq_get_next_out_packet_id(v_con_get_network_queue()), bye);
else if(!v_n_set_network_address(&a, address))
return;
else if(v_co_switch_connection(a.ip, a.port))
v_send_hidden_connect_terminate(v_con_get_network_address(), v_noq_get_next_out_packet_id(v_con_get_network_queue()), bye);
if(v_con_get_connect_stage() != V_CS_PENDING_DECISION)
verse_session_destroy(v_con_get_network_queue());
}
void verse_send_ping(const char *address, const char *message)
{
VNetworkAddress a;
if(v_n_set_network_address(&a, address))
{
unsigned int buffer_pos = 0;
uint8 buf[1500];
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], 0);/* Packing the Packet id */
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 5);/* Packing the command */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_ping(address = %s text = %s);\n", address, message);
#endif
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], message, 1400);
v_n_send_data(&a, buf, buffer_pos);
}
#if defined V_PRINT_SEND_COMMANDS
else
printf("send: verse_send_ping(address = %s (FAULTY) message = %s);\n", address, message);
#endif
}
unsigned int v_unpack_ping(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_ping)(void *user_data, const char *address, const char *text);
char address[64];
char message[1400];
func_ping = v_fs_get_user_func(5);
v_n_get_address_string(v_con_get_network_address(), address);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], message, 1400, buffer_length - buffer_pos);
#if defined V_PRINT_RECEIVE_COMMANDS
printf("receive: verse_send_ping(address = %s message = %s ); callback = %p\n", address, message, v_fs_get_user_func(5));
#endif
if(func_ping != NULL)
func_ping(v_fs_get_user_data(5), address, message);
return buffer_pos;
}
typedef struct {
uint32 ip;
uint16 port;
char message[1400];
void *next;
} VPingCommand;
static VPingCommand *v_ping_commands = NULL;
boolean v_connect_unpack_ping(const char *buf, size_t buffer_length, uint32 ip, uint16 port)
{
if(buffer_length > 5)
{
unsigned int buffer_pos = 0;
uint8 cmd_id;
uint32 pack_id;
buffer_pos = vnp_raw_unpack_uint32(&buf[buffer_pos], &pack_id);
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &cmd_id);
if(cmd_id == 5)
{
if(NULL != v_fs_get_user_func(5))
{
VPingCommand *pc;
pc = malloc(sizeof *pc);
pc->ip = ip;
pc->port = port;
vnp_raw_unpack_string(&buf[buffer_pos], pc->message,
sizeof pc->message, buffer_length - buffer_pos);
pc->next = v_ping_commands;
v_ping_commands = pc;
}
return TRUE;
}
}
return FALSE;
}
void v_ping_update(void)
{
VPingCommand *cp;
void (* func_ping)(void *user_data, const char *address, const char *text);
VNetworkAddress a;
char address[64];
func_ping = v_fs_get_user_func(5);
while(v_ping_commands != NULL)
{
cp = v_ping_commands->next;
a.ip = v_ping_commands->ip;
a.port = v_ping_commands->port;
v_n_get_address_string(&a, address);
#if defined V_PRINT_RECEIVE_COMMANDS
printf("receive: verse_send_ping(address = %s message = %s ); callback = %p\n", address, v_ping_commands->message, v_fs_get_user_func(5));
#endif
if(func_ping != NULL)
func_ping(v_fs_get_user_data(5), address, v_ping_commands->message);
free(v_ping_commands);
v_ping_commands = cp;
}
}
#endif

@ -1,490 +0,0 @@
/*
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "v_cmd_buf.h"
#include "v_network_in_que.h"
#include "v_network_out_que.h"
#include "v_cmd_gen.h"
#include "v_connection.h"
#include "v_encryption.h"
#include "v_util.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "verse.h"
#define CONNECTION_CHUNK_SIZE 16
#define V_MAX_CONNECT_PACKET_SIZE 1500
#define V_CON_MAX_MICROSECOND_BETWEEN_SENDS 100
#define V_RE_CONNECTON_TIME_OUT 4
#define V_CONNECTON_TIME_OUT 30
typedef struct {
VNetOutQueue *out_queue;
VNetInQueue in_queue;
VNetworkAddress network_address;
boolean connected;
unsigned int avatar;
/* unsigned int packet_id;*/
int32 timedelta_s;
uint32 timedelta_f;
boolean destroy_flag;
void *ordered_storage;
char name[V_ENCRYPTION_LOGIN_KEY_SIZE / 2];
char pass[V_ENCRYPTION_LOGIN_KEY_SIZE / 2];
VConnectStage connect_stage;
unsigned int stage_atempts;
uint8 key_my[V_ENCRYPTION_LOGIN_KEY_FULL_SIZE];
uint8 key_other[V_ENCRYPTION_LOGIN_KEY_FULL_SIZE];
uint8 key_data[V_ENCRYPTION_DATA_KEY_SIZE];
uint8 *expected_key;
} VConnection;
static struct {
VConnection *con;
unsigned int con_count;
unsigned int current_connection;
VNetworkAddress *connect_address;
void *unified_func_storage;
uint16 connect_port;
unsigned int pending_packets;
uint8 host_id[V_ENCRYPTION_LOGIN_KEY_FULL_SIZE];
} VConData;
extern void cmd_buf_init(void);
void v_con_init(void) /* since verse doesnt have an init function this function is runned over an ove ard starts whit a check it it has run before */
{
static boolean v_con_initialized = FALSE;
if(v_con_initialized)
return;
cmd_buf_init();
v_con_initialized = TRUE;
VConData.con = malloc(CONNECTION_CHUNK_SIZE * sizeof *VConData.con);
memset(VConData.con, 0, CONNECTION_CHUNK_SIZE * sizeof *VConData.con); /* Clear the memory. */
VConData.con_count = 0;
VConData.pending_packets = 0;
/* v_e_connect_create_key(&VConData.host_id[V_ENCRYPTION_LOGIN_PRIVATE_START],
&VConData.host_id[V_ENCRYPTION_LOGIN_PUBLIC_START],
&VConData.host_id[V_ENCRYPTION_LOGIN_N_START]);*/ /* default host id if none is set by user */
}
void verse_set_port(uint16 port)
{
v_n_set_port(port);
}
void verse_host_id_create(uint8 *id)
{
v_e_connect_create_key(&id[V_ENCRYPTION_LOGIN_PRIVATE_START],
&id[V_ENCRYPTION_LOGIN_PUBLIC_START], &id[V_ENCRYPTION_LOGIN_N_START]);
}
void verse_host_id_set(uint8 *id)
{
memcpy(VConData.host_id, id, V_ENCRYPTION_LOGIN_KEY_FULL_SIZE);
}
extern void *v_fs_create_func_storage(void);
extern void *v_create_ordered_storage(void);
extern void v_destroy_ordered_storage(void *data);
void *v_con_connect(uint32 ip, uint16 port, VConnectStage stage) /* creates a new connection slot */
{
v_con_init(); /* init connections, if not done yet */
if((VConData.con_count - 1) % CONNECTION_CHUNK_SIZE == 0) /* do we need more slots for connections, then reallocate more space */
VConData.con = realloc(VConData.con, (sizeof *VConData.con) * (VConData.con_count + CONNECTION_CHUNK_SIZE));
VConData.con[VConData.con_count].out_queue = v_noq_create_network_queue(); /* create a out queue fo all out going commands */
v_niq_clear(&VConData.con[VConData.con_count].in_queue); /* clear and init the que of incomming packets.*/
VConData.con[VConData.con_count].connected = FALSE; /* not yet propperly connected and should not accept commands yet */
VConData.con[VConData.con_count].network_address.ip = ip; /* ip address of other side */
VConData.con[VConData.con_count].network_address.port = port; /* port used by other side */
VConData.con[VConData.con_count].avatar = 0; /* no avatar set yet*/
/* VConData.con[VConData.con_count].packet_id = 2;*/
VConData.con[VConData.con_count].destroy_flag = FALSE; /* this is a flag that is set once the connection is about to be destroyed.*/
VConData.con[VConData.con_count].ordered_storage = v_create_ordered_storage();
VConData.con[VConData.con_count].name[0] = 0; /* nouser name set yet */
VConData.con[VConData.con_count].pass[0] = 0; /* no password set yet */
VConData.con[VConData.con_count].connect_stage = stage; /* this is the stage of the connection, it show if the connection is ready, the init state depends if this is a client or host */
VConData.con[VConData.con_count].stage_atempts = 0; /* each stage in the connection prosess is atempted multiple times to avoid failiure if packets get lost*/
VConData.con[VConData.con_count].timedelta_s = 0; /* number of seconds since last incomming packet to the connection*/
VConData.con[VConData.con_count].timedelta_f = 0; /* number of fractions of a second since last incomming packet to the connection*/
VConData.con[VConData.con_count].expected_key = NULL; /* expected hist id if this is a client */
VConData.current_connection = VConData.con_count; /* set the new connection to the current*/
++VConData.con_count; /* add one to the number of connections*/
return VConData.con[VConData.current_connection].out_queue;
}
void verse_session_destroy(VSession session) /* a session can not be destroyed right away, because this function might be called inside a call back from the session it tryes tpo destroy, therfor it only markes it*/
{
unsigned int i;
for(i = 0; i < VConData.con_count && VConData.con[i].out_queue != session; i++);
if(i < VConData.con_count)
{
VConData.con[i].destroy_flag = TRUE;
}
}
void verse_session_set(VSession session) /* find a session and make it the current*/
{
unsigned int i;
for(i = 0; i < VConData.con_count && session != VConData.con[i].out_queue; i++);
if(i < VConData.con_count)
VConData.current_connection = i;
}
VSession verse_session_get(void)
{
if(VConData.current_connection < VConData.con_count)
return VConData.con[VConData.current_connection].out_queue;
return NULL;
}
uint32 v_co_find_connection(uint32 ip, uint16 port) /* if a packet comes form a ip address what connection does it belong to? */
{
unsigned int i;
for(i = 0; i < VConData.con_count; i++)
{
if(ip == VConData.con[i].network_address.ip &&
port == VConData.con[i].network_address.port &&
VConData.con[i].destroy_flag == 0)
{
return i;
}
}
return -1;
}
boolean v_co_switch_connection(uint32 ip, uint16 port) /* switches to the current connection to one ip address if it exists */
{
unsigned int i;
for(i = 0; i < VConData.con_count; i++)
{
if(ip == VConData.con[i].network_address.ip && port == VConData.con[i].network_address.port)
{
VConData.current_connection = i;
return TRUE;
}
}
return FALSE;
}
void v_con_inqueue_timer_update(void)
{
if(VConData.current_connection < VConData.con_count)
{
v_niq_timer_update(&VConData.con[VConData.current_connection].in_queue);
}
}
/*
extern void v_fs_buf_unpack(const uint8 *data, unsigned int length);
extern void v_fs_buf_store_pack(uint8 *data, unsigned int length);
extern boolean v_fs_buf_unpack_stored(void);
*/
extern void v_unpack_connection(const char *buf, unsigned int buffer_length);
extern void verse_send_packet_nak(uint32 packet_id);
extern void v_callback_connect_terminate(const char *bye);
extern boolean v_connect_unpack_ping(const char *buf, size_t buffer_length, uint32 ip, uint16 port);
extern void v_ping_update(void);
void v_fs_unpack_beginning(uint8 *data, unsigned int length);
/* Main function that receives and distributes all incoming packets. */
boolean v_con_network_listen(void)
{
VNetworkAddress address;
uint8 buf[V_MAX_CONNECT_PACKET_SIZE], *store;
int size = 0;
unsigned int connection;
uint32 packet_id;
boolean ret = FALSE;
v_con_init(); /* Init if needed. */
connection = VConData.current_connection; /* Store current connection in a local variable so that we can restore it later. */
size = v_n_receive_data(&address, buf, sizeof buf); /* Ask for incoming data from the network. */
while(size != -1 && size != 0) /* Did we get any data? */
{
VConData.current_connection = v_co_find_connection(address.ip, address.port); /* Is there a connection matching the IP and port? */
vnp_raw_unpack_uint32(buf, &packet_id); /* Unpack the ID of the packet. */
/* printf("got packet ID %u, %d bytes, connection %u\n", packet_id, size, VConData.current_connection);*/
if(VConData.current_connection < VConData.con_count &&
!(VConData.con[VConData.current_connection].connect_stage == V_CS_CONNECTED && packet_id == 0)) /* If this isn't a packet from an existing connection, disregard it. */
{
if(VConData.con[VConData.current_connection].connect_stage == V_CS_CONNECTED) /* Is this connection initialized? */
{
store = v_niq_store(&VConData.con[VConData.current_connection].in_queue, size, packet_id); /* Store the packet. */
if(store != NULL)
{
VConData.pending_packets++; /* We now have one more packet pending unpack. */
v_e_data_decrypt_packet(store, buf, size, VConData.con[VConData.current_connection].key_data); /* Decrypt the packet. */
v_fs_unpack_beginning(store, size);
}
}
else
{
v_unpack_connection(buf, size); /* This is an ongoing connecton-attempt. */
v_niq_timer_update(&VConData.con[VConData.current_connection].in_queue);
}
}
else if(v_connect_unpack_ping(buf, size, address.ip, address.port)) /* Ping handled. */
;
else if(v_fs_func_accept_connections()) /* Do we accept connection-attempts? */
{
if(VConData.current_connection >= VConData.con_count ||
V_RE_CONNECTON_TIME_OUT < v_niq_time_out(&VConData.con[VConData.current_connection].in_queue)) /* Is it a new client, or an old client that we haven't heard form in some time? */
{
if(VConData.current_connection < VConData.con_count)
{
VConData.con[VConData.current_connection].network_address.ip = 0;
VConData.con[VConData.current_connection].destroy_flag = TRUE; /* Destroy old connection if there is one. */
}
v_con_connect(address.ip, address.port, V_CS_IDLE); /* Create a new connection. */
v_unpack_connection(buf, size); /* Unpack the connection-attempt. */
}
}
else
{
fprintf(stderr, __FILE__ ": Unhandled packet--dropping\n");
if(VConData.con_count > 0)
{
fprintf(stderr, __FILE__ ": State: connections=%u, current=%u (stage %u), packet_id=%u\n",
VConData.con_count,
VConData.current_connection,
(VConData.current_connection < VConData.con_count) ? VConData.con[VConData.current_connection].connect_stage : 0,
packet_id);
}
}
size = v_n_receive_data(&address, buf, sizeof buf); /* See if there are more incoming packets. */
ret = TRUE;
}
VConData.current_connection = connection; /* Reset the current connection. */
return ret;
}
extern void v_update_connection_pending(boolean resend);
boolean v_con_callback_update(void)
{
static unsigned int seconds;
boolean output = FALSE;
size_t size;
unsigned int connection, s;
VNetInPacked *p;
v_n_get_current_time(&s, NULL);
connection = VConData.current_connection;
for(VConData.current_connection = 0; VConData.current_connection < VConData.con_count; VConData.current_connection++)
if(VConData.con[VConData.current_connection].connect_stage != V_CS_CONNECTED)
v_update_connection_pending(s != seconds);
seconds = s;
VConData.current_connection = connection;
if(VConData.pending_packets == 0)
return FALSE;
if(VConData.con[VConData.current_connection].connect_stage == V_CS_CONNECTED)
{
while((p = v_niq_get(&VConData.con[VConData.current_connection].in_queue, &size)) != NULL)
{
VConData.pending_packets--;
v_fs_unpack(p->data, size);
v_niq_release(&VConData.con[VConData.current_connection].in_queue, p);
output = TRUE;
}
v_con_network_listen();
}
return output;
}
void verse_callback_update(unsigned int microseconds)
{
unsigned int connection, passed;
v_ping_update(); /* Deliver any pending pings. */
connection = VConData.current_connection;
for(VConData.current_connection = 0; VConData.current_connection < VConData.con_count; VConData.current_connection++)
{
if(VConData.con[VConData.current_connection].connect_stage == V_CS_CONNECTED)
v_noq_send_queue(VConData.con[VConData.current_connection].out_queue, &VConData.con[VConData.current_connection].network_address);
if(VConData.con[VConData.current_connection].destroy_flag == TRUE)
{
v_noq_destroy_network_queue(VConData.con[VConData.current_connection].out_queue);
VConData.pending_packets -= v_niq_free(&VConData.con[VConData.current_connection].in_queue);
v_destroy_ordered_storage(VConData.con[VConData.current_connection].ordered_storage);
if(VConData.con[VConData.current_connection].expected_key != NULL)
free(VConData.con[VConData.current_connection].expected_key);
if(VConData.con_count - 1 != VConData.current_connection)
VConData.con[VConData.current_connection] = VConData.con[VConData.con_count - 1];
VConData.con_count--;
if(connection >= VConData.con_count)
VConData.current_connection = 0;
return;
}
}
VConData.current_connection = connection;
if(VConData.con_count > 0)
{
/* printf("checking timeout of stage %d connection %u\n",
VConData.con[VConData.current_connection].connect_stage, VConData.current_connection);
*/ if(V_CONNECTON_TIME_OUT < v_niq_time_out(&VConData.con[VConData.current_connection].in_queue))
{
if(VConData.con[VConData.current_connection].connect_stage != V_CS_CONNECTED)
{
VConData.con[VConData.current_connection].destroy_flag = TRUE;
}
else
v_callback_connect_terminate("connection timed out");
}
}
v_con_network_listen();
if(VConData.con_count > 0)
if(v_con_callback_update())
return;
for(passed = 0; passed < microseconds && VConData.pending_packets == 0;)
{
boolean update;
if(microseconds - passed > V_CON_MAX_MICROSECOND_BETWEEN_SENDS) /* Still a long way to go? */
passed += v_n_wait_for_incoming(V_CON_MAX_MICROSECOND_BETWEEN_SENDS);
else
passed += v_n_wait_for_incoming(microseconds - passed);
do
{
update = v_con_network_listen();
connection = VConData.current_connection;
for(VConData.current_connection = 0; VConData.current_connection < VConData.con_count; VConData.current_connection++)
{
if(VConData.con[VConData.current_connection].connect_stage == V_CS_CONNECTED)
{
if(v_noq_send_queue(VConData.con[VConData.current_connection].out_queue, &VConData.con[VConData.current_connection].network_address))
update = TRUE;
}
}
VConData.current_connection = connection;
} while(update);
}
if(VConData.con_count > 0)
v_con_callback_update();
}
void v_con_set_name_pass(const char *name, const char *pass)
{
v_strlcpy(VConData.con[VConData.current_connection].name, name, sizeof VConData.con[VConData.current_connection].name);
v_strlcpy(VConData.con[VConData.current_connection].pass, pass, sizeof VConData.con[VConData.current_connection].pass);
}
const char * v_con_get_name(void)
{
return VConData.con[VConData.current_connection].name;
}
const char * v_con_get_pass(void)
{
return VConData.con[VConData.current_connection].pass;
}
void v_con_set_connect_stage(VConnectStage stage)
{
VConData.con[VConData.current_connection].connect_stage = stage;
VConData.con[VConData.current_connection].stage_atempts = 0;
}
VConnectStage v_con_get_connect_stage(void)
{
return VConData.con[VConData.current_connection].connect_stage;
}
uint8 *v_con_get_my_key(void)
{
return VConData.con[VConData.current_connection].key_my;
}
uint8 *v_con_get_other_key(void)
{
return VConData.con[VConData.current_connection].key_other;
}
uint8 **v_con_get_expected_key(void)
{
return &VConData.con[VConData.current_connection].expected_key;
}
uint8 * v_con_get_host_id(void)
{
return VConData.host_id;
}
void v_con_set_data_key(const uint8 *key)
{
memcpy(VConData.con[VConData.current_connection].key_data, key, V_ENCRYPTION_DATA_KEY_SIZE);
}
const uint8 * v_con_get_data_key(void)
{
return VConData.con[VConData.current_connection].key_data;
}
void * v_con_get_network_queue(void)
{
return VConData.con[VConData.current_connection].out_queue;
}
VNetworkAddress * v_con_get_network_address(void)
{
return &VConData.con[VConData.current_connection].network_address;
}
void * v_con_get_ordered_storage(void)
{
return VConData.con[VConData.current_connection].ordered_storage;
}
void v_con_set_avatar(uint32 avatar)
{
VConData.con[VConData.current_connection].avatar = avatar;
}
uint32 verse_session_get_avatar(void)
{
return VConData.con[VConData.current_connection].avatar;
}
void verse_session_get_time(uint32 *seconds, uint32 *fractions)
{
uint32 s, f;
v_n_get_current_time(&s, &f);
if((uint32)~0 - f < VConData.con[VConData.current_connection].timedelta_f)
s++;
if(seconds != NULL)
{
if(VConData.con[VConData.current_connection].timedelta_s < 0)
*seconds = s - (uint32)(-VConData.con[VConData.current_connection].timedelta_s);
else
*seconds = s + VConData.con[VConData.current_connection].timedelta_s;
}
if(fractions != NULL)
*fractions = f + VConData.con[VConData.current_connection].timedelta_f;
}
void v_con_set_time(uint32 seconds, uint32 fractions)
{
uint32 s, f;
v_n_get_current_time(&s, &f);
if(f < fractions)
s--;
if (s < seconds)
VConData.con[VConData.current_connection].timedelta_s = -(int)(seconds - s);
else
VConData.con[VConData.current_connection].timedelta_s = (int)(s - seconds);
VConData.con[VConData.current_connection].timedelta_f = f - fractions;
}
#endif

@ -1,73 +0,0 @@
/*
**
*/
#include "v_network.h"
typedef struct{
char name[16];
char pass[16];
uint8 key;
VNodeID avatar;
}VSConnectionID;
typedef enum{
V_CS_IDLE = 0, /* Host connection waiting for connection */
V_CS_CONTACT = 1, /* client tryes to contact host */
V_CS_CONTACTED = 2, /* Host replyes whit challange */
V_CS_PENDING_ACCEPT = 3, /* Client sends login */
V_CS_PENDING_HOST_CALLBACK = 4, /* Host got login waits for accept connect callback */
V_CS_PENDING_CLIENT_CALLBACK_ACCEPT = 5, /* Host got login waits for accept connect callback */
V_CS_PENDING_CLIENT_CALLBACK_TERMINATE = 6, /* Host got login waits for connect terminate callback */
V_CS_PENDING_DECISION = 7, /* Host got has executed Callback waits for accept command */
V_CS_CONNECTED = 8 /* Connection establiched */
}VConnectStage;
/* Connection related functions (v_connection.c) */
extern boolean v_con_network_listen(void);
extern void v_con_set_name_pass(const char *name, const char *pass);
extern const char * v_con_get_name(void);
extern const char * v_con_get_pass(void);
extern void v_con_set_avatar(uint32 avatar);
extern void v_con_set_time(uint32 seconds, uint32 fractions);
extern void v_con_set_connect_stage(VConnectStage stage);
extern VConnectStage v_con_get_connect_stage(void);
extern uint8 *v_con_get_my_key(void);
extern uint8 *v_con_get_other_key(void);
extern uint8 *v_con_get_host_id(void);
extern uint8 **v_con_get_expected_key(void);
extern void v_con_set_data_key(const uint8 *key);
extern const uint8 * v_con_get_data_key(void);
extern void * v_con_get_network_queue(void);
extern VNetworkAddress *v_con_get_network_address(void);
extern void * v_con_get_network_address_id(unsigned int id);
extern unsigned int * v_con_get_network_expected_packet(void);
extern void * v_con_get_ordered_storage(void);
extern void * v_con_get_func_storage(void);
extern void * v_con_connect(uint32 ip, uint16 port, VConnectStage stage);
extern unsigned int v_con_get_network_address_count(void);
extern boolean v_co_switch_connection(uint32 ip, uint16 port);
extern void v_con_inqueue_timer_update(void);
/* Func storage related functions (v_func_storage.c)*/
extern void v_fs_unpack(uint8 *data, unsigned int length);
extern boolean v_fs_func_accept_connections(void);
extern void v_fs_add_func(unsigned int cmd_id, unsigned int (*unpack_func)(const char *buf, size_t buffer_length), void *pack_func, void *alias_func);
extern void * v_fs_get_alias_user_func(unsigned int cmd_id);
extern void * v_fs_get_alias_user_data(unsigned int cmd_id);
extern void * v_fs_get_user_func(unsigned int cmd_id);
extern void * v_fs_get_user_data(unsigned int cmd_id);

@ -1,255 +0,0 @@
/*
* Verse encryption routines. Implements RSA encryption/decryption plus fast XORx.
*/
#if !defined(V_GENERATE_FUNC_MODE)
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "verse.h"
#include "v_pack.h"
#include "v_bignum.h"
#include "v_encryption.h"
#define BITS V_ENCRYPTION_LOGIN_KEY_BITS /* Save some typing. */
extern void v_prime_set_random(VBigDig *x);
extern void v_prime_set_table(VBigDig *x, int i);
const uint8 * v_e_data_create_key(void) /* possibly the worst key gen ever */
{
static unsigned int counter = 0;
static uint8 buffer[V_ENCRYPTION_DATA_KEY_SIZE];
unsigned int i, temp;
for(i = 0; i < V_ENCRYPTION_DATA_KEY_SIZE; i++)
{
counter++;
temp = (counter << 13) ^ counter;
temp = (temp * (temp * temp * 15731 + 789221) + 1376312589) & 0x7fffffff;
buffer[i] = temp;
}
/* FIXME: This really isn't very pretty. */
buffer[0] &= 0x3f; /* Make sure top word is... Low. For RSA compatibility. */
/* memset(buffer, 0, sizeof buffer);
fprintf(stderr, "**WARNING: XOR data encryption disabled\n");
*/
return buffer;
}
void v_e_data_encrypt_command(uint8 *packet, size_t packet_size, const uint8 *command, size_t command_size, const uint8 *key)
{
uint32 pos, i;
vnp_raw_unpack_uint32(packet, &pos);
/* printf("encrypting packet %u", pos);*/
pos = key[pos % V_ENCRYPTION_DATA_KEY_SIZE] + packet_size;
/* printf(" -> pos=%u (size %u)", pos, packet_size);
printf(", key begins: [");
for(i = 0; i < 16; i++)
printf(" %02X", key[(pos + i) % V_ENCRYPTION_DATA_KEY_SIZE]);
printf(" ]\n");
*/
for(i = 0; i < command_size; i++)
packet[packet_size + i] = command[i] ^ key[(i + pos) % V_ENCRYPTION_DATA_KEY_SIZE];
}
void v_e_data_decrypt_packet(uint8 *to, const uint8 *from, size_t size, const uint8 *key)
{
uint32 pos, i;
vnp_raw_unpack_uint32(from, &pos);
/* printf("decrypting packet %u", pos);*/
pos = key[pos % V_ENCRYPTION_DATA_KEY_SIZE];
/* printf(" -> pos=%u", pos);
printf(", key begins: [");
for(i = 0; i < 16; i++)
printf(" %02X", key[(i + pos) % V_ENCRYPTION_DATA_KEY_SIZE]);
printf(" ]\n");
*/ for(i = 0; i < 4; i++)
to[i] = from[i];
for(i = 4; i < size; i++)
to[i] = from[i] ^ key[(i + pos) % V_ENCRYPTION_DATA_KEY_SIZE];
}
#endif
/* From Knuth. Computes multiplicative inverse of u, modulo v. */
void v_e_math_inv(VBigDig *inv, const VBigDig *u, const VBigDig *v)
{
VBigDig VBIGNUM(u1, 2*BITS), VBIGNUM(u3, 2*BITS), VBIGNUM(v1, 2*BITS), VBIGNUM(v3, 2 *BITS),
VBIGNUM(t1, 2*BITS), VBIGNUM(t3, 2*BITS), VBIGNUM(q, 2*BITS), VBIGNUM(w, 2*BITS);
int iter = 1;
v_bignum_set_one(u1);
v_bignum_set_bignum(u3, u);
v_bignum_set_zero(v1);
v_bignum_set_bignum(v3, v);
while(!v_bignum_eq_zero(v3))
{
v_bignum_set_bignum(q, u3);
v_bignum_div(q, v3, t3);
v_bignum_set_bignum(w, q);
v_bignum_mul(w, v1);
v_bignum_set_bignum(t1, u1);
v_bignum_add(t1, w);
v_bignum_set_bignum(u1, v1);
v_bignum_set_bignum(v1, t1);
v_bignum_set_bignum(u3, v3);
v_bignum_set_bignum(v3, t3);
iter = -iter;
}
if(iter < 0)
{
v_bignum_set_bignum(inv, v);
v_bignum_sub(inv, u1);
}
else
v_bignum_set_bignum(inv, u1);
}
void v_e_connect_create_key(uint8 *private_key, uint8 *public_key, uint8 *n)
{
VBigDig VBIGNUM(p, BITS / 2), VBIGNUM(q, BITS / 2), VBIGNUM(qmo, BITS / 2), VBIGNUM(phi, BITS),
VBIGNUM(pub, BITS), VBIGNUM(priv, BITS), VBIGNUM(mod, BITS);
#if !defined _WIN32
/* FIXME: This is a security backdoor. Intent is simply to save time during testing. */
if(getenv("VERSE_NORSA") != NULL)
{
printf("VERSE: Found the NORSA envvar, using constant keys\n");
v_prime_set_table(p, 0);
v_prime_set_table(q, 1);
goto compute_phi;
}
#endif
/* printf("find prime p\n");*/
v_prime_set_random(p);
/* printf("find prime q\n");*/
v_prime_set_random(q);
compute_phi:
/* printf("done, computing key\n");*/
/* printf("p=");
v_bignum_print_hex_lf(p);
printf("q=");
v_bignum_print_hex_lf(q);
*/ v_bignum_set_bignum(phi, p);
v_bignum_sub_digit(phi, 1);
v_bignum_set_bignum(qmo, q);
v_bignum_sub_digit(qmo, 1);
v_bignum_mul(phi, qmo);
/* printf("phi=");
v_bignum_print_hex_lf(phi);
*/ v_bignum_set_string_hex(pub, "0x10001");
v_e_math_inv(priv, pub, phi);
/* printf(" pub=");
v_bignum_print_hex_lf(pub);
printf("priv=");
v_bignum_print_hex_lf(priv);
*/
v_bignum_set_bignum(mod, p);
v_bignum_mul(mod, q);
/* printf(" mod=");
v_bignum_print_hex_lf(mod);
printf("key-creation finished\n");
*/ /* Write out the keys. */
v_bignum_raw_export(pub, public_key);
v_bignum_raw_export(priv, private_key);
v_bignum_raw_export(mod, n);
}
void v_e_connect_encrypt(uint8 *output, const uint8 *data, const uint8 *key, const uint8 *key_n)
{
VBigDig VBIGNUM(packet, BITS), VBIGNUM(expo, BITS), VBIGNUM(mod, BITS);
v_bignum_raw_import(packet, data);
v_bignum_raw_import(expo, key);
v_bignum_raw_import(mod, key_n);
/* Verify that data is less than the modulo, this is a prerequisite for encryption. */
if(!v_bignum_gte(mod, packet))
{
printf("*** WARNING. Data is not less than modulo, as it should be--encryption will break!\n");
printf(" RSA modulo: ");
v_bignum_print_hex_lf(mod);
printf(" RSA data: ");
v_bignum_print_hex_lf(packet);
}
/* printf("RSA key: ");
v_bignum_print_hex_lf(expo);
printf("RSA mod: ");
v_bignum_print_hex_lf(mod);
printf("RSA in: ");
v_bignum_print_hex_lf(packet);
printf("bits in packet: %d, ", v_bignum_bit_msb(packet) + 1);
printf("bits in modulo: %d\n", v_bignum_bit_msb(mod) + 1);
*/ v_bignum_pow_mod(packet, expo, mod); /* Blam. */
/* printf("RSA out: ");
v_bignum_print_hex_lf(packet);
*/ v_bignum_raw_export(packet, output);
}
#if defined CRYPTALONE
void v_encrypt_test(void)
{
uint8 k_priv[BITS / 8], k_pub[BITS / 8], k_n[BITS / 8], cipher[BITS / 8], plain[BITS / 8], decode[BITS / 8], i;
printf("testing RSA-crypto\n");
v_e_connect_create_key(k_pub, k_priv, k_n);
/* exit(0);*/
printf("key pair generated, encrypting something\n");
memset(plain, 0, sizeof plain);
strcpy(plain, "This is some text to encrypt, to give it something to chew on.");
printf("plain: %02X (%u)\n", plain[0], strlen(plain));
v_e_connect_encrypt(cipher, plain, k_pub, k_n);
printf("plain: %02X, cipher: %02X\n", plain[0], cipher[0]);
v_e_connect_encrypt(decode, cipher, k_priv, k_n);
printf("decoded: %02X: '", decode[0]);
for(i = 0; decode[i] != 0; i++)
putchar(decode[i]);
printf("'\n");
/* printf("\npublic key: ");
v_bignum_print_hex_lf(k_public);
printf("private key: ");
v_bignum_print_hex_lf(k_private);
v_bignum_set_string(msg, "123");
gettimeofday(&t1, NULL);
v_bignum_pow_mod(msg, k_private, k_n);
gettimeofday(&t2, NULL);
printf("encrypted: ");
v_bignum_print_hex_lf(msg);
printf("encrypted %u bits in %g s\n", BITS, t2.tv_sec - t1.tv_sec + 1.0E-6 * (t2.tv_usec - t1.tv_usec));
gettimeofday(&t1, NULL);
v_bignum_pow_mod(msg, k_public, k_n);
gettimeofday(&t2, NULL);
printf("decrypted: ");
v_bignum_print_hex_lf(msg);
printf("decrypted %u bits in %g s\n", BITS, t2.tv_sec - t1.tv_sec + 1.0E-6 * (t2.tv_usec - t1.tv_usec));
exit(0);
*//* v_e_encrypt(cipher, plain, &k_private, &k_n);
printf("encrypted data: ");
for(i = 0; i < sizeof cipher; i++)
printf("%c", isalnum(cipher[i]) ? cipher[i] : '?');
printf("\n\n");
printf("decrypting\n");
v_e_encrypt(decode, cipher, &k_public, &k_n);
printf("decrypted data: ");
for(i = 0; i < sizeof cipher; i++)
printf("%c", isalnum(decode[i]) ? decode[i] : '?');
printf("\n\n");
*/
}
int main(void)
{
v_encrypt_test();
return 0;
}
#endif

@ -1,32 +0,0 @@
/*
* Verse encryption routines. There are two distinct flavors of encryption
* in use: one "heavy" for login/connection establishment security, and
* a far lighter symmetrical one that is applied to each data packet after
* the key has been exchanged during connection.
*/
#include "verse.h"
/* Internal key size definitions. *MUST* be kept in sync with V_HOST_ID_SIZE in verse_header.h! */
#define V_ENCRYPTION_LOGIN_KEY_BITS 512
#define V_ENCRYPTION_LOGIN_KEY_SIZE (V_ENCRYPTION_LOGIN_KEY_BITS / 8)
#define V_ENCRYPTION_LOGIN_KEY_FULL_SIZE (3 * V_ENCRYPTION_LOGIN_KEY_SIZE)
#define V_ENCRYPTION_LOGIN_KEY_HALF_SIZE (2 * V_ENCRYPTION_LOGIN_KEY_SIZE)
#define V_ENCRYPTION_LOGIN_PUBLIC_START (0 * V_ENCRYPTION_LOGIN_KEY_SIZE)
#define V_ENCRYPTION_LOGIN_PRIVATE_START (1 * V_ENCRYPTION_LOGIN_KEY_SIZE)
#define V_ENCRYPTION_LOGIN_N_START (2 * V_ENCRYPTION_LOGIN_KEY_SIZE)
#define V_ENCRYPTION_DATA_KEY_SIZE (V_ENCRYPTION_LOGIN_KEY_BITS / 8)
/* Connection encryption. Heavy, and symmetrical, so encrypt() does both encryption
* and decryption given the proper key. Current algorithm used is RSA.
*/
extern void v_e_connect_create_key(uint8 *private_key, uint8 *public_key, uint8 *n);
extern void v_e_connect_encrypt(uint8 *output, const uint8 *data, const uint8 *key, const uint8 *key_n);
/* Actual data traffic encryption. Also symmetrical, with a single key. Uses XOR. */
extern const uint8 * v_e_data_create_key(void);
extern void v_e_data_encrypt_command(uint8 *packet, size_t packet_length,
const uint8 *command, size_t command_length, const uint8 *key);
extern void v_e_data_decrypt_packet(uint8 *to, const uint8 *from, size_t size, const uint8 *key);

@ -1,194 +0,0 @@
/*
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "verse_header.h"
#include "v_pack.h"
#include "v_cmd_gen.h"
#include "v_connection.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "verse.h"
#include "v_cmd_buf.h"
#include "v_network_out_que.h"
#define V_FS_MAX_CMDS 256
extern void init_pack_and_unpack(void);
static struct {
unsigned int (*unpack_func[V_FS_MAX_CMDS])(const char *data, size_t length);
void *pack_func[V_FS_MAX_CMDS];
void *user_func[V_FS_MAX_CMDS];
void *user_data[V_FS_MAX_CMDS];
void *alias_pack_func[V_FS_MAX_CMDS];
void *alias_user_func[V_FS_MAX_CMDS];
void *alias_user_data[V_FS_MAX_CMDS];
boolean call;
} VCmdData;
static boolean v_fs_initialized = FALSE;
extern void verse_send_packet_ack(uint32 packet_id);
extern void callback_send_packet_ack(void *user, uint32 packet_id);
extern void verse_send_packet_nak(uint32 packet_id);
extern void callback_send_packet_nak(void *user, uint32 packet_id);
void v_fs_init(void)
{
unsigned int i;
if(v_fs_initialized)
return;
for(i = 0; i < V_FS_MAX_CMDS; i++)
{
VCmdData.unpack_func[i] = NULL;
VCmdData.pack_func[i] = NULL;
VCmdData.user_func[i] = NULL;
VCmdData.user_data[i] = NULL;
VCmdData.alias_pack_func[i] = NULL;
VCmdData.alias_user_func[i] = NULL;
VCmdData.alias_user_data[i] = NULL;
}
#if !defined(V_GENERATE_FUNC_MODE)
init_pack_and_unpack();
#endif
for(i = 0; i < V_FS_MAX_CMDS && VCmdData.pack_func[i] != verse_send_packet_ack; i++);
VCmdData.user_func[i] = callback_send_packet_ack;
for(i = 0; i < V_FS_MAX_CMDS && VCmdData.pack_func[i] != verse_send_packet_nak; i++);
VCmdData.user_func[i] = callback_send_packet_nak;
v_fs_initialized = TRUE;
}
void v_fs_add_func(unsigned int cmd_id, unsigned int (*unpack_func)(const char *data, size_t length), void *pack_func, void *alias_func)
{
VCmdData.unpack_func[cmd_id] = unpack_func;
VCmdData.pack_func[cmd_id] = pack_func;
VCmdData.alias_pack_func[cmd_id] = alias_func;
}
void *v_fs_get_user_func(unsigned int cmd_id)
{
/* if(VCmdData.call)*/
return VCmdData.user_func[cmd_id];
return NULL;
}
void *v_fs_get_user_data(unsigned int cmd_id)
{
return VCmdData.user_data[cmd_id];
}
void *v_fs_get_alias_user_func(unsigned int cmd_id)
{
/* if(VCmdData.call)*/
return VCmdData.alias_user_func[cmd_id];
return NULL;
}
void *v_fs_get_alias_user_data(unsigned int cmd_id)
{
return VCmdData.alias_user_data[cmd_id];
}
void verse_callback_set(void *command, void *callback, void *user)
{
unsigned int i;
if(!v_fs_initialized)
v_fs_init();
for(i = 0; i < V_FS_MAX_CMDS; i++)
{
if(VCmdData.pack_func[i] == command)
{
VCmdData.user_data[i] = user;
VCmdData.user_func[i] = callback;
return;
}
if(VCmdData.alias_pack_func[i] == command)
{
VCmdData.alias_user_data[i] = user;
VCmdData.alias_user_func[i] = callback;
return;
}
}
}
/* Do we accept incoming connections, i.e. are we a host implementation? */
boolean v_fs_func_accept_connections(void)
{
return VCmdData.user_func[0] != NULL;
}
/* Inspect beginning of packet, looking for ACK or NAK commands. */
void v_fs_unpack_beginning(const uint8 *data, unsigned int length)
{
uint32 id, i = 4;
uint8 cmd_id;
i += vnp_raw_unpack_uint8(&data[i], &cmd_id);
while(i < length && (cmd_id == 7 || cmd_id == 8))
{
i += vnp_raw_unpack_uint32(&data[i], &id);
if(cmd_id == 7)
callback_send_packet_ack(NULL, id);
else
callback_send_packet_nak(NULL, id);
i += vnp_raw_unpack_uint8(&data[i], &cmd_id);
}
}
void v_fs_unpack(uint8 *data, unsigned int length)
{
uint32 i, output, pack_id;
uint8 cmd_id, last = 255;
i = vnp_raw_unpack_uint32(data, &pack_id); /* each packet starts with a 32 bit id */
vnp_raw_unpack_uint8(&data[i], &cmd_id);
while(i < length && (cmd_id == 7 || cmd_id == 8))
{
i += 5;
vnp_raw_unpack_uint8(&data[i], &cmd_id);
}
while(i < length)
{
i += vnp_raw_unpack_uint8(&data[i], &cmd_id);
if(VCmdData.unpack_func[cmd_id] != NULL)
{
VCmdData.call = TRUE;
output = VCmdData.unpack_func[cmd_id](&data[i], length - i);
if(output == (unsigned int) -1) /* Can this happen? Should be size_t or int, depending. */
{
printf("** Aborting decode, command %u unpacker returned failure\n", cmd_id);
/* verse_send_packet_nak(pack_id);*/
return;
}
last = cmd_id;
i += output;
}
else /* If unknown command byte was found, complain loudly and stop parsing packet. */
{
size_t j;
printf("\n** Unknown command ID %u (0x%02X) encountered--aborting packet decode len=%u pos=%u last=%u\n", cmd_id, cmd_id, length, i, last);
printf(" decoded %u bytes: ", --i);
for(j = 0; j < i; j++)
printf("%02X ", data[j]);
printf("\n (packet id=%u)", pack_id);
printf(" remaining %u bytes: ", length - i);
for(j = i; j < length; j++)
printf("%02X ", data[j]);
printf("\n");
/* *(char *) 0 = 0;*/
break;
}
}
/* if(expected != NULL)
verse_send_packet_ack(pack_id);*/
}
extern unsigned int v_unpack_connection(const char *data, size_t length);
#endif

@ -1,521 +0,0 @@
/*
** This is automatically generated source code -- do not edit.
** Changes are affected either by editing the corresponding protocol
** definition file (v_cmd_def_X.c where X=node type), or by editing
** the code generator itself, in v_cmd_gen.c.
*/
#include <stdlib.h>
#include <stdio.h>
#include "v_cmd_gen.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "verse.h"
#include "v_cmd_buf.h"
#include "v_network_out_que.h"
#include "v_network.h"
#include "v_connection.h"
#include "v_util.h"
void verse_send_a_buffer_create(VNodeID node_id, VBufferID buffer_id, const char *name, VNABlockType type, real64 frequency)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 160); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_a_buffer_create(node_id = %u buffer_id = %u name = %s type = %u frequency = %f );\n", node_id, buffer_id, name, type, frequency);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], frequency);
if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_a_buffer_destroy(VNodeID node_id, VBufferID buffer_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 160); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_a_buffer_destroy(node_id = %u buffer_id = %u );\n", node_id, buffer_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], V_REAL64_MAX);
if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_a_buffer_create(const char *buf, size_t buffer_length)
{
uint8 enum_temp;
unsigned int buffer_pos = 0;
void (* func_a_buffer_create)(void *user_data, VNodeID node_id, VBufferID buffer_id, const char *name, VNABlockType type, real64 frequency);
VNodeID node_id;
VBufferID buffer_id;
char name[16];
VNABlockType type;
real64 frequency;
func_a_buffer_create = v_fs_get_user_func(160);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &buffer_id);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos);
if(buffer_length < 9 + buffer_pos)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
type = (VNABlockType)enum_temp;
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frequency);
#if defined V_PRINT_RECEIVE_COMMANDS
if(name[0] == 0)
printf("receive: verse_send_a_buffer_destroy(node_id = %u buffer_id = %u ); callback = %p\n", node_id, buffer_id, v_fs_get_alias_user_func(160));
else
printf("receive: verse_send_a_buffer_create(node_id = %u buffer_id = %u name = %s type = %u frequency = %f ); callback = %p\n", node_id, buffer_id, name, type, frequency, v_fs_get_user_func(160));
#endif
if(name[0] == 0)
{
void (* alias_a_buffer_destroy)(void *user_data, VNodeID node_id, VBufferID buffer_id);
alias_a_buffer_destroy = v_fs_get_alias_user_func(160);
if(alias_a_buffer_destroy != NULL)
alias_a_buffer_destroy(v_fs_get_alias_user_data(160), node_id, buffer_id);
return buffer_pos;
}
if(func_a_buffer_create != NULL)
func_a_buffer_create(v_fs_get_user_data(160), node_id, buffer_id, name, (VNABlockType) type, frequency);
return buffer_pos;
}
void verse_send_a_buffer_subscribe(VNodeID node_id, VBufferID layer_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 161); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_a_buffer_subscribe(node_id = %u layer_id = %u );\n", node_id, layer_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_a_buffer_unsubscribe(VNodeID node_id, VBufferID layer_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 161); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_a_buffer_unsubscribe(node_id = %u layer_id = %u );\n", node_id, layer_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_a_buffer_subscribe(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_a_buffer_subscribe)(void *user_data, VNodeID node_id, VBufferID layer_id);
VNodeID node_id;
VBufferID layer_id;
uint8 alias_bool;
func_a_buffer_subscribe = v_fs_get_user_func(161);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id);
if(buffer_length < buffer_pos + 1)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
#if defined V_PRINT_RECEIVE_COMMANDS
if(!alias_bool)
printf("receive: verse_send_a_buffer_unsubscribe(node_id = %u layer_id = %u ); callback = %p\n", node_id, layer_id, v_fs_get_alias_user_func(161));
else
printf("receive: verse_send_a_buffer_subscribe(node_id = %u layer_id = %u ); callback = %p\n", node_id, layer_id, v_fs_get_user_func(161));
#endif
if(!alias_bool)
{
void (* alias_a_buffer_unsubscribe)(void *user_data, VNodeID node_id, VBufferID layer_id);
alias_a_buffer_unsubscribe = v_fs_get_alias_user_func(161);
if(alias_a_buffer_unsubscribe != NULL)
alias_a_buffer_unsubscribe(v_fs_get_alias_user_data(161), node_id, layer_id);
return buffer_pos;
}
if(func_a_buffer_subscribe != NULL)
func_a_buffer_subscribe(v_fs_get_user_data(161), node_id, layer_id);
return buffer_pos;
}
void verse_send_a_block_set(VNodeID node_id, VLayerID buffer_id, uint32 block_index, VNABlockType type, const VNABlock *samples)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 162); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_a_block_set(node_id = %u buffer_id = %u block_index = %u type = %u samples = %p );\n", node_id, buffer_id, block_index, type, samples);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], block_index);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
buffer_pos += vnp_pack_audio_block(&buf[buffer_pos], type, samples);
if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u || block_index == (uint32) ~0u)
v_cmd_buf_set_unique_address_size(head, 11);
else
v_cmd_buf_set_address_size(head, 11);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_a_block_clear(VNodeID node_id, VLayerID buffer_id, uint32 block_index)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 162); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_a_block_clear(node_id = %u buffer_id = %u block_index = %u );\n", node_id, buffer_id, block_index);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], block_index);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u || block_index == (uint32) ~0u)
v_cmd_buf_set_unique_address_size(head, 11);
else
v_cmd_buf_set_address_size(head, 11);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_a_block_set(const char *buf, size_t buffer_length)
{
uint8 enum_temp;
unsigned int buffer_pos = 0;
void (* func_a_block_set)(void *user_data, VNodeID node_id, VLayerID buffer_id, uint32 block_index, VNABlockType type, const VNABlock *samples);
VNodeID node_id;
VLayerID buffer_id;
uint32 block_index;
VNABlockType type;
const VNABlock *samples;
func_a_block_set = v_fs_get_user_func(162);
if(buffer_length < 10)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &buffer_id);
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &block_index);
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
type = (VNABlockType)enum_temp;
#if defined V_PRINT_RECEIVE_COMMANDS
if(type > VN_A_BLOCK_REAL64)
printf("receive: verse_send_a_block_clear(node_id = %u buffer_id = %u block_index = %u ); callback = %p\n", node_id, buffer_id, block_index, v_fs_get_alias_user_func(162));
else
printf("receive: verse_send_a_block_set(node_id = %u buffer_id = %u block_index = %u type = %u ); callback = %p\n", node_id, buffer_id, block_index, type, v_fs_get_user_func(162));
#endif
if(type <= VN_A_BLOCK_REAL64)
{
VNABlock block;
buffer_pos += vnp_unpack_audio_block(&buf[buffer_pos], type, &block);
if(func_a_block_set != NULL)
func_a_block_set(v_fs_get_user_data(162), node_id, buffer_id, block_index, (VNABlockType) type, &block);
return buffer_pos;
}
if(type > VN_A_BLOCK_REAL64)
{
void (* alias_a_block_clear)(void *user_data, VNodeID node_id, VLayerID buffer_id, uint32 block_index);
alias_a_block_clear = v_fs_get_alias_user_func(162);
if(alias_a_block_clear != NULL)
alias_a_block_clear(v_fs_get_alias_user_data(162), node_id, buffer_id, block_index);
return buffer_pos;
}
if(func_a_block_set != NULL)
func_a_block_set(v_fs_get_user_data(162), node_id, buffer_id, block_index, (VNABlockType) type, samples);
return buffer_pos;
}
void verse_send_a_stream_create(VNodeID node_id, VLayerID stream_id, const char *name)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 163); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_a_stream_create(node_id = %u stream_id = %u name = %s );\n", node_id, stream_id, name);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16);
if(node_id == (uint32) ~0u || stream_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_a_stream_destroy(VNodeID node_id, VLayerID stream_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 163); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_a_stream_destroy(node_id = %u stream_id = %u );\n", node_id, stream_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
if(node_id == (uint32) ~0u || stream_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_a_stream_create(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_a_stream_create)(void *user_data, VNodeID node_id, VLayerID stream_id, const char *name);
VNodeID node_id;
VLayerID stream_id;
char name[16];
func_a_stream_create = v_fs_get_user_func(163);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &stream_id);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos);
#if defined V_PRINT_RECEIVE_COMMANDS
if(name[0] == 0)
printf("receive: verse_send_a_stream_destroy(node_id = %u stream_id = %u ); callback = %p\n", node_id, stream_id, v_fs_get_alias_user_func(163));
else
printf("receive: verse_send_a_stream_create(node_id = %u stream_id = %u name = %s ); callback = %p\n", node_id, stream_id, name, v_fs_get_user_func(163));
#endif
if(name[0] == 0)
{
void (* alias_a_stream_destroy)(void *user_data, VNodeID node_id, VLayerID stream_id);
alias_a_stream_destroy = v_fs_get_alias_user_func(163);
if(alias_a_stream_destroy != NULL)
alias_a_stream_destroy(v_fs_get_alias_user_data(163), node_id, stream_id);
return buffer_pos;
}
if(func_a_stream_create != NULL)
func_a_stream_create(v_fs_get_user_data(163), node_id, stream_id, name);
return buffer_pos;
}
void verse_send_a_stream_subscribe(VNodeID node_id, VLayerID stream_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 164); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_a_stream_subscribe(node_id = %u stream_id = %u );\n", node_id, stream_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
if(node_id == (uint32) ~0u || stream_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_a_stream_unsubscribe(VNodeID node_id, VLayerID stream_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 164); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_a_stream_unsubscribe(node_id = %u stream_id = %u );\n", node_id, stream_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
if(node_id == (uint32) ~0u || stream_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_a_stream_subscribe(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_a_stream_subscribe)(void *user_data, VNodeID node_id, VLayerID stream_id);
VNodeID node_id;
VLayerID stream_id;
uint8 alias_bool;
func_a_stream_subscribe = v_fs_get_user_func(164);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &stream_id);
if(buffer_length < buffer_pos + 1)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
#if defined V_PRINT_RECEIVE_COMMANDS
if(!alias_bool)
printf("receive: verse_send_a_stream_unsubscribe(node_id = %u stream_id = %u ); callback = %p\n", node_id, stream_id, v_fs_get_alias_user_func(164));
else
printf("receive: verse_send_a_stream_subscribe(node_id = %u stream_id = %u ); callback = %p\n", node_id, stream_id, v_fs_get_user_func(164));
#endif
if(!alias_bool)
{
void (* alias_a_stream_unsubscribe)(void *user_data, VNodeID node_id, VLayerID stream_id);
alias_a_stream_unsubscribe = v_fs_get_alias_user_func(164);
if(alias_a_stream_unsubscribe != NULL)
alias_a_stream_unsubscribe(v_fs_get_alias_user_data(164), node_id, stream_id);
return buffer_pos;
}
if(func_a_stream_subscribe != NULL)
func_a_stream_subscribe(v_fs_get_user_data(164), node_id, stream_id);
return buffer_pos;
}
void verse_send_a_stream(VNodeID node_id, VLayerID stream_id, uint32 time_s, uint32 time_f, VNABlockType type, real64 frequency, const VNABlock *samples)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 165); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_a_stream(node_id = %u stream_id = %u time_s = %u time_f = %u type = %u frequency = %f samples = %p );\n", node_id, stream_id, time_s, time_f, type, frequency, samples);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id);
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s);
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], frequency);
buffer_pos += vnp_pack_audio_block(&buf[buffer_pos], type, samples);
if(node_id == (uint32) ~0u || stream_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_a_stream(const char *buf, size_t buffer_length)
{
uint8 enum_temp;
unsigned int buffer_pos = 0;
void (* func_a_stream)(void *user_data, VNodeID node_id, VLayerID stream_id, uint32 time_s, uint32 time_f, VNABlockType type, real64 frequency, const VNABlock *samples);
VNodeID node_id;
VLayerID stream_id;
uint32 time_s;
uint32 time_f;
VNABlockType type;
real64 frequency;
const VNABlock *samples;
func_a_stream = v_fs_get_user_func(165);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &stream_id);
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s);
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f);
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
type = (VNABlockType)enum_temp;
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frequency);
#if defined V_PRINT_RECEIVE_COMMANDS
printf("receive: verse_send_a_stream(node_id = %u stream_id = %u time_s = %u time_f = %u type = %u frequency = %f ); callback = %p\n", node_id, stream_id, time_s, time_f, type, frequency, v_fs_get_user_func(165));
#endif
{
VNABlock block;
buffer_pos += vnp_unpack_audio_block(&buf[buffer_pos], type, &block);
if(func_a_stream != NULL)
func_a_stream(v_fs_get_user_data(165), node_id, stream_id, time_s, time_f, (VNABlockType) type, frequency, &block);
return buffer_pos;
}
if(func_a_stream != NULL)
func_a_stream(v_fs_get_user_data(165), node_id, stream_id, time_s, time_f, (VNABlockType) type, frequency, samples);
return buffer_pos;
}
#endif

@ -1,238 +0,0 @@
/*
** This is automatically generated source code -- do not edit.
** Changes are affected either by editing the corresponding protocol
** definition file (v_cmd_def_X.c where X=node type), or by editing
** the code generator itself, in v_cmd_gen.c.
*/
#include <stdlib.h>
#include <stdio.h>
#include "v_cmd_gen.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "verse.h"
#include "v_cmd_buf.h"
#include "v_network_out_que.h"
#include "v_network.h"
#include "v_connection.h"
#include "v_util.h"
void verse_send_b_dimensions_set(VNodeID node_id, uint16 width, uint16 height, uint16 depth)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_20);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 80); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_b_dimensions_set(node_id = %u width = %u height = %u depth = %u );\n", node_id, width, height, depth);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], width);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], height);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], depth);
if(node_id == (uint32) ~0u)
v_cmd_buf_set_unique_address_size(head, 5);
else
v_cmd_buf_set_address_size(head, 5);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_b_dimensions_set(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_b_dimensions_set)(void *user_data, VNodeID node_id, uint16 width, uint16 height, uint16 depth);
VNodeID node_id;
uint16 width;
uint16 height;
uint16 depth;
func_b_dimensions_set = v_fs_get_user_func(80);
if(buffer_length < 4)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &width);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &height);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &depth);
#if defined V_PRINT_RECEIVE_COMMANDS
printf("receive: verse_send_b_dimensions_set(node_id = %u width = %u height = %u depth = %u ); callback = %p\n", node_id, width, height, depth, v_fs_get_user_func(80));
#endif
if(func_b_dimensions_set != NULL)
func_b_dimensions_set(v_fs_get_user_data(80), node_id, width, height, depth);
return buffer_pos;
}
void verse_send_b_layer_create(VNodeID node_id, VLayerID layer_id, const char *name, VNBLayerType type)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 81); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_b_layer_create(node_id = %u layer_id = %u name = %s type = %u );\n", node_id, layer_id, name, type);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_b_layer_destroy(VNodeID node_id, VLayerID layer_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 81); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_b_layer_destroy(node_id = %u layer_id = %u );\n", node_id, layer_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_b_layer_create(const char *buf, size_t buffer_length)
{
uint8 enum_temp;
unsigned int buffer_pos = 0;
void (* func_b_layer_create)(void *user_data, VNodeID node_id, VLayerID layer_id, const char *name, VNBLayerType type);
VNodeID node_id;
VLayerID layer_id;
char name[16];
VNBLayerType type;
func_b_layer_create = v_fs_get_user_func(81);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos);
if(buffer_length < 1 + buffer_pos)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
type = (VNBLayerType)enum_temp;
#if defined V_PRINT_RECEIVE_COMMANDS
if(name[0] == 0)
printf("receive: verse_send_b_layer_destroy(node_id = %u layer_id = %u ); callback = %p\n", node_id, layer_id, v_fs_get_alias_user_func(81));
else
printf("receive: verse_send_b_layer_create(node_id = %u layer_id = %u name = %s type = %u ); callback = %p\n", node_id, layer_id, name, type, v_fs_get_user_func(81));
#endif
if(name[0] == 0)
{
void (* alias_b_layer_destroy)(void *user_data, VNodeID node_id, VLayerID layer_id);
alias_b_layer_destroy = v_fs_get_alias_user_func(81);
if(alias_b_layer_destroy != NULL)
alias_b_layer_destroy(v_fs_get_alias_user_data(81), node_id, layer_id);
return buffer_pos;
}
if(func_b_layer_create != NULL)
func_b_layer_create(v_fs_get_user_data(81), node_id, layer_id, name, (VNBLayerType) type);
return buffer_pos;
}
void verse_send_b_layer_subscribe(VNodeID node_id, VLayerID layer_id, uint8 level)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 82); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_b_layer_subscribe(node_id = %u layer_id = %u level = %u );\n", node_id, layer_id, level);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], level);
if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_b_layer_unsubscribe(VNodeID node_id, VLayerID layer_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 82); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_b_layer_unsubscribe(node_id = %u layer_id = %u );\n", node_id, layer_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], -1);
if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_b_layer_subscribe(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_b_layer_subscribe)(void *user_data, VNodeID node_id, VLayerID layer_id, uint8 level);
VNodeID node_id;
VLayerID layer_id;
uint8 level;
func_b_layer_subscribe = v_fs_get_user_func(82);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id);
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &level);
#if defined V_PRINT_RECEIVE_COMMANDS
if(level == 255)
printf("receive: verse_send_b_layer_unsubscribe(node_id = %u layer_id = %u ); callback = %p\n", node_id, layer_id, v_fs_get_alias_user_func(82));
else
printf("receive: verse_send_b_layer_subscribe(node_id = %u layer_id = %u level = %u ); callback = %p\n", node_id, layer_id, level, v_fs_get_user_func(82));
#endif
if(level == 255)
{
void (* alias_b_layer_unsubscribe)(void *user_data, VNodeID node_id, VLayerID layer_id);
alias_b_layer_unsubscribe = v_fs_get_alias_user_func(82);
if(alias_b_layer_unsubscribe != NULL)
alias_b_layer_unsubscribe(v_fs_get_alias_user_data(82), node_id, layer_id);
return buffer_pos;
}
if(func_b_layer_subscribe != NULL)
func_b_layer_subscribe(v_fs_get_user_data(82), node_id, layer_id, level);
return buffer_pos;
}
#endif

@ -1,189 +0,0 @@
/*
** This is automatically generated source code -- do not edit.
** Changes are affected either by editing the corresponding protocol
** definition file (v_cmd_def_X.c where X=node type), or by editing
** the code generator itself, in v_cmd_gen.c.
*/
#include <stdlib.h>
#include <stdio.h>
#include "v_cmd_gen.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "verse.h"
#include "v_cmd_buf.h"
#include "v_network_out_que.h"
#include "v_network.h"
#include "v_connection.h"
#include "v_util.h"
void verse_send_c_curve_create(VNodeID node_id, VLayerID curve_id, const char *name, uint8 dimensions)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 128); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_c_curve_create(node_id = %u curve_id = %u name = %s dimensions = %u );\n", node_id, curve_id, name, dimensions);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], dimensions);
if(node_id == (uint32) ~0u || curve_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_c_curve_destroy(VNodeID node_id, VLayerID curve_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 128); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_c_curve_destroy(node_id = %u curve_id = %u );\n", node_id, curve_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], -1);
if(node_id == (uint32) ~0u || curve_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_c_curve_create(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_c_curve_create)(void *user_data, VNodeID node_id, VLayerID curve_id, const char *name, uint8 dimensions);
VNodeID node_id;
VLayerID curve_id;
char name[16];
uint8 dimensions;
func_c_curve_create = v_fs_get_user_func(128);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &curve_id);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos);
if(buffer_length < 1 + buffer_pos)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &dimensions);
#if defined V_PRINT_RECEIVE_COMMANDS
if(name[0] == 0)
printf("receive: verse_send_c_curve_destroy(node_id = %u curve_id = %u ); callback = %p\n", node_id, curve_id, v_fs_get_alias_user_func(128));
else
printf("receive: verse_send_c_curve_create(node_id = %u curve_id = %u name = %s dimensions = %u ); callback = %p\n", node_id, curve_id, name, dimensions, v_fs_get_user_func(128));
#endif
if(name[0] == 0)
{
void (* alias_c_curve_destroy)(void *user_data, VNodeID node_id, VLayerID curve_id);
alias_c_curve_destroy = v_fs_get_alias_user_func(128);
if(alias_c_curve_destroy != NULL)
alias_c_curve_destroy(v_fs_get_alias_user_data(128), node_id, curve_id);
return buffer_pos;
}
if(func_c_curve_create != NULL)
func_c_curve_create(v_fs_get_user_data(128), node_id, curve_id, name, dimensions);
return buffer_pos;
}
void verse_send_c_curve_subscribe(VNodeID node_id, VLayerID curve_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 129); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_c_curve_subscribe(node_id = %u curve_id = %u );\n", node_id, curve_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
if(node_id == (uint32) ~0u || curve_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_c_curve_unsubscribe(VNodeID node_id, VLayerID curve_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 129); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_c_curve_unsubscribe(node_id = %u curve_id = %u );\n", node_id, curve_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
if(node_id == (uint32) ~0u || curve_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_c_curve_subscribe(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_c_curve_subscribe)(void *user_data, VNodeID node_id, VLayerID curve_id);
VNodeID node_id;
VLayerID curve_id;
uint8 alias_bool;
func_c_curve_subscribe = v_fs_get_user_func(129);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &curve_id);
if(buffer_length < buffer_pos + 1)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
#if defined V_PRINT_RECEIVE_COMMANDS
if(!alias_bool)
printf("receive: verse_send_c_curve_unsubscribe(node_id = %u curve_id = %u ); callback = %p\n", node_id, curve_id, v_fs_get_alias_user_func(129));
else
printf("receive: verse_send_c_curve_subscribe(node_id = %u curve_id = %u ); callback = %p\n", node_id, curve_id, v_fs_get_user_func(129));
#endif
if(!alias_bool)
{
void (* alias_c_curve_unsubscribe)(void *user_data, VNodeID node_id, VLayerID curve_id);
alias_c_curve_unsubscribe = v_fs_get_alias_user_func(129);
if(alias_c_curve_unsubscribe != NULL)
alias_c_curve_unsubscribe(v_fs_get_alias_user_data(129), node_id, curve_id);
return buffer_pos;
}
if(func_c_curve_subscribe != NULL)
func_c_curve_subscribe(v_fs_get_user_data(129), node_id, curve_id);
return buffer_pos;
}
#endif

File diff suppressed because it is too large Load Diff

@ -1,95 +0,0 @@
/*
** This is automatically generated source code -- do not edit.
** Changes are affected either by editing the corresponding protocol
** definition file (v_cmd_def_X.c where X=node type), or by editing
** the code generator itself, in v_cmd_gen.c.
*/
#include <stdlib.h>
#include <stdio.h>
#include "v_cmd_gen.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "verse.h"
#include "v_cmd_buf.h"
#include "v_network_out_que.h"
#include "v_network.h"
#include "v_connection.h"
#include "v_util.h"
#include "v_gen_unpack_func.h"
#include "verse.h"
extern void verse_send_packet_ack(uint32 packet_id);
extern void verse_send_packet_nak(uint32 packet_id);
void init_pack_and_unpack(void)
{
v_fs_add_func(0, v_unpack_connect, (void *) verse_send_connect, NULL);
v_fs_add_func(1, v_unpack_connect_accept, (void *) verse_send_connect_accept, NULL);
v_fs_add_func(2, v_unpack_connect_terminate, (void *) verse_send_connect_terminate, NULL);
v_fs_add_func(5, v_unpack_ping, (void *) verse_send_ping, NULL);
v_fs_add_func(7, v_unpack_packet_ack, verse_send_packet_ack, NULL);
v_fs_add_func(8, v_unpack_packet_nak, verse_send_packet_nak, NULL);
v_fs_add_func(9, v_unpack_node_index_subscribe, verse_send_node_index_subscribe, NULL);
v_fs_add_func(10, v_unpack_node_create, verse_send_node_create, verse_send_node_destroy);
v_fs_add_func(11, v_unpack_node_subscribe, verse_send_node_subscribe, verse_send_node_unsubscribe);
v_fs_add_func(16, v_unpack_tag_group_create, verse_send_tag_group_create, verse_send_tag_group_destroy);
v_fs_add_func(17, v_unpack_tag_group_subscribe, verse_send_tag_group_subscribe, verse_send_tag_group_unsubscribe);
v_fs_add_func(18, v_unpack_tag_create, verse_send_tag_create, verse_send_tag_destroy);
v_fs_add_func(19, v_unpack_node_name_set, verse_send_node_name_set, NULL);
v_fs_add_func(32, v_unpack_o_transform_pos_real32, verse_send_o_transform_pos_real32, NULL);
v_fs_add_func(33, v_unpack_o_transform_rot_real32, verse_send_o_transform_rot_real32, NULL);
v_fs_add_func(34, v_unpack_o_transform_scale_real32, verse_send_o_transform_scale_real32, NULL);
v_fs_add_func(35, v_unpack_o_transform_pos_real64, verse_send_o_transform_pos_real64, NULL);
v_fs_add_func(36, v_unpack_o_transform_rot_real64, verse_send_o_transform_rot_real64, NULL);
v_fs_add_func(37, v_unpack_o_transform_scale_real64, verse_send_o_transform_scale_real64, NULL);
v_fs_add_func(38, v_unpack_o_transform_subscribe, verse_send_o_transform_subscribe, verse_send_o_transform_unsubscribe);
v_fs_add_func(39, v_unpack_o_light_set, verse_send_o_light_set, NULL);
v_fs_add_func(40, v_unpack_o_link_set, verse_send_o_link_set, verse_send_o_link_destroy);
v_fs_add_func(41, v_unpack_o_method_group_create, verse_send_o_method_group_create, verse_send_o_method_group_destroy);
v_fs_add_func(42, v_unpack_o_method_group_subscribe, verse_send_o_method_group_subscribe, verse_send_o_method_group_unsubscribe);
v_fs_add_func(43, v_unpack_o_method_create, verse_send_o_method_create, verse_send_o_method_destroy);
v_fs_add_func(44, v_unpack_o_method_call, verse_send_o_method_call, NULL);
v_fs_add_func(45, v_unpack_o_anim_run, verse_send_o_anim_run, NULL);
v_fs_add_func(46, v_unpack_o_hide, verse_send_o_hide, NULL);
v_fs_add_func(48, v_unpack_g_layer_create, verse_send_g_layer_create, verse_send_g_layer_destroy);
v_fs_add_func(49, v_unpack_g_layer_subscribe, verse_send_g_layer_subscribe, verse_send_g_layer_unsubscribe);
v_fs_add_func(50, v_unpack_g_vertex_set_xyz_real32, verse_send_g_vertex_set_xyz_real32, verse_send_g_vertex_delete_real32);
v_fs_add_func(51, v_unpack_g_vertex_set_xyz_real64, verse_send_g_vertex_set_xyz_real64, verse_send_g_vertex_delete_real64);
v_fs_add_func(52, v_unpack_g_vertex_set_uint32, verse_send_g_vertex_set_uint32, NULL);
v_fs_add_func(53, v_unpack_g_vertex_set_real64, verse_send_g_vertex_set_real64, NULL);
v_fs_add_func(54, v_unpack_g_vertex_set_real32, verse_send_g_vertex_set_real32, NULL);
v_fs_add_func(55, v_unpack_g_polygon_set_corner_uint32, verse_send_g_polygon_set_corner_uint32, verse_send_g_polygon_delete);
v_fs_add_func(56, v_unpack_g_polygon_set_corner_real64, verse_send_g_polygon_set_corner_real64, NULL);
v_fs_add_func(57, v_unpack_g_polygon_set_corner_real32, verse_send_g_polygon_set_corner_real32, NULL);
v_fs_add_func(58, v_unpack_g_polygon_set_face_uint8, verse_send_g_polygon_set_face_uint8, NULL);
v_fs_add_func(59, v_unpack_g_polygon_set_face_uint32, verse_send_g_polygon_set_face_uint32, NULL);
v_fs_add_func(60, v_unpack_g_polygon_set_face_real64, verse_send_g_polygon_set_face_real64, NULL);
v_fs_add_func(61, v_unpack_g_polygon_set_face_real32, verse_send_g_polygon_set_face_real32, NULL);
v_fs_add_func(62, v_unpack_g_crease_set_vertex, verse_send_g_crease_set_vertex, NULL);
v_fs_add_func(63, v_unpack_g_crease_set_edge, verse_send_g_crease_set_edge, NULL);
v_fs_add_func(64, v_unpack_g_bone_create, verse_send_g_bone_create, verse_send_g_bone_destroy);
v_fs_add_func(68, v_unpack_m_fragment_create, verse_send_m_fragment_create, verse_send_m_fragment_destroy);
v_fs_add_func(80, v_unpack_b_dimensions_set, verse_send_b_dimensions_set, NULL);
v_fs_add_func(81, v_unpack_b_layer_create, verse_send_b_layer_create, verse_send_b_layer_destroy);
v_fs_add_func(82, v_unpack_b_layer_subscribe, verse_send_b_layer_subscribe, verse_send_b_layer_unsubscribe);
v_fs_add_func(83, v_unpack_b_tile_set, (void *) verse_send_b_tile_set, NULL);
v_fs_add_func(96, v_unpack_t_language_set, verse_send_t_language_set, NULL);
v_fs_add_func(97, v_unpack_t_buffer_create, verse_send_t_buffer_create, verse_send_t_buffer_destroy);
v_fs_add_func(98, v_unpack_t_buffer_subscribe, verse_send_t_buffer_subscribe, verse_send_t_buffer_unsubscribe);
v_fs_add_func(99, v_unpack_t_text_set, (void *) verse_send_t_text_set, NULL);
v_fs_add_func(128, v_unpack_c_curve_create, verse_send_c_curve_create, verse_send_c_curve_destroy);
v_fs_add_func(129, v_unpack_c_curve_subscribe, verse_send_c_curve_subscribe, verse_send_c_curve_unsubscribe);
v_fs_add_func(130, v_unpack_c_key_set, (void *) verse_send_c_key_set, (void *) verse_send_c_key_destroy);
v_fs_add_func(160, v_unpack_a_buffer_create, verse_send_a_buffer_create, verse_send_a_buffer_destroy);
v_fs_add_func(161, v_unpack_a_buffer_subscribe, verse_send_a_buffer_subscribe, verse_send_a_buffer_unsubscribe);
v_fs_add_func(162, v_unpack_a_block_set, verse_send_a_block_set, verse_send_a_block_clear);
v_fs_add_func(163, v_unpack_a_stream_create, verse_send_a_stream_create, verse_send_a_stream_destroy);
v_fs_add_func(164, v_unpack_a_stream_subscribe, verse_send_a_stream_subscribe, verse_send_a_stream_unsubscribe);
v_fs_add_func(165, v_unpack_a_stream, verse_send_a_stream, NULL);
}
#endif

@ -1,352 +0,0 @@
/*
** This is automatically generated source code -- do not edit.
** Changes are affected either by editing the corresponding protocol
** definition file (v_cmd_def_X.c where X=node type), or by editing
** the code generator itself, in v_cmd_gen.c.
*/
#include <stdlib.h>
#include <stdio.h>
#include "v_cmd_gen.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "verse.h"
#include "v_cmd_buf.h"
#include "v_network_out_que.h"
#include "v_network.h"
#include "v_connection.h"
#include "v_util.h"
void verse_send_m_fragment_create(VNodeID node_id, VNMFragmentID frag_id, VNMFragmentType type, const VMatFrag *fragment)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 68); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_m_fragment_create(node_id = %u frag_id = %u type = %u fragment = %p );\n", node_id, frag_id, type, fragment);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], frag_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
switch(type)
{
case VN_M_FT_COLOR :
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->color.red);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->color.green);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->color.blue);
break;
case VN_M_FT_LIGHT :
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->light.type);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->light.normal_falloff);
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], fragment->light.brdf);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->light.brdf_r, 16);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->light.brdf_g, 16);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->light.brdf_b, 16);
break;
case VN_M_FT_REFLECTION :
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->reflection.normal_falloff);
break;
case VN_M_FT_TRANSPARENCY :
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->transparency.normal_falloff);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->transparency.refraction_index);
break;
case VN_M_FT_GEOMETRY :
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->geometry.layer_r, 16);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->geometry.layer_g, 16);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->geometry.layer_b, 16);
break;
case VN_M_FT_VOLUME :
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.diffusion);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.col_r);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.col_g);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.col_b);
break;
case VN_M_FT_VIEW :
break;
case VN_M_FT_TEXTURE :
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], fragment->texture.bitmap);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->texture.layer_r, 16);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->texture.layer_g, 16);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->texture.layer_b, 16);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->texture.filtered);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->texture.mapping);
break;
case VN_M_FT_NOISE :
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->noise.type);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->noise.mapping);
break;
case VN_M_FT_BLENDER :
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->blender.type);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->blender.data_a);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->blender.data_b);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->blender.control);
break;
case VN_M_FT_CLAMP :
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->clamp.min);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->clamp.red);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->clamp.green);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->clamp.blue);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->clamp.data);
break;
case VN_M_FT_MATRIX :
{
unsigned int i;
for(i = 0; i < 16; i++)
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->matrix.matrix[i]);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->matrix.data);
}
break;
case VN_M_FT_RAMP :
if(fragment->ramp.point_count == 0)
return;
{
unsigned int i, pos;
double last;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->ramp.type);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->ramp.channel);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->ramp.mapping);
pos = buffer_pos;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], fragment->ramp.point_count);
last = fragment->ramp.ramp[0].pos - 1;
for(i = 0; i < fragment->ramp.point_count && fragment->ramp.ramp[i].pos > last && i < 48; i++)
{
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].pos);
last = fragment->ramp.ramp[i].pos;
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].red);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].green);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].blue);
}
if(i != fragment->ramp.point_count)
vnp_raw_pack_uint8(&buf[pos], i);
}
break;
case VN_M_FT_ANIMATION :
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->animation.label, 16);
break;
case VN_M_FT_ALTERNATIVE :
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->alternative.alt_a);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->alternative.alt_b);
break;
case VN_M_FT_OUTPUT :
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->output.label, 16);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->output.front);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->output.back);
break;
}
if(node_id == (uint32) ~0u || frag_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_m_fragment_destroy(VNodeID node_id, VNMFragmentID frag_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 68); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_m_fragment_destroy(node_id = %u frag_id = %u );\n", node_id, frag_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], frag_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
if(node_id == (uint32) ~0u || frag_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_m_fragment_create(const char *buf, size_t buffer_length)
{
uint8 enum_temp;
unsigned int buffer_pos = 0;
void (* func_m_fragment_create)(void *user_data, VNodeID node_id, VNMFragmentID frag_id, VNMFragmentType type, const VMatFrag *fragment);
VNodeID node_id;
VNMFragmentID frag_id;
VNMFragmentType type;
const VMatFrag *fragment;
func_m_fragment_create = v_fs_get_user_func(68);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag_id);
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
type = (VNMFragmentType)enum_temp;
#if defined V_PRINT_RECEIVE_COMMANDS
if(type > VN_M_FT_OUTPUT)
printf("receive: verse_send_m_fragment_destroy(node_id = %u frag_id = %u ); callback = %p\n", node_id, frag_id, v_fs_get_alias_user_func(68));
else
printf("receive: verse_send_m_fragment_create(node_id = %u frag_id = %u type = %u ); callback = %p\n", node_id, frag_id, type, v_fs_get_user_func(68));
#endif
if(type <= VN_M_FT_OUTPUT)
{
VMatFrag frag;
uint8 temp;
switch(type)
{
case VN_M_FT_COLOR :
if(buffer_pos + 3 * 8 > buffer_length)
return -1;
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.color.red);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.color.green);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.color.blue);
break;
case VN_M_FT_LIGHT :
if(buffer_pos + 13 > buffer_length)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);
frag.light.type = (VNMLightType)temp;
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.light.normal_falloff);
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &frag.light.brdf);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.light.brdf_r, 16, buffer_length - buffer_pos);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.light.brdf_g, 16, buffer_length - buffer_pos);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.light.brdf_b, 16, buffer_length - buffer_pos);
break;
case VN_M_FT_REFLECTION :
if(buffer_pos + 8 > buffer_length)
return -1;
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.reflection.normal_falloff);
break;
case VN_M_FT_TRANSPARENCY :
if(buffer_pos + 16 > buffer_length)
return -1;
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.transparency.normal_falloff);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.transparency.refraction_index);
break;
case VN_M_FT_VOLUME :
if(buffer_pos + 32 > buffer_length)
return -1;
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.diffusion);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.col_r);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.col_g);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.col_b);
break;
case VN_M_FT_VIEW :
break;
case VN_M_FT_GEOMETRY :
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.geometry.layer_r, 16, buffer_length - buffer_pos);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.geometry.layer_g, 16, buffer_length - buffer_pos);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.geometry.layer_b, 16, buffer_length - buffer_pos);
break;
case VN_M_FT_TEXTURE :
if(buffer_pos + 10 > buffer_length)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &frag.texture.bitmap);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.texture.layer_r, 16, buffer_length - buffer_pos);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.texture.layer_g, 16, buffer_length - buffer_pos);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.texture.layer_b, 16, buffer_length - buffer_pos);
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);
frag.texture.filtered = (VNMNoiseType)temp;
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.texture.mapping);
break;
case VN_M_FT_NOISE :
if(buffer_pos + 3 > buffer_length)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);
frag.noise.type = (VNMNoiseType)temp;
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.noise.mapping);
break;
case VN_M_FT_BLENDER :
if(buffer_pos + 7 > buffer_length)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);
frag.blender.type = (VNMBlendType)temp;
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.blender.data_a);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.blender.data_b);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.blender.control);
break;
case VN_M_FT_CLAMP :
if(buffer_pos + 27 > buffer_length)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);
frag.clamp.min = (VNMBlendType)temp;
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.clamp.red);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.clamp.green);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.clamp.blue);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.clamp.data);
break;
case VN_M_FT_MATRIX :
if(buffer_pos + 8 * 16 + 2 > buffer_length)
return -1;
else
{
unsigned int i;
for(i = 0; i < 16; i++)
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.matrix.matrix[i]);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.matrix.data);
}
break;
case VN_M_FT_RAMP :
if(buffer_pos + 5 + 4 * 8 > buffer_length)
return -1;
else
{
unsigned int i, pos;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);
frag.ramp.type = (VNMRampType)temp;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);
frag.ramp.channel = (VNMRampChannel)temp;
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.ramp.mapping);
pos = buffer_pos;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &frag.ramp.point_count);
for(i = 0; i < frag.ramp.point_count && buffer_pos + 8 * 4 <= buffer_length && i < 48; i++)
{
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].pos);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].red);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].green);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].blue);
}if(i != frag.ramp.point_count)
frag.ramp.point_count = i;
}
break;
case VN_M_FT_ANIMATION :
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.animation.label, 16, buffer_length - buffer_pos);
break;
case VN_M_FT_ALTERNATIVE :
if(buffer_pos + 4 > buffer_length)
return -1;
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.alternative.alt_a);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.alternative.alt_b);
break;
case VN_M_FT_OUTPUT :
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.output.label, 16, buffer_length - buffer_pos);
if(buffer_pos + 4 > buffer_length)
return -1;
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.output.front);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.output.back);
break;
}
if(func_m_fragment_create != NULL)
func_m_fragment_create(v_fs_get_user_data(68), node_id, frag_id, type, &frag);
return buffer_pos;
}
if(type > VN_M_FT_OUTPUT)
{
void (* alias_m_fragment_destroy)(void *user_data, VNodeID node_id, VNMFragmentID frag_id);
alias_m_fragment_destroy = v_fs_get_alias_user_func(68);
if(alias_m_fragment_destroy != NULL)
alias_m_fragment_destroy(v_fs_get_alias_user_data(68), node_id, frag_id);
return buffer_pos;
}
if(func_m_fragment_create != NULL)
func_m_fragment_create(v_fs_get_user_data(68), node_id, frag_id, (VNMFragmentType) type, fragment);
return buffer_pos;
}
#endif

File diff suppressed because it is too large Load Diff

@ -1,711 +0,0 @@
/*
** This is automatically generated source code -- do not edit.
** Changes are affected either by editing the corresponding protocol
** definition file (v_cmd_def_X.c where X=node type), or by editing
** the code generator itself, in v_cmd_gen.c.
*/
#include <stdlib.h>
#include <stdio.h>
#include "v_cmd_gen.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "verse.h"
#include "v_cmd_buf.h"
#include "v_network_out_que.h"
#include "v_network.h"
#include "v_connection.h"
#include "v_util.h"
void verse_send_packet_ack(uint32 packet_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 7); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], packet_id);
v_cmd_buf_set_unique_address_size(head, buffer_pos);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_ack_nak_buf(v_con_get_network_queue(), head);
return;
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_packet_ack(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_packet_ack)(void *user_data, uint32 packet_id);
uint32 packet_id;
func_packet_ack = v_fs_get_user_func(7);
if(buffer_length < 4)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &packet_id);
#if defined V_PRINT_RECEIVE_COMMANDS
#endif
if(func_packet_ack != NULL)
func_packet_ack(v_fs_get_user_data(7), packet_id);
return buffer_pos;
}
void verse_send_packet_nak(uint32 packet_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 8); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], packet_id);
v_cmd_buf_set_unique_address_size(head, buffer_pos);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_ack_nak_buf(v_con_get_network_queue(), head);
return;
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_packet_nak(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_packet_nak)(void *user_data, uint32 packet_id);
uint32 packet_id;
func_packet_nak = v_fs_get_user_func(8);
if(buffer_length < 4)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &packet_id);
#if defined V_PRINT_RECEIVE_COMMANDS
#endif
if(func_packet_nak != NULL)
func_packet_nak(v_fs_get_user_data(8), packet_id);
return buffer_pos;
}
void verse_send_node_index_subscribe(uint32 mask)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 9); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_node_index_subscribe(mask = %u );\n", mask);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], mask);
if(mask == (uint32) ~0u)
v_cmd_buf_set_unique_address_size(head, 5);
else
v_cmd_buf_set_address_size(head, 5);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_node_index_subscribe(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_node_index_subscribe)(void *user_data, uint32 mask);
uint32 mask;
func_node_index_subscribe = v_fs_get_user_func(9);
if(buffer_length < 4)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &mask);
#if defined V_PRINT_RECEIVE_COMMANDS
printf("receive: verse_send_node_index_subscribe(mask = %u ); callback = %p\n", mask, v_fs_get_user_func(9));
#endif
if(func_node_index_subscribe != NULL)
func_node_index_subscribe(v_fs_get_user_data(9), mask);
return buffer_pos;
}
void verse_send_node_create(VNodeID node_id, VNodeType type, VNodeOwner owner)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 10); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_node_create(node_id = %u type = %u owner = %u );\n", node_id, type, owner);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)owner);
if(node_id == (uint32) ~0u)
v_cmd_buf_set_unique_address_size(head, 5);
else
v_cmd_buf_set_address_size(head, 5);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_node_destroy(VNodeID node_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 10); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_node_destroy(node_id = %u );\n", node_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
if(node_id == (uint32) ~0u)
v_cmd_buf_set_unique_address_size(head, 5);
else
v_cmd_buf_set_address_size(head, 5);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_node_create(const char *buf, size_t buffer_length)
{
uint8 enum_temp;
unsigned int buffer_pos = 0;
void (* func_node_create)(void *user_data, VNodeID node_id, VNodeType type, VNodeOwner owner);
VNodeID node_id;
VNodeType type;
VNodeOwner owner;
func_node_create = v_fs_get_user_func(10);
if(buffer_length < 4)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
type = (VNodeType)enum_temp;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
owner = (VNodeOwner)enum_temp;
#if defined V_PRINT_RECEIVE_COMMANDS
if(owner == (uint8) ~0u || type >= V_NT_NUM_TYPES)
printf("receive: verse_send_node_destroy(node_id = %u ); callback = %p\n", node_id, v_fs_get_alias_user_func(10));
else
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));
#endif
if(owner == (uint8) ~0u || type >= V_NT_NUM_TYPES)
{
void (* alias_node_destroy)(void *user_data, VNodeID node_id);
alias_node_destroy = v_fs_get_alias_user_func(10);
if(alias_node_destroy != NULL)
alias_node_destroy(v_fs_get_alias_user_data(10), node_id);
return buffer_pos;
}
if(func_node_create != NULL)
func_node_create(v_fs_get_user_data(10), node_id, (VNodeType) type, (VNodeOwner) owner);
return buffer_pos;
}
void verse_send_node_subscribe(VNodeID node_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 11); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_node_subscribe(node_id = %u );\n", node_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
if(node_id == (uint32) ~0u)
v_cmd_buf_set_unique_address_size(head, 5);
else
v_cmd_buf_set_address_size(head, 5);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_node_unsubscribe(VNodeID node_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 11); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_node_unsubscribe(node_id = %u );\n", node_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
if(node_id == (uint32) ~0u)
v_cmd_buf_set_unique_address_size(head, 5);
else
v_cmd_buf_set_address_size(head, 5);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_node_subscribe(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_node_subscribe)(void *user_data, VNodeID node_id);
VNodeID node_id;
uint8 alias_bool;
func_node_subscribe = v_fs_get_user_func(11);
if(buffer_length < 4)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
if(buffer_length < buffer_pos + 1)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
#if defined V_PRINT_RECEIVE_COMMANDS
if(!alias_bool)
printf("receive: verse_send_node_unsubscribe(node_id = %u ); callback = %p\n", node_id, v_fs_get_alias_user_func(11));
else
printf("receive: verse_send_node_subscribe(node_id = %u ); callback = %p\n", node_id, v_fs_get_user_func(11));
#endif
if(!alias_bool)
{
void (* alias_node_unsubscribe)(void *user_data, VNodeID node_id);
alias_node_unsubscribe = v_fs_get_alias_user_func(11);
if(alias_node_unsubscribe != NULL)
alias_node_unsubscribe(v_fs_get_alias_user_data(11), node_id);
return buffer_pos;
}
if(func_node_subscribe != NULL)
func_node_subscribe(v_fs_get_user_data(11), node_id);
return buffer_pos;
}
void verse_send_tag_group_create(VNodeID node_id, uint16 group_id, const char *name)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 16); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_tag_group_create(node_id = %u group_id = %u name = %s );\n", node_id, group_id, name);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16);
if(node_id == (uint32) ~0u || group_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_tag_group_destroy(VNodeID node_id, uint16 group_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 16); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_tag_group_destroy(node_id = %u group_id = %u );\n", node_id, group_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
if(node_id == (uint32) ~0u || group_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_tag_group_create(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_tag_group_create)(void *user_data, VNodeID node_id, uint16 group_id, const char *name);
VNodeID node_id;
uint16 group_id;
char name[16];
func_tag_group_create = v_fs_get_user_func(16);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos);
#if defined V_PRINT_RECEIVE_COMMANDS
if(name[0] == 0)
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));
else
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));
#endif
if(name[0] == 0)
{
void (* alias_tag_group_destroy)(void *user_data, VNodeID node_id, uint16 group_id);
alias_tag_group_destroy = v_fs_get_alias_user_func(16);
if(alias_tag_group_destroy != NULL)
alias_tag_group_destroy(v_fs_get_alias_user_data(16), node_id, group_id);
return buffer_pos;
}
if(func_tag_group_create != NULL)
func_tag_group_create(v_fs_get_user_data(16), node_id, group_id, name);
return buffer_pos;
}
void verse_send_tag_group_subscribe(VNodeID node_id, uint16 group_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 17); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_tag_group_subscribe(node_id = %u group_id = %u );\n", node_id, group_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
if(node_id == (uint32) ~0u || group_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_tag_group_unsubscribe(VNodeID node_id, uint16 group_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 17); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_tag_group_unsubscribe(node_id = %u group_id = %u );\n", node_id, group_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
if(node_id == (uint32) ~0u || group_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_tag_group_subscribe(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_tag_group_subscribe)(void *user_data, VNodeID node_id, uint16 group_id);
VNodeID node_id;
uint16 group_id;
uint8 alias_bool;
func_tag_group_subscribe = v_fs_get_user_func(17);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id);
if(buffer_length < buffer_pos + 1)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
#if defined V_PRINT_RECEIVE_COMMANDS
if(!alias_bool)
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));
else
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));
#endif
if(!alias_bool)
{
void (* alias_tag_group_unsubscribe)(void *user_data, VNodeID node_id, uint16 group_id);
alias_tag_group_unsubscribe = v_fs_get_alias_user_func(17);
if(alias_tag_group_unsubscribe != NULL)
alias_tag_group_unsubscribe(v_fs_get_alias_user_data(17), node_id, group_id);
return buffer_pos;
}
if(func_tag_group_subscribe != NULL)
func_tag_group_subscribe(v_fs_get_user_data(17), node_id, group_id);
return buffer_pos;
}
void verse_send_tag_create(VNodeID node_id, uint16 group_id, uint16 tag_id, const char *name, VNTagType type, const VNTag *tag)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 18); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
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);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], tag_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
if(type > VN_TAG_BLOB)
{
v_cmd_buf_free(head);
return;
}
switch(type)
{
case VN_TAG_BOOLEAN :
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((VNTag *)tag)->vboolean);
break;
case VN_TAG_UINT32 :
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vuint32);
break;
case VN_TAG_REAL64 :
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64);
break;
case VN_TAG_STRING :
{
unsigned int i;
for(i = 0; ((VNTag *)tag)->vstring[i] != 0 && i < VN_TAG_MAX_BLOB_SIZE; i++)
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((VNTag *)tag)->vstring[i]);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);
}
break;
case VN_TAG_REAL64_VEC3 :
{
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[0]);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[1]);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[2]);
}
break;
case VN_TAG_LINK :
{
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vlink);
}
break;
case VN_TAG_ANIMATION :
{
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.curve);
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.start);
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.end);
}
break;
case VN_TAG_BLOB :
{
unsigned int i;
if(((VNTag *)tag)->vblob.size > VN_TAG_MAX_BLOB_SIZE)
((VNTag *)tag)->vblob.size = VN_TAG_MAX_BLOB_SIZE;
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], ((VNTag *)tag)->vblob.size);
for(i = 0; i < ((VNTag *)tag)->vblob.size; i++)
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((uint8 *)((VNTag *)tag)->vblob.blob)[i]);
}
break;
default :
;
}
if(node_id == (uint32) ~0u || group_id == (uint16) ~0u || tag_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 9);
else
v_cmd_buf_set_address_size(head, 9);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_tag_destroy(VNodeID node_id, uint16 group_id, uint16 tag_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 18); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_tag_destroy(node_id = %u group_id = %u tag_id = %u );\n", node_id, group_id, tag_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], tag_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
if(node_id == (uint32) ~0u || group_id == (uint16) ~0u || tag_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 9);
else
v_cmd_buf_set_address_size(head, 9);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_tag_create(const char *buf, size_t buffer_length)
{
uint8 enum_temp;
unsigned int buffer_pos = 0;
void (* func_tag_create)(void *user_data, VNodeID node_id, uint16 group_id, uint16 tag_id, const char *name, VNTagType type, const VNTag *tag);
VNodeID node_id;
uint16 group_id;
uint16 tag_id;
char name[16];
VNTagType type;
const VNTag *tag;
func_tag_create = v_fs_get_user_func(18);
if(buffer_length < 8)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &tag_id);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos);
if(buffer_length < 1 + buffer_pos)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
type = (VNTagType)enum_temp;
#if defined V_PRINT_RECEIVE_COMMANDS
if(type >= VN_TAG_TYPE_COUNT)
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));
else
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));
#endif
if(type < VN_TAG_TYPE_COUNT)
{
VNTag tag;
unsigned int i;
char string[VN_TAG_MAX_BLOB_SIZE];
switch(type)
{
case VN_TAG_BOOLEAN :
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &tag.vboolean);
break;
case VN_TAG_UINT32 :
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vuint32);
break;
case VN_TAG_REAL64 :
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64);
break;
case VN_TAG_STRING :
{
tag.vstring = string;
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], string, VN_TAG_MAX_BLOB_SIZE, buffer_length - buffer_pos);
}
break;
case VN_TAG_REAL64_VEC3 :
{
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[0]);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[1]);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[2]);
}
break;
case VN_TAG_LINK :
{
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vlink);
}
break;
case VN_TAG_ANIMATION :
{
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.curve);
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.start);
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.end);
}
break;
case VN_TAG_BLOB :
{
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &tag.vblob.size);
if(tag.vblob.size > VN_TAG_MAX_BLOB_SIZE)
tag.vblob.size = VN_TAG_MAX_BLOB_SIZE;
tag.vblob.blob = string;
for(i = 0; i < tag.vblob.size; i++)
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &string[i]);
}
break;
default :
;
}
if(func_tag_create != NULL)
func_tag_create(v_fs_get_user_data(18), node_id, group_id, tag_id, name, type, &tag);
return buffer_pos;
}
if(type >= VN_TAG_TYPE_COUNT)
{
void (* alias_tag_destroy)(void *user_data, VNodeID node_id, uint16 group_id, uint16 tag_id);
alias_tag_destroy = v_fs_get_alias_user_func(18);
if(alias_tag_destroy != NULL)
alias_tag_destroy(v_fs_get_alias_user_data(18), node_id, group_id, tag_id);
return buffer_pos;
}
if(func_tag_create != NULL)
func_tag_create(v_fs_get_user_data(18), node_id, group_id, tag_id, name, (VNTagType) type, tag);
return buffer_pos;
}
void verse_send_node_name_set(VNodeID node_id, const char *name)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 19); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_node_name_set(node_id = %u name = %s );\n", node_id, name);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 512);
if(node_id == (uint32) ~0u)
v_cmd_buf_set_unique_address_size(head, 5);
else
v_cmd_buf_set_address_size(head, 5);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_node_name_set(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_node_name_set)(void *user_data, VNodeID node_id, const char *name);
VNodeID node_id;
char name[512];
func_node_name_set = v_fs_get_user_func(19);
if(buffer_length < 4)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 512, buffer_length - buffer_pos);
#if defined V_PRINT_RECEIVE_COMMANDS
printf("receive: verse_send_node_name_set(node_id = %u name = %s ); callback = %p\n", node_id, name, v_fs_get_user_func(19));
#endif
if(func_node_name_set != NULL)
func_node_name_set(v_fs_get_user_data(19), node_id, name);
return buffer_pos;
}
#endif

@ -1,226 +0,0 @@
/*
** This is automatically generated source code -- do not edit.
** Changes are affected either by editing the corresponding protocol
** definition file (v_cmd_def_X.c where X=node type), or by editing
** the code generator itself, in v_cmd_gen.c.
*/
#include <stdlib.h>
#include <stdio.h>
#include "v_cmd_gen.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "verse.h"
#include "v_cmd_buf.h"
#include "v_network_out_que.h"
#include "v_network.h"
#include "v_connection.h"
#include "v_util.h"
void verse_send_t_language_set(VNodeID node_id, const char *language)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 96); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_t_language_set(node_id = %u language = %s );\n", node_id, language);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], language, 512);
if(node_id == (uint32) ~0u)
v_cmd_buf_set_unique_address_size(head, 5);
else
v_cmd_buf_set_address_size(head, 5);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_t_language_set(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_t_language_set)(void *user_data, VNodeID node_id, const char *language);
VNodeID node_id;
char language[512];
func_t_language_set = v_fs_get_user_func(96);
if(buffer_length < 4)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], language, 512, buffer_length - buffer_pos);
#if defined V_PRINT_RECEIVE_COMMANDS
printf("receive: verse_send_t_language_set(node_id = %u language = %s ); callback = %p\n", node_id, language, v_fs_get_user_func(96));
#endif
if(func_t_language_set != NULL)
func_t_language_set(v_fs_get_user_data(96), node_id, language);
return buffer_pos;
}
void verse_send_t_buffer_create(VNodeID node_id, VBufferID buffer_id, const char *name)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 97); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_t_buffer_create(node_id = %u buffer_id = %u name = %s );\n", node_id, buffer_id, name);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16);
if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_t_buffer_destroy(VNodeID node_id, VBufferID buffer_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 97); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_t_buffer_destroy(node_id = %u buffer_id = %u );\n", node_id, buffer_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_t_buffer_create(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_t_buffer_create)(void *user_data, VNodeID node_id, VBufferID buffer_id, const char *name);
VNodeID node_id;
VBufferID buffer_id;
char name[16];
func_t_buffer_create = v_fs_get_user_func(97);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &buffer_id);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos);
#if defined V_PRINT_RECEIVE_COMMANDS
if(name[0] == 0)
printf("receive: verse_send_t_buffer_destroy(node_id = %u buffer_id = %u ); callback = %p\n", node_id, buffer_id, v_fs_get_alias_user_func(97));
else
printf("receive: verse_send_t_buffer_create(node_id = %u buffer_id = %u name = %s ); callback = %p\n", node_id, buffer_id, name, v_fs_get_user_func(97));
#endif
if(name[0] == 0)
{
void (* alias_t_buffer_destroy)(void *user_data, VNodeID node_id, VBufferID buffer_id);
alias_t_buffer_destroy = v_fs_get_alias_user_func(97);
if(alias_t_buffer_destroy != NULL)
alias_t_buffer_destroy(v_fs_get_alias_user_data(97), node_id, buffer_id);
return buffer_pos;
}
if(func_t_buffer_create != NULL)
func_t_buffer_create(v_fs_get_user_data(97), node_id, buffer_id, name);
return buffer_pos;
}
void verse_send_t_buffer_subscribe(VNodeID node_id, VBufferID buffer_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 98); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_t_buffer_subscribe(node_id = %u buffer_id = %u );\n", node_id, buffer_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_t_buffer_unsubscribe(VNodeID node_id, VBufferID buffer_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 98); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_t_buffer_unsubscribe(node_id = %u buffer_id = %u );\n", node_id, buffer_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u)
v_cmd_buf_set_unique_address_size(head, 7);
else
v_cmd_buf_set_address_size(head, 7);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_t_buffer_subscribe(const char *buf, size_t buffer_length)
{
unsigned int buffer_pos = 0;
void (* func_t_buffer_subscribe)(void *user_data, VNodeID node_id, VBufferID buffer_id);
VNodeID node_id;
VBufferID buffer_id;
uint8 alias_bool;
func_t_buffer_subscribe = v_fs_get_user_func(98);
if(buffer_length < 6)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &buffer_id);
if(buffer_length < buffer_pos + 1)
return -1;
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
#if defined V_PRINT_RECEIVE_COMMANDS
if(!alias_bool)
printf("receive: verse_send_t_buffer_unsubscribe(node_id = %u buffer_id = %u ); callback = %p\n", node_id, buffer_id, v_fs_get_alias_user_func(98));
else
printf("receive: verse_send_t_buffer_subscribe(node_id = %u buffer_id = %u ); callback = %p\n", node_id, buffer_id, v_fs_get_user_func(98));
#endif
if(!alias_bool)
{
void (* alias_t_buffer_unsubscribe)(void *user_data, VNodeID node_id, VBufferID buffer_id);
alias_t_buffer_unsubscribe = v_fs_get_alias_user_func(98);
if(alias_t_buffer_unsubscribe != NULL)
alias_t_buffer_unsubscribe(v_fs_get_alias_user_data(98), node_id, buffer_id);
return buffer_pos;
}
if(func_t_buffer_subscribe != NULL)
func_t_buffer_subscribe(v_fs_get_user_data(98), node_id, buffer_id);
return buffer_pos;
}
#endif

@ -1,63 +0,0 @@
extern unsigned int v_unpack_connect(const char *data, size_t length);
extern unsigned int v_unpack_connect_accept(const char *data, size_t length);
extern unsigned int v_unpack_connect_terminate(const char *data, size_t length);
extern unsigned int v_unpack_ping(const char *data, size_t length);
extern unsigned int v_unpack_packet_ack(const char *data, size_t length);
extern unsigned int v_unpack_packet_nak(const char *data, size_t length);
extern unsigned int v_unpack_node_index_subscribe(const char *data, size_t length);
extern unsigned int v_unpack_node_create(const char *data, size_t length);
extern unsigned int v_unpack_node_subscribe(const char *data, size_t length);
extern unsigned int v_unpack_tag_group_create(const char *data, size_t length);
extern unsigned int v_unpack_tag_group_subscribe(const char *data, size_t length);
extern unsigned int v_unpack_tag_create(const char *data, size_t length);
extern unsigned int v_unpack_node_name_set(const char *data, size_t length);
extern unsigned int v_unpack_o_transform_pos_real32(const char *data, size_t length);
extern unsigned int v_unpack_o_transform_rot_real32(const char *data, size_t length);
extern unsigned int v_unpack_o_transform_scale_real32(const char *data, size_t length);
extern unsigned int v_unpack_o_transform_pos_real64(const char *data, size_t length);
extern unsigned int v_unpack_o_transform_rot_real64(const char *data, size_t length);
extern unsigned int v_unpack_o_transform_scale_real64(const char *data, size_t length);
extern unsigned int v_unpack_o_transform_subscribe(const char *data, size_t length);
extern unsigned int v_unpack_o_light_set(const char *data, size_t length);
extern unsigned int v_unpack_o_link_set(const char *data, size_t length);
extern unsigned int v_unpack_o_method_group_create(const char *data, size_t length);
extern unsigned int v_unpack_o_method_group_subscribe(const char *data, size_t length);
extern unsigned int v_unpack_o_method_create(const char *data, size_t length);
extern unsigned int v_unpack_o_method_call(const char *data, size_t length);
extern unsigned int v_unpack_o_anim_run(const char *data, size_t length);
extern unsigned int v_unpack_o_hide(const char *data, size_t length);
extern unsigned int v_unpack_g_layer_create(const char *data, size_t length);
extern unsigned int v_unpack_g_layer_subscribe(const char *data, size_t length);
extern unsigned int v_unpack_g_vertex_set_xyz_real32(const char *data, size_t length);
extern unsigned int v_unpack_g_vertex_set_xyz_real64(const char *data, size_t length);
extern unsigned int v_unpack_g_vertex_set_uint32(const char *data, size_t length);
extern unsigned int v_unpack_g_vertex_set_real64(const char *data, size_t length);
extern unsigned int v_unpack_g_vertex_set_real32(const char *data, size_t length);
extern unsigned int v_unpack_g_polygon_set_corner_uint32(const char *data, size_t length);
extern unsigned int v_unpack_g_polygon_set_corner_real64(const char *data, size_t length);
extern unsigned int v_unpack_g_polygon_set_corner_real32(const char *data, size_t length);
extern unsigned int v_unpack_g_polygon_set_face_uint8(const char *data, size_t length);
extern unsigned int v_unpack_g_polygon_set_face_uint32(const char *data, size_t length);
extern unsigned int v_unpack_g_polygon_set_face_real64(const char *data, size_t length);
extern unsigned int v_unpack_g_polygon_set_face_real32(const char *data, size_t length);
extern unsigned int v_unpack_g_crease_set_vertex(const char *data, size_t length);
extern unsigned int v_unpack_g_crease_set_edge(const char *data, size_t length);
extern unsigned int v_unpack_g_bone_create(const char *data, size_t length);
extern unsigned int v_unpack_m_fragment_create(const char *data, size_t length);
extern unsigned int v_unpack_b_dimensions_set(const char *data, size_t length);
extern unsigned int v_unpack_b_layer_create(const char *data, size_t length);
extern unsigned int v_unpack_b_layer_subscribe(const char *data, size_t length);
extern unsigned int v_unpack_b_tile_set(const char *data, size_t length);
extern unsigned int v_unpack_t_language_set(const char *data, size_t length);
extern unsigned int v_unpack_t_buffer_create(const char *data, size_t length);
extern unsigned int v_unpack_t_buffer_subscribe(const char *data, size_t length);
extern unsigned int v_unpack_t_text_set(const char *data, size_t length);
extern unsigned int v_unpack_c_curve_create(const char *data, size_t length);
extern unsigned int v_unpack_c_curve_subscribe(const char *data, size_t length);
extern unsigned int v_unpack_c_key_set(const char *data, size_t length);
extern unsigned int v_unpack_a_buffer_create(const char *data, size_t length);
extern unsigned int v_unpack_a_buffer_subscribe(const char *data, size_t length);
extern unsigned int v_unpack_a_block_set(const char *data, size_t length);
extern unsigned int v_unpack_a_stream_create(const char *data, size_t length);
extern unsigned int v_unpack_a_stream_subscribe(const char *data, size_t length);
extern unsigned int v_unpack_a_stream(const char *data, size_t length);

@ -1,2 +0,0 @@
extern void verse_send_packet_ack(uint32 packet_id);
extern void verse_send_packet_nak(uint32 packet_id);

@ -1,498 +0,0 @@
/*
**
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "v_cmd_gen.h"
#if !defined V_GENERATE_FUNC_MODE
#include "verse.h"
#include "v_cmd_buf.h"
#include "v_network_out_que.h"
#include "v_network.h"
#include "v_connection.h"
#include "v_encryption.h"
unsigned int v_unpack_connect(const char *buf, unsigned int buffer_length)
{
return -1; /* this command is illegal to send */
}
unsigned int v_unpack_connect_accept(const char *buf, unsigned int buffer_length)
{
return -1; /* this command is illegal to send */
}
extern void v_callback_connect_terminate(const char *bye);
unsigned int v_unpack_connect_terminate(const char *buf, unsigned int buffer_length)
{
unsigned int buffer_pos = 0;
char bye[512];
buffer_pos = vnp_raw_unpack_string(buf, bye, sizeof bye, buffer_length);
v_callback_connect_terminate(bye);
return buffer_pos;
}
static unsigned int pack_b_tile_set_head(VCMDBufHead *head, VNodeID node_id, VLayerID layer_id, uint16 tile_x, uint16 tile_y, uint16 z, VNBLayerType type, const VNBTile *tile)
{
unsigned int buffer_pos = 0;
uint8 *buf;
buf = ((VCMDBuffer30 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 83); /* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_b_tile_set(node_id = %u layer_id = %u tile_x = %u tile_y = %u z = %u type = %u tile = %p );\n", node_id, layer_id, tile_x, tile_y, z, type, tile);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], tile_x);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], tile_y);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], z);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
return buffer_pos;
v_cmd_buf_set_address_size(head, 13);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_b_tile_set(VNodeID node_id, VLayerID layer_id, uint16 tile_x, uint16 tile_y, uint16 z, VNBLayerType type, const VNBTile *tile)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
switch(type)
{
case VN_B_LAYER_UINT1 :
head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
buf = ((VCMDBuffer30 *)head)->buf;
buffer_pos += pack_b_tile_set_head(head, node_id, layer_id, tile_x, tile_y, z, type, tile);
buffer_pos += vnp_raw_pack_uint8_vector(&buf[buffer_pos], tile->vuint1, VN_B_TILE_SIZE * VN_B_TILE_SIZE / 8);
break;
case VN_B_LAYER_UINT8 :
head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */
buf = ((VCMDBuffer80 *)head)->buf;
buffer_pos += pack_b_tile_set_head(head, node_id, layer_id, tile_x, tile_y, z, type, tile);
buffer_pos += vnp_raw_pack_uint8_vector(&buf[buffer_pos], tile->vuint8, VN_B_TILE_SIZE * VN_B_TILE_SIZE);
break;
case VN_B_LAYER_UINT16 :
head = v_cmd_buf_allocate(VCMDBS_160);/* Allocating the buffer */
buf = ((VCMDBuffer160 *)head)->buf;
buffer_pos += pack_b_tile_set_head(head, node_id, layer_id, tile_x, tile_y, z, type, tile);
buffer_pos += vnp_raw_pack_uint16_vector(&buf[buffer_pos], tile->vuint16, VN_B_TILE_SIZE * VN_B_TILE_SIZE);
break;
case VN_B_LAYER_REAL32 :
head = v_cmd_buf_allocate(VCMDBS_320);/* Allocating the buffer */
buf = ((VCMDBuffer320 *)head)->buf;
buffer_pos += pack_b_tile_set_head(head, node_id, layer_id, tile_x, tile_y, z, type, tile);
buffer_pos += vnp_raw_pack_real32_vector(&buf[buffer_pos], tile->vreal32, VN_B_TILE_SIZE * VN_B_TILE_SIZE);
break;
case VN_B_LAYER_REAL64 :
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += pack_b_tile_set_head(head, node_id, layer_id, tile_x, tile_y, z, type, tile);
buffer_pos += vnp_raw_pack_real64_vector(&buf[buffer_pos], tile->vreal64, VN_B_TILE_SIZE * VN_B_TILE_SIZE);
break;
default:
head = NULL;
}
v_cmd_buf_set_address_size(head, 13);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_b_tile_set(const char *buf, size_t buffer_length)
{
uint8 enum_temp;
unsigned int buffer_pos = 0;
void (* func_b_tile_set)(void *user_data, VNodeID node_id, VLayerID layer_id, uint16 tile_x, uint16 tile_y, uint16 z, VNBLayerType type, const VNBTile *tile);
VNodeID node_id;
VLayerID layer_id;
uint16 tile_x;
uint16 tile_y;
uint16 z;
VNBLayerType type;
const VNBTile *tile;
func_b_tile_set = v_fs_get_user_func(83);
if(buffer_length < 12)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &tile_x);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &tile_y);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &z);
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
type = (VNBLayerType)enum_temp;
#if defined V_PRINT_RECEIVE_COMMANDS
printf("receive: verse_send_b_tile_set(node_id = %u layer_id = %u tile_x = %u tile_y = %u z = %u type = %u ); callback = %p\n", node_id, layer_id, tile_x, tile_y, z, type, v_fs_get_user_func(83));
#endif
{
VNBTile tile;
switch(type)
{
case VN_B_LAYER_UINT1 :
buffer_pos += vnp_raw_unpack_uint8_vector(&buf[buffer_pos], tile.vuint1, VN_B_TILE_SIZE * VN_B_TILE_SIZE / 8);
break;
case VN_B_LAYER_UINT8 :
buffer_pos += vnp_raw_unpack_uint8_vector(&buf[buffer_pos], tile.vuint8, VN_B_TILE_SIZE * VN_B_TILE_SIZE);
break;
case VN_B_LAYER_UINT16 :
buffer_pos += vnp_raw_unpack_uint16_vector(&buf[buffer_pos], tile.vuint16, VN_B_TILE_SIZE * VN_B_TILE_SIZE);
break;
case VN_B_LAYER_REAL32 :
buffer_pos += vnp_raw_unpack_real32_vector(&buf[buffer_pos], tile.vreal32, VN_B_TILE_SIZE * VN_B_TILE_SIZE);
break;
case VN_B_LAYER_REAL64 :
buffer_pos += vnp_raw_unpack_real64_vector(&buf[buffer_pos], tile.vreal64, VN_B_TILE_SIZE * VN_B_TILE_SIZE);
break;
}
if(func_b_tile_set != NULL && type <= VN_B_LAYER_REAL64)
func_b_tile_set(v_fs_get_user_data(83), node_id, layer_id, tile_x, tile_y, z, type, &tile);
return buffer_pos;
}
if(func_b_tile_set != NULL)
func_b_tile_set(v_fs_get_user_data(83), node_id, layer_id, tile_x, tile_y, z, (VNBLayerType)type, tile);
return buffer_pos;
}
typedef struct VTempText VTempText;
struct VTempText {
VNodeID node_id;
VBufferID buffer_id;
uint32 pos;
uint32 length;
uint16 index;
char *text;
VTempText *next;
};
typedef struct {
VTempText *text_temp;
uint16 text_send_id;
uint16 text_receive_id;
} VOrderedStorage;
VOrderedStorage * v_create_ordered_storage(void)
{
VOrderedStorage *s;
s = malloc(sizeof *s);
s->text_temp = NULL;
s->text_send_id = 0;
s->text_receive_id = 0;
return s;
}
void v_destroy_ordered_storage(VOrderedStorage *s)
{
VTempText *line, *next;
for(line = s->text_temp; line != NULL; line = next)
{
next = line->next;
if(line->text != NULL)
free(line->text);
free(line);
}
free(s);
}
void verse_send_t_text_set(VNodeID node_id, VBufferID buffer_id, uint32 pos, uint32 length, const char *text)
{
uint8 *buf;
VOrderedStorage *s;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 99);/* Packing the command */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_t_text_set(node_id = %u buffer_id = %u pos = %u length = %u text = %s );\n", node_id, buffer_id, pos, length, text);
#endif
s = v_con_get_ordered_storage();
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], pos);
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], length);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], s->text_send_id++);
if(text == NULL)
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);
else
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], text, VN_T_MAX_TEXT_CMD_SIZE);
v_cmd_buf_set_unique_address_size(head, buffer_pos);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
static void call_text_set(VTempText *line)
{
const char *t;
void (* func_t_text_set)(void *user_data, VNodeID node_id, VBufferID buffer_id, uint32 pos, uint16 length, const char *text);
func_t_text_set = v_fs_get_user_func(99);
#if defined V_PRINT_RECEIVE_COMMANDS
printf("receive: verse_send_t_text_set(node_id = %u buffer_id = %u pos = %u length = %u text = %s ); callback = %p\n", line->node_id, line->buffer_id, line->pos, line->length, line->text, v_fs_get_user_func(99));
#endif
if(line->text == NULL)
t = "";
else
t = line->text;
if(func_t_text_set != NULL)
func_t_text_set(v_fs_get_user_data(99), line->node_id, line->buffer_id, line->pos, line->length, t);
}
unsigned int v_unpack_t_text_set(const char *buf, size_t buffer_length)
{
unsigned int i, buffer_pos = 0;
VOrderedStorage *s;
VTempText l, *line, *past = NULL;
char text[1500];
if(buffer_length < 12)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &l.node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &l.buffer_id);
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &l.pos);
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &l.length);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &l.index);
buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], text, sizeof text, buffer_length - buffer_pos);
if(text[0] == 0)
l.text = NULL;
else
l.text = text;
s = v_con_get_ordered_storage();
if(s->text_receive_id == l.index)
{
call_text_set(&l);
s->text_receive_id++;
line = s->text_temp;
while(line != NULL)
{
if(line->index == s->text_receive_id)
{
call_text_set(line);
if(past == NULL)
s->text_temp = line->next;
else
past->next = line->next;
if(line->text != NULL)
free(line->text);
past = NULL;
free(line);
line = s->text_temp;
s->text_receive_id++;
}
else
{
past = line;
line = line->next;
}
}
}
else
{
line = malloc(sizeof *line);
*line = l;
line->next = s->text_temp;
s->text_temp = line;
i = strlen(text);
if(i > 0)
{
line->text = malloc(i + 1);
strcpy(line->text, text);
}
else
line->text = NULL;
}
return buffer_pos;
}
void verse_send_c_key_set(VNodeID node_id, VLayerID curve_id, uint32 key_id, uint8 dimensions,
const real64 *pre_value, const uint32 *pre_pos,
const real64 *value, real64 pos,
const real64 *post_value, const uint32 *post_pos)
{
uint8 *buf;
unsigned int i, buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
if(dimensions == 0 || dimensions > 4)
return;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 130);/* Packing the command */
#if defined V_PRINT_SEND_COMMANDS
switch(dimensions)
{
case 1:
printf("send: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = %f pre_pos = %u value = %f pos = %f, pre_value = %f pre_pos = %u ); callback = %p\n", node_id, curve_id, key_id, dimensions, pre_value[0], pre_pos[0], value[0], pos, pre_value[0], pre_pos[0], v_fs_get_user_func(130));
break;
case 2:
printf("sende: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f} pre_pos = {%u, %u} value = {%f, %f} pos = %f, pre_value = {%f, %f} pre_pos = {%u, %u}); callback = %p\n",
node_id, curve_id, key_id, dimensions,
pre_value[0], pre_value[1],
pre_pos[0], pre_pos[1],
value[0], value[1], pos,
pre_value[0], pre_value[1],
pre_pos[0], pre_pos[1], v_fs_get_user_func(130));
break;
case 3:
printf("send: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f, %f} pre_pos = {%u, %u, %u} value = {%f, %f, %f} pos = %f, pre_value = {%f, %f, %f} pre_pos = {%u, %u, %u}); callback = %p\n",
node_id, curve_id, key_id, dimensions,
pre_value[0], pre_value[1], pre_value[2],
pre_pos[0], pre_pos[1], pre_pos[2],
value[0], value[1], value[2], pos,
pre_value[0], pre_value[1], pre_value[2],
pre_pos[0], pre_pos[1], pre_pos[2], v_fs_get_user_func(130));
break;
case 4:
printf("send: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f, %f, %f} pre_pos = {%u, %u, %u, %u} value = {%f, %f, %f, %f} pos = %f, pre_value = {%f, %f, %f, %f} pre_pos = {%u, %u, %u, %u}); callback = %p\n",
node_id, curve_id, key_id, dimensions,
pre_value[0], pre_value[1], pre_value[2], pre_value[3],
pre_pos[0], pre_pos[1], pre_pos[2], pre_pos[3],
value[0], value[1], value[2], value[3], pos,
pre_value[0], pre_value[1], pre_value[2], pre_value[3],
pre_pos[0], pre_pos[1], pre_pos[2], pre_pos[3], v_fs_get_user_func(130));
break;
}
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id);
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], key_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], dimensions);
for(i = 0; i < dimensions; i++)
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pre_value[i]);
for(i = 0; i < dimensions; i++)
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], pre_pos[i]);
for(i = 0; i < dimensions; i++)
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], value[i]);
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos);
for(i = 0; i < dimensions; i++)
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], post_value[i]);
for(i = 0; i < dimensions; i++)
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], post_pos[i]);
if(key_id == (uint32) ~0u)
v_cmd_buf_set_unique_address_size(head, 11);
else
v_cmd_buf_set_address_size(head, 11);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
void verse_send_c_key_destroy(VNodeID node_id, VLayerID curve_id, uint32 key_id)
{
uint8 *buf;
unsigned int buffer_pos = 0;
VCMDBufHead *head;
head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
buf = ((VCMDBuffer10 *)head)->buf;
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 130);/* Packing the command */
#if defined V_PRINT_SEND_COMMANDS
printf("send: verse_send_c_key_destroy(node_id = %u curve_id = %u key_id = %u );\n", node_id, curve_id, key_id);
#endif
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id);
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], key_id);
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);
v_cmd_buf_set_address_size(head, 11);
v_cmd_buf_set_size(head, buffer_pos);
v_noq_send_buf(v_con_get_network_queue(), head);
}
unsigned int v_unpack_c_key_set(const char *buf, size_t buffer_length)
{
unsigned int i, buffer_pos = 0;
VNodeID node_id;
VLayerID curve_id;
uint32 key_id;
uint8 dimensions;
real64 pre_value[4], value[4], pos, post_value[4];
uint32 post_pos[4], pre_pos[4];
if(buffer_length < 11)
return -1;
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &curve_id);
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &key_id);
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &dimensions);
if(dimensions != 0 && dimensions < 5)
{
void (* func_c_key_set)(void *user_data, VNodeID node_id, VLayerID curve_id, uint32 key_id, uint8 dimensions, real64 *pre_value, uint32 *pre_pos, real64 *value, real64 pos, real64 *post_value, uint32 *post_pos);
for(i = 0; i < dimensions; i++)
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &pre_value[i]);
for(i = 0; i < dimensions; i++)
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &pre_pos[i]);
for(i = 0; i < dimensions; i++)
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &value[i]);
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &pos);
for(i = 0; i < dimensions; i++)
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &post_value[i]);
for(i = 0; i < dimensions; i++)
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &post_pos[i]);
#if defined V_PRINT_RECEIVE_COMMANDS
switch(dimensions)
{
case 1:
printf("receive: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = %f pre_pos = %u value = %f pos = %f, pre_value = %f pre_pos = %u ); callback = %p\n", node_id, curve_id, key_id, dimensions, pre_value[0], pre_pos[0], value[0], pos, pre_value[0], pre_pos[0], v_fs_get_user_func(130));
break;
case 2:
printf("receive: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f} pre_pos = {%u, %u} value = {%f, %f} pos = %f, pre_value = {%f, %f} pre_pos = {%u, %u}); callback = %p\n",
node_id, curve_id, key_id, dimensions,
pre_value[0], pre_value[1],
pre_pos[0], pre_pos[1],
value[0], value[1], pos,
pre_value[0], pre_value[1],
pre_pos[0], pre_pos[1], v_fs_get_user_func(130));
break;
case 3:
printf("receive: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f, %f} pre_pos = {%u, %u, %u} value = {%f, %f, %f} pos = %f, pre_value = {%f, %f, %f} pre_pos = {%u, %u, %u}); callback = %p\n",
node_id, curve_id, key_id, dimensions,
pre_value[0], pre_value[1], pre_value[2],
pre_pos[0], pre_pos[1], pre_pos[2],
value[0], value[1], value[2], pos,
pre_value[0], pre_value[1], pre_value[2],
pre_pos[0], pre_pos[1], pre_pos[2], v_fs_get_user_func(130));
break;
case 4:
printf("receive: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f, %f, %f} pre_pos = {%u, %u, %u, %u} value = {%f, %f, %f, %f} pos = %f, pre_value = {%f, %f, %f, %f} pre_pos = {%u, %u, %u, %u}); callback = %p\n",
node_id, curve_id, key_id, dimensions,
pre_value[0], pre_value[1], pre_value[2], pre_value[3],
pre_pos[0], pre_pos[1], pre_pos[2], pre_pos[3],
value[0], value[1], value[2], value[3], pos,
pre_value[0], pre_value[1], pre_value[2], pre_value[3],
pre_pos[0], pre_pos[1], pre_pos[2], pre_pos[3], v_fs_get_user_func(130));
break;
}
#endif
func_c_key_set = v_fs_get_user_func(130);
if(func_c_key_set != NULL)
func_c_key_set(v_fs_get_user_data(130), node_id, curve_id, key_id, dimensions, pre_value, pre_pos, value, pos, post_value, post_pos);
return buffer_pos;
}else
{
void (* alias_c_key_destroy)(void *user_data, VNodeID node_id, VLayerID curve_id, uint32 key_id);
alias_c_key_destroy = v_fs_get_alias_user_func(130);
printf("receive: verse_send_c_key_destroy(node_id = %u curve_id = %u key_id = %u); callback = %p\n", node_id, curve_id, key_id, alias_c_key_destroy);
if(alias_c_key_destroy != NULL)
alias_c_key_destroy(v_fs_get_alias_user_data(130), node_id, curve_id, key_id);
return buffer_pos;
}
}
#endif

@ -1,274 +0,0 @@
/*
**
*/
#if defined _WIN32
#include <winsock.h>
typedef unsigned int uint;
typedef SOCKET VSocket;
#else
typedef int VSocket;
#include <fcntl.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <signal.h>
#endif
#include <stdio.h>
#include <stdlib.h>
typedef unsigned int uint32;
typedef int int32;
typedef unsigned short uint16;
typedef short int16;
typedef unsigned char uint8;
typedef char int8;
typedef unsigned char boolean;
#include "v_cmd_gen.h"
#include "v_network.h"
#if !defined socklen_t
#define socklen_t int
#endif
#define TRUE 1
#define FALSE 0
typedef struct{
struct sockaddr_in address;
struct hostent *he;
} VNetworkConnection;
#define VERSE_STD_CONNECT_TO_PORT 4950
static VSocket my_socket = -1;
static uint16 my_port = 0;
void v_n_set_port(unsigned short port)
{
my_port = port;
}
VSocket v_n_socket_create(void)
{
static boolean initialized = FALSE;
struct sockaddr_in address;
int buffer_size = 1 << 20;
if(my_socket != -1)
return my_socket;
#if defined _WIN32
if(!initialized)
{
WSADATA wsaData;
if(WSAStartup(MAKEWORD(1, 1), &wsaData) != 0)
{
fprintf(stderr, "WSAStartup failed.\n");
exit(1);
}
}
#endif
initialized = TRUE;
if((my_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
return -1;
#if defined _WIN32
{
unsigned long one = 1UL;
if(ioctlsocket(my_socket, FIONBIO, &one) != 0)
return -1;
}
#else
if(fcntl(my_socket, F_SETFL, O_NONBLOCK) != 0)
{
fprintf(stderr, "v_network: Couldn't make socket non-blocking\n");
return -1;
}
#endif
address.sin_family = AF_INET; /* host byte order */
address.sin_port = htons(my_port); /* short, network byte order */
address.sin_addr.s_addr = INADDR_ANY;
if(bind(my_socket, (struct sockaddr *) &address, sizeof(struct sockaddr)) != 0)
{
fprintf(stderr, "v_network: Failed to bind(), code %d (%s)\n", errno, strerror(errno));
exit(0); /* FIX ME */
}
if(setsockopt(my_socket, SOL_SOCKET, SO_SNDBUF, (const char *) &buffer_size, sizeof buffer_size) != 0)
fprintf(stderr, "v_network: Couldn't set send buffer size of socket to %d\n", buffer_size);
if(setsockopt(my_socket, SOL_SOCKET, SO_RCVBUF, (const char *) &buffer_size, sizeof buffer_size) != 0)
fprintf(stderr, "v_network: Couldn't set receive buffer size of socket to %d\n", buffer_size);
return my_socket;
}
void v_n_socket_destroy(void)
{
#if defined _WIN32
closesocket(my_socket);
#else
close(my_socket);
#endif
my_socket = -1;
}
boolean v_n_set_network_address(VNetworkAddress *address, const char *host_name)
{
struct hostent *he;
char *colon = NULL, *buf = NULL;
boolean ok = FALSE;
v_n_socket_create();
address->port = VERSE_STD_CONNECT_TO_PORT;
/* If a port number is included, as indicated by a colon, we need to work a bit more. */
if((colon = strchr(host_name, ':')) != NULL)
{
size_t hl = strlen(host_name);
if((buf = malloc(hl + 1)) != NULL)
{
unsigned int tp;
strcpy(buf, host_name);
colon = buf + (colon - host_name);
*colon = '\0';
host_name = buf;
if(sscanf(colon + 1, "%u", &tp) == 1)
{
address->port = (unsigned short) tp;
if(address->port != tp) /* Protect against overflow. */
host_name = NULL;
}
else
host_name = NULL; /* Protect against parse error. */
}
else
return FALSE;
}
if(host_name != NULL && (he = gethostbyname(host_name)) != NULL)
{
memcpy(&address->ip, he->h_addr_list[0], he->h_length);
address->ip = ntohl(address->ip);
ok = TRUE;
}
if(buf != NULL)
free(buf);
return ok;
}
int v_n_send_data(VNetworkAddress *address, const char *data, size_t length)
{
struct sockaddr_in address_in;
VSocket sock;
int ret;
if((sock = v_n_socket_create()) == -1 || length == 0)
return 0;
address_in.sin_family = AF_INET; /* host byte order */
address_in.sin_port = htons(address->port); /* short, network byte order */
address_in.sin_addr.s_addr = htonl(address->ip);
memset(&address_in.sin_zero, 0, sizeof address_in.sin_zero);
ret = sendto(sock, data, length, 0, (struct sockaddr *) &address_in, sizeof(struct sockaddr_in));
if(ret < 0)
fprintf(stderr, "Socket sendto() of %u bytes failed, code %d (%s)\n", (unsigned int) length, errno, strerror(errno));
return ret;
}
#if !defined V_GENERATE_FUNC_MODE
extern void *v_con_get_network_address_id(unsigned int id);
extern unsigned int v_con_get_network_address_count();
unsigned int v_n_wait_for_incoming(unsigned int microseconds)
{
struct timeval tv;
fd_set fd_select;
unsigned int s1, f1, s2, f2;
if(microseconds == 0)
return 0;
v_n_socket_create();
tv.tv_sec = microseconds / 1000000;
tv.tv_usec = microseconds % 1000000;
FD_ZERO(&fd_select);
FD_SET(my_socket, &fd_select);
v_n_get_current_time(&s1, &f1);
select(1, &fd_select, NULL, NULL, &tv);
v_n_get_current_time(&s2, &f2);
return (unsigned int) (1000000 * (s2 - s1) + (1000000.0 / 0xffffffffu) * (long) (f2 - f1)); /* Must cast to (long) for f1 > f2 case! */
}
#endif
int v_n_receive_data(VNetworkAddress *address, char *data, size_t length)
{
struct sockaddr_in address_in;
socklen_t from_length = sizeof address_in;
size_t len;
if(v_n_socket_create() == -1)
return 0;
memset(&address_in, 0, sizeof address_in);
address_in.sin_family = AF_INET;
address_in.sin_port = htons(my_port);
address_in.sin_addr.s_addr = INADDR_ANY;
len = recvfrom(v_n_socket_create(), data, length, 0, (struct sockaddr *) &address_in, &from_length);
if(len > 0)
{
address->ip = ntohl(address_in.sin_addr.s_addr);
address->port = ntohs(address_in.sin_port);
}
return len;
}
#if defined _WIN32
void v_n_get_current_time(uint32 *seconds, uint32 *fractions)
{
static LARGE_INTEGER frequency;
static boolean init = FALSE;
LARGE_INTEGER counter;
if(!init)
{
init = TRUE;
QueryPerformanceFrequency(&frequency);
}
QueryPerformanceCounter(&counter);
if(seconds != NULL)
*seconds = (uint32) (counter.QuadPart / frequency.QuadPart);
if(fractions != NULL)
*fractions = (uint32) ((0xffffffffUL * (counter.QuadPart % frequency.QuadPart)) / frequency.QuadPart);
}
#else
void v_n_get_current_time(uint32 *seconds, uint32 *fractions)
{
struct timeval tv;
gettimeofday(&tv, NULL);
if(seconds != NULL)
*seconds = tv.tv_sec;
if(fractions != NULL)
*fractions = tv.tv_usec * 1E-6 * (double) (uint32)~0;
}
#endif
void v_n_get_address_string(const VNetworkAddress *address, char *string)
{
sprintf(string, "%u.%u.%u.%u:%u", address->ip >> 24, (address->ip >> 16) & 0xff,
(address->ip >> 8) & 0xff, address->ip & 0xff, address->port);
}

@ -1,24 +0,0 @@
/*
**
*/
#if !defined V_NETWORK_H
#define V_NETWORK_H
#define VERSE_STD_CONNECT_PORT 4950
typedef struct{
unsigned int ip;
unsigned short port;
}VNetworkAddress;
extern void v_n_set_port(unsigned short port);
extern unsigned int v_n_wait_for_incoming(unsigned int microseconds);
extern boolean v_n_set_network_address(VNetworkAddress *address, const char *host_name);
extern int v_n_send_data(VNetworkAddress *address, const char *data, size_t length);
extern int v_n_receive_data(VNetworkAddress *address, char *data, size_t length);
extern void v_n_get_address_string(const VNetworkAddress *address, char *string);
extern void v_n_get_current_time(unsigned int *seconds, unsigned int *fractions);
#endif /* V_NETWORK_H */

@ -1,140 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "verse_header.h"
#include "v_cmd_buf.h"
#include "v_cmd_gen.h"
#include "v_connection.h"
#include "v_internal_verse.h"
#include "v_network.h"
#include "v_pack.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "v_network_in_que.h"
static VNetInPacked *v_niq_temp = NULL;
void v_niq_clear(VNetInQueue *queue)
{
queue->oldest = NULL;
queue->newest = NULL;
queue->packet_id = 2;
v_niq_timer_update(queue);
}
/* Set queue's last-used timestamp to "now". */
void v_niq_timer_update(VNetInQueue *queue)
{
v_n_get_current_time(&queue->seconds, &queue->fractions);
queue->acc_seconds = queue->acc_fractions = 0;
}
uint32 v_niq_time_out(VNetInQueue *queue)
{
uint32 fractions, f;
/* Magic code to disregard if the clock moves forward more than one second at a time.
* This should help keep Verse alive on e.g. a notebook that is suspended.
*/
v_n_get_current_time(NULL, &fractions);
if(fractions < queue->fractions)
f = 0xffffffffu - queue->fractions + fractions;
else
f = fractions - queue->fractions;
/* printf("now=%u last=%u -> f=%u\n", fractions, queue->fractions, f);*/
if(queue->acc_fractions + f < queue->acc_fractions)
queue->acc_seconds += 1;
queue->acc_fractions += f;
queue->fractions = fractions;
/* printf("queue at %p has seconds=%u, now=%u -> diff=%u\n", queue, queue->seconds, seconds, seconds - queue->seconds);*/
return queue->acc_seconds;
}
VNetInPacked * v_niq_get(VNetInQueue *queue, size_t *length)
{
VNetInPacked *p;
if(queue->oldest == NULL)
{
*length = 0;
return NULL;
}
/* pop oldest package */
p = queue->oldest;
queue->oldest = p->newer;
if(queue->oldest == NULL)
queue->newest = NULL;
else
((VNetInPacked *)queue->oldest)->older = NULL;
*length = p->size;
return p;
}
unsigned int v_niq_free(VNetInQueue *queue)
{
unsigned int i;
size_t length;
for(i = 0; v_niq_get(queue, &length) != NULL; i++)
;
return i;
}
void v_niq_release(VNetInQueue *queue, VNetInPacked *p)
{
/* push on v_niq_temp for re-use */
p->older = v_niq_temp;
v_niq_temp = p;
}
char *v_niq_store(VNetInQueue *queue, size_t length, unsigned int packet_id)
{
VNetInPacked *p;
v_niq_timer_update(queue);
if(packet_id < queue->packet_id)
return NULL;
while(queue->packet_id != packet_id)
{
verse_send_packet_nak(queue->packet_id++);
if(queue->packet_id == 0)
queue->packet_id++;
}
queue->packet_id++;
if(queue->packet_id == 0)
queue->packet_id++;
verse_send_packet_ack(packet_id);
if(v_niq_temp == NULL)
p = malloc(sizeof *p);
else
{
/* pop off v_niq_temp */
p = v_niq_temp;
v_niq_temp = p->older;
}
/* push as newest */
p->older = queue->newest;
p->newer = NULL;
if(queue->newest == NULL)
queue->oldest = p;
else
((VNetInPacked *)queue->newest)->newer = p;
queue->newest = p;
p->size = length;
return p->data;
}
#endif

@ -1,24 +0,0 @@
typedef struct{
void *oldest;
void *newest;
uint32 packet_id;
uint32 seconds, fractions; /* Current time. */
uint32 acc_seconds, acc_fractions; /* Accumulated time. */
}VNetInQueue;
typedef struct{
void *newer;
void *older;
char data[1500];
size_t size;
}VNetInPacked;
extern void v_niq_clear(VNetInQueue *queue);
extern void v_niq_timer_update(VNetInQueue *queue);
extern VNetInPacked * v_niq_get(VNetInQueue *queue, size_t *length);
extern void v_niq_release(VNetInQueue *queue, VNetInPacked *p);
extern char * v_niq_store(VNetInQueue *queue, size_t length, unsigned int packet_id);
unsigned int v_niq_free(VNetInQueue *queue);
extern uint32 v_niq_time_out(VNetInQueue *queue);

@ -1,396 +0,0 @@
/*
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "verse_header.h"
#include "v_cmd_buf.h"
#include "v_cmd_gen.h"
#include "v_connection.h"
#include "v_network.h"
#include "v_pack.h"
#include "v_encryption.h"
#include "v_network_out_que.h"
#include "v_util.h"
#if !defined(V_GENERATE_FUNC_MODE)
#define STD_QUE_SIZE 64
#define V_NOQ_OPTIMIZATION_SLOTS 2048
#define V_NOQ_WINDOW_SIZE 100000
#define V_NOQ_MAX_SORTED_COMMANDS 5000
typedef struct{
void *next;
char *data;
size_t size;
} NetPacked;
struct VNetOutQueue{
uint8 packet_buffer[V_NOQ_MAX_PACKET_SIZE];
size_t packet_buffer_use;
NetPacked *packed;
NetPacked *last;
VCMDBufHead *unsent[V_NOQ_OPTIMIZATION_SLOTS];
VCMDBufHead *history[V_NOQ_OPTIMIZATION_SLOTS];
VCMDBufHead *ack_nak;
VCMDBufHead *unsorted;
VCMDBufHead *unsorted_end;
uint32 unsorted_count; /* debug only */
uint32 unsent_comands;
size_t unsent_size;
size_t sent_size;
unsigned int packet_id;
unsigned int slot;
uint32 seconds;
uint32 fractions;
};
size_t verse_session_get_size(void)
{
const VNetOutQueue *queue;
queue = v_con_get_network_queue();
return queue->unsent_size + queue->sent_size;
}
VNetOutQueue * v_noq_create_network_queue(void)
{
VNetOutQueue *queue;
unsigned int i;
queue = malloc(sizeof *queue);
for(i = 0; i < V_NOQ_OPTIMIZATION_SLOTS; i++)
{
queue->unsent[i] = NULL;
queue->history[i] = NULL;
}
queue->unsent_comands = 0;
queue->unsent_size = 0;
queue->sent_size = 0;
queue->packet_id = 2;
queue->slot = 0;
queue->packed = NULL;
queue->last = NULL;
queue->ack_nak = NULL;
queue->unsorted = NULL;
queue->unsorted_end = NULL;
queue->unsorted_count = 0;
queue->packet_buffer_use = 0;
v_n_get_current_time(&queue->seconds, &queue->fractions);
return queue;
}
unsigned int v_noq_get_next_out_packet_id(VNetOutQueue *queue)
{
queue->packet_id++;
if(queue->packet_id == 0)
queue->packet_id++;
return queue->packet_id;
}
void v_noq_destroy_network_queue(VNetOutQueue *queue)
{
VCMDBufHead *buf, *b;
unsigned int i;
for(i = 0; i < V_NOQ_OPTIMIZATION_SLOTS; i++)
{
for(buf = queue->history[i]; buf != NULL; buf = b)
{
b = buf->next;
v_cmd_buf_free(buf);
}
for(buf = queue->unsent[i]; buf != NULL; buf = b)
{
b = buf->next;
v_cmd_buf_free(buf);
}
}
for(buf = queue->unsorted; buf != NULL; buf = b)
{
b = buf->next;
v_cmd_buf_free(buf);
}
free(queue);
}
void v_noq_sort_and_collapse_buf(VNetOutQueue *queue, VCMDBufHead *buf)
{
VCMDBufHead *b, *last = NULL;
unsigned int slot;
slot = buf->address_sum % V_NOQ_OPTIMIZATION_SLOTS;
queue->unsent_size += buf->size;
queue->unsent_comands++;
if(queue->unsent[slot] != NULL)
{
for(b = queue->unsent[slot]; !v_cmd_buf_compare(buf, b) && b->next != NULL; b = b->next)
last = b;
if(v_cmd_buf_compare(buf, b)) /* found a command to replace */
{
queue->unsent_size -= b->size;
queue->unsent_comands--;
if(last != NULL) /* if its not the first */
last->next = buf;
else
queue->unsent[slot] = buf;
buf->next = b->next;
v_cmd_buf_free(b);
}else /* inserting the command last in queue */
{
buf->next = NULL;
b->next = buf;
}
}else /* inserting the first command */
{
queue->unsent[slot] = buf;
buf->next = NULL;
}
if(queue->history[slot] != NULL) /* if there is a history clear it from any commnds with same address */
{
last = NULL;
for(b = queue->history[slot]; b != NULL && !v_cmd_buf_compare(buf, b); b = b->next)
last = b;
if(b != NULL) /* found a command to replace */
{
if(last == NULL)
queue->history[slot] = b->next;
else
last->next = b->next;
queue->sent_size -= b->size;
v_cmd_buf_free(b);
}
}
}
void v_noq_send_buf(VNetOutQueue *queue, VCMDBufHead *buf)
{
static int count = 0;
/* if(queue->unsent_comands > V_NOQ_MAX_SORTED_COMMANDS)
{
*/ if(queue->unsorted == NULL)
{
queue->unsorted_end = buf;
queue->unsorted = buf;
}else
{
queue->unsorted_end->next = buf;
queue->unsorted_end = buf;
}
queue->unsorted_count++;
/* }else
v_noq_sort_and_colapse_buf(queue, buf);
*/ count = (count + 1) % 30;
if(count == 0)
{
v_con_network_listen();
v_noq_send_queue(queue, v_con_get_network_address());
}
}
void v_noq_sort_unsorted(VNetOutQueue *queue)
{
VCMDBufHead *buf;
while(queue->unsent_comands < V_NOQ_MAX_SORTED_COMMANDS && queue->unsorted != NULL)
{
buf = queue->unsorted;
if(queue->unsorted == queue->unsorted_end)
{
queue->unsorted_end = NULL;
queue->unsorted = NULL;
}else
{
queue->unsorted = buf->next;
buf->next = NULL;
}
queue->unsorted_count--;
v_noq_sort_and_collapse_buf(queue, buf);
}
}
boolean v_noq_send_queue(VNetOutQueue *queue, void *address)
{
static unsigned int my_counter = 0;
VCMDBufHead *buf;
unsigned int size;
uint8 *data;
uint32 seconds, fractions;
double delta;
data = queue->packet_buffer;
v_n_get_current_time(&seconds, &fractions);
delta = seconds - queue->seconds + (fractions - queue->fractions) / (double) 0xffffffff;
if(queue->unsorted != NULL)
v_noq_sort_unsorted(queue);
if(queue->unsent_size == 0 && delta < 1.0 && (queue->ack_nak == NULL || queue->ack_nak->next == NULL))
return FALSE;
if(delta > 3.0 && queue->unsent_size == 0 && queue->ack_nak == NULL && queue->packet_buffer_use != 0)
{
/* printf("A) re-sending last delta=%g\n", delta);*/
v_n_send_data(address, data, queue->packet_buffer_use);
queue->seconds = seconds;
queue->fractions = fractions;
return TRUE;
}
size = 4;
buf = queue->ack_nak;
while(buf != NULL && size + buf->size < V_NOQ_MAX_PACKET_SIZE)
{
vnp_raw_pack_uint32(data, queue->packet_id);
queue->ack_nak = buf->next;
buf->next = queue->history[queue->slot];
queue->history[queue->slot] = buf;
buf->packet = queue->packet_id;
v_e_data_encrypt_command(data, size, ((VCMDBuffer1500 *)buf)->buf, buf->size, v_con_get_data_key());
size += buf->size;
queue->sent_size += buf->size;
buf = queue->ack_nak;
}
if(queue->unsent_size == 0 || queue->sent_size >= V_NOQ_WINDOW_SIZE)
{
if(size > 5)
{
/* printf("ACK: sending actual size=%u id=%u\n", size, queue->packet_id);*/
v_n_send_data(address, data, size);
queue->packet_buffer_use = size;
queue->seconds = seconds;
queue->fractions = fractions;
queue->packet_id++;
return TRUE;
}
/* printf("returning FALSE from send_queue()\n");*/
return FALSE;
}
/* if(queue->sent_size < V_NOQ_WINDOW_SIZE && queue->unsent_size != 0)*/
{
vnp_raw_pack_uint32(data, queue->packet_id);
while(queue->unsent_size != 0)
{
queue->slot = ((1 + queue->slot) % V_NOQ_OPTIMIZATION_SLOTS);
buf = queue->unsent[queue->slot];
if(buf != NULL)
{
if(buf->size + size > V_NOQ_MAX_PACKET_SIZE)
break;
queue->unsent[queue->slot] = buf->next;
buf->next = queue->history[queue->slot];
queue->history[queue->slot] = buf;
buf->packet = queue->packet_id;
v_e_data_encrypt_command(data, size, ((VCMDBuffer1500 *)buf)->buf, buf->size, v_con_get_data_key());
size += buf->size;
queue->unsent_comands--;
queue->unsent_size -= buf->size;
queue->sent_size += buf->size;
my_counter++;
}
}
v_n_send_data(address, data, size);
queue->packet_buffer_use = size;
queue->packet_id++;
/* size = vnp_raw_pack_uint32(data, queue->packet_id);*/
queue->seconds = seconds;
queue->fractions = fractions;
}
return TRUE;
}
void v_noq_send_ack_nak_buf(VNetOutQueue *queue, VCMDBufHead *buf)
{
buf->next = queue->ack_nak;
queue->ack_nak = buf;
}
void callback_send_packet_ack(void *user, uint32 packet_id)
{
VNetOutQueue *queue;
VCMDBufHead *buf, *last;
unsigned int slot;
queue = v_con_get_network_queue();
for(slot = 0; slot < V_NOQ_OPTIMIZATION_SLOTS; slot++)
{
last = NULL;
for(buf = queue->history[slot]; buf != NULL && buf->packet != packet_id; buf = buf->next)
last = buf;
if(buf != NULL)
{
if(last == NULL)
{
while(queue->history[slot] != NULL && queue->history[slot]->packet == packet_id)
{
queue->sent_size -= queue->history[slot]->size;
buf = queue->history[slot]->next;
v_cmd_buf_free(queue->history[slot]);
queue->history[slot] = buf;
}
}else
{
for(; buf != NULL && buf->packet == packet_id; buf = last->next)
{
queue->sent_size -= buf->size;
last->next = buf->next;
v_cmd_buf_free(buf);
}
}
}
}
}
void callback_send_packet_nak(void *user, uint32 packet_id)
{
VNetOutQueue *queue;
VCMDBufHead *buf, *last;
unsigned int slot;
queue = v_con_get_network_queue();
for(slot = 0; slot < V_NOQ_OPTIMIZATION_SLOTS; slot++)
{
last = NULL;
for(buf = queue->history[slot]; buf != NULL && buf->packet != packet_id; buf = buf->next)
last = buf;
if(buf != NULL)
{
if(last == NULL)
{
for(; queue->history[slot] != NULL && queue->history[slot]->packet == packet_id; queue->history[slot] = buf)
{
queue->unsent_comands++;
queue->unsent_size += queue->history[slot]->size;
queue->sent_size -= queue->history[slot]->size;
buf = queue->history[slot]->next;
queue->history[slot]->next = queue->unsent[slot];
queue->unsent[slot] = queue->history[slot];
}
}else
{
for(; last->next != NULL && ((VCMDBufHead *)last->next)->packet == packet_id;)
{
queue->unsent_comands++;
queue->unsent_size += ((VCMDBufHead *)last->next)->size;
queue->sent_size -= ((VCMDBufHead *)last->next)->size;
buf = last->next;
last->next = buf->next;
buf->next = queue->unsent[slot];
queue->unsent[slot] = buf;
}
}
}
}
}
#endif

@ -1,17 +0,0 @@
/*
**
*/
typedef struct VNetOutQueue VNetOutQueue;
extern VNetOutQueue * v_noq_create_network_queue(void);
extern void v_noq_destroy_network_queue(VNetOutQueue *queue);
extern void v_noq_send_buf(VNetOutQueue *queue, VCMDBufHead *buf);
extern void v_noq_send_ack_nak_buf(VNetOutQueue *queue, VCMDBufHead *buf);
extern void v_noq_send_ack(VNetOutQueue *queue, unsigned int id);
extern void v_noq_send_nak(VNetOutQueue *queue, unsigned int id);
extern boolean v_noq_send_queue(VNetOutQueue *queue, void *address);
extern unsigned int v_noq_get_next_out_packet_id(VNetOutQueue *queue);

@ -1,386 +0,0 @@
/*
** v_pack.c
**
** These functions are used to pack and unpack various quantities to/from network
** packet buffers. They do not care about alignment, operating at byte level internally.
** The external byte-ordering used is big-endian (aka "network byte order") for all
** quantities larger than a single byte.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "v_pack.h"
size_t vnp_raw_pack_uint8(void *buffer, uint8 data)
{
*(uint8 *) buffer = data;
return sizeof data;
}
size_t vnp_raw_unpack_uint8(const void *buffer, uint8 *data)
{
*data = *(uint8 *) buffer;
return sizeof *data;
}
size_t vnp_raw_pack_uint8_vector(void *buffer, const uint8 *data, unsigned int length)
{
memcpy(buffer, data, length);
return length;
}
size_t vnp_raw_unpack_uint8_vector(const void *buffer, uint8 *data, unsigned int length)
{
memcpy(data, buffer, length);
return length;
}
size_t vnp_raw_pack_uint16(void *buffer, uint16 data)
{
*(uint8 *) buffer = (data & 0xFF00) >> 8;
*((uint8 *) buffer + 1) = data & 0xFF;
return sizeof data;
}
size_t vnp_raw_unpack_uint16(const void *buffer, uint16 *data)
{
register const uint8 *b = buffer;
register uint16 tmp;
tmp = ((uint16) *b++) << 8;
tmp |= (uint16) *b;
*data = tmp;
return sizeof *data;
}
size_t vnp_raw_pack_uint16_vector(void *buffer, const uint16 *data, unsigned int length)
{
register uint8 *b = buffer;
unsigned int i;
for(i = 0; i < length; i++)
{
*b++ = (*data & 0xFF00) >> 8;
*b++ = *data & 0xFF;
data++;
}
return length * 2;
}
size_t vnp_raw_unpack_uint16_vector(const void *buffer, uint16 *data, unsigned int length)
{
register const uint8 *b = buffer;
uint16 *end;
for(end = data + length; end != data; data++)
{
*data = ((uint16) *b++) << 8;
*data |= (uint16) *b++;
}
return length * 2;
}
size_t vnp_raw_pack_uint24(void *buffer, uint32 data)
{
register uint8 *p = buffer;
data >>= 8;
*(p++) = (data >> 24) & 0xFF;
*(p++) = (data >> 16) & 0xFF;
*(p++) = (data >> 8) & 0xFF;
return 3;
}
size_t vnp_raw_unpack_uint24(const void *buffer, uint32 *data)
{
register const uint8 *p = buffer;
register uint32 tmp = 0;
tmp |= ((uint32) *p++) << 24;
tmp |= ((uint32) *p++) << 16;
tmp |= ((uint32) *p++) << 8;
tmp |= tmp >> 24;
return 3;
}
size_t vnp_raw_pack_uint24_vector(void *buffer, const uint32 *data, unsigned int length)
{
register uint8 *b = buffer;
unsigned int i;
for(i = 0; i < length; i++)
{
*b++ = (*data >> 24) & 0xFF;
*b++ = (*data >> 16) & 0xFF;
*b++ = (*data >> 8) & 0xFF;
data++;
}
return length * 3;
}
size_t vnp_raw_unpack_uint24_vector(const void *buffer, uint32 *data, unsigned int length)
{
register const uint8 *b = buffer;
register uint32 tmp;
uint32 *end;
for(end = data + length; end != data; data++)
{
tmp = ((uint32) *b++) << 24;
tmp |= ((uint32) *b++) << 16;
tmp |= ((uint32) *b++) << 8;
tmp |= tmp >> 24;
*data = tmp;
}
return length * 3;
}
size_t vnp_raw_pack_uint32(void *buffer, uint32 data)
{
register uint8 *b = buffer;
*b++ = (data >> 24) & 0xFF;
*b++ = (data >> 16) & 0xFF;
*b++ = (data >> 8) & 0xFF;
*b++ = data & 0xFF;
return sizeof data;
}
size_t vnp_raw_unpack_uint32(const void *buffer, uint32 *data)
{
register const uint8 *b = buffer;
*data = ((uint32) *b++) << 24;
*data |= ((uint32) *b++) << 16;
*data |= ((uint32) *b++) << 8;
*data |= *b;
return sizeof *data;
}
size_t vnp_raw_pack_uint32_vector(void *buffer, const uint32 *data, unsigned int length)
{
register uint8 *b = buffer;
unsigned int i;
for(i = 0; i < length; i++)
{
*b++ = (*data >> 24) & 0xFF;
*b++ = (*data >> 16) & 0xFF;
*b++ = (*data >> 8) & 0xFF;
*b++ = *data & 0xFF;
data++;
}
return length * 4;
}
size_t vnp_raw_unpack_uint32_vector(const void *buffer, uint32 *data, unsigned int length)
{
register const uint8 *b = buffer;
uint32 *end;
for(end = data + length; end != data; data++)
{
*data = ((uint32) *b++) << 24;
*data |= ((uint32) *b++) << 16;
*data |= ((uint32) *b++) << 8;
*data |= ((uint32) *b++);
}
return length * 4;
}
size_t vnp_raw_pack_real32(void *buffer, real32 data)
{
union { uint32 uint; real32 real; } punt;
punt.real = data;
return vnp_raw_pack_uint32(buffer, punt.uint);
}
size_t vnp_raw_unpack_real32(const void *buffer, real32 *data)
{
return vnp_raw_unpack_uint32(buffer, (uint32 *) data);
}
size_t vnp_raw_pack_real32_vector(void *buffer, const real32 *data, unsigned int length)
{
uint32 i;
for(i = 0; i < length; i++)
vnp_raw_pack_real32(&((uint8 *)buffer)[i * 4], data[i]);
return length * 4;
}
size_t vnp_raw_unpack_real32_vector(const void *buffer, real32 *data, unsigned int length)
{
uint32 i;
for(i = 0; i < length; i++)
vnp_raw_unpack_real32(&((uint8 *)buffer)[i * 4], &data[i]);
return length * 4;
}
size_t vnp_raw_pack_real64(void *buffer, real64 data)
{
union { uint32 uint[2]; real64 real; } punt;
uint32 size;
punt.real = data;
size = vnp_raw_pack_uint32(buffer, punt.uint[0]);
buffer = (uint8 *) buffer + size;
size += vnp_raw_pack_uint32(buffer, punt.uint[1]);
return size;
}
size_t vnp_raw_unpack_real64(const void *buffer, real64 *data)
{
union { uint32 uint[2]; real64 real; } punt;
uint32 size;
size = vnp_raw_unpack_uint32(buffer, &punt.uint[0]);
size += vnp_raw_unpack_uint32(((uint8 *)buffer) + size, &punt.uint[1]);
*data = punt.real;
return size;
}
size_t vnp_raw_pack_real64_vector(void *buffer, const real64 *data, unsigned int length)
{
uint32 i;
for(i = 0; i < length; i++)
vnp_raw_pack_real64(&((uint8 *)buffer)[i * 8], data[i]);
return length * 8;
}
size_t vnp_raw_unpack_real64_vector(const void *buffer, real64 *data, unsigned int length)
{
uint32 i;
for(i = 0; i < length; i++)
vnp_raw_unpack_real64(&((uint8 *)buffer)[i * 8], &data[i]);
return length * 8;
}
size_t vnp_raw_pack_string(void *buffer, const char *string, size_t max_size)
{
unsigned int i = 0;
char *p = buffer;
if(string != 0)
for(; i < max_size && string[i] != 0; i++)
p[i] = string[i];
p[i] = 0;
return ++i;
}
size_t vnp_raw_unpack_string(const void *buffer, char *string, size_t max_size, size_t max_size2)
{
unsigned int i;
const char *p = buffer;
max_size--;
max_size2--;
for(i = 0; i < max_size && i < max_size2 && p[i] != 0; i++)
string[i] = p[i];
string[i] = 0;
return ++i;
}
/* --------------------------------------------------------------------------------------------------- */
size_t vnp_pack_quat32(void *buffer, const VNQuat32 *data)
{
uint8 *out = buffer;
if(data == NULL)
return 0;
out += vnp_raw_pack_real32(out, data->x);
out += vnp_raw_pack_real32(out, data->y);
out += vnp_raw_pack_real32(out, data->z);
out += vnp_raw_pack_real32(out, data->w);
return out - (uint8 *) buffer;
}
size_t vnp_unpack_quat32(const void *buffer, VNQuat32 *data)
{
const uint8 *in = buffer;
if(data == NULL)
return 0;
in += vnp_raw_unpack_real32(in, &data->x);
in += vnp_raw_unpack_real32(in, &data->y);
in += vnp_raw_unpack_real32(in, &data->z);
in += vnp_raw_unpack_real32(in, &data->w);
return in - (uint8 *) buffer;
}
size_t vnp_pack_quat64(void *buffer, const VNQuat64 *data)
{
uint8 *out = buffer;
if(data == NULL)
return 0;
out += vnp_raw_pack_real64(out, data->x);
out += vnp_raw_pack_real64(out, data->y);
out += vnp_raw_pack_real64(out, data->z);
out += vnp_raw_pack_real64(out, data->w);
return out - (uint8 *) buffer;
}
size_t vnp_unpack_quat64(const void *buffer, VNQuat64 *data)
{
const uint8 *in = buffer;
if(data == NULL)
return 0;
in += vnp_raw_unpack_real64(in, &data->x);
in += vnp_raw_unpack_real64(in, &data->y);
in += vnp_raw_unpack_real64(in, &data->z);
in += vnp_raw_unpack_real64(in, &data->w);
return in - (uint8 *) buffer;
}
size_t vnp_pack_audio_block(void *buffer, VNABlockType type, const VNABlock *block)
{
if(block == NULL)
return 0;
switch(type)
{
case VN_A_BLOCK_INT8:
return vnp_raw_pack_uint8_vector(buffer, block->vint8, sizeof block->vint8 / sizeof *block->vint8);
case VN_A_BLOCK_INT16:
return vnp_raw_pack_uint16_vector(buffer, block->vint16, sizeof block->vint16 / sizeof *block->vint16);
case VN_A_BLOCK_INT24:
return vnp_raw_pack_uint24_vector(buffer, block->vint24, sizeof block->vint24 / sizeof *block->vint24);
case VN_A_BLOCK_INT32:
return vnp_raw_pack_uint32_vector(buffer, block->vint32, sizeof block->vint32 / sizeof *block->vint32);
case VN_A_BLOCK_REAL32:
return vnp_raw_pack_real32_vector(buffer, block->vreal32, sizeof block->vreal32 / sizeof *block->vreal32);
case VN_A_BLOCK_REAL64:
return vnp_raw_pack_real64_vector(buffer, block->vreal64, sizeof block->vreal64 / sizeof *block->vreal64);
}
return 0;
}
size_t vnp_unpack_audio_block(const void *buffer, VNABlockType type, VNABlock *block)
{
if(block == NULL)
return 0;
switch(type)
{
case VN_A_BLOCK_INT8:
return vnp_raw_unpack_uint8_vector(buffer, block->vint8, sizeof block->vint8 / sizeof *block->vint8);
case VN_A_BLOCK_INT16:
return vnp_raw_unpack_uint16_vector(buffer, block->vint16, sizeof block->vint16 / sizeof *block->vint16);
case VN_A_BLOCK_INT24:
return vnp_raw_unpack_uint24_vector(buffer, block->vint24, sizeof block->vint24 / sizeof *block->vint24);
case VN_A_BLOCK_INT32:
return vnp_raw_unpack_uint32_vector(buffer, block->vint32, sizeof block->vint32 / sizeof *block->vint32);
case VN_A_BLOCK_REAL32:
return vnp_raw_unpack_real32_vector(buffer, block->vreal32, sizeof block->vreal32 / sizeof *block->vreal32);
case VN_A_BLOCK_REAL64:
return vnp_raw_unpack_real64_vector(buffer, block->vreal64, sizeof block->vreal64 / sizeof *block->vreal64);
}
return 0;
}

@ -1,59 +0,0 @@
/*
** v_pack.h
**
** These functions are used to pack and unpack various quantities to/from network
** packet buffers. They do not care about alignment, operating at byte level internally.
** The external byte-ordering used is big-endian (aka "network byte order") for all
** quantities larger than a single byte.
*/
#include "verse_header.h"
extern size_t vnp_raw_pack_uint8(void *buffer, uint8 data);
extern size_t vnp_raw_unpack_uint8(const void *buffer, uint8 *data);
extern size_t vnp_raw_pack_uint16(void *buffer, uint16 data);
extern size_t vnp_raw_unpack_uint16(const void *buffer, uint16 *data);
extern size_t vnp_raw_pack_uint24(void *buffer, uint32 data);
extern size_t vnp_raw_unpack_uint24(const void *buffer, uint32 *data);
extern size_t vnp_raw_pack_uint32(void *buffer, uint32 data);
extern size_t vnp_raw_unpack_uint32(const void *buffer, uint32 *data);
extern size_t vnp_raw_pack_real32(void *buffer, real32 data);
extern size_t vnp_raw_unpack_real32(const void *buffer, real32 *data);
extern size_t vnp_raw_pack_real64(void *buffer, real64 data);
extern size_t vnp_raw_unpack_real64(const void *buffer, real64 *data);
extern size_t vnp_raw_pack_string(void *buffer, const char *string, size_t max_size);
extern size_t vnp_raw_unpack_string(const void *buffer, char *string, size_t max_size, size_t max_size2);
extern size_t vnp_raw_pack_uint8_vector(void *buffer, const uint8 *data, unsigned int length);
extern size_t vnp_raw_unpack_uint8_vector(const void *buffer, uint8 *data, unsigned int length);
extern size_t vnp_raw_pack_uint16_vector(void *buffer, const uint16 *data, unsigned int length);
extern size_t vnp_raw_unpack_uint16_vector(const void *buffer, uint16 *data, unsigned int length);
extern size_t vnp_raw_pack_uint24_vector(void *buffer, const uint32 *data, unsigned int length);
extern size_t vnp_raw_unpack_uint24_vector(const void *buffer, uint32 *data, unsigned int length);
extern size_t vnp_raw_pack_uint32_vector(void *buffer, const uint32 *data, unsigned int length);
extern size_t vnp_raw_unpack_uint32_vector(const void *buffer, uint32 *data, unsigned int length);
extern size_t vnp_raw_pack_real32_vector(void *buffer, const real32 *data, unsigned int length);
extern size_t vnp_raw_unpack_real32_vector(const void *buffer, real32 *data, unsigned int length);
extern size_t vnp_raw_pack_real64_vector(void *buffer, const real64 *data, unsigned int length);
extern size_t vnp_raw_unpack_real64_vector(const void *buffer, real64 *data, unsigned int length);
/* --------------------------------------------------------------------------------------------------- */
extern size_t vnp_pack_quat32(void *buffer, const VNQuat32 *data);
extern size_t vnp_unpack_quat32(const void *buffer, VNQuat32 *data);
extern size_t vnp_pack_quat64(void *buffer, const VNQuat64 *data);
extern size_t vnp_unpack_quat64(const void *buffer, VNQuat64 *data);
extern size_t vnp_pack_audio_block(void *buffer, VNABlockType type, const VNABlock *block);
extern size_t vnp_unpack_audio_block(const void *buffer, VNABlockType type, VNABlock *block);

@ -1,219 +0,0 @@
/*
**
*/
#include <stdlib.h>
#include "v_cmd_gen.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "verse.h"
#include "v_pack.h"
VNOPackedParams * verse_method_call_pack(unsigned int param_count, const VNOParamType *param_type, const VNOParam *params)
{
unsigned int i, j, buffer_pos;
uint8 *buf;
buf = malloc(1500 + 8 * 16);
buffer_pos = vnp_raw_pack_uint16(buf, 0);
for(i = 0; i < param_count; i++)
{
switch(param_type[i])
{
case VN_O_METHOD_PTYPE_INT8 :
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], params[i].vint8);
break;
case VN_O_METHOD_PTYPE_INT16 :
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], params[i].vint16);
break;
case VN_O_METHOD_PTYPE_INT32 :
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], params[i].vint32);
break;
case VN_O_METHOD_PTYPE_UINT8 :
buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], params[i].vuint8);
break;
case VN_O_METHOD_PTYPE_UINT16 :
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], params[i].vuint16);
break;
case VN_O_METHOD_PTYPE_UINT32 :
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], params[i].vuint32);
break;
case VN_O_METHOD_PTYPE_REAL32 :
buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32);
break;
case VN_O_METHOD_PTYPE_REAL64 :
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64);
break;
case VN_O_METHOD_PTYPE_STRING :
buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], params[i].vstring, (1500 + 8 * 16) - buffer_pos);
break;
case VN_O_METHOD_PTYPE_NODE :
buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], params[i].vnode);
break;
case VN_O_METHOD_PTYPE_LAYER :
buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], params[i].vlayer);
break;
case VN_O_METHOD_PTYPE_REAL32_VEC2 :
for(j = 0; j < 2; j++)
buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32_vec[j]);
break;
case VN_O_METHOD_PTYPE_REAL32_VEC3 :
for(j = 0; j < 3; j++)
buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32_vec[j]);
break;
case VN_O_METHOD_PTYPE_REAL32_VEC4 :
for(j = 0; j < 4; j++)
buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32_vec[j]);
break;
case VN_O_METHOD_PTYPE_REAL64_VEC2 :
for(j = 0; j < 2; j++)
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64_vec[j]);
break;
case VN_O_METHOD_PTYPE_REAL64_VEC3 :
for(j = 0; j < 3; j++)
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64_vec[j]);
break;
case VN_O_METHOD_PTYPE_REAL64_VEC4 :
for(j = 0; j < 4; j++)
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64_vec[j]);
break;
case VN_O_METHOD_PTYPE_REAL32_MAT4 :
for(j = 0; j < 4; j++)
buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32_mat[j]);
break;
case VN_O_METHOD_PTYPE_REAL32_MAT9 :
for(j = 0; j < 9; j++)
buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32_mat[j]);
break;
case VN_O_METHOD_PTYPE_REAL32_MAT16 :
for(j = 0; j < 16; j++)
buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32_mat[j]);
break;
case VN_O_METHOD_PTYPE_REAL64_MAT4 :
for(j = 0; j < 4; j++)
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64_mat[j]);
break;
case VN_O_METHOD_PTYPE_REAL64_MAT9 :
for(j = 0; j < 9; j++)
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64_mat[j]);
break;
case VN_O_METHOD_PTYPE_REAL64_MAT16 :
for(j = 0; j < 16; j++)
buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64_mat[j]);
break;
}
if(buffer_pos > 1500)
{
free(buf);
return NULL;
}
}
vnp_raw_pack_uint16(buf, buffer_pos);
return buf;
}
boolean verse_method_call_unpack(const VNOPackedParams *data, unsigned int param_count, const VNOParamType *param_type, VNOParam *params)
{
unsigned int i, j, buffer_pos = 0, len;
uint16 size;
const uint8 *buf;
static char string[2048];
char *stringput = string;
buf = data;
buffer_pos += vnp_raw_unpack_uint16(buf, &size);
for(i = 0; i < param_count; i++)
{
switch(param_type[i])
{
case VN_O_METHOD_PTYPE_INT8 :
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &params[i].vint8);
break;
case VN_O_METHOD_PTYPE_INT16 :
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &params[i].vint16);
break;
case VN_O_METHOD_PTYPE_INT32 :
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &params[i].vint32);
break;
case VN_O_METHOD_PTYPE_UINT8 :
buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &params[i].vuint8);
break;
case VN_O_METHOD_PTYPE_UINT16 :
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &params[i].vuint16);
break;
case VN_O_METHOD_PTYPE_UINT32 :
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &params[i].vuint32);
break;
case VN_O_METHOD_PTYPE_REAL32 :
buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &params[i].vreal32);
break;
case VN_O_METHOD_PTYPE_REAL64 :
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &params[i].vreal64);
break;
case VN_O_METHOD_PTYPE_STRING :
params[i].vstring = stringput;
len = vnp_raw_unpack_string(&buf[buffer_pos], stringput, (1500 + 8 * 16) - buffer_pos, -1);
stringput += len;
buffer_pos += len;
break;
case VN_O_METHOD_PTYPE_NODE :
buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &params[i].vnode);
break;
case VN_O_METHOD_PTYPE_LAYER :
buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &params[i].vlayer);
break;
case VN_O_METHOD_PTYPE_REAL32_VEC2 :
for(j = 0; j < 2; j++)
buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &params[i].vreal32_vec[j]);
break;
case VN_O_METHOD_PTYPE_REAL32_VEC3 :
for(j = 0; j < 3; j++)
buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &params[i].vreal32_vec[j]);
break;
case VN_O_METHOD_PTYPE_REAL32_VEC4 :
for(j = 0; j < 4; j++)
buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &params[i].vreal32_vec[j]);
break;
case VN_O_METHOD_PTYPE_REAL64_VEC2 :
for(j = 0; j < 2; j++)
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &params[i].vreal64_vec[j]);
break;
case VN_O_METHOD_PTYPE_REAL64_VEC3 :
for(j = 0; j < 3; j++)
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &params[i].vreal64_vec[j]);
break;
case VN_O_METHOD_PTYPE_REAL64_VEC4 :
for(j = 0; j < 4; j++)
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &params[i].vreal64_vec[j]);
break;
case VN_O_METHOD_PTYPE_REAL32_MAT4 :
for(j = 0; j < 4; j++)
buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &params[i].vreal32_mat[j]);
break;
case VN_O_METHOD_PTYPE_REAL32_MAT9 :
for(j = 0; j < 9; j++)
buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &params[i].vreal32_mat[j]);
break;
case VN_O_METHOD_PTYPE_REAL32_MAT16 :
for(j = 0; j < 16; j++)
buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &params[i].vreal32_mat[j]);
break;
case VN_O_METHOD_PTYPE_REAL64_MAT4 :
for(j = 0; j < 4; j++)
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &params[i].vreal64_mat[j]);
break;
case VN_O_METHOD_PTYPE_REAL64_MAT9 :
for(j = 0; j < 9; j++)
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &params[i].vreal64_mat[j]);
break;
case VN_O_METHOD_PTYPE_REAL64_MAT16 :
for(j = 0; j < 16; j++)
buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &params[i].vreal64_mat[j]);
break;
}
}
return TRUE;
}
#endif

@ -1,165 +0,0 @@
/*
* Program to generate primes of the form p = 2 * q + 1,
* where p and q are both primes.
*
* Originally written by Pontus Nyman <f97-pny@nada.kth.se>,
* ported to Verse's bignums and rewritten from scratch by
* Emil Brink.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include "v_bignum.h"
#include "v_encryption.h"
#include "verse_header.h"
#define BITS V_ENCRYPTION_LOGIN_KEY_BITS /* Save some typing. */
#define CYCLES 10 /* Number of times to apply Miller-Rabin test. */
/* Test divisibility of <n> against table of small known primes. Returns 1 if n looks prime, 0 if it IS not. */
static int quick_filter(const VBigDig *n)
{
VBigDig VBIGNUM(m, 16), VBIGNUM(tmp, BITS / 2);
const unsigned int prime[] = { 3, 5, 7, 11, 13, 17, 19, 23, 39, 31, 37, 41, 43, 47, 53 };
unsigned int i;
for(i = 0; i < sizeof prime / sizeof *prime; i++)
{
v_bignum_set_bignum(tmp, n);
v_bignum_set_digit(m, prime[i]);
v_bignum_mod(tmp, m);
if(v_bignum_eq_zero(tmp))
return 0;
}
return 1;
}
/* The Miller-Rabin primality test. Returns 1 if the candidate looks prime, 0 if
* it IS NOT prime. Assumes that n is BITS / 2 bits, so that its square fits in BITS.
*/
static int miller_rabin(const VBigDig *n, VRandGen *gen)
{
int i, k;
VBigDig VBIGNUM(a, BITS / 2), VBIGNUM(d, BITS), VBIGNUM(nmo, BITS / 2), VBIGNUM(x, BITS);
const VBigDig *mu;
mu = v_bignum_reduce_begin(n);
/* Pick a "witness", a number in the [1, n) range. */
v_bignum_set_random(a, gen);
v_bignum_reduce(a, n, mu);
v_bignum_set_one(d);
v_bignum_set_bignum(nmo, n);
v_bignum_sub_digit(nmo, 1); /* nmo = n - 1 (say it). */
k = v_bignum_bit_msb(nmo);
for(i = k; i >= 0; i--)
{
v_bignum_set_bignum(x, d);
v_bignum_square_half(d);
v_bignum_reduce(d, n, mu);
if(v_bignum_eq_one(d) && !v_bignum_eq_one(x) && !v_bignum_eq(x, nmo))
{
v_bignum_reduce_end(mu);
return 0; /* Composite found. */
}
if(v_bignum_bit_test(nmo, i))
{
v_bignum_mul(d, a);
v_bignum_reduce(d, n, mu);
}
}
v_bignum_reduce_end(mu);
return v_bignum_eq_one(d); /* It might be prime. */
}
/* Test q for primality, returning 1 if it seems prime, 0 if it certainly IS not. */
int v_prime_test(const VBigDig *q, VRandGen *gen)
{
int i;
if(!quick_filter(q))
return 0;
for(i = 0; i < CYCLES; i++)
{
if(!miller_rabin(q, gen))
return 0;
}
return 1;
}
void v_prime_set_random(VBigDig *x)
{
int bits = v_bignum_bit_size(x);
VRandGen *gen;
gen = v_randgen_new();
do
{
/* Create candidate, making sure it's both odd and non-zero. */
v_bignum_set_random(x, gen);
/* Set topmost two bits, makes sure products are big. */
v_bignum_bit_set(x, bits - 1);
v_bignum_bit_set(x, bits - 2);
/* Set lowermost bit, makes sure it is odd (better prime candidate that way). */
v_bignum_bit_set(x, 0);
} while(!v_prime_test(x, gen));
/* printf("Prime found after %d iterations: ", count);
v_bignum_print_hex_lf(x);
*/
v_randgen_destroy(gen);
}
/* Big (small?) primes from <http://www.utm.edu/research/primes/lists/small/small3.html#300>. */
void v_prime_set_table(VBigDig *x, unsigned int i)
{
if(i == 0)
v_bignum_set_string_hex(x, "0xCBC2C5536E3D6283FDAF36B1D0F91C3EAAB1D12892B961B866907930F6471851");
else if(i == 1)
v_bignum_set_string_hex(x, "0xC14F93E7A1543BD57C1DFBE98C29F9E4C13077FD27A0FEC05CCBC913CD213F19");
else
v_bignum_set_string(x, "65537"); /* It ain't big, but it's prime. */
}
#if PRIMEALONE
#include <sys/time.h>
#define REPS 300
static double elapsed(const struct timeval *t1, const struct timeval *t2)
{
return t2->tv_sec - t1->tv_sec + 1E-6 * (t2->tv_usec - t1->tv_usec);
}
int main(void)
{
struct timeval now, then;
VBigDig VBIGNUM(x, BITS / 2);
int i;
srand(clock());
/* gettimeofday(&then, NULL);
for(i = 0; i < REPS; i++)
{
v_prime_set_random_incr(x);
}
gettimeofday(&now, NULL);
printf("incr: %g\n", elapsed(&then, &now));
*/
gettimeofday(&then, NULL);
for(i = 0; i < REPS; i++)
{
v_prime_set_random(x);
}
gettimeofday(&now, NULL);
printf("rand: %g\n", elapsed(&then, &now));
return EXIT_SUCCESS;
}
#endif

@ -1,101 +0,0 @@
/*
* Random number generator module. Defines a simple API to allocate, use and
* destroy a generator of randomness. Relies on platform-specific APIs.
*/
#include <stdio.h>
#include <stdlib.h>
#include "v_randgen.h"
#if defined _WIN32
/* This is a fall-back to the old style of simply using rand(). It should
* be replaced by something using the proper Win32 cryptography APIs.
* The CryptAcquireContext() and CryptGenRandom() calls sound interesting.
*
* FIXME: Replace ASAP.
*/
VRandGen * v_randgen_new(void)
{
return (VRandGen *) 1; /* Anything that isn't NULL. */
}
void v_randgen_get(VRandGen *gen, void *bytes, size_t num)
{
if(gen != NULL && bytes != NULL)
{
unsigned char *put = bytes, *get;
size_t i;
int x;
while(num > 0)
{
x = rand();
get = (unsigned char *) &x;
for(i = 0; i < sizeof x && num > 0; i++, num--)
*put++ = *get++;
}
}
}
void v_randgen_destroy(VRandGen *gen)
{
/* Nothing to do here. */
}
#else
/* On non-Win32 platforms (which is Linux and Darwin, at the moment), we
* read random data from a file, which is assumed to be one of the kernel's
* virtual files.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
struct VRandGen {
int fd;
};
#define SOURCE "/dev/urandom" /* Name of file to read random bits from. */
VRandGen * v_randgen_new(void)
{
VRandGen *gen;
if((gen = malloc(sizeof *gen)) != NULL)
{
gen->fd = open(SOURCE, O_RDONLY);
if(gen->fd < 0)
{
fprintf(stderr, __FILE__ ": Couldn't open " SOURCE " for reading\n");
free(gen);
gen = NULL;
}
}
return gen;
}
void v_randgen_get(VRandGen *gen, void *bytes, size_t num)
{
if(gen != NULL && bytes != NULL)
{
if(read(gen->fd, bytes, num) != (int) num)
fprintf(stderr, __FILE__ ": Failed to read %u bytes of random data from " SOURCE "\n", (unsigned int) num);
}
}
void v_randgen_destroy(VRandGen *gen)
{
if(gen != NULL)
{
close(gen->fd);
free(gen);
}
}
#endif

@ -1,14 +0,0 @@
/*
* Random number generator API. A way to improve over rand().
*/
#if !defined V_RANDGEN_H
#define V_RANDGEN_H
typedef struct VRandGen VRandGen;
extern VRandGen * v_randgen_new(void);
extern void v_randgen_get(VRandGen *gen, void *bytes, size_t num);
extern void v_randgen_destroy(VRandGen *gen);
#endif /* V_RANDGEN_H */

@ -1,98 +0,0 @@
/*
* Utility functions.
*/
#include <stdio.h>
#include "verse_header.h"
#include "v_network.h"
#include "v_util.h"
/* Safe string copy. Copies from <src> to <dst>, not using more than <size>
* bytes of destination space. Always 0-terminates the destination. Returns
* the beginning of the destination string.
*/
char * v_strlcpy(char *dst, const char *src, size_t size)
{
char *base = dst;
if(size == 0)
return NULL;
for(size--; size > 0 && *src != '\0'; size--)
*dst++ = *src++;
*dst = '\0';
return base;
}
void v_timer_start(VUtilTimer *timer)
{
v_n_get_current_time(&timer->seconds, &timer->fractions);
}
void v_timer_advance(VUtilTimer *timer, double seconds)
{
if(timer == NULL)
return;
timer->seconds += (uint32) seconds;
timer->fractions += (uint32) ((seconds - (int) seconds) * (double) 0xffffffff);
}
double v_timer_elapsed(const VUtilTimer *timer)
{
uint32 cur_seconds, cur_fractions;
v_n_get_current_time(&cur_seconds, &cur_fractions);
return (double)(cur_seconds - timer->seconds) + ((double)cur_fractions - (double)timer->fractions) / (double) 0xffffffff;
}
void v_timer_print(const VUtilTimer *timer)
{
uint32 cur_seconds, cur_fractions;
v_n_get_current_time(&cur_seconds, &cur_fractions);
printf("%f", (double)(cur_seconds - timer->seconds) + ((double)cur_fractions - (double)timer->fractions) / (double) 0xffffffff);
}
/* Compare |x| against built-in semi-magical constant, and return 1 if it's larger, 0 if not. */
static int quat_valid(real64 x)
{
const real64 EPSILON = 0.0000001;
return x > 0.0 ? x > EPSILON : x < -EPSILON;
}
int v_quat32_valid(const VNQuat32 *q)
{
if(q == NULL)
return 0;
return quat_valid(q->x) && quat_valid(q->y) && quat_valid(q->z) && quat_valid(q->w);
}
int v_quat64_valid(const VNQuat64 *q)
{
if(q == NULL)
return 0;
return quat_valid(q->x) && quat_valid(q->y) && quat_valid(q->z) && quat_valid(q->w);
}
VNQuat32 * v_quat32_from_quat64(VNQuat32 *dst, const VNQuat64 *src)
{
if(dst == NULL || src == NULL)
return NULL;
dst->x = (real32) src->x;
dst->y = (real32) src->y;
dst->z = (real32) src->z;
dst->w = (real32) src->w;
return dst;
}
VNQuat64 * v_quat64_from_quat32(VNQuat64 *dst, const VNQuat32 *src)
{
if(dst == NULL || src == NULL)
return NULL;
dst->x = src->x;
dst->y = src->y;
dst->z = src->z;
dst->w = src->w;
return dst;
}

@ -1,21 +0,0 @@
/*
* Miscellaneous utility routines for generic use throughout the code.
*/
/* Safe, buffer size limited, string copy. */
extern char * v_strlcpy(char *dst, const char *src, size_t size);
typedef struct {
uint32 seconds;
uint32 fractions;
} VUtilTimer;
extern void v_timer_start(VUtilTimer *timer);
extern void v_timer_advance(VUtilTimer *timer, double seconds);
extern double v_timer_elapsed(const VUtilTimer *timer);
extern void v_timer_print(const VUtilTimer *timer);
extern int v_quat32_valid(const VNQuat32 *q);
extern int v_quat64_valid(const VNQuat64 *q);
extern VNQuat32*v_quat32_from_quat64(VNQuat32 *dst, const VNQuat64 *src);
extern VNQuat64*v_quat64_from_quat32(VNQuat64 *dst, const VNQuat32 *src);

@ -1,530 +0,0 @@
/*
** Verse API Header file (for use with libverse.a).
** This is automatically generated code; do not edit.
*/
#if !defined VERSE_H
#if defined __cplusplus /* Declare as C symbols for C++ users. */
extern "C" {
#endif
#define VERSE_H
#if !defined VERSE_TYPES
#define VERSE_TYPES
#include <stdlib.h>
/* Release information. */
#define V_RELEASE_NUMBER 6
#define V_RELEASE_PATCH 1
#define V_RELEASE_LABEL ""
typedef unsigned char boolean;
typedef signed char int8;
typedef unsigned char uint8;
typedef short int16;
typedef unsigned short uint16;
typedef int int32;
typedef unsigned int uint32;
typedef float real32;
typedef double real64;
#define V_REAL64_MAX 1.7976931348623158e+308
#define V_REAL32_MAX 3.402823466e+38f
#if !defined TRUE
#define TRUE 1
#define FALSE 0
#endif
#define V_HOST_ID_SIZE (3 * (512 / 8)) /* The size of host IDs (keys), in 8-bit bytes. */
typedef enum {
V_NT_OBJECT = 0,
V_NT_GEOMETRY,
V_NT_MATERIAL,
V_NT_BITMAP,
V_NT_TEXT,
V_NT_CURVE,
V_NT_AUDIO,
V_NT_NUM_TYPES,
V_NT_SYSTEM = V_NT_NUM_TYPES,
V_NT_NUM_TYPES_NETPACK
} VNodeType;
typedef uint32 VNodeID;
typedef uint16 VLayerID; /* Commonly used to identify layers, nodes that have them. */
typedef uint16 VBufferID; /* Commonly used to identify buffers, nodes that have them. */
typedef uint16 VNMFragmentID;
typedef void * VSession;
#define V_MAX_NAME_LENGTH_SHORT 16
#define V_MAX_NAME_LENGTH_LONG 48
#define V_MAX_NAME_PASS_LENGTH 128
typedef enum {
VN_OWNER_OTHER = 0,
VN_OWNER_MINE
} VNodeOwner;
typedef enum {
VN_O_METHOD_PTYPE_INT8 = 0,
VN_O_METHOD_PTYPE_INT16,
VN_O_METHOD_PTYPE_INT32,
VN_O_METHOD_PTYPE_UINT8,
VN_O_METHOD_PTYPE_UINT16,
VN_O_METHOD_PTYPE_UINT32,
VN_O_METHOD_PTYPE_REAL32,
VN_O_METHOD_PTYPE_REAL64,
VN_O_METHOD_PTYPE_REAL32_VEC2,
VN_O_METHOD_PTYPE_REAL32_VEC3,
VN_O_METHOD_PTYPE_REAL32_VEC4,
VN_O_METHOD_PTYPE_REAL64_VEC2,
VN_O_METHOD_PTYPE_REAL64_VEC3,
VN_O_METHOD_PTYPE_REAL64_VEC4,
VN_O_METHOD_PTYPE_REAL32_MAT4,
VN_O_METHOD_PTYPE_REAL32_MAT9,
VN_O_METHOD_PTYPE_REAL32_MAT16,
VN_O_METHOD_PTYPE_REAL64_MAT4,
VN_O_METHOD_PTYPE_REAL64_MAT9,
VN_O_METHOD_PTYPE_REAL64_MAT16,
VN_O_METHOD_PTYPE_STRING,
VN_O_METHOD_PTYPE_NODE,
VN_O_METHOD_PTYPE_LAYER
} VNOParamType;
typedef union {
int8 vint8;
int16 vint16;
int32 vint32;
uint8 vuint8;
uint16 vuint16;
uint32 vuint32;
real32 vreal32;
real64 vreal64;
real32 vreal32_vec[4];
real32 vreal32_mat[16];
real64 vreal64_vec[4];
real64 vreal64_mat[16];
char *vstring;
VNodeID vnode;
VLayerID vlayer;
} VNOParam;
#define VN_TAG_MAX_BLOB_SIZE 500
typedef enum {
VN_TAG_BOOLEAN = 0,
VN_TAG_UINT32,
VN_TAG_REAL64,
VN_TAG_STRING,
VN_TAG_REAL64_VEC3,
VN_TAG_LINK,
VN_TAG_ANIMATION,
VN_TAG_BLOB,
VN_TAG_TYPE_COUNT
} VNTagType;
typedef enum {
VN_TAG_GROUP_SIZE = 16,
VN_TAG_NAME_SIZE = 16,
VN_TAG_FULL_NAME_SIZE = 64,
VN_TAG_STRING_SIZE = 128
} VNTagConstants;
typedef union {
boolean vboolean;
uint32 vuint32;
real64 vreal64;
char *vstring;
real64 vreal64_vec3[3];
VNodeID vlink;
struct {
VNodeID curve;
uint32 start;
uint32 end;
} vanimation;
struct {
uint16 size;
void *blob;
} vblob;
} VNTag;
typedef enum {
VN_S_CONNECT_NAME_SIZE = 32,
VN_S_CONNECT_KEY_SIZE = 4,
VN_S_CONNECT_DATA_SIZE = 32,
VS_S_CONNECT_HOSTID_PRIVATE_SIZE = 3 * 2048 / 8,
VS_S_CONNECT_HOSTID_PUBLIC_SIZE = 2 * 2048 / 8
} VNSConnectConstants;
typedef enum {
VN_FORMAT_REAL32,
VN_FORMAT_REAL64
} VNRealFormat;
typedef struct {
real32 x, y, z, w;
} VNQuat32;
typedef struct {
real64 x, y, z, w;
} VNQuat64;
typedef enum {
VN_O_METHOD_GROUP_NAME_SIZE = 16,
VN_O_METHOD_NAME_SIZE = 16,
VN_O_METHOD_SIG_SIZE = 256
} VNOMethodConstants;
typedef void VNOPackedParams; /* Opaque type. */
typedef enum {
VN_G_LAYER_VERTEX_XYZ = 0,
VN_G_LAYER_VERTEX_UINT32,
VN_G_LAYER_VERTEX_REAL,
VN_G_LAYER_POLYGON_CORNER_UINT32 = 128,
VN_G_LAYER_POLYGON_CORNER_REAL,
VN_G_LAYER_POLYGON_FACE_UINT8,
VN_G_LAYER_POLYGON_FACE_UINT32,
VN_G_LAYER_POLYGON_FACE_REAL
} VNGLayerType;
typedef enum {
VN_M_LIGHT_DIRECT = 0,
VN_M_LIGHT_AMBIENT,
VN_M_LIGHT_DIRECT_AND_AMBIENT,
VN_M_LIGHT_BACK_DIRECT,
VN_M_LIGHT_BACK_AMBIENT,
VN_M_LIGHT_BACK_DIRECT_AND_AMBIENT
} VNMLightType;
typedef enum {
VN_M_NOISE_PERLIN_ZERO_TO_ONE = 0,
VN_M_NOISE_PERLIN_MINUS_ONE_TO_ONE,
VN_M_NOISE_POINT_ZERO_TO_ONE,
VN_M_NOISE_POINT_MINUS_ONE_TO_ONE
} VNMNoiseType;
typedef enum {
VN_M_RAMP_SQUARE = 0,
VN_M_RAMP_LINEAR,
VN_M_RAMP_SMOOTH
} VNMRampType;
typedef enum {
VN_M_RAMP_RED = 0,
VN_M_RAMP_GREEN,
VN_M_RAMP_BLUE
} VNMRampChannel;
typedef struct {
real64 pos;
real64 red;
real64 green;
real64 blue;
} VNMRampPoint;
typedef enum {
VN_M_BLEND_FADE = 0,
VN_M_BLEND_ADD,
VN_M_BLEND_SUBTRACT,
VN_M_BLEND_MULTIPLY,
VN_M_BLEND_DIVIDE,
} VNMBlendType;
typedef enum {
VN_M_FT_COLOR = 0,
VN_M_FT_LIGHT,
VN_M_FT_REFLECTION,
VN_M_FT_TRANSPARENCY,
VN_M_FT_VOLUME,
VN_M_FT_VIEW,
VN_M_FT_GEOMETRY,
VN_M_FT_TEXTURE,
VN_M_FT_NOISE,
VN_M_FT_BLENDER,
VN_M_FT_CLAMP,
VN_M_FT_MATRIX,
VN_M_FT_RAMP,
VN_M_FT_ANIMATION,
VN_M_FT_ALTERNATIVE,
VN_M_FT_OUTPUT
} VNMFragmentType;
typedef union {
struct {
real64 red;
real64 green;
real64 blue;
} color;
struct {
uint8 type;
real64 normal_falloff;
VNodeID brdf;
char brdf_r[16];
char brdf_g[16];
char brdf_b[16];
} light;
struct {
real64 normal_falloff;
} reflection;
struct {
real64 normal_falloff;
real64 refraction_index;
} transparency;
struct {
real64 diffusion;
real64 col_r;
real64 col_g;
real64 col_b;
} volume;
struct {
char layer_r[16];
char layer_g[16];
char layer_b[16];
} geometry;
struct{
VNodeID bitmap;
char layer_r[16];
char layer_g[16];
char layer_b[16];
boolean filtered;
VNMFragmentID mapping;
} texture;
struct {
uint8 type;
VNMFragmentID mapping;
} noise;
struct {
uint8 type;
VNMFragmentID data_a;
VNMFragmentID data_b;
VNMFragmentID control;
} blender;
struct {
boolean min;
real64 red;
real64 green;
real64 blue;
VNMFragmentID data;
} clamp;
struct {
real64 matrix[16];
VNMFragmentID data;
} matrix;
struct {
uint8 type;
uint8 channel;
VNMFragmentID mapping;
uint8 point_count;
VNMRampPoint ramp[48];
} ramp;
struct {
char label[16];
} animation;
struct {
VNMFragmentID alt_a;
VNMFragmentID alt_b;
} alternative;
struct {
char label[16];
VNMFragmentID front;
VNMFragmentID back;
} output;
} VMatFrag;
typedef enum {
VN_B_LAYER_UINT1 = 0,
VN_B_LAYER_UINT8,
VN_B_LAYER_UINT16,
VN_B_LAYER_REAL32,
VN_B_LAYER_REAL64
} VNBLayerType;
#define VN_B_TILE_SIZE 8
typedef union{
uint8 vuint1[8];
uint8 vuint8[64];
uint16 vuint16[64];
real32 vreal32[64];
real64 vreal64[64];
} VNBTile;
typedef enum {
VN_T_CONTENT_LANGUAGE_SIZE = 32,
VN_T_CONTENT_INFO_SIZE = 256,
VN_T_BUFFER_NAME_SIZE = 16,
VN_T_MAX_TEXT_CMD_SIZE = 1450
} VNTConstants;
/* This is how many *samples* are included in a block of the given type. Not bytes. */
typedef enum {
VN_A_BLOCK_SIZE_INT8 = 1024,
VN_A_BLOCK_SIZE_INT16 = 512,
VN_A_BLOCK_SIZE_INT24 = 384,
VN_A_BLOCK_SIZE_INT32 = 256,
VN_A_BLOCK_SIZE_REAL32 = 256,
VN_A_BLOCK_SIZE_REAL64 = 128
} VNAConstants;
typedef enum {
VN_A_BLOCK_INT8,
VN_A_BLOCK_INT16,
VN_A_BLOCK_INT24,
VN_A_BLOCK_INT32,
VN_A_BLOCK_REAL32,
VN_A_BLOCK_REAL64
} VNABlockType;
/* Audio commands take pointers to blocks of these. They are not packed as unions. */
typedef union {
int8 vint8[VN_A_BLOCK_SIZE_INT8];
int16 vint16[VN_A_BLOCK_SIZE_INT16];
int32 vint24[VN_A_BLOCK_SIZE_INT24];
int32 vint32[VN_A_BLOCK_SIZE_INT32];
real32 vreal32[VN_A_BLOCK_SIZE_REAL32];
real64 vreal64[VN_A_BLOCK_SIZE_REAL64];
} VNABlock;
extern void verse_set_port(uint16 port);
extern void verse_host_id_create(uint8 *id);
extern void verse_host_id_set(uint8 *id);
extern void verse_callback_set(void *send_func, void *callback, void *user_data);
extern void verse_callback_update(uint32 microseconds);
extern void verse_session_set(VSession session);
extern VSession verse_session_get(void);
extern void verse_session_destroy(VSession session);
extern size_t verse_session_get_size(void);
extern VNodeID verse_session_get_avatar(void);
extern void verse_session_get_time(uint32 *seconds, uint32 *fractions);
extern VNOPackedParams * verse_method_call_pack(uint32 param_count, const VNOParamType *param_type, const VNOParam *params);
extern boolean verse_method_call_unpack(const VNOPackedParams *data, uint32 param_count, const VNOParamType *param_type, VNOParam *params);
/*
#define V_PRINT_SEND_COMMANDS
#define V_PRINT_RECEIVE_COMMANDS
*/
#endif /* VERSE_TYPES */
/* Command sending functions begin. ----------------------------------------- */
extern VSession verse_send_connect(const char *name, const char *pass, const char *address, const uint8 *expected_host_id);
extern VSession verse_send_connect_accept(VNodeID avatar, const char *address, uint8 *host_id);
extern void verse_send_connect_terminate(const char *address, const char *bye);
extern void verse_send_ping(const char *address, const char *message);
extern void verse_send_node_index_subscribe(uint32 mask);
extern void verse_send_node_create(VNodeID node_id, VNodeType type, VNodeOwner owner);
extern void verse_send_node_destroy(VNodeID node_id);
extern void verse_send_node_subscribe(VNodeID node_id);
extern void verse_send_node_unsubscribe(VNodeID node_id);
extern void verse_send_tag_group_create(VNodeID node_id, uint16 group_id, const char *name);
extern void verse_send_tag_group_destroy(VNodeID node_id, uint16 group_id);
extern void verse_send_tag_group_subscribe(VNodeID node_id, uint16 group_id);
extern void verse_send_tag_group_unsubscribe(VNodeID node_id, uint16 group_id);
extern void verse_send_tag_create(VNodeID node_id, uint16 group_id, uint16 tag_id, const char *name, VNTagType type, const VNTag *tag);
extern void verse_send_tag_destroy(VNodeID node_id, uint16 group_id, uint16 tag_id);
extern void verse_send_node_name_set(VNodeID node_id, const char *name);
extern void verse_send_o_transform_pos_real32(VNodeID node_id, uint32 time_s, uint32 time_f, const real32 *pos, const real32 *speed, const real32 *accelerate, const real32 *drag_normal, real32 drag);
extern void verse_send_o_transform_rot_real32(VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat32 *rot, const VNQuat32 *speed, const VNQuat32 *accelerate, const VNQuat32 *drag_normal, real32 drag);
extern void verse_send_o_transform_scale_real32(VNodeID node_id, real32 scale_x, real32 scale_y, real32 scale_z);
extern void verse_send_o_transform_pos_real64(VNodeID node_id, uint32 time_s, uint32 time_f, const real64 *pos, const real64 *speed, const real64 *accelerate, const real64 *drag_normal, real64 drag);
extern void verse_send_o_transform_rot_real64(VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat64 *rot, const VNQuat64 *speed, const VNQuat64 *accelerate, const VNQuat64 *drag_normal, real64 drag);
extern void verse_send_o_transform_scale_real64(VNodeID node_id, real64 scale_x, real64 scale_y, real64 scale_z);
extern void verse_send_o_transform_subscribe(VNodeID node_id, VNRealFormat type);
extern void verse_send_o_transform_unsubscribe(VNodeID node_id, VNRealFormat type);
extern void verse_send_o_light_set(VNodeID node_id, real64 light_r, real64 light_g, real64 light_b);
extern void verse_send_o_link_set(VNodeID node_id, uint16 link_id, VNodeID link, const char *label, uint32 target_id);
extern void verse_send_o_link_destroy(VNodeID node_id, uint16 link_id);
extern void verse_send_o_method_group_create(VNodeID node_id, uint16 group_id, const char *name);
extern void verse_send_o_method_group_destroy(VNodeID node_id, uint16 group_id);
extern void verse_send_o_method_group_subscribe(VNodeID node_id, uint16 group_id);
extern void verse_send_o_method_group_unsubscribe(VNodeID node_id, uint16 group_id);
extern void verse_send_o_method_create(VNodeID node_id, uint16 group_id, uint16 method_id, const char *name, uint8 param_count, const VNOParamType *param_types, const char * *param_names);
extern void verse_send_o_method_destroy(VNodeID node_id, uint16 group_id, uint16 method_id);
extern void verse_send_o_method_call(VNodeID node_id, uint16 group_id, uint16 method_id, VNodeID sender, const VNOPackedParams *params);
extern void verse_send_o_anim_run(VNodeID node_id, uint16 link_id, uint32 time_s, uint32 time_f, uint8 dimensions, const real64 *pos, const real64 *speed, const real64 *accel, const real64 *scale, const real64 *scale_speed);
extern void verse_send_o_hide(VNodeID node_id, uint8 hidden);
extern void verse_send_g_layer_create(VNodeID node_id, VLayerID layer_id, const char *name, VNGLayerType type, uint32 def_uint, real64 def_real);
extern void verse_send_g_layer_destroy(VNodeID node_id, VLayerID layer_id);
extern void verse_send_g_layer_subscribe(VNodeID node_id, VLayerID layer_id, VNRealFormat type);
extern void verse_send_g_layer_unsubscribe(VNodeID node_id, VLayerID layer_id);
extern void verse_send_g_vertex_set_xyz_real32(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real32 x, real32 y, real32 z);
extern void verse_send_g_vertex_delete_real32(VNodeID node_id, uint32 vertex_id);
extern void verse_send_g_vertex_set_xyz_real64(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real64 x, real64 y, real64 z);
extern void verse_send_g_vertex_delete_real64(VNodeID node_id, uint32 vertex_id);
extern void verse_send_g_vertex_set_uint32(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, uint32 value);
extern void verse_send_g_vertex_set_real64(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real64 value);
extern void verse_send_g_vertex_set_real32(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real32 value);
extern void verse_send_g_polygon_set_corner_uint32(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint32 v0, uint32 v1, uint32 v2, uint32 v3);
extern void verse_send_g_polygon_delete(VNodeID node_id, uint32 polygon_id);
extern void verse_send_g_polygon_set_corner_real64(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real64 v0, real64 v1, real64 v2, real64 v3);
extern void verse_send_g_polygon_set_corner_real32(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real32 v0, real32 v1, real32 v2, real32 v3);
extern void verse_send_g_polygon_set_face_uint8(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint8 value);
extern void verse_send_g_polygon_set_face_uint32(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint32 value);
extern void verse_send_g_polygon_set_face_real64(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real64 value);
extern void verse_send_g_polygon_set_face_real32(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real32 value);
extern void verse_send_g_crease_set_vertex(VNodeID node_id, const char *layer, uint32 def_crease);
extern void verse_send_g_crease_set_edge(VNodeID node_id, const char *layer, uint32 def_crease);
extern void verse_send_g_bone_create(VNodeID node_id, uint16 bone_id, const char *weight, const char *reference, uint16 parent, real64 pos_x, real64 pos_y, real64 pos_z, const char *position_label, const char *rotation_label, const char *scale_label);
extern void verse_send_g_bone_destroy(VNodeID node_id, uint16 bone_id);
extern void verse_send_m_fragment_create(VNodeID node_id, VNMFragmentID frag_id, VNMFragmentType type, const VMatFrag *fragment);
extern void verse_send_m_fragment_destroy(VNodeID node_id, VNMFragmentID frag_id);
extern void verse_send_b_dimensions_set(VNodeID node_id, uint16 width, uint16 height, uint16 depth);
extern void verse_send_b_layer_create(VNodeID node_id, VLayerID layer_id, const char *name, VNBLayerType type);
extern void verse_send_b_layer_destroy(VNodeID node_id, VLayerID layer_id);
extern void verse_send_b_layer_subscribe(VNodeID node_id, VLayerID layer_id, uint8 level);
extern void verse_send_b_layer_unsubscribe(VNodeID node_id, VLayerID layer_id);
extern void verse_send_b_tile_set(VNodeID node_id, VLayerID layer_id, uint16 tile_x, uint16 tile_y, uint16 z, VNBLayerType type, const VNBTile *tile);
extern void verse_send_t_language_set(VNodeID node_id, const char *language);
extern void verse_send_t_buffer_create(VNodeID node_id, VBufferID buffer_id, const char *name);
extern void verse_send_t_buffer_destroy(VNodeID node_id, VBufferID buffer_id);
extern void verse_send_t_buffer_subscribe(VNodeID node_id, VBufferID buffer_id);
extern void verse_send_t_buffer_unsubscribe(VNodeID node_id, VBufferID buffer_id);
extern void verse_send_t_text_set(VNodeID node_id, VBufferID buffer_id, uint32 pos, uint32 length, const char *text);
extern void verse_send_c_curve_create(VNodeID node_id, VLayerID curve_id, const char *name, uint8 dimensions);
extern void verse_send_c_curve_destroy(VNodeID node_id, VLayerID curve_id);
extern void verse_send_c_curve_subscribe(VNodeID node_id, VLayerID curve_id);
extern void verse_send_c_curve_unsubscribe(VNodeID node_id, VLayerID curve_id);
extern void verse_send_c_key_set(VNodeID node_id, VLayerID curve_id, uint32 key_id, uint8 dimensions, const real64 *pre_value, const uint32 *pre_pos, const real64 *value, real64 pos, const real64 *post_value, const uint32 *post_pos);
extern void verse_send_c_key_destroy(VNodeID node_id, VLayerID curve_id, uint32 key_id);
extern void verse_send_a_buffer_create(VNodeID node_id, VBufferID buffer_id, const char *name, VNABlockType type, real64 frequency);
extern void verse_send_a_buffer_destroy(VNodeID node_id, VBufferID buffer_id);
extern void verse_send_a_buffer_subscribe(VNodeID node_id, VBufferID layer_id);
extern void verse_send_a_buffer_unsubscribe(VNodeID node_id, VBufferID layer_id);
extern void verse_send_a_block_set(VNodeID node_id, VLayerID buffer_id, uint32 block_index, VNABlockType type, const VNABlock *samples);
extern void verse_send_a_block_clear(VNodeID node_id, VLayerID buffer_id, uint32 block_index);
extern void verse_send_a_stream_create(VNodeID node_id, VLayerID stream_id, const char *name);
extern void verse_send_a_stream_destroy(VNodeID node_id, VLayerID stream_id);
extern void verse_send_a_stream_subscribe(VNodeID node_id, VLayerID stream_id);
extern void verse_send_a_stream_unsubscribe(VNodeID node_id, VLayerID stream_id);
extern void verse_send_a_stream(VNodeID node_id, VLayerID stream_id, uint32 time_s, uint32 time_f, VNABlockType type, real64 frequency, const VNABlock *samples);
#if defined __cplusplus
}
#endif
#endif /* VERSE_H */

@ -1,409 +0,0 @@
#if !defined VERSE_TYPES
#define VERSE_TYPES
#include <stdlib.h>
/* Release information. */
#define V_RELEASE_NUMBER 6
#define V_RELEASE_PATCH 1
#define V_RELEASE_LABEL ""
typedef unsigned char boolean;
typedef signed char int8;
typedef unsigned char uint8;
typedef short int16;
typedef unsigned short uint16;
typedef int int32;
typedef unsigned int uint32;
typedef float real32;
typedef double real64;
#define V_REAL64_MAX 1.7976931348623158e+308
#define V_REAL32_MAX 3.402823466e+38f
#if !defined TRUE
#define TRUE 1
#define FALSE 0
#endif
#define V_HOST_ID_SIZE (3 * (512 / 8)) /* The size of host IDs (keys), in 8-bit bytes. */
typedef enum {
V_NT_OBJECT = 0,
V_NT_GEOMETRY,
V_NT_MATERIAL,
V_NT_BITMAP,
V_NT_TEXT,
V_NT_CURVE,
V_NT_AUDIO,
V_NT_NUM_TYPES,
V_NT_SYSTEM = V_NT_NUM_TYPES,
V_NT_NUM_TYPES_NETPACK
} VNodeType;
typedef uint32 VNodeID;
typedef uint16 VLayerID; /* Commonly used to identify layers, nodes that have them. */
typedef uint16 VBufferID; /* Commonly used to identify buffers, nodes that have them. */
typedef uint16 VNMFragmentID;
typedef void * VSession;
#define V_MAX_NAME_LENGTH_SHORT 16
#define V_MAX_NAME_LENGTH_LONG 48
#define V_MAX_NAME_PASS_LENGTH 128
typedef enum {
VN_OWNER_OTHER = 0,
VN_OWNER_MINE
} VNodeOwner;
typedef enum {
VN_O_METHOD_PTYPE_INT8 = 0,
VN_O_METHOD_PTYPE_INT16,
VN_O_METHOD_PTYPE_INT32,
VN_O_METHOD_PTYPE_UINT8,
VN_O_METHOD_PTYPE_UINT16,
VN_O_METHOD_PTYPE_UINT32,
VN_O_METHOD_PTYPE_REAL32,
VN_O_METHOD_PTYPE_REAL64,
VN_O_METHOD_PTYPE_REAL32_VEC2,
VN_O_METHOD_PTYPE_REAL32_VEC3,
VN_O_METHOD_PTYPE_REAL32_VEC4,
VN_O_METHOD_PTYPE_REAL64_VEC2,
VN_O_METHOD_PTYPE_REAL64_VEC3,
VN_O_METHOD_PTYPE_REAL64_VEC4,
VN_O_METHOD_PTYPE_REAL32_MAT4,
VN_O_METHOD_PTYPE_REAL32_MAT9,
VN_O_METHOD_PTYPE_REAL32_MAT16,
VN_O_METHOD_PTYPE_REAL64_MAT4,
VN_O_METHOD_PTYPE_REAL64_MAT9,
VN_O_METHOD_PTYPE_REAL64_MAT16,
VN_O_METHOD_PTYPE_STRING,
VN_O_METHOD_PTYPE_NODE,
VN_O_METHOD_PTYPE_LAYER
} VNOParamType;
typedef union {
int8 vint8;
int16 vint16;
int32 vint32;
uint8 vuint8;
uint16 vuint16;
uint32 vuint32;
real32 vreal32;
real64 vreal64;
real32 vreal32_vec[4];
real32 vreal32_mat[16];
real64 vreal64_vec[4];
real64 vreal64_mat[16];
char *vstring;
VNodeID vnode;
VLayerID vlayer;
} VNOParam;
#define VN_TAG_MAX_BLOB_SIZE 500
typedef enum {
VN_TAG_BOOLEAN = 0,
VN_TAG_UINT32,
VN_TAG_REAL64,
VN_TAG_STRING,
VN_TAG_REAL64_VEC3,
VN_TAG_LINK,
VN_TAG_ANIMATION,
VN_TAG_BLOB,
VN_TAG_TYPE_COUNT
} VNTagType;
typedef enum {
VN_TAG_GROUP_SIZE = 16,
VN_TAG_NAME_SIZE = 16,
VN_TAG_FULL_NAME_SIZE = 64,
VN_TAG_STRING_SIZE = 128
} VNTagConstants;
typedef union {
boolean vboolean;
uint32 vuint32;
real64 vreal64;
char *vstring;
real64 vreal64_vec3[3];
VNodeID vlink;
struct {
VNodeID curve;
uint32 start;
uint32 end;
} vanimation;
struct {
uint16 size;
void *blob;
} vblob;
} VNTag;
typedef enum {
VN_S_CONNECT_NAME_SIZE = 32,
VN_S_CONNECT_KEY_SIZE = 4,
VN_S_CONNECT_DATA_SIZE = 32,
VS_S_CONNECT_HOSTID_PRIVATE_SIZE = 3 * 2048 / 8,
VS_S_CONNECT_HOSTID_PUBLIC_SIZE = 2 * 2048 / 8
} VNSConnectConstants;
typedef enum {
VN_FORMAT_REAL32,
VN_FORMAT_REAL64
} VNRealFormat;
typedef struct {
real32 x, y, z, w;
} VNQuat32;
typedef struct {
real64 x, y, z, w;
} VNQuat64;
typedef enum {
VN_O_METHOD_GROUP_NAME_SIZE = 16,
VN_O_METHOD_NAME_SIZE = 16,
VN_O_METHOD_SIG_SIZE = 256
} VNOMethodConstants;
typedef void VNOPackedParams; /* Opaque type. */
typedef enum {
VN_G_LAYER_VERTEX_XYZ = 0,
VN_G_LAYER_VERTEX_UINT32,
VN_G_LAYER_VERTEX_REAL,
VN_G_LAYER_POLYGON_CORNER_UINT32 = 128,
VN_G_LAYER_POLYGON_CORNER_REAL,
VN_G_LAYER_POLYGON_FACE_UINT8,
VN_G_LAYER_POLYGON_FACE_UINT32,
VN_G_LAYER_POLYGON_FACE_REAL
} VNGLayerType;
typedef enum {
VN_M_LIGHT_DIRECT = 0,
VN_M_LIGHT_AMBIENT,
VN_M_LIGHT_DIRECT_AND_AMBIENT,
VN_M_LIGHT_BACK_DIRECT,
VN_M_LIGHT_BACK_AMBIENT,
VN_M_LIGHT_BACK_DIRECT_AND_AMBIENT
} VNMLightType;
typedef enum {
VN_M_NOISE_PERLIN_ZERO_TO_ONE = 0,
VN_M_NOISE_PERLIN_MINUS_ONE_TO_ONE,
VN_M_NOISE_POINT_ZERO_TO_ONE,
VN_M_NOISE_POINT_MINUS_ONE_TO_ONE
} VNMNoiseType;
typedef enum {
VN_M_RAMP_SQUARE = 0,
VN_M_RAMP_LINEAR,
VN_M_RAMP_SMOOTH
} VNMRampType;
typedef enum {
VN_M_RAMP_RED = 0,
VN_M_RAMP_GREEN,
VN_M_RAMP_BLUE
} VNMRampChannel;
typedef struct {
real64 pos;
real64 red;
real64 green;
real64 blue;
} VNMRampPoint;
typedef enum {
VN_M_BLEND_FADE = 0,
VN_M_BLEND_ADD,
VN_M_BLEND_SUBTRACT,
VN_M_BLEND_MULTIPLY,
VN_M_BLEND_DIVIDE,
} VNMBlendType;
typedef enum {
VN_M_FT_COLOR = 0,
VN_M_FT_LIGHT,
VN_M_FT_REFLECTION,
VN_M_FT_TRANSPARENCY,
VN_M_FT_VOLUME,
VN_M_FT_VIEW,
VN_M_FT_GEOMETRY,
VN_M_FT_TEXTURE,
VN_M_FT_NOISE,
VN_M_FT_BLENDER,
VN_M_FT_CLAMP,
VN_M_FT_MATRIX,
VN_M_FT_RAMP,
VN_M_FT_ANIMATION,
VN_M_FT_ALTERNATIVE,
VN_M_FT_OUTPUT
} VNMFragmentType;
typedef union {
struct {
real64 red;
real64 green;
real64 blue;
} color;
struct {
uint8 type;
real64 normal_falloff;
VNodeID brdf;
char brdf_r[16];
char brdf_g[16];
char brdf_b[16];
} light;
struct {
real64 normal_falloff;
} reflection;
struct {
real64 normal_falloff;
real64 refraction_index;
} transparency;
struct {
real64 diffusion;
real64 col_r;
real64 col_g;
real64 col_b;
} volume;
struct {
char layer_r[16];
char layer_g[16];
char layer_b[16];
} geometry;
struct{
VNodeID bitmap;
char layer_r[16];
char layer_g[16];
char layer_b[16];
boolean filtered;
VNMFragmentID mapping;
} texture;
struct {
uint8 type;
VNMFragmentID mapping;
} noise;
struct {
uint8 type;
VNMFragmentID data_a;
VNMFragmentID data_b;
VNMFragmentID control;
} blender;
struct {
boolean min;
real64 red;
real64 green;
real64 blue;
VNMFragmentID data;
} clamp;
struct {
real64 matrix[16];
VNMFragmentID data;
} matrix;
struct {
uint8 type;
uint8 channel;
VNMFragmentID mapping;
uint8 point_count;
VNMRampPoint ramp[48];
} ramp;
struct {
char label[16];
} animation;
struct {
VNMFragmentID alt_a;
VNMFragmentID alt_b;
} alternative;
struct {
char label[16];
VNMFragmentID front;
VNMFragmentID back;
} output;
} VMatFrag;
typedef enum {
VN_B_LAYER_UINT1 = 0,
VN_B_LAYER_UINT8,
VN_B_LAYER_UINT16,
VN_B_LAYER_REAL32,
VN_B_LAYER_REAL64
} VNBLayerType;
#define VN_B_TILE_SIZE 8
typedef union{
uint8 vuint1[8];
uint8 vuint8[64];
uint16 vuint16[64];
real32 vreal32[64];
real64 vreal64[64];
} VNBTile;
typedef enum {
VN_T_CONTENT_LANGUAGE_SIZE = 32,
VN_T_CONTENT_INFO_SIZE = 256,
VN_T_BUFFER_NAME_SIZE = 16,
VN_T_MAX_TEXT_CMD_SIZE = 1450
} VNTConstants;
/* This is how many *samples* are included in a block of the given type. Not bytes. */
typedef enum {
VN_A_BLOCK_SIZE_INT8 = 1024,
VN_A_BLOCK_SIZE_INT16 = 512,
VN_A_BLOCK_SIZE_INT24 = 384,
VN_A_BLOCK_SIZE_INT32 = 256,
VN_A_BLOCK_SIZE_REAL32 = 256,
VN_A_BLOCK_SIZE_REAL64 = 128
} VNAConstants;
typedef enum {
VN_A_BLOCK_INT8,
VN_A_BLOCK_INT16,
VN_A_BLOCK_INT24,
VN_A_BLOCK_INT32,
VN_A_BLOCK_REAL32,
VN_A_BLOCK_REAL64
} VNABlockType;
/* Audio commands take pointers to blocks of these. They are not packed as unions. */
typedef union {
int8 vint8[VN_A_BLOCK_SIZE_INT8];
int16 vint16[VN_A_BLOCK_SIZE_INT16];
int32 vint24[VN_A_BLOCK_SIZE_INT24];
int32 vint32[VN_A_BLOCK_SIZE_INT32];
real32 vreal32[VN_A_BLOCK_SIZE_REAL32];
real64 vreal64[VN_A_BLOCK_SIZE_REAL64];
} VNABlock;
extern void verse_set_port(uint16 port);
extern void verse_host_id_create(uint8 *id);
extern void verse_host_id_set(uint8 *id);
extern void verse_callback_set(void *send_func, void *callback, void *user_data);
extern void verse_callback_update(uint32 microseconds);
extern void verse_session_set(VSession session);
extern VSession verse_session_get(void);
extern void verse_session_destroy(VSession session);
extern size_t verse_session_get_size(void);
extern VNodeID verse_session_get_avatar(void);
extern void verse_session_get_time(uint32 *seconds, uint32 *fractions);
extern VNOPackedParams * verse_method_call_pack(uint32 param_count, const VNOParamType *param_type, const VNOParam *params);
extern boolean verse_method_call_unpack(const VNOPackedParams *data, uint32 param_count, const VNOParamType *param_type, VNOParam *params);
/*
#define V_PRINT_SEND_COMMANDS
#define V_PRINT_RECEIVE_COMMANDS
*/
#endif /* VERSE_TYPES */

@ -1,286 +0,0 @@
/*
* A helper library to send and parse master server pings. See the relevant
* header for details.
*
* This code was written in 2006 by Emil Brink. It is released as public domain.
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "verse.h"
#include "verse_ms.h"
/* Build and send a MS:GET packet. */
void verse_ms_get_send(const char *address, int fields, const char *tags)
{
char req[128];
strcpy(req, "MS:GET IP=");
if(fields & VERSE_MS_FIELD_DESCRIPTION)
strcat(req, "DE");
if(tags != NULL)
{
strcat(req, " TA=");
strcat(req, tags);
}
verse_send_ping(address, req);
}
/* Skip assign, i.e. "NAME=" string, at <msg>. Stores name into <put>, and then updates
* it. Returns NULL on parse error, in which case the <put> pointer is not advanced.
*/
static const char * skip_assign(char **put, const char *msg)
{
if(isalpha(*msg))
{
char *p = put != NULL ? *put : NULL;
if(p != NULL)
*p++ = *msg;
msg++;
while(*msg && (isalnum(*msg) || *msg == '_'))
{
if(p != NULL)
*p++ = *msg;
msg++;
}
if(*msg == '=')
{
if(p != NULL)
*p++ = '\0';
if(put != NULL)
*put = p;
return msg + 1;
}
}
return NULL;
}
/** Skip value at <msg>, optionally storing de-quoted version through <put>,
* which is advanced. Returns NULL on parse error, without updating <put>.
*/
static const char * skip_value(char **put, const char *msg)
{
char *p = (put != NULL) ? *put : NULL;
if(*msg == '"')
{
msg++;
while(*msg != '\0' && *msg != '"')
{
if(*msg == '\\')
{
if(msg[1] != '\0')
msg++;
else
return NULL;
}
if(p != NULL)
*p++ = *msg;
msg++;
}
if(*msg == '"')
{
if(p != NULL)
*p++ = '\0';
if(put != NULL)
*put = p;
msg++;
if(*msg == '\0' || isspace(*msg))
return msg;
}
return NULL;
}
while(*msg && !isspace(*msg))
{
if(*msg == '"')
return NULL;
if(p != NULL)
*p++ = *msg;
msg++;
}
if(p != NULL)
*p++ = '\0';
if(put != NULL)
*put = p;
return msg;
}
static const char * put_field(VMSField *field, char **put, const char *src)
{
const char *ptr;
char *base = *put;
if((ptr = skip_assign(put, src)) != NULL && ptr - src > 1)
{
field->name = base;
src = ptr;
base = *put;
if((ptr = skip_value(put, src)) != NULL)
{
field->value = base;
return ptr;
}
}
return NULL;
}
static int cmp_fields(const void *a, const void *b)
{
return strcmp(((const VMSField *) a)->name, ((const VMSField *) b)->name);
}
VMSServer ** verse_ms_list_parse(const char *msg)
{
const char *word[384]; /* Takes quite a lot of stack space. */
const char *ptr;
char *put;
size_t num_word = 0, i, j, num_ip = 0, num_field, space = 0;
VMSServer **desc, *next;
VMSField *field;
if(strncmp(msg, "MS:LIST", 7) == 0)
msg += 7;
if(*msg != ' ')
return NULL;
/* Step one: split the string into words, at whitespace. Split is aware
* of quoting rules for value assignment, this is crucial. This split is
* non-invasive, meaning each "word" will be a suffix.
*/
while(*msg)
{
while(isspace(*msg))
msg++;
ptr = skip_assign(NULL, msg);
if(ptr != NULL)
{
space += ptr - msg;
word[num_word++] = msg;
msg = ptr;
ptr = skip_value(NULL, msg);
if(ptr == NULL)
{
fprintf(stderr, "Parse error\n");
return NULL;
}
space += ptr - msg + 1;
msg = ptr;
}
else if(*msg != '\0')
{
fprintf(stderr, "Parse error\n");
return NULL;
}
}
/* Now, count how many words begin with "IP=". */
for(i = 0; i < num_word; i++)
{
if(strncmp(word[i], "IP=", 3) == 0)
num_ip++;
}
/* printf("found %u IPs, %u bytes\n", num_ip, space);
printf("%u IP and %u words -> %u fields total\n", num_ip, num_word, num_word - num_ip);
*/ num_field = num_word - num_ip;
/* Allocate the descriptions. */
/* printf("allocating %u bytes\n", (num_ip + 1) * (sizeof *desc) + num_ip * sizeof **desc + num_field * sizeof (VMSField) + space);
printf(" %u for pointers, %u for structs, %u for fields, %u string\n",
(num_ip + 1) * (sizeof *desc), num_ip * sizeof **desc, num_field * sizeof (VMSField), space);
*/ desc = malloc((num_ip + 1) * (sizeof *desc) + num_ip * sizeof **desc + num_field * sizeof (VMSField) + space);
next = (VMSServer *) (desc + (num_ip + 1));
/* printf("desc store at %u\n", (char *) next - (char *) desc);*/
field = (VMSField *) (next + num_ip);
/* printf("field store at %u\n", (char *) field - (char *) desc);*/
put = (char *) (field + num_field);
/* printf("string store at %u\n", put - (char *) desc);*/
for(i = j = 0; i < num_word;)
{
if(strncmp(word[i], "IP=", 3) == 0)
{
desc[j] = next;
next->ip = put;
ptr = skip_value(&put, word[i] + 3);
next->num_fields = 0;
next->field = field;
for(i++; i < num_word && strncmp(word[i], "IP=", 3) != 0; i++, next->num_fields++, field++)
put_field(&next->field[next->num_fields], &put, word[i]);
if(next->num_fields > 0) /* Sort the fields, for binary search later. */
qsort(next->field, next->num_fields, sizeof *next->field, cmp_fields);
j++;
next++;
}
else
i++;
}
desc[j] = NULL;
return desc;
}
/* A binary search, exploiting that the fields are sorted. */
static const VMSField * field_find(const VMSServer *ms, const char *name)
{
int lo, hi, mid, rel;
if(ms == NULL || name == NULL)
return NULL;
lo = 0;
hi = ms->num_fields;
while(lo <= hi)
{
mid = (lo + hi) / 2;
rel = strcmp(name, ms->field[mid].name);
if(rel == 0)
return &ms->field[mid];
if(rel < 0)
hi = mid - 1;
else
lo = mid + 1;
}
return NULL;
}
int verse_ms_field_exists(const VMSServer *ms, const char *name)
{
if(ms == NULL || name == NULL)
return 0;
return field_find(ms, name) != NULL;
}
const char * verse_ms_field_value(const VMSServer *ms, const char *name)
{
const VMSField *f;
if((f = field_find(ms, name)) != NULL)
return f->value;
return NULL;
}
#if defined VERSE_MS_STANDALONE
int main(void)
{
VMSServer **servers = verse_ms_list_parse("MS:LIST IP=127.0.0.1:4951 DE=\"A test server, mainly for Eskil\" COOL=yes BACKUP=daily LANG=sv_SE "
"IP=130.237.221.74 DE=\"Test server on a puny laptop\" COOL=yes DORKY=no OPEN=absolutely "
"IP=127.0.0.1:5151 DE=\"This is a back slash: '\\\\', cool huh?\" "
"IP=127.0.0.1:6676 DE=\"a quote looks like this: \\\"\" IP=127.0.0.1:1122 ");
if(servers != NULL)
{
int i, j;
printf("Server info:\n");
for(i = 0; servers[i] != NULL; i++)
{
printf("%u: IP=%s\n", i, servers[i]->ip);
for(j = 0; j < servers[i]->num_fields; j++)
printf(" %s='%s'\n", servers[i]->field[j].name, servers[i]->field[j].value);
}
free(servers);
}
return EXIT_SUCCESS;
}
#endif /* VERSE_MS_STANDALONE */

@ -1,72 +0,0 @@
/*
* This is Verse Master Server, a small help library to aid application developers
* make their applications interact with a Verse master server.
*
* There are two steps to the process:
*
* 1) Send a MS:GET request to a master server. This is done by the verse_ms_get_send()
* function, which calls verse_send_ping() internally.
*
* 2) Parse any returned MS:LIST packets. This is a two-step process. The application
* still owns the ping callback, and will need to check for received pings that
* start with MS:LIST, and call the verse_ms_list_parse() function to parse those.
*
* A successfully parsed MS:LIST packet will result in an array of VMSServer pointers
* being returned. Each VMSServer instance describes one server. Use the provided
* functions to query each server structure.
*
* The application should call free() on the returned vector, whenever it is done with
* the data (perhaps after copying it into application-defined data structures).
*
* For a lot more detail about the Verse master server protocol, please see
* the spec at <http://verse.blender.org/cms/Master_Server__v2.775.0.html>.
*
* This code was written in 2006 by Emil Brink. It is released as public domain.
*
*/
#define VERSE_MS_VERSION "1.0"
#if defined __cplusplus
extern "C" {
#endif
typedef struct {
const char *name; /* Field name. Upper-case. */
const char *value; /* Field value. Fully parsed, might contain spaces. */
} VMSField;
typedef struct {
const char *ip; /* IP address of server, in dotted decimal:port. */
unsigned int num_fields; /* Number of fields of extra info. */
VMSField *field; /* Vector of fields, or NULL if none. */
} VMSServer;
/* Formats and sends a MS:GET ping packet to the master server. The <fields> argument
* should be a combination of VERSE_MS_FIELD_ mask values. If <tags> is set, it should
* be a comma-separated set of include/exclude tags, like "a,b,-c,d,-e".
*/
#define VERSE_MS_FIELD_DESCRIPTION (1 << 0)
extern void verse_ms_get_send(const char *address, int fields, const char *tags);
/* Parses a master server response. This will be a string of the form "MS:LIST IP=blah ...",
* which is split into one struct per IP, and any additional fields parsed (unquoted etc).
* Returns an array of VMSServer pointers, which is NULL-terminated. Returns NULL if there
* was a parse error somewhere in the string, no partial success is possible.
*/
extern VMSServer ** verse_ms_list_parse(const char *list);
/* This is the only standard field name, currently. */
#define VERSE_MS_FIELD_DESCRIPTION_NAME "DE" /* Human-readable server description. */
/* Checks wether the given server has a field with the given name. */
extern int verse_ms_field_exists(const VMSServer *ms, const char *name);
/* Returns the value for the named field in the given server, if present.
* If not, NULL is returned.
*/
extern const char * verse_ms_field_value(const VMSServer *ms, const char *name);
#if defined __cplusplus
}
#endif

@ -1,179 +0,0 @@
#include <stdlib.h>
#include "v_cmd_gen.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "verse.h"
#include "v_util.h"
#define VS_CONNECTION_CHUNK_SIZE 64
typedef struct{
VSession *session;
unsigned int session_count;
} VSSubscriptionList;
typedef struct{
VSession session;
uint32 node_id;
char name[128];
char pass[128];
} VSConnection;
static struct {
VSConnection *connection;
unsigned int connection_length;
VSSubscriptionList **list;
unsigned int list_length;
unsigned int current_session;
} VSConnectionStorage;
void vs_init_connection_storage(void)
{
VSConnectionStorage.connection = NULL;
VSConnectionStorage.connection_length = 0;
VSConnectionStorage.list = NULL;
VSConnectionStorage.list_length = 0;
VSConnectionStorage.current_session = 0;
}
void vs_add_new_connection(VSession session, const char *name, const char *pass, VNodeID node_id)
{
VSConnection *conn;
if(VSConnectionStorage.connection_length % VS_CONNECTION_CHUNK_SIZE == 0)
VSConnectionStorage.connection = realloc(VSConnectionStorage.connection, (sizeof *VSConnectionStorage.connection) * (VSConnectionStorage.connection_length + VS_CONNECTION_CHUNK_SIZE));
conn = &VSConnectionStorage.connection[VSConnectionStorage.connection_length];
conn->session = session;
conn->node_id = node_id;
v_strlcpy(conn->name, name, sizeof conn->name);
v_strlcpy(conn->pass, pass, sizeof conn->pass);
VSConnectionStorage.connection_length++;
}
uint32 vs_get_avatar(void)
{
return VSConnectionStorage.connection[VSConnectionStorage.current_session].node_id;
}
VSession vs_get_session(void)
{
return VSConnectionStorage.connection[VSConnectionStorage.current_session].session;
}
const char * vs_get_user_name(void)
{
return VSConnectionStorage.connection[VSConnectionStorage.current_session].name;
}
const char * vs_get_user_pass(void)
{
return VSConnectionStorage.connection[VSConnectionStorage.current_session].pass;
}
void vs_remove_connection(void)
{
unsigned int i, j;
VSession *session;
VSSubscriptionList *list;
session = VSConnectionStorage.connection[VSConnectionStorage.current_session].session;
for(i = 0; i < VSConnectionStorage.list_length; i++)
{
list = VSConnectionStorage.list[i];
for(j = 0; j < list->session_count && list->session[j] != session; j++);
if(j < list->session_count)
list->session[j] = list->session[--list->session_count];
}
j = --VSConnectionStorage.connection_length;
if(VSConnectionStorage.current_session < j)
{
VSConnectionStorage.connection[VSConnectionStorage.current_session].session = VSConnectionStorage.connection[j].session;
VSConnectionStorage.connection[VSConnectionStorage.current_session].node_id = VSConnectionStorage.connection[j].node_id;
}
else
VSConnectionStorage.current_session = 0;
}
void vs_set_next_session(void)
{
if(++VSConnectionStorage.current_session >= VSConnectionStorage.connection_length)
VSConnectionStorage.current_session = 0;
if(VSConnectionStorage.connection_length != 0)
verse_session_set(VSConnectionStorage.connection[VSConnectionStorage.current_session].session);
}
VSSubscriptionList *vs_create_subscription_list(void)
{
VSSubscriptionList *list;
list = malloc(sizeof *list);
if(VSConnectionStorage.list_length % VS_CONNECTION_CHUNK_SIZE == 0)
VSConnectionStorage.list = realloc(VSConnectionStorage.list, (sizeof *VSConnectionStorage.list) * (VSConnectionStorage.list_length + VS_CONNECTION_CHUNK_SIZE));
VSConnectionStorage.list[VSConnectionStorage.list_length] = list;
list->session = NULL;
list->session_count = 0;
VSConnectionStorage.list_length++;
return list;
}
void vs_destroy_subscription_list(VSSubscriptionList *list)
{
unsigned int i;
if(list == NULL)
return;
if(list->session != NULL)
free(list->session);
for(i = 0; i < VSConnectionStorage.list_length && VSConnectionStorage.list[i] != list; i++)
;
if(i < VSConnectionStorage.list_length)
VSConnectionStorage.list[i] = VSConnectionStorage.list[--VSConnectionStorage.list_length];
free(list);
}
/* Returns 1 if subscriber was added, 0 if not (typically meaning it was already on the list). */
int vs_add_new_subscriptor(VSSubscriptionList *list)
{
unsigned int i;
if(list->session_count % VS_CONNECTION_CHUNK_SIZE == 0)
list->session = realloc(list->session, (sizeof *list->session) * (list->session_count + VS_CONNECTION_CHUNK_SIZE));
for(i = 0; i < list->session_count; i++)
if(list->session[i] == VSConnectionStorage.connection[VSConnectionStorage.current_session].session)
return 0;
list->session[list->session_count] = VSConnectionStorage.connection[VSConnectionStorage.current_session].session;
list->session_count++;
return 1;
}
void vs_remove_subscriptor(VSSubscriptionList *list)
{
unsigned int i;
VSession *session;
session = VSConnectionStorage.connection[VSConnectionStorage.current_session].session;
for(i = 0; i < list->session_count && list->session[i] != session; i++);
if(i < list->session_count)
list->session[i] = list->session[--list->session_count];
}
size_t vs_get_subscript_count(const VSSubscriptionList *list)
{
return list != NULL ? list->session_count : 0;
}
void vs_set_subscript_session(VSSubscriptionList *list, unsigned int session)
{
verse_session_set(list->session[session]);
}
void vs_reset_subscript_session(void)
{
verse_session_set(VSConnectionStorage.connection[VSConnectionStorage.current_session].session);
}
#endif

@ -1,180 +0,0 @@
/*
** A simple Verse server.
*/
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include "v_cmd_gen.h"
#if !defined V_GENERATE_FUNC_MODE
#include "verse.h"
#include "v_network.h"
#include "v_util.h"
#include "vs_server.h"
extern VNodeID vs_node_create(VNodeID owner_id, unsigned int type);
extern void callback_send_node_destroy(void *user_data, VNodeID node_id);
extern void vs_reset_owner(VNodeID owner_id);
static void callback_send_connect(void *user, const char *name, const char *pass, const char *address, const uint8 *host_id)
{
VNodeID avatar;
VSession *session;
printf("Connecting '%s'\n", name);
if(TRUE)
{
avatar = vs_node_create(~0, V_NT_OBJECT);
session = verse_send_connect_accept(avatar, address, NULL);
vs_add_new_connection(session, name, pass, avatar);
/* vs_avatar_init(avatar, name);*/
}
else
{
verse_send_connect_terminate(address, "I'm sorry but you are not welcome here.");
}
}
static void callback_send_connect_terminate(void *user, char *address, char *bye)
{
printf("callback_send_connect_terminate\n");
vs_reset_owner(vs_get_avatar());
callback_send_node_destroy(NULL, vs_get_avatar());
verse_session_destroy(vs_get_session());
vs_remove_connection();
}
static void vs_load_host_id(const char *file_name)
{
FILE *f;
uint8 id[V_HOST_ID_SIZE];
size_t got;
/* Attempt to read key from given filename. Fails silently. */
if((f = fopen(file_name, "rb")) != NULL)
{
if((got = fread(id, 1, sizeof id, f)) > 0)
{
printf("Loaded %u-bit host ID key successfully\n", 8 * (got / 3));
verse_host_id_set(id);
}
fclose(f);
if(got)
return;
}
/* If file didn't open, or reading failed, generate a new key and write it out. */
verse_host_id_create(id);
verse_host_id_set(id);
if((f = fopen(file_name, "wb")) != NULL)
{
if(fwrite(id, sizeof id, 1, f) != 1)
fprintf(stderr, "Warning: Couldn't write host ID to \"%s\"\n", file_name);
fclose(f);
}
else
fprintf(stderr, "Warning: Couldn't open \"%s\" for host ID writing\n", file_name);
}
static void cb_sigint_handler(int sig)
{
if(sig == SIGINT)
{
printf("Verse server terminating\n");
exit(EXIT_SUCCESS);
}
}
static void callback_send_ping(void *user, const char *address, const char *message)
{
if(strncmp(message, "DESCRIBE", 8) == 0 && message[8] == ' ')
vs_master_handle_describe(address, message + 9);
}
static void usage(void)
{
printf("Verse server usage:\n");
printf(" -h\t\t\tShow this usage information.\n");
printf(" -ms\t\t\tRegisters the server with a master server at the address\n");
printf(" \t\t\tgiven with the -ms:ip= option. Off by default.\n");
printf(" -ms:ip=IP[:PORT]\tSet master server to register with. Implies -ms.\n");
printf(" \t\t\tThe default address is <%s>.\n", vs_master_get_address());
printf(" -ms:de=DESC\t\tSet description, sent to master server.\n");
printf(" -ms:ta=TAGS\t\tSet tags, sent to master server.\n");
printf(" -port=PORT\t\tSet port to use for incoming connections.\n");
printf(" -version\t\tPrint version information and exit.\n");
}
int main(int argc, char **argv)
{
uint32 i, seconds, fractions, port = VERSE_STD_CONNECT_PORT;
signal(SIGINT, cb_sigint_handler);
vs_master_set_address("master.uni-verse.org"); /* The default master address. */
vs_master_set_enabled(FALSE); /* Make sure master server support is disabled. */
for(i = 1; i < (uint32) argc; i++)
{
if(strcmp(argv[i], "-h") == 0)
{
usage();
return EXIT_SUCCESS;
}
else if(strcmp(argv[i], "-ms") == 0)
vs_master_set_enabled(TRUE);
else if(strncmp(argv[i], "-ms:ip=", 7) == 0)
{
vs_master_set_address(argv[i] + 7);
vs_master_set_enabled(TRUE);
}
else if(strncmp(argv[i], "-ms:de=", 7) == 0)
vs_master_set_desc(argv[i] + 7);
else if(strncmp(argv[i], "-ms:ta=", 7) == 0)
vs_master_set_tags(argv[i] + 7);
else if(strncmp(argv[i], "-port=", 6) == 0)
port = strtoul(argv[i] + 6, NULL, 0);
else if(strcmp(argv[i], "-version") == 0)
{
printf("r%up%u%s\n", V_RELEASE_NUMBER, V_RELEASE_PATCH, V_RELEASE_LABEL);
return EXIT_SUCCESS;
}
else
fprintf(stderr, "Ignoring unknown argument \"%s\", try -h for help\n", argv[i]);
}
printf("Verse Server r%up%u%s by Eskil Steenberg <http://verse.blender.org/>\n", V_RELEASE_NUMBER, V_RELEASE_PATCH, V_RELEASE_LABEL);
verse_set_port(port); /* The Verse standard port. */
printf(" Listening on port %d\n", port);
/* Seed the random number generator. Still rather too weak for crypto, I guess. */
v_n_get_current_time(&seconds, &fractions);
srand(seconds ^ fractions);
vs_load_host_id("host_id.rsa");
vs_init_node_storage();
vs_o_callback_init();
vs_g_callback_init();
vs_m_callback_init();
vs_b_callback_init();
vs_t_callback_init();
vs_c_callback_init();
vs_a_callback_init();
vs_h_callback_init();
init_callback_node_storage();
verse_callback_set(verse_send_ping, callback_send_ping, NULL);
verse_callback_set(verse_send_connect, callback_send_connect, NULL);
verse_callback_set(verse_send_connect_terminate, callback_send_connect_terminate, NULL);
while(TRUE)
{
vs_set_next_session();
verse_callback_update(1000000);
vs_master_update();
}
return EXIT_SUCCESS;
}
#endif /* V_GENERATE_FUNC_MODE */

@ -1,131 +0,0 @@
/*
* Master server communication code.
*/
#include <stdio.h>
#include <string.h>
#include "verse.h"
#include "v_util.h"
#include "vs_server.h"
#define MASTER_SERVER_PERIOD (60.0) /* Period between ANNOUNCE to master server, in seconds. */
static struct {
boolean enabled;
boolean started;
const char *master;
char desc[64];
const char *tags;
VUtilTimer timer;
} server_info;
#define LEFT(d) (sizeof server_info.desc - (d - server_info.desc) - 1)
void vs_master_set_enabled(boolean enabled)
{
server_info.enabled = enabled;
}
const char * vs_master_get_address(void)
{
return server_info.master;
}
void vs_master_set_address(const char *address)
{
server_info.master = address;
}
void vs_master_set_desc(const char *desc)
{
const char *src = desc;
char *dst = server_info.desc;
for(; *src != '\0' && LEFT(dst) > 0;)
{
if(*src == '"')
{
if(LEFT(dst) < 2)
break;
*dst++ = '\\';
}
else if(*src == '\\')
{
if(LEFT(dst) < 2)
break;
*dst++ = '\\';
}
*dst++ = *src++;
}
*dst = '\0';
}
void vs_master_set_tags(const char *tags)
{
server_info.tags = tags; /* This needs more protection, instead of relying on the master server. */
}
void vs_master_update(void)
{
if(!server_info.enabled || server_info.master == NULL)
return;
if(!server_info.started)
{
v_timer_start(&server_info.timer);
v_timer_advance(&server_info.timer, MASTER_SERVER_PERIOD);
server_info.started = TRUE;
return;
}
if(v_timer_elapsed(&server_info.timer) < MASTER_SERVER_PERIOD)
return;
verse_send_ping(server_info.master, "MS:ANNOUNCE");
v_timer_start(&server_info.timer);
/* printf("MS:ANNOUNCE sent to %s\n", server_info.master);*/
}
/* Check if a description request, of the form "A,B,C,...,D" includes the given keyword. This needs to
* do more than just a simple strstr(), since the keyword may be a prefix. Shades of OpenGL extensions.
*/
static int desc_has_keyword(const char *desc, const char *keyword)
{
const char *ptr;
if(desc == NULL || *desc == '\0') /* Quick-check for empty description. */
return 0;
if((ptr = strstr(desc, keyword)) != NULL)
{
size_t kl = strlen(keyword);
return ptr[kl] == ',' || ptr[kl] == '\0';
}
return 0;
}
static int keyword_fits(size_t used, size_t max, const char *key, const char *value)
{
size_t vsize = 0;
if(key != NULL && value != NULL)
vsize += 1 + strlen(key) + 1 + 1 + strlen(value) + 1;
return max - 1 - used >= vsize;
}
static char * append_desc(char *buf, const char *key, const char *value)
{
return buf + sprintf(buf, " %s=\"%s\"", key, value);
}
void vs_master_handle_describe(const char *address, const char *message)
{
char desc[1380] = "DESCRIPTION", *put = desc + 11;
if(desc_has_keyword(message, "DE") && server_info.desc != NULL && keyword_fits(put - desc, sizeof desc, "DE", server_info.desc))
put = append_desc(put, "DE", server_info.desc);
if(desc_has_keyword(message, "TA") && server_info.tags != NULL && keyword_fits(put - desc, sizeof desc, "TA", server_info.tags))
put = append_desc(put, "TA", server_info.tags);
verse_send_ping(address, desc);
}

@ -1,420 +0,0 @@
/*
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "v_cmd_gen.h"
#if !defined V_GENERATE_FUNC_MODE
#include "verse.h"
#include "vs_server.h"
typedef struct {
void **data;
unsigned int length;
char name[16];
VNABlockType type;
real64 frequency;
VSSubscriptionList *subscribers;
} VSNLayer;
typedef struct {
char name[16];
VSSubscriptionList *subscribers;
} VSNStream;
typedef struct{
VSNodeHead head;
VSNLayer *buffers;
unsigned int buffer_count;
VSNStream *streams;
unsigned int stream_count;
} VSNodeAudio;
VSNodeAudio * vs_a_create_node(unsigned int owner)
{
VSNodeAudio *node;
char name[48];
unsigned int i;
node = malloc(sizeof *node);
vs_add_new_node(&node->head, V_NT_AUDIO);
sprintf(name, "Audio_Node_%u", node->head.id);
create_node_head(&node->head, name, owner);
node->buffer_count = 16;
node->buffers = malloc((sizeof *node->buffers) * node->buffer_count);
for(i = 0; i < node->buffer_count; i++)
node->buffers[i].name[0] = 0;
node->stream_count = 16;
node->streams = malloc((sizeof *node->streams) * node->stream_count);
for(i = 0; i < node->stream_count; i++)
node->streams[i].name[0] = 0;
return node;
}
void vs_a_destroy_node(VSNodeAudio *node)
{
unsigned int i, j;
destroy_node_head(&node->head);
for(i = 0; i < node->buffer_count; i++)
{
if(node->buffers[i].name[0] != 0)
{
for(j = 0; j < node->buffers[i].length; j++)
if(node->buffers[i].data[j] != NULL)
free(node->buffers[i].data[j]);
free(node->buffers[i].data);
}
}
free(node->buffers);
free(node->streams);
free(node);
}
void vs_a_subscribe(VSNodeAudio *node)
{
unsigned int i;
if(node == NULL)
return;
for(i = 0; i < node->buffer_count; i++)
if(node->buffers[i].name[0] != 0)
verse_send_a_buffer_create(node->head.id, i, node->buffers[i].name, node->buffers[i].type,
node->buffers[i].frequency);
for(i = 0; i < node->stream_count; i++)
if(node->streams[i].name[0] != 0)
verse_send_a_stream_create(node->head.id, i, node->streams[i].name);
}
void vs_a_unsubscribe(VSNodeAudio *node)
{
unsigned int i;
for(i = 0; i < node->buffer_count; i++)
if(node->buffers[i].name[0] != 0)
vs_remove_subscriptor(node->buffers[i].subscribers);
for(i = 0; i < node->stream_count; i++)
if(node->streams[i].name[0] != 0)
vs_remove_subscriptor(node->streams[i].subscribers);
}
static void callback_send_a_stream_create(void *user, VNodeID node_id, VLayerID stream_id, const char *name)
{
VSNodeAudio *node;
unsigned int i, j, count;
node = (VSNodeAudio *) vs_get_node(node_id, V_NT_AUDIO);
if(node == NULL)
return;
for(i = 0; i < node->stream_count; i++)
{
if(stream_id != i)
{
for(j = 0; name[j] == node->streams[i].name[j] && name[j] != 0; j++);
if(name[j] == node->streams[i].name[j])
return;
}
}
if(stream_id >= node->stream_count || node->streams[stream_id].name[0] == 0)
{
for(stream_id = 0; stream_id < node->stream_count && node->streams[stream_id].name[0] != 0; stream_id++);
if(stream_id == node->stream_count)
{
stream_id = node->stream_count;
node->stream_count += 16;
node->streams = realloc(node->streams, (sizeof *node->streams) * node->stream_count);
for(i = stream_id; i < node->stream_count; i++)
node->streams[i].name[0] = 0;
}
node->streams[stream_id].subscribers = vs_create_subscription_list();
}
for(i = 0; name[i] != 0 && i < 15; i++)
node->streams[stream_id].name[i] = name[i];
node->streams[stream_id].name[i] = 0;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_a_stream_create(node_id, stream_id, name);
}
vs_reset_subscript_session();
}
static void callback_send_a_stream_destroy(void *user, VNodeID node_id, VLayerID stream_id)
{
VSNodeAudio *node;
unsigned int i, count;
node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO);
if(node == NULL || stream_id >= node->stream_count || node->streams[stream_id].name[0] == 0)
return;
vs_remove_subscriptor(node->streams[stream_id].subscribers);
node->streams[stream_id].name[0] = 0;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_a_stream_destroy(node_id, stream_id);
}
vs_reset_subscript_session();
}
static void callback_send_a_buffer_create(void *user, VNodeID node_id, VBufferID buffer_id, const char *name,
VNABlockType type, real64 frequency)
{
VSNodeAudio *node;
unsigned int i, j, count;
if(frequency < 0.0)
return;
node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO);
if(node == NULL)
return;
for(i = 0; i < node->buffer_count; i++)
{
if(buffer_id != i)
{
for(j = 0; name[j] == node->buffers[i].name[j] && name[j] != 0; j++);
if(name[j] == node->buffers[i].name[j])
return;
}
}
if(buffer_id < node->buffer_count && node->buffers[buffer_id].name[0] != 0 && type != node->buffers[buffer_id].type)
{
free(node->buffers[buffer_id].data);
vs_destroy_subscription_list(node->buffers[buffer_id].subscribers);
node->buffers[buffer_id].name[0] = 0;
}
if(buffer_id >= node->buffer_count || node->buffers[buffer_id].name[0] == 0)
{
for(buffer_id = 0; buffer_id < node->buffer_count && node->buffers[buffer_id].name[0] != 0; buffer_id++);
if(buffer_id == node->buffer_count)
{
buffer_id = node->buffer_count;
node->buffer_count += 16;
node->buffers = realloc(node->buffers, (sizeof *node->buffers) * node->buffer_count);
for(i = buffer_id; i < node->buffer_count; i++)
node->buffers[i].name[0] = 0;
}
node->buffers[buffer_id].subscribers = vs_create_subscription_list();
node->buffers[buffer_id].type = type;
node->buffers[buffer_id].frequency = frequency;
node->buffers[buffer_id].length = 64;
node->buffers[buffer_id].data = malloc(sizeof(*node->buffers[buffer_id].data) * node->buffers[buffer_id].length);
for(i = 0; i < node->buffers[buffer_id].length; i++)
node->buffers[buffer_id].data[i] = NULL;
}
for(i = 0; name[i] != 0 && i < 15; i++)
node->buffers[buffer_id].name[i] = name[i];
node->buffers[buffer_id].name[i] = 0;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_a_buffer_create(node_id, buffer_id, name, type, frequency);
}
vs_reset_subscript_session();
}
static void callback_send_a_buffer_destroy(void *user, VNodeID node_id, VBufferID buffer_id)
{
VSNodeAudio *node;
unsigned int i, count;
node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO);
if(node == NULL || buffer_id >= node->buffer_count || node->buffers[buffer_id].name[0] == 0)
return;
vs_remove_subscriptor(node->buffers[buffer_id].subscribers);
node->buffers[buffer_id].name[0] = 0;
free(node->buffers[buffer_id].data);
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_a_buffer_destroy(node_id, buffer_id);
}
vs_reset_subscript_session();
}
static void callback_send_a_buffer_subscribe(void *user, VNodeID node_id, VLayerID buffer_id)
{
VSNodeAudio *node;
unsigned int i;
node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO);
if(node == NULL)
return;
if(node->buffer_count <= buffer_id)
return;
if(node->buffers[buffer_id].name[0] == 0)
return;
vs_add_new_subscriptor(node->buffers[buffer_id].subscribers);
for(i = 0; i < node->buffers[buffer_id].length; i++)
{
if(node->buffers[buffer_id].data[i] != NULL)
verse_send_a_block_set(node_id, buffer_id, i, node->buffers[buffer_id].type, node->buffers[buffer_id].data[i]);
}
}
static void callback_send_a_buffer_unsubscribe(void *user, VNodeID node_id, VLayerID buffer_id)
{
VSNodeAudio *node;
node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO);
if(node == NULL)
return;
if(node->buffer_count <= buffer_id)
return;
if(node->buffers[buffer_id].name[0] == 0)
return;
vs_remove_subscriptor(node->buffers[buffer_id].subscribers);
}
static void callback_send_a_block_set(void *user, VNodeID node_id, VLayerID buffer_id, uint32 block_index,
VNABlockType type, const VNABlock *data)
{
static const size_t blocksize[] = {
VN_A_BLOCK_SIZE_INT8 * sizeof (int8),
VN_A_BLOCK_SIZE_INT16 * sizeof (int16),
VN_A_BLOCK_SIZE_INT24 * 3 * sizeof (int8),
VN_A_BLOCK_SIZE_INT32 * sizeof (int32),
VN_A_BLOCK_SIZE_REAL32 * sizeof (real32),
VN_A_BLOCK_SIZE_REAL64 * sizeof (real64)
};
VSNodeAudio *node;
unsigned int i, count;
if(type > VN_A_BLOCK_REAL64) /* Protect blocksize array. */
return;
node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO);
if(node == NULL)
return;
if(node->buffers[buffer_id].name[0] == 0)
return;
if(type != node->buffers[buffer_id].type) /* Disregard attempts to set data of wrong type. */
return;
if(block_index > node->buffers[buffer_id].length)
{
node->buffers[buffer_id].data = realloc(node->buffers[buffer_id].data,
(sizeof *node->buffers[buffer_id].data) * (block_index + 64));
for(i = node->buffers[buffer_id].length; i < block_index + 64; i++)
node->buffers[buffer_id].data[i] = NULL;
node->buffers[buffer_id].length = block_index + 64;
}
if(node->buffers[buffer_id].data[block_index] == NULL)
node->buffers[buffer_id].data[block_index] = malloc(blocksize[type]);
if(node->buffers[buffer_id].data[block_index] != NULL)
{
memcpy(node->buffers[buffer_id].data[block_index], data, blocksize[type]);
count = vs_get_subscript_count(node->buffers[buffer_id].subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->buffers[buffer_id].subscribers, i);
verse_send_a_block_set(node_id, buffer_id, block_index, type, data);
}
vs_reset_subscript_session();
}
}
static void callback_send_a_block_clear(void *user, VNodeID node_id, VLayerID buffer_id, uint32 id)
{
VSNodeAudio *node;
unsigned int i, count;
node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO);
if(node == NULL)
return;
if(node->buffer_count <= buffer_id)
return;
if(node->buffers[buffer_id].name[0] == 0)
return;
if(id >= node->buffers[buffer_id].length)
return;
if(node->buffers[buffer_id].data[id] == NULL)
return;
free(node->buffers[buffer_id].data[id]);
node->buffers[buffer_id].data[id] = NULL;
count = vs_get_subscript_count(node->buffers[buffer_id].subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->buffers[buffer_id].subscribers, i);
verse_send_a_block_clear(node_id, buffer_id, id);
}
vs_reset_subscript_session();
}
static void callback_send_a_stream_subscribe(void *user, VNodeID node_id, VLayerID stream_id)
{
VSNodeAudio *node;
node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO);
if(node == NULL)
return;
if(node->stream_count <= stream_id)
return;
if(node->streams[stream_id].name[0] == 0)
return;
vs_add_new_subscriptor(node->streams[stream_id].subscribers);
}
static void callback_send_a_stream_unsubscribe(void *user, VNodeID node_id, VLayerID stream_id)
{
VSNodeAudio *node;
node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO);
if(node == NULL)
return;
if(node->stream_count <= stream_id)
return;
if(node->streams[stream_id].name[0] == 0)
return;
vs_remove_subscriptor(node->streams[stream_id].subscribers);
}
static void callback_send_a_stream(void *user, VNodeID node_id, VLayerID stream_id, uint32 time_s, uint32 time_f,
VNABlockType type, real64 frequency, const VNABlock *data)
{
VSNodeAudio *node;
unsigned int i, count;
if(frequency < 0)
return;
node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO);
if(node == NULL)
return;
if(node->stream_count <= stream_id)
return;
if(node->streams[stream_id].name[0] == 0)
return;
count = vs_get_subscript_count(node->streams[stream_id].subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->streams[stream_id].subscribers, i);
verse_send_a_stream(node_id, stream_id, time_s, time_f, type, frequency, data);
}
vs_reset_subscript_session();
}
void vs_a_callback_init(void)
{
verse_callback_set(verse_send_a_buffer_create, callback_send_a_buffer_create, NULL);
verse_callback_set(verse_send_a_buffer_destroy, callback_send_a_buffer_destroy, NULL);
verse_callback_set(verse_send_a_buffer_subscribe, callback_send_a_buffer_subscribe, NULL);
verse_callback_set(verse_send_a_buffer_unsubscribe, callback_send_a_buffer_unsubscribe, NULL);
verse_callback_set(verse_send_a_block_set, callback_send_a_block_set, NULL);
verse_callback_set(verse_send_a_block_clear, callback_send_a_block_clear, NULL);
verse_callback_set(verse_send_a_stream_create, callback_send_a_stream_create, NULL);
verse_callback_set(verse_send_a_stream_destroy, callback_send_a_stream_destroy, NULL);
verse_callback_set(verse_send_a_stream_subscribe, callback_send_a_stream_subscribe, NULL);
verse_callback_set(verse_send_a_stream_unsubscribe, callback_send_a_stream_unsubscribe, NULL);
verse_callback_set(verse_send_a_stream, callback_send_a_stream, NULL);
}
#endif

@ -1,560 +0,0 @@
/*
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "v_cmd_gen.h"
#if !defined V_GENERATE_FUNC_MODE
#include "verse.h"
#include "vs_server.h"
typedef struct {
VNBLayerType type;
char name[16];
void *layer;
VSSubscriptionList *subscribers;
} VSNBLayers;
typedef struct {
VSNodeHead head;
uint16 size[3];
uint32 partial_tile_col, partial_tile_row; /* These rows/columns are partial. ~0 for none. */
VSNBLayers *layers;
unsigned int layer_count;
} VSNodeBitmap;
static unsigned long tile_counter = 0;
VSNodeBitmap * vs_b_create_node(unsigned int owner)
{
VSNodeBitmap *node;
char name[48];
node = malloc(sizeof *node);
vs_add_new_node(&node->head, V_NT_BITMAP);
sprintf(name, "Bitmap_Node_%u", node->head.id);
create_node_head(&node->head, name, owner);
node->size[0] = 0;
node->size[1] = 0;
node->size[2] = 0;
node->partial_tile_col = ~0;
node->partial_tile_row = ~0;
node->layers = NULL;
node->layer_count = 0;
return node;
}
void vs_b_destroy_node(VSNodeBitmap *node)
{
unsigned int i;
destroy_node_head(&node->head);
if(node->layers != NULL)
{
for(i = 0; i < node->layer_count; i++)
if(node->layers[i].layer != NULL)
free(node->layers[i].layer);
free(node->layers);
}
free(node);
}
void vs_b_subscribe(VSNodeBitmap *node)
{
unsigned int i;
verse_send_b_dimensions_set(node->head.id, node->size[0], node->size[1], node->size[2]);
for(i = 0; i < node->layer_count; i++)
if(node->layers[i].name[0] != 0)
verse_send_b_layer_create(node->head.id, (uint16)i, node->layers[i].name, (uint8)node->layers[i].type);
}
void vs_b_unsubscribe(VSNodeBitmap *node)
{
unsigned int i;
for(i = 0; i < node->layer_count; i++)
if(node->layers[i].name[0] != 0)
vs_remove_subscriptor(node->layers[i].subscribers);
}
static void callback_send_b_dimensions_set(void *user, VNodeID node_id, uint16 width, uint16 height, uint16 depth)
{
VSNodeBitmap *node;
unsigned int i, j, k, count, tiles[2], read, write, end = 0;
if((node = (VSNodeBitmap *)vs_get_node(node_id, V_NT_BITMAP)) == NULL)
return;
tiles[0] = (width + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE;
tiles[1] = (height + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE;
node->size[0] = (node->size[0] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE;
node->size[1] = (node->size[1] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE;
if(node->size[0] > tiles[0])
node->size[0] = tiles[0];
if(node->size[1] > tiles[1])
node->size[1] = tiles[1];
if(node->size[2] > depth)
node->size[2] = depth;
for(i = 0; i < node->layer_count; i++)
{
if(node->layers[i].name[0] != 0)
{
switch(node->layers[i].type)
{
case VN_B_LAYER_UINT1 :
{
uint16 *array, *old;
write = 0;
old = node->layers[i].layer;
array = node->layers[i].layer = malloc((sizeof *array) * tiles[0] * tiles[1] * depth);
for(j = 0; j < node->size[2]; j++)
{
for(k = 0; k < node->size[1]; k++)
{
read = (j * node->size[1] * node->size[0] + k * node->size[0]);
end = (j * tiles[1] * tiles[0] + k * tiles[0] + node->size[0]);
while(write < end)
array[write++] = old[read++];
end = (j * tiles[1] * tiles[0] + (k + 1) * tiles[0]);
while(write < end)
array[write++] = 0;
}
end = ((j + 1) * tiles[1] * tiles[0]);
while(write < end)
array[write++] = 0;
}
k = depth * tiles[1] * tiles[0];
while(write < end)
array[write++] = 0;
}
break;
case VN_B_LAYER_UINT8 :
{
uint8 *array, *old;
write = 0;
old = node->layers[i].layer;
array = node->layers[i].layer = malloc((sizeof *array) * tiles[0] * tiles[1] * depth * VN_B_TILE_SIZE * VN_B_TILE_SIZE);
for(j = 0; j < node->size[2]; j++)
{
for(k = 0; k < node->size[1]; k++)
{
read = (j * node->size[1] * node->size[0] + k * node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
end = (j * tiles[1] * tiles[0] + k * tiles[0] + node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = old[read++];
end = (j * tiles[1] * tiles[0] + (k + 1) * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = 0;
}
end = ((j + 1) * tiles[1] * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = 0;
}
end = depth * tiles[1] * tiles[0] * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = 0;
}
break;
case VN_B_LAYER_UINT16 :
{
uint16 *array, *old;
write = 0;
old = node->layers[i].layer;
array = node->layers[i].layer = malloc((sizeof *array) * tiles[0] * tiles[1] * depth * VN_B_TILE_SIZE * VN_B_TILE_SIZE);
for(j = 0; j < node->size[2]; j++)
{
for(k = 0; k < node->size[1]; k++)
{
read = (j * node->size[1] * node->size[0] + k * node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
end = (j * tiles[1] * tiles[0] + k * tiles[0] + node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = old[read++];
end = (j * tiles[1] * tiles[0] + (k + 1) * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = 0;
}
end = ((j + 1) * tiles[1] * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = 0;
}
end = depth * tiles[1] * tiles[0] * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = 0;
}
break;
case VN_B_LAYER_REAL32 :
{
real32 *array, *old;
write = 0;
old = node->layers[i].layer;
array = node->layers[i].layer = malloc((sizeof *array) * tiles[0] * tiles[1] * depth * VN_B_TILE_SIZE * VN_B_TILE_SIZE);
for(j = 0; j < node->size[2]; j++)
{
for(k = 0; k < node->size[1]; k++)
{
read = (j * node->size[1] * node->size[0] + k * node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
end = (j * tiles[1] * tiles[0] + k * tiles[0] + node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = old[read++];
end = (j * tiles[1] * tiles[0] + (k + 1) * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = 0;
}
end = ((j + 1) * tiles[1] * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = 0;
}
end = depth * tiles[1] * tiles[0] * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = 0;
}
break;
case VN_B_LAYER_REAL64 :
{
real64 *array, *old;
write = 0;
old = node->layers[i].layer;
array = node->layers[i].layer = malloc((sizeof *array) * tiles[0] * tiles[1] * depth * VN_B_TILE_SIZE * VN_B_TILE_SIZE);
for(j = 0; j < node->size[2]; j++)
{
for(k = 0; k < node->size[1]; k++)
{
read = (j * node->size[1] * node->size[0] + k * node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
end = (j * tiles[1] * tiles[0] + k * tiles[0] + node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = old[read++];
end = (j * tiles[1] * tiles[0] + (k + 1) * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = 0;
}
end = ((j + 1) * tiles[1] * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = 0;
}
end = depth * tiles[1] * tiles[0] * VN_B_TILE_SIZE * VN_B_TILE_SIZE;
while(write < end)
array[write++] = 0;
}
break;
}
}
}
node->size[0] = width;
node->size[1] = height;
node->size[2] = depth;
node->partial_tile_col = (width % VN_B_TILE_SIZE) != 0 ? (width + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE - 1 : ~0;
node->partial_tile_row = (height % VN_B_TILE_SIZE) != 0 ? (height + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE - 1 : ~0;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_b_dimensions_set(node_id, width, height, depth);
}
vs_reset_subscript_session();
}
static void callback_send_b_layer_create(void *user, VNodeID node_id, VLayerID layer_id, char *name, uint8 type)
{
VSNodeBitmap *node;
unsigned int i, count;
if((node = (VSNodeBitmap *)vs_get_node(node_id, V_NT_BITMAP)) == NULL)
return;
if(node->layer_count <= layer_id || node->layers[layer_id].name[0] == 0)
{
for(layer_id = 0; layer_id < node->layer_count && node->layers[layer_id].name[0] != 0; layer_id++)
;
if(layer_id == node->layer_count)
{
node->layers = realloc(node->layers, (sizeof *node->layers) * (node->layer_count + 16));
for(i = node->layer_count; i < node->layer_count + 16; i++)
{
node->layers[i].layer = NULL;
node->layers[i].type = 0;
node->layers[i].name[0] = 0;
node->layers[i].subscribers = NULL;
}
node->layer_count += 16;
}
node->layers[layer_id].subscribers = vs_create_subscription_list();
node->layers[layer_id].type = type + 1;
}
if(node->layers[layer_id].type != type || node->layers[layer_id].name[0] == 0)
{
count = ((node->size[0] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE) * ((node->size[1] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE);
count *= VN_B_TILE_SIZE * VN_B_TILE_SIZE * node->size[2];
if(node->layers[layer_id].layer != NULL)
free(node->layers[layer_id].layer);
if(count != 0)
{
switch(type)
{
case VN_B_LAYER_UINT1 :
node->layers[layer_id].layer = malloc(sizeof(uint8) * count / 8);
memset(node->layers[layer_id].layer, 0, count * sizeof(uint8) / 8);
break;
case VN_B_LAYER_UINT8 :
node->layers[layer_id].layer = malloc(sizeof(uint8) * count);
memset(node->layers[layer_id].layer, 0, count * sizeof(uint8));
break;
case VN_B_LAYER_UINT16 :
node->layers[layer_id].layer = malloc(sizeof(uint16) * count);
memset(node->layers[layer_id].layer, 0, count * sizeof(uint16));
break;
case VN_B_LAYER_REAL32 :
node->layers[layer_id].layer = malloc(sizeof(real32) * count);
memset(node->layers[layer_id].layer, 0, count * sizeof(real32));
break;
case VN_B_LAYER_REAL64 :
node->layers[layer_id].layer = malloc(sizeof(real64) * count);
memset(node->layers[layer_id].layer, 0, count * sizeof(real64));
break;
}
}else
node->layers[layer_id].layer = NULL;
}
node->layers[layer_id].type = type;
for(i = 0; i < 15 && name[i] != 0; i++)
node->layers[layer_id].name[i] = name[i];
node->layers[layer_id].name[i] = 0;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_b_layer_create(node_id, layer_id, name, type);
}
vs_reset_subscript_session();
}
static void callback_send_b_layer_destroy(void *user, VNodeID node_id, VLayerID layer_id)
{
VSNodeBitmap *node;
unsigned int i, count;
if((node = (VSNodeBitmap *)vs_get_node(node_id, V_NT_BITMAP)) == NULL)
return;
if(layer_id >= node->layer_count || node->layers[layer_id].layer == NULL)
return;
if(node->layers[layer_id].layer != NULL)
free(node->layers[layer_id].layer);
node->layers[layer_id].layer = NULL;
node->layers[layer_id].type = 0;
node->layers[layer_id].name[0] = 0;
vs_destroy_subscription_list(node->layers[layer_id].subscribers);
node->layers[layer_id].subscribers = NULL;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_b_layer_destroy(node_id, layer_id);
}
vs_reset_subscript_session();
}
static void callback_send_b_layer_subscribe(void *user, VNodeID node_id, VLayerID layer_id, uint8 level)
{
VSNodeBitmap *node;
const void *data;
unsigned int i, j, k, tile[3];
if((node = (VSNodeBitmap *)vs_get_node(node_id, V_NT_BITMAP)) == NULL)
return;
if(layer_id >= node->layer_count || node->layers[layer_id].layer == NULL)
return;
if(vs_add_new_subscriptor(node->layers[layer_id].subscribers) == 0)
return;
tile[0] = ((node->size[0] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE);
tile[1] = ((node->size[1] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE);
tile[2] = node->size[2];
data = node->layers[layer_id].layer;
switch(node->layers[layer_id].type)
{
case VN_B_LAYER_UINT1:
for(i = 0; i < tile[0]; i++)
for(j = 0; j < tile[1]; j++)
for(k = 0; k < tile[2]; k++)
verse_send_b_tile_set(node_id, layer_id, i, j, k, VN_B_LAYER_UINT1, (VNBTile *) &((uint8*)data)[(tile[0] * tile[1] * k + j * tile[0] + i) * VN_B_TILE_SIZE * VN_B_TILE_SIZE / 8]);
break;
case VN_B_LAYER_UINT8 :
for(i = 0; i < tile[0]; i++)
for(j = 0; j < tile[1]; j++)
for(k = 0; k < tile[2]; k++)
verse_send_b_tile_set(node_id, layer_id, i, j, k, VN_B_LAYER_UINT8, (VNBTile *) &((uint8*)data)[(tile[0] * tile[1] * k + j * tile[0] + i) * VN_B_TILE_SIZE * VN_B_TILE_SIZE]);
break;
case VN_B_LAYER_UINT16 :
for(i = 0; i < tile[0]; i++)
for(j = 0; j < tile[1]; j++)
for(k = 0; k < tile[2]; k++)
verse_send_b_tile_set(node_id, layer_id, i, j, k, VN_B_LAYER_UINT16, (VNBTile *) &((uint16*)data)[(tile[0] * tile[1] * k + j * tile[0] + i) * VN_B_TILE_SIZE * VN_B_TILE_SIZE]);
break;
case VN_B_LAYER_REAL32 :
for(i = 0; i < tile[0]; i++)
for(j = 0; j < tile[1]; j++)
for(k = 0; k < tile[2]; k++)
verse_send_b_tile_set(node_id, layer_id, i, j, k, VN_B_LAYER_REAL32, (VNBTile *) &((real32*)data)[(tile[0] * tile[1] * k + j * tile[0] + i) * VN_B_TILE_SIZE * VN_B_TILE_SIZE]);
break;
case VN_B_LAYER_REAL64 :
for(i = 0; i < tile[0]; i++)
for(j = 0; j < tile[1]; j++)
for(k = 0; k < tile[2]; k++)
verse_send_b_tile_set(node_id, layer_id, i, j, k, VN_B_LAYER_REAL64, (VNBTile *) &((real64*)data)[(tile[0] * tile[1] * k + j * tile[0] + i) * VN_B_TILE_SIZE * VN_B_TILE_SIZE]);
break;
}
}
static void callback_send_b_layer_unsubscribe(void *user, VNodeID node_id, VLayerID layer_id)
{
VSNodeBitmap *node;
if((node = (VSNodeBitmap *)vs_get_node(node_id, V_NT_BITMAP)) == NULL)
return;
if(layer_id >= node->layer_count || node->layers[layer_id].layer == NULL)
return;
vs_remove_subscriptor(node->layers[layer_id].subscribers);
}
/* Clear any pixels that lie outside the image, so we don't violoate specs when
* sending (stored version of) the tile out to subscribers.
*/
static void clear_outside(const VSNodeBitmap *node, uint16 tile_x, uint16 tile_y, uint8 type, VNBTile *tile)
{
int x, y, bx, by, p;
by = tile_y * VN_B_TILE_SIZE;
for(y = p = 0; y < VN_B_TILE_SIZE; y++, by++)
{
bx = tile_x * VN_B_TILE_SIZE;
for(x = 0; x < VN_B_TILE_SIZE; x++, bx++, p++)
{
/* Simply test current pixel against bitmap size. Not quick, but simple. */
if(bx >= node->size[0] || by >= node->size[1])
{
switch(type)
{
case VN_B_LAYER_UINT1:
tile->vuint1[y] &= ~(128 >> x);
break;
case VN_B_LAYER_UINT8:
tile->vuint8[p] = 0;
break;
case VN_B_LAYER_UINT16:
tile->vuint16[p] = 0;
break;
case VN_B_LAYER_REAL32:
tile->vreal32[p] = 0.0f;
break;
case VN_B_LAYER_REAL64:
tile->vreal64[p] = 0.0;
break;
}
}
}
}
}
static void callback_send_b_tile_set(void *user, VNodeID node_id, VLayerID layer_id,
uint16 tile_x, uint16 tile_y, uint16 tile_z, uint8 type, VNBTile *data)
{
VSNodeBitmap *node;
unsigned int i, count, tile[3];
if((node = (VSNodeBitmap *)vs_get_node(node_id, V_NT_BITMAP)) == NULL)
{
printf("got tile for unknown bitmpa node %u, aborting\n", node_id);
return;
}
if(layer_id >= node->layer_count || node->layers[layer_id].layer == NULL || node->layers[layer_id].type != type)
{
printf("node %u got tile for bad layer %u (have %u) %p\n", node_id, layer_id, node->layer_count, layer_id < node->layer_count ? node->layers[layer_id].layer : NULL);
return;
}
if(tile_x >= ((node->size[0] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE) || tile_y >= ((node->size[1] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE) || tile_z >= node->size[2])
{
printf("got tile that is outside image, at (%u,%u,%u)\n", tile_x, tile_y, tile_z);
return;
}
tile_counter++;
tile[0] = ((node->size[0] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE);
tile[1] = ((node->size[1] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE);
tile[2] = node->size[2];
/* If tile is in a partial column or row, clear the "outside" pixels. */
if((uint32) tile_x == node->partial_tile_col || (uint32) tile_y == node->partial_tile_row)
clear_outside(node, tile_x, tile_y, type, data);
switch(node->layers[layer_id].type)
{
case VN_B_LAYER_UINT1 :
{
uint8 *p;
p = &((uint8 *)node->layers[layer_id].layer)[(tile[0] * tile[1] * tile_z + tile_y * tile[0] + tile_x) * VN_B_TILE_SIZE * VN_B_TILE_SIZE/8];
memcpy(p, data->vuint1, VN_B_TILE_SIZE * sizeof(uint8));
}
break;
case VN_B_LAYER_UINT8 :
{
uint8 *p;
p = &((uint8 *)node->layers[layer_id].layer)[(tile[0] * tile[1] * tile_z + tile_y * tile[0] + tile_x) * VN_B_TILE_SIZE * VN_B_TILE_SIZE];
memcpy(p, data->vuint8, VN_B_TILE_SIZE * VN_B_TILE_SIZE * sizeof(uint8));
}
break;
case VN_B_LAYER_UINT16 :
{
uint16 *p;
p = &((uint16 *)node->layers[layer_id].layer)[(tile[0] * tile[1] * tile_z + tile_y * tile[0] + tile_x) * VN_B_TILE_SIZE * VN_B_TILE_SIZE];
memcpy(p, data->vuint16, VN_B_TILE_SIZE * VN_B_TILE_SIZE * sizeof(uint16));
}
break;
case VN_B_LAYER_REAL32 :
{
real32 *p;
p = &((real32 *)node->layers[layer_id].layer)[(tile[0] * tile[1] * tile_z + tile_y * tile[0] + tile_x) * VN_B_TILE_SIZE * VN_B_TILE_SIZE];
memcpy(p, data->vreal32, VN_B_TILE_SIZE * VN_B_TILE_SIZE * sizeof(real32));
}
break;
case VN_B_LAYER_REAL64 :
{
real64 *p;
p = &((real64 *)node->layers[layer_id].layer)[(tile[0] * tile[1] * tile_z + tile_y * tile[0] + tile_x) * VN_B_TILE_SIZE * VN_B_TILE_SIZE];
memcpy(p, data->vreal64, VN_B_TILE_SIZE * VN_B_TILE_SIZE * sizeof(real64));
}
break;
}
count = vs_get_subscript_count(node->layers[layer_id].subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->layers[layer_id].subscribers, i);
verse_send_b_tile_set(node_id, layer_id, tile_x, tile_y, tile_z, type, data);
}
vs_reset_subscript_session();
}
void vs_b_callback_init(void)
{
verse_callback_set(verse_send_b_dimensions_set, callback_send_b_dimensions_set, NULL);
verse_callback_set(verse_send_b_layer_create, callback_send_b_layer_create, NULL);
verse_callback_set(verse_send_b_layer_destroy, callback_send_b_layer_destroy, NULL);
verse_callback_set(verse_send_b_layer_subscribe, callback_send_b_layer_subscribe, NULL);
verse_callback_set(verse_send_b_layer_unsubscribe, callback_send_b_layer_unsubscribe, NULL);
verse_callback_set(verse_send_b_tile_set, callback_send_b_tile_set, NULL);
}
#endif

@ -1,258 +0,0 @@
/*
**
*/
#include <stdio.h>
#include <stdlib.h>
#include "v_cmd_gen.h"
#if !defined V_GENERATE_FUNC_MODE
#include "verse.h"
#include "vs_server.h"
typedef struct {
real64 pre_value[4];
uint32 pre_pos[4];
real64 value[4];
real64 pos;
real64 post_value[4];
uint32 post_pos[4];
} VSNKey;
typedef struct {
VSNKey *keys;
unsigned int length;
char name[16];
uint8 dimensions;
VSSubscriptionList *subscribers;
} VSNCurve;
typedef struct{
VSNodeHead head;
VSNCurve *curves;
unsigned int curve_count;
} VSNodeCurve;
VSNodeCurve * vs_c_create_node(unsigned int owner)
{
VSNodeCurve *node;
char name[48];
unsigned int i;
node = malloc(sizeof *node);
vs_add_new_node(&node->head, V_NT_CURVE);
sprintf(name, "Curve_Node_%u", node->head.id);
create_node_head(&node->head, name, owner);
node->curves = malloc((sizeof *node->curves) * 16);
node->curve_count = 16;
for(i = 0; i < 16; i++)
node->curves[i].name[0] = 0;
return node;
}
void vs_c_destroy_node(VSNodeCurve *node)
{
destroy_node_head(&node->head);
free(node);
}
void vs_c_subscribe(VSNodeCurve *node)
{
unsigned int i;
if(node == NULL)
return;
for(i = 0; i < node->curve_count; i++)
if(node->curves[i].name[0] != 0)
verse_send_c_curve_create(node->head.id, i, node->curves[i].name, node->curves[i].dimensions);
}
void vs_c_unsubscribe(VSNodeCurve *node)
{
unsigned int i;
for(i = 0; i < node->curve_count; i++)
if(node->curves[i].name[0] != 0)
vs_remove_subscriptor(node->curves[i].subscribers);
}
static void callback_send_c_curve_create(void *user, VNodeID node_id, VLayerID curve_id, const char *name, uint8 dimensions)
{
VSNodeCurve *node;
unsigned int i, j, count;
node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE);
if(node == NULL)
return;
for(i = 0; i < node->curve_count; i++)
{
if(curve_id != i)
{
for(j = 0; name[j] == node->curves[i].name[j] && name[j] != 0; j++);
if(name[j] == node->curves[i].name[j])
return;
}
}
if(curve_id >= node->curve_count || node->curves[curve_id].name[0] == 0)
{
for(curve_id = 0; curve_id < node->curve_count && node->curves[curve_id].name[0] != 0; curve_id++);
if(curve_id == node->curve_count)
{
curve_id = node->curve_count;
node->curve_count += 16;
node->curves = realloc(node->curves, (sizeof *node->curves) * node->curve_count);
for(i = curve_id; i < node->curve_count; i++)
node->curves[i].name[0] = 0;
}
node->curves[curve_id].subscribers = vs_create_subscription_list();
node->curves[curve_id].length = 64;
node->curves[curve_id].keys = malloc((sizeof *node->curves[curve_id].keys) * 64);
for(i = 0; i < 64; i++)
node->curves[curve_id].keys[i].pos = V_REAL64_MAX;
}else if(node->curves[curve_id].dimensions != dimensions)
{
for(i = 0; i < node->curves[curve_id].length; i++)
{
if(node->curves[curve_id].keys[i].pos != V_REAL64_MAX)
{
for(j = node->curves[curve_id].dimensions; j < dimensions; j++)
{
node->curves[curve_id].keys[i].pre_value[j] = node->curves[curve_id].keys[i].pre_value[0];
node->curves[curve_id].keys[i].pre_pos[j] = node->curves[curve_id].keys[i].pre_pos[0];
node->curves[curve_id].keys[i].value[j] = node->curves[curve_id].keys[i].value[0];
node->curves[curve_id].keys[i].post_value[j] = node->curves[curve_id].keys[i].post_value[0];
node->curves[curve_id].keys[i].post_pos[j] = node->curves[curve_id].keys[i].post_pos[0];
}
}
}
vs_destroy_subscription_list(node->curves[curve_id].subscribers);
node->curves[curve_id].subscribers = vs_create_subscription_list();
}
for(i = 0; name[i] != 0 && i < 15; i++)
node->curves[curve_id].name[i] = name[i];
node->curves[curve_id].name[i] = 0;
node->curves[curve_id].dimensions = dimensions;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_c_curve_create(node_id, curve_id, name, dimensions);
}
vs_reset_subscript_session();
}
static void callback_send_c_curve_destroy(void *user, VNodeID node_id, VLayerID curve_id)
{
VSNodeCurve *node;
unsigned int i, count;
node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE);
if(node == NULL || node->curve_count >= curve_id || node->curves[curve_id].name[0] == 0)
return;
vs_remove_subscriptor(node->curves[curve_id].subscribers);
node->curves[curve_id].name[0] = 0;
free(node->curves[curve_id].keys);
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_c_curve_destroy(node_id, curve_id);
}
vs_reset_subscript_session();
}
static void callback_send_c_key_set(void *user, VNodeID node_id, VLayerID curve_id, uint32 key_id, uint8 dimensions, real64 *pre_value, uint32 *pre_pos, real64 *value, real64 pos, real64 *post_value, uint32 *post_pos)
{
VSNodeCurve *node;
unsigned int i, count;
node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE);
if(node == NULL)
return;
if(node->curve_count <= curve_id)
return;
if(node->curves[curve_id].name[0] == 0)
return;
if(node == NULL || node->curve_count <= curve_id || node->curves[curve_id].name[0] == 0 || node->curves[curve_id].dimensions != dimensions)
return;
if(node->curves[curve_id].length <= key_id || node->curves[curve_id].keys[key_id].pos == V_REAL64_MAX)
{
for(key_id = 0; key_id < node->curves[curve_id].length && node->curves[curve_id].keys[key_id].pos != V_REAL64_MAX; key_id++);
if(key_id == node->curves[curve_id].length)
for(i = 0; i < 64; i++)
node->curves[curve_id].keys[node->curves[curve_id].length++].pos = V_REAL64_MAX;
}
for(i = 0; i < dimensions; i++)
node->curves[curve_id].keys[key_id].pre_value[i] = pre_value[i];
for(i = 0; i < dimensions; i++)
node->curves[curve_id].keys[key_id].pre_pos[i] = pre_pos[i];
for(i = 0; i < dimensions; i++)
node->curves[curve_id].keys[key_id].value[i] = value[i];
node->curves[curve_id].keys[key_id].pos = pos;
for(i = 0; i < dimensions; i++)
node->curves[curve_id].keys[key_id].post_value[i] = post_value[i];
for(i = 0; i < dimensions; i++)
node->curves[curve_id].keys[key_id].post_pos[i] = post_pos[i];
count = vs_get_subscript_count(node->curves[curve_id].subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->curves[curve_id].subscribers, i);
verse_send_c_key_set(node_id, curve_id, key_id, dimensions, pre_value, pre_pos, value, pos, post_value, post_pos);
}
vs_reset_subscript_session();
}
static void callback_send_c_key_destroy(void *user, VNodeID node_id, VLayerID curve_id, uint32 key_id)
{
VSNodeCurve *node;
unsigned int i, count;
node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE);
if(node == NULL || node->curve_count <= curve_id || node->curves[curve_id].name[0] == 0)
return;
if(node->curves[curve_id].length <= key_id || node->curves[curve_id].keys[key_id].pos == V_REAL64_MAX)
return;
node->curves[curve_id].keys[key_id].pos = V_REAL64_MAX;
count = vs_get_subscript_count(node->curves[curve_id].subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->curves[curve_id].subscribers, i);
verse_send_c_key_destroy(node_id, curve_id, key_id);
}
vs_reset_subscript_session();
}
static void callback_send_c_curve_subscribe(void *user, VNodeID node_id, VLayerID curve_id)
{
VSNodeCurve *node;
unsigned int i;
node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE);
if(node == NULL || node->curve_count <= curve_id || node->curves[curve_id].name[0] == 0)
return;
vs_add_new_subscriptor(node->curves[curve_id].subscribers);
for(i = 0; i < node->curves[curve_id].length; i++)
if(node->curves[curve_id].keys[i].pos != V_REAL64_MAX)
verse_send_c_key_set(node_id, curve_id, i, node->curves[curve_id].dimensions, node->curves[curve_id].keys[i].pre_value, node->curves[curve_id].keys[i].pre_pos, node->curves[curve_id].keys[i].value, node->curves[curve_id].keys[i].pos, node->curves[curve_id].keys[i].post_value, node->curves[curve_id].keys[i].post_pos);
}
static void callback_send_c_curve_unsubscribe(void *user, VNodeID node_id, VLayerID curve_id)
{
VSNodeCurve *node;
node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE);
if(node == NULL || curve_id >= node->curve_count || node->curves[curve_id].name[0] == 0)
return;
vs_remove_subscriptor(node->curves[curve_id].subscribers);
}
void vs_c_callback_init(void)
{
verse_callback_set(verse_send_c_curve_create, callback_send_c_curve_create, NULL);
verse_callback_set(verse_send_c_curve_destroy, callback_send_c_curve_destroy, NULL);
verse_callback_set(verse_send_c_curve_subscribe, callback_send_c_curve_subscribe, NULL);
verse_callback_set(verse_send_c_curve_unsubscribe, callback_send_c_curve_unsubscribe, NULL);
verse_callback_set(verse_send_c_key_set, callback_send_c_key_set, NULL);
verse_callback_set(verse_send_c_key_destroy, callback_send_c_key_destroy, NULL);
}
#endif

File diff suppressed because it is too large Load Diff

@ -1,414 +0,0 @@
/*
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "v_cmd_gen.h"
#if !defined(V_GENERATE_FUNC_MODE)
#include "verse.h"
#include "v_util.h"
#include "vs_server.h"
typedef struct {
VNTag tag;
VNTagType type;
char tag_name[16];
} VSTag;
typedef struct {
VSTag *tags;
unsigned int tag_count;
char group_name[16];
VSSubscriptionList *subscribers;
} VSTagGroup;
void create_node_head(VSNodeHead *node, const char *name, unsigned int owner)
{
size_t len;
len = strlen(name) + 1;
node->name = malloc(len);
v_strlcpy(node->name, name, len);
node->owner = owner;
node->tag_groups = NULL;
node->group_count = 0;
node->subscribers = vs_create_subscription_list();
}
void destroy_node_head(VSNodeHead *node)
{
unsigned int i, j;
if(node->name != NULL)
free(node->name);
if(node->tag_groups != NULL)
{
for(i = 0; i < node->group_count; i++)
{
for(j = 0; j < ((VSTagGroup *)node->tag_groups)[i].tag_count; j++)
{
if(((VSTagGroup *)node->tag_groups)[i].tags[j].type == VN_TAG_STRING)
free(((VSTagGroup *)node->tag_groups)[i].tags[j].tag.vstring);
if(((VSTagGroup *)node->tag_groups)[i].tags[j].type == VN_TAG_BLOB)
free(((VSTagGroup *)node->tag_groups)[i].tags[j].tag.vblob.blob);
}
if(((VSTagGroup *)node->tag_groups)[i].tags != NULL)
free(((VSTagGroup *)node->tag_groups)[i].tags);
}
if(node->tag_groups != NULL)
free(node->tag_groups);
}
}
void callback_send_tag_group_create(void *user, VNodeID node_id, uint16 group_id, const char *name)
{
VSNodeHead *node;
unsigned int count, i, j, element;
if((node = vs_get_node_head(node_id)) == 0)
return;
if(name[0] == 0)
return;
for(i = 0; i < node->group_count; i++) /* see if a tag group with this name alredy exists*/
{
if(((VSTagGroup *)node->tag_groups)[i].group_name[0] != 0)
{
for(j = 0; name[j] == ((VSTagGroup *)node->tag_groups)[i].group_name[j] && name[j] != 0; j++);
if(name[j] == ((VSTagGroup *)node->tag_groups)[i].group_name[j])
return;
}
}
if(group_id < node->group_count && ((VSTagGroup *)node->tag_groups)[group_id].group_name[0] != 0) /* rename existing group */
{
element = group_id;
}else /* create new game group */
{
for(element = 0; element < node->group_count && ((VSTagGroup *)node->tag_groups)[element].group_name[0] != 0; element++);
if(element == node->group_count)
{
node->tag_groups = realloc(node->tag_groups, sizeof(VSTagGroup) * (node->group_count + 16));
for(i = node->group_count; i < node->group_count + 16U; i++)
{
((VSTagGroup *)node->tag_groups)[i].group_name[0] = 0;
((VSTagGroup *)node->tag_groups)[i].tags = NULL;
((VSTagGroup *)node->tag_groups)[i].tag_count = 0;
((VSTagGroup *)node->tag_groups)[i].subscribers = NULL;
}
node->group_count += 16;
}
((VSTagGroup *)node->tag_groups)[element].subscribers = vs_create_subscription_list();
}
v_strlcpy(((VSTagGroup *)node->tag_groups)[element].group_name, name,
sizeof ((VSTagGroup *)node->tag_groups)[element].group_name);
count = vs_get_subscript_count(node->subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->subscribers, i);
verse_send_tag_group_create(node_id, element, name);
}
vs_reset_subscript_session();
}
static void callback_send_tag_group_destroy(void *user, VNodeID node_id, uint16 group_id)
{
VSNodeHead *node;
unsigned int count, i;
if((node = vs_get_node_head(node_id)) == 0)
return;
if(node->group_count <= group_id || ((VSTagGroup *)node->tag_groups)[group_id].group_name[0] == 0)
return;
vs_destroy_subscription_list(((VSTagGroup *)node->tag_groups)[group_id].subscribers);
for(i = 0; i < ((VSTagGroup *)node->tag_groups)[group_id].tag_count; i++)
{
if(((VSTagGroup *)node->tag_groups)[group_id].tags[i].type == VN_TAG_STRING)
free(((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag.vstring);
if(((VSTagGroup *)node->tag_groups)[group_id].tags[i].type == VN_TAG_BLOB)
free(((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag.vblob.blob);
}
if(((VSTagGroup *)node->tag_groups)[group_id].tags != NULL)
free(((VSTagGroup *)node->tag_groups)[group_id].tags);
((VSTagGroup *)node->tag_groups)[group_id].group_name[0] = 0;
((VSTagGroup *)node->tag_groups)[group_id].tags = NULL;
((VSTagGroup *)node->tag_groups)[group_id].tag_count = 0;
count = vs_get_subscript_count(node->subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->subscribers, i);
verse_send_tag_group_destroy(node_id, group_id);
}
vs_reset_subscript_session();
}
static void callback_send_tag_group_subscribe(void *user, VNodeID node_id, uint16 group_id)
{
VSNodeHead *node;
unsigned int i;
if((node = vs_get_node_head(node_id)) == 0)
return;
if(group_id < node->group_count && ((VSTagGroup *)node->tag_groups)[group_id].group_name[0] != 0)
{
vs_add_new_subscriptor(((VSTagGroup *)node->tag_groups)[group_id].subscribers);
for(i = 0; i < ((VSTagGroup *)node->tag_groups)[group_id].tag_count; i++)
{
if(((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag_name[0] != 0)
{
verse_send_tag_create(node_id, group_id, (uint16)i, ((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag_name, ((VSTagGroup *)node->tag_groups)[group_id].tags[i].type, &((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag);
}
}
}
}
static void callback_send_tag_group_unsubscribe(void *user, VNodeID node_id, uint16 group_id)
{
VSNodeHead *node;
if((node = vs_get_node_head(node_id)) == 0)
return;
if(group_id < node->group_count && ((VSTagGroup *)node->tag_groups)[group_id].group_name[0] != 0)
vs_remove_subscriptor(((VSTagGroup *)node->tag_groups)[group_id].subscribers);
}
static void callback_send_tag_create(void *user, VNodeID node_id, uint16 group_id, uint16 tag_id, char *name, uint8 type, void *tag)
{
VSNodeHead *node;
VSTag *t = NULL;
unsigned int i, count;
if((node = vs_get_node_head(node_id)) == 0)
return;
if(group_id >= node->group_count || ((VSTagGroup *)node->tag_groups)[group_id].group_name[0] == 0)
return;
/* for(i = 0; i < ((VSTagGroup *)node->tag_groups)[group_id].tag_count; i++)
{
if(((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag_name != NULL && i != tag_id)
{
for(j = 0; name[j] == ((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag_name[j] && name[j] != 0; j++);
if(name[j] == ((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag_name[j])
return;
}
}*/
if(tag_id < ((VSTagGroup *)node->tag_groups)[group_id].tag_count && ((VSTagGroup *)node->tag_groups)[group_id].tags[tag_id].tag_name[0] != 0)
;
else
{
for(tag_id = 0; tag_id < ((VSTagGroup *)node->tag_groups)[group_id].tag_count && ((VSTagGroup *)node->tag_groups)[group_id].tags[tag_id].tag_name[0] != 0; tag_id++)
;
if(tag_id == ((VSTagGroup *)node->tag_groups)[group_id].tag_count)
{
((VSTagGroup *)node->tag_groups)[group_id].tags = realloc(((VSTagGroup *)node->tag_groups)[group_id].tags, sizeof(VSTag) * (((VSTagGroup *)node->tag_groups)[group_id].tag_count + 16));
for(i = tag_id; i < ((VSTagGroup *)node->tag_groups)[group_id].tag_count + 16; i++)
((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag_name[0] = 0;
((VSTagGroup *)node->tag_groups)[group_id].tag_count += 16;
}
}
t = &((VSTagGroup *)node->tag_groups)[group_id].tags[tag_id];
if(t->tag_name[0] != '\0') /* Old tag being re-set? */
{
if(t->type == VN_TAG_STRING)
free(t->tag.vstring);
else if(t->type == VN_TAG_BLOB)
free(t->tag.vblob.blob);
}
t->type = type;
v_strlcpy(t->tag_name, name, sizeof t->tag_name);
switch(type)
{
case VN_TAG_BOOLEAN :
t->tag.vboolean = ((VNTag *)tag)->vboolean;
break;
case VN_TAG_UINT32 :
t->tag.vuint32 = ((VNTag *)tag)->vuint32;
break;
case VN_TAG_REAL64 :
t->tag.vreal64 = ((VNTag *)tag)->vreal64;
break;
case VN_TAG_STRING :
i = strlen(((VNTag *) tag)->vstring);
t->tag.vstring = malloc(i + 1);
strcpy(t->tag.vstring, ((VNTag *) tag)->vstring);
break;
case VN_TAG_REAL64_VEC3 :
t->tag.vreal64_vec3[0] = ((VNTag *)tag)->vreal64_vec3[0];
t->tag.vreal64_vec3[1] = ((VNTag *)tag)->vreal64_vec3[1];
t->tag.vreal64_vec3[2] = ((VNTag *)tag)->vreal64_vec3[2];
break;
case VN_TAG_LINK :
t->tag.vlink = ((VNTag *)tag)->vlink;
break;
case VN_TAG_ANIMATION :
t->tag.vanimation.curve = ((VNTag *)tag)->vanimation.curve;
t->tag.vanimation.start = ((VNTag *)tag)->vanimation.start;
t->tag.vanimation.end = ((VNTag *)tag)->vanimation.end;
break;
case VN_TAG_BLOB :
t->tag.vblob.blob = malloc(((VNTag *)tag)->vblob.size);
t->tag.vblob.size = ((VNTag *)tag)->vblob.size;
memcpy(t->tag.vblob.blob, ((VNTag *)tag)->vblob.blob, ((VNTag *)tag)->vblob.size);
break;
}
count = vs_get_subscript_count(((VSTagGroup *) node->tag_groups)[group_id].subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(((VSTagGroup *) node->tag_groups)[group_id].subscribers, i);
verse_send_tag_create(node_id, group_id, tag_id, name, type, tag);
}
vs_reset_subscript_session();
}
static void callback_send_tag_destroy(void *user, VNodeID node_id, uint16 group_id, uint16 tag_id)
{
VSNodeHead *node;
unsigned int count, i;
if((node = vs_get_node_head(node_id)) == 0)
return;
count = vs_get_subscript_count(((VSTagGroup *) node->tag_groups)[group_id].subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(((VSTagGroup *) node->tag_groups)[group_id].subscribers, i);
verse_send_tag_destroy(node_id, group_id, tag_id);
}
vs_reset_subscript_session();
}
static void callback_send_node_name_set(void *user, VNodeID node_id, char *name)
{
VSNodeHead *node;
unsigned int count, i;
size_t len;
if((node = vs_get_node_head(node_id)) == 0)
return;
len = strlen(name);
if(len == 0)
return;
free(node->name);
len++;
node->name = malloc(len);
v_strlcpy(node->name, name, len);
count = vs_get_subscript_count(node->subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->subscribers, i);
verse_send_node_name_set(node_id, name);
}
vs_reset_subscript_session();
}
extern void vs_o_subscribe(VSNodeHead *node);
extern void vs_g_subscribe(VSNodeHead *node);
extern void vs_m_subscribe(VSNodeHead *node);
extern void vs_b_subscribe(VSNodeHead *node);
extern void vs_t_subscribe(VSNodeHead *node);
extern void vs_c_subscribe(VSNodeHead *node);
extern void vs_a_subscribe(VSNodeHead *node);
static void callback_send_node_subscribe(void *user, VNodeID node_id)
{
unsigned int i;
VSNodeHead *node;
if((node = vs_get_node_head(node_id)) == NULL)
return;
switch(node->type)
{
case V_NT_OBJECT :
vs_o_subscribe(node);
break;
case V_NT_GEOMETRY :
vs_g_subscribe(node);
break;
case V_NT_MATERIAL :
vs_m_subscribe(node);
break;
case V_NT_BITMAP :
vs_b_subscribe(node);
break;
case V_NT_TEXT:
vs_t_subscribe(node);
break;
case V_NT_CURVE:
vs_c_subscribe(node);
break;
case V_NT_AUDIO:
vs_a_subscribe(node);
break;
default:
fprintf(stderr, "Not subscribing to node type %d\n", node->type);
}
verse_send_node_name_set(node->id, node->name);
for(i = 0; i < node->group_count; i++)
if(((VSTagGroup *)node->tag_groups)[i].group_name[0] != 0)
verse_send_tag_group_create(node->id, (uint16)i, ((VSTagGroup *)node->tag_groups)[i].group_name);
vs_add_new_subscriptor(node->subscribers);
}
extern void vs_o_unsubscribe(VSNodeHead *node);
extern void vs_g_unsubscribe(VSNodeHead *node);
extern void vs_m_unsubscribe(VSNodeHead *node);
extern void vs_b_unsubscribe(VSNodeHead *node);
extern void vs_t_unsubscribe(VSNodeHead *node);
extern void vs_c_unsubscribe(VSNodeHead *node);
extern void vs_a_unsubscribe(VSNodeHead *node);
static void callback_send_node_unsubscribe(void *user, VNodeID node_id)
{
VSNodeHead *node;
if((node = vs_get_node_head(node_id)) == NULL)
return;
vs_remove_subscriptor(node->subscribers);
switch(node->type)
{
case V_NT_OBJECT :
vs_o_unsubscribe(node);
break;
case V_NT_GEOMETRY :
vs_g_unsubscribe(node);
break;
case V_NT_MATERIAL :
vs_m_unsubscribe(node);
break;
case V_NT_BITMAP :
vs_b_unsubscribe(node);
break;
case V_NT_TEXT:
vs_t_unsubscribe(node);
break;
case V_NT_CURVE:
vs_c_unsubscribe(node);
break;
case V_NT_AUDIO:
vs_a_unsubscribe(node);
break;
default:
fprintf(stderr, "Not unsubscribing from node type %d\n", node->type);
}
}
void vs_h_callback_init(void)
{
verse_callback_set(verse_send_tag_group_create, callback_send_tag_group_create, NULL);
verse_callback_set(verse_send_tag_group_destroy, callback_send_tag_group_destroy, NULL);
verse_callback_set(verse_send_tag_group_subscribe, callback_send_tag_group_subscribe, NULL);
verse_callback_set(verse_send_tag_group_unsubscribe, callback_send_tag_group_unsubscribe, NULL);
verse_callback_set(verse_send_tag_create, callback_send_tag_create, NULL);
verse_callback_set(verse_send_tag_destroy, callback_send_tag_destroy, NULL);
verse_callback_set(verse_send_node_name_set, callback_send_node_name_set, NULL);
verse_callback_set(verse_send_node_subscribe, callback_send_node_subscribe, NULL);
verse_callback_set(verse_send_node_unsubscribe, callback_send_node_unsubscribe, NULL);
}
#endif

@ -1,116 +0,0 @@
/*
**
*/
#include <stdio.h>
#include <stdlib.h>
#include "v_cmd_gen.h"
#if !defined V_GENERATE_FUNC_MODE
#include "verse.h"
#include "vs_server.h"
typedef struct {
VNMFragmentType type;
VMatFrag frag;
} VSMatFrag;
typedef struct{
VSNodeHead head;
VSMatFrag *frag;
unsigned int frag_count;
} VSNodeMaterial;
VSNodeMaterial * vs_m_create_node(unsigned int owner)
{
VSNodeMaterial *node;
char name[48];
node = malloc(sizeof *node);
vs_add_new_node(&node->head, V_NT_MATERIAL);
sprintf(name, "Material_Node_%u", node->head.id);
create_node_head(&node->head, name, owner);
node->frag = NULL;
node->frag_count = 0;
return node;
}
void vs_m_destroy_node(VSNodeMaterial *node)
{
destroy_node_head(&node->head);
free(node->frag);
free(node);
}
void vs_m_subscribe(VSNodeMaterial *node)
{
uint16 i;
for(i = 0; i < node->frag_count; i++)
if(node->frag[i].type <= VN_M_FT_OUTPUT)
verse_send_m_fragment_create(node->head.id, (uint16)i, (uint8)node->frag[i].type, &node->frag[i].frag);
}
void vs_m_unsubscribe(VSNodeMaterial *node)
{
}
static void callback_send_m_fragment_create(void *user, VNodeID node_id, VNMFragmentID frag_id, uint8 type, VMatFrag *fragment)
{
unsigned int count;
uint16 i;
VSNodeMaterial *node;
node = (VSNodeMaterial *)vs_get_node(node_id, V_NT_MATERIAL);
if(node == NULL)
return;
if(node->frag_count + 32 < frag_id)
frag_id = (uint16)-1;
if(frag_id == (uint16) ~0u)
for(frag_id = 0; frag_id < node->frag_count && node->frag[frag_id].type < VN_M_FT_OUTPUT + 1; frag_id++)
;
if(frag_id >= node->frag_count)
{
node->frag = realloc(node->frag, (sizeof *node->frag) * (node->frag_count + 32));
for(i = node->frag_count; i < (node->frag_count + 32); i++)
node->frag[i].type = 255;
node->frag_count += 32;
}
node->frag[frag_id].type = type;
node->frag[frag_id].frag = *fragment;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_m_fragment_create(node_id, frag_id, type, fragment);
}
vs_reset_subscript_session();
}
static void callback_send_m_fragment_destroy(void *user, VNodeID node_id, VNMFragmentID frag_id)
{
unsigned int count, i;
VSNodeMaterial *node;
node = (VSNodeMaterial *)vs_get_node(node_id, V_NT_MATERIAL);
printf("callback_send_m_fragment_destroy %p\n", node);
if(node == NULL)
return;
if(node->frag_count <= frag_id || node->frag[frag_id].type > VN_M_FT_OUTPUT)
return;
node->frag[frag_id].type = 255;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_m_fragment_destroy(node_id, frag_id);
}
vs_reset_subscript_session();
}
void vs_m_callback_init(void)
{
verse_callback_set(verse_send_m_fragment_create, callback_send_m_fragment_create, NULL);
verse_callback_set(verse_send_m_fragment_destroy, callback_send_m_fragment_destroy, NULL);
}
#endif

@ -1,837 +0,0 @@
/*
**
*/
#include <stdio.h>
#include <stdlib.h>
#include "v_cmd_gen.h"
#if !defined V_GENERATE_FUNC_MODE
#include "verse.h"
#include "v_util.h"
#include "vs_server.h"
extern void verse_send_o_link_set(VNodeID node_id, uint16 link_id, VNodeID link, const char *name, uint32 target_id);
extern void verse_send_o_link_destroy(VNodeID node_id, uint16 link_id);
typedef struct {
VNodeID link;
char name[16];
uint32 target_id;
/* Animation parameters. */
uint32 time_s;
uint32 time_f;
uint32 dimensions;
real64 pos[4];
real64 speed[4];
real64 accel[4];
real64 scale[4];
real64 scale_speed[4];
} VSLink;
typedef struct {
char name[16];
uint8 param_count;
VNOParamType *param_types;
char *param_names;
} VSMethod;
typedef struct {
char name[VN_O_METHOD_GROUP_NAME_SIZE];
VSMethod *methods;
unsigned int method_count;
VSSubscriptionList *subscribers;
} VSMethodGroup;
typedef struct {
real64 position[3];
VNQuat64 rotation;
real64 scale[3];
/* VSSubscriptionList *subscribers;*/
} VSTransform;
typedef struct {
VSNodeHead head;
VSTransform transform;
VSSubscriptionList *trans_sub64;
VSSubscriptionList *trans_sub32;
real64 light[3];
VSMethodGroup *groups;
uint16 group_count;
VSLink *links;
uint16 link_count;
boolean hidden;
} VSNodeObject;
VSNodeObject * vs_o_create_node(unsigned int owner)
{
VSNodeObject *node;
unsigned int i, j;
char name[48];
node = malloc(sizeof *node);
vs_add_new_node(&node->head, V_NT_OBJECT);
sprintf(name, "Object_Node_%u", node->head.id);
create_node_head(&node->head, name, owner);
node->trans_sub64 = vs_create_subscription_list();
node->trans_sub32 = vs_create_subscription_list();
node->transform.position[0] = node->transform.position[1] = node->transform.position[2] = 0;
node->transform.rotation.x = node->transform.rotation.y = node->transform.rotation.z = 0.0;
node->transform.rotation.w = 1.0;
node->transform.scale[0] = node->transform.scale[1] = node->transform.scale[2] = 1.0;
node->light[0] = node->light[1] = node->light[2] = V_REAL64_MAX;
node->groups = malloc((sizeof *node->groups) * 16);
node->group_count = 16;
for(i = 0; i < 16; i++)
{
node->groups[i].name[0] = 0;
node->groups[i].methods = NULL;
node->groups[i].method_count = 0;
node->groups[i].subscribers = NULL;
}
node->link_count = 16;
node->links = malloc((sizeof *node->links) * node->link_count);
for(i = 0; i < node->link_count; i++)
{
node->links[i].link = -1;
node->links[i].name[0] = 0;
node->links[i].target_id = -1;
node->links[i].dimensions = 0;
for(j = 0; j < 4; j++)
{
node->links[i].pos[j] = 0.0;
node->links[i].speed[j] = 0.0;
node->links[i].accel[j] = 0.0;
node->links[i].scale[j] = 0.0;
node->links[i].scale_speed[j] = 0.0;
}
}
node->hidden = FALSE;
return node;
}
void vs_o_destroy_node(VSNodeObject *node)
{
unsigned int i, j;
destroy_node_head(&node->head);
for(i = 0; i < node->group_count; i++)
{
if(node->groups[i].name[0] != 0)
{
for(j = 0; j < node->groups[i].method_count; j++)
{
if(node->groups[i].methods[j].name[0] != 0 && node->groups[i].methods[j].param_count != 0)
{
free(node->groups[i].methods[j].param_types);
free(node->groups[i].methods[j].param_names);
}
}
if(node->groups[i].methods != NULL)
free(node->groups[i].methods);
}
}
free(node->groups);
free(node);
}
void vs_o_subscribe(VSNodeObject *node)
{
unsigned int i;
for(i = 0; i < node->link_count; i++)
{
const VSLink *lnk = node->links + i;
if(lnk->name[0] != 0)
{
verse_send_o_link_set(node->head.id, i, lnk->link, lnk->name, lnk->target_id);
if(lnk->dimensions != 0)
{
verse_send_o_anim_run(node->head.id, i, lnk->time_s, lnk->time_f, lnk->dimensions,
lnk->pos, lnk->speed, lnk->accel,
lnk->scale, lnk->scale_speed);
}
}
}
if(node->light[0] != V_REAL64_MAX || node->light[1] != V_REAL64_MAX || node->light[2] != V_REAL64_MAX)
verse_send_o_light_set(node->head.id, node->light[0], node->light[1], node->light[2]);
for(i = 0; i < node->group_count; i++)
{
if(node->groups[i].name[0] != 0)
verse_send_o_method_group_create(node->head.id, i, node->groups[i].name);
}
if(node->hidden)
verse_send_o_hide(node->head.id, TRUE);
}
void vs_o_unsubscribe(VSNodeObject *node)
{
unsigned int i;
for(i = 0; i < node->group_count; i++)
if(node->groups[i].name[0] != 0)
vs_remove_subscriptor(node->groups[i].subscribers);
vs_remove_subscriptor(node->trans_sub64);
vs_remove_subscriptor(node->trans_sub32);
}
static void callback_send_o_transform_pos_real32(void *user, VNodeID node_id, uint32 time_s, uint32 time_f, real32 *pos, real32 *speed, real32 *accelerate, real32 *drag_normal, real32 drag)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL)
return;
node->transform.position[0] = pos[0];
node->transform.position[1] = pos[1];
node->transform.position[2] = pos[2];
if((count = vs_get_subscript_count(node->trans_sub64)) > 0) /* Anyone listening at 64 bits? */
{
real64 spd[3], acc[3], drn[3], *pspd = NULL, *pacc = NULL, *pdrn = NULL;
pspd = (speed != NULL) ? spd : NULL;
pacc = (accelerate != NULL) ? acc : NULL;
pdrn = (drag_normal != NULL) ? drn : NULL;
/* Convert non-position values to 64-bit. */
for(i = 0; i < 3; i++)
{
if(speed != NULL)
spd[i] = speed[i];
if(accelerate != NULL)
acc[i] = accelerate[i];
if(drag_normal != NULL)
drn[i] = drag_normal[i];
}
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->trans_sub64, i);
verse_send_o_transform_pos_real64(node_id, time_s, time_f, node->transform.position, pspd, pacc, pdrn, drag);
}
}
count = vs_get_subscript_count(node->trans_sub32);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->trans_sub32, i);
verse_send_o_transform_pos_real32(node_id, time_s, time_f, pos, speed, accelerate, drag_normal, drag);
}
vs_reset_subscript_session();
}
static void callback_send_o_transform_rot_real32(void *user, VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat32 *rot,
const VNQuat32 *speed, const VNQuat32 *accelerate, const VNQuat32 *drag_normal, real32 drag)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL)
return;
node->transform.rotation.x = rot->x;
node->transform.rotation.y = rot->y;
node->transform.rotation.z = rot->z;
node->transform.rotation.w = rot->w;
if((count = vs_get_subscript_count(node->trans_sub64)) > 0)
{
VNQuat64 spd, acc, drn, *p[3];
/* Convert 32-bit quaternions to 64-bit. Converter handles NULLs, has nice return semantics. */
p[0] = v_quat64_from_quat32(&spd, speed);
p[1] = v_quat64_from_quat32(&acc, accelerate);
p[2] = v_quat64_from_quat32(&drn, drag_normal);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->trans_sub64, i);
verse_send_o_transform_rot_real64(node_id, time_s, time_f, &node->transform.rotation, p[0], p[1], p[2], drag);
}
}
count = vs_get_subscript_count(node->trans_sub32);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->trans_sub32, i);
verse_send_o_transform_rot_real32(node_id, time_s, time_f, rot, speed, accelerate, drag_normal, drag);
}
vs_reset_subscript_session();
}
static void callback_send_o_transform_scale_real32(void *user, VNodeID node_id, real32 scale_x, real32 scale_y, real32 scale_z)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL)
return;
node->transform.scale[0] = scale_x;
node->transform.scale[1] = scale_y;
node->transform.scale[2] = scale_z;
count = vs_get_subscript_count(node->trans_sub64);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->trans_sub64, i);
verse_send_o_transform_scale_real64(node_id, scale_x, scale_y, scale_z);
}
count = vs_get_subscript_count(node->trans_sub32);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->trans_sub32, i);
verse_send_o_transform_scale_real32(node_id, scale_x, scale_y, scale_z);
}
vs_reset_subscript_session();
}
static void callback_send_o_transform_pos_real64(void *user, VNodeID node_id, uint32 time_s, uint32 time_f, const real64 *pos,
const real64 *speed, const real64 *accelerate, const real64 *drag_normal, real64 drag)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL)
return;
node->transform.position[0] = pos[0];
node->transform.position[1] = pos[1];
node->transform.position[2] = pos[2];
count = vs_get_subscript_count(node->trans_sub64);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->trans_sub64, i);
verse_send_o_transform_pos_real64(node_id, time_s, time_f, node->transform.position, speed, accelerate, drag_normal, drag);
}
if((count = vs_get_subscript_count(node->trans_sub32)) > 0) /* Anyone listening at 32 bits? */
{
real32 ps[3], spd[3], acc[3], drn[3], *p[] = { NULL, NULL, NULL };
ps[0] = pos[0];
ps[1] = pos[1];
ps[2] = pos[2];
if(speed != NULL)
{
p[0] = spd;
spd[0] = speed[0];
spd[1] = speed[1];
spd[2] = speed[2];
}
else
p[0] = NULL;
if(accelerate != NULL)
{
p[1] = acc;
acc[0] = accelerate[0];
acc[1] = accelerate[1];
acc[2] = accelerate[2];
}
else
p[1] = NULL;
if(drag_normal != NULL)
{
p[1] = drn;
drn[0] = drag_normal[0];
drn[1] = drag_normal[1];
drn[2] = drag_normal[2];
}
else
p[2] = NULL;
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->trans_sub32, i);
verse_send_o_transform_pos_real32(node_id, time_s, time_f, ps, p[0], p[1], p[2], (real32) drag);
}
}
vs_reset_subscript_session();
}
static void callback_send_o_transform_rot_real64(void *user, VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat64 *rot,
const VNQuat64 *speed, const VNQuat64 *accelerate, const VNQuat64 *drag_normal, real64 drag)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL)
return;
node->transform.rotation = *rot;
count = vs_get_subscript_count(node->trans_sub64);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->trans_sub64, i);
verse_send_o_transform_rot_real64(node_id, time_s, time_f, &node->transform.rotation, speed, accelerate, drag_normal, drag);
}
if((count = vs_get_subscript_count(node->trans_sub32)) > 0) /* Anyone listening at 32 bits? */
{
VNQuat32 rt, spd, acc, drn, *p[3];
v_quat32_from_quat64(&rt, rot);
p[0] = v_quat32_from_quat64(&spd, speed);
p[1] = v_quat32_from_quat64(&acc, accelerate);
p[2] = v_quat32_from_quat64(&drn, drag_normal);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->trans_sub32, i);
verse_send_o_transform_rot_real32(node_id, time_s, time_f, &rt, p[0], p[1], p[2], (real32) drag);
}
}
vs_reset_subscript_session();
}
static void callback_send_o_transform_scale_real64(void *user, VNodeID node_id, real64 scale_x, real64 scale_y, real64 scale_z)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL)
return;
node->transform.scale[0] = scale_x;
node->transform.scale[1] = scale_y;
node->transform.scale[2] = scale_z;
count = vs_get_subscript_count(node->trans_sub64);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->trans_sub64, i);
verse_send_o_transform_scale_real64(node_id, scale_x, scale_y, scale_z);
}
count = vs_get_subscript_count(node->trans_sub32);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->trans_sub32, i);
verse_send_o_transform_scale_real32(node_id, (real32) scale_x, (real32) scale_y, (real32) scale_z);
}
vs_reset_subscript_session();
}
static void callback_send_o_transform_subscribe(void *user, VNodeID node_id, VNRealFormat type)
{
VSNodeObject *node;
uint32 time_s, time_f;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL)
return;
verse_session_get_time(&time_s, &time_f);
if(type == VN_FORMAT_REAL32)
{
real32 tpos[3];
VNQuat32 rot;
vs_add_new_subscriptor(node->trans_sub32);
tpos[0] = node->transform.position[0];
tpos[1] = node->transform.position[1];
tpos[2] = node->transform.position[2];
verse_send_o_transform_pos_real32(node_id, time_s, time_f, tpos, NULL, NULL, NULL, 0.0f);
v_quat32_from_quat64(&rot, &node->transform.rotation);
verse_send_o_transform_rot_real32(node_id, time_s, time_f, &rot, NULL, NULL, NULL, 0.0f);
verse_send_o_transform_scale_real32(node_id, (real32) node->transform.scale[0], (real32) node->transform.scale[1], (real32) node->transform.scale[2]);
}
else
{
vs_add_new_subscriptor(node->trans_sub64);
verse_send_o_transform_pos_real64(node_id, time_s, time_f, node->transform.position, NULL, NULL, NULL, 0);
verse_send_o_transform_rot_real64(node_id, time_s, time_f, &node->transform.rotation, NULL, NULL, NULL, 0);
verse_send_o_transform_scale_real64(node_id, node->transform.scale[0], node->transform.scale[1], node->transform.scale[2]);
}
}
static void callback_send_o_transform_unsubscribe(void *user, VNodeID node_id, VNRealFormat type)
{
VSNodeObject *node;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL)
return;
if(type == VN_FORMAT_REAL32)
vs_remove_subscriptor(node->trans_sub32);
else
vs_remove_subscriptor(node->trans_sub64);
}
static void callback_send_o_light_set(void *user, VNodeID node_id, real64 light_r, real64 light_g, real64 light_b)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL)
return;
node->light[0] = light_r;
node->light[1] = light_g;
node->light[2] = light_b;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_o_light_set(node_id, light_r, light_g, light_b);
}
vs_reset_subscript_session();
}
static void callback_send_o_link_set(void *user, VNodeID node_id, uint16 link_id, VNodeID link, const char *name, uint32 target_id)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL)
return;
if(name[0] == 0)
return;
if(vs_get_node_head(link) == 0)
link = 0;
if(link_id >= node->link_count || node->links[link_id].name[0] == 0)
{
for(link_id = 0; link_id < node->link_count && node->links[link_id].name[0] != 0; link_id++);
if(link_id == node->link_count)
{
i = node->link_count;
node->link_count += 16;
node->links = realloc(node->links, (sizeof *node->links) * node->link_count);
for(; i < node->link_count; i++)
{
node->links[i].name[0] = 0;
node->links[i].dimensions = 0;
}
}
}
node->links[link_id].link = link;
for(i = 0; i < 15 && name[i] != 0; i++)
node->links[link_id].name[i] = name[i];
node->links[link_id].name[i] = 0;
node->links[link_id].target_id = target_id;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_o_link_set(node_id, link_id, link, name, target_id);
}
vs_reset_subscript_session();
}
static void callback_send_o_link_destroy(void *user, VNodeID node_id, uint16 link_id)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL)
return;
if(link_id >= node->link_count || node->links[link_id].name[0] == 0)
return;
node->links[link_id].name[0] = 0;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_o_link_destroy(node_id, link_id);
}
vs_reset_subscript_session();
}
static void callback_send_o_method_group_create(void *user, VNodeID node_id, uint16 group_id, char *name)
{
VSNodeObject *node;
unsigned int i, j, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL)
return;
for(i = 0; i < node->group_count; i++)
{
for(j = 0; node->groups[i].name[j] == name[j] && node->groups[i].name[j] != 0; j++);
if(node->groups[i].name[j] == name[j])
return;
}
if(group_id >= node->group_count || node->groups[group_id].name[0] == 0)
{
for(group_id = 0; group_id < node->group_count && node->groups[group_id].name[0] != 0; group_id++)
if(group_id == node->group_count)
{
node->groups = realloc(node->groups, sizeof(*node->groups) * (node->group_count + 16));
for(i = node->group_count; i < node->group_count + 16u; i++)
{
node->groups[i].name[0] = 0;
node->groups[i].methods = NULL;
node->groups[i].method_count = 0;
}
node->group_count += 16;
}
node->groups[group_id].subscribers = vs_create_subscription_list();
}
for(i = 0; i < 15 && name[i] != 0; i++)
node->groups[group_id].name[i] = name[i];
node->groups[group_id].name[i] = 0;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_o_method_group_create(node_id, group_id, name);
}
vs_reset_subscript_session();
}
static void callback_send_o_method_group_destroy(void *user, VNodeID node_id, uint16 group_id)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL)
return;
if(group_id >= node->group_count || node->groups[group_id].name[0] == 0)
return;
node->groups[group_id].name[0] = 0;
for(i = 0; i < node->groups[group_id].method_count; i++)
{
if(node->groups[group_id].methods[i].name[0] != 0 && node->groups[group_id].methods[i].param_count > 0)
{
free(node->groups[group_id].methods[i].param_names);
free(node->groups[group_id].methods[i].param_types);
}
}
free(node->groups[group_id].methods);
node->groups[group_id].methods = NULL;
node->groups[group_id].method_count = 0;
vs_destroy_subscription_list(node->groups[group_id].subscribers);
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_o_method_group_destroy(node_id, group_id);
}
vs_reset_subscript_session();
}
static void callback_send_o_method_group_subscribe(void *user, VNodeID node_id, uint16 group_id)
{
VSNodeObject *node;
unsigned int i, j;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL)
return;
if(group_id < node->group_count && node->groups[group_id].name[0] != 0)
vs_add_new_subscriptor(node->groups[group_id].subscribers);
for(i = 0; i < node->groups[group_id].method_count; i++)
{
if(node->groups[group_id].methods[i].name[0] != 0)
{
char *names[255];
for(j = 0; j < node->groups[group_id].methods[i].param_count; j++)
names[j] = &node->groups[group_id].methods[i].param_names[j * 16];
verse_send_o_method_create(node_id, group_id, i, node->groups[group_id].methods[i].name, node->groups[group_id].methods[i].param_count, node->groups[group_id].methods[i].param_types, (const char **) names);
}
}
}
static void callback_send_o_method_group_unsubscribe(void *user, VNodeID node_id, uint16 group_id)
{
VSNodeObject *node;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL)
return;
if(group_id < node->group_count && node->groups[group_id].name[0] != 0)
vs_remove_subscriptor(node->groups[group_id].subscribers);
}
static void callback_send_o_method_create(void *user, VNodeID node_id, uint16 group_id, uint16 method_id, char *name, uint8 param_count, VNOParamType *param_types, char * *param_names)
{
VSNodeObject *node;
unsigned int i, j, count;
VSMethodGroup *group;
node = (VSNodeObject *) vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL)
return;
if(group_id >= node->group_count || node->groups[group_id].name[0] == 0)
return;
group = &node->groups[group_id];
for(i = 0; i < group->method_count; i++)
{
if(i != method_id)
{
for(j = 0; group->methods[i].name[j] == name[j] && group->methods[i].name[j] != 0; j++);
if(group->methods[i].name[j] == name[j])
return;
}
}
if(method_id < group->method_count && group->methods[method_id].name[0] != 0)
{
for(i = 0; i < 16; i++)
group->methods[method_id].name[i] = name[i];
if(group->methods[method_id].param_count != 0)
{
free(group->methods[method_id].param_names);
free(group->methods[method_id].param_types);
}
}else
{
for(method_id = 0; method_id < group->method_count && group->methods[method_id].name[0] != 0; method_id++);
if(method_id == group->method_count)
{
group->methods = realloc(group->methods, sizeof(*group->methods) * (group->method_count + 16));
for(i = group->method_count; i < group->method_count + 16; i++)
group->methods[i].name[0] = 0;
group->method_count += 16;
}
}
for(i = 0; i < VN_O_METHOD_NAME_SIZE && name[i] != 0; i++)
group->methods[method_id].name[i] = name[i];
group->methods[method_id].name[i] = '\0';
group->methods[method_id].param_count = param_count;
if(param_count > 0)
{
group->methods[method_id].param_types = malloc((sizeof *group->methods[method_id].param_types) * param_count);
group->methods[method_id].param_names = malloc((sizeof *group->methods[method_id].param_names) * param_count * 16);
}
for(i = 0; i < param_count; i++)
{
group->methods[method_id].param_types[i] = param_types[i];
for(j = 0; j < 15 && param_names[i][j] != 0; j++)
group->methods[method_id].param_names[i * 16 + j] = param_names[i][j];
group->methods[method_id].param_names[i * 16 + j] = 0;
}
count = vs_get_subscript_count(node->groups[group_id].subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->groups[group_id].subscribers, i);
verse_send_o_method_create(node_id, group_id, method_id, name, param_count, param_types, (const char **) param_names);
}
vs_reset_subscript_session();
}
static void callback_send_o_method_destroy(void *user, VNodeID node_id, uint16 group_id, uint16 method_id)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL)
return;
if(group_id >= node->group_count || node->groups[group_id].name[0] == 0 || method_id >= node->groups[group_id].method_count || node->groups[group_id].methods[method_id].name[0] == 0)
return;
node->groups[group_id].methods[method_id].name[0] = 0;
if(node->groups[group_id].methods[method_id].param_count != 0)
{
free(node->groups[group_id].methods[method_id].param_names);
free(node->groups[group_id].methods[method_id].param_types);
}
count = vs_get_subscript_count(node->groups[group_id].subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->groups[group_id].subscribers, i);
verse_send_o_method_destroy(node_id, group_id, method_id);
}
vs_reset_subscript_session();
}
static void callback_send_o_method_call(void *user, VNodeID node_id, uint16 group_id, uint16 method_id, VNodeID sender, void *params)
{
VNOParam unpacked_params[255];
void *data;
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL)
return;
if(group_id >= node->group_count || node->groups[group_id].name[0] == 0 || method_id >= node->groups[group_id].method_count || node->groups[group_id].methods[method_id].name[0] == 0)
return;
if(!verse_method_call_unpack(params, node->groups[group_id].methods[method_id].param_count, node->groups[group_id].methods[method_id].param_types, unpacked_params))
return;
sender = vs_get_avatar();
count = vs_get_subscript_count(node->groups[group_id].subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->groups[group_id].subscribers, i);
data = verse_method_call_pack(node->groups[group_id].methods[method_id].param_count, node->groups[group_id].methods[method_id].param_types, unpacked_params);
if(data != NULL)
verse_send_o_method_call(node_id, group_id, method_id, sender, data);
}
vs_reset_subscript_session();
}
static void callback_send_o_anim_run(void *user, VNodeID node_id, uint16 link_id, uint32 time_s, uint32 time_f, uint8 dimensions, real64 *pos,
real64 *speed, real64 *accel, real64 *scale, real64 *scale_speed)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL)
return;
if(link_id >= node->link_count || node->links[link_id].name[0] == 0)
return;
if(NULL == vs_get_node(node->links[link_id].link, V_NT_CURVE))
return;
node->links[link_id].time_s = time_s;
node->links[link_id].time_f = time_f;
node->links[link_id].dimensions = dimensions;
for(i = 0; i < dimensions && i < 4; i++)
{
node->links[link_id].pos[i] = pos[i];
node->links[link_id].speed[i] = speed[i];
node->links[link_id].accel[i] = accel[i];
node->links[link_id].scale[i] = scale[i];
node->links[link_id].scale_speed[i] = scale_speed[i];
}
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_o_anim_run(node_id, link_id, time_s, time_f, dimensions, pos, speed, accel, scale, scale_speed);
}
vs_reset_subscript_session();
}
static void callback_send_o_hide(void *user, VNodeID node_id, uint8 hidden)
{
VSNodeObject *node;
unsigned int i, count;
node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT);
if(node == NULL || hidden == node->hidden)
return;
node->hidden = hidden;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_o_hide(node_id, hidden);
}
vs_reset_subscript_session();
}
void vs_o_callback_init(void)
{
verse_callback_set(verse_send_o_transform_pos_real32, callback_send_o_transform_pos_real32, NULL);
verse_callback_set(verse_send_o_transform_rot_real32, callback_send_o_transform_rot_real32, NULL);
verse_callback_set(verse_send_o_transform_scale_real32, callback_send_o_transform_scale_real32, NULL);
verse_callback_set(verse_send_o_transform_pos_real64, callback_send_o_transform_pos_real64, NULL);
verse_callback_set(verse_send_o_transform_rot_real64, callback_send_o_transform_rot_real64, NULL);
verse_callback_set(verse_send_o_transform_scale_real64, callback_send_o_transform_scale_real64, NULL);
verse_callback_set(verse_send_o_transform_subscribe, callback_send_o_transform_subscribe, NULL);
verse_callback_set(verse_send_o_transform_unsubscribe, callback_send_o_transform_unsubscribe, NULL);
verse_callback_set(verse_send_o_link_set, callback_send_o_link_set, NULL);
verse_callback_set(verse_send_o_light_set, callback_send_o_light_set, NULL);
verse_callback_set(verse_send_o_link_set, callback_send_o_link_set, NULL);
verse_callback_set(verse_send_o_link_destroy, callback_send_o_link_destroy, NULL);
verse_callback_set(verse_send_o_method_group_create, callback_send_o_method_group_create, NULL);
verse_callback_set(verse_send_o_method_group_destroy, callback_send_o_method_group_destroy, NULL);
verse_callback_set(verse_send_o_method_group_subscribe, callback_send_o_method_group_subscribe, NULL);
verse_callback_set(verse_send_o_method_group_unsubscribe, callback_send_o_method_group_unsubscribe, NULL);
verse_callback_set(verse_send_o_method_create, callback_send_o_method_create, NULL);
verse_callback_set(verse_send_o_method_destroy, callback_send_o_method_destroy, NULL);
verse_callback_set(verse_send_o_method_call, callback_send_o_method_call, NULL);
verse_callback_set(verse_send_o_anim_run, callback_send_o_anim_run, NULL);
verse_callback_set(verse_send_o_hide, callback_send_o_hide, NULL);
}
#endif

@ -1,52 +0,0 @@
/*
**
*/
#include <stdio.h>
#include <stdlib.h>
#include "v_cmd_gen.h"
#if !defined V_GENERATE_FUNC_MODE
#include "verse.h"
#include "vs_server.h"
/*
typedef struct {
VSNodeHead head;
} VSNodeObject;
VSNodeObject *vs_o_create_node(unsigned int owner)
{
VSNodeObject *node;
node = malloc(sizeof *node);
create_node_head(&node->head, name, owner);
vs_add_new_node(&node->head, V_NT_OBJECT);
return node;
}
void vs_o_destroy_node(VSNodeObject *node)
{
destroy_node_head(&node->head);
free(node);
}
void vs_o_subscribe(VSNodeObject *node)
{
}
static void callback_send_o_unsubscribe(void *user, VNodeID node_id)
{
VSNodeObject *node;
node = (VSNodeObject *)vs_get_node(node_id);
if(node == NULL)
return;
vs_remove_subscriptor(node->head.subscribers);
}
void vs_o_callback_init(void)
{
}
*/
#endif

@ -1,245 +0,0 @@
/*
**
*/
#include <stdio.h>
#include <stdlib.h>
#include "v_cmd_gen.h"
#if !defined V_GENERATE_FUNC_MODE
#include "verse.h"
#include "vs_server.h"
#define VS_NODE_STORAGE_CHUNK_SIZE 16
static struct {
VSNodeHead **nodes;
unsigned int node_length;
unsigned int node_allocated;
VSSubscriptionList *list[V_NT_NUM_TYPES];
} VSNodeStorage;
extern void callback_send_tag_group_create(void *user, VNodeID node_id, uint16 group_id, const char *name);
void vs_init_node_storage(void)
{
unsigned int i;
VSNodeStorage.nodes = malloc((sizeof *VSNodeStorage.nodes) * VS_NODE_STORAGE_CHUNK_SIZE);
VSNodeStorage.nodes[0] = NULL;
VSNodeStorage.node_length = 0;
VSNodeStorage.node_allocated = VS_NODE_STORAGE_CHUNK_SIZE;
for(i = 0; i < V_NT_NUM_TYPES; i++)
VSNodeStorage.list[i] = vs_create_subscription_list();
}
unsigned int vs_add_new_node(VSNodeHead *node, VNodeType type)
{
unsigned int i, j;
for(i = 0; i < VSNodeStorage.node_length && VSNodeStorage.nodes[i] != NULL; i++);
if(i >= VSNodeStorage.node_allocated)
{
j = VSNodeStorage.node_allocated;
VSNodeStorage.node_allocated += VS_NODE_STORAGE_CHUNK_SIZE;
VSNodeStorage.nodes = realloc(VSNodeStorage.nodes, (sizeof *VSNodeStorage.nodes) * VSNodeStorage.node_allocated);
while(j < VSNodeStorage.node_allocated)
VSNodeStorage.nodes[j++] = NULL;
}
VSNodeStorage.nodes[i] = node;
if(i >= VSNodeStorage.node_length)
VSNodeStorage.node_length = i + 1;
node->id = i;
node->type = type;
return node->id;
}
VSNodeHead *vs_get_node(unsigned int node_id, VNodeType type)
{
if(VSNodeStorage.node_length > node_id)
{
VSNodeHead *node = VSNodeStorage.nodes[node_id];
if(node != NULL && node->type == type)
return node;
}
return NULL;
}
VSNodeHead *vs_get_node_head(unsigned int node_id)
{
if(VSNodeStorage.node_length > node_id)
return VSNodeStorage.nodes[node_id];
return NULL;
}
extern VSNodeHead *vs_o_create_node(unsigned int owner);
extern VSNodeHead *vs_g_create_node(unsigned int owner);
extern VSNodeHead *vs_m_create_node(unsigned int owner);
extern VSNodeHead *vs_b_create_node(unsigned int owner);
extern VSNodeHead *vs_t_create_node(unsigned int owner);
extern VSNodeHead *vs_c_create_node(unsigned int owner);
extern VSNodeHead *vs_p_create_node(unsigned int owner);
extern VSNodeHead *vs_a_create_node(unsigned int owner);
extern void vs_o_destroy_node(VSNodeHead *node);
extern void vs_g_destroy_node(VSNodeHead *node);
extern void vs_m_destroy_node(VSNodeHead *node);
extern void vs_b_destroy_node(VSNodeHead *node);
extern void vs_t_destroy_node(VSNodeHead *node);
extern void vs_c_destroy_node(VSNodeHead *node);
extern void vs_p_destroy_node(VSNodeHead *node);
extern void vs_a_destroy_node(VSNodeHead *node);
VNodeID vs_node_create(VNodeID owner_id, unsigned int type)
{
unsigned int count, i;
VSNodeHead *node;
VNodeID node_id;
printf("vs_node_create(%u, %u)\n", owner_id, type);
switch(type)
{
case V_NT_OBJECT :
node = vs_o_create_node(owner_id);
break;
case V_NT_GEOMETRY :
node = vs_g_create_node(owner_id);
break;
case V_NT_MATERIAL :
node = vs_m_create_node(owner_id);
break;
case V_NT_BITMAP :
node = vs_b_create_node(owner_id);
break;
case V_NT_TEXT :
node = vs_t_create_node(owner_id);
break;
case V_NT_CURVE :
node = vs_c_create_node(owner_id);
break;
case V_NT_AUDIO :
node = vs_a_create_node(owner_id);
break;
default:
fprintf(stderr, "Can't create node of unknown type %u\n", type);
return 0U;
}
node_id = node->id;
count = vs_get_subscript_count(VSNodeStorage.list[type]);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(VSNodeStorage.list[type], i);
if(owner_id != verse_session_get_avatar())
verse_send_node_create(node_id, type, VN_OWNER_OTHER);
else
verse_send_node_create(node_id, type, VN_OWNER_MINE);
}
if(count != 0)
vs_reset_subscript_session();
return node_id;
}
/* Initialize an object node into being an avatar. */
void vs_avatar_init(VNodeID id, const char *name)
{
callback_send_tag_group_create(NULL, id, (short) ~0u, "avatar");
/* FIXME: Populate the group, too. */
}
void vs_reset_owner(VNodeID owner_id)
{
unsigned int i;
for(i = 0; i < VSNodeStorage.node_length; i++)
if(VSNodeStorage.nodes[i] != NULL)
if(VSNodeStorage.nodes[i]->owner == owner_id)
VSNodeStorage.nodes[i]->owner = ~0;
}
static void callback_send_node_create(void *user_data, VNodeID node_id, uint8 type, VNodeOwner owner_id)
{
vs_node_create(vs_get_avatar(), type);
}
void callback_send_node_destroy(void *user_data, VNodeID node_id)
{
unsigned int count, i;
VSNodeHead *node;
VNodeType type;
node = vs_get_node_head(node_id);
if(node == NULL)
return;
VSNodeStorage.nodes[node_id] = NULL;
type = node->type;
switch(type)
{
case V_NT_OBJECT :
vs_o_destroy_node(node);
break;
case V_NT_GEOMETRY :
vs_g_destroy_node(node);
break;
case V_NT_MATERIAL :
vs_m_destroy_node(node);
break;
case V_NT_BITMAP :
vs_b_destroy_node(node);
break;
case V_NT_TEXT :
vs_t_destroy_node(node);
break;
case V_NT_CURVE :
vs_c_destroy_node(node);
break;
case V_NT_AUDIO :
vs_c_destroy_node(node);
break;
default:
fprintf(stderr, __FILE__ " Can't handle node_destroy for type %d--not implemented", type);
return;
}
count = vs_get_subscript_count(VSNodeStorage.list[type]);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(VSNodeStorage.list[type], i);
verse_send_node_destroy(node_id);
}
vs_reset_subscript_session();
}
static void callback_send_node_index_subscribe(void *user_data, uint32 mask)
{
unsigned int i, j, pow = 1;
for(i = 0; i < V_NT_NUM_TYPES; i++, pow <<= 1)
{
if((mask & pow) != 0)
{
for(j = 0; j < VSNodeStorage.node_length; j++)
{
if(VSNodeStorage.nodes[j] != NULL && VSNodeStorage.nodes[j]->type == (VNodeType)i)
{
if(VSNodeStorage.nodes[j]->owner == verse_session_get_avatar())
verse_send_node_create(VSNodeStorage.nodes[j]->id, i, VN_OWNER_MINE);
else
verse_send_node_create(VSNodeStorage.nodes[j]->id, i, VN_OWNER_OTHER);
}
}
vs_add_new_subscriptor(VSNodeStorage.list[i]);
}
else
vs_remove_subscriptor(VSNodeStorage.list[i]);
}
}
void init_callback_node_storage(void)
{
verse_callback_set(verse_send_node_index_subscribe, callback_send_node_index_subscribe, NULL);
verse_callback_set(verse_send_node_create, callback_send_node_create, NULL);
verse_callback_set(verse_send_node_destroy, callback_send_node_destroy, NULL);
}
#endif

@ -1,274 +0,0 @@
/*
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "v_cmd_gen.h"
#if !defined V_GENERATE_FUNC_MODE
#include "verse.h"
#include "vs_server.h"
#define VS_TEXT_CHUNK_SIZE 4096
typedef struct {
char name[16];
char *text;
size_t length;
size_t allocated;
VSSubscriptionList *subscribers;
} VSTextBuffer;
typedef struct {
VSNodeHead head;
char language[512];
VSTextBuffer *buffer;
unsigned int buffer_count;
} VSNodeText;
VSNodeText * vs_t_create_node(unsigned int owner)
{
VSNodeText *node;
char name[48];
unsigned int i;
node = malloc(sizeof *node);
vs_add_new_node(&node->head, V_NT_TEXT);
sprintf(name, "Text_Node_%u", node->head.id);
create_node_head(&node->head, name, owner);
node->language[0] = 0;
node->buffer_count = 16;
node->buffer = malloc((sizeof *node->buffer) * node->buffer_count);
for(i = 0; i < node->buffer_count; i++)
node->buffer[i].name[0] = 0;
return node;
}
void vs_t_destroy_node(VSNodeText *node)
{
unsigned int i;
destroy_node_head(&node->head);
for(i = 0; i < node->buffer_count; i++)
{
if(node->buffer[i].name[0] != 0)
{
free(node->buffer[i].text);
vs_destroy_subscription_list(node->buffer[i].subscribers);
}
}
free(node->buffer);
free(node);
}
void vs_t_subscribe(VSNodeText *node)
{
unsigned int i;
verse_send_t_language_set(node->head.id, node->language);
for(i = 0; i < node->buffer_count; i++)
if(node->buffer[i].name[0] != 0)
verse_send_t_buffer_create(node->head.id, i, node->buffer[i].name);
}
void vs_t_unsubscribe(VSNodeText *node)
{
unsigned int i;
for(i = 0; i < node->buffer_count; i++)
if(node->buffer[i].name[0] != 0)
vs_remove_subscriptor(node->buffer[i].subscribers);
}
static void callback_send_t_language_set(void *user, VNodeID node_id, char *language)
{
VSNodeText *node;
unsigned int i, count;
node = (VSNodeText *)vs_get_node(node_id, V_NT_TEXT);
if(node == NULL)
return;
for(i = 0; i < 511 && language[i]; i++)
node->language[i] = language[i];
node->language[i] = 0;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_t_language_set(node_id, language);
}
vs_reset_subscript_session();
}
static void callback_send_t_buffer_create(void *user, VNodeID node_id, VBufferID buffer_id, const char *name)
{
VSNodeText *node;
unsigned int i, count;
node = (VSNodeText *)vs_get_node(node_id, V_NT_TEXT);
if(node == NULL)
return;
if(buffer_id >= node->buffer_count || node->buffer[buffer_id].name[0] != 0)
{
for(buffer_id = 0; buffer_id < node->buffer_count && node->buffer[buffer_id].name[0] != 0; buffer_id++)
;
if(buffer_id == node->buffer_count)
{
node->buffer = realloc(node->buffer, (sizeof *node->buffer) * node->buffer_count);
for(i = node->buffer_count; i < node->buffer_count + 16; i++)
node->buffer[i].name[0] = 0;
node->buffer_count = i;
}
}
if(node->buffer[buffer_id].name[0] == 0)
{
node->buffer[buffer_id].allocated = VS_TEXT_CHUNK_SIZE;
node->buffer[buffer_id].text = malloc(node->buffer[buffer_id].allocated);
node->buffer[buffer_id].length = 0;
node->buffer[buffer_id].subscribers = vs_create_subscription_list();
}
for(i = 0; i < 15 && name[i] != 0; i++)
node->buffer[buffer_id].name[i] = name[i];
node->buffer[buffer_id].name[i] = 0;
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_t_buffer_create(node_id, buffer_id, name);
}
vs_reset_subscript_session();
}
void callback_send_t_buffer_destroy(void *user, VNodeID node_id, VBufferID buffer_id)
{
VSNodeText *node;
unsigned int i, count;
node = (VSNodeText *)vs_get_node(node_id, V_NT_TEXT);
if(node == NULL)
return;
if(buffer_id >= node->buffer_count || node->buffer[buffer_id].name[0] == 0)
return;
node->buffer[buffer_id].name[0] = 0;
free(node->buffer[buffer_id].text);
vs_destroy_subscription_list(node->buffer[buffer_id].subscribers);
count = vs_get_subscript_count(node->head.subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(node->head.subscribers, i);
verse_send_t_buffer_destroy(node_id, buffer_id);
}
vs_reset_subscript_session();
}
static void callback_send_t_buffer_subscribe(void *user, VNodeID node_id, VBufferID buffer_id)
{
VSNodeText *node;
unsigned int i;
node = (VSNodeText *)vs_get_node(node_id, V_NT_TEXT);
if(node == NULL)
return;
if(buffer_id >= node->buffer_count || node->buffer[buffer_id].name[0] == 0)
return;
if(vs_add_new_subscriptor(node->buffer[buffer_id].subscribers) == 0)
return;
for(i = 0; i < node->buffer[buffer_id].length; i += VN_T_MAX_TEXT_CMD_SIZE)
{
if(i + VN_T_MAX_TEXT_CMD_SIZE > node->buffer[buffer_id].length)
verse_send_t_text_set(node_id, buffer_id, i, node->buffer[buffer_id].length - i, &node->buffer[buffer_id].text[i]);
else
verse_send_t_text_set(node_id, buffer_id, i, VN_T_MAX_TEXT_CMD_SIZE, &node->buffer[buffer_id].text[i]);
}
}
static void callback_send_t_buffer_unsubscribe(void *user, VNodeID node_id, VBufferID buffer_id)
{
VSNodeText *node;
node = (VSNodeText *)vs_get_node(node_id, V_NT_TEXT);
if(node == NULL)
return;
if(buffer_id >= node->buffer_count || node->buffer[buffer_id].name[0] == 0)
return;
vs_remove_subscriptor(node->buffer[buffer_id].subscribers);
}
static void callback_send_t_text_set(void *user, VNodeID node_id, VBufferID buffer_id, uint32 pos, uint32 length, const char *text)
{
VSNodeText *node;
VSTextBuffer *tb;
unsigned int i, count, text_length;
char *buf;
node = (VSNodeText *) vs_get_node(node_id, V_NT_TEXT);
if(node == NULL)
return;
if(buffer_id >= node->buffer_count || node->buffer[buffer_id].name[0] == 0)
return;
tb = &node->buffer[buffer_id];
text_length = strlen(text);
/* Clamp position and length of deleted region. */
if(pos > tb->length)
pos = tb->length;
if(pos + length > tb->length)
length = tb->length - pos;
buf = tb->text;
if(tb->length + text_length - length > tb->allocated)
{
buf = realloc(buf, tb->length + text_length - length + VS_TEXT_CHUNK_SIZE);
tb->allocated = tb->length + text_length - length + VS_TEXT_CHUNK_SIZE;
}
if(text_length < length) /* Insert smaller than delete? */
{
memmove(buf + pos + text_length, buf + pos + length, tb->length - (pos + length));
memcpy(buf + pos, text, text_length);
}
else /* Insert is larger than delete. */
{
memmove(buf + pos + text_length, buf + pos + length, tb->length - pos);
memcpy(buf + pos, text, text_length);
}
tb->length += (int) text_length - length;
buf[tb->length] = '\0';
/* Buffer very much larger than content? Then shrink it. */
if(tb->allocated > VS_TEXT_CHUNK_SIZE * 8 && tb->allocated * 2 > tb->length)
{
buf = realloc(buf, tb->length + VS_TEXT_CHUNK_SIZE);
tb->allocated = tb->length + VS_TEXT_CHUNK_SIZE;
}
tb->text = buf;
count = vs_get_subscript_count(tb->subscribers);
for(i = 0; i < count; i++)
{
vs_set_subscript_session(tb->subscribers, i);
verse_send_t_text_set(node_id, buffer_id, pos, length, text);
}
vs_reset_subscript_session();
}
void vs_t_callback_init(void)
{
verse_callback_set(verse_send_t_language_set, callback_send_t_language_set, NULL);
verse_callback_set(verse_send_t_buffer_create, callback_send_t_buffer_create, NULL);
verse_callback_set(verse_send_t_buffer_destroy, callback_send_t_buffer_destroy, NULL);
verse_callback_set(verse_send_t_buffer_subscribe, callback_send_t_buffer_subscribe, NULL);
verse_callback_set(verse_send_t_buffer_unsubscribe, callback_send_t_buffer_unsubscribe, NULL);
verse_callback_set(verse_send_t_text_set, callback_send_t_text_set, NULL);
}
#endif

@ -1,62 +0,0 @@
/*
**
*/
#include <stdlib.h>
extern void vs_init_connection_storage(void);
extern void vs_add_new_connection(VSession session, const char *name, const char *pass, VNodeID node_id);
extern void vs_remove_connection(void);
extern void vs_set_next_session(void);
typedef void VSSubscriptionList;
extern VSSubscriptionList * vs_create_subscription_list(void);
extern void vs_destroy_subscription_list(VSSubscriptionList *list);
extern int vs_add_new_subscriptor(VSSubscriptionList *list);
extern void vs_remove_subscriptor(VSSubscriptionList *list);
extern unsigned int vs_get_subscript_count(const VSSubscriptionList *list);
extern void vs_set_subscript_session(VSSubscriptionList *list, unsigned int session);
extern void vs_reset_subscript_session(void);
extern uint32 vs_get_avatar(void);
extern VSession vs_get_session(void);
extern const char * vs_get_user_name(void);
extern const char * vs_get_user_pass(void);
typedef struct {
VNodeID id;
VNodeType type;
VNodeID owner;
char *name;
void *tag_groups;
uint16 group_count;
VSSubscriptionList *subscribers;
} VSNodeHead;
extern void vs_init_node_storage(void);
extern uint32 vs_add_new_node(VSNodeHead *node, VNodeType type);
extern VSNodeHead * vs_get_node(unsigned int node_id, VNodeType type);
extern VSNodeHead * vs_get_node_head(unsigned int node_id);
extern void create_node_head(VSNodeHead *node, const char *name, unsigned int owner);
extern void destroy_node_head(VSNodeHead *node);
extern void vs_send_node_head(VSNodeHead *node);
extern void vs_h_callback_init(void); /* "Head", not an actual node type. */
extern void vs_o_callback_init(void);
extern void vs_g_callback_init(void);
extern void vs_m_callback_init(void);
extern void vs_b_callback_init(void);
extern void vs_t_callback_init(void);
extern void vs_c_callback_init(void);
extern void vs_a_callback_init(void);
extern void init_callback_node_storage(void);
extern void vs_master_set_enabled(boolean enabled);
extern void vs_master_set_address(const char *address);
extern const char * vs_master_get_address(void);
extern void vs_master_set_desc(const char *desc);
extern void vs_master_set_tags(const char *tags);
extern void vs_master_update(void);
extern void vs_master_handle_describe(const char *address, const char *message);

@ -1,279 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="verse"
ProjectGUID="{F9850C15-FF0A-429E-9D47-89FB433C9BD8}"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Blender Debug|Win32"
OutputDirectory="..\..\..\..\..\build\msvc_7\extern\verse\debug"
IntermediateDirectory="..\..\..\..\..\build\msvc_7\extern\verse\debug"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\include;..\..\..\..\..\lib\windows\freetype\include"
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;FTGL_LIBRARY_STATIC"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderFile="..\..\..\..\..\build\msvc_7\extern\verse\debug\libverse.pch"
AssemblerListingLocation="..\..\..\..\..\build\msvc_7\extern\verse\debug\"
ObjectFile="..\..\..\..\..\build\msvc_7\extern\verse\debug\"
ProgramDataBaseFileName="..\..\..\..\..\build\msvc_7\extern\verse\debug\"
WarningLevel="2"
SuppressStartupBanner="TRUE"
DebugInformationFormat="3"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\..\..\build\msvc_7\libs\extern\debug\verse.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"
Description="Copying verse files library (debug target) to lib tree."
CommandLine="ECHO Copying header files
IF NOT EXIST ..\..\..\..\..\build\msvc_7\extern\verse\include\ MKDIR ..\..\..\..\..\build\msvc_7\extern\verse\include
XCOPY /Y ..\..\dist\*.h ..\..\..\..\..\build\msvc_7\extern\verse\include
ECHO Done
"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Blender Release|Win32"
OutputDirectory="..\..\..\..\..\build\msvc_7\extern\verse"
IntermediateDirectory="..\..\..\..\..\build\msvc_7\extern\verse"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\include;..\..\..\..\..\lib\windows\freetype\include"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;FTGL_LIBRARY_STATIC"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile="..\..\..\..\..\build\msvc_7\extern\verse\libverse.pch"
AssemblerListingLocation="..\..\..\..\..\build\msvc_7\extern\verse\"
ObjectFile="..\..\..\..\..\build\msvc_7\extern\verse\"
ProgramDataBaseFileName="..\..\..\..\..\build\msvc_7\extern\verse\"
WarningLevel="2"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\..\..\build\msvc_7\libs\extern\verse.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"
Description="Copying verse files library to lib tree."
CommandLine="ECHO Copying header files
IF NOT EXIST ..\..\..\..\..\build\msvc_7\extern\verse\include\ MKDIR ..\..\..\..\..\build\msvc_7\extern\verse\include
XCOPY /Y ..\..\dist\*.h ..\..\..\..\..\build\msvc_7\extern\verse\include
ECHO Done
"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="..\..\dist\v_bignum.c">
</File>
<File
RelativePath="..\..\dist\v_cmd_buf.c">
</File>
<File
RelativePath="..\..\dist\v_cmd_def_a.c">
</File>
<File
RelativePath="..\..\dist\v_cmd_def_b.c">
</File>
<File
RelativePath="..\..\dist\v_cmd_def_c.c">
</File>
<File
RelativePath="..\..\dist\v_cmd_def_g.c">
</File>
<File
RelativePath="..\..\dist\v_cmd_def_m.c">
</File>
<File
RelativePath="..\..\dist\v_cmd_def_o.c">
</File>
<File
RelativePath="..\..\dist\v_cmd_def_s.c">
</File>
<File
RelativePath="..\..\dist\v_cmd_def_t.c">
</File>
<File
RelativePath="..\..\dist\v_connect.c">
</File>
<File
RelativePath="..\..\dist\v_connection.c">
</File>
<File
RelativePath="..\..\dist\v_encryption.c">
</File>
<File
RelativePath="..\..\dist\v_func_storage.c">
</File>
<File
RelativePath="..\..\dist\v_gen_pack_a_node.c">
</File>
<File
RelativePath="..\..\dist\v_gen_pack_b_node.c">
</File>
<File
RelativePath="..\..\dist\v_gen_pack_c_node.c">
</File>
<File
RelativePath="..\..\dist\v_gen_pack_g_node.c">
</File>
<File
RelativePath="..\..\dist\v_gen_pack_init.c">
</File>
<File
RelativePath="..\..\dist\v_gen_pack_m_node.c">
</File>
<File
RelativePath="..\..\dist\v_gen_pack_o_node.c">
</File>
<File
RelativePath="..\..\dist\v_gen_pack_s_node.c">
</File>
<File
RelativePath="..\..\dist\v_gen_pack_t_node.c">
</File>
<File
RelativePath="..\..\dist\v_man_pack_node.c">
</File>
<File
RelativePath="..\..\dist\v_network.c">
</File>
<File
RelativePath="..\..\dist\v_network_in_que.c">
</File>
<File
RelativePath="..\..\dist\v_network_out_que.c">
</File>
<File
RelativePath="..\..\dist\v_pack.c">
</File>
<File
RelativePath="..\..\dist\v_pack_method.c">
</File>
<File
RelativePath="..\..\dist\v_prime.c">
</File>
<File
RelativePath="..\..\dist\v_randgen.c">
</File>
<File
RelativePath="..\..\dist\v_util.c">
</File>
<File
RelativePath="..\..\dist\verse_ms.c">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="..\..\dist\v_bignum.h">
</File>
<File
RelativePath="..\..\dist\v_cmd_buf.h">
</File>
<File
RelativePath="..\..\dist\v_connection.h">
</File>
<File
RelativePath="..\..\dist\v_encryption.h">
</File>
<File
RelativePath="..\..\dist\v_internal_verse.h">
</File>
<File
RelativePath="..\..\dist\v_network.h">
</File>
<File
RelativePath="..\..\dist\v_network_in_que.h">
</File>
<File
RelativePath="..\..\dist\v_network_out_que.h">
</File>
<File
RelativePath="..\..\dist\v_pack.h">
</File>
<File
RelativePath="..\..\dist\v_randgen.h">
</File>
<File
RelativePath="..\..\dist\v_util.h">
</File>
</Filter>
<File
RelativePath="..\..\dist\verse_ms.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

@ -1,481 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="verse_server"
ProjectGUID="{FC752464-F413-4D4F-842D-A5D3AA0E6A3D}"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="3D Plugin Debug|Win32"
OutputDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\debug"
IntermediateDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\debug"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include"
PreprocessorDefinitions="_DEBUG,WIN32,_CONSOLE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
DefaultCharIsUnsigned="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\debug\verse.pch"
AssemblerListingLocation="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\debug\"
ObjectFile="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\debug\"
ProgramDataBaseFileName="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\debug\"
WarningLevel="2"
SuppressStartupBanner="TRUE"
DebugInformationFormat="3"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib"
OutputFile=".\..\..\..\source\blender\makesdna\intern/DNA_makesdna.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\..\..\build\msvc_7\libs\intern\mtdll\debug;..\..\..\..\build\msvc_7\libs\mtdll\debug"
IgnoreDefaultLibraryNames=" libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="..\..\..\..\build\msvc_7\libs\debug\DNA_makesdna.pdb"
SubSystem="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/DNA_makesdna.tlb"/>
<Tool
Name="VCPostBuildEventTool"
Description="Building DNA"
CommandLine="CD ..\..\..\source\blender\makesdna\intern\
DNA_makesdna.exe dna.c
"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Blender Release|Win32"
OutputDirectory="..\..\..\..\bin"
IntermediateDirectory="..\..\..\..\..\build\msvc_7\extern\verse\server"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
DefaultCharIsUnsigned="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile="..\..\..\..\..\build\msvc_7\source\blender\verse\server\verse.pch"
AssemblerListingLocation="..\..\..\..\..\build\msvc_7\extern\verse\server\"
ObjectFile="..\..\..\..\..\build\msvc_7\extern\verse\server\"
ProgramDataBaseFileName="..\..\..\..\..\build\msvc_7\extern\verse\server\"
WarningLevel="2"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="verse.lib ws2_32.lib"
OutputFile="..\..\..\..\bin\verse.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\..\..\..\build\msvc_7\libs\extern"
IgnoreDefaultLibraryNames="libc.lib"
ProgramDatabaseFile="..\..\..\..\..\build\msvc_7\extern\verse\server\verse.pdb"
SubSystem="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="3D Plugin Release|Win32"
OutputDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll"
IntermediateDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include"
PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
DefaultCharIsUnsigned="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\verse.pch"
AssemblerListingLocation="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\"
ObjectFile="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\"
ProgramDataBaseFileName="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\"
WarningLevel="2"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib"
OutputFile="..\..\..\source\blender\makesdna\intern\verse.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\..\..\build\msvc_7\libs\intern\mtdll;..\..\..\..\build\msvc_7\libs\mtdll"
IgnoreDefaultLibraryNames=" libc.lib, libcmt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib"
ProgramDatabaseFile="..\..\..\..\build\msvc_7\libs\verse.pdb"
SubSystem="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"/>
<Tool
Name="VCPostBuildEventTool"
Description="Building DNA"
CommandLine="CD ..\..\..\source\blender\makesdna\intern\
verse.exe dna.c
"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Blender Debug|Win32"
OutputDirectory="..\..\..\..\bin\debug"
IntermediateDirectory="..\..\..\..\..\build\msvc_7\extern\verse\server\debug"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
DefaultCharIsUnsigned="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile="..\..\..\..\..\build\msvc_7\source\blender\verse\server\debug\verse.pch"
ExpandAttributedSource="FALSE"
AssemblerListingLocation="..\..\..\..\..\build\msvc_7\extern\verse\server\debug\"
ObjectFile="..\..\..\..\..\build\msvc_7\extern\verse\server\debug\"
ProgramDataBaseFileName="..\..\..\..\..\build\msvc_7\extern\verse\server\debug\"
WarningLevel="2"
SuppressStartupBanner="TRUE"
DebugInformationFormat="3"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386
"
AdditionalDependencies="verse.lib ws2_32.lib"
OutputFile="..\..\..\..\bin\debug\verse.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\..\..\..\build\msvc_7\libs\extern\debug"
IgnoreAllDefaultLibraries="FALSE"
IgnoreDefaultLibraryNames="libcd"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="..\..\..\..\..\build\msvc_7\extern\verse\server\debug\verse.pdb"
SubSystem="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="BlenderPlayer Debug|Win32"
OutputDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\debug\blenplayer"
IntermediateDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\debug\blenplayer"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include"
PreprocessorDefinitions="_DEBUG,WIN32,_CONSOLE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
DefaultCharIsUnsigned="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile="..\..\..\..\build\msvc_7\source\blender\makesdna\debug\verse.pch"
ExpandAttributedSource="FALSE"
AssemblerListingLocation="..\..\..\..\build\msvc_7\source\blender\makesdna\debug\"
ObjectFile="..\..\..\..\build\msvc_7\source\blender\makesdna\debug\"
ProgramDataBaseFileName="..\..\..\..\build\msvc_7\source\blender\makesdna\debug\"
WarningLevel="2"
SuppressStartupBanner="TRUE"
DebugInformationFormat="3"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386
"
AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib"
OutputFile="..\..\..\source\blender\makesdna\intern\verse.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\..\..\build\msvc_7\libs\intern\debug;..\..\..\..\build\msvc_7\libs\debug"
IgnoreAllDefaultLibraries="FALSE"
IgnoreDefaultLibraryNames="libc.lib, libcd.lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="..\..\..\..\build\msvc_7\libs\debug\verse.pdb"
SubSystem="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"/>
<Tool
Name="VCPostBuildEventTool"
Description="Building DNA"
CommandLine="CD ..\..\..\source\blender\makesdna\intern
verse.exe dna.c
"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="BlenderPlayer Release|Win32"
OutputDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\blenplayer"
IntermediateDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\blenplayer"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include"
PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
DefaultCharIsUnsigned="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile="..\..\..\..\build\msvc_7\source\blender\makesdna\verse.pch"
AssemblerListingLocation="..\..\..\..\build\msvc_7\source\blender\makesdna\"
ObjectFile="..\..\..\..\build\msvc_7\source\blender\makesdna\"
ProgramDataBaseFileName="..\..\..\..\build\msvc_7\source\blender\makesdna\"
WarningLevel="2"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib"
OutputFile="..\..\..\source\blender\makesdna\intern\verse.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\..\..\build\msvc_7\libs\intern;..\..\..\..\build\msvc_7\libs"
IgnoreDefaultLibraryNames="libc.lib"
ProgramDatabaseFile="..\..\..\..\build\msvc_7\libs\verse.pdb"
SubSystem="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"/>
<Tool
Name="VCPostBuildEventTool"
Description="Building DNA"
CommandLine="CD ..\..\..\source\blender\makesdna\intern\
verse.exe dna.c
"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="..\..\dist\vs_connection.c">
</File>
<File
RelativePath="..\..\dist\vs_main.c">
</File>
<File
RelativePath="..\..\dist\vs_master.c">
</File>
<File
RelativePath="..\..\dist\vs_node_audio.c">
</File>
<File
RelativePath="..\..\dist\vs_node_bitmap.c">
</File>
<File
RelativePath="..\..\dist\vs_node_curve.c">
</File>
<File
RelativePath="..\..\dist\vs_node_geometry.c">
</File>
<File
RelativePath="..\..\dist\vs_node_head.c">
</File>
<File
RelativePath="..\..\dist\vs_node_material.c">
</File>
<File
RelativePath="..\..\dist\vs_node_object.c">
</File>
<File
RelativePath="..\..\dist\vs_node_particle.c">
</File>
<File
RelativePath="..\..\dist\vs_node_storage.c">
</File>
<File
RelativePath="..\..\dist\vs_node_text.c">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="..\..\dist\v_cmd_gen.h">
</File>
<File
RelativePath="..\..\dist\v_util.h">
</File>
<File
RelativePath="..\..\dist\verse.h">
</File>
<File
RelativePath="..\..\dist\vs_server.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

@ -1,368 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="EXT_verse"
ProjectGUID="{531D4862-D0E7-4B9B-A0B6-B3A6A25B547A}"
RootNamespace="verse"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Blender Debug|Win32"
OutputDirectory="..\..\..\..\..\build\msvc_9\extern\verse\debug"
IntermediateDirectory="..\..\..\..\..\build\msvc_9\extern\verse\debug"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\include;..\..\..\..\..\lib\windows\freetype\include"
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;FTGL_LIBRARY_STATIC"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="..\..\..\..\..\build\msvc_9\extern\verse\debug\libverse.pch"
AssemblerListingLocation="..\..\..\..\..\build\msvc_9\extern\verse\debug\"
ObjectFile="..\..\..\..\..\build\msvc_9\extern\verse\debug\"
ProgramDataBaseFileName="..\..\..\..\..\build\msvc_9\extern\verse\debug\"
WarningLevel="2"
SuppressStartupBanner="true"
DebugInformationFormat="3"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\..\..\build\msvc_9\libs\extern\debug\verse.lib"
SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Copying verse files library (debug target) to lib tree."
CommandLine="ECHO Copying header files&#x0D;&#x0A;IF NOT EXIST ..\..\..\..\..\build\msvc_9\extern\verse\include\ MKDIR ..\..\..\..\..\build\msvc_9\extern\verse\include&#x0D;&#x0A;XCOPY /Y ..\..\dist\*.h ..\..\..\..\..\build\msvc_9\extern\verse\include&#x0D;&#x0A;ECHO Done&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
Name="Blender Release|Win32"
OutputDirectory="..\..\..\..\..\build\msvc_9\extern\verse"
IntermediateDirectory="..\..\..\..\..\build\msvc_9\extern\verse"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\include;..\..\..\..\..\lib\windows\freetype\include"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;FTGL_LIBRARY_STATIC"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="..\..\..\..\..\build\msvc_9\extern\verse\libverse.pch"
AssemblerListingLocation="..\..\..\..\..\build\msvc_9\extern\verse\"
ObjectFile="..\..\..\..\..\build\msvc_9\extern\verse\"
ProgramDataBaseFileName="..\..\..\..\..\build\msvc_9\extern\verse\"
WarningLevel="2"
SuppressStartupBanner="true"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\..\..\build\msvc_9\libs\extern\verse.lib"
SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Copying verse files library to lib tree."
CommandLine="ECHO Copying header files&#x0D;&#x0A;IF NOT EXIST ..\..\..\..\..\build\msvc_9\extern\verse\include\ MKDIR ..\..\..\..\..\build\msvc_9\extern\verse\include&#x0D;&#x0A;XCOPY /Y ..\..\dist\*.h ..\..\..\..\..\build\msvc_9\extern\verse\include&#x0D;&#x0A;ECHO Done&#x0D;&#x0A;"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="..\..\dist\v_bignum.c"
>
</File>
<File
RelativePath="..\..\dist\v_cmd_buf.c"
>
</File>
<File
RelativePath="..\..\dist\v_cmd_def_a.c"
>
</File>
<File
RelativePath="..\..\dist\v_cmd_def_b.c"
>
</File>
<File
RelativePath="..\..\dist\v_cmd_def_c.c"
>
</File>
<File
RelativePath="..\..\dist\v_cmd_def_g.c"
>
</File>
<File
RelativePath="..\..\dist\v_cmd_def_m.c"
>
</File>
<File
RelativePath="..\..\dist\v_cmd_def_o.c"
>
</File>
<File
RelativePath="..\..\dist\v_cmd_def_s.c"
>
</File>
<File
RelativePath="..\..\dist\v_cmd_def_t.c"
>
</File>
<File
RelativePath="..\..\dist\v_connect.c"
>
</File>
<File
RelativePath="..\..\dist\v_connection.c"
>
</File>
<File
RelativePath="..\..\dist\v_encryption.c"
>
</File>
<File
RelativePath="..\..\dist\v_func_storage.c"
>
</File>
<File
RelativePath="..\..\dist\v_gen_pack_a_node.c"
>
</File>
<File
RelativePath="..\..\dist\v_gen_pack_b_node.c"
>
</File>
<File
RelativePath="..\..\dist\v_gen_pack_c_node.c"
>
</File>
<File
RelativePath="..\..\dist\v_gen_pack_g_node.c"
>
</File>
<File
RelativePath="..\..\dist\v_gen_pack_init.c"
>
</File>
<File
RelativePath="..\..\dist\v_gen_pack_m_node.c"
>
</File>
<File
RelativePath="..\..\dist\v_gen_pack_o_node.c"
>
</File>
<File
RelativePath="..\..\dist\v_gen_pack_s_node.c"
>
</File>
<File
RelativePath="..\..\dist\v_gen_pack_t_node.c"
>
</File>
<File
RelativePath="..\..\dist\v_man_pack_node.c"
>
</File>
<File
RelativePath="..\..\dist\v_network.c"
>
</File>
<File
RelativePath="..\..\dist\v_network_in_que.c"
>
</File>
<File
RelativePath="..\..\dist\v_network_out_que.c"
>
</File>
<File
RelativePath="..\..\dist\v_pack.c"
>
</File>
<File
RelativePath="..\..\dist\v_pack_method.c"
>
</File>
<File
RelativePath="..\..\dist\v_prime.c"
>
</File>
<File
RelativePath="..\..\dist\v_randgen.c"
>
</File>
<File
RelativePath="..\..\dist\v_util.c"
>
</File>
<File
RelativePath="..\..\dist\verse_ms.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="..\..\dist\v_bignum.h"
>
</File>
<File
RelativePath="..\..\dist\v_cmd_buf.h"
>
</File>
<File
RelativePath="..\..\dist\v_connection.h"
>
</File>
<File
RelativePath="..\..\dist\v_encryption.h"
>
</File>
<File
RelativePath="..\..\dist\v_internal_verse.h"
>
</File>
<File
RelativePath="..\..\dist\v_network.h"
>
</File>
<File
RelativePath="..\..\dist\v_network_in_que.h"
>
</File>
<File
RelativePath="..\..\dist\v_network_out_que.h"
>
</File>
<File
RelativePath="..\..\dist\v_pack.h"
>
</File>
<File
RelativePath="..\..\dist\v_randgen.h"
>
</File>
<File
RelativePath="..\..\dist\v_util.h"
>
</File>
</Filter>
<File
RelativePath="..\..\dist\verse_ms.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

@ -1,669 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="EXT_verse_server"
ProjectGUID="{FC752464-F413-4D4F-842D-A5D3AA0E6A3D}"
RootNamespace="verse_server"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="3D Plugin Debug|Win32"
OutputDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\debug"
IntermediateDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/DNA_makesdna.tlb"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include"
PreprocessorDefinitions="_DEBUG,WIN32,_CONSOLE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
DefaultCharIsUnsigned="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\debug\verse.pch"
AssemblerListingLocation="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\debug\"
ObjectFile="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\debug\"
ProgramDataBaseFileName="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\debug\"
WarningLevel="2"
SuppressStartupBanner="true"
DebugInformationFormat="3"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib"
OutputFile=".\..\..\..\source\blender\makesdna\intern/DNA_makesdna.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\..\build\msvc_9\libs\intern\mtdll\debug;..\..\..\..\build\msvc_9\libs\mtdll\debug"
IgnoreDefaultLibraryNames=" libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib"
GenerateDebugInformation="true"
ProgramDatabaseFile="..\..\..\..\build\msvc_9\libs\debug\DNA_makesdna.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Building DNA"
CommandLine="CD ..\..\..\source\blender\makesdna\intern\&#x0D;&#x0A;DNA_makesdna.exe dna.c&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
Name="Blender Release|Win32"
OutputDirectory="..\..\..\..\bin"
IntermediateDirectory="..\..\..\..\..\build\msvc_9\extern\verse\server"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"
/>
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
DefaultCharIsUnsigned="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="..\..\..\..\..\build\msvc_9\source\blender\verse\server\verse.pch"
AssemblerListingLocation="..\..\..\..\..\build\msvc_9\extern\verse\server\"
ObjectFile="..\..\..\..\..\build\msvc_9\extern\verse\server\"
ProgramDataBaseFileName="..\..\..\..\..\build\msvc_9\extern\verse\server\"
WarningLevel="2"
SuppressStartupBanner="true"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="verse.lib ws2_32.lib"
OutputFile="..\..\..\..\bin\verse.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\..\..\build\msvc_9\libs\extern"
IgnoreDefaultLibraryNames="libc.lib"
ProgramDatabaseFile="..\..\..\..\..\build\msvc_9\extern\verse\server\verse.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="3D Plugin Release|Win32"
OutputDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll"
IntermediateDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"
/>
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include"
PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
DefaultCharIsUnsigned="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\verse.pch"
AssemblerListingLocation="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\"
ObjectFile="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\"
ProgramDataBaseFileName="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\"
WarningLevel="2"
SuppressStartupBanner="true"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib"
OutputFile="..\..\..\source\blender\makesdna\intern\verse.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\..\build\msvc_9\libs\intern\mtdll;..\..\..\..\build\msvc_9\libs\mtdll"
IgnoreDefaultLibraryNames=" libc.lib, libcmt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib"
ProgramDatabaseFile="..\..\..\..\build\msvc_9\libs\verse.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Building DNA"
CommandLine="CD ..\..\..\source\blender\makesdna\intern\&#x0D;&#x0A;verse.exe dna.c&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
Name="Blender Debug|Win32"
OutputDirectory="..\..\..\..\bin\debug"
IntermediateDirectory="..\..\..\..\..\build\msvc_9\extern\verse\server\debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
DefaultCharIsUnsigned="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="..\..\..\..\..\build\msvc_9\source\blender\verse\server\debug\verse.pch"
ExpandAttributedSource="false"
AssemblerListingLocation="..\..\..\..\..\build\msvc_9\extern\verse\server\debug\"
ObjectFile="..\..\..\..\..\build\msvc_9\extern\verse\server\debug\"
ProgramDataBaseFileName="..\..\..\..\..\build\msvc_9\extern\verse\server\debug\"
WarningLevel="2"
SuppressStartupBanner="true"
DebugInformationFormat="3"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386&#x0D;&#x0A;"
AdditionalDependencies="verse.lib ws2_32.lib"
OutputFile="..\..\..\..\bin\debug\verse.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\..\..\build\msvc_9\libs\extern\debug"
IgnoreAllDefaultLibraries="false"
IgnoreDefaultLibraryNames="libcd"
GenerateDebugInformation="true"
ProgramDatabaseFile="..\..\..\..\..\build\msvc_9\extern\verse\server\debug\verse.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="BlenderPlayer Debug|Win32"
OutputDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\debug\blenplayer"
IntermediateDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\debug\blenplayer"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include"
PreprocessorDefinitions="_DEBUG,WIN32,_CONSOLE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
DefaultCharIsUnsigned="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="..\..\..\..\build\msvc_9\source\blender\makesdna\debug\verse.pch"
ExpandAttributedSource="false"
AssemblerListingLocation="..\..\..\..\build\msvc_9\source\blender\makesdna\debug\"
ObjectFile="..\..\..\..\build\msvc_9\source\blender\makesdna\debug\"
ProgramDataBaseFileName="..\..\..\..\build\msvc_9\source\blender\makesdna\debug\"
WarningLevel="2"
SuppressStartupBanner="true"
DebugInformationFormat="3"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386&#x0D;&#x0A;"
AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib"
OutputFile="..\..\..\source\blender\makesdna\intern\verse.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\..\build\msvc_9\libs\intern\debug;..\..\..\..\build\msvc_9\libs\debug"
IgnoreAllDefaultLibraries="false"
IgnoreDefaultLibraryNames="libc.lib, libcd.lib"
GenerateDebugInformation="true"
ProgramDatabaseFile="..\..\..\..\build\msvc_9\libs\debug\verse.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Building DNA"
CommandLine="CD ..\..\..\source\blender\makesdna\intern&#x0D;&#x0A;verse.exe dna.c&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
Name="BlenderPlayer Release|Win32"
OutputDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\blenplayer"
IntermediateDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\blenplayer"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"
/>
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include"
PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
DefaultCharIsUnsigned="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="..\..\..\..\build\msvc_9\source\blender\makesdna\verse.pch"
AssemblerListingLocation="..\..\..\..\build\msvc_9\source\blender\makesdna\"
ObjectFile="..\..\..\..\build\msvc_9\source\blender\makesdna\"
ProgramDataBaseFileName="..\..\..\..\build\msvc_9\source\blender\makesdna\"
WarningLevel="2"
SuppressStartupBanner="true"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib"
OutputFile="..\..\..\source\blender\makesdna\intern\verse.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\..\..\build\msvc_9\libs\intern;..\..\..\..\build\msvc_9\libs"
IgnoreDefaultLibraryNames="libc.lib"
ProgramDatabaseFile="..\..\..\..\build\msvc_9\libs\verse.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Building DNA"
CommandLine="CD ..\..\..\source\blender\makesdna\intern\&#x0D;&#x0A;verse.exe dna.c&#x0D;&#x0A;"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="..\..\dist\vs_connection.c"
>
</File>
<File
RelativePath="..\..\dist\vs_main.c"
>
</File>
<File
RelativePath="..\..\dist\vs_master.c"
>
</File>
<File
RelativePath="..\..\dist\vs_node_audio.c"
>
</File>
<File
RelativePath="..\..\dist\vs_node_bitmap.c"
>
</File>
<File
RelativePath="..\..\dist\vs_node_curve.c"
>
</File>
<File
RelativePath="..\..\dist\vs_node_geometry.c"
>
</File>
<File
RelativePath="..\..\dist\vs_node_head.c"
>
</File>
<File
RelativePath="..\..\dist\vs_node_material.c"
>
</File>
<File
RelativePath="..\..\dist\vs_node_object.c"
>
</File>
<File
RelativePath="..\..\dist\vs_node_particle.c"
>
</File>
<File
RelativePath="..\..\dist\vs_node_storage.c"
>
</File>
<File
RelativePath="..\..\dist\vs_node_text.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="..\..\dist\v_cmd_gen.h"
>
</File>
<File
RelativePath="..\..\dist\v_util.h"
>
</File>
<File
RelativePath="..\..\dist\verse.h"
>
</File>
<File
RelativePath="..\..\dist\vs_server.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

@ -200,18 +200,6 @@ ifeq ($(WITH_FREETYPE2), true)
endif
endif
ifeq ($(WITH_VERSE), true)
ifeq ($(OS), windows)
ifeq ($(FREE_WINDOWS), true)
COMLIB += $(NAN_VERSE)/lib/libverse.a
else
COMLIB += $(NAN_VERSE)/lib/verse.lib
endif
else
COMLIB += $(NAN_VERSE)/lib/libverse.a
endif
endif
ifeq ($(OS), irix)
COMLIB += $(NAN_SDL)/lib/libSDL.a
endif

@ -83,7 +83,7 @@ struct DerivedMesh {
/* copy a single vert/edge/face from the derived mesh into
* *{vert/edge/face}_r. note that the current implementation
* of this function can be quite slow, iterating over all
* elements (editmesh, verse mesh)
* elements (editmesh)
*/
void (*getVert)(DerivedMesh *dm, int index, struct MVert *vert_r);
void (*getEdge)(DerivedMesh *dm, int index, struct MEdge *edge_r);

@ -152,10 +152,7 @@ typedef struct Global {
#define G_DRAW_EDGEANG (1 << 24)
/* #define G_RECORDKEYS (1 << 25) also removed */
/*#ifdef WITH_VERSE*/
#define G_VERSE_CONNECTED (1 << 26)
#define G_DRAW_VERSE_DEBUG (1 << 27)
/*#endif*/
#define G_DRAWSHARP (1 << 28) /* draw edges with the sharp flag */
#define G_SCULPTMODE (1 << 29)
#define G_PARTICLEEDIT (1 << 30)

@ -82,7 +82,6 @@ struct RenderResult;
#define IMA_TYPE_MULTILAYER 1
/* generated */
#define IMA_TYPE_UV_TEST 2
#define IMA_TYPE_VERSE 3
/* viewers */
#define IMA_TYPE_R_RESULT 4
#define IMA_TYPE_COMPOSITE 5

@ -1,583 +0,0 @@
/**
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Contributor(s): Jiri Hnidek.
*
* ***** END GPL LICENSE BLOCK *****
*/
/* #define WITH_VERSE */
#ifndef BKE_VERSE_H
#define BKE_VERSE_H
#include "DNA_listBase.h"
#include "BLI_dynamiclist.h"
#include "verse.h"
#include "verse_ms.h"
struct VNode;
struct VerseEdge;
/*
* Verse Edge Hash (similar to edit edge hash)
*/
#define VEDHASHSIZE (512*512)
#define VEDHASH(a, b) ((a<b ? a : b) % VEDHASHSIZE)
/*
* verse data: 4 float value
*/
typedef struct quat_real32_item {
struct quat_real32_item *next, *prev;
struct VLayer *vlayer; /* pointer at VerseLayer */
uint32 id; /* id of item */
real32 value[4];
} quat_real32_item;
/*
* verse data: 4 uint32 values
*/
typedef struct quat_uint32_item {
struct quat_uint32_item *next, *prev;
struct VLayer *vlayer; /* pointer at VerseLayer */
uint32 id; /* id of item */
uint32 value[4];
} quat_uint32_item;
/*
* verse data: 3 float values
*/
typedef struct vec_real32_item {
struct vec_real32_item *next, *prev;
struct VLayer *vlayer; /* pointer at VerseLayer */
uint32 id; /* id of item */
real32 value[3];
} vec_real32_item;
/*
* verse data: float value (weight)
*/
typedef struct real32_item {
struct real32_item *next, *prev;
struct VLayer *vlayer; /* pointer at VerseLayer */
uint32 id; /* id of item */
real32 value;
} real32_item;
/*
* verse data: uint32 value
*/
typedef struct uint32_item {
struct uint32_item *next, *prev;
struct VLayer *vlayer; /* pointer at VerseLayer */
uint32 id; /* id of item */
uint32 value;
} uint32_item;
/*
* verse data: uint8 value
*/
typedef struct uint8_item {
struct uint8_item *next, *prev;
struct VLayer *vlayer; /* pointer at VerseLayer */
uint32 id; /* id of item */
uint8 value;
} uint8_item;
/*
* verse data: vertex
*/
typedef struct VerseVert {
struct VerseVert *next, *prev;
/* verse data */
struct VLayer *vlayer; /* pointer at VerseLayer */
uint32 id; /* id of vertex */
real32 co[3]; /* x,y,z-coordinates of vertex */
real32 no[3]; /* normal of vertex */
/* blender internals */
short flag; /* flags: VERT_DELETED, VERT_RECEIVED, etc. */
void *vertex; /* pointer at EditVert or MVert */
int counter; /* counter of VerseFaces using this VerseVert */
union {
unsigned int index; /* counter need during transformation to mesh */
struct VerseVert *vvert;
} tmp; /* pointer at new created verse vert, it is
* used during duplicating geometry node */
float *cos; /* modified coordinates of vertex */
float *nos; /* modified normal vector */
} VerseVert;
/*
* structture used for verse edge hash
*/
typedef struct HashVerseEdge {
struct VerseEdge *vedge;
struct HashVerseEdge *next;
} HashVerseEdge;
/*
* fake verse data: edge
*/
typedef struct VerseEdge {
struct VerseEdge *next, *prev;
uint32 v0, v1; /* indexes of verse vertexes */
int counter; /* counter of verse faces using this edge */
struct HashVerseEdge hash; /* hash table */
union {
unsigned int index; /* temporary index of edge */
} tmp;
} VerseEdge;
/*
* verse data: polygon
*/
typedef struct VerseFace {
struct VerseFace *next, *prev;
/* verse data */
struct VLayer *vlayer; /* pointer at VerseLayer */
uint32 id; /* id of face */
struct VerseVert *vvert0; /* pointer at 1st VerseVert */
struct VerseVert *vvert1; /* pointer at 2nd VerseVert */
struct VerseVert *vvert2; /* pointer at 3th VerseVert */
struct VerseVert *vvert3; /* pointer at 4th VerseVert */
unsigned int v0, v1, v2, v3; /* indexes of VerseVerts ... needed during receiving */
/* blender internals */
char flag; /* flags: FACE_SEND_READY, FACE_SENT, FACE_RECEIVED, FACE_CHANGED*/
short counter; /* counter of missed VerseVertexes */
void *face; /* pointer at EditFace */
float no[3]; /* normal vector */
float *nos; /* modified normal vector */
} VerseFace;
/*
* verse data: layer
*/
typedef struct VLayer {
struct VLayer *next, *prev;
/* verse data*/
struct VNode *vnode; /* pointer at VerseNode */
uint16 id; /* id of layer */
char *name; /* name of layer */
VNGLayerType type; /* type of layer (VN_G_LAYER_VERTEX_XYZ, VN_G_LAYER_POLYGON_CORNER_UINT32) */
uint32 def_int; /* default integer value */
real64 def_real; /* default float value */
/* blender internals */
char flag; /* flags: LAYER_SENT, LAYER_RECEIVED, LAYER_DELETED, LAYER_OBSOLETE */
short content; /* type of content (VERTEX_LAYER, POLYGON_LAYER) */
struct DynamicList dl; /* vertexes, polygons, etc. */
struct ListBase queue; /* queue of vertexes, polygons, etc. waiting for sending to verse server */
struct ListBase orphans; /* list of versedata (polygons, etc.), that can be added to the DynamicList
* due to not received VerseVerts */
unsigned int counter; /* counter of sent items */
/* client dependent methods */
void (*post_layer_create)(struct VLayer *vlayer);
void (*post_layer_destroy)(struct VLayer *vlayer);
} VLayer;
/*
* verse data: link
*/
typedef struct VLink{
struct VLink *next, *prev;
/* verse data */
struct VerseSession *session; /* session pointer */
struct VNode *source; /* object VerseNode "pointing" at some other VerseNode */
struct VNode *target; /* VerseNode linked with some object node */
unsigned int id; /* id of VerseLink */
unsigned int target_id; /* some unknow id */
char *label; /* name/label of VerseLink */
/* blender internals */
char flag; /* flags: LINK_SEND_READY */
/* client dependent methods */
void (*post_link_set)(struct VLink *vlink);
void (*post_link_destroy)(struct VLink *vlink);
} VLink;
/*
* bitmap layer
*/
typedef struct VBitmapLayer {
struct VBitmapLayer *next, *prev;
/* verse data */
struct VNode *vnode; /* pointer at Verse Node */
VLayerID id; /* id of layer */
char *name; /* name of layer */
VNBLayerType type; /* type of layer (bits per channel) 1, 8, 16, 32, 64 */
void *data; /* dynamic allocated data */
/* blender internals */
char flag;
} VBitmapLayer;
/*
* data of bitmap node
*/
typedef struct VBitmapData {
struct DynamicList layers; /* dynamic list with access array of bitmap layers */
struct ListBase queue; /* queue of layers waiting for receiving from verse server */
uint16 width; /* width of all verse layers */
uint16 height; /* height of all verse layers */
uint16 depth; /* depth of bitmap 1 is 2D bitmap, >1 is 3D bitmap */
/* blender internals */
uint16 t_width; /* = (width/VN_B_TILE_SIZE + 1)*VN_B_TILE_SIZE */
uint16 t_height; /* = (height/VN_B_TILE_SIZE + 1)*VN_B_TILE_SIZE */
void *image; /* pointer at image */
/* client dependent methods */
void (*post_bitmap_dimension_set)(struct VNode *vnode);
void (*post_bitmap_layer_create)(struct VBitmapLayer *vblayer);
void (*post_bitmap_layer_destroy)(struct VBitmapLayer *vblayer);
void (*post_bitmap_tile_set)(struct VBitmapLayer *vblayer, unsigned int xs, unsigned int ys);
}VBitmapData;
/*
* data of geometry node
*/
typedef struct VGeomData {
struct DynamicList layers; /* dynamic list with access array of Layers */
struct VLink *vlink; /* pointer at VerseLink connecting object node and geom node */
struct ListBase queue; /* queue of our layers waiting for receiving from verse server */
void *mesh; /* pointer at Mesh (object node) */
void *editmesh; /* pointer at EditMesh (edit mode) */
struct HashVerseEdge *hash; /* verse edge hash */
struct ListBase edges; /* list of fake verse edges */
/* client dependent methods */
void (*post_vertex_create)(struct VerseVert *vvert);
void (*post_vertex_set_xyz)(struct VerseVert *vvert);
void (*post_vertex_delete)(struct VerseVert *vvert);
void (*post_vertex_free_constraint)(struct VerseVert *vvert);
void (*post_polygon_create)(struct VerseFace *vface);
void (*post_polygon_set_corner)(struct VerseFace *vface);
void (*post_polygon_delete)(struct VerseFace *vface);
void (*post_polygon_free_constraint)(struct VerseFace *vface);
void (*post_geometry_free_constraint)(struct VNode *vnode);
void (*post_polygon_set_uint8)(struct VerseFace *vface);
} VGeomData;
/*
* data of object node
*/
typedef struct VObjectData {
struct DynamicList links; /* dynamic list with access array of links between other nodes */
struct ListBase queue; /* queue of links waiting for sending and receiving from verse server */
float pos[3]; /* position of object VerseNode */
float quat[4]; /* rotation of object VerseNode stored in quat */
float scale[3]; /* scale of object VerseNode */
void *object; /* pointer at object */
short flag; /* flag: POS_RECEIVE_READY, ROT_RECEIVE_READY. SCALE_RECEIVE_READY */
/* client dependent methods */
/* void (*post_transform)(struct VNode *vnode);*/
void (*post_transform_pos)(struct VNode *vnode);
void (*post_transform_rot)(struct VNode *vnode);
void (*post_transform_scale)(struct VNode *vnode);
void (*post_object_free_constraint)(struct VNode *vnode);
} VObjectData;
/*
* Verse Tag
*/
typedef struct VTag {
struct VTag *next, *prev;
/* verse data*/
struct VTagGroup *vtaggroup; /* pointer at Verse Tag Group */
uint16 id; /* id of this tag */
char *name; /* name of this tag*/
VNTagType type; /* type: VN_TAG_BOOLEAN, VN_TAG_UINT32, VN_TAG_REAL64, VN_TAG_REAL64_VEC3,
VN_TAG_LINK, VN_TAG_ANIMATION, VN_TAG_BLOB */
VNTag *tag; /* pointer at value (enum: vboolean, vuint32, vreal64, vstring,
vreal64_vec3, vlink, vanimation, vblob)*/
/* blender internals */
void *value; /* pointer at blender value */
} VTag;
/*
* Verse Tag Group (verse tags are grouped in tag groups)
*/
typedef struct VTagGroup {
struct VTagGroup *next, *prev;
/* verse data*/
struct VNode *vnode; /* pointer at Verse Node */
uint16 id; /* id of this tag group */
char *name; /* name of this tag group */
/* blender internals */
struct DynamicList tags; /* dynamic list with access array containing tags */
struct ListBase queue; /* list of tags waiting for receiving from verse server */
/* client dependent methods */
void (*post_tag_change)(struct VTag *vatg);
void (*post_taggroup_create)(struct VTagGroup *vtaggroup);
} VTagGroup;
/*
* Verse Method Group
*/
typedef struct VMethodGroup
{
struct VMethodGroup *next, *prev;
uint16 group_id;
char name[16];
struct ListBase methods;
} VMethodGroup;
/*
* Verse Method
*/
typedef struct VMethod
{
struct VMethod *next, *prev;
uint16 id;
char name[500];
uint8 param_count;
VNOParamType *param_type;
char **param_name;
} VMethod;
/*
* Verse Node
*/
typedef struct VNode {
struct VNode *next, *prev;
/* verse data*/
struct VerseSession *session; /* session pointer */
VNodeID id; /* node id */
VNodeID owner_id; /* owner's id of this node */
char *name; /* name of this node */
uint32 type; /* type of node (V_NT_OBJECT, V_NT_GEOMETRY, V_NT_BITMAP) */
/* blender internals */
char flag; /* flags: NODE_SENT, NODE_RECEIVED, NODE_DELTED, NODE_OBSOLETE */
struct DynamicList taggroups; /* dynamic list with access array of taggroups */
struct ListBase methodgroups; /* method groups */
struct ListBase queue; /* list of taggroups waiting for receiving from verse server */
void *data; /* generic pointer at some data (VObjectData, VGeomData, ...) */
int counter; /* counter of verse link pointing at this vnode (vlink->target) */
/* client dependent methods */
void (*post_node_create)(struct VNode *vnode);
void (*post_node_destroy)(struct VNode *vnode);
void (*post_node_name_set)(struct VNode *vnode);
#ifdef VERSECHAT
/* verse chat */
int chat_flag; /* CHAT_LOGGED, CHAT_NOTLOGGED */
#endif
} VNode;
/*
* Verse Session: verse client can be connected to several verse servers
* it is neccessary to store some information about each session
*/
typedef struct VerseSession {
struct VerseSession *next, *prev;
/* verse data */
VSession *vsession; /* pointer at VSeesion (verse.h) */
uint32 avatar; /* id of avatar */
char *address; /* string containg IP/domain name of verse server and number of port */
void *connection; /* no clue */
uint8 *host_id; /* no clue */
/* blender internals */
short flag; /* flag: VERSE_CONNECTING, VERSE_CONNECTED */
DynamicList nodes; /* list of verse nodes */
ListBase queue; /* list of nodes waiting for sending to verse server */
unsigned int counter; /* count of events, when connection wasn't accepted */
/* client dependent methods */
void (*post_connect_accept)(struct VerseSession *session);
void (*post_connect_terminated)(struct VerseSession *session);
void (*post_connect_update)(struct VerseSession *session);
} VerseSession;
typedef struct VerseServer {
struct VerseServer *next, *prev;
char *name; /* human-readable server name */
char *ip; /* string containing IP/domain name of verse server and number of port */
short flag; /* flag: VERSE_CONNECTING, VERSE_CONNECTED */
struct VerseSession *session; /* pointer to related session */
} VerseServer;
/*
* list of post callback functions
*/
typedef struct PostCallbackFunction {
void (*function)(void *arg);
void *param;
} PostCallbackFunction;
/* VerseSession->flag */
#define VERSE_CONNECTING 1
#define VERSE_CONNECTED 2
#define VERSE_AUTOSUBSCRIBE 4
/* max VerseSession->counter value */
#define MAX_UNCONNECTED_EVENTS 100
/* VNode flags */
#define NODE_SENT 1
#define NODE_RECEIVED 2
#define NODE_DELTED 4
#define NODE_OBSOLETE 8
#ifdef VERSECHAT
#define CHAT_NOTLOGGED 0
#define CHAT_LOGGED 1
#endif
/* VLayer flags */
#define LAYER_SENT 1
#define LAYER_RECEIVED 2
#define LAYER_DELETED 4
#define LAYER_OBSOLETE 8
/* VLink->flag */
#define LINK_SEND_READY 1
/* VObjectData->flag */
#define POS_RECEIVE_READY 1
#define ROT_RECEIVE_READY 2
#define SCALE_RECEIVE_READY 4
#define POS_SEND_READY 8
#define ROT_SEND_READY 16
#define SCALE_SEND_READY 32
/* VLayer->content */
#define VERTEX_LAYER 0
#define POLYGON_LAYER 1
/* VerseVert->flag */
#define VERT_DELETED 1 /* vertex delete command was received from verse server */
#define VERT_RECEIVED 2 /* VerseVert was received from verse server (is not in sending queue) */
#define VERT_LOCKED 4 /* VerseVert is ready to send local position to verse server */
#define VERT_POS_OBSOLETE 8 /* position of vertex was changed during sending to verse server */
#define VERT_OBSOLETE 16 /* vertex delete command was sent to verse server; it means, that
* no information related to this vertex shoudln't be sent to verse
* until verse vertex is completely deleted ... then this vertex id
* can be reused again for new vertex */
/* VerseFace->flag */
#define FACE_SEND_READY 1 /* VerseFace is ready for sending to verse server */
#define FACE_RECEIVED 2 /* VerseFace was received from verse server */
#define FACE_SENT 4 /* VerseFace was sent to verse server and we expect receiving from verse server */
#define FACE_DELETED 8 /* delete command was sent to verse server */
#define FACE_CHANGED 16 /* VerseFace was only changed not created */
#define FACE_OBSOLETE 32 /* VerseFace was changed during sending to verse server */
/* Queue type */
#define VERSE_NODE 1
#define VERSE_LINK 2
#define VERSE_LAYER 3
#define VERSE_VERT 4
#define VERSE_FACE 5
#define VERSE_TAG 6
#define VERSE_TAG_GROUP 7
#define VERSE_VERT_UINT32 8
#define VERSE_VERT_REAL32 9
#define VERSE_VERT_VEC_REAL32 10
#define VERSE_FACE_UINT8 11
#define VERSE_FACE_UINT32 12
#define VERSE_FACE_REAL32 13
#define VERSE_FACE_QUAT_UINT32 14
#define VERSE_FACE_QUAT_REAL32 15
/* Verse Bitmap Layer flags */
#define VBLAYER_SUBSCRIBED 1
/* function prototypes */
/* functions from verse_session.c */
void set_verse_session_callbacks(void);
struct VerseSession *versesession_from_vsession(VSession *vsession);
struct VerseSession *current_verse_session(void);
struct VerseSession *create_verse_session(const char *name, const char *pass, const char *address, uint8 *expected_key);
void free_verse_session(struct VerseSession *session);
void b_verse_update(void);
void b_verse_ms_get(void);
void b_verse_connect(char *address);
void end_verse_session(struct VerseSession *session);
void end_all_verse_sessions(void);
/* functions from verse_node.c */
void send_verse_tag(struct VTag *vtag);
void send_verse_taggroup(struct VTagGroup *vtaggroup);
void send_verse_node(struct VNode *vnode);
void free_verse_node_data(struct VNode *vnode);
void free_verse_node(struct VNode *vnode);
struct VNode* lookup_vnode(VerseSession *session, VNodeID node_id);
struct VNode* create_verse_node(VerseSession *session, VNodeID node_id, uint8 type, VNodeID owner_id);
void set_node_callbacks(void);
/* functions from verse_object_node.c */
struct VLink *find_unsent_parent_vlink(struct VerseSession *session, struct VNode *vnode);
struct VLink *find_unsent_child_vlink(struct VerseSession *session, struct VNode *vnode);
struct VLink *create_verse_link(VerseSession *session, struct VNode *source, struct VNode *target, uint16 link_id, uint32 target_id, const char *label);
void send_verse_object_position(struct VNode *vnode);
void send_verse_object_rotation(struct VNode *vnode);
void send_verse_object_scale(struct VNode *vnode);
void send_verse_link(struct VLink *vlink);
void free_object_data(struct VNode *vnode);
void set_object_callbacks(void);
struct VObjectData *create_object_data(void);
/* functions from verse_method.c */
void free_verse_methodgroup(VMethodGroup *vmg);
#ifdef VERSECHAT
void send_say(const char *chan, const char *utter);
void send_login(struct VNode *vnode);
void send_logout(struct VNode *vnode);
void send_join(struct VNode *vnode, const char *chan);
void send_leave(struct VNode *vnode, const char *chan);
#endif
void set_method_callbacks(void);
/* functions from verse_geometry_node.c */
struct VerseFace* create_verse_face(struct VLayer *vlayer, uint32 polygon_id, uint32 v0, uint32 v1, uint32 v2, uint32 v3);
struct VerseVert* create_verse_vertex(struct VLayer *vlayer, uint32 vertex_id, real32 x, real32 y, real32 z);
struct VLayer *create_verse_layer(struct VNode *vnode, VLayerID layer_id, const char *name, VNGLayerType type, uint32 def_integer, real64 def_real);
struct VGeomData *create_geometry_data(void);
void send_verse_layer(struct VLayer *vlayer);
void send_verse_face_corner_quat_real32(struct quat_real32_item *item, short type);
void send_verse_face_corner_quat_uint32(struct quat_uint32_item *item, short type);
void send_verse_face_real32(struct real32_item *item, short type);
void send_verse_face_uint32(struct uint32_item *item, short type);
void send_verse_face_uint8(struct uint8_item *item, short type);
void send_verse_vert_vec_real32(struct vec_real32_item *item, short type);
void send_verse_vert_real32(struct real32_item *item, short type);
void send_verse_vert_uint32(struct uint32_item *item, short type);
void send_verse_vertex_delete(struct VerseVert *vvert);
void send_verse_vertex(struct VerseVert *vvert);
void send_verse_face_delete(struct VerseFace *vface);
void destroy_geometry(struct VNode *vnode);
struct VLayer* find_verse_layer_type(struct VGeomData *geom, short content);
void add_item_to_send_queue(struct ListBase *lb, void *item, short type);
void free_geom_data(struct VNode *vnode);
void set_geometry_callbacks(void);
/* functions prototypes from verse_bitmap.c */
void set_bitmap_callbacks(void);
void free_bitmap_layer_data(struct VBitmapLayer *vblayer);
struct VBitmapLayer *create_bitmap_layer(struct VNode *vnode, VLayerID layer_id, const char *name, VNBLayerType type);
void free_bitmap_node_data(struct VNode *vnode);
struct VBitmapData *create_bitmap_data(void);
#endif

@ -37,11 +37,6 @@ SET(INC
${ZLIB_INC}
)
IF(WITH_VERSE)
ADD_DEFINITIONS(-DWITH_VERSE)
SET(INC ${INC} ${VERSE_INC})
ENDIF(WITH_VERSE)
IF(WITH_OPENEXR)
ADD_DEFINITIONS(-DWITH_OPENEXR)
ENDIF(WITH_OPENEXR)
@ -72,10 +67,6 @@ ENDIF(WITH_PYTHON)
BLENDERLIB(bf_blenkernel "${SRC}" "${INC}")
IF(WITH_VERSE)
ADD_DEPENDENCIES(bf_blenkernel mkprot verse)
ENDIF(WITH_VERSE)
IF(WITH_INTERNATIONAL)
ADD_DEFINITIONS(-DWITH_FREETYPE2)
ENDIF(WITH_INTERNATIONAL)

@ -31,13 +31,6 @@ if env['WITH_BF_SDL']:
if env['WITH_BF_INTERNATIONAL']:
defs += ' WITH_FREETYPE2'
if env['WITH_BF_VERSE']:
defs += ' WITH_VERSE'
incs += ' ' + env['BF_VERSE_INCLUDE']
if env['WITH_BF_VERSE']:
defs += ' WITH_VERSE'
if env['WITH_BF_OPENEXR']:
defs += ' WITH_OPENEXR'

@ -80,10 +80,6 @@
#include "BLO_sys_types.h" // for intptr_t support
#ifdef WITH_VERSE
#include "BKE_verse.h"
#endif
#include "BIF_gl.h"
#include "BIF_glutil.h"
@ -1388,573 +1384,6 @@ static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, Object *ob,
return (DerivedMesh*) emdm;
}
#ifdef WITH_VERSE
/* verse derived mesh */
typedef struct {
struct DerivedMesh dm;
struct VNode *vnode;
struct VLayer *vertex_layer;
struct VLayer *polygon_layer;
struct ListBase *edges;
float (*vertexCos)[3];
} VDerivedMesh;
/* this function set up border points of verse mesh bounding box */
static void vDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseVert *vvert;
if(!vdm->vertex_layer) return;
vvert = (VerseVert*)vdm->vertex_layer->dl.lb.first;
if(vdm->vertex_layer->dl.da.count > 0) {
while(vvert) {
DO_MINMAX(vdm->vertexCos ? vvert->cos : vvert->co, min_r, max_r);
vvert = vvert->next;
}
}
else {
min_r[0] = min_r[1] = min_r[2] = max_r[0] = max_r[1] = max_r[2] = 0.0;
}
}
/* this function return number of vertexes in vertex layer */
static int vDM_getNumVerts(DerivedMesh *dm)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
if(!vdm->vertex_layer) return 0;
else return vdm->vertex_layer->dl.da.count;
}
/* this function return number of 'fake' edges */
static int vDM_getNumEdges(DerivedMesh *dm)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
return BLI_countlist(vdm->edges);
}
/* this function returns number of polygons in polygon layer */
static int vDM_getNumFaces(DerivedMesh *dm)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
if(!vdm->polygon_layer) return 0;
else return vdm->polygon_layer->dl.da.count;
}
/* this function doesn't return vertex with index of access array,
* but it return 'indexth' vertex of dynamic list */
void vDM_getVert(DerivedMesh *dm, int index, MVert *vert_r)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseVert *vvert;
int i;
if(!vdm->vertex_layer) return;
for(vvert = vdm->vertex_layer->dl.lb.first, i=0 ; i<index; i++) vvert = vvert->next;
if(vvert) {
VECCOPY(vert_r->co, vvert->co);
vert_r->no[0] = vvert->no[0] * 32767.0;
vert_r->no[1] = vvert->no[1] * 32767.0;
vert_r->no[2] = vvert->no[2] * 32767.0;
/* TODO what to do with vert_r->flag and vert_r->mat_nr? */
vert_r->mat_nr = 0;
vert_r->flag = 0;
}
}
/* this function returns fake verse edge */
void vDM_getEdge(DerivedMesh *dm, int index, MEdge *edge_r)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseEdge *vedge;
struct VLayer *vert_vlayer = vdm->vertex_layer;
struct VerseVert *vvert;
int j;
if(!vdm->vertex_layer || !vdm->edges) return;
if(vdm->edges->first) {
struct VerseVert *vvert1, *vvert2;
/* store vert indices in tmp union */
for(vvert = vdm->vertex_layer->dl.lb.first, j = 0; vvert; vvert = vvert->next, j++)
vvert->tmp.index = j;
for(vedge = vdm->edges->first; vedge; vedge = vedge->next) {
if(vedge->tmp.index==index) {
vvert1 = BLI_dlist_find_link(&(vert_vlayer->dl), (unsigned int)vedge->v0);
vvert2 = BLI_dlist_find_link(&(vert_vlayer->dl), (unsigned int)vedge->v1);
if(vvert1 && vvert2) {
edge_r->v1 = vvert1->tmp.index;
edge_r->v2 = vvert2->tmp.index;
}
else {
edge_r->v1 = 0;
edge_r->v2 = 0;
}
/* not supported yet */
edge_r->flag = 0;
edge_r->crease = 0;
edge_r->bweight = 0;
break;
}
}
}
}
/* this function doesn't return face with index of access array,
* but it returns 'indexth' vertex of dynamic list */
void vDM_getFace(DerivedMesh *dm, int index, MFace *face_r)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseFace *vface;
struct VerseVert *vvert;
struct VerseVert *vvert0, *vvert1, *vvert2, *vvert3;
int i;
if(!vdm->vertex_layer || !vdm->polygon_layer) return;
for(vface = vdm->polygon_layer->dl.lb.first, i = 0; i < index; ++i) vface = vface->next;
face_r->mat_nr = 0;
face_r->flag = 0;
/* goddamn, we have to search all verts to find indices */
vvert0 = vface->vvert0;
vvert1 = vface->vvert1;
vvert2 = vface->vvert2;
vvert3 = vface->vvert3;
if(!vvert3) face_r->v4 = 0;
for(vvert = vdm->vertex_layer->dl.lb.first, i = 0; vvert0 || vvert1 || vvert2 || vvert3; i++, vvert = vvert->next) {
if(vvert == vvert0) {
face_r->v1 = i;
vvert0 = NULL;
}
if(vvert == vvert1) {
face_r->v2 = i;
vvert1 = NULL;
}
if(vvert == vvert2) {
face_r->v3 = i;
vvert2 = NULL;
}
if(vvert == vvert3) {
face_r->v4 = i;
vvert3 = NULL;
}
}
test_index_face(face_r, NULL, 0, vface->vvert3?4:3);
}
/* fill array of mvert */
void vDM_copyVertArray(DerivedMesh *dm, MVert *vert_r)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseVert *vvert;
if(!vdm->vertex_layer) return;
for(vvert = vdm->vertex_layer->dl.lb.first ; vvert; vvert = vvert->next, ++vert_r) {
VECCOPY(vert_r->co, vvert->co);
vert_r->no[0] = vvert->no[0] * 32767.0;
vert_r->no[1] = vvert->no[1] * 32767.0;
vert_r->no[2] = vvert->no[2] * 32767.0;
vert_r->mat_nr = 0;
vert_r->flag = 0;
}
}
/* dummy function, edges arent supported in verse mesh */
void vDM_copyEdgeArray(DerivedMesh *dm, MEdge *edge_r)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
if(!vdm->vertex_layer || !vdm->edges) return;
if(vdm->edges->first) {
struct VerseEdge *vedge;
struct VLayer *vert_vlayer = vdm->vertex_layer;
struct VerseVert *vvert, *vvert1, *vvert2;
int j;
/* store vert indices in tmp union */
for(vvert = vdm->vertex_layer->dl.lb.first, j = 0; vvert; vvert = vvert->next, ++j)
vvert->tmp.index = j;
for(vedge = vdm->edges->first, j=0 ; vedge; vedge = vedge->next, ++edge_r, j++) {
/* create temporary edge index */
vedge->tmp.index = j;
vvert1 = BLI_dlist_find_link(&(vert_vlayer->dl), (unsigned int)vedge->v0);
vvert2 = BLI_dlist_find_link(&(vert_vlayer->dl), (unsigned int)vedge->v1);
if(vvert1 && vvert2) {
edge_r->v1 = vvert1->tmp.index;
edge_r->v2 = vvert2->tmp.index;
}
else {
printf("error: vDM_copyEdgeArray: %d, %d\n", vedge->v0, vedge->v1);
edge_r->v1 = 0;
edge_r->v2 = 0;
}
/* not supported yet */
edge_r->flag = 0;
edge_r->crease = 0;
edge_r->bweight = 0;
}
}
}
/* fill array of mfaces */
void vDM_copyFaceArray(DerivedMesh *dm, MFace *face_r)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseFace *vface;
struct VerseVert *vvert;
int i;
if(!vdm->vertex_layer || !vdm->polygon_layer) return;
/* store vertexes indices in tmp union */
for(vvert = vdm->vertex_layer->dl.lb.first, i = 0; vvert; vvert = vvert->next, ++i)
vvert->tmp.index = i;
for(vface = vdm->polygon_layer->dl.lb.first; vface; vface = vface->next, ++face_r) {
face_r->mat_nr = 0;
face_r->flag = 0;
face_r->v1 = vface->vvert0->tmp.index;
face_r->v2 = vface->vvert1->tmp.index;
face_r->v3 = vface->vvert2->tmp.index;
if(vface->vvert3) face_r->v4 = vface->vvert3->tmp.index;
else face_r->v4 = 0;
test_index_face(face_r, NULL, 0, vface->vvert3?4:3);
}
}
/* return coordination of vertex with index */
static void vDM_getVertCo(DerivedMesh *dm, int index, float co_r[3])
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseVert *vvert = NULL;
if(!vdm->vertex_layer) return;
vvert = BLI_dlist_find_link(&(vdm->vertex_layer->dl), index);
if(vvert) {
VECCOPY(co_r, vdm->vertexCos ? vvert->cos : vvert->co);
}
else {
co_r[0] = co_r[1] = co_r[2] = 0.0;
}
}
/* return array of vertex coordiantions */
static void vDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3])
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseVert *vvert;
int i = 0;
if(!vdm->vertex_layer) return;
vvert = vdm->vertex_layer->dl.lb.first;
while(vvert) {
VECCOPY(cos_r[i], vdm->vertexCos ? vvert->cos : vvert->co);
i++;
vvert = vvert->next;
}
}
/* return normal of vertex with index */
static void vDM_getVertNo(DerivedMesh *dm, int index, float no_r[3])
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseVert *vvert = NULL;
if(!vdm->vertex_layer) return;
vvert = BLI_dlist_find_link(&(vdm->vertex_layer->dl), index);
if(vvert) {
VECCOPY(no_r, vvert->no);
}
else {
no_r[0] = no_r[1] = no_r[2] = 0.0;
}
}
/* draw all VerseVertexes */
static void vDM_drawVerts(DerivedMesh *dm)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseVert *vvert;
if(!vdm->vertex_layer) return;
vvert = vdm->vertex_layer->dl.lb.first;
//XXX bglBegin(GL_POINTS);
while(vvert) {
//XXX bglVertex3fv(vdm->vertexCos ? vvert->cos : vvert->co);
vvert = vvert->next;
}
//XXX bglEnd();
}
/* draw all edges of VerseFaces ... it isn't optimal, because verse
* specification doesn't support edges :-( ... bother eskil ;-)
* ... some edges (most of edges) are drawn twice */
static void vDM_drawEdges(DerivedMesh *dm, int drawLooseEdges)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseEdge *vedge;
struct VLayer *vert_vlayer = vdm->vertex_layer;
if(vert_vlayer && vdm->edges && (BLI_countlist(vdm->edges) > 0)) {
struct VerseVert *vvert1, *vvert2;
glBegin(GL_LINES);
for(vedge = vdm->edges->first; vedge; vedge = vedge->next) {
vvert1 = BLI_dlist_find_link(&(vert_vlayer->dl), (unsigned int)vedge->v0);
vvert2 = BLI_dlist_find_link(&(vert_vlayer->dl), (unsigned int)vedge->v1);
if(vvert1 && vvert2) {
glVertex3fv(vdm->vertexCos ? vvert1->cos : vvert1->co);
glVertex3fv(vdm->vertexCos ? vvert2->cos : vvert2->co);
}
}
glEnd();
}
}
/* verse spec doesn't support edges ... loose edges can't exist */
void vDM_drawLooseEdges(DerivedMesh *dm)
{
}
/* draw uv edges, not supported yet */
static void vDM_drawUVEdges(DerivedMesh *dm)
{
}
/* draw all VerseFaces */
static void vDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int, void *attribs))
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseFace *vface;
if(!vdm->polygon_layer) return;
vface = vdm->polygon_layer->dl.lb.first;
glShadeModel(GL_FLAT);
while(vface) {
glBegin(vface->vvert3?GL_QUADS:GL_TRIANGLES);
glNormal3fv(vface->no);
glVertex3fv(vdm->vertexCos ? vface->vvert0->cos : vface->vvert0->co);
glVertex3fv(vdm->vertexCos ? vface->vvert1->cos : vface->vvert1->co);
glVertex3fv(vdm->vertexCos ? vface->vvert2->cos : vface->vvert2->co);
if(vface->vvert3)
glVertex3fv(vdm->vertexCos ? vface->vvert3->cos : vface->vvert3->co);
glEnd();
vface = vface->next;
}
}
/* this function should draw mesh with mapped texture, but it isn't supported yet */
static void vDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tface, MCol *mcol, int matnr))
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseFace *vface;
if(!vdm->polygon_layer) return;
vface = vdm->polygon_layer->dl.lb.first;
while(vface) {
glBegin(vface->vvert3?GL_QUADS:GL_TRIANGLES);
glVertex3fv(vdm->vertexCos ? vface->vvert0->cos : vface->vvert0->co);
glVertex3fv(vdm->vertexCos ? vface->vvert1->cos : vface->vvert1->co);
glVertex3fv(vdm->vertexCos ? vface->vvert2->cos : vface->vvert2->co);
if(vface->vvert3)
glVertex3fv(vdm->vertexCos ? vface->vvert3->cos : vface->vvert3->co);
glEnd();
vface = vface->next;
}
}
/* this function should draw mesh with colored faces (weight paint, vertex
* colors, etc.), but it isn't supported yet */
static void vDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned char *col1, unsigned char *col2)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
struct VerseFace *vface;
if(!vdm->polygon_layer) return;
vface = vdm->polygon_layer->dl.lb.first;
while(vface) {
glBegin(vface->vvert3?GL_QUADS:GL_TRIANGLES);
glVertex3fv(vdm->vertexCos ? vface->vvert0->cos : vface->vvert0->co);
glVertex3fv(vdm->vertexCos ? vface->vvert1->cos : vface->vvert1->co);
glVertex3fv(vdm->vertexCos ? vface->vvert2->cos : vface->vvert2->co);
if(vface->vvert3)
glVertex3fv(vdm->vertexCos ? vface->vvert3->cos : vface->vvert3->co);
glEnd();
vface = vface->next;
}
}
/**/
static void vDM_foreachMappedVert(
DerivedMesh *dm,
void (*func)(void *userData, int index, float *co, float *no_f, short *no_s),
void *userData)
{
}
/**/
static void vDM_foreachMappedEdge(
DerivedMesh *dm,
void (*func)(void *userData, int index, float *v0co, float *v1co),
void *userData)
{
}
/**/
static void vDM_foreachMappedFaceCenter(
DerivedMesh *dm,
void (*func)(void *userData, int index, float *cent, float *no),
void *userData)
{
}
/**/
static void vDM_drawMappedFacesTex(
DerivedMesh *dm,
int (*setDrawParams)(void *userData, int index),
void *userData)
{
/* not supported yet */
vDM_drawFacesTex(dm, NULL);
}
/**/
static void vDM_drawMappedFaces(
DerivedMesh *dm,
int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r),
void *userData,
int useColors)
{
}
/**/
static void vDM_drawMappedEdges(
DerivedMesh *dm,
int (*setDrawOptions)(void *userData, int index),
void *userData)
{
}
/**/
static void vDM_drawMappedEdgesInterp(
DerivedMesh *dm,
int (*setDrawOptions)(void *userData, int index),
void (*setDrawInterpOptions)(void *userData, int index, float t),
void *userData)
{
}
/* free all DerivedMesh data */
static void vDM_release(DerivedMesh *dm)
{
VDerivedMesh *vdm = (VDerivedMesh*)dm;
if (DM_release(dm)) {
if(vdm->vertexCos) MEM_freeN(vdm->vertexCos);
MEM_freeN(vdm);
}
}
/* create derived mesh from verse mesh ... it is used in object mode, when some other client can
* change shared data and want to see this changes in real time too */
DerivedMesh *derivedmesh_from_versemesh(VNode *vnode, float (*vertexCos)[3])
{
VDerivedMesh *vdm = MEM_callocN(sizeof(*vdm), "vdm");
vdm->vnode = vnode;
vdm->vertex_layer = find_verse_layer_type((VGeomData*)vnode->data, VERTEX_LAYER);
vdm->polygon_layer = find_verse_layer_type((VGeomData*)vnode->data, POLYGON_LAYER);
vdm->edges = &((VGeomData*)vnode->data)->edges;
/* vertex and polygon layer has to exist */
if(vdm->vertex_layer && vdm->polygon_layer)
DM_init(&vdm->dm, vdm->vertex_layer->dl.da.count, BLI_countlist(vdm->edges), vdm->polygon_layer->dl.da.count);
else
DM_init(&vdm->dm, 0, 0, 0);
vdm->dm.getMinMax = vDM_getMinMax;
vdm->dm.getNumVerts = vDM_getNumVerts;
vdm->dm.getNumEdges = vDM_getNumEdges;
vdm->dm.getNumFaces = vDM_getNumFaces;
vdm->dm.getVert = vDM_getVert;
vdm->dm.getEdge = vDM_getEdge;
vdm->dm.getFace = vDM_getFace;
vdm->dm.copyVertArray = vDM_copyVertArray;
vdm->dm.copyEdgeArray = vDM_copyEdgeArray;
vdm->dm.copyFaceArray = vDM_copyFaceArray;
vdm->dm.foreachMappedVert = vDM_foreachMappedVert;
vdm->dm.foreachMappedEdge = vDM_foreachMappedEdge;
vdm->dm.foreachMappedFaceCenter = vDM_foreachMappedFaceCenter;
vdm->dm.getVertCos = vDM_getVertCos;
vdm->dm.getVertCo = vDM_getVertCo;
vdm->dm.getVertNo = vDM_getVertNo;
vdm->dm.drawVerts = vDM_drawVerts;
vdm->dm.drawEdges = vDM_drawEdges;
vdm->dm.drawLooseEdges = vDM_drawLooseEdges;
vdm->dm.drawUVEdges = vDM_drawUVEdges;
vdm->dm.drawFacesSolid = vDM_drawFacesSolid;
vdm->dm.drawFacesTex = vDM_drawFacesTex;
vdm->dm.drawFacesColored = vDM_drawFacesColored;
vdm->dm.drawMappedFacesTex = vDM_drawMappedFacesTex;
vdm->dm.drawMappedFaces = vDM_drawMappedFaces;
vdm->dm.drawMappedEdges = vDM_drawMappedEdges;
vdm->dm.drawMappedEdgesInterp = vDM_drawMappedEdgesInterp;
vdm->dm.release = vDM_release;
vdm->vertexCos = vertexCos;
return (DerivedMesh*) vdm;
}
#endif
/***/
DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, ModifierData *md)
@ -1973,12 +1402,7 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, Modifier
float (*deformedVerts)[3] = mesh_getVertexCos(me, &numVerts);
mti->deformVerts(md, ob, NULL, deformedVerts, numVerts);
#ifdef WITH_VERSE
if(me->vnode) dm = derivedmesh_from_versemesh(me->vnode, deformedVerts);
else dm = getMeshDerivedMesh(me, ob, deformedVerts);
#else
dm = getMeshDerivedMesh(me, ob, deformedVerts);
#endif
MEM_freeN(deformedVerts);
} else {
@ -2163,22 +1587,11 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
* coordinates (vpaint, etc.)
*/
if (deform_r) {
#ifdef WITH_VERSE
if(me->vnode) *deform_r = derivedmesh_from_versemesh(me->vnode, deformedVerts);
else {
*deform_r = CDDM_from_mesh(me, ob);
if(deformedVerts) {
CDDM_apply_vert_coords(*deform_r, deformedVerts);
CDDM_calc_normals(*deform_r);
}
}
#else
*deform_r = CDDM_from_mesh(me, ob);
if(deformedVerts) {
CDDM_apply_vert_coords(*deform_r, deformedVerts);
CDDM_calc_normals(*deform_r);
}
#endif
}
} else {
/* default behaviour for meshes */
@ -2195,13 +1608,6 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
dm = NULL;
orcodm = NULL;
#ifdef WITH_VERSE
/* hack to make sure modifiers don't try to use mesh data from a verse
* node
*/
if(me->vnode) dm = derivedmesh_from_versemesh(me->vnode, deformedVerts);
#endif
for(;md; md = md->next, curr = curr->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@ -2333,23 +1739,11 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
} else if(dm) {
finaldm = dm;
} else {
#ifdef WITH_VERSE
if(me->vnode)
finaldm = derivedmesh_from_versemesh(me->vnode, deformedVerts);
else {
finaldm = CDDM_from_mesh(me, ob);
if(deformedVerts) {
CDDM_apply_vert_coords(finaldm, deformedVerts);
CDDM_calc_normals(finaldm);
}
}
#else
finaldm = CDDM_from_mesh(me, ob);
if(deformedVerts) {
CDDM_apply_vert_coords(finaldm, deformedVerts);
CDDM_calc_normals(finaldm);
}
#endif
}
/* add an orco layer if needed */

Some files were not shown because too many files have changed in this diff Show More