aboutsummaryrefslogtreecommitdiff
path: root/src/version.c
diff options
context:
space:
mode:
authorLudvig Gunne Lindström <ludviggunnelindstrom@gmail.com>2026-07-17 11:42:57 +0200
committerLudvig Gunne Lindström <ludviggunnelindstrom@gmail.com>2026-11-08 14:05:19 +0100
commitfd27bacdd9c97f696938b12d2a437da4e514c26f (patch)
tree2d676bb280b35420a2c105676b0e66fe5b91958d /src/version.c
downloadmelisma-archive.tar.gz
Diffstat (limited to 'src/version.c')
-rw-r--r--src/version.c62
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);
+ }
+}