Spawn is creating the processes correctly now
This commit is contained in:
parent
0284bc6ebc
commit
9de58d6d9c
18
cc.c
18
cc.c
|
@ -42,8 +42,10 @@ int main(int argc, char** argv, char** envp)
|
||||||
FUZZING = FALSE;
|
FUZZING = FALSE;
|
||||||
MAX_STRING = 4096;
|
MAX_STRING = 4096;
|
||||||
PREPROCESSOR_MODE = FALSE;
|
PREPROCESSOR_MODE = FALSE;
|
||||||
|
int debug_flag = TRUE;
|
||||||
FILE* in = stdin;
|
FILE* in = stdin;
|
||||||
FILE* tempfile;
|
FILE* tempfile;
|
||||||
|
char* destination_name = "/dev/stdout";
|
||||||
FILE* destination_file = stdout;
|
FILE* destination_file = stdout;
|
||||||
init_macro_env("__M2__", "42", "__INTERNAL_M2__", 0); /* Setup __M2__ */
|
init_macro_env("__M2__", "42", "__INTERNAL_M2__", 0); /* Setup __M2__ */
|
||||||
char* name;
|
char* name;
|
||||||
|
@ -172,13 +174,21 @@ int main(int argc, char** argv, char** envp)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char* filename = calloc(100, sizeof(char));
|
name = calloc(100, sizeof(char));
|
||||||
strcpy(filename, "/tmp/M2-Mesoplanet-XXXXXX");
|
strcpy(name, "/tmp/M2-Mesoplanet-XXXXXX");
|
||||||
i = mkstemp(filename);
|
i = mkstemp(name);
|
||||||
tempfile = fdopen(i, "rw");
|
tempfile = fdopen(i, "w+");
|
||||||
if(NULL != tempfile)
|
if(NULL != tempfile)
|
||||||
{
|
{
|
||||||
|
/* Our preprocessed crap */
|
||||||
output_tokens(global_token, tempfile);
|
output_tokens(global_token, tempfile);
|
||||||
|
fclose(tempfile);
|
||||||
|
|
||||||
|
/* Make me a real binary */
|
||||||
|
spawn_processes(debug_flag, name, destination_name, envp);
|
||||||
|
|
||||||
|
/* And clean up the donkey */
|
||||||
|
remove(name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,7 +38,6 @@ int MAX_STRING;
|
||||||
int PREPROCESSOR_MODE;
|
int PREPROCESSOR_MODE;
|
||||||
|
|
||||||
/* enable spawn behavior to be effective */
|
/* enable spawn behavior to be effective */
|
||||||
char* PATH;
|
|
||||||
char* M2LIBC_PATH;
|
char* M2LIBC_PATH;
|
||||||
|
|
||||||
/* So we don't shoot ourself in the face */
|
/* So we don't shoot ourself in the face */
|
||||||
|
|
|
@ -39,7 +39,6 @@ extern long MAX_STRING;
|
||||||
extern int PREPROCESSOR_MODE;
|
extern int PREPROCESSOR_MODE;
|
||||||
|
|
||||||
/* enable spawn behavior to be effective */
|
/* enable spawn behavior to be effective */
|
||||||
extern char* PATH;
|
|
||||||
extern char* M2LIBC_PATH;
|
extern char* M2LIBC_PATH;
|
||||||
extern char* Architecture;
|
extern char* Architecture;
|
||||||
extern int WORDSIZE;
|
extern int WORDSIZE;
|
||||||
|
|
70
cc_spawn.c
70
cc_spawn.c
|
@ -47,6 +47,8 @@ char* find_char(char* string, char a)
|
||||||
/* Find the full path to an executable */
|
/* Find the full path to an executable */
|
||||||
char* find_executable(char* name)
|
char* find_executable(char* name)
|
||||||
{
|
{
|
||||||
|
char* PATH = env_lookup("PATH");
|
||||||
|
require(NULL != PATH, "No PATH found\nAborting\n");
|
||||||
if(match("", name))
|
if(match("", name))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -186,12 +188,13 @@ int spawn_hex2(char* input, char* output, char* architecture, char** envp, int d
|
||||||
{
|
{
|
||||||
/* TODO FINISH */
|
/* TODO FINISH */
|
||||||
char** array = calloc(MAX_ARRAY, sizeof(char*));
|
char** array = calloc(MAX_ARRAY, sizeof(char*));
|
||||||
insert_array(array, 0, "--file");
|
insert_array(array, 0, "hex2");
|
||||||
insert_array(array, 1, input);
|
insert_array(array, 1, "--file");
|
||||||
insert_array(array, 2, "--output");
|
insert_array(array, 2, input);
|
||||||
insert_array(array, 3, output);
|
insert_array(array, 3, "--output");
|
||||||
insert_array(array, 4, "--architecture");
|
insert_array(array, 4, output);
|
||||||
insert_array(array, 5, architecture);
|
insert_array(array, 5, "--architecture");
|
||||||
|
insert_array(array, 6, architecture);
|
||||||
int r = _execute("hex2", array, envp);
|
int r = _execute("hex2", array, envp);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -200,23 +203,24 @@ int spawn_hex2(char* input, char* output, char* architecture, char** envp, int d
|
||||||
int spawn_M1(char* input, char* debug_file, char* output, char* architecture, char** envp, int debug_flag)
|
int spawn_M1(char* input, char* debug_file, char* output, char* architecture, char** envp, int debug_flag)
|
||||||
{
|
{
|
||||||
char** array = calloc(MAX_ARRAY, sizeof(char*));
|
char** array = calloc(MAX_ARRAY, sizeof(char*));
|
||||||
insert_array(array, 0, "--file");
|
insert_array(array, 0, "M1");
|
||||||
insert_array(array, 1, input);
|
insert_array(array, 1, "--file");
|
||||||
|
insert_array(array, 2, input);
|
||||||
if(debug_flag)
|
if(debug_flag)
|
||||||
{
|
{
|
||||||
insert_array(array, 2, "--file");
|
insert_array(array, 3, "--file");
|
||||||
insert_array(array, 3, debug_file);
|
insert_array(array, 4, debug_file);
|
||||||
insert_array(array, 4, "--output");
|
insert_array(array, 5, "--output");
|
||||||
insert_array(array, 5, output);
|
insert_array(array, 6, output);
|
||||||
insert_array(array, 6, "--architecture");
|
insert_array(array, 7, "--architecture");
|
||||||
insert_array(array, 7, architecture);
|
insert_array(array, 8, architecture);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
insert_array(array, 2, "--output");
|
insert_array(array, 3, "--output");
|
||||||
insert_array(array, 3, output);
|
insert_array(array, 4, output);
|
||||||
insert_array(array, 4, "--architecture");
|
insert_array(array, 5, "--architecture");
|
||||||
insert_array(array, 5, architecture);
|
insert_array(array, 6, architecture);
|
||||||
}
|
}
|
||||||
int r = _execute("M1", array, envp);
|
int r = _execute("M1", array, envp);
|
||||||
return r;
|
return r;
|
||||||
|
@ -226,13 +230,14 @@ int spawn_M1(char* input, char* debug_file, char* output, char* architecture, ch
|
||||||
int spawn_blood_elf(char* input, char* output, char* architecture, char** envp, int large_flag)
|
int spawn_blood_elf(char* input, char* output, char* architecture, char** envp, int large_flag)
|
||||||
{
|
{
|
||||||
char** array = calloc(MAX_ARRAY, sizeof(char*));
|
char** array = calloc(MAX_ARRAY, sizeof(char*));
|
||||||
insert_array(array, 0, "--file");
|
insert_array(array, 0, "blood-elf");
|
||||||
insert_array(array, 1, input);
|
insert_array(array, 1, "--file");
|
||||||
insert_array(array, 2, "--output");
|
insert_array(array, 2, input);
|
||||||
insert_array(array, 3, output);
|
insert_array(array, 3, "--output");
|
||||||
insert_array(array, 4, "--architecture");
|
insert_array(array, 4, output);
|
||||||
insert_array(array, 5, architecture);
|
insert_array(array, 5, "--architecture");
|
||||||
if(large_flag) insert_array(array, 6, "--64");
|
insert_array(array, 6, architecture);
|
||||||
|
if(large_flag) insert_array(array, 7, "--64");
|
||||||
int r = _execute("blood-elf", array, envp);
|
int r = _execute("blood-elf", array, envp);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -240,13 +245,14 @@ int spawn_blood_elf(char* input, char* output, char* architecture, char** envp,
|
||||||
int spawn_M2(char* input, char* output, char* architecture, char** envp, int debug_flag)
|
int spawn_M2(char* input, char* output, char* architecture, char** envp, int debug_flag)
|
||||||
{
|
{
|
||||||
char** array = calloc(MAX_ARRAY, sizeof(char*));
|
char** array = calloc(MAX_ARRAY, sizeof(char*));
|
||||||
insert_array(array, 0, "--file");
|
insert_array(array, 0, "M2-Planet");
|
||||||
insert_array(array, 1, input);
|
insert_array(array, 1, "--file");
|
||||||
insert_array(array, 2, "--output");
|
insert_array(array, 2, input);
|
||||||
insert_array(array, 3, output);
|
insert_array(array, 3, "--output");
|
||||||
insert_array(array, 4, "--architecture");
|
insert_array(array, 4, output);
|
||||||
insert_array(array, 5, architecture);
|
insert_array(array, 5, "--architecture");
|
||||||
if(debug_flag) insert_array(array, 6, "--debug");
|
insert_array(array, 6, architecture);
|
||||||
|
if(debug_flag) insert_array(array, 7, "--debug");
|
||||||
int r = _execute("M2-Planet", array, envp);
|
int r = _execute("M2-Planet", array, envp);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
3
makefile
3
makefile
|
@ -25,13 +25,14 @@ CFLAGS:=$(CFLAGS) -D_GNU_SOURCE -O0 -std=c99 -ggdb
|
||||||
|
|
||||||
all: M2-Mesoplanet
|
all: M2-Mesoplanet
|
||||||
|
|
||||||
M2-Mesoplanet: bin results cc.h cc_reader.c cc_core.c cc.c cc_globals.c cc_globals.h
|
M2-Mesoplanet: bin results cc.h cc_reader.c cc_core.c cc_macro.c cc_env.c cc_spawn.c cc.c cc_globals.c cc_globals.h
|
||||||
$(CC) $(CFLAGS) \
|
$(CC) $(CFLAGS) \
|
||||||
M2libc/bootstrappable.c \
|
M2libc/bootstrappable.c \
|
||||||
cc_reader.c \
|
cc_reader.c \
|
||||||
cc_core.c \
|
cc_core.c \
|
||||||
cc_macro.c \
|
cc_macro.c \
|
||||||
cc_env.c \
|
cc_env.c \
|
||||||
|
cc_spawn.c \
|
||||||
cc.c \
|
cc.c \
|
||||||
cc.h \
|
cc.h \
|
||||||
cc_globals.c \
|
cc_globals.c \
|
||||||
|
|
Loading…
Reference in New Issue