Commit a7cc0a2a authored by Lubomir Bulej's avatar Lubomir Bulej

Merge branch 'protobuf' into 'master'

Protobuf

See merge request !2
parents dd1b15ea a4161a17
Pipeline #3110 passed with stages
in 2 minutes and 54 seconds
......@@ -15,5 +15,6 @@
<classpathentry kind="lib" path="lib/disl/asm-analysis.jar" sourcepath="lib/devel/asm-analysis-source.jar"/>
<classpathentry kind="lib" path="lib/disl/asm-commons.jar" sourcepath="lib/devel/asm-commons-source.jar"/>
<classpathentry kind="lib" path="lib/disl/asm-util.jar" sourcepath="lib/devel/asm-util-source.jar"/>
<classpathentry kind="lib" path="lib/disl/protobuf-lite.jar"/>
<classpathentry kind="output" path="output/build/disl"/>
</classpath>
......@@ -249,6 +249,15 @@
<fileset dir="${lib.test.dir}" includes="*.jar"/>
</path>
<path id="protobuf.classpath">
<fileset dir="${lib.disl.dir}" includes="protobuf*.jar"/>
</path>
<!-- Get ProtoBuf Java libs from ProtoBuf class path. -->
<pathconvert pathsep=" " property="protobuf.libs" refid="protobuf.classpath">
<mapper type="flatten"/>
</pathconvert>
<!-- Project class paths -->
<path id="util.classpath">
<pathelement location="${build.util}"/>
......@@ -470,6 +479,7 @@
<path refid="disl.bypass.classpath"/>
<path refid="util.classpath"/>
<path refid="asm.classpath"/>
<path refid="protobuf.classpath"/>
</classpath>
</javac>
</target>
......@@ -484,7 +494,7 @@
<jar destfile="${out.lib}/${disl.lib}">
<manifest>
<attribute name="Class-Path" value="${asm.libs}"/>
<attribute name="Class-Path" value="${asm.libs} ${protobuf.libs}"/>
<attribute name="Main-Class" value="${server.class}"/>
<attribute name="DiSL-Version" value="${disl.version}"/>
</manifest>
......@@ -973,9 +983,10 @@
<!-- Miscellaneous -->
<target name="copy-asm" depends="-init">
<target name="copy-libs" depends="-init">
<copy todir="${out.lib}" flatten="true">
<path refid="asm.classpath"/>
<path refid="protobuf.classpath"/>
</copy>
</target>
......@@ -1057,7 +1068,7 @@
<target name="compile" depends="compile-disl,compile-disl-agent,compile-shvm,compile-shvm-agent" description="Compiles DiSL, Shadow VM, and the JVM agents for both."/>
<target name="build" depends="build-disl,build-disl-agent,build-shvm,build-shvm-agent,copy-asm" description="Builds DiSL and Shadow VM, without documentation."/>
<target name="build" depends="build-disl,build-disl-agent,build-shvm,build-shvm-agent,copy-libs" description="Builds DiSL and Shadow VM, without documentation."/>
<target name="eclipse" depends="download-sources,build-eclipse-agent,build-disl-bypass" description="Creates libraries for developing DiSL under Eclipse."/>
......
......@@ -11,3 +11,7 @@ asm.org=org.ow2.asm
log4j.rev=1.2.17
log4j.org=log4j
protobuf.rev=3.0.1
protobuf.org=com.google.protobuf
protobuf.lib=protobuf-lite
......@@ -28,6 +28,7 @@
<dependency org="${asm.org}" name="asm-util" rev="${asm.rev}" conf="disl->default;devel->sources,javadoc" />
<dependency org="${asm.org}" name="asm-commons" rev="${asm.rev}" conf="disl->default;devel->sources,javadoc" />
<dependency org="${log4j.org}" name="log4j" rev="${log4j.rev}" conf="disl->default;devel->sources,javadoc" />
<dependency org="${protobuf.org}" name="${protobuf.lib}" rev="${protobuf.rev}" conf="disl->default;devel->sources,javadoc" />
</dependencies>
</ivy-module>
......@@ -6,5 +6,6 @@ lib/disl/asm-tree.jar
lib/disl/asm-util.jar
lib/disl/asm.jar
lib/disl/log4j.jar
lib/disl/protobuf-lite.jar
lib/test/hamcrest-core.jar
lib/test/junit.jar
\ No newline at end of file
lib/test/junit.jar
......@@ -108,10 +108,12 @@ LIBRARY := $(TARGET_DIR)/$(LIBRARY_NAME)
# Source and object files needed to create the library
SOURCES = bytecode.c common.c jvmtiutil.c connection.c \
connpool.c msgchannel.c network.c classparser.c \
dislagent.c
dislserver.pb-c.c protobuf-c.c dislagent.c
HEADERS = $(wildcard *.h) codeflags.h dislserver.pb-c.h
GENSRCS = bytecode.c codeflags.h \
dislserver.pb-c.c dislserver.pb-c.h
HEADERS = $(wildcard *.h) codeflags.h
GENSRCS = bytecode.c codeflags.h
OBJECTS = $(addprefix $(BUILD_DIR)/,$(SOURCES:%.c=%.o))
SRCDEPS = $(SOURCES:%.c=%.d)
......
......@@ -45,7 +45,7 @@ die_with_error (const char * message) {
void
die_with_std_error (const char * message, int errnum) {
char * cause = strerror (errnum);
fprintf (stderr, "%s%s\ncause: %s", ERROR_PREFIX, message, cause);
fprintf (stderr, "%s%s\ncause: %s\n", ERROR_PREFIX, message, cause);
exit (ERROR_STD);
}
......
......@@ -87,7 +87,7 @@ connection_close (struct connection * connection) {
typedef ssize_t (* xfer_fn) (int sockfd, void * buf, size_t len, int flags);
static inline ssize_t
__socket_xfer (xfer_fn xfer, const int sockfd, const void * buf, const ssize_t len) {
__socket_xfer_full (xfer_fn xfer, const int sockfd, const void * buf, const size_t len) {
unsigned char * buf_tail = (unsigned char *) buf;
size_t remaining = len;
......@@ -110,13 +110,12 @@ __socket_xfer (xfer_fn xfer, const int sockfd, const void * buf, const ssize_t l
* data has been sent. Returns the number of bytes sent.
*/
ssize_t
connection_send (struct connection * connection, const void * buf, const ssize_t len) {
connection_send_full (struct connection * connection, const void * buf, const size_t len) {
assert (connection != NULL);
assert (buf != NULL);
assert (len >= 0);
assert ((buf != NULL) || (buf == NULL && len == 0));
ssize_t sent = __socket_xfer ((xfer_fn) send, connection->sockfd, buf, len);
check_std_error (sent < 0, "error sending data to server");
ssize_t sent = __socket_xfer_full ((xfer_fn) send, connection->sockfd, buf, len);
check_std_error (sent < 0, "connection_send_full: error sending data to server");
#ifdef DEBUG
connection->sent_bytes += sent;
......@@ -131,13 +130,31 @@ connection_send (struct connection * connection, const void * buf, const ssize_t
* until all requested data has been received. Returns the number of bytes received.
*/
ssize_t
connection_recv (struct connection * connection, void * buf, const ssize_t len) {
connection_recv_full (struct connection * connection, void * buf, const size_t len) {
assert (connection != NULL);
assert ((buf != NULL) || (buf == NULL && len == 0));
ssize_t received = __socket_xfer_full ((xfer_fn) recv, connection->sockfd, buf, len);
check_std_error (received < 0, "connection_recv_full: error receiving data from server");
#ifdef DEBUG
connection->recv_bytes += received;
#endif
return received;
}
/**
* Receives data from the given connection.
* Returns the number of bytes received.
*/
ssize_t
connection_recv (struct connection * connection, void * buf, const size_t len) {
assert (connection != NULL);
assert (buf != NULL);
assert (len >= 0);
ssize_t received = __socket_xfer ((xfer_fn) recv, connection->sockfd, buf, len);
check_std_error (received < 0, "error receiving data from server");
ssize_t received = recv (connection->sockfd, buf, len, 0);
check_std_error (received < 0, "connection_recv: error receiving data from server");
#ifdef DEBUG
connection->recv_bytes += received;
......@@ -153,7 +170,7 @@ connection_recv (struct connection * connection, void * buf, const ssize_t len)
typedef ssize_t (* xfer_iov_fn) (int sockfd, struct iovec * iovs, int iov_count);
static inline ssize_t
__socket_xfer_iov (
__socket_xfer_iov_full (
xfer_iov_fn xfer_iov, const int sockfd, struct iovec * iovs, const int iov_count
) {
ssize_t total = 0;
......@@ -198,12 +215,12 @@ __socket_xfer_iov (
* data have been sent. Returns the number of bytes sent.
*/
ssize_t
connection_send_iov (struct connection * connection, struct iovec * iovs, int iov_count) {
connection_send_iov_full (struct connection * connection, struct iovec * iovs, int iov_count) {
assert (connection != NULL);
assert (iovs != NULL);
assert (iov_count >= 0);
ssize_t sent = __socket_xfer_iov ((xfer_iov_fn) writev, connection->sockfd, iovs, iov_count);
ssize_t sent = __socket_xfer_iov_full ((xfer_iov_fn) writev, connection->sockfd, iovs, iov_count);
check_std_error (sent < 0, "error sending data to server");
#ifdef DEBUG
......@@ -219,13 +236,13 @@ connection_send_iov (struct connection * connection, struct iovec * iovs, int io
* all requested data have been received. Returns the number of bytes received.
*/
ssize_t
connection_recv_iov (struct connection * connection, struct iovec * iovs, int iov_count) {
connection_recv_iov_full (struct connection * connection, struct iovec * iovs, int iov_count) {
assert (connection != NULL);
assert (iovs != NULL);
assert (iov_count >= 0);
ssize_t received = __socket_xfer_iov ((xfer_iov_fn) readv, connection->sockfd, iovs, iov_count);
check_std_error (received < 0, "error receiving data from server");
ssize_t received = __socket_xfer_iov_full ((xfer_iov_fn) readv, connection->sockfd, iovs, iov_count);
check_std_error (received < 0, "connection_recv_iov_full: error receiving data from server");
#ifdef DEBUG
connection->recv_bytes += received;
......
......@@ -43,15 +43,16 @@ struct connection {
struct connection * connection_open (struct addrinfo * addr);
void connection_close (struct connection * connection);
ssize_t connection_send (struct connection * connection, const void * buf, const ssize_t len);
ssize_t connection_recv (struct connection * connection, void * buf, const ssize_t len);
ssize_t connection_send_full (struct connection * connection, const void * buf, const size_t len);
ssize_t connection_recv_full (struct connection * connection, void * buf, const size_t len);
ssize_t connection_recv (struct connection * connection, void * buf, const size_t len);
#ifndef MINGW
#include <sys/uio.h>
ssize_t connection_send_iov (struct connection * connection, struct iovec * iovs, int iov_count);
ssize_t connection_recv_iov (struct connection * connection, struct iovec * iovs, int iov_count);
ssize_t connection_send_iov_full (struct connection * connection, struct iovec * iovs, int iov_count);
ssize_t connection_recv_iov_full (struct connection * connection, struct iovec * iovs, int iov_count);
#endif
......
......@@ -4,6 +4,7 @@
#include "connection.h"
#include "network.h"
#include "msgchannel.h"
#include "dislserver.pb-c.h"
#include "bytecode.h"
#include "classparser.h"
......@@ -217,31 +218,40 @@ __instrument_class (
// send the it to the server. Receive the response and release the
// connection again.
//
struct message request = {
.message_flags = request_flags,
.control_size = (class_name != NULL) ? strlen (class_name) : 0,
.classcode_size = class_def->class_byte_count,
.control = (unsigned char *) class_name,
.classcode = class_def->class_bytes,
};
InstrumentClassRequest request = INSTRUMENT_CLASS_REQUEST__INIT;
request.has_flags = true;
request.flags = request_flags;
request.classname = (char *) class_name;
request.has_classbytes = true;
request.classbytes.len = class_def->class_byte_count;
request.classbytes.data = (uint8_t *) class_def->class_bytes;
//
size_t send_size = instrument_class_request__get_packed_size (&request);
void * send_buffer = malloc (send_size);
assert (send_buffer != NULL);
instrument_class_request__pack (&request, send_buffer);
struct connection * conn = network_acquire_connection ();
message_send (conn, &request);
message_send (conn, send_buffer, send_size);
//
struct message response;
message_recv (conn, &response);
void * recv_buffer;
size_t recv_size = message_recv (conn, &recv_buffer);
network_release_connection (conn);
InstrumentClassResponse * response = instrument_class_response__unpack (NULL, recv_size, recv_buffer);
assert (response != NULL);
free (recv_buffer);
//
// Check if error occurred on the server.
// The control field of the response contains the error message.
//
if (response.control_size > 0) {
if (response->result == INSTRUMENT_CLASS_RESULT__ERROR) {
fprintf (
stderr, "%sinstrumentation server error:\n%s\n",
ERROR_PREFIX, response.control
ERROR_PREFIX, response->errormessage
);
exit (ERROR_SERVER);
......@@ -252,12 +262,19 @@ __instrument_class (
// modified if non-empty class code has been returned. Otherwise,
// signal that the class has not been modified.
//
if (response.classcode_size > 0) {
class_def->class_byte_count = response.classcode_size;
class_def->class_bytes = response.classcode;
if (response->result == INSTRUMENT_CLASS_RESULT__CLASS_MODIFIED) {
class_def->class_byte_count = response->classbytes.len;
class_def->class_bytes = response->classbytes.data;
response->has_classbytes = false;
response->classbytes.len = 0;
response->classbytes.data = NULL;
instrument_class_response__free_unpacked (response, NULL);
return true;
} else {
instrument_class_response__free_unpacked (response, NULL);
return false;
}
}
......
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
/* Generated from: dislserver.proto */
/* Do not generate deprecated warnings for self */
#ifndef PROTOBUF_C__NO_DEPRECATED
#define PROTOBUF_C__NO_DEPRECATED
#endif
#include "dislserver.pb-c.h"
void instrument_class_request__init
(InstrumentClassRequest *message)
{
static InstrumentClassRequest init_value = INSTRUMENT_CLASS_REQUEST__INIT;
*message = init_value;
}
size_t instrument_class_request__get_packed_size
(const InstrumentClassRequest *message)
{
assert(message->base.descriptor == &instrument_class_request__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t instrument_class_request__pack
(const InstrumentClassRequest *message,
uint8_t *out)
{
assert(message->base.descriptor == &instrument_class_request__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t instrument_class_request__pack_to_buffer
(const InstrumentClassRequest *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &instrument_class_request__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
InstrumentClassRequest *
instrument_class_request__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (InstrumentClassRequest *)
protobuf_c_message_unpack (&instrument_class_request__descriptor,
allocator, len, data);
}
void instrument_class_request__free_unpacked
(InstrumentClassRequest *message,
ProtobufCAllocator *allocator)
{
assert(message->base.descriptor == &instrument_class_request__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void instrument_class_response__init
(InstrumentClassResponse *message)
{
static InstrumentClassResponse init_value = INSTRUMENT_CLASS_RESPONSE__INIT;
*message = init_value;
}
size_t instrument_class_response__get_packed_size
(const InstrumentClassResponse *message)
{
assert(message->base.descriptor == &instrument_class_response__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t instrument_class_response__pack
(const InstrumentClassResponse *message,
uint8_t *out)
{
assert(message->base.descriptor == &instrument_class_response__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t instrument_class_response__pack_to_buffer
(const InstrumentClassResponse *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &instrument_class_response__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
InstrumentClassResponse *
instrument_class_response__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (InstrumentClassResponse *)
protobuf_c_message_unpack (&instrument_class_response__descriptor,
allocator, len, data);
}
void instrument_class_response__free_unpacked
(InstrumentClassResponse *message,
ProtobufCAllocator *allocator)
{
assert(message->base.descriptor == &instrument_class_response__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
static const ProtobufCFieldDescriptor instrument_class_request__field_descriptors[3] =
{
{
"flags",
1,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_INT32,
offsetof(InstrumentClassRequest, has_flags),
offsetof(InstrumentClassRequest, flags),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"className",
2,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(InstrumentClassRequest, classname),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"classBytes",
3,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_BYTES,
offsetof(InstrumentClassRequest, has_classbytes),
offsetof(InstrumentClassRequest, classbytes),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned instrument_class_request__field_indices_by_name[] = {
2, /* field[2] = classBytes */
1, /* field[1] = className */
0, /* field[0] = flags */
};
static const ProtobufCIntRange instrument_class_request__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 3 }
};
const ProtobufCMessageDescriptor instrument_class_request__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"InstrumentClassRequest",
"InstrumentClassRequest",
"InstrumentClassRequest",
"",
sizeof(InstrumentClassRequest),
3,
instrument_class_request__field_descriptors,
instrument_class_request__field_indices_by_name,
1, instrument_class_request__number_ranges,
(ProtobufCMessageInit) instrument_class_request__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor instrument_class_response__field_descriptors[3] =
{
{
"result",
1,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_ENUM,
offsetof(InstrumentClassResponse, has_result),
offsetof(InstrumentClassResponse, result),
&instrument_class_result__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"errorMessage",
2,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(InstrumentClassResponse, errormessage),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"classBytes",
3,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_BYTES,
offsetof(InstrumentClassResponse, has_classbytes),
offsetof(InstrumentClassResponse, classbytes),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned instrument_class_response__field_indices_by_name[] = {
2, /* field[2] = classBytes */
1, /* field[1] = errorMessage */
0, /* field[0] = result */
};
static const ProtobufCIntRange instrument_class_response__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 3 }
};
const ProtobufCMessageDescriptor instrument_class_response__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"InstrumentClassResponse",
"InstrumentClassResponse",
"InstrumentClassResponse",
"",
sizeof(InstrumentClassResponse),
3,
instrument_class_response__field_descriptors,
instrument_class_response__field_indices_by_name,
1, instrument_class_response__number_ranges,
(ProtobufCMessageInit) instrument_class_response__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCEnumValue instrument_class_result__enum_values_by_number[3] =
{
{ "CLASS_UNMODIFIED", "INSTRUMENT_CLASS_RESULT__CLASS_UNMODIFIED", 0 },
{ "CLASS_MODIFIED", "INSTRUMENT_CLASS_RESULT__CLASS_MODIFIED", 1 },
{ "ERROR", "INSTRUMENT_CLASS_RESULT__ERROR", 3 },
};
static const ProtobufCIntRange instrument_class_result__value_ranges[] = {
{0, 0},{3, 2},{0, 3}
};
static const ProtobufCEnumValueIndex instrument_class_result__enum_values_by_name[3] =
{
{ "CLASS_MODIFIED", 1 },
{ "CLASS_UNMODIFIED", 0 },
{ "ERROR", 2 },
};
const ProtobufCEnumDescriptor instrument_class_result__descriptor =
{
PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
"InstrumentClassResult",
"InstrumentClassResult",
"InstrumentClassResult",
"",
3,
instrument_class_result__enum_values_by_number,
3,
instrument_class_result__enum_values_by_name,
2,
instrument_class_result__value_ranges,
NULL,NULL,NULL,NULL /* reserved[1234] */
};
/* Generated by the protocol buffer compiler. DO NOT EDIT! */
/* Generated from: dislserver.proto */
#ifndef PROTOBUF_C_dislserver_2eproto__INCLUDED
#define PROTOBUF_C_dislserver_2eproto__INCLUDED
#include "protobuf-c.h"
PROTOBUF_C__BEGIN_DECLS
#if PROTOBUF_C_VERSION_NUMBER < 1000000
# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers.
#elif 1002001 < PROTOBUF_C_MIN_COMPILER_VERSION
# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c.
#endif
typedef struct _InstrumentClassRequest InstrumentClassRequest;
typedef struct _InstrumentClassResponse InstrumentClassResponse;
/* --- enums --- */
typedef enum _InstrumentClassResult {
INSTRUMENT_CLASS_RESULT__CLASS_UNMODIFIED = 0,
INSTRUMENT_CLASS_RESULT__CLASS_MODIFIED = 1,
INSTRUMENT_CLASS_RESULT__ERROR = 3
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(INSTRUMENT_CLASS_RESULT)
} InstrumentClassResult;
/* --- messages --- */
struct _InstrumentClassRequest
{
ProtobufCMessage base;
protobuf_c_boolean has_flags;
int32_t flags;
char *classname;
protobuf_c_boolean has_classbytes;
ProtobufCBinaryData classbytes;
};
#define INSTRUMENT_CLASS_REQUEST__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&instrument_class_request__descriptor) \
, 0,0, NULL, 0,{0,NULL} }
struct _InstrumentClassResponse
{
ProtobufCMessage base;
protobuf_c_boolean has_result;
InstrumentClassResult result;
char *errormessage;
protobuf_c_boolean has_classbytes;
ProtobufCBinaryData classbytes;
};
#define INSTRUMENT_CLASS_RESPONSE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&instrument_class_response__descriptor) \
, 0,0, NULL, 0,{0,NULL} }
/* InstrumentClassRequest methods */
void instrument_class_request__init
(InstrumentClassRequest *message);
size_t instrument_class_request__get_packed_size
(const InstrumentClassRequest *message);
size_t instrument_class_request__pack
(const InstrumentClassRequest *message,
uint8_t *out);
size_t instrument_class_request__pack_to_buffer
(const InstrumentClassRequest *message,
ProtobufCBuffer *buffer);
InstrumentClassRequest *
instrument_class_request__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void instrument_class_request__free_unpacked
(InstrumentClassRequest *message,
ProtobufCAllocator *allocator);
/* InstrumentClassResponse methods */
void instrument_class_response__init
(InstrumentClassResponse *message);
size_t instrument_class_response__get_packed_size
(const InstrumentClassResponse *message);
size_t instrument_class_response__pack
(const InstrumentClassResponse *message,
uint8_t *out);
size_t instrument_class_response__pack_to_buffer
(const InstrumentClassResponse *message,
ProtobufCBuffer *buffer);
InstrumentClassResponse *
instrument_class_response__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void instrument_class_response__free_unpacked
(InstrumentClassResponse *message,
ProtobufCAllocator *allocator);
/* --- per-message closures --- */
typedef void (*InstrumentClassRequest_Closure)
(const InstrumentClassRequest *message,
void *closure_data);
typedef void (*InstrumentClassResponse_Closure)
(const InstrumentClassResponse *message,
void *closure_data);
/* --- services --- */
/* --- descriptors --- */
extern const ProtobufCEnumDescriptor instrument_class_result__descriptor;
extern const ProtobufCMessageDescriptor instrument_class_request__descriptor;
extern const ProtobufCMessageDescriptor instrument_class_response__descriptor;
PROTOBUF_C__END_DECLS
#endif /* PROTOBUF_C_dislserver_2eproto__INCLUDED */
......@@ -5,54 +5,33 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifndef MINGW
#include <sys/uio.h>
#endif
#include <jni.h>
//
#ifdef MINGW
static inline ssize_t
__send (struct connection * conn, struct message * msg, void * header, const size_t header_size) {
ssize_t sent = connection_send (conn, header, header_size);
sent += connection_send (conn, msg->control, msg->control_size);
sent += connection_send (conn, msg->classcode, msg->classcode_size);
__send (struct connection * conn, void * header, const size_t header_size, void * body, const size_t body_size) {
ssize_t sent = connection_send_full (conn, header, header_size);
sent += connection_send_full (conn, body, body_size);
return sent; <