You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
naka/src/version.c

35 lines
668 B

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <version.h>
usize v_ctosn(version_t ver, usize max, char out[static pOUT max])
{
struct v_comp comp = ver.comp;
const char* const fmt = comp.revision ? "%hhu.%hhu.%hhur%hhu" : "%hhu.%hhu.%hhu";
return snprintf(out, max, fmt,
comp.major,
comp.minor,
comp.bugfix,
comp.revision);
}
const char* v_ctoss(version_t ver)
{
_Thread_local static char buffer[VERSION_STRING_MAX+1];
buffer[v_ctosn(ver, VERSION_STRING_MAX+1, buffer)] = 0;
return buffer;
}
char* v_ctos(version_t ver)
{
usize sz = v_ctosn_sz(ver);
char* buf = malloc(sz+1);
v_ctosn(ver, sz+1, buf);
return buf;
}