本文整理汇总了C++中optget函数的典型用法代码示例。如果您正苦于以下问题:C++ optget函数的具体用法?C++ optget怎么用?C++ optget使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了optget函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: b_command
/*
* command is called with argc==0 when checking for -V or -v option
* In this case return 0 when -v or -V or unknown option, otherwise
* the shift count to the command is returned
*/
int b_command(register int argc,char *argv[],Shbltin_t *context)
{
register int n, flags=0;
register Shell_t *shp = context->shp;
opt_info.index = opt_info.offset = 0;
while((n = optget(argv,sh_optcommand))) switch(n)
{
case 'p':
if(sh_isoption(SH_RESTRICTED))
errormsg(SH_DICT,ERROR_exit(1),e_restricted,"-p");
sh_onstate(SH_DEFPATH);
break;
case 'v':
flags |= X_FLAG;
break;
case 'V':
flags |= V_FLAG;
break;
case 'x':
shp->xargexit = 1;
break;
case ':':
if(argc==0)
return(0);
errormsg(SH_DICT,2, "%s", opt_info.arg);
break;
case '?':
if(argc==0)
return(0);
errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
break;
}
if(argc==0)
return(flags?0:opt_info.index);
argv += opt_info.index;
if(error_info.errors || !*argv)
errormsg(SH_DICT,ERROR_usage(2),"%s", optusage((char*)0));
return(whence(shp,argv, flags));
}
开发者ID:ISLEcode,项目名称:kornshell,代码行数:44,代码来源:whence.c
示例2: b_basename
int
b_basename(int argc,register char *argv[], void* context)
{
register int n;
cmdinit(argc, argv, context, ERROR_CATALOG, 0);
while (n = optget(argv, usage)) switch (n)
{
case ':':
error(2, "%s", opt_info.arg);
break;
case '?':
error(ERROR_usage(2), "%s", opt_info.arg);
break;
}
argv += opt_info.index;
argc -= opt_info.index;
if(error_info.errors || argc < 1 || argc > 2)
error(ERROR_usage(2), "%s", optusage(NiL));
namebase(sfstdout,argv[0],argv[1]);
return(0);
}
开发者ID:alarcher,项目名称:illumos-gate,代码行数:22,代码来源:basename.c
示例3: onas_fan_checkowner
int
onas_fan_checkowner (int pid, const struct optstruct *opts)
{
char path[32];
STATBUF sb;
const struct optstruct *opt;
if (!(opt = optget (opts, "OnAccessExcludeUID"))->enabled)
return 0;
snprintf (path, sizeof (path), "/proc/%u", pid);
if (CLAMSTAT (path, &sb) == 0)
{
while (opt)
{
if (opt->numarg == (long long) sb.st_uid)
return 1;
opt = opt->nextarg;
}
}
return 0;
}
开发者ID:Distrotech,项目名称:clamav,代码行数:22,代码来源:others.c
示例4: b_basename
int
b_basename(int argc, register char** argv, Shbltin_t* context)
{
char* string;
char* suffix = 0;
int all = 0;
cmdinit(argc, argv, context, ERROR_CATALOG, 0);
for (;;)
{
switch (optget(argv, usage))
{
case 'a':
all = 1;
continue;
case 's':
all = 1;
suffix = opt_info.arg;
continue;
case ':':
error(2, "%s", opt_info.arg);
break;
case '?':
error(ERROR_usage(2), "%s", opt_info.arg);
break;
}
break;
}
argv += opt_info.index;
argc -= opt_info.index;
if (error_info.errors || argc < 1 || !all && argc > 2)
error(ERROR_usage(2), "%s", optusage(NiL));
if (!all)
namebase(sfstdout, argv[0], argv[1]);
else
while (string = *argv++)
namebase(sfstdout, string, suffix);
return 0;
}
开发者ID:nathanmkaya,项目名称:ksh-arch,代码行数:39,代码来源:basename.c
示例5: b_exec
//
// Builtin `exec`.
//
int b_exec(int argc, char *argv[], Shbltin_t *context) {
UNUSED(argc);
struct login logdata;
int n;
logdata.clear = 0;
logdata.arg0 = NULL;
logdata.sh = context->shp;
logdata.sh->st.ioset = 0;
while ((n = optget(argv, sh_optexec))) {
switch (n) {
case 'a': {
logdata.arg0 = opt_info.arg;
break;
}
case 'c': {
logdata.clear = 1;
break;
}
case ':': {
errormsg(SH_DICT, 2, "%s", opt_info.arg);
break;
}
case '?': {
errormsg(SH_DICT, ERROR_usage(0), "%s", opt_info.arg);
return 2;
}
default: { break; }
}
}
argv += opt_info.index;
if (error_info.errors) {
errormsg(SH_DICT, ERROR_usage(2), "%s", optusage(NULL));
__builtin_unreachable();
}
if (*argv) B_login(0, argv, (Shbltin_t *)&logdata);
return 0;
}
开发者ID:att,项目名称:ast,代码行数:41,代码来源:misc.c
示例6: milter_exit
static void milter_exit(int sig) {
const struct optstruct *opt;
logg("*clamav-milter: milter_exit, signal %d\n", sig);
#ifndef _WIN32
if((opt = optget(opts, "MilterSocket"))) {
if(unlink(opt->strarg) == -1)
logg("!Can't unlink the socket file %s\n", opt->strarg);
else
logg("Socket file removed.\n");
}
#endif
logg("clamav-milter: stopped\n");
optfree(opts);
logg_close();
cpool_free();
localnets_free();
whitelist_free();
}
开发者ID:anh2hn,项目名称:clamav-devel,代码行数:23,代码来源:clamav-milter.c
示例7: b_whence
/*
* for the whence command
*/
int b_whence(int argc,char *argv[],Shbltin_t *context)
{
register int flags=0, n;
register Shell_t *shp = context->shp;
NOT_USED(argc);
if(*argv[0]=='t')
flags = V_FLAG;
while((n = optget(argv,sh_optwhence))) switch(n)
{
case 'a':
flags |= A_FLAG;
/* FALL THRU */
case 'v':
flags |= V_FLAG;
break;
case 'f':
flags |= F_FLAG;
break;
case 'p':
flags |= P_FLAG;
flags &= ~V_FLAG;
break;
case 'q':
flags |= Q_FLAG;
break;
case ':':
errormsg(SH_DICT,2, "%s", opt_info.arg);
break;
case '?':
errormsg(SH_DICT,ERROR_usage(2), "%s", opt_info.arg);
break;
}
argv += opt_info.index;
if(error_info.errors || !*argv)
errormsg(SH_DICT,ERROR_usage(2),optusage((char*)0));
return(whence(shp, argv, flags));
}
开发者ID:ISLEcode,项目名称:kornshell,代码行数:40,代码来源:whence.c
示例8: clamd_virus_found_cb
void clamd_virus_found_cb(int fd, const char *virname, void *ctx)
{
struct cb_context *c = ctx;
struct scan_cb_data *d = c->scandata;
const char *fname;
if (d == NULL)
return;
if (!(d->options & CL_SCAN_ALLMATCHES))
return;
if (virname == NULL)
return;
fname = (c && c->filename) ? c->filename : "(filename not set)";
if (virname) {
conn_reply_virus(d->conn, fname, virname);
if(c->virsize > 0 && optget(d->opts, "ExtendedDetectionInfo")->enabled)
logg("~%s: %s(%s:%llu) FOUND\n", fname, virname, c->virhash, c->virsize);
logg("~%s: %s FOUND\n", fname, virname);
}
return;
}
开发者ID:anh2hn,项目名称:clamav-devel,代码行数:24,代码来源:scanner.c
示例9: b_eval
int b_eval(int argc,char *argv[], void *extra)
{
register int r;
register Shell_t *shp = ((Shbltin_t*)extra)->shp;
NOT_USED(argc);
while (r = optget(argv,sh_opteval)) switch (r)
{
case ':':
errormsg(SH_DICT,2, "%s", opt_info.arg);
break;
case '?':
errormsg(SH_DICT,ERROR_usage(0), "%s",opt_info.arg);
return(2);
}
if(error_info.errors)
errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
argv += opt_info.index;
if(*argv && **argv)
{
sh_offstate(SH_MONITOR);
sh_eval(sh_sfeval(argv),0);
}
return(shp->exitval);
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:24,代码来源:misc.c
示例10: localserver
int localserver(const struct optstruct *opts)
{
struct sockaddr_un server;
int sockfd, backlog;
STATBUF foo;
char *estr;
memset((char *) &server, 0, sizeof(server));
server.sun_family = AF_UNIX;
strncpy(server.sun_path, optget(opts, "LocalSocket")->strarg, sizeof(server.sun_path));
server.sun_path[sizeof(server.sun_path)-1]='\0';
if((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
estr = strerror(errno);
logg("!LOCAL: Socket allocation error: %s\n", estr);
return -1;
}
if(bind(sockfd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) == -1) {
if(errno == EADDRINUSE) {
if(connect(sockfd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) >= 0) {
logg("!LOCAL: Socket file %s is in use by another process.\n", server.sun_path);
close(sockfd);
return -1;
}
if(optget(opts, "FixStaleSocket")->enabled) {
logg("#LOCAL: Removing stale socket file %s\n", server.sun_path);
if(unlink(server.sun_path) == -1) {
estr = strerror(errno);
logg("!LOCAL: Socket file %s could not be removed: %s\n", server.sun_path, estr);
close(sockfd);
return -1;
}
if(bind(sockfd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) == -1) {
estr = strerror(errno);
logg("!LOCAL: Socket file %s could not be bound: %s (unlink tried)\n", server.sun_path, estr);
close(sockfd);
return -1;
}
} else if(CLAMSTAT(server.sun_path, &foo) != -1) {
logg("!LOCAL: Socket file %s exists. Either remove it, or configure a different one.\n", server.sun_path);
close(sockfd);
return -1;
}
} else {
estr = strerror(errno);
logg("!LOCAL: Socket file %s could not be bound: %s\n", server.sun_path, estr);
close(sockfd);
return -1;
}
}
logg("#LOCAL: Unix socket file %s\n", server.sun_path);
backlog = optget(opts, "MaxConnectionQueueLength")->numarg;
logg("#LOCAL: Setting connection queue length to %d\n", backlog);
if(listen(sockfd, backlog) == -1) {
estr = strerror(errno);
logg("!LOCAL: listen() error: %s\n", estr);
close(sockfd);
return -1;
}
return sockfd;
}
开发者ID:Jyang772,项目名称:clamav-devel,代码行数:66,代码来源:localserver.c
示例11: command
/* returns
* -1 on fatal error (shutdown)
* 0 on ok
* >0 errors encountered
*/
int command(client_conn_t *conn, int *virus)
{
int desc = conn->sd;
struct cl_engine *engine = conn->engine;
unsigned int options = conn->options;
const struct optstruct *opts = conn->opts;
int type = -1; /* TODO: make this enum */
int maxdirrec;
int ret = 0;
int flags = CLI_FTW_STD;
struct scan_cb_data scandata;
struct cli_ftw_cbdata data;
unsigned ok, error, total;
STATBUF sb;
jobgroup_t *group = NULL;
if (thrmgr_group_need_terminate(conn->group)) {
logg("$Client disconnected while command was active\n");
if (conn->scanfd != -1)
close(conn->scanfd);
return 1;
}
thrmgr_setactiveengine(engine);
data.data = &scandata;
memset(&scandata, 0, sizeof(scandata));
scandata.id = conn->id;
scandata.group = conn->group;
scandata.odesc = desc;
scandata.conn = conn;
scandata.options = options;
scandata.engine = engine;
scandata.opts = opts;
scandata.thr_pool = conn->thrpool;
scandata.toplevel_path = conn->filename;
switch (conn->cmdtype) {
case COMMAND_SCAN:
thrmgr_setactivetask(NULL, "SCAN");
type = TYPE_SCAN;
break;
case COMMAND_CONTSCAN:
thrmgr_setactivetask(NULL, "CONTSCAN");
type = TYPE_CONTSCAN;
break;
case COMMAND_MULTISCAN: {
int multiscan, max, alive;
/* use MULTISCAN only for directories (bb #1869) */
if (STAT(conn->filename, &sb) == 0 &&
!S_ISDIR(sb.st_mode)) {
thrmgr_setactivetask(NULL, "CONTSCAN");
type = TYPE_CONTSCAN;
break;
}
pthread_mutex_lock(&conn->thrpool->pool_mutex);
multiscan = conn->thrpool->thr_multiscan;
max = conn->thrpool->thr_max;
if (multiscan+1 < max)
conn->thrpool->thr_multiscan = multiscan+1;
else {
alive = conn->thrpool->thr_alive;
ret = -1;
}
pthread_mutex_unlock(&conn->thrpool->pool_mutex);
if (ret) {
/* multiscan has 1 control thread, so there needs to be at least
1 threads that is a non-multiscan controlthread to scan and
make progress. */
logg("^Not enough threads for multiscan. Max: %d, Alive: %d, Multiscan: %d+1\n",
max, alive, multiscan);
conn_reply(conn, conn->filename, "Not enough threads for multiscan. Increase MaxThreads.", "ERROR");
return 1;
}
flags &= ~CLI_FTW_NEED_STAT;
thrmgr_setactivetask(NULL, "MULTISCAN");
type = TYPE_MULTISCAN;
scandata.group = group = thrmgr_group_new();
if (!group) {
if(optget(opts, "ExitOnOOM")->enabled)
return -1;
else
return 1;
}
break;
}
case COMMAND_MULTISCANFILE:
thrmgr_setactivetask(NULL, "MULTISCANFILE");
scandata.group = NULL;
scandata.type = TYPE_SCAN;
scandata.thr_pool = NULL;
/* TODO: check ret value */
ret = scan_callback(NULL, conn->filename, conn->filename, visit_file, &data); /* callback freed it */
//.........这里部分代码省略.........
开发者ID:Yuyue,项目名称:clamav-devel,代码行数:101,代码来源:session.c
示例12: execute_or_dispatch_command
/* returns:
* <0 for error
* -1 out of memory
* -2 other
* 0 for async dispatched
* 1 for command completed (connection can be closed)
*/
int execute_or_dispatch_command(client_conn_t *conn, enum commands cmd, const char *argument)
{
int desc = conn->sd;
char term = conn->term;
const struct cl_engine *engine = conn->engine;
/* execute commands that can be executed quickly on the recvloop thread,
* these must:
* - not involve any operation that can block for a long time, such as disk
* I/O
* - send of atomic message is allowed.
* Dispatch other commands */
if (conn->group) {
switch (cmd) {
case COMMAND_FILDES:
case COMMAND_SCAN:
case COMMAND_END:
case COMMAND_INSTREAM:
case COMMAND_INSTREAMSCAN:
case COMMAND_VERSION:
case COMMAND_PING:
case COMMAND_STATS:
case COMMAND_COMMANDS:
/* These commands are accepted inside IDSESSION */
break;
default:
/* these commands are not recognized inside an IDSESSION */
conn_reply_error(conn, "Command invalid inside IDSESSION.");
logg("$SESSION: command is not valid inside IDSESSION: %d\n", cmd);
conn->group = NULL;
return 1;
}
}
switch (cmd) {
case COMMAND_SHUTDOWN:
pthread_mutex_lock(&exit_mutex);
progexit = 1;
pthread_mutex_unlock(&exit_mutex);
return 1;
case COMMAND_RELOAD:
pthread_mutex_lock(&reload_mutex);
reload = 1;
pthread_mutex_unlock(&reload_mutex);
mdprintf(desc, "RELOADING%c", term);
/* we set reload flag, and we'll reload before closing the
* connection */
return 1;
case COMMAND_PING:
if (conn->group)
mdprintf(desc, "%u: PONG%c", conn->id, term);
else
mdprintf(desc, "PONG%c", term);
return conn->group ? 0 : 1;
case COMMAND_VERSION:
{
if (conn->group)
mdprintf(desc, "%u: ", conn->id);
print_ver(desc, conn->term, engine);
return conn->group ? 0 : 1;
}
case COMMAND_COMMANDS:
{
if (conn->group)
mdprintf(desc, "%u: ", conn->id);
print_commands(desc, conn->term, engine);
return conn->group ? 0 : 1;
}
case COMMAND_DETSTATSCLEAR:
{
detstats_clear();
return 1;
}
case COMMAND_DETSTATS:
{
detstats_print(desc, conn->term);
return 1;
}
case COMMAND_INSTREAM:
{
int rc = cli_gentempfd(optget(conn->opts, "TemporaryDirectory")->strarg, &conn->filename, &conn->scanfd);
if (rc != CL_SUCCESS)
return rc;
conn->quota = optget(conn->opts, "StreamMaxLength")->numarg;
conn->mode = MODE_STREAM;
return 0;
}
case COMMAND_STREAM:
case COMMAND_MULTISCAN:
case COMMAND_CONTSCAN:
case COMMAND_STATS:
case COMMAND_FILDES:
case COMMAND_SCAN:
case COMMAND_INSTREAMSCAN:
//.........这里部分代码省略.........
开发者ID:Yuyue,项目名称:clamav-devel,代码行数:101,代码来源:session.c
示例13: b_cut
int
b_cut(int argc, char** argv, void* context)
{
register char* cp = 0;
register Sfio_t* fp;
char* s;
int n;
Cut_t* cut;
int mode = 0;
Delim_t wdelim;
Delim_t ldelim;
size_t reclen = 0;
cmdinit(argc, argv, context, ERROR_CATALOG, 0);
wdelim.chr = '\t';
ldelim.chr = '\n';
wdelim.len = ldelim.len = 1;
for (;;)
{
switch (n = optget(argv, usage))
{
case 0:
break;
case 'b':
case 'c':
if(mode&C_FIELDS)
{
error(2, "f option already specified");
continue;
}
cp = opt_info.arg;
if(n=='b')
mode |= C_BYTES;
else
mode |= C_CHARS;
continue;
case 'D':
ldelim.str = opt_info.arg;
if (mbwide())
{
s = opt_info.arg;
ldelim.chr = mbchar(s);
if ((n = s - opt_info.arg) > 1)
{
ldelim.len = n;
continue;
}
}
ldelim.chr = *(unsigned char*)opt_info.arg;
ldelim.len = 1;
continue;
case 'd':
wdelim.str = opt_info.arg;
if (mbwide())
{
s = opt_info.arg;
wdelim.chr = mbchar(s);
if ((n = s - opt_info.arg) > 1)
{
wdelim.len = n;
continue;
}
}
wdelim.chr = *(unsigned char*)opt_info.arg;
wdelim.len = 1;
continue;
case 'f':
if(mode&(C_CHARS|C_BYTES))
{
error(2, "c option already specified");
continue;
}
cp = opt_info.arg;
mode |= C_FIELDS;
continue;
case 'n':
mode |= C_NOSPLIT;
continue;
case 'N':
mode |= C_NONEWLINE;
continue;
case 'R':
case 'r':
if(opt_info.num>0)
reclen = opt_info.num;
continue;
case 's':
mode |= C_SUPRESS;
continue;
case ':':
error(2, "%s", opt_info.arg);
break;
case '?':
error(ERROR_usage(2), "%s", opt_info.arg);
break;
}
break;
}
argv += opt_info.index;
if (error_info.errors)
//.........这里部分代码省略.........
开发者ID:jasonbking,项目名称:illumos-gate,代码行数:101,代码来源:cut.c
示例14: b_mktemp
int
b_mktemp(int argc, char** argv, Shbltin_t* context)
{
mode_t mode = 0;
mode_t mask;
int fd;
int i;
int quiet = 0;
int unsafe = 0;
int* fdp = &fd;
char* dir = "";
char* pfx;
char* t;
char path[PATH_MAX];
cmdinit(argc, argv, context, ERROR_CATALOG, ERROR_NOTIFY);
for (;;)
{
switch (optget(argv, usage))
{
case 'd':
fdp = 0;
continue;
case 'm':
mode = strperm(pfx = opt_info.arg, &opt_info.arg, S_IRWXU);
if (*opt_info.arg)
error(ERROR_exit(0), "%s: invalid mode", pfx);
continue;
case 'p':
if ((t = getenv("TMPDIR")) && *t)
dir = 0;
else
dir = opt_info.arg;
continue;
case 'q':
quiet = 1;
continue;
case 't':
dir = 0;
continue;
case 'u':
unsafe = 1;
fdp = 0;
continue;
case 'R':
if (!pathtemp(NiL, 0, opt_info.arg, "/seed", NiL))
error(2, "%s: regression test initializtion failed", opt_info.arg);
continue;
case ':':
error(2, "%s", opt_info.arg);
break;
case '?':
error(ERROR_usage(2), "%s", opt_info.arg);
break;
}
break;
}
argv += opt_info.index;
if (error_info.errors || (pfx = *argv++) && *argv)
error(ERROR_usage(2), "%s", optusage(NiL));
mask = umask(0);
if (!mode)
mode = (fdp ? (S_IRUSR|S_IWUSR) : S_IRWXU) & ~mask;
umask(~mode & (S_IRWXU|S_IRWXG|S_IRWXO));
if (!pfx)
{
pfx = "tmp_";
if (dir && !*dir)
dir = 0;
}
if (t = strrchr(pfx, '/'))
{
i = ++t - pfx;
dir = fmtbuf(i);
memcpy(dir, pfx, i);
dir[i] = 0;
pfx = t;
}
for (;;)
{
if (!pathtemp(path, sizeof(path), dir, pfx, fdp))
{
if (quiet)
error_info.errors++;
else
error(ERROR_SYSTEM|2, "cannot create temporary path");
break;
}
if (fdp || unsafe || !mkdir(path, mode))
{
if (fdp)
close(*fdp);
sfputr(sfstdout, path, '\n');
break;
}
if (sh_checksig(context))
{
error_info.errors++;
break;
}
//.........这里部分代码省略.........
开发者ID:ISLEcode,项目名称:kornshell,代码行数:101,代码来源:mktemp.c
示例15: client
int client(const struct optstruct *opts, int *infected, int *err)
{
int remote, scantype, session = 0, errors = 0, scandash = 0, maxrec, flags = 0;
const char *fname;
scandash = (opts->filename && opts->filename[0] && !strcmp(opts->filename[0], "-") && !optget(opts, "file-list")->enabled && !opts->filename[1]);
remote = isremote(opts) | optget(opts, "stream")->enabled;
#ifdef HAVE_FD_PASSING
if(!remote && optget(clamdopts, "LocalSocket")->enabled && (optget(opts, "fdpass")->enabled || scandash)) {
scantype = FILDES;
session = optget(opts, "multiscan")->enabled;
} else
#endif
if(remote || scandash) {
scantype = STREAM;
session = optget(opts, "multiscan")->enabled;
}
else if(optget(opts, "multiscan")->enabled) scantype = MULTI;
else if(optget(opts, "allmatch")->enabled) scantype = ALLMATCH;
else scantype = CONT;
maxrec = optget(clamdopts, "MaxDirectoryRecursion")->numarg;
maxstream = optget(clamdopts, "StreamMaxLength")->numarg;
if (optget(clamdopts, "FollowDirectorySymlinks")->enabled)
flags |= CLI_FTW_FOLLOW_DIR_SYMLINK;
if (optget(clamdopts, "FollowFileSymlinks")->enabled)
flags |= CLI_FTW_FOLLOW_FILE_SYMLINK;
flags |= CLI_FTW_TRIM_SLASHES;
*infected = 0;
if(scandash) {
int sockd, ret;
STATBUF sb;
if(FSTAT(0, &sb) < 0) {
logg("client.c: fstat failed for file name \"%s\", with %s\n.",
opts->filename[0], strerror(errno));
return 2;
}
if((sb.st_mode & S_IFMT) != S_IFREG) scantype = STREAM;
if((sockd = dconnect()) >= 0 && (ret = dsresult(sockd, scantype, NULL, &ret, NULL)) >= 0)
*infected = ret;
else
errors = 1;
if(sockd >= 0) closesocket(sockd);
} else if(opts->filename || optget(opts, "file-list")->enabled) {
if(opts->filename && optget(opts, "file-list")->enabled)
logg("^Only scanning files from --file-list (files passed at cmdline are ignored)\n");
while((fname = filelist(opts, NULL))) {
if(!strcmp(fname, "-")) {
logg("!Scanning from standard input requires \"-\" to be the only file argument\n");
continue;
}
errors += client_scan(fname, scantype, infected, err, maxrec, session, flags);
/* this may be too strict
if(errors >= 10) {
logg("!Too many errors\n");
break;
}
*/
}
} else {
errors = client_scan("", scantype, infected, err, maxrec, session, flags);
}
return *infected ? 1 : (errors ? 2 : 0);
}
开发者ID:LZ-SecurityTeam,项目名称:clamav-devel,代码行数:67,代码来源:client.c
示例16: main
int main(int argc, char **argv)
{
int ds, dms, ret;
double mb, rmb;
struct timeval t1, t2;
#ifndef _WIN32
sigset_t sigset;
#endif
struct optstruct *opts;
const struct optstruct *opt;
if(check_flevel())
exit(2);
#if !defined(_WIN32) && !defined(C_BEOS)
sigemptyset(&sigset);
sigaddset(&sigset, SIGXFSZ);
sigprocmask(SIG_SETMASK, &sigset, NULL);
#endif
cl_initialize_crypto();
if((opts = optparse(NULL, argc, argv, 1, OPT_CLAMSCAN, 0, NULL)) == NULL) {
mprintf("!Can't parse command line options\n");
return 2;
}
if(optget(opts, "verbose")->enabled) {
mprintf_verbose = 1;
logg_verbose = 1;
}
if(optget(opts, "quiet")->enabled)
mprintf_quiet = 1;
if(optget(opts, "stdout")->enabled)
mprintf_stdout = 1;
if(optget(opts, "debug")->enabled) {
#if defined(C_LINUX)
/* [email protected]: create a dump if needed */
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
if(setrlimit(RLIMIT_CORE, &rlim) < 0)
perror("setrlimit");
#endif
cl_debug(); /* enable debug messages */
}
if (optget(opts, "gen-mdb")->enabled) {
cl_always_gen_section_hash();
}
if(optget(opts, "version")->enabled) {
print_version(optget(opts, "database")->strarg);
optfree(opts);
return 0;
}
if(optget(opts, "help")->enabled) {
optfree(opts);
help();
return 0;
}
if(optget(opts, "recursive")->enabled)
recursion = 1;
if(optget(opts, "infected")->enabled)
printinfected = 1;
if(optget(opts, "suppress-ok-results")->enabled)
printclean = 0;
if(optget(opts, "bell")->enabled)
bell = 1;
/* initialize logger */
if((opt = optget(opts, "log"))->enabled) {
logg_file = opt->strarg;
if(logg("#\n-------------------------------------------------------------------------------\n\n")) {
mprintf("!Problem with internal logger.\n");
optfree(opts);
return 2;
}
} else
logg_file = NULL;
if(actsetup(opts)) {
optfree(opts);
logg_close();
exit(2);
}
memset(&info, 0, sizeof(struct s_info));
gettimeofday(&t1, NULL);
//.........这里部分代码省略.........
开发者ID:capturePointer,项目名称:clamav-devel,代码行数:101,代码来源:clamscan.c
示例17: init_actions
int init_actions(struct optstruct *opts) {
const struct optstruct *opt;
if(!(opt = optget(opts, "LogInfected"))->enabled || !strcasecmp(opt->strarg, "Off"))
loginfected = LOGINF_NONE;
else if(!strcasecmp(opt->strarg, "Basic"))
loginfected = LOGINF_BASIC;
else if(!strcasecmp(opt->strarg, "Full"))
loginfected = LOGINF_FULL;
else {
logg("!Invalid setting %s for option LogInfected\n", opt->strarg);
return 1;
}
if((opt = optget(opts, "LogClean"))->enabled) {
if(!strcasecmp(opt->strarg, "Basic"))
loginfected |= LOGCLN_BASIC;
else if(!strcasecmp(opt->strarg, "Full"))
loginfected |= LOGCLN_FULL;
else if(strcasecmp(opt->strarg, "Off")) {
logg("!Invalid setting %s for option LogClean\n", opt->strarg);
return 1;
}
}
if((opt = optget(opts, "VirusAction"))->enabled)
viraction = strdup(opt->strarg);
if((opt = optget(opts, "OnFail"))->enabled) {
switch(parse_action(opt->strarg)) {
case 0:
FailAction = SMFIS_ACCEPT;
break;
case 1:
FailAction = SMFIS_TEMPFAIL;
break;
case 2:
FailAction = SMFIS_REJECT;
break;
default:
logg("!Invalid action %s for option OnFail\n", opt->strarg);
return 1;
}
} else FailAction = SMFIS_TEMPFAIL;
if((opt = optget(opts, "OnClean"))->enabled) {
switch(parse_action(opt->strarg)) {
case 0:
CleanAction = action_accept;
break;
case 1:
CleanAction = action_defer;
break;
case 2:
CleanAction = action_reject;
break;
case 3:
CleanAction = action_blackhole;
break;
case 4:
CleanAction = action_quarantine;
break;
default:
logg("!Invalid action %s for option OnClean\n", opt->strarg);
return 1;
}
} else CleanAction = action_accept;
if((opt = optget(opts, "OnInfected"))->enabled) {
switch(parse_action(opt->strarg)) {
case 0:
InfectedAction = action_accept;
break;
case 1:
InfectedAction = action_defer;
break;
case 3:
InfectedAction = action_blackhole;
break;
case 4:
InfectedAction = action_quarantine;
break;
case 2:
InfectedAction = action_reject_msg;
if((opt = optget(opts, "RejectMsg"))->enabled) {
const char *src = opt->strarg;
char *dst, c;
int gotpctv = 0;
rejectfmt = dst = malloc(strlen(src) * 4 + 1);
if(!dst) {
logg("!Failed to allocate memory for RejectMsg\n");
return 1;
}
while ((c = *src++)) {
if(!isprint(c)) {
logg("!RejectMsg contains non printable characters\n");
free(rejectfmt);
return 1;
}
//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:clamav,代码行数:101,代码来源:clamfi.c
示例18: main
int main (int argc, char **argv) {
int norun;
char *schemaname;
char *sexpr, *ssofile;
char *aexpr, *afile, *asofile;
char *prefix;
char *ccflags, *ldflags;
DDSsplitter_t *splitterp;
struct rlimit rl;
channel_t *chanp;
DDSheader_t hdr;
Sfio_t *ifp;
int ret;
if (AGGRinit () == -1)
SUerror ("ddssplitnaggr", "AGGRinit failed");
DDSinit ();
schemaname = NULL;
sexpr = NULL, ssofile = NULL;
aexpr = NULL, afile = NULL, asofile = NULL;
prefix = "dds.aggr";
classp = "ddssplitnaggr";
keytype = AGGR_TYPE_STRING, keylen = -1;
valtype = AGGR_TYPE_FLOAT, vallen = AGGRtypelens[valtype];
framen = 1;
dictincr = 1, itemincr = 1;
queuen = 1000000;
appendflag = 0;
schemap = NULL;
ccflags = ldflags = "";
norun = 0;
for (;;) {
switch (optget (argv, usage)) {
case -100:
schemaname = opt_info.arg;
continue;
case -230:
sexpr = opt_info.arg;
continue;
case -232:
ssofile = opt_info.arg;
continue;
case -270:
aexpr = opt_info.arg;
continue;
case -271:
afile = opt_info.arg;
continue;
case -272:
asofile = opt_info.arg;
continue;
case -300:
prefix = opt_info.arg;
continue;
case -301:
classp = opt_info.arg;
continue;
case -302:
if (AGGRparsetype (opt_info.arg, &keytype, &keylen) == -1)
SUerror ("ddssplitnaggr", "bad argument for -kt option");
continue;
case -303:
if (AGGRparsetype (opt_info.arg, &valtype, &vallen) == -1)
SUerror ("ddssplitnaggr", "bad argument for -vt option");
continue;
case -304:
framen = opt_info.num;
continue;
case -305:
dictincr = opt_info.num;
continue;
case -306:
itemincr = opt_info.num;
continue;
case -307:
queuen = opt_info.num;
continue;
case -308:
appendflag = 1;
continue;
case -400:
ccflags = opt_info.arg;
continue;
case -401:
ldflags = opt_info.arg;
continue;
case -999:
SUwarnlevel++;
continue;
case '?':
SUusage (0, "ddssplitnaggr", opt_info.arg);
norun = 1;
continue;
case ':':
SUusage (1, "ddssplitnaggr", opt_info.arg);
norun = 2;
continue;
}
break;
}
//.........这里部分代码省略.........
开发者ID:TidyHuang,项目名称:vizgems,代码行数:101,代码来源:ddssplitnaggr.c
示例19: main
int main(int argc, char *argv[])
{
FILE *f;
struct cli_bc *bc;
struct cli_bc_ctx *ctx;
int rc, dbgargc, bc_stats=0;
struct optstruct *opts;
const struct optstruct *opt;
unsigned funcid=0, i;
struct cli_all_bc bcs;
int fd = -1;
unsigned tracelevel;
if(check_flevel())
exit(1);
opts = optparse(NULL, argc, argv, 1, OPT_CLAMBC, 0, NULL);
if (!opts) {
fprintf(stderr, "ERROR: Can't parse command line options\n");
exit(1);
}
if(optget(opts, "version")->enabled) {
printf("Clam AntiVirus Bytecode Testing Tool %s\n", get_version());
cl_init(CL_INIT_DEFAULT);
cli_bytecode_printversion();
optfree(opts);
exit(0);
}
if(optget(opts, "help")->enabled || !opts->filename) {
optfree(opts);
help();
exit(0);
}
f = fopen(opts->filename[0], "r");
if (!f) {
fprintf(stderr, "Unable to load %s\n", argv[1]);
optfree(opts);
exit(2);
}
bc = malloc(sizeof(*bc));
if (!bc) {
fprintf(stderr, "Out of memory\n");
optfree(opts);
exit(3);
}
if (optget(opts,"debug")->enabled) {
cl_debug();
debug_flag=1;
}
rc = cl_init(CL_INIT_DEFAULT);
if (rc != CL_SUCCESS) {
fprintf(stderr,"Unable to init libclamav: %s\n", cl_strerror(rc));
optfree(opts);
exit(4);
}
dbgargc=1;
while (opts->filename[dbgargc]) dbgargc++;
if (dbgargc > 1)
cli_bytecode_debug(dbgargc, opts->filename);
if (optget(opts, "force-interpreter")->enabled) {
bcs.engine = NULL;
} else {
rc = cli_bytecode_init(&bcs);
if (rc != CL_SUCCESS) {
fprintf(stderr,"Unable to init bytecode engine: %s\n", cl_strerror(rc));
optfree(opts);
exit(4);
}
}
bcs.all_bcs = bc;
bcs.count = 1;
if((opt = optget(opts, "statistics"))->enabled) {
while(opt) {
if (!strcasecmp(opt->strarg, "bytecode"))
bc_stats=1;
opt = opt->nextarg;
}
}
rc = cli_bytecode_load(bc, f, NULL, optget(opts, "trust-bytecode")->enabled, bc_stats);
if (rc != CL_SUCCESS) {
fprintf(stderr,"Unable to load bytecode: %s\n", cl_strerror(rc));
optfree(opts);
exit(4);
}
fclose(f);
if (bc->state == bc_skip) {
fprintf(stderr,"bytecode load skipped\n");
exit(0);
}
if (debug_flag)
printf("[clambc] Bytecode loaded\n");
if (optget(opts, "info")->enabled) {
//.........这里部分代码省略.........
开发者ID:vrtadmin,项目名称:clamav-devel,代码行数:101,代码来源:bcrun.c
示例20: main
int main (int argc, char **argv) {
int norun;
int mode;
char *sofile;
char *schemaname, *oschemaname;
DDSschema_t *schemap, *oschemap;
int fieldi;
DDSheader_t hdr;
char buf[10000];
Sfio_t *ifp;
int ret;
char *kexpr;
char *fexpr, *ffile;
char *sexpr;
char *gexpr, *gfile;
char *eexpr;
char *cexpr, *cfile;
char *aexpr, *afile;
char *pexpr, *pfile;
int valtype, vallen;
int fastflag;
char *ccflags, *ldflags;
DDSexpr_t fe;
DDSexpr_t ge;
DDSexpr_t ce;
DDSexpr_t ae;
DDSexpr_t pe;
if (AGGRinit () == -1)
SUerror ("ddscc", "AGGRinit failed");
DDSinit ();
mode = 0;
sofile = "ddsobj.so";
schemaname = oschemaname = NULL;
schemap = NULL, oschemap = NULL;
kexpr = NULL;
fexpr = NULL, ffile = NULL;
sexpr = NULL;
gexpr = NULL, gfile = NULL;
eexpr = NULL;
cexpr = NULL, cfile = NULL;
aexpr = NULL, afile = NULL;
pexpr = NULL, pfile = NULL;
valtype = AGGR_TYPE_INT, vallen = AGGRtypelens[valtype];
fastflag = FALSE;
ccflags = ldflags = "";
norun = 0;
for (;;) {
switch (optget (argv, usage)) {
case -150:
mode = MODE_LOADER;
continue;
case -151:
mode = MODE_SORTER;
continue;
case -152:
mode = MODE_FILTER;
continue;
case -153:
mode = MODE_SPLITTER;
continue;
case -154:
mode = MODE_GROUPER;
continue;
case -155:
mode = MODE_EXTRACTOR;
continue;
case -156:
mode = MODE_CONVERTER;
continue;
case -157:
mode = MODE_COUNTER;
continue;
case -158:
mode = MODE_AGGREGATOR;
continue;
case -159:
mode = MODE_PRINTER;
continue;
case -200:
sofile = opt_info.arg;
continue;
case -100:
schemaname = opt_info.arg;
continue;
case -101:
oschemaname = opt_info.arg;
continue;
case -210:
kexpr = opt_info.arg;
continue;
case -220:
fexpr = opt_info.arg;
continue;
case -221:
ffile = opt_info.arg;
continue;
case -230:
sexpr = opt_info.arg;
continue;
//.........这里部分代码省略.........
开发者ID:TidyHuang,项目名称:vizgems,代码行数:101,代码来源:ddscc.c
注:本文中的optget函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论