summaryrefslogtreecommitdiff
path: root/src/m_argv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/m_argv.c')
-rw-r--r--src/m_argv.c61
1 files changed, 50 insertions, 11 deletions
diff --git a/src/m_argv.c b/src/m_argv.c
index 4d321bbc..59381b65 100644
--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <string.h>
-#include "doomdef.h"
+#include "doomtype.h"
#include "i_system.h"
#include "m_misc.h"
@@ -60,13 +60,25 @@ int M_CheckParmWithArgs(char *check, int num_args)
return 0;
}
+//
+// M_ParmExists
+//
+// Returns true if the given parameter exists in the program's command
+// line arguments, false if not.
+//
+
+boolean M_ParmExists(char *check)
+{
+ return M_CheckParm(check) != 0;
+}
+
int M_CheckParm(char *check)
{
return M_CheckParmWithArgs(check, 0);
}
#define MAXARGVS 100
-
+
static void LoadResponseFile(int argv_index)
{
FILE *handle;
@@ -95,14 +107,23 @@ static void LoadResponseFile(int argv_index)
// Read in the entire file
// Allocate one byte extra - this is in case there is an argument
- // at the end of the response file, in which case a '\0' will be
+ // at the end of the response file, in which case a '\0' will be
// needed.
file = malloc(size + 1);
- if (fread(file, 1, size, handle) < size)
+ i = 0;
+
+ while (i < size)
{
- I_Error("Failed to read entire response file");
+ k = fread(file + i, 1, size - i, handle);
+
+ if (k < 0)
+ {
+ I_Error("Failed to read full contents of '%s'", response_filename);
+ }
+
+ i += k;
}
fclose(handle);
@@ -120,7 +141,7 @@ static void LoadResponseFile(int argv_index)
newargv[i] = myargv[i];
++newargc;
}
-
+
infile = file;
k = 0;
@@ -131,7 +152,7 @@ static void LoadResponseFile(int argv_index)
while(k < size && isspace(infile[k]))
{
++k;
- }
+ }
if (k >= size)
{
@@ -142,7 +163,7 @@ static void LoadResponseFile(int argv_index)
// the contents as a single argument. This allows long filenames
// to be specified.
- if (infile[k] == '\"')
+ if (infile[k] == '\"')
{
// Skip the first character(")
++k;
@@ -156,9 +177,9 @@ static void LoadResponseFile(int argv_index)
++k;
}
- if (k >= size || infile[k] == '\n')
+ if (k >= size || infile[k] == '\n')
{
- I_Error("Quotes unclosed in response file '%s'",
+ I_Error("Quotes unclosed in response file '%s'",
response_filename);
}
@@ -184,7 +205,7 @@ static void LoadResponseFile(int argv_index)
++k;
}
- }
+ }
// Add arguments following the response file argument
@@ -227,3 +248,21 @@ void M_FindResponseFile(void)
}
}
+// Return the name of the executable used to start the program:
+
+char *M_GetExecutableName(void)
+{
+ char *sep;
+
+ sep = strrchr(myargv[0], DIR_SEPARATOR);
+
+ if (sep == NULL)
+ {
+ return myargv[0];
+ }
+ else
+ {
+ return sep + 1;
+ }
+}
+