Files
najdek 2189ee962d refactor: decompose main.c and payload_mgr.c into focused modules
Split two monolithic files (main.c 1538→233 lines, payload_mgr.c
2355→467 lines) into 8 single-responsibility modules:

- http_server.c: MHD request router and all route handlers
- repository.c: repo cache, download, install/commit, self-update
- sources.c: multi-source repository management
- config.c: PldmgrConfig struct, read/write, JSON config handler
- log_server.c: ring buffer, SSE streaming, pldmgr_log()
- json_helpers.c: JsonListBuilder, JSON parser, file I/O utilities
- sha256.c: SHA256 hash implementation
- process_mgr.c: process listing and kill

Introduces PldmgrConfig struct to replace the 8-out-param
read_next_config_values() pattern. Renames extracted functions to
match their new modules (e.g. repository_install_download,
sources_add, process_kill). No HTTP route changes — frontend
is unaffected.
2026-06-03 18:22:26 +02:00

30 lines
1.2 KiB
C

#ifndef PAYLOAD_MGR_H
#define PAYLOAD_MGR_H
#include <stddef.h>
/*
* Scans directories and populates json_buf with a JSON array of payloads.
* Returns the length of the string written.
*/
size_t payload_mgr_list_json(char *json_buf, size_t buf_size);
int payload_mgr_resolve_path(const char *filename, char *out_path, size_t out_size);
int payload_mgr_delete_payload_file(const char *filename);
int payload_mgr_import_to_storage(const char *filename, const char *temp_path,
const char *install_source, const char *install_source_detail,
char *msg_buf, size_t msg_buf_size);
int payload_mgr_check_existing(const char *filename, char *out_json, size_t out_size);
int payload_mgr_write_metadata(const char *payload_path, const char *install_source,
const char *install_source_detail);
/* USB Import */
int payload_mgr_usb_check(const char *usb_path, char *out_json, size_t out_size);
int payload_mgr_usb_move(const char *usb_path, int overwrite, char *out_json,
size_t out_size);
/* Internal utility — exposed for use by repository.c and sources.c */
void payload_mgr_remove_old_files(const char *dir_path, const char *new_filename);
#endif