summaryrefslogtreecommitdiff
path: root/src/m_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/m_misc.c')
-rw-r--r--src/m_misc.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/src/m_misc.c b/src/m_misc.c
index acab0a5b..4f3becfb 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -2,6 +2,7 @@
//-----------------------------------------------------------------------------
//
// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 1993-2008 Raven Software
// Copyright(C) 2005 Simon Howard
//
// This program is free software; you can redistribute it and/or
@@ -27,6 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <ctype.h>
#include <errno.h>
@@ -42,10 +44,9 @@
#include <sys/types.h>
#endif
-#include "doomdef.h"
-#include "doomstat.h"
+#include "doomtype.h"
-#include "deh_main.h"
+#include "deh_str.h"
#include "i_swap.h"
#include "i_system.h"
@@ -198,3 +199,51 @@ char *M_TempFile(char *s)
return result;
}
+void M_ExtractFileBase(char *path, char *dest)
+{
+ char* src;
+ int length;
+
+ src = path + strlen(path) - 1;
+
+ // back up until a \ or the start
+ while (src != path && *(src - 1) != DIR_SEPARATOR)
+ {
+ src--;
+ }
+
+ // copy up to eight characters
+ memset(dest, 0, 8);
+ length = 0;
+
+ while (*src != '\0' && *src != '.')
+ {
+ ++length;
+
+ if (length > 8)
+ {
+ I_Error ("Filename base of %s >8 chars", path);
+ }
+
+ *dest++ = toupper((int)*src++);
+ }
+}
+
+//---------------------------------------------------------------------------
+//
+// PROC M_ForceUppercase
+//
+// Change string to uppercase.
+//
+//---------------------------------------------------------------------------
+
+void M_ForceUppercase(char *text)
+{
+ char *p;
+
+ for (p = text; *p != '\0'; ++p)
+ {
+ *p = toupper(*p);
+ }
+}
+