/*
 * Copyright (C) 2023 Hasl Developers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
 */

#ifndef HASL_VERSION_H
#define HASL_VERSION_H

#include <glib.h>

#include <hasl/haslversionconsts.h>

G_BEGIN_DECLS

/**
 * HASL_CHECK_VERSION:
 * @major: The major version to check for.
 * @minor: The minor version to check for.
 * @micro: The micro version to check for.
 *
 * Checks the version of hasl being compiled against. See [func@check_version]
 * for a runtime check.
 *
 * Returns: %TRUE if the version is the same or newer than the passed-in
 *          version.
 *
 * Since: 0.2.0
 */
#define HASL_CHECK_VERSION(major, minor, micro) ((major) == HASL_MAJOR_VERSION && \
                                                 ((minor) < HASL_MINOR_VERSION || \
                                                  ((minor) == HASL_MINOR_VERSION && (micro) <= HASL_MICRO_VERSION)))

/**
 * hasl_check_version:
 * @required_major: the required major version.
 * @required_minor: the required minor version.
 * @required_micro: the required micro version.
 *
 * Checks that the hasl version is compatible with the requested version.
 *
 * Returns: %NULL if the versions are compatible, or a string describing
 *          the version mismatch if not compatible.
 *
 * Since: 0.2.0
 */
const char *hasl_check_version(guint required_major, guint required_minor, guint required_micro);

/**
 * hasl_version:
 *
 * The full version string of the running hasl.
 *
 * Since: 0.2.0
 */
extern const char *hasl_version;

/**
 * hasl_major_version:
 *
 * The major version of the running hasl. Contrast with #HASL_MAJOR_VERSION,
 * which expands at compile time to the major version of hasl being compiled
 * against.
 *
 * Since: 0.2.0
 */
extern const guint hasl_major_version;

/**
 * hasl_minor_version:
 *
 * The minor version of the running hasl. Contrast with #HASL_MINOR_VERSION,
 * which expands at compile time to the minor version of hasl being compiled
 * against.
 *
 * Since: 0.2.0
 */
extern const guint hasl_minor_version;

/**
 * hasl_micro_version:
 *
 * The micro version of the running hasl. Contrast with #HASL_MICRO_VERSION,
 * which expands at compile time to the micro version of hasl being compiled
 * against.
 *
 * Since: 0.2.0
 */
extern const guint hasl_micro_version;

G_END_DECLS

#endif /* HASL_VERSION_CONSTS_H */
