SS_UINT32 SS_Trace(void *pbUserData, const char *aFormat, ...
);
+/**
+ *******************************************************************************
+ * Allocate a memory block.
+ *
+ * \param size Memory block size, in blocks
+ *
+ * \return A pointer to the memory block on success, NULL on failure
+ *******************************************************************************
+ */
+ void *SS_Malloc(SS_UINT32 size);
+
+/**
+ *******************************************************************************
+ * Free a memory block.
+ *
+ * \param pMemBlock Pointer to the memory block
+ *******************************************************************************
+ */
+ void SS_Free(void *pMemBlock);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
--- /dev/null
+/*
+ * libtota
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+long curr_offset = 0;
+long next_offset = 0;
+long cut_offset = 0;
+long max_logfile_size = (2*1024*1024);
+
+/*-----------------------------------------------------------------------------
+ log_printf
+ ----------------------------------------------------------------------------*/
+int log_printf(FILE* log_fp, char* format_str, ...)
+{
+ int ret = 0;
+ char log_str[4096];
+ int len;
+ int wlen;
+ va_list list;
+
+ va_start(list, format_str);
+ vsprintf(log_str, format_str, list);
+ va_end(list);
+
+ len = strlen(log_str);
+ next_offset = curr_offset + len;
+
+ if (next_offset <= max_logfile_size) {
+ wlen = len;
+ if (fwrite(log_str, 1, wlen, log_fp) != wlen) {
+ ret = -1;
+ goto exit;
+ }
+ curr_offset = next_offset;
+ if (curr_offset == max_logfile_size) {
+ rewind(log_fp);
+ curr_offset = 0;
+ }
+ } else {
+ cut_offset = max_logfile_size - curr_offset;
+ wlen = cut_offset;
+ if (fwrite(log_str, 1, wlen, log_fp) != wlen) {
+ ret = -1;
+ goto exit;
+ }
+ rewind(log_fp);
+ wlen = next_offset - max_logfile_size;
+ if (fwrite(log_str+cut_offset, 1, wlen, log_fp) != wlen) {
+ ret = -1;
+ goto exit;
+ }
+ curr_offset = next_offset - max_logfile_size;
+ }
+
+exit:
+ return ret;
+}
+
+/*-----------------------------------------------------------------------------
+ truncate_log_file
+ ----------------------------------------------------------------------------*/
+void truncate_log_file(char *log_path, int size_kb)
+{
+ FILE *log_fp;
+
+ if (size_kb == 0) {
+ log_fp = fopen(log_path, "w");
+ if (log_fp == NULL) {
+ perror("file open error\n");
+ } else {
+ fclose(log_fp);
+ }
+ }
+
+ sync();
+}
+
+
extern unsigned int __log_level__;
extern FILE *__log_out_file__;
extern int log_printf(FILE* log_fp, char* format_str, ...);
+extern void truncate_log_file(char *log_path, int size_kb);
#define LOG_INFO (1<<8)
#define LOG_ENGINE (1<<7)
#define LOG_FLASH (1<<2)
#define LOG_SSENGINE LOG_ENGINE
-//#define LOG_REDBEND LOG_ENGINE
//#define DEBUG_STDOUT
#define DEBUG_FILE
#ifndef _FOTA_TAR_H_
#define _FOTA_TAR_H_
-extern void SS_Free(void *pMemBlock);
-extern int tar_get_item_offset(char *tar, char *item);
+int tar_get_item_offset(char *tar, char *item);
-extern int tar_get_item_size(char *tar, char *item);
+int tar_get_item_size(char *tar, char *item);
-extern int tar_get_cfg_data(char *tar, char *item, char *buf, int buflen);
+int tar_get_cfg_data(char *tar, char *item, char *buf, int buflen);
-extern int tar_get_folder_size(char *tar, char *item);
+int tar_get_folder_size(char *tar, char *item);
#endif /* _FOTA_TAR_H_ */