clamd/others.h
e3aaff8e
 /*
086eab5c
  *  Copyright (C) 2007-2009 Sourcefire, Inc.
  *
  *  Authors: Tomasz Kojm, Trog, Török Edvin
e3aaff8e
  *
  *  This program is free software; you can redistribute it and/or modify
bb34cb31
  *  it under the terms of the GNU General Public License version 2 as
  *  published by the Free Software Foundation.
e3aaff8e
  *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
48b7b4a7
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  *  MA 02110-1301, USA.
e3aaff8e
  */
 
2d70a403
 #ifndef __CLAMD_OTHERS_H
 #define __CLAMD_OTHERS_H
e3aaff8e
 
fb787a06
 #if HAVE_CONFIG_H
 #include "clamav-config.h"
 #endif
 
e3aaff8e
 #include <stdlib.h>
064b4a0c
 #include "shared/optparser.h"
949c6fe5
 #include "thrmgr.h"
 #include "cltypes.h"
 
 enum mode {
     MODE_COMMAND,
     MODE_STREAM,
     MODE_WAITREPLY,
     MODE_WAITANCILL
 };
 
 struct fd_buf {
e4a0f2c9
     char *buffer;
949c6fe5
     size_t bufsize;
     size_t off;
     int fd;
     char term;
     int got_newdata; /* 0: no, 1: yes, -1: error */
     int recvfd;
     /* TODO: these fields don't belong here, there are identical fields in conn
      * too that don't belong there either. */
     enum mode mode;
     int id;
     int dumpfd;
     uint32_t chunksize;
     long quota;
     char *dumpname;
5f6edb22
     time_t timeout_at; /* 0 - no timeout */
949c6fe5
     jobgroup_t *group;
 };
 
 struct fd_data {
7660b7cb
     pthread_mutex_t *buf_mutex; /* protects buf and nfds */
949c6fe5
     struct fd_buf *buf;
     size_t nfds;
 #ifdef HAVE_POLL
     struct pollfd *poll_data;
     size_t poll_data_nfds;
 #endif
 };
e3aaff8e
 
80681b50
 #ifdef HAVE_POLL
7660b7cb
 #define FDS_INIT(mutex) { (mutex), NULL, 0, NULL, 0}
80681b50
 #else
7660b7cb
 #define FDS_INIT(mutex) { (mutex), NULL, 0}
80681b50
 #endif
 
f22f13d9
 int poll_fd(int fd, int timeout_sec, int check_signals);
064b4a0c
 void virusaction(const char *filename, const char *virname, const struct optstruct *opts);
94709323
 int writen(int fd, void *buff, unsigned int count);
5f6edb22
 int fds_add(struct fd_data *data, int fd, int listen_only, int timeout);
949c6fe5
 void fds_remove(struct fd_data *data, int fd);
5f6edb22
 void fds_cleanup(struct fd_data *data);
288b945f
 int fds_poll_recv(struct fd_data *data, int timeout, int check_signals, void *event);
949c6fe5
 void fds_free(struct fd_data *data);
0249f9d2
 
49f8de22
 void detstats_clear(void);
 void detstats_add(const char *virname, const char *fname, unsigned int fsize, const char *md5);
 void detstats_print(int desc, char term);
 
23b57d67
 #ifdef CLAMUKO
 int clamuko_checkowner(int pid, const struct optstruct *opts);
 #endif
 
e3aaff8e
 #endif