diff options
| author | JP Appel <jeanpierre.appel01@gmail.com> | 2024-04-26 13:19:12 -0400 |
|---|---|---|
| committer | JP Appel <jeanpierre.appel01@gmail.com> | 2024-04-26 13:19:12 -0400 |
| commit | 22141040a52c362a60f4feb7d03e4f7d346dcae3 (patch) | |
| tree | c6568e8f5c38f872b275c3aced3ae21095516dc3 /src/fractals.c | |
| parent | c3e492ca3a880411a6a98e60df012cbd6324b629 (diff) | |
add cli options to renderer, improved grid_print
Diffstat (limited to 'src/fractals.c')
| -rw-r--r-- | src/fractals.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/fractals.c b/src/fractals.c index 4d8967e..395ccdb 100644 --- a/src/fractals.c +++ b/src/fractals.c @@ -193,17 +193,21 @@ int main(const int argc, char *argv[]) { } //use "safer" versions of c string functions - if(strncmp(output_filename, "-", 1) && strnlen(output_filename, 16) == 1){ + //likely aren't necessary unless a user can pass non-null terminated strings as arguments, but that would likely break something up in getopt + if(output_filename[0] == '-' && strnlen(output_filename, 16) == 1){ if(write_grid(stdout, grid) == GRID_WRITE_ERROR){ - fprintf(stderr, "Error writing occured while writting to file %s\n", output_filename); + fprintf(stderr, "Error occured while writting to file %s\n", output_filename); } } else { FILE* file = fopen(output_filename, "wb"); - if(write_grid(file, grid) == GRID_WRITE_ERROR){ - fprintf(stderr, "Error writing occured while writting to file %s\n", output_filename); + if(!file){ + perror("Error occured while trying to write"); } - fclose(file); + else if(write_grid(file, grid) == GRID_WRITE_ERROR){ + fprintf(stderr, "Error occured while writting to file %s\n", output_filename); + } + fclose(file); } free(params); |
