brainfuck  0.1
A full fledged brainfuck compiler
common.h
Go to the documentation of this file.
1 
9 #ifndef COMMON_H
10 #define COMMON_H
11 
12 #include <stdio.h> /* FILE */
13 
17 #define COMPILE (1 << 0)
18 #define ASSEMBLE (1 << 1)
19 #define LINK (1 << 2)
20 #define PIPE_OUT (1 << 3)
21 #define PIPE_IN (1 << 4)
22 #define VERBOSE (1 << 5)
23 
24 int is_uint(const char *str);
25 void print_help(void);
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);
28 char *remove_extenstion(const char *str);
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);
32 int close_as_file(int mode, FILE *f);
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);
35 #endif
char * get_as(int mode, const char *name, const char *original, char **ret)
Gets the name of the assembly code file.
Definition: common.c:153
void print_help(void)
Prints the help message when "-h" or "--help" are command line arguments.
Definition: common.c:38
int get_in(int mode, const char *input_file, FILE **in)
Gets the source code file pointer and deals with IO errors.
Definition: common.c:310
int close_as_file(int mode, FILE *f)
Closes the file pointer to the assembly source file.
Definition: common.c:267
int my_getopt(int argc, char **argv, int *stack_size, int *array_size, char **output_file, char **input_file, int *mode)
Custom getopt function.
Definition: common.c:71
int is_uint(const char *str)
Checks if the given string can represent a positive integer.
Definition: common.c:23
int get_as_file(int mode, FILE **out, const char *name, const char *input_name)
Gets the file pointer to the assembly code file.
Definition: common.c:217
char * get_obj(int mode, const char *name, const char *original, char **ret)
Gets the name of the assembled file.
Definition: common.c:184
int assemble(int mode, const char *as_file, const char *obj_file)
Wrapper around assembling the assembly code.
Definition: common.c:289
char * remove_extenstion(const char *str)
Removes the file extension from a string, if there is one at all.
Definition: common.c:125
int compile(FILE *in, FILE *out, int stack_size, int array_size)
compiler function
Definition: compiler.c:28