diff options
| author | Ludvig Gunne Lindström <ludviggunnelindstrom@gmail.com> | 2026-07-17 11:42:57 +0200 |
|---|---|---|
| committer | Ludvig Gunne Lindström <ludviggunnelindstrom@gmail.com> | 2026-11-08 14:07:53 +0100 |
| commit | 98b3c66ebc79597f5b54fff132eaafbebf581248 (patch) | |
| tree | f999ec466ae3ac635653d1fe0a6a6dd1a2f2c3b0 /src/version.c | |
| download | melisma-98b3c66ebc79597f5b54fff132eaafbebf581248.tar.gz | |
Diffstat (limited to 'src/version.c')
| -rw-r--r-- | src/version.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/version.c b/src/version.c new file mode 100644 index 0000000..2213bc6 --- /dev/null +++ b/src/version.c @@ -0,0 +1,62 @@ +/* + * melisma - extensible and scriptable audio engine + * Copyright (C) 2026 Ludvig Gunne Lindström + * + * This program 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, either version 3 of the License, or + * (at your option) any later version. + * + * 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, see <https://www.gnu.org/licenses/>. + */ + +#include <stdlib.h> +#include <string.h> +#include <assert.h> +#include "melisma.h" +#include <lauxlib.h> + +struct semver +{ + int major; + int minor; + int patch; +}; + +static void parse(struct semver *out, const char *str) +{ + const char *tok; + char buf[32]; + + strcpy(buf, str); + + assert((tok = strtok(buf, "."))); + out->major = atoi(tok); + + assert((tok = strtok(NULL, "."))); + out->minor = atoi(tok); + + assert((tok = strtok(NULL, "."))); + out->patch = atoi(tok); +} + +void ml__check_version(const char *s) +{ + extern lua_State *state; + struct semver melisma, module; + + parse(&melisma,MELISMA_VERSION); + parse(&module,s); + + if (melisma.major != module.major) + { + luaL_error(state,"Mismatching versions (melisma: %s, module: %s)", + MELISMA_VERSION,s); + } +} |
