diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-11-18 09:27:35 -0500 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-11-18 09:27:35 -0500 |
| commit | a9d975389aaf5d79d738517b98161e375e757cba (patch) | |
| tree | 634a4c1a4ddc9fe6b1a7748c980cbc48f58d624a /src/cli/stasis_indexer/callbacks.c | |
| parent | f2cc2cee71c6d2fb0cdd5b7736e86efa4f999c0a (diff) | |
| download | stasis-a9d975389aaf5d79d738517b98161e375e757cba.tar.gz | |
Break down indexer into independent source files
* Generate test result output
* Add helper function to manage changing file extensions
Diffstat (limited to 'src/cli/stasis_indexer/callbacks.c')
| -rw-r--r-- | src/cli/stasis_indexer/callbacks.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/cli/stasis_indexer/callbacks.c b/src/cli/stasis_indexer/callbacks.c new file mode 100644 index 0000000..4790e09 --- /dev/null +++ b/src/cli/stasis_indexer/callbacks.c @@ -0,0 +1,39 @@ +// +// Created by jhunk on 11/15/24. +// + +#include "core.h" +#include "callbacks.h" + +// qsort callback to sort delivery contexts by compact python version +int callback_sort_deliveries_cmpfn(const void *a, const void *b) { + const struct Delivery *delivery1 = (struct Delivery *) a; + const size_t delivery1_python = strtoul(delivery1->meta.python_compact, NULL, 10); + const struct Delivery *delivery2 = (struct Delivery *) b; + const size_t delivery2_python = strtoul(delivery2->meta.python_compact, NULL, 10); + + if (delivery2_python > delivery1_python) { + return 1; + } + if (delivery2_python < delivery1_python) { + return -1; + } + return 0; +} + +// qsort callback to sort dynamically allocated delivery contexts by compact python version +int callback_sort_deliveries_dynamic_cmpfn(const void *a, const void *b) { + const struct Delivery *delivery1 = *(struct Delivery **) a; + const size_t delivery1_python = strtoul(delivery1->meta.python_compact, NULL, 10); + const struct Delivery *delivery2 = *(struct Delivery **) b; + const size_t delivery2_python = strtoul(delivery2->meta.python_compact, NULL, 10); + + if (delivery2_python > delivery1_python) { + return 1; + } + if (delivery2_python < delivery1_python) { + return -1; + } + return 0; +} + |
