aboutsummaryrefslogtreecommitdiffstats
path: root/src/program/program.c
diff options
context:
space:
mode:
authorGalin Simeonov <gts@volconst.com>2021-06-04 22:49:33 +0300
committerGalin Simeonov <gts@volconst.com>2021-07-15 18:07:29 +0300
commitc875f8795586056a676e8a643a44211041ce44d2 (patch)
tree88bfd4b4923ed30de31b130672dda65e4b18a607 /src/program/program.c
parenta26684a417729699e95b335a3d00798237ffba9b (diff)
downloadMEGATRON-c875f8795586056a676e8a643a44211041ce44d2.tar.gz
various stuffs
Diffstat (limited to 'src/program/program.c')
-rw-r--r--src/program/program.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/program/program.c b/src/program/program.c
index 51757a2..09650ec 100644
--- a/src/program/program.c
+++ b/src/program/program.c
@@ -10,9 +10,15 @@ struct Source* extract_source(char *src_name)
file=fopen(src_name,"r");
if(file==NULL)
- return NULL;
+ {
+ fprintf(stderr,"Could not open source file. ");
+ exit(1);
+ }
if(fseek(file,0L,SEEK_END)!=0)
- return NULL;
+ {
+ fprintf(stderr,"Could not open source file. ");
+ exit(1);
+ }
ret=malloc(sizeof(struct Source));
ret->src_size=ftell(file);
@@ -42,6 +48,9 @@ struct Options* parse_command_line(int argc,char **argv)
ret->src_name=NULL;
ret->output_name=NULL;
ret->is_quiet=0;
+ ret->providing_own_queue_implementation=0;
+ ret->providing_own_buffer_implementation=0;
+ ret->has_mutex=0;
for(i=0;i<argc;++i)
{
@@ -51,6 +60,12 @@ struct Options* parse_command_line(int argc,char **argv)
ret->target=OPTION_TARGET_AST;
else if(!strncmp(argv[i],"--print-c",sizeof("--print-c")))
ret->target=OPTION_TARGET_C;
+ else if(!strncmp(argv[i],"--extern-queue",sizeof("--extern-queue")))
+ ret->providing_own_queue_implementation=1;
+ else if(!strncmp(argv[i],"--extern-buffer",sizeof("--extern-buffer")))
+ ret->providing_own_buffer_implementation=1;
+ else if(!strncmp(argv[i],"--extern-mutex",sizeof("--extern-mutex")))
+ ret->has_mutex=1;
else if(!strncmp(argv[i],"-o",sizeof("-o")) || !strncmp(argv[i],"--output",sizeof("--output")))
{
if(++i<argc)
@@ -59,19 +74,23 @@ struct Options* parse_command_line(int argc,char **argv)
ret->output_name=argv[i];
else if(!ret->is_quiet)
{
- fprintf(stderr,"Error: Output filename is too long");
+ fprintf(stderr,"Error: Output filename is too long\n");
exit(1);
}else
{
exit(1);
}
}
+ }else if(argv[i][0]=='-')
+ {
+ fprintf(stderr,"Error: Invalid command line option %s\n",argv[i]);
+ exit(1);
}else if(strnlen(argv[i],101)<100)
{
ret->src_name=argv[i];
}else if(!ret->is_quiet)
{
- fprintf(stderr,"Error: Input filename is too long");
+ fprintf(stderr,"Error: Input filename is too long\n");
exit(1);
}else
{