1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 //#ifndef __RECORDIO_H__ 19 //#define __RECORDIO_H__ 20 module deimos.zookeeper.recordio; 21 public import core.stdc.inttypes; 22 public import core.sys.posix.sys.types; 23 //#include <sys/types.h> 24 //#ifndef WIN32 25 //#define STRUCT_INITIALIZER(l,r) .l = r 26 //#else 27 //#define STRUCT_INITIALIZER(l,r) r 28 //#include "winconfig.h" 29 //#endif 30 // 31 //#ifdef __cplusplus 32 //extern "C" { 33 //#endif 34 35 extern(C): 36 37 struct buffer { 38 int32_t len; 39 char *buff; 40 }; 41 42 void deallocate_String(char **s); 43 void deallocate_Buffer(buffer *b); 44 void deallocate_vector(void *d); 45 struct iarchive { 46 int function ( iarchive *ia, const char *tag) start_record; 47 int function( iarchive *ia, const char *tag) end_record; 48 int function( iarchive *ia, const char *tag, int32_t *count) start_vector; 49 int function( iarchive *ia, const char *tag) end_vector; 50 int function( iarchive *ia, const char *name, int32_t *) deserialize_Bool; 51 int function( iarchive *ia, const char *name, int32_t *) deserialize_Int; 52 int function( iarchive *ia, const char *name, int64_t *) deserialize_Long; 53 int function( iarchive *ia, const char *name, buffer *) deserialize_Buffer; 54 int function( iarchive *ia, const char *name, char **) deserialize_String; 55 void *priv; 56 }; 57 struct oarchive { 58 int function( oarchive *oa, const char *tag) start_record; 59 int function( oarchive *oa, const char *tag) end_record; 60 int function( oarchive *oa, const char *tag, const int32_t *count) start_vector; 61 int function( oarchive *oa, const char *tag) end_vector; 62 int function( oarchive *oa, const char *name, const int32_t *) serialize_Bool; 63 int function( oarchive *oa, const char *name, const int32_t *) serialize_Int; 64 int function( oarchive *oa, const char *name, 65 const int64_t *) serialize_Long; 66 int function( oarchive *oa, const char *name, 67 const buffer *) serialize_Buffer; 68 int function( oarchive *oa, const char *name, char **) serialize_String; 69 void *priv; 70 }; 71 72 oarchive *create_buffer_oarchive(); 73 void close_buffer_oarchive( oarchive **oa, int free_buffer); 74 iarchive *create_buffer_iarchive(char *buffer, int len); 75 void close_buffer_iarchive( iarchive **ia); 76 char *get_buffer( oarchive *); 77 int get_buffer_len( oarchive *); 78 79 int64_t zoo_htonll(int64_t v);