summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--draw.c56
-rw-r--r--read_cfg.c32
-rw-r--r--read_cfg.obin11464 -> 11464 bytes
3 files changed, 72 insertions, 16 deletions
diff --git a/draw.c b/draw.c
index 8864d8a..d588b98 100644
--- a/draw.c
+++ b/draw.c
@@ -26,6 +26,9 @@ void switch_col();
void trav_col(int dir); //0 = down, 1 = up
char *get_launch();
char *compat_convert(char *path, int mode);
+#if defined _WIN32 || defined _WIN64
+void win_launch();
+#endif
static int width;
static int height;
@@ -124,19 +127,12 @@ int main(int argc, char **argv){
trav_col(1);
break;
- //FIXME Windows issue calling system() while in an ncurses instance. For Windows, call execl() instead
case 10: //enter key
- full_command = get_launch();
#if defined _WIN32 || defined _WIN64
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- ZeroMemory(&si, sizeof(si));
- si.cb = sizeof(si);
- ZeroMemory(&pi, sizeof(pi));
- if(!CreateProcess(NULL, full_command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) printf("Windows CreateProcess Failed: %d\n", GetLastError());
-
+ win_launch();
#else
+ full_command = get_launch();
system(full_command);
#endif
refresh();
@@ -379,8 +375,8 @@ void trav_col(int dir){
return;
}
-//TODO this looks ugly with all the #ifdefs...
//FIXME account for how Windows does things: ""program.exe" [flags] "file""
+ //There is an issue with flags: needs to be able to have quotation marks
char *get_launch(){
char *program = get_gprog(g[g_hover]);
char *flags = get_gflags(g[g_hover]);
@@ -406,9 +402,7 @@ char *get_launch(){
strcat(full_command, "\"");
if(flags[0] !='\0'){
strcat(full_command, " ");
- strcat(full_command, "\"");
strcat(full_command, flags);
- strcat(full_command, "\"");
}
strcat(full_command, " ");
strcat(full_command, "\"");
@@ -447,3 +441,41 @@ char *compat_convert(char *path, int mode){
return new;
}
+
+#if defined _WIN32 || defined _WIN64
+void win_launch(){
+ char *program = get_gprog(g[g_hover]);
+ char *flags = get_gflags(g[g_hover]);
+ char *path = get_epath(e[e_hover]);
+ char file[BUF_LEN];
+ char params[BUF_LEN];
+
+ file[0] = '\0';
+
+ if(!(strcmp(program, "./"))){
+ strcat(file, "\"");
+ strcat(file, path);
+ strcat(file, "\"");
+ ShellExecute(NULL, NULL, file, NULL, NULL, SW_SHOW);
+ }
+
+ else{
+ strcat(file, "\"");
+ strcat(file, program);
+ strcat(file, "\"");
+
+ params[0] = '\0';
+ if(flags[0] != '\0'){
+ strcat(params, flags);
+ strcat(params, " ");
+ }
+ strcat(params, "\"");
+ strcat(params, path);
+ strcat(params, "\"");
+
+ ShellExecute(NULL, NULL, file, params, NULL, SW_SHOW);
+ }
+
+ return;
+}
+#endif
diff --git a/read_cfg.c b/read_cfg.c
index 74c0e4f..9029d0b 100644
--- a/read_cfg.c
+++ b/read_cfg.c
@@ -108,6 +108,8 @@ void check_line(char *buffer, char **options){
char *tok = strtok(buffer, delims);
char args[MAX_ARGS][BUF_LEN];
GROUP **g;
+ char *tok_p;
+ char *arg_p;
int g_count;
int search_res;
int i;
@@ -129,11 +131,33 @@ void check_line(char *buffer, char **options){
strcpy(args[i], tok);
//handle if an argument has spaces and is wrapped in quotes
if(tok[0] == '"'){
- while(tok[strlen(tok)-1] != '"'){
- tok = strtok(NULL, delims);
- strcat(args[i], " ");
- strcat(args[i], tok);
+ arg_p = &args[i][0];
+ tok_p = &tok[1];
+
+ while(*tok_p != '"'){
+ switch(*tok_p){
+
+
+ case '\0':
+ tok = strtok(NULL, delims);
+ tok_p = &tok[0];
+ *arg_p = ' ';
+ arg_p++;
+ break;
+
+ case '\\':
+ if(*(tok_p+1) == '"') tok_p++;
+
+ default:
+ *arg_p = *tok_p;
+ tok_p++;
+ arg_p++;
+
+ }
}
+
+ *arg_p = '\0';
+
}
tok = strtok(NULL, delims);
diff --git a/read_cfg.o b/read_cfg.o
index 40bd640..34660e3 100644
--- a/read_cfg.o
+++ b/read_cfg.o
Binary files differ