-
Notifications
You must be signed in to change notification settings - Fork 0
JAPML
When writing JAPM I was heavily inspired on pacman (Arch Linux’s package manager). Pacman has a library for backend functions named alpm while pacman is a front-end calling back end functions. JAPM is built in a similar way. JAPM is the fronted while JAPML (standing for Just-Another-Package-Management-Library) is the backend that performs all the important functions.
This documentation does not contain all functions or structures of JAPML but rather the ones that should be used and called by the front end.
- lib/libjapml/input.h
- lib/libjapml/parser.h
- lib/libjapml/parser.c
A system that allows parsing input passing from argc and argv. This can be used to configure a handle and should be called before doing so.
Structures
- japml_parse_parameters_t
Functions
- japml_parse_input(): Allocates a japml_parse_parameters_t structure
- japml_parse_params_free(): Frees a japml_parse_parameters_t should always be called if japml_parse_input() is called
- lib/libjapml/init.h
- lib/libjapml/init.c
Inits a handle according to parsed input.
Functions
- japml_init(japml_parse_parameters_t): Allocates and creates japml_handle_t according to parameters. Additionally configures terminal, files, curl, and SQLite. Should be called as one of the first steps.
- lib/libjapml/log.h
- lib/libjapml/log.c Additionally (if TUI enabled in handle):
- lib/libjapml/japmlcurses.h
- lib/libjapml/japmlcurses.c
The logging system has the ability to log messages of 4 types: Debug, Information, Error, Critical. The handle specifies a log level, a log message with a level below than this level will not be longed. Depending on the type of message the output will be logged to normal or error log files if provided. Additionally, if TUI (ncurses) is enabled it will use JAPML’s ncurses API to also write a message to the ncurses log screen.
Structures
- japml_log_message_t => should not be used by front end.
Enums
- japml_log_level_t
Fucntions
- japml_log(japml_handle_t, japml_log_level, char*)
- lib/libjapml/error.h
- lib/libjapml/error.c Additionally:
- The logging system
The error system consists of a very simple API that can be called by the front end. It “throws” an error by logging and potentially exiting the application if the error is critical and the handle is configured to do so (it is by default).
Enums
- japml_error_t: An Enum representing all possible error types. The higher the value the more critical the error is. Any error above or equal to custom_error_crit is a critical one.
Functions
- japml_throw_error(japml_handle_t, japml_error_t, char*): throws error
- lib/libjapml/action.h
- lib/libjapml/action.c
Front end communicates with the backend by sending actions. Actions are structures representing package management functionality that the back end can perform when being asked to. An action contains a reference to the packages the back end will operate on, the type of action (install, remove, remove_recursive) and the status (initialized, approved, denied, committed). Actions are not passed between functions but are referenced by the handle.
- An action needs to be created passing the targets and the type of action.
- Then it needs to be verified. This process involves checking for dependency break, adding dependencies to the target list if a package requires so and asking the user for agreement.
- Finally to realize an action you need to “commit” it. In this process the backend will perform what the front end has asked for.
If the process goes normally and all states of the action are passed successfully, JAPML fully frees the allocated memory removing the need of the front end to do so.
Stucts
- japml_action_t
Enums
- japml_action_type_t
- japml_action_status_t
Functions
- japml_action_create(japml_handle_t, japml_list_t, japml_action_type_t)
- japml_action_check(japml_handle_t)
- japml_action_commit(japml_handle_t)