Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 6bc13bfb authored by David Parsons's avatar David Parsons
Browse files

View_gener shows last_gener by default

parent 46abf924
No related branches found
No related tags found
No related merge requests found
......@@ -67,7 +67,7 @@ int main(int argc, char* argv[])
// =================================================================
//
// 1) Initialize command-line option variables with default values
int64_t time = 0;
int64_t time = -1;
// 2) Define allowed options
const char * options_list = "hVg:";
......@@ -107,6 +107,25 @@ int main(int argc, char* argv[])
}
}
// Set undefined command line parameters to default values
if (time == -1) {
// Set t_end to the content of the LAST_GENER file if it exists.
// If it doesn't, print help and exit
FILE* lg_file = fopen(LAST_GENER_FNAME, "r");
if (lg_file != NULL) {
if (fscanf(lg_file, "%" PRId64, &time) == EOF) {
printf("ERROR: failed to read last generation from file %s\n",
LAST_GENER_FNAME);
exit(EXIT_FAILURE);
}
fclose(lg_file);
}
else {
printf("%s: error: You must provide a generation number.\n", argv[0]);
exit(EXIT_FAILURE);
}
}
printf("Displaying generation %" PRId64 "...\n", time);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment