ClamAV-Clamd
view release on metacpan or search on metacpan
include/clamav/clamd_abi_impl.h view on Meta::CPAN
/* clamd_abi_impl.h - the wrappers behind clamd_abi.h.
*
* Included by the root .xs AFTER the headers defining the real
* functions. Not installed: a consumer vendors clamd_abi.h and never
* sees this.
*/
#ifndef CLAMD_ABI_IMPL_H
#define CLAMD_ABI_IMPL_H
#include "clamav/clamd_abi.h"
/* A target is a cc_target plus the storage its char pointers reference.
* cc_target borrows them, and an ABI consumer's strings are not this
* dist's to keep alive. */
typedef struct {
cc_target t;
char *path;
char *host;
} cca_target;
static void *cca_target_new(pTHX_ const char *socket_path,
const char *host, int port) {
cca_target *g;
PERL_UNUSED_CONTEXT;
if (!socket_path && !host) return NULL;
if (socket_path && host) return NULL;
#ifndef _WIN32
/* Refused, never truncated: a shortened sun_path connects to a
* different socket, and believing an answer from an unidentified
* peer is worse than not getting one. */
if (socket_path && strlen(socket_path) >= CC_SUN_PATH_MAX) return NULL;
#else
if (socket_path) return NULL;
#endif
g = (cca_target *)malloc(sizeof *g);
if (!g) return NULL;
memset(g, 0, sizeof *g);
g->path = socket_path ? cc_strdup(socket_path) : NULL;
g->host = host ? cc_strdup(host) : NULL;
if ((socket_path && !g->path) || (host && !g->host)) {
free(g->path); free(g->host); free(g);
return NULL;
}
g->t.path = g->path;
g->t.host = g->host;
g->t.port = port > 0 ? port : 3310;
g->t.connect_timeout = 5.0;
g->t.reply_timeout = 30.0;
g->t.reply_max = 1024 * 1024;
g->t.frame = CC_FRAME_Z;
return g;
}
static void cca_target_timeouts(pTHX_ void *target, double ct, double rt) {
cca_target *g = (cca_target *)target;
PERL_UNUSED_CONTEXT;
if (!g) return;
if (ct > 0) g->t.connect_timeout = ct;
if (rt > 0) g->t.reply_timeout = rt;
}
static void cca_target_limits(pTHX_ void *target, size_t reply_max,
size_t chunk, size_t max_size) {
cca_target *g = (cca_target *)target;
PERL_UNUSED_CONTEXT;
if (!g) return;
if (reply_max) g->t.reply_max = reply_max;
g->t.chunk = chunk;
( run in 1.078 second using v1.01-cache-2.11-cpan-14f38c9f855 )