summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/os_calls.c47
-rw-r--r--common/os_calls.h4
2 files changed, 47 insertions, 4 deletions
diff --git a/common/os_calls.c b/common/os_calls.c
index 673837fb..24528aa8 100644
--- a/common/os_calls.c
+++ b/common/os_calls.c
@@ -512,7 +512,15 @@ g_file_open(char* file_name)
FILE_SHARE_READ | FILE_SHARE_WRITE,
0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
#else
- return open(file_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+ int rv;
+
+ rv = open(file_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+ if (rv == -1)
+ {
+ /* can't open read / write, try to open read only */
+ rv = open(file_name, O_RDONLY);
+ }
+ return rv;
#endif
}
@@ -903,12 +911,45 @@ g_get_strerror(void)
}
/*****************************************************************************/
-void
+int
g_execvp(char* p1, char* args[])
{
#if defined(_WIN32)
+ return 0;
#else
- execvp(p1, args);
+ return execvp(p1, args);
+#endif
+}
+
+/*****************************************************************************/
+/* takes up to 30 parameters */
+int
+g_execlp(int num_params, char* param1, ...)
+{
+#if defined(_WIN32)
+ return 0;
+#else
+ va_list ap;
+ char* p[32];
+ int index;
+
+ if (num_params > 30)
+ {
+ return 0;
+ }
+ memset(p, 0, sizeof(p));
+ p[0] = param1;
+ va_start(ap, param1);
+ for (index = 1; index < num_params; index++)
+ {
+ p[index] = va_arg(ap, char*);
+ }
+ va_end(ap);
+ return execlp(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
+ p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15],
+ p[16], p[17], p[18], p[19], p[20], p[21], p[22], p[23],
+ p[24], p[25], p[26], p[27], p[28], p[29], p[30], p[31],
+ (void*)0);
#endif
}
diff --git a/common/os_calls.h b/common/os_calls.h
index 52d958ee..fb7e1feb 100644
--- a/common/os_calls.h
+++ b/common/os_calls.h
@@ -139,9 +139,11 @@ int
g_system(char* aexec);
char*
g_get_strerror(void);
-void
+int
g_execvp(char* p1, char* args[]);
int
+g_execlp(int num_params, char* param1, ...);
+int
g_execlp3(char* a1, char* a2, char* a3);
int
g_execlp11(char* a1, char* a2, char* a3, char* a4, char* a5, char* a6,