376307a0 |
/*
* Copyright (C) 2007 Tomasz Kojm <tkojm@clamav.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef __MIRMAN_H
#define __MIRMAN_H
|
dd8a6b10 |
#include "freshclamcodes.h"
typedef enum mir_status_tag {
MIRROR_OK=0,
MIRROR_FAILURE,
MIRROR_IGNORE__PREV_ERRS,
MIRROR_IGNORE__OUTDATED_VERSION
} mir_status_t;
typedef enum mir_ignore_tag {
IGNORE_NO=0,
IGNORE_LONGTERM,
IGNORE_SHORTTERM
} mir_ignore_t; |
dd8a6b10 |
/**
* @brief Read mirrors.dat into an existing mirdat structur.
*
* @param file The filename (probably mirrors.dat).
* @param mdat An existing mirdat structure. Must not be NULL.
* @param active 1 - active, 0 - inactive (e.g. when using private mirrors or proxies).
* @return fc_error_t FC_SUCCESS or an error code.
*/
fc_error_t mirman_read(const char *file, struct mirdat *mdat, uint8_t active);
/**
* @brief Check if a mirror is should be ignored, if it's in the mirror table.
*
* Will add the mirror to the table if it isn't in the table.
*
* @param ip The mirror in question.
* @param af AF_INET or AF_INET6.
* @param mdat The mirrors.dat structure.
* @param[out] md A pointer to the mirror in mdat
* @param[out] mirror_status MIRROR_OK or an ignore reason, such as:
* MIRROR_IGNORE__PREV_ERRS or
* MIRROR_IGNORE__OUTDATED_VERSION
* @return fc_error_t FC_SUCCESS or an FCE error code.
*/
fc_error_t mirman_check(uint32_t * ip, int af, struct mirdat *mdat,
struct mirdat_ip **md, mir_status_t *mirror_status);
/**
* @brief Update the mirdat structure with the current mirror status
*
* @param ip IP of current mirror.
* @param af AF_INET or AF_INET6.
* @param mdat The mirrors.dat structure.
* @param error FC_SUCCESS or an FCE error code.
* @return fc_error_t FC_SUCCESS or an FCE error code.
*/
fc_error_t mirman_update(uint32_t * ip, int af, struct mirdat *mdat, fc_error_t mirror_status);
/**
* @brief Print out the mirror info.
*
* @param mdat The mirdat struct.
*/
void mirman_list(const struct mirdat *mdat);
/**
* @brief Remove "ignore" flag on mirrors.
*
* @param mdat Structure
* @param mode 1: Whitelist _all_ mirrors.
* 2: Whitelist only mirrors that were in Short-Term ignore.
*/
void mirman_whitelist(struct mirdat *mdat, unsigned int mode);
/**
* @brief Update mirrors.dat with the current mirdat struct info.
*
* @param file The filename to write to (probably "mirrors.dat")
* @param dir The database directory to store the file in.
* @param mdat The mirdat struct to write to disk.
* @return fc_error_t FC_SUCCESS or an error code.
*/
fc_error_t mirman_write(const char *file, const char *dir, struct mirdat *mdat);
/**
* @brief Free up the mirror table in the mirdat structure.
*
* Does not attempt to free mdat itself.
*
* @param mdat The mirdat structure.
*/
void mirman_free(struct mirdat *mdat); |