Skip to content

Commit

Permalink
Allow skipping checks on archaeologist count
Browse files Browse the repository at this point in the history
  • Loading branch information
a-random-lemurian committed Dec 17, 2023
1 parent 67ddf06 commit c35717e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/ancientpkg/ancientpkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ typedef struct DigControlFlags

/* Location */
char* location;

int force_archaeologists;
} DigControlFlags;

typedef struct Package
Expand Down Expand Up @@ -138,8 +140,8 @@ int dig_common(int archaeologists, int expected_packages, int passes,
* @param expected_packages Expected packages argument
* @return int
*/
int has_missing_args(char *location, int archaeologists, int passes,
int expected_packages);
int has_missing_args(DigControlFlags *dcf, char *location, int archaeologists,
int passes, int expected_packages);


void package_shard_failure(DigControlFlags *dcf, int i, char *pkgname);
Expand Down
5 changes: 4 additions & 1 deletion src/ancientpkg/dig.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ int cmd_dig(int argc, char **argv)
"Include source packages."),
OPT_BOOLEAN(0, "no-proprietary-packages", &dcf.no_proprietary_packages,
"Include only free software."),
OPT_GROUP("Other flags"),
OPT_BOOLEAN(0, "force-archaeologists", &dcf.force_archaeologists,
"Ignore population limit of 8 billion on archaeologists"),
OPT_END()};

const char *usages[] = {
Expand All @@ -78,7 +81,7 @@ int cmd_dig(int argc, char **argv)
dig_from_json(jsonfile);
}

if (has_missing_args(location, archaeologists, passes, expected_packages))
if (has_missing_args(&dcf, location, archaeologists, passes, expected_packages))
{
printf("From the command line: missing arguments.\n");
exit(1);
Expand Down
27 changes: 15 additions & 12 deletions src/ancientpkg/digcommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,27 +245,30 @@ int dig_common(int archaeologists, int expected_packages,
* Check the archaeologists, passes, location, and expected_packages variables
* and ensure that they are valid.
*/
int has_missing_args(char *location, int archaeologists, int passes,
int expected_packages)
int has_missing_args(DigControlFlags *dcf, char *location, int archaeologists,
int passes, int expected_packages)
{
int had_fatal_err = 0;
if (location == NULL)
{
printf(ERROR "location must be specified\n");
had_fatal_err = 1;
}

if (archaeologists <= 1)
{
printf(ERROR "need more than 1 archaeologist.\n");
had_fatal_err = 1;
}

if (archaeologists > 8000000000)
if (!dcf->force_archaeologists)
{
printf(ERROR "Too many archaeologists (not everyone in the world is "
"one,)\n");
had_fatal_err = 1;
if (archaeologists <= 1)
{
printf(ERROR "need more than 1 archaeologist.\n");
had_fatal_err = 1;
}

if (archaeologists > 8000000000)
{
printf(ERROR "Too many archaeologists (not everyone in the world is "
"one,)\n");
had_fatal_err = 1;
}
}

if (passes <= 0)
Expand Down

0 comments on commit c35717e

Please sign in to comment.