#ifndef _DWC_PROTO_H
#define _DWC_PROTO_H

/*--------------------------------------------------------------------------
 *  Copyright (c) 2001-2004 Igor Daniloff. 
 *	All rights reserved.
 *
 * By using this file, you agree to the terms and conditions set
 * forth in the LICENSE file which can be found at this directory.
 *------------------------------------------------------------------------*/
 
/* $Id: dwc_proto.h,v 1.14.2.2 2009/10/08 14:35:22 akorkov Exp $ */

#include <unistd.h>
#include <sys/types.h>
#include <stdint.h>
#include "dwc_type.h"
#include "dwc_macro.h"
#include "dwc_ipc.h"
#include "dwc_strings.h"
#include "dwc_lib.h"

#ifdef  __cplusplus
extern "C" {
#endif

/* current filter <-> agent version */
#define DW_AGENT_PROTOCOL_VERSION      (1)

/* commands for agent */    
#define DW_AGENT_POST_STAT             (1)
#define DW_AGENT_REGISTER_CONNECTION   (100)
#define DW_AGENT_DEREGISTER_CONNECTION (101)

/* agent answers */
#define DW_AGENT_OK                    (0)
#define DW_AGENT_ERROR                 (~0)    

typedef unsigned int        dwc_proto_int_t;
typedef dwc_proto_int_t     dwc_proto_int32_t;
#if defined(__GNUC__) && !defined(Solaris_DW) && !defined(EMX_DW)
typedef uint64_t           dwc_proto_int64_t;
#endif /* GNUC and not SOLARIS and not EMX */
typedef dwc_membuf_t        dwc_proto_bytestring_t;
typedef dwc_bool_t          (*dwc_combiner_proc_t)(dwc_length_t, dwc_membuf_t, dwc_pointer_t, dwc_pointer_t );

extern dwc_bool_t dw_proto_write_int( dwc_ipc_t ipc, dwc_proto_int_t value );
extern dwc_bool_t dw_proto_read_int( dwc_ipc_t ipc, dwc_proto_int_t* pvalue );
#if defined(__GNUC__) && !defined(Solaris_DW) && !defined(EMX_DW)
extern dwc_bool_t dw_proto_write_int64( dwc_ipc_t ipc, dwc_proto_int64_t value );
extern dwc_bool_t dw_proto_read_int64( dwc_ipc_t ipc, dwc_proto_int64_t* pvalue );
#endif /* GNUC and not SOLARIS and not EMX */
extern dwc_bool_t dw_proto_write_bytestring( dwc_ipc_t ipc, dwc_length_t buf_len, const char* buf );
extern dwc_bool_t dw_proto_read_bytestring( dwc_ipc_t ipc, dwc_length_t* pbuf_len, dwc_proto_bytestring_t* pbuf, dwc_bool_t add_null );
extern dwc_bool_t dw_proto_write_list( dwc_ipc_t ipc, dwc_multistring_t list, dwc_bool_t add_null );
extern dwc_bool_t dw_proto_read_list( dwc_ipc_t ipc, dwc_combiner_proc_t combiner, dwc_pointer_t arg_3, dwc_pointer_t arg_4 );
extern dwc_bool_t dw_proto_write_buf( dwc_ipc_t ipc, dwc_length_t buf_len, const char* buf );
extern dwc_bool_t dw_proto_read_buf( dwc_ipc_t ipc, dwc_length_t buf_len, dwc_pointer_t buf );
/* Some complex types */
extern dwc_bool_t dw_proto_write_stat( DWC_ipc_t ipc, dwc_scan_stat_t* stat );
extern dwc_bool_t dw_proto_read_stat( DWC_ipc_t ipc, dwc_scan_stat_t* stat );
/* Special utility */
extern dwc_string_t dw_proto_read_report( dwc_ipc_t ipc, dwc_length_t size, dwc_const_path_t del_path );
extern dwc_bool_t dw_combiner_add_multistring( dwc_length_t line_len, dwc_membuf_t line, dwc_pointer_t arg_list, dwc_pointer_t ignore );
extern dwc_bool_t dw_combiner_add_multistring_and_delete_path( dwc_length_t line_len, dwc_membuf_t line, dwc_pointer_t arg_list, dwc_pointer_t arg_path );
extern dwc_bool_t dw_combiner_parse_viruses( dwc_length_t line_len, dwc_membuf_t line, dwc_pointer_t arg_struct, dwc_pointer_t ignore );

#ifdef  __cplusplus
}
#endif

#endif /* _DWC_PROTO_H */
 
