diff src/main.c @ 88:af4ed765c1ac

*: add IUP GUI a lot simpler than win32, but I assume there's more going on in the background that I don't know about :)
author Paper <paper@tflc.us>
date Mon, 14 Jul 2025 02:39:24 -0400
parents 1acd477da42f
children
line wrap: on
line diff
--- a/src/main.c	Mon Jul 15 01:35:03 2024 -0400
+++ b/src/main.c	Mon Jul 14 02:39:24 2025 -0400
@@ -9,79 +9,14 @@
 
 #include "common.h"
 
-/* non-portable functions */
-static char* msvpvf_internal_strdup(const char* str) {
-	size_t len = strlen(str) + 1;
-
-	char* copy = malloc(len);
-	if (!copy)
-		return NULL;
-
-	memcpy(copy, str, len);
-	return copy;
-}
-
-static char *msvpvf_internal_asnprintf(const char *format, ...) {
-	va_list args;
-	int needed_size;
-	char *output = NULL;
-
-	va_start(args, format);
-
-	needed_size = vsnprintf(NULL, 0, format, args);
-	if (needed_size < 0)
-		return NULL;
-
-	va_end(args);
-
-	output = malloc((needed_size + 1) * sizeof(char));
-	if (!output)
-		return NULL;
-
-	va_start(args, format);
-
-	needed_size = vsnprintf(output, needed_size + 1, format, args);
-	if (needed_size < 0) {
-		free(output);
-		return NULL;
-	}
-
-	va_end(args);
-
-	return output;
-}
-
-/* source needs read permissions, target needs write permissions, both must be in binary mode */
-static int copy_file(FILE* source, FILE* target) {
-	char ch[4096];
-
-	while (!feof(source)) {
-		size_t b = fread(ch, 1, sizeof(ch), source);
-		if (b)
-			fwrite(ch, 1, b, target);
-	}
-
-	return 0;
-}
-
-static const char* type_names[] = {
-	[TYPES_VF] = "Movie Studio",
-	[TYPES_VEG] = "Vegas Pro",
-	[TYPES_UNKNOWN] = "Unknown",
-};
-
-static const char* type_extensions[] = {
+static const char *type_extensions[] = {
 	[TYPES_VF] = "vf",
 	[TYPES_VEG] = "veg",
 };
 
-#ifndef ARRAYSIZE
-#define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
-#endif
-
 static const char* help_text =
 	"msvpvf help text\n"
-	"author: Paper <paper@paper.us.eu.org>\n"
+	"author: Paper <paper@tflc.us>\n"
 	"usage: %s <input>... (arguments)\n"
 	"\n"
 	"arguments:\n"
@@ -168,13 +103,13 @@
 
 		{
 			/* open the output file... */
-			char* basec = msvpvf_internal_strdup(input);
+			char* basec = str_dup(input);
 			char* bname = basename(basec);
 			int ext = strrchr(bname, '.') - bname;
 
-			char *output = msvpvf_internal_asnprintf("V%u_%.*s.%s", version, ext, bname, type_extensions[type]);
+			char *output = msvpvf_asprintf("V%u_%.*s.%s", version, ext, bname, type_extensions[type]);
 			if (!output) {
-				fprintf(stderr, "[ERROR]: msvpvf_internal_asnprintf failed!\n");
+				fprintf(stderr, "[ERROR]: msvpvf_asprintf failed!\n");
 				free(basec);
 				free(output);
 				fclose(input_file);