ClamAV学习【6】—— cli_load函数浏览

来源:互联网 发布:在手机淘宝上购物流程 编辑:程序博客网 时间:2024/05/17 02:18

(老爸回家,就放开心和他到处走,累……趁其和老妈聊天之际,再继续看代码)

参数选项,加载病毒都浏览得七七八八了,这里就贴个简单的函数注释吧。哈哈。

代码注释如下:

int cli_load(const char *filename, struct cl_engine **engine, unsigned int *signo, unsigned int options, struct cli_dbio *dbio){FILE *fs = NULL;int ret = CL_SUCCESS;uint8_t skipped = 0;const char *dbname;//打开病毒库文件    if(!dbio && (fs = fopen(filename, "rb")) == NULL) {cli_errmsg("cli_load(): Can't open file %s\n", filename);return CL_EOPEN;    }//不清楚下面宏定义为啥被忽略了//路径分隔符windows的应该不是/的/*#ifdef C_WINDOWS    if((dbname = strrchr(filename, '\\')))#else*///将dbname定位到文件名位置    if((dbname = strrchr(filename, '/')))/*#endif */dbname++;    elsedbname = filename;//判断拓展名//不同类型病毒库(临时生成)调用不同方法    if(cli_strbcasestr(dbname, ".db")) {ret = cli_loaddb(fs, engine, signo, options, dbio, dbname);    } else if(cli_strbcasestr(dbname, ".cvd")) {    int warn = 0;//判断是否为daily.cvd文件if(!strcmp(dbname, "daily.cvd"))    warn = 1;//调用cvdload加载病毒库ret = cli_cvdload(fs, engine, signo, warn, options, 0);    } else if(cli_strbcasestr(dbname, ".cld")) {    int warn = 0;if(!strcmp(dbname, "daily.cld"))    warn = 1;ret = cli_cvdload(fs, engine, signo, warn, options | CL_DB_CVDNOTMP, 1);    } else if(cli_strbcasestr(dbname, ".hdb")) {ret = cli_loadmd5(fs, engine, signo, MD5_HDB, options, dbio, dbname);    } else if(cli_strbcasestr(dbname, ".hdu")) {if(options & CL_DB_PUA)    ret = cli_loadmd5(fs, engine, signo, MD5_HDB, options, dbio, dbname);else    skipped = 1;    } else if(cli_strbcasestr(dbname, ".fp")) {ret = cli_loadmd5(fs, engine, signo, MD5_FP, options, dbio, dbname);    } else if(cli_strbcasestr(dbname, ".mdb")) {ret = cli_loadmd5(fs, engine, signo, MD5_MDB, options, dbio, dbname);    } else if(cli_strbcasestr(dbname, ".mdu")) {if(options & CL_DB_PUA)    ret = cli_loadmd5(fs, engine, signo, MD5_MDB, options, dbio, dbname);else    skipped = 1;    } else if(cli_strbcasestr(dbname, ".ndb")) {ret = cli_loadndb(fs, engine, signo, 0, options, dbio, dbname);    } else if(cli_strbcasestr(dbname, ".ndu")) {if(!(options & CL_DB_PUA))    skipped = 1;else    ret = cli_loadndb(fs, engine, signo, 0, options, dbio, dbname);    } else if(cli_strbcasestr(dbname, ".sdb")) {ret = cli_loadndb(fs, engine, signo, 1, options, dbio, dbname);    } else if(cli_strbcasestr(dbname, ".zmd")) {ret = cli_loadmd(fs, engine, signo, 1, options, dbio, dbname);    } else if(cli_strbcasestr(dbname, ".rmd")) {ret = cli_loadmd(fs, engine, signo, 2, options, dbio, dbname);    } else if(cli_strbcasestr(dbname, ".cfg")) {ret = cli_dconf_load(fs, engine, options, dbio);    } else if(cli_strbcasestr(dbname, ".wdb")) {if(options & CL_DB_PHISHING_URLS) {    ret = cli_loadwdb(fs, engine, options, dbio);} else    skipped = 1;    } else if(cli_strbcasestr(dbname, ".pdb")) {if(options & CL_DB_PHISHING_URLS) {    ret = cli_loadpdb(fs, engine, options, dbio);} else    skipped = 1;    } else if(cli_strbcasestr(dbname, ".ftm")) {ret = cli_loadftm(fs, engine, options, 0, dbio);    } else if(cli_strbcasestr(dbname, ".ign")) {ret = cli_loadign(fs, engine, options, dbio);    } else {cli_dbgmsg("cli_load: unknown extension - assuming old database format\n");ret = cli_loaddb(fs, engine, signo, options, dbio, dbname);    }//判断病毒库加载是否成功    if(ret) {cli_errmsg("Can't load %s: %s\n", filename, cl_strerror(ret));    } else  {if(skipped)    cli_dbgmsg("%s skipped\n", filename);else    cli_dbgmsg("%s loaded\n", filename);    }    if(fs)fclose(fs);    return ret;}


原创粉丝点击