Selaa lähdekoodia

Reorganize statfiles and classifiers into libstat.

tags/0.9.0
Vsevolod Stakhov 9 vuotta sitten
vanhempi
commit
b5597411a2

+ 1
- 1
CMakeLists.txt Näytä tiedosto

############################# CONFIG SECTION ############################################# ############################# CONFIG SECTION #############################################
# Initial set # Initial set


INCLUDE_DIRECTORIES(src/libutil src/libserver src/libmime)
INCLUDE_DIRECTORIES(src/libutil src/libserver src/libmime src/libstat)


IF(CMAKE_INSTALL_PREFIX) IF(CMAKE_INSTALL_PREFIX)
SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(PREFIX ${CMAKE_INSTALL_PREFIX})

+ 2
- 0
src/CMakeLists.txt Näytä tiedosto

ADD_SUBDIRECTORY(libutil) ADD_SUBDIRECTORY(libutil)
ADD_SUBDIRECTORY(libserver) ADD_SUBDIRECTORY(libserver)
ADD_SUBDIRECTORY(libmime) ADD_SUBDIRECTORY(libmime)
ADD_SUBDIRECTORY(libstat)
ADD_SUBDIRECTORY(client) ADD_SUBDIRECTORY(client)
SET(RSPAMDSRC ${CMAKE_CURRENT_BINARY_DIR}/modules.c SET(RSPAMDSRC ${CMAKE_CURRENT_BINARY_DIR}/modules.c
SET_TARGET_PROPERTIES(rspamd PROPERTIES VERSION ${RSPAMD_VERSION}) SET_TARGET_PROPERTIES(rspamd PROPERTIES VERSION ${RSPAMD_VERSION})
ENDIF(NOT DEBIAN_BUILD) ENDIF(NOT DEBIAN_BUILD)


TARGET_LINK_LIBRARIES(rspamd rspamd-stat)
TARGET_LINK_LIBRARIES(rspamd rspamd-mime) TARGET_LINK_LIBRARIES(rspamd rspamd-mime)
TARGET_LINK_LIBRARIES(rspamd rspamd-server) TARGET_LINK_LIBRARIES(rspamd rspamd-server)
TARGET_LINK_LIBRARIES(rspamd rspamd-util) TARGET_LINK_LIBRARIES(rspamd rspamd-util)

+ 2
- 2
src/controller.c Näytä tiedosto





#include "config.h" #include "config.h"
#include "tokenizers/tokenizers.h"
#include "classifiers/classifiers.h"
#include "tokenizers.h"
#include "classifiers.h"
#include "libserver/dynamic_cfg.h" #include "libserver/dynamic_cfg.h"
#include "libutil/rrd.h" #include "libutil/rrd.h"
#include "libutil/map.h" #include "libutil/map.h"

+ 2
- 2
src/libmime/filter.c Näytä tiedosto

#include "expressions.h" #include "expressions.h"
#include "binlog.h" #include "binlog.h"
#include "diff.h" #include "diff.h"
#include "classifiers/classifiers.h"
#include "tokenizers/tokenizers.h"
#include "classifiers.h"
#include "tokenizers.h"


#ifdef WITH_LUA #ifdef WITH_LUA
# include "lua/lua_common.h" # include "lua/lua_common.h"

+ 1
- 1
src/libmime/message.c Näytä tiedosto

#include "html.h" #include "html.h"
#include "images.h" #include "images.h"
#include "utlist.h" #include "utlist.h"
#include "tokenizers/tokenizers.h"
#include "tokenizers.h"


#include <iconv.h> #include <iconv.h>



+ 1
- 8
src/libserver/CMakeLists.txt Näytä tiedosto

url.c url.c
worker_util.c) worker_util.c)


SET(TOKENIZERSSRC ../tokenizers/tokenizers.c
../tokenizers/osb.c)

SET(CLASSIFIERSSRC ../classifiers/classifiers.c
../classifiers/bayes.c
../classifiers/winnow.c)

# Librspamd-server # Librspamd-server


#IF(WITH_DB) #IF(WITH_DB)
# LIST(APPEND LIBRSPAMDSERVERSRC kvstorage_sqlite.c) # LIST(APPEND LIBRSPAMDSERVERSRC kvstorage_sqlite.c)
#ENDIF(WITH_SQLITE) #ENDIF(WITH_SQLITE)
ADD_LIBRARY(rspamd-server ${LINK_TYPE} ${LIBRSPAMDSERVERSRC} ${TOKENIZERSSRC} ${CLASSIFIERSSRC})
ADD_LIBRARY(rspamd-server ${LINK_TYPE} ${LIBRSPAMDSERVERSRC})
IF(NOT DEBIAN_BUILD) IF(NOT DEBIAN_BUILD)
SET_TARGET_PROPERTIES(rspamd-server PROPERTIES VERSION ${RSPAMD_VERSION}) SET_TARGET_PROPERTIES(rspamd-server PROPERTIES VERSION ${RSPAMD_VERSION})
ENDIF(NOT DEBIAN_BUILD) ENDIF(NOT DEBIAN_BUILD)

+ 1
- 1
src/libserver/binlog.c Näytä tiedosto

#include "config.h" #include "config.h"
#include "binlog.h" #include "binlog.h"
#include "cfg_file.h" #include "cfg_file.h"
#include "tokenizers/tokenizers.h"
#include "tokenizers.h"


#define BINLOG_SUFFIX ".binlog" #define BINLOG_SUFFIX ".binlog"
#define BACKUP_SUFFIX ".old" #define BACKUP_SUFFIX ".old"

+ 2
- 2
src/libserver/cfg_rcl.c Näytä tiedosto

#include "cfg_file.h" #include "cfg_file.h"
#include "lua/lua_common.h" #include "lua/lua_common.h"
#include "expressions.h" #include "expressions.h"
#include "classifiers/classifiers.h"
#include "tokenizers/tokenizers.h"
#include "classifiers.h"
#include "tokenizers.h"




struct rspamd_rcl_default_handler_data { struct rspamd_rcl_default_handler_data {

+ 1
- 1
src/libserver/cfg_utils.c Näytä tiedosto

#include "main.h" #include "main.h"
#include "uthash_strcase.h" #include "uthash_strcase.h"
#include "filter.h" #include "filter.h"
#include "classifiers/classifiers.h"
#include "classifiers.h"
#include "lua/lua_common.h" #include "lua/lua_common.h"
#include "kvstorage_config.h" #include "kvstorage_config.h"
#include "map.h" #include "map.h"

+ 2
- 2
src/libserver/statfile_sync.c Näytä tiedosto



#include "config.h" #include "config.h"
#include "cfg_file.h" #include "cfg_file.h"
#include "tokenizers/tokenizers.h"
#include "classifiers/classifiers.h"
#include "tokenizers.h"
#include "classifiers.h"
#include "statfile.h" #include "statfile.h"
#include "binlog.h" #include "binlog.h"
#include "buffer.h" #include "buffer.h"

+ 27
- 0
src/libstat/CMakeLists.txt Näytä tiedosto

# Librspamdserver
SET(LIBSTATSRC
)
SET(TOKENIZERSSRC tokenizers/tokenizers.c
tokenizers/osb.c)

SET(CLASSIFIERSSRC classifiers/classifiers.c
classifiers/bayes.c
classifiers/winnow.c)
ADD_LIBRARY(rspamd-stat ${LINK_TYPE} ${LIBSTATSRC} ${TOKENIZERSSRC} ${CLASSIFIERSSRC})
IF(NOT DEBIAN_BUILD)
SET_TARGET_PROPERTIES(rspamd-stat PROPERTIES VERSION ${RSPAMD_VERSION})
ENDIF(NOT DEBIAN_BUILD)
SET_TARGET_PROPERTIES(rspamd-stat PROPERTIES LINKER_LANGUAGE C COMPILE_FLAGS "-DRSPAMD_LIB")
TARGET_LINK_LIBRARIES(rspamd-stat rspamd-server)

IF(CMAKE_COMPILER_IS_GNUCC)
SET_TARGET_PROPERTIES(rspamd-stat PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB -fno-strict-aliasing")
ENDIF(CMAKE_COMPILER_IS_GNUCC)


IF(NO_SHARED MATCHES "OFF")
INSTALL(TARGETS rspamd-stat
LIBRARY DESTINATION ${LIBDIR}
PUBLIC_HEADER DESTINATION ${INCLUDEDIR})
ENDIF(NO_SHARED MATCHES "OFF")

src/classifiers/classifiers.h → src/libstat/classifiers.h Näytä tiedosto

#include "config.h" #include "config.h"
#include "mem_pool.h" #include "mem_pool.h"
#include "statfile.h" #include "statfile.h"
#include "tokenizers/tokenizers.h"
#include "tokenizers.h"
#include <lua.h> #include <lua.h>


/* Consider this value as 0 */ /* Consider this value as 0 */

src/classifiers/bayes.c → src/libstat/classifiers/bayes.c Näytä tiedosto

* Bayesian classifier * Bayesian classifier
*/ */
#include "classifiers.h" #include "classifiers.h"
#include "tokenizers/tokenizers.h"
#include "tokenizers.h"
#include "main.h" #include "main.h"
#include "filter.h" #include "filter.h"
#include "cfg_file.h" #include "cfg_file.h"

src/classifiers/classifiers.c → src/libstat/classifiers/classifiers.c Näytä tiedosto


src/classifiers/winnow.c → src/libstat/classifiers/winnow.c Näytä tiedosto

*/ */


#include "classifiers.h" #include "classifiers.h"
#include "tokenizers/tokenizers.h"
#include "tokenizers.h"
#include "main.h" #include "main.h"
#include "filter.h" #include "filter.h"
#include "cfg_file.h" #include "cfg_file.h"

+ 59
- 0
src/libstat/stat_api.h Näytä tiedosto

/* Copyright (c) 2015, Vsevolod Stakhov
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STAT_API_H_
#define STAT_API_H_

#include "config.h"
#include "task.h"

/**
* @file stat_api.h
* High level statistics API
*/

/**
* Initialise statistics modules
* @param cfg
*/
void rspamd_stat_init (struct rspamd_config *cfg);

/**
* Classify the task specified and insert symbols if needed
* @param task
* @return TRUE if task has been classified
*/
gboolean rspamd_stat_classify (struct rspamd_task *task, GError **err);


/**
* Learn task as spam or ham, task must be processed prior to this call
* @param task task to learn
* @param spam if TRUE learn spam, otherwise learn ham
* @return TRUE if task has been learned
*/
gboolean rspamd_stat_learn (struct rspamd_task *task, gboolean spam, GError **err);


void rspamd_stat_unload (void);

#endif /* STAT_API_H_ */

src/tokenizers/tokenizers.h → src/libstat/tokenizers.h Näytä tiedosto


src/tokenizers/osb.c → src/libstat/tokenizers/osb.c Näytä tiedosto


src/tokenizers/tokenizers.c → src/libstat/tokenizers/tokenizers.c Näytä tiedosto


+ 1
- 1
src/lua/lua_classifier.c Näytä tiedosto



#include "lua_common.h" #include "lua_common.h"
#include "cfg_file.h" #include "cfg_file.h"
#include "classifiers/classifiers.h"
#include "classifiers.h"


/* Classifier methods */ /* Classifier methods */
LUA_FUNCTION_DEF (classifier, register_pre_callback); LUA_FUNCTION_DEF (classifier, register_pre_callback);

+ 1
- 1
src/lua/lua_config.c Näytä tiedosto

#include "message.h" #include "message.h"
#include "radix.h" #include "radix.h"
#include "trie.h" #include "trie.h"
#include "classifiers/classifiers.h"
#include "classifiers.h"


/*** /***
* This module is used to configure rspamd and is normally available as global * This module is used to configure rspamd and is normally available as global

+ 2
- 2
src/lua/lua_task.c Näytä tiedosto

#include "images.h" #include "images.h"
#include "cfg_file.h" #include "cfg_file.h"
#include "statfile.h" #include "statfile.h"
#include "tokenizers/tokenizers.h"
#include "classifiers/classifiers.h"
#include "tokenizers.h"
#include "classifiers.h"
#include "binlog.h" #include "binlog.h"
#include "statfile_sync.h" #include "statfile_sync.h"
#include "diff.h" #include "diff.h"

Loading…
Peruuta
Tallenna