diff options
author | George Hazan <george.hazan@gmail.com> | 2015-03-15 15:30:03 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-03-15 15:30:03 +0000 |
commit | b81bd804e435e76592f9f281b717c696c3618fa2 (patch) | |
tree | 57c9295922457227265ba59e6f3f507ad038e194 /plugins/Dbx_kv/src/hamsterdb/src/2protobuf | |
parent | 641c67a9d552b07664308c2ae3384cc95a75a2d0 (diff) |
initial release
git-svn-id: http://svn.miranda-ng.org/main/trunk@12409 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_kv/src/hamsterdb/src/2protobuf')
4 files changed, 1246 insertions, 0 deletions
diff --git a/plugins/Dbx_kv/src/hamsterdb/src/2protobuf/Makefile.am b/plugins/Dbx_kv/src/hamsterdb/src/2protobuf/Makefile.am new file mode 100644 index 0000000000..b5c5c881f4 --- /dev/null +++ b/plugins/Dbx_kv/src/hamsterdb/src/2protobuf/Makefile.am @@ -0,0 +1,15 @@ + +AM_CPPFLAGS = -DHAM_ENABLE_REMOTE -I$(top_builddir)/include + +# INCLUDES = + +noinst_LTLIBRARIES = libprotocol.la + +nodist_libprotocol_la_SOURCES = messages.pb.cc +libprotocol_la_SOURCES = protocol.h +libprotocol_la_LIBADD = -lprotobuf + +EXTRA_DIST = messages.proto +messages.pb.cc proto: $(srcdir)/messages.proto + protoc $(srcdir)/messages.proto --cpp_out=. + diff --git a/plugins/Dbx_kv/src/hamsterdb/src/2protobuf/Makefile.in b/plugins/Dbx_kv/src/hamsterdb/src/2protobuf/Makefile.in new file mode 100644 index 0000000000..e198a11d7d --- /dev/null +++ b/plugins/Dbx_kv/src/hamsterdb/src/2protobuf/Makefile.in @@ -0,0 +1,627 @@ +# Makefile.in generated by automake 1.14.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/2protobuf +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/depcomp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/ax_cxx_gcc_abi_demangle.m4 \ + $(top_srcdir)/m4/boost.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libprotocol_la_DEPENDENCIES = +am_libprotocol_la_OBJECTS = +nodist_libprotocol_la_OBJECTS = messages.pb.lo +libprotocol_la_OBJECTS = $(am_libprotocol_la_OBJECTS) \ + $(nodist_libprotocol_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libprotocol_la_SOURCES) $(nodist_libprotocol_la_SOURCES) +DIST_SOURCES = $(libprotocol_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BOOST_CHRONO_LDFLAGS = @BOOST_CHRONO_LDFLAGS@ +BOOST_CHRONO_LDPATH = @BOOST_CHRONO_LDPATH@ +BOOST_CHRONO_LIBS = @BOOST_CHRONO_LIBS@ +BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ +BOOST_FILESYSTEM_LDFLAGS = @BOOST_FILESYSTEM_LDFLAGS@ +BOOST_FILESYSTEM_LDPATH = @BOOST_FILESYSTEM_LDPATH@ +BOOST_FILESYSTEM_LIBS = @BOOST_FILESYSTEM_LIBS@ +BOOST_LDPATH = @BOOST_LDPATH@ +BOOST_ROOT = @BOOST_ROOT@ +BOOST_SYSTEM_LDFLAGS = @BOOST_SYSTEM_LDFLAGS@ +BOOST_SYSTEM_LDPATH = @BOOST_SYSTEM_LDPATH@ +BOOST_SYSTEM_LIBS = @BOOST_SYSTEM_LIBS@ +BOOST_THREAD_LDFLAGS = @BOOST_THREAD_LDFLAGS@ +BOOST_THREAD_LDPATH = @BOOST_THREAD_LDPATH@ +BOOST_THREAD_LIBS = @BOOST_THREAD_LIBS@ +BOOST_THREAD_WIN32_LDFLAGS = @BOOST_THREAD_WIN32_LDFLAGS@ +BOOST_THREAD_WIN32_LDPATH = @BOOST_THREAD_WIN32_LDPATH@ +BOOST_THREAD_WIN32_LIBS = @BOOST_THREAD_WIN32_LIBS@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +JDK_INCLUDE = @JDK_INCLUDE@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = -DHAM_ENABLE_REMOTE -I$(top_builddir)/include + +# INCLUDES = +noinst_LTLIBRARIES = libprotocol.la +nodist_libprotocol_la_SOURCES = messages.pb.cc +libprotocol_la_SOURCES = protocol.h +libprotocol_la_LIBADD = -lprotobuf +EXTRA_DIST = messages.proto +all: all-am + +.SUFFIXES: +.SUFFIXES: .cc .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/2protobuf/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/2protobuf/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libprotocol.la: $(libprotocol_la_OBJECTS) $(libprotocol_la_DEPENDENCIES) $(EXTRA_libprotocol_la_DEPENDENCIES) + $(AM_V_CXXLD)$(CXXLINK) $(libprotocol_la_OBJECTS) $(libprotocol_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/messages.pb.Plo@am__quote@ + +.cc.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cc.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cc.lo: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +messages.pb.cc proto: $(srcdir)/messages.proto + protoc $(srcdir)/messages.proto --cpp_out=. + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/plugins/Dbx_kv/src/hamsterdb/src/2protobuf/messages.proto b/plugins/Dbx_kv/src/hamsterdb/src/2protobuf/messages.proto new file mode 100644 index 0000000000..f8ec8fdcb6 --- /dev/null +++ b/plugins/Dbx_kv/src/hamsterdb/src/2protobuf/messages.proto @@ -0,0 +1,457 @@ + + +package hamsterdb; + +option optimize_for = LITE_RUNTIME; + +message ProtoWrapper { + enum Type { + CONNECT_REQUEST = 10; + CONNECT_REPLY = 11; + DISCONNECT_REQUEST = 12; + DISCONNECT_REPLY = 13; + ENV_RENAME_REQUEST = 20; + ENV_RENAME_REPLY = 21; + ENV_GET_PARAMETERS_REQUEST = 30; + ENV_GET_PARAMETERS_REPLY = 31; + ENV_GET_DATABASE_NAMES_REQUEST = 40; + ENV_GET_DATABASE_NAMES_REPLY = 41; + ENV_FLUSH_REQUEST = 50; + ENV_FLUSH_REPLY = 51; + ENV_CREATE_DB_REQUEST = 60; + ENV_CREATE_DB_REPLY = 61; + ENV_OPEN_DB_REQUEST = 70; + ENV_OPEN_DB_REPLY = 71; + ENV_ERASE_DB_REQUEST = 80; + ENV_ERASE_DB_REPLY = 81; + DB_CLOSE_REQUEST = 90; + DB_CLOSE_REPLY = 91; + DB_GET_PARAMETERS_REQUEST = 100; + DB_GET_PARAMETERS_REPLY = 101; + // DB_FLUSH_REQUEST = 110; + // DB_FLUSH_REPLY = 111; + TXN_BEGIN_REQUEST = 120; + TXN_BEGIN_REPLY = 121; + TXN_COMMIT_REQUEST = 130; + TXN_COMMIT_REPLY = 131; + TXN_ABORT_REQUEST = 140; + TXN_ABORT_REPLY = 141; + DB_CHECK_INTEGRITY_REQUEST = 150; + DB_CHECK_INTEGRITY_REPLY = 151; + DB_GET_KEY_COUNT_REQUEST = 160; + DB_GET_KEY_COUNT_REPLY = 161; + DB_INSERT_REQUEST = 170; + DB_INSERT_REPLY = 171; + DB_ERASE_REQUEST = 180; + DB_ERASE_REPLY = 181; + DB_FIND_REQUEST = 190; + DB_FIND_REPLY = 191; + CURSOR_CREATE_REQUEST = 200; + CURSOR_CREATE_REPLY = 201; + CURSOR_CLONE_REQUEST = 210; + CURSOR_CLONE_REPLY = 211; + CURSOR_CLOSE_REQUEST = 220; + CURSOR_CLOSE_REPLY = 221; + CURSOR_INSERT_REQUEST = 230; + CURSOR_INSERT_REPLY = 231; + CURSOR_ERASE_REQUEST = 240; + CURSOR_ERASE_REPLY = 241; + CURSOR_GET_RECORD_COUNT_REQUEST = 260; + CURSOR_GET_RECORD_COUNT_REPLY = 261; + CURSOR_GET_DUPLICATE_POSITION_REQUEST = 262; + CURSOR_GET_DUPLICATE_POSITION_REPLY = 263; + CURSOR_GET_RECORD_SIZE_REQUEST = 264; + CURSOR_GET_RECORD_SIZE_REPLY = 265; + CURSOR_OVERWRITE_REQUEST = 270; + CURSOR_OVERWRITE_REPLY = 271; + CURSOR_MOVE_REQUEST = 280; + CURSOR_MOVE_REPLY = 281; + } + + required Type type = 1; + + optional ConnectRequest connect_request = 10; + optional ConnectReply connect_reply = 11; + optional DisconnectRequest disconnect_request = 12; + optional DisconnectReply disconnect_reply = 13; + optional EnvRenameRequest env_rename_request = 20; + optional EnvRenameReply env_rename_reply = 21; + optional EnvGetParametersRequest env_get_parameters_request = 30; + optional EnvGetParametersReply env_get_parameters_reply = 31; + optional EnvGetDatabaseNamesRequest env_get_database_names_request = 40; + optional EnvGetDatabaseNamesReply env_get_database_names_reply = 41; + optional EnvFlushRequest env_flush_request = 50; + optional EnvFlushReply env_flush_reply = 51; + optional EnvCreateDbRequest env_create_db_request = 60; + optional EnvCreateDbReply env_create_db_reply = 61; + optional EnvOpenDbRequest env_open_db_request = 70; + optional EnvOpenDbReply env_open_db_reply = 71; + optional EnvEraseDbRequest env_erase_db_request = 80; + optional EnvEraseDbReply env_erase_db_reply = 81; + optional DbCloseRequest db_close_request = 90; + optional DbCloseReply db_close_reply = 91; + optional DbGetParametersRequest db_get_parameters_request = 100; + optional DbGetParametersReply db_get_parameters_reply = 101; + optional TxnBeginRequest txn_begin_request = 120; + optional TxnBeginReply txn_begin_reply = 121; + optional TxnCommitRequest txn_commit_request = 130; + optional TxnCommitReply txn_commit_reply = 131; + optional TxnAbortRequest txn_abort_request = 140; + optional TxnAbortReply txn_abort_reply = 141; + optional DbCheckIntegrityRequest db_check_integrity_request = 150; + optional DbCheckIntegrityReply db_check_integrity_reply = 151; + optional DbCountRequest db_count_request = 160; + optional DbCountReply db_count_reply = 161; + optional DbInsertRequest db_insert_request = 170; + optional DbInsertReply db_insert_reply = 171; + optional DbEraseRequest db_erase_request = 180; + optional DbEraseReply db_erase_reply = 181; + optional DbFindRequest db_find_request = 190; + optional DbFindReply db_find_reply = 191; + optional CursorCreateRequest cursor_create_request = 200; + optional CursorCreateReply cursor_create_reply = 201; + optional CursorCloneRequest cursor_clone_request = 210; + optional CursorCloneReply cursor_clone_reply = 211; + optional CursorCloseRequest cursor_close_request = 220; + optional CursorCloseReply cursor_close_reply = 221; + optional CursorInsertRequest cursor_insert_request = 230; + optional CursorInsertReply cursor_insert_reply = 231; + optional CursorEraseRequest cursor_erase_request = 240; + optional CursorEraseReply cursor_erase_reply = 241; + optional CursorGetRecordCountRequest cursor_get_record_count_request = 260; + optional CursorGetRecordCountReply cursor_get_record_count_reply = 261; + optional CursorGetDuplicatePositionRequest cursor_get_duplicate_position_request = 262; + optional CursorGetDuplicatePositionReply cursor_get_duplicate_position_reply = 263; + optional CursorGetRecordSizeRequest cursor_get_record_size_request = 264; + optional CursorGetRecordSizeReply cursor_get_record_size_reply = 265; + optional CursorOverwriteRequest cursor_overwrite_request = 270; + optional CursorOverwriteReply cursor_overwrite_reply = 271; + optional CursorMoveRequest cursor_move_request = 280; + optional CursorMoveReply cursor_move_reply = 281; +} + +message ConnectRequest { + required string path = 1; +} + +message ConnectReply { + required sint32 status = 1; + optional uint32 env_flags = 2; + optional uint64 env_handle = 3; +} + +message DisconnectRequest { + required uint64 env_handle = 1; +} + +message DisconnectReply { + required sint32 status = 1; +} + +message EnvGetParametersRequest { + required uint64 env_handle = 1; + repeated uint32 names = 2; +} + +message EnvGetParametersReply { + required sint32 status = 1; + optional uint32 cache_size = 2; + optional uint32 page_size = 3; + optional uint32 max_env_databases = 4; + optional uint32 flags = 5; + optional uint32 filemode = 6; + optional string filename = 7; +}; + +message EnvGetDatabaseNamesRequest { + required uint64 env_handle = 1; +} + +message EnvGetDatabaseNamesReply { + required sint32 status = 1; + repeated uint32 names = 2; +} + +message EnvRenameRequest { + required uint64 env_handle = 1; + required uint32 oldname = 2; + required uint32 newname = 3; + required uint32 flags = 4; +} + +message EnvRenameReply { + required sint32 status = 1; +}; + +message EnvFlushRequest { + required uint64 env_handle = 1; + required uint32 flags = 2; +} + +message EnvFlushReply { + required sint32 status = 1; +}; + +message EnvCreateDbRequest { + required uint64 env_handle = 1; + required uint32 dbname = 2; + required uint32 flags = 3; + repeated uint32 param_names = 4; + repeated uint64 param_values = 5; +} + +message EnvCreateDbReply { + required sint32 status = 1; + optional uint64 db_handle = 2; + optional uint32 db_flags = 3; +}; + +message EnvOpenDbRequest { + required uint64 env_handle = 1; + required uint32 dbname = 2; + required uint32 flags = 3; + repeated uint32 param_names = 4; + repeated uint64 param_values = 5; +} + +message EnvOpenDbReply { + required sint32 status = 1; + optional uint64 db_handle = 2; + optional uint32 db_flags = 3; +}; + +message EnvEraseDbRequest { + required uint64 env_handle = 1; + required uint32 name = 2; + required uint32 flags = 3; +} + +message EnvEraseDbReply { + required sint32 status = 1; +}; + +message DbCloseRequest { + required uint64 db_handle = 1; + required uint32 flags = 2; +} + +message DbCloseReply { + required sint32 status = 1; +}; + +message DbGetParametersRequest { + required uint64 db_handle = 1; + repeated uint32 names = 2; +} + +message DbGetParametersReply { + required sint32 status = 1; + optional uint32 max_env_databases = 2; + optional uint32 flags = 3; + optional uint32 key_size = 4; + optional uint32 dbname = 5; + optional uint32 keys_per_page = 6; + optional uint32 key_type = 7; + optional uint32 record_size = 8; +}; + +message TxnBeginRequest { + required uint64 env_handle = 1; + required uint32 flags = 2; + optional string name = 3; +} + +message TxnBeginReply { + required sint32 status = 1; + required uint64 txn_handle = 2; +}; + +message TxnCommitRequest { + required uint64 txn_handle = 1; + required uint32 flags = 2; +} + +message TxnCommitReply { + required sint32 status = 1; +}; + +message TxnAbortRequest { + required uint64 txn_handle = 1; + required uint32 flags = 2; +} + +message TxnAbortReply { + required sint32 status = 1; +}; + +message DbCheckIntegrityRequest { + required uint64 db_handle = 1; + required uint32 flags = 2; +} + +message DbCheckIntegrityReply { + required sint32 status = 1; +}; + +message DbCountRequest { + required uint64 db_handle = 1; + required uint64 txn_handle = 2; + required bool distinct = 3; +}; + +message DbCountReply { + required sint32 status = 1; + required uint64 keycount = 2; +}; + +message Key { + optional bytes data = 1; + required uint32 flags = 2; + required uint32 intflags = 3; +} + +message Record { + optional bytes data = 1; + required uint32 flags = 2; + required uint32 partial_offset = 3; + required uint32 partial_size = 4; +} + +message DbInsertRequest { + required uint64 db_handle = 1; + required uint64 txn_handle = 2; + optional Key key = 3; + optional Record record = 4; + required uint32 flags = 5; +}; + +message DbInsertReply { + required sint32 status = 1; + optional Key key = 2; +}; + +message DbEraseRequest { + required uint64 db_handle = 1; + required uint64 txn_handle = 2; + required Key key = 3; + required uint32 flags = 4; +}; + +message DbEraseReply { + required sint32 status = 1; +}; + +message DbFindRequest { + required uint64 db_handle = 1; + required uint64 txn_handle = 2; + required uint64 cursor_handle = 3; + required Key key = 4; + optional Record record = 5; + required uint32 flags = 6; +}; + +message DbFindReply { + required sint32 status = 1; + required Record record = 2; + optional Key key = 3; +}; + +message CursorCreateRequest { + required uint64 db_handle = 1; + required uint64 txn_handle = 2; + required uint32 flags = 3; +}; + +message CursorCreateReply { + required sint32 status = 1; + required uint64 cursor_handle = 2; +}; + +message CursorCloneRequest { + required uint64 cursor_handle = 1; +}; + +message CursorCloneReply { + required sint32 status = 1; + required uint64 cursor_handle = 2; +}; + +message CursorCloseRequest { + required uint64 cursor_handle = 1; +}; + +message CursorCloseReply { + required sint32 status = 1; +}; + +message CursorInsertRequest { + required uint64 cursor_handle = 1; + optional Key key = 2; + optional Record record = 3; + required uint32 flags = 4; +}; + +message CursorInsertReply { + required sint32 status = 1; + optional Key key = 2; +}; + +message CursorEraseRequest { + required uint64 cursor_handle = 1; + required uint32 flags = 2; +}; + +message CursorEraseReply { + required sint32 status = 1; +}; + +message CursorGetRecordCountRequest { + required uint64 cursor_handle = 1; + required uint32 flags = 2; +}; + +message CursorGetRecordCountReply { + required sint32 status = 1; + required uint32 count = 2; +}; + +message CursorGetRecordSizeRequest { + required uint64 cursor_handle = 1; +}; + +message CursorGetRecordSizeReply { + required sint32 status = 1; + required uint64 size = 2; +}; + +message CursorGetDuplicatePositionRequest { + required uint64 cursor_handle = 1; +}; + +message CursorGetDuplicatePositionReply { + required sint32 status = 1; + required uint32 position = 2; +}; + +message CursorOverwriteRequest { + required uint64 cursor_handle = 1; + required Record record = 2; + required uint32 flags = 3; +}; + +message CursorOverwriteReply { + required sint32 status = 1; +}; + +message CursorMoveRequest { + required uint64 cursor_handle = 1; + optional Key key = 2; + optional Record record = 3; + required uint32 flags = 4; +}; + +message CursorMoveReply { + required sint32 status = 1; + optional Key key = 2; + optional Record record = 3; +}; diff --git a/plugins/Dbx_kv/src/hamsterdb/src/2protobuf/protocol.h b/plugins/Dbx_kv/src/hamsterdb/src/2protobuf/protocol.h new file mode 100644 index 0000000000..8a2ab9d49f --- /dev/null +++ b/plugins/Dbx_kv/src/hamsterdb/src/2protobuf/protocol.h @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2005-2015 Christoph Rupp (chris@crupp.de). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Abstraction layer for the remote protocol + * + * @exception_safe: no + * @thread_safe: no + */ + +#ifndef HAM_PROTOCOL_H +#define HAM_PROTOCOL_H + +#include "0root/root.h" + +// Always verify that a file of level N does not include headers > N! +#include "1mem/mem.h" +#include "1base/error.h" +#include "1base/dynamic_array.h" +#include "2protobuf/messages.pb.h" + +#ifndef HAM_ROOT_H +# error "root.h was not included" +#endif + +using namespace hamsterdb; + +/** a magic and version indicator for the remote protocol */ +#define HAM_TRANSFER_MAGIC_V1 (('h'<<24)|('a'<<16)|('m'<<8)|'1') + +/** + * the Protocol class maps a single message that is exchanged between + * client and server + */ +class Protocol : public hamsterdb::ProtoWrapper +{ + public: + Protocol() { } + + /** constructor - assigns a type */ + Protocol(hamsterdb::ProtoWrapper_Type type) { + set_type(type); + } + + /** helper function which copies a ham_key_t into a ProtoBuf key */ + static void assign_key(hamsterdb::Key *protokey, ham_key_t *hamkey, + bool deep_copy = true) { + if (deep_copy) + protokey->set_data(hamkey->data, hamkey->size); + protokey->set_flags(hamkey->flags); + protokey->set_intflags(hamkey->_flags); + } + + /** helper function which copies a ham_record_t into a ProtoBuf record */ + static void assign_record(hamsterdb::Record *protorec, + ham_record_t *hamrec, bool deep_copy = true) { + if (deep_copy) + protorec->set_data(hamrec->data, hamrec->size); + protorec->set_flags(hamrec->flags); + protorec->set_partial_offset(hamrec->partial_offset); + protorec->set_partial_size(hamrec->partial_size); + } + + /** + * Factory function; creates a new Protocol structure from a serialized + * buffer + */ + static Protocol *unpack(const uint8_t *buf, uint32_t size) { + if (*(uint32_t *)&buf[0] != HAM_TRANSFER_MAGIC_V1) { + ham_trace(("invalid protocol version")); + return (0); + } + + Protocol *p = new Protocol; + if (!p->ParseFromArray(buf + 8, size - 8)) { + delete p; + return (0); + } + return (p); + } + + /* + * Packs the Protocol structure into a memory buffer and returns + * a pointer to the buffer and the buffer size + */ + bool pack(uint8_t **data, uint32_t *size) { + uint32_t packed_size = ByteSize(); + /* we need 8 more bytes for magic and size */ + uint8_t *p = Memory::allocate<uint8_t>(packed_size + 8); + if (!p) + return (false); + + /* write the magic and the payload size of the packed structure */ + *(uint32_t *)&p[0] = HAM_TRANSFER_MAGIC_V1; + *(uint32_t *)&p[4] = packed_size; + + /* now write the packed structure */ + if (!SerializeToArray(&p[8], packed_size)) { + Memory::release(p); + return (false); + } + + *data = p; + *size = packed_size + 8; + return (true); + } + + /* + * Packs the Protocol structure into a ByteArray + */ + bool pack(ByteArray *barray) { + uint32_t packed_size = ByteSize(); + /* we need 8 more bytes for magic and size */ + uint8_t *p = (uint8_t *)barray->resize(packed_size + 8); + if (!p) + return (false); + + /* write the magic and the payload size of the packed structure */ + *(uint32_t *)&p[0] = HAM_TRANSFER_MAGIC_V1; + *(uint32_t *)&p[4] = packed_size; + + /* now write the packed structure */ + return (SerializeToArray(&p[8], packed_size)); + } + + /** + * shutdown/free globally allocated memory + */ + static void shutdown() { + google::protobuf::ShutdownProtobufLibrary(); + } +}; + +#endif /* HAM_PROTOCOL_H */ |