#ifndef __DRWEBDC_DEMO_H
# define __DRWEBDC_DEMO_H

/*--------------------------------------------------------------------------
 Dr. Web daemon client demo (tools & data)
                                       ID Antivirus Lab http://www.drweb.ru
                                             http://www.drweb.ru/unix/forum
                                                   http://www.drweb.ru/unix
--------------------------------------------------------------------------*/
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/un.h>
#ifndef __FreeBSD__
# include <endian.h>
#endif
#include <netdb.h>

//--------------------------------------------------------------------------
// error codes:
#define DRWEBD_DEMO_USAGE    -1
#define DRWEBD_IN_FILE       -2
#define DRWEBD_NO_MEMORY     -3
#define DRWEBD_SOCKET_ERR    -4
#define DRWEBD_SWRITE_ERR    -5
#define DRWEBD_SREAD_ERR     -6
#define DRWEBD_TIMEOUT       -7


//--------------------------------------------------------------------------
// Dr. Web daemon exit codes:
#define DERR_READ_ERR           0x00001
#define DERR_WRITE_ERR          0x00002
#define DERR_NOMEMORY           0x00004
#define DERR_CRC_ERROR          0x00008
#define DERR_READSOCKET         0x00010
#define DERR_KNOWN_VIRUS        0x00020
#define DERR_UNKNOWN_VIRUS      0x00040
#define DERR_VIRUS_MODIFICATION 0x00080
#define DERR_TIMEOUT            0x00200
#define DERR_SYMLINK            0x00400
#define DERR_NO_REGFILE         0x00800
#define DERR_SKIPPED            0x01000
#define DERR_TOO_BIG            0x02000
#define DERR_TOO_COMPRESSED     0x04000
#define DERR_BAD_CALL           0x08000
#define DERR_EVAL_VERSION	0x10000
#define DERR_SPAM_MESSAGE       0x20000

//--------------------------------------------------------------------------
// Dr. Web daemon commands:
#define DRWEBD_SCAN_CMD       0x0001
#define DRWEBD_VERSION_CMD    0x0002
#define DRWEBD_BASEINFO_CMD   0x0003
#define DRWEBD_IDSTRING_CMD   0x0004

// DRWEBD_SCAN_FILE command flags:
#define DRWEBD_RETURN_VIRUSES 0x0001
#define DRWEBD_RETURN_REPORT  0x0002
#define DRWEBD_RETURN_CODES   0x0004
#define DRWEBD_HEURISTIC_ON   0x0008
#define DRWEBD_SPAM_FILTER    0x0020

//--------------------------------------------------------------------------
// defaults values:
#define DRWEBD_DEFAULT_PORT      3000
#define DRWEBD_DEFAULT_IP        "127.0.0.1"
#define DRWEBD_DEFAULT_TIMEOUT   40
#define DRWEBD_DEFAULT_OPTIONS   0x0000

//--------------------------------------------------------------------------
// external data:
extern char szSocketFile[];
extern char szDaemonIP[];
extern int  Socket;
extern int  Port;
extern int  Timeout;
extern int  bQuiet;
extern int  scanOptions;

//--------------------------------------------------------------------------
// tools:
void printn( int n );
void prints( const char * s );
void closeSocket( void );
void cleanup( void );
int  createSocket( void );
int  writeBuf( const void * buf, int n );
int  writeInt( int n );
int  readOutput( int size, void * buf );

//--------------------------------------------------------------------------

#endif
