17 #define COMPILE (1 << 0)
18 #define ASSEMBLE (1 << 1)
20 #define PIPE_OUT (1 << 3)
21 #define PIPE_IN (1 << 4)
22 #define VERBOSE (1 << 5)
26 int my_getopt(
int argc,
char **argv,
int *stack_size,
int *array_size,
char **output_file,
char **input_file,
int *mode);
27 int compile(FILE *in, FILE *out,
int stack_size,
int array_size);
29 char *
get_as(
int mode,
const char *name,
const char *original,
char **ret);
30 char *
get_obj(
int mode,
const char *name,
const char *original,
char **ret);
31 int get_as_file(
int mode, FILE **out,
const char *name,
const char *input_name);
33 int assemble(
int mode,
const char *as_file,
const char *obj_file);
34 int get_in(
int mode,
const char *input_file, FILE **in);
char * get_as(int mode, const char *name, const char *original, char **ret)
Gets the name of the assembly code file.
void print_help(void)
Prints the help message when "-h" or "--help" are command line arguments.
int get_in(int mode, const char *input_file, FILE **in)
Gets the source code file pointer and deals with IO errors.
int close_as_file(int mode, FILE *f)
Closes the file pointer to the assembly source file.
int my_getopt(int argc, char **argv, int *stack_size, int *array_size, char **output_file, char **input_file, int *mode)
Custom getopt function.
int is_uint(const char *str)
Checks if the given string can represent a positive integer.
int get_as_file(int mode, FILE **out, const char *name, const char *input_name)
Gets the file pointer to the assembly code file.
char * get_obj(int mode, const char *name, const char *original, char **ret)
Gets the name of the assembled file.
int assemble(int mode, const char *as_file, const char *obj_file)
Wrapper around assembling the assembly code.
char * remove_extenstion(const char *str)
Removes the file extension from a string, if there is one at all.
int compile(FILE *in, FILE *out, int stack_size, int array_size)
compiler function