There are two functionalities in the osu: resize, update.
Function for resize is separated into its file so it is easy to find and
maintain. On the other hand, update is embeded in the osu.c with main
function.
To increase readability and maintainability, update function is
separated into update.c and update.h.
Change-Id: Iaf84325f1ef8edc7236a4a324f1194e1ec9f8b25
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
INCLUDE_DIRECTORIES(. ${CMAKE_SOURCE_DIR}/include)
-FILE(GLOB_RECURSE SRCS osu.c resize.c)
+FILE(GLOB_RECURSE SRCS osu.c resize.c update.c)
ADD_EXECUTABLE(${OUTPUT_BIN_NAME} ${SRCS})
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
TARGET_LINK_LIBRARIES(${OUTPUT_BIN_NAME} ${REQUIRED_PKGS_LDFLAGS} update-control)
#include <getopt.h>
#include <assert.h>
-#include "update_control.h"
#include "resize.h"
+#include "update.h"
struct arguments {
"By default, without an argument, the OS Upgrade will be triggered.\n\n", my_name);
}
-static int do_update()
-{
- int ret = 0;
- ret = update_control_initialize();
- if (ret != UPDATE_CONTROL_ERROR_NONE) {
- printf("Failed to initialize: %d\n", ret);
- return ret;
- }
- printf("Succeed to initialize\n");
-
- ret = update_control_check_new_version();
- if (ret != UPDATE_CONTROL_ERROR_NONE) {
- printf("Failed to check new version: %d\n", ret);
- goto cleanup;
- }
-
- ret = update_control_download_package();
- if (ret != UPDATE_CONTROL_ERROR_NONE) {
- printf("Failed to download delta: %d\n", ret);
- goto cleanup;
- }
- printf("Succeed to download delta\n");
-
- ret = update_control_do_update();
- if (ret != UPDATE_CONTROL_ERROR_NONE) {
- printf("Failed to trigger update: %d\n", ret);
- goto cleanup;
- }
-
- printf("Succeed to trigger update: %d\n", ret);
-
-cleanup:
- ret = update_control_deinitialize();
- if (ret != UPDATE_CONTROL_ERROR_NONE)
- printf("Failed to deinitialize: %d\n", ret);
-
- return ret;
-}
-
int main(int argc, char **argv)
{
int ret = 0;
--- /dev/null
+#include <stdio.h>
+
+#include "update_control.h"
+#include "update.h"
+
+int do_update(void)
+{
+ int ret = 0;
+ ret = update_control_initialize();
+ if (ret != UPDATE_CONTROL_ERROR_NONE) {
+ printf("Failed to initialize: %d\n", ret);
+ return ret;
+ }
+ printf("Succeed to initialize\n");
+
+ ret = update_control_check_new_version();
+ if (ret != UPDATE_CONTROL_ERROR_NONE) {
+ printf("Failed to check new version: %d\n", ret);
+ goto cleanup;
+ }
+
+ ret = update_control_download_package();
+ if (ret != UPDATE_CONTROL_ERROR_NONE) {
+ printf("Failed to download delta: %d\n", ret);
+ goto cleanup;
+ }
+ printf("Succeed to download delta\n");
+
+ ret = update_control_do_update();
+ if (ret != UPDATE_CONTROL_ERROR_NONE) {
+ printf("Failed to trigger update: %d\n", ret);
+ goto cleanup;
+ }
+
+ printf("Succeed to trigger update: %d\n", ret);
+
+cleanup:
+ ret = update_control_deinitialize();
+ if (ret != UPDATE_CONTROL_ERROR_NONE)
+ printf("Failed to deinitialize: %d\n", ret);
+
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#pragma once
+
+int do_update(void);