Integrate some common codes to libtota 62/138862/3
authorSunmin Lee <sunm.lee@samsung.com>
Tue, 23 May 2017 02:55:47 +0000 (11:55 +0900)
committerSunmin Lee <sunm.lee@samsung.com>
Fri, 14 Jul 2017 10:06:35 +0000 (19:06 +0900)
There were duplicated codes in tota-ua and libtota.
It would be better to integrate in one place and manage them.

Change-Id: I20108e80f4731adac60ee1510834bcfdf0a96a4e
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
CMakeLists.txt
packaging/tota-ua.spec
src/common/fota_common.h [deleted file]
src/common/fota_log.c [deleted file]
src/common/fota_log.h [deleted file]
src/common/fota_tar.h [deleted file]

index bd612feda2b08c4a1789669a695a67d64ee834c5..da85c2c94e4ec04221f0f80424ef8c6190de2f36 100755 (executable)
@@ -9,9 +9,7 @@ ENDIF("${FOTA_PARTITION_TYPE}" STREQUAL "PART_RPI3")
 
 SET(SRCS
        src/common/fota_cfg.c
-       #src/common/fota_tar.c
        src/common/fota_util.c
-       src/common/fota_log.c
        src/common/mmc_io.c
        src/${MODELDIR}/ua.c
 )
index 2c3e7871bb47963aa8841357c510f31c3b90b07d..69253076d33f69867074037c3bd2a02ce7ec6d96 100755 (executable)
@@ -1,8 +1,8 @@
 Name:          tota-ua
 Summary:       fota update agent
 ExclusiveArch:         %{arm}
-Version:       0.1.1
-Release:       2
+Version:       0.1.2
+Release:       3
 Group:         System
 License:       Apache-2.0
 Source0:       %{name}-%{version}.tar.gz
diff --git a/src/common/fota_common.h b/src/common/fota_common.h
deleted file mode 100755 (executable)
index c766a70..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * tota-ua
- *
- * 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.
- */
-
-#ifndef __FOTA_COMMON_H__
-#define __FOTA_COMMON_H__
-
-
-#include <stdio.h>
-#include "fota_log.h"
-
-typedef signed char s8;
-typedef unsigned char u8;
-
-typedef signed short s16;
-typedef unsigned short u16;
-
-typedef signed int s32;
-typedef unsigned int u32;
-typedef u32 size_t;
-
-typedef signed long sl32;
-typedef unsigned long ul32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-#ifndef HEAP_PROFILING
-       //#define HEAP_PROFILING;
-#endif
-#define UNUSED(x) (void)(x)
-
-struct tar_Data {
-    int itemSize;
-    int itemOffset;
-    int itemName[256];
-    struct tar_Data *nextnode;
-};
-typedef struct tar_Data tar_Data_t;
-
-#endif                          /* __FOTA_COMMON_H__ */
diff --git a/src/common/fota_log.c b/src/common/fota_log.c
deleted file mode 100755 (executable)
index 3e078f4..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * tota-ua
- *
- * 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();
-}
-
-
diff --git a/src/common/fota_log.h b/src/common/fota_log.h
deleted file mode 100755 (executable)
index 828228c..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * tota-ua
- *
- * 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.
- */
-
-#ifndef __FOTA_LOG_H__
-#define __FOTA_LOG_H__
-
-#include <stdio.h>
-
-/*
- * DEBUGGING FEATURE
- */
-
-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_FUNCS      (1<<6)
-#define LOG_GUI                (1<<5)
-#define LOG_DEBUG      (1<<4)
-#define LOG_FILE       (1<<3)
-#define LOG_FLASH      (1<<2)
-#define LOG_SSENGINE  LOG_ENGINE
-
-//#define DEBUG_STDOUT
-#define DEBUG_FILE
-
-#ifdef DEBUG_STDOUT
-#define LOGE(s, args...) printf("UA/ERROR(%s)  " s, __func__, ##args) // Error log
-#define LOGL(mask, s, args...) do{if((mask) & __log_level__) printf("UA/(%s): " s,__func__, ##args);}while(0)
-#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
-
-#elif defined(DEBUG_FILE)
-#define LOGE(s, args...) (void)log_printf(__log_out_file__, "UA/ERROR(%s)  " s, __func__, ##args)
-#define LOGL(mask, s, args...) do{if((mask) & __log_level__) (void)log_printf(__log_out_file__, "UA/(%s): " s ,__func__, ##args);}while(0)
-#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
-
-#elif defined(DEBUG_STDOUT_FILE) // debug printf
-#define LOGE(s, args...) do {\
-                                               printf("UA/ERROR(%s)  " s, __func__, ##args);\
-                                               (void)log_printf(__log_out_file__, "UA/ERROR(%s)  " s, __func__, ##args);\
-                                       }while(0)
-#define LOGL(mask, s, args...) do{ \
-                                               if((mask) & __log_level__){\
-                                                       printf("UA/(%s): " s ,__func__, ##args);\
-                                                   (void)log_printf(__log_out_file__, "UA/(%s): " s,__func__, ##args);\
-                                               }\
-                                       }while(0)
-#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
-
-#else
-#define LOGE(s, args...)
-#define LOGL(mask, s, args...)
-#define LOG(s, args...)
-
-#endif
-
-
-#endif /* __FOTA_LOG_H__ */
-
diff --git a/src/common/fota_tar.h b/src/common/fota_tar.h
deleted file mode 100755 (executable)
index d82df1f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * tota-ua
- *
- * 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.
- */
-
-#ifndef _FOTA_TAR_H_
-#define _FOTA_TAR_H_
-
- int tar_get_item_offset(char* tar, char* item);
-
- int tar_get_item_size(char* tar, char* item);
-
- int tar_get_cfg_data(char* tar, char* item, char *buf, int buflen);
-
- int tar_get_folder_size(char* tar, char* item);
-#endif /* _FOTA_TAR_H_ */