-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
237 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "axl.h" | ||
#include "axl_internal.h" | ||
|
||
#include "kvtree.h" | ||
#include "kvtree_util.h" | ||
|
||
int | ||
main(void) { | ||
int rc; | ||
kvtree* axl_config_values = kvtree_new(); | ||
|
||
size_t old_axl_file_buf_size = axl_file_buf_size; | ||
int old_axl_debug = axl_debug; | ||
int old_axl_make_directories = axl_make_directories; | ||
int old_axl_copy_metadata = axl_copy_metadata; | ||
|
||
rc = AXL_Init(); | ||
if (rc != AXL_SUCCESS) { | ||
printf("AXL_Init() failed (error %d)\n", rc); | ||
return rc; | ||
} | ||
|
||
/* check AXL configuration settings */ | ||
rc = kvtree_util_set_bytecount(axl_config_values, | ||
AXL_KEY_CONFIG_FILE_BUF_SIZE, | ||
old_axl_file_buf_size + 1); | ||
if (rc != KVTREE_SUCCESS) { | ||
printf("kvtree_util_set_bytecount failed (error %d)\n", rc); | ||
return rc; | ||
} | ||
rc = kvtree_util_set_int(axl_config_values, AXL_KEY_CONFIG_DEBUG, | ||
!old_axl_debug); | ||
if (rc != KVTREE_SUCCESS) { | ||
printf("kvtree_util_set_int failed (error %d)\n", rc); | ||
return rc; | ||
} | ||
|
||
printf("Configuring AXL (first set of options)...\n"); | ||
if (AXL_Config(-1, axl_config_values) == NULL) { | ||
printf("AXL_Config() failed\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
/* check that options were set */ | ||
|
||
if (axl_file_buf_size != old_axl_file_buf_size + 1) { | ||
printf("AXL_Config() failed to set %s: %lu != %lu\n", | ||
AXL_KEY_CONFIG_FILE_BUF_SIZE, (long unsigned)axl_file_buf_size, | ||
(long unsigned)(old_axl_file_buf_size + 1)); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (axl_debug != !old_axl_debug) { | ||
printf("AXL_Config() failed to set %s: %d != %d\n", | ||
AXL_KEY_CONFIG_DEBUG, axl_debug, !old_axl_debug); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
/* set remainder of options */ | ||
kvtree_delete(&axl_config_values); | ||
axl_config_values = kvtree_new(); | ||
|
||
rc = kvtree_util_set_int(axl_config_values, AXL_KEY_CONFIG_MKDIR, | ||
!old_axl_make_directories); | ||
if (rc != KVTREE_SUCCESS) { | ||
printf("kvtree_util_set_int failed (error %d)\n", rc); | ||
return rc; | ||
} | ||
rc = kvtree_util_set_int(axl_config_values, AXL_KEY_CONFIG_COPY_METADATA, | ||
!old_axl_copy_metadata); | ||
if (rc != KVTREE_SUCCESS) { | ||
printf("kvtree_util_set_int failed (error %d)\n", rc); | ||
return rc; | ||
} | ||
|
||
printf("Configuring AXL (second set of options)...\n"); | ||
if (AXL_Config(-1, axl_config_values) == NULL) { | ||
printf("AXL_Config() failed\n"); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
/* check all options once more */ | ||
|
||
if (axl_file_buf_size != old_axl_file_buf_size + 1) { | ||
printf("AXL_Config() failed to set %s: %lu != %lu\n", | ||
AXL_KEY_CONFIG_FILE_BUF_SIZE, (long unsigned)axl_file_buf_size, | ||
(long unsigned)(old_axl_file_buf_size + 1)); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (axl_debug != !old_axl_debug) { | ||
printf("AXL_Config() failed to set %s: %d != %d\n", | ||
AXL_KEY_CONFIG_DEBUG, axl_debug, !old_axl_debug); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (axl_make_directories != !old_axl_make_directories) { | ||
printf("AXL_Config() failed to set %s: %d != %d\n", | ||
AXL_KEY_CONFIG_MKDIR, axl_make_directories, | ||
!old_axl_make_directories); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (axl_copy_metadata != !old_axl_copy_metadata) { | ||
printf("AXL_Config() failed to set %s: %d != %d\n", | ||
AXL_KEY_CONFIG_COPY_METADATA, axl_copy_metadata, | ||
!old_axl_copy_metadata); | ||
return EXIT_FAILURE; | ||
} | ||
|
||
rc = AXL_Finalize(); | ||
if (rc != AXL_SUCCESS) { | ||
printf("AXL_Finalize() failed (error %d)\n", rc); | ||
return rc; | ||
} | ||
|
||
return AXL_SUCCESS; | ||
} |