/*
 * Copyright (C) 2026 Jakub Kruszona-Zawadzki, Saglabs SA
 * 
 * This file is part of MooseFS.
 * 
 * MooseFS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 2 (only).
 * 
 * MooseFS 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, see
 * <https://www.gnu.org/licenses/>.
 */

#ifndef _CHANGELOG_H_
#define _CHANGELOG_H_

#include <inttypes.h>

#if defined(__printflike)
#	define PRINTF_LIKE(fmt, args) __printflike(fmt, args)
#elif defined(__GNUC__) || defined(__clang__)
#	define PRINTF_LIKE(fmt, args) __attribute__((format(printf, fmt, args)))
#else
#	define PRINTF_LIKE(fmt, args)
#endif

uint32_t changelog_get_old_changes(uint64_t version,void (*sendfn)(void *,uint64_t,uint8_t *,uint32_t),void *userdata,uint32_t limit);
uint64_t changelog_get_minversion(void);

#define ROTATE_FLAG_BROADCAST 1
#define ROTATE_FLAG_FOREGROUND 2

void changelog_rotate(uint8_t rotate_flags);
void changelog_mr(uint64_t version,const char *data);

void changelog(const char *format,...) PRINTF_LIKE(1, 2);

char* changelog_generate_gids(uint32_t gids,uint32_t *gid);
char* changelog_escape_name(uint32_t nleng,const uint8_t *name);
int changelog_init(void);

uint64_t changelog_findfirstversion(const char *fname);
uint64_t changelog_findlastversion(const char *fname);
int changelog_checkname(const char *fname);

#endif
