
#ifndef ETHERCAT_UTILS_VERSION_INFO_H
#define ETHERCAT_UTILS_VERSION_INFO_H

#pragma once

#include "../ethercat_types.h"
#include <stdint.h>
#include <stdio.h>

#ifdef __cplusplus
extern "C" {
#endif

static inline int format_version(const version_info_t* info,
                                        char* buf, int buf_size)
{
    if (!info || !buf || buf_size <= 0) return 0;

    if (info->build != 0) {
        return snprintf(buf, buf_size, "%u.%u.%u.%u",
                        info->major, info->minor, info->patch, info->build);
    } else {
        return snprintf(buf, buf_size, "%u.%u.%u",
                        info->major, info->minor, info->patch);
    }
}

#ifdef __cplusplus
}
#endif

#endif
