diff --git a/docs/libglacier.html b/docs/libglacier.html index 1798cd8..8e88fed 100644 --- a/docs/libglacier.html +++ b/docs/libglacier.html @@ -40,26 +40,26 @@
$ ${EDITOR} config.mk
Before proceeding with ANY other step, make sure you define
By default this variable is not defined. Results will be unexpected if the library is compiled without
Before proceeding with ANY other step, make sure you define
By default this variable is not defined. Results will be unexpected if the library is compiled without
Build the library:
$ make lib
If you wish to compile a shared library instead, you must edit the Makefile
To use
#include <glacier_config.h>
-#include <glacier_data.h>
-#include <glacier_log.h>
-#include <glacier_pkgops.h>
-#include <glacier_runtime.h>
-#include <glacier_security.h>
+#include <glacier/config.h>
+#include <glacier/data.h>
+#include <glacier/log.h>
+#include <glacier/pkgops.h>
+#include <glacier/runtime.h>
+#include <glacier/security.h>
To compile
No parameters are accepted by
#include <glacier_config.h>
-+
#include <glacier/config.h>
+
int
main()
{
-if (init_config() != 0) {
-errlog("failed to initialize libconfig"); -
return(EXIT_FAILURE);
-}
-else {
-successlog("Initialized libconfig"); -
} +
if (init_config() != 0) {
+errlog("failed to initialize libconfig");
+return(EXIT_FAILURE);
+}
+else {
+successlog("Initialized libconfig");
+}
}
No parameters are accepted by
#include <glacier_config.h>
-+
#include <glacier/config.h>
+
int
main()
{
-die_config();
+die_config();
}
4.3 load_all_from_config
No parameters are accepted by
#include <glacier_config.h>
-+
#include <glacier/config.h>
+
int
main()
{
-init_config();
+init_config();
}
Since Glacier is a package manager,
5.1 create_node
@@ -125,14 +127,16 @@#include <glacier_data.h>
-+
#include <glacier/data.h>
+
int
main()
{
-struct node package = create_node("Package");
+struct node package = create_node("Package");
}
5.2 add_child
#include <glacier_data.h>
-+
#include <glacier/data.h>
+
int
main()
{
@@ -152,6 +156,8 @@add_child(pack, dep1);
}
5.3 print_tree
#include <glacier_data.h>
-+
#include <glacier/data.h>
+
int
main()
{
@@ -172,22 +178,28 @@print_tree(pack, 0);
}
5.4 init_queue
The queue data structure was removed in a recent update (March 2025). This function is no longer available in the current version of libglacier.
+#include <glacier_data.h>
-+
#include <glacier/data.h>
+
int
main()
{
-hi
+/* Queue implementation removed */
+}
The logging functions
The following logging functions are included:
@@ -207,109 +219,283 @@Logging functions do not require a newline character ('\n'), they will automatically place one after the message.
+All logging functions return 0 on success, and 1 on failure.
#include <glacier_log.h>
-+
#include <glacier/log.h>
+
int
main()
{
-infolog("This is an info message");
-warnlog("This is a warning message");
-errlog("This is an error message");
-successlog("This is a success message");
+infolog("This is an info message");
+warnlog("This is a warning message");
+errlog("This is an error message");
+successlog("This is a success message");
}
This section describes the numerous functions related to operations on packages.
7.1 mkworkspace
#include <glacier/pkgops.h>
++
int
+main()
+{
+mkworkspace();
+}
+0 on success
2 on library error
#include <glacier_pkgops.h>
--
int
-main()
-{
-mkworkspace();
-}
-Calling
7.2 prepare_pkg
#include <glacier/pkgops.h>
++
int
+main()
+{
+prepare_pkg("/glacier/localdb/epkgs-x86_64-musl/foo.tar");
+}
+0 on success
1 on package does not exist, or error untarring
#include <glacier_pkgops.h>
--
int
-main()
-{
-prepare_pkg("/glacier/localdb/epkgs-x86_64-musl/foo.tar");
-}
-
This example presented is not the best. Instead of manually specifying the package directory, you should be calling the system profile.
7.3 run_make_task
#include <glacier/pkgops.h>
++
int
+main()
+{
+prepare_pkg("/glacier/localdb/epkgs-x86_64-musl/foo.tar");
+run_make_task("installpkg");
+}
+0 on success
1 on failure
#include <glacier_pkgops.h>
--
int
-main()
-{
-prepare_pkg("/glacier/localdb/epkgs-x86_64-musl/foo.tar");
-run_make_task("installpkg");
- -}
-The functions described here are used for various runtime checks.
8.1 runtime_exists
#include <glacier_runtime.h>
-+
#include <glacier/runtime.h>
+
int
main()
{
-runtime_exists();
+runtime_exists();
}
8.2 +
8.2 is_process_root
+#include <glacier/runtime.h>
++
int
+main()
+{
+if (is_process_root() != 0) {
+errlog("insufficient permissions to perform package operations");
+return(EXIT_FAILURE);
+}
+}
+0 on sufficient permissions (process is root)
1 on insufficient permissions (process is not root)
8.3 get_system_profile
+#include <glacier/runtime.h>
++
int
+main()
+{
+char *profile = get_system_profile();
+infolog(profile);
+}
+These functions provide security checks for package integrity and signatures.
+9.1 verify_signature
+This function is planned for a future release and is not yet implemented in the current version of libglacier.
+#include <glacier/security.h>
++
int
+main()
+{
+if (verify_signature("package.tar", "package.tar.sig") != 0) {
+errlog("invalid package signature");
+return(EXIT_FAILURE);
+}
+return(EXIT_SUCCESS);
+}
+0 on valid signature
1 on invalid signature
2 on file not found
9.2 check_integrity
+This function is planned for a future release and is not yet implemented in the current version of libglacier.
+Note that the underlying functions for calculating file hashes (
#include <glacier/security.h>
++
int
+main()
+{
+char *expected = "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592";
+if (check_integrity("package.tar", expected) != 0) {
+errlog("package integrity check failed");
+return(EXIT_FAILURE);
+}
+return(EXIT_SUCCESS);
+}
+0 on hash match
1 on hash mismatch
2 on file not found or hash calculation error
This section covers more advanced usage patterns for
10.1 Custom dependency tree handling
+While
#include <glacier/data.h>
+#include <glacier/log.h>
++
int
+resolve_dependencies(struct node *root)
+{
+/* Custom dependency resolution logic here */
+for (int i = 0; i < root->num_children; i++) {
+infolog(root->children[i]->data);
+/* Process child dependencies recursively */
+resolve_dependencies(root->children[i]);
+}
+return(0);
+}
++
int
+main()
+{
+struct node *root = create_node("base-package");
+struct node *dep1 = create_node("dependency1");
+struct node *dep2 = create_node("dependency2");
+add_child(root, dep1);
+add_child(root, dep2);
+resolve_dependencies(root);
+return(EXIT_SUCCESS);
+}
+10.2 Error handling best practices
+When using
#include <glacier/config.h>
+#include <glacier/log.h>
+#include <glacier/pkgops.h>
++
int
+main()
+{
+/* Initialize configuration */
+if (init_config() != 0) {
+errlog("failed to initialize configuration");
+return(EXIT_FAILURE);
+}
++
/* Create workspace */
+if (mkworkspace() != 0) {
+errlog("failed to create workspace");
+die_config();
+return(EXIT_FAILURE);
+}
++
/* Always clean up resources */
+die_config();
+return(EXIT_SUCCESS);
+}
+Always free resources and clean up configurations when your program exits, even on error paths.
+This prevents memory leaks and ensures consistent behavior.
+