Module: kamailio Branch: master Commit: ca72b6487fbed30be4ca83f7864c2ac1a29c647e URL: https://github.com/kamailio/kamailio/commit/ca72b6487fbed30be4ca83f7864c2ac1...
Author: Xenofon Karamanos 22965395+xkaraman@users.noreply.github.com Committer: Henning Westerholt hw@gilawa.com Date: 2025-06-06T15:43:16+02:00
file_out: Add file properties init function
---
Modified: src/modules/file_out/types.c Modified: src/modules/file_out/types.h
---
Diff: https://github.com/kamailio/kamailio/commit/ca72b6487fbed30be4ca83f7864c2ac1... Patch: https://github.com/kamailio/kamailio/commit/ca72b6487fbed30be4ca83f7864c2ac1...
---
diff --git a/src/modules/file_out/types.c b/src/modules/file_out/types.c index 1b5ffc4c6cb..9c2056ef59e 100644 --- a/src/modules/file_out/types.c +++ b/src/modules/file_out/types.c @@ -121,6 +121,41 @@ void fo_free_queue(fo_queue_t *q) shm_free(q); }
+int fo_file_properties_init(fo_file_properties_t *fp) +{ + if(fp == NULL) { + return -1; + } + + /* Malloc member for each element required */ + fp->fo_base_filename.s = (char *)shm_malloc(FO_MAX_PATH_LEN * sizeof(char)); + if(fp->fo_base_filename.s == NULL) { + LM_ERR("Failed to allocate memory for base filename\n"); + return -1; + } + fp->fo_extension.s = (char *)shm_malloc(10 * sizeof(char)); + if(fp->fo_extension.s == NULL) { + LM_ERR("Failed to allocate memory for extension\n"); + return -1; + } + + fp->fo_prefix.s = (char *)shm_malloc(4096 * sizeof(char)); + if(fp->fo_prefix.s == NULL) { + LM_ERR("Failed to allocate memory for prefix\n"); + return -1; + } + fp->fo_stored_timestamp = time(NULL); + fp->fo_interval_seconds = 0; + + fp->fo_prefix_pvs = (pv_elem_t *)shm_malloc(sizeof(pv_elem_t)); + if(fp->fo_prefix_pvs == NULL) { + LM_ERR("Failed to allocate memory for prefix pvs\n"); + return -1; + } + + return 1; +} + int fo_file_properties_destroy(fo_file_properties_t *fp) { if(fp == NULL) { diff --git a/src/modules/file_out/types.h b/src/modules/file_out/types.h index 940c6f7476b..27d3884ffc9 100644 --- a/src/modules/file_out/types.h +++ b/src/modules/file_out/types.h @@ -27,6 +27,7 @@ #include "../../core/pvar.h"
#define FO_MAX_FILES 10 /* Maximum number of files */ +#define FO_MAX_PATH_LEN 2048
typedef struct log_message { @@ -65,6 +66,7 @@ typedef struct fo_file_properties FILE *fo_file_output; } fo_file_properties_t;
+int fo_file_properties_init(fo_file_properties_t *fp); int fo_file_properties_destroy(fo_file_properties_t *fp); int fo_file_properties_print(const fo_file_properties_t file_prop);