#ifdef CONFIG_MARU
extern int start_simple_client(char* msg);
+extern char* maru_convert_path(char* msg, const char *path);
#endif
DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
file, strerror(-ret));
#ifdef CONFIG_MARU
- const char _msg[] = "Failed to load disk file from the following path. Check if the file was corrupted or missing.\n\n";
- char* current_path = NULL;
- char* err_msg = NULL;
-#ifdef _WIN32
- char* dos_err_msg = NULL;
-#endif
- int total_len = 0;
- int msg_len = 0;
- int cur_path_len = 0;
- int disk_path_len = 0;
- int res = -1;
-
- res = (int)g_path_is_absolute((gchar*)file);
- disk_path_len = (strlen(file) + 1);
- msg_len = strlen(_msg) + 1;
-
- if (!res) {
- current_path = (char*)g_get_current_dir();
- cur_path_len = strlen(current_path) + strlen("/") + 1;
- total_len += cur_path_len;
- }
- total_len += (disk_path_len + msg_len);
-
- err_msg = g_malloc0(total_len * sizeof(char));
- if (!err_msg) {
- printf("failed to allocate memory\n");
- }
-
- snprintf(err_msg, msg_len, "%s", _msg);
- total_len = msg_len - 1;
- if (!res) {
- snprintf(err_msg + total_len, cur_path_len, "%s%s", current_path, "/");
- total_len += (cur_path_len - 1);
- }
- snprintf(err_msg + total_len, disk_path_len, "%s", file);
-
-#ifdef _WIN32
- {
- int i;
-
- dos_err_msg = strdup(err_msg);
- if (!dos_err_msg) {
- printf("failed to duplicate an error message from %p\n", err_msg);
- }
-
- for (i = (total_len - 1); dos_err_msg[i]; i++) {
- if (dos_err_msg[i] == '/') {
- dos_err_msg[i] = '\\';
- }
- }
- strncpy(err_msg, dos_err_msg, strlen(dos_err_msg));
- free(dos_err_msg);
- }
-#endif
+ const char _msg[] = "Failed to load disk file from the following path. Check if the file is corrupted or missing.\n\n";
+ char* err_msg = NULL;
+ err_msg = maru_convert_path((char*)_msg, file);
start_simple_client(err_msg);
-
- g_free(current_path);
- g_free(err_msg);
+ if (err_msg) {
+ g_free(err_msg);
+ }
#endif
goto err;
kernel_filename, strerror(errno));
#ifdef CONFIG_MARU
- char* current_path = (char *)g_get_current_dir();
- int len = strlen(current_path) + strlen(kernel_filename) + 2;
-
- char* error_msg = g_malloc0(len * sizeof(char));
- snprintf(error_msg, len, "%s/%s", current_path, kernel_filename);
+ char *error_msg = NULL;
+ error_msg = maru_convert_path(error_msg, kernel_filename);
maru_register_exit_msg(MARU_EXIT_KERNEL_FILE_EXCEPTION, error_msg);
-
- g_free(current_path);
- g_free(error_msg);
+ if (error_msg) {
+ g_free(error_msg);
+ }
#endif
exit(1);
fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
#ifdef CONFIG_MARU
- char* current_path = (char *)g_get_current_dir();
- const char* _path = qemu_get_data_dir();
-
- int len = strlen(current_path) + strlen(_path) + strlen(bios_name) + 3;
-
- char* error_msg = g_malloc0(len * sizeof(char));
- snprintf(error_msg, len, "%s/%s/%s", current_path, _path, bios_name);
-
- maru_register_exit_msg(MARU_EXIT_BIOS_FILE_EXCEPTION, error_msg);
-
- g_free(current_path);
- g_free(error_msg);
+ char *error_msg = NULL;
+ const char *path = qemu_get_data_dir();
+ char *bios_path = NULL;
+ int bios_len = 0;
+
+ bios_len = strlen(path) + strlen("/") + strlen(bios_name) + 1;
+ bios_path = g_malloc(bios_len * sizeof(char));
+ if (!bios_path) {
+ fprintf(stderr, "qemu: failed to allocate memory\n");
+ }
+ snprintf(bios_path, bios_len, "%s/%s", path, bios_name);
+ error_msg = maru_convert_path(error_msg, bios_path);
+ maru_register_exit_msg(MARU_EXIT_BIOS_FILE_EXCEPTION, error_msg);
+
+ if (bios_path) {
+ g_free(bios_path);
+ }
+ if (error_msg) {
+ g_free(error_msg);
+ }
#endif
exit(1);
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
void qemu_restore_context (AVCodecContext *dst, AVCodecContext *src);
+void qemu_codec_close (SVCodecState *s, uint32_t value);
+
void qemu_get_codec_ver (SVCodecState *s, int ctxIndex);
/*
* FFMPEG APIs
#include "maru_err_table.h"
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <glib.h>
#ifdef _WIN32
#include <windows.h>
static char _maru_string_table[][JAVA_MAX_COMMAND_LENGTH] = {
/* 0 */ "", //MARU_EXIT_UNKNOWN
/* 1 */ "Failed to allocate memory in qemu.", //MARU_EXIT_MEMORY_EXCEPTION
- /* 2 */ "Fail to load kernel file. Check if the file is corrupted or missing from the following path.\n\n", //MARU_EXIT_KERNEL_FILE_EXCEPTION
- /* 3 */ "Fail to load bios file. Check if the file is corrupted or missing from the following path.\n\n", //MARU_EXIT_BIOS_FILE_EXCEPTION
+ /* 2 */ "Failed to load a kernel file the following path. Check if the file is corrupted or missing.\n\n", //MARU_EXIT_KERNEL_FILE_EXCEPTION
+ /* 3 */ "Failed to load a bios file the following path. Check if the file is corrupted or missing.\n\n", //MARU_EXIT_BIOS_FILE_EXCEPTION
/* 4 */ "Skin process cannot be initialized. Skin server is not ready.",
/* add here.. */
"" //MARU_EXIT_NORMAL
void maru_atexit(void)
{
if (maru_exit_status != MARU_EXIT_NORMAL || strlen(maru_exit_msg) != 0) {
- maru_dump_backtrace(NULL, 0);
+ maru_dump_backtrace(NULL, 0);
start_simple_client(maru_exit_msg);
}
}
+char* maru_convert_path(char *msg, const char *path)
+{
+ char* current_path = NULL;
+ char* err_msg = NULL;
+#ifdef _WIN32
+ char* dos_err_msg = NULL;
+#endif
+ int total_len = 0;
+ int msg_len = 0;
+ int cur_path_len = 0;
+ int path_len = 0;
+ int res = -1;
+
+ res = (int)g_path_is_absolute(path);
+ path_len = (strlen(path) + 1);
+ if (msg) {
+ msg_len = strlen(msg) + 1;
+ }
+
+ if (!res) {
+ current_path = (char*)g_get_current_dir();
+ cur_path_len = strlen(current_path) + strlen("/") + 1;
+ total_len += cur_path_len;
+ }
+ total_len += (path_len + msg_len);
+
+ err_msg = g_malloc0(total_len * sizeof(char));
+ if (!err_msg) {
+ fprintf(stderr, "failed to allocate memory\n");
+ if (current_path) {
+ g_free(current_path);
+ }
+ return NULL;
+ }
+
+ if (msg) {
+ snprintf(err_msg, msg_len, "%s", msg);
+ total_len = msg_len - 1;
+ } else {
+ total_len = 0;
+ }
+
+ if (!res) {
+ snprintf(err_msg + total_len, cur_path_len, "%s%s", current_path, "/");
+ total_len += (cur_path_len - 1);
+ }
+ snprintf(err_msg + total_len, path_len, "%s", path);
+
+#ifdef _WIN32
+ {
+ int i;
+
+ dos_err_msg = strdup(err_msg);
+ if (!dos_err_msg) {
+ printf(stderr, "failed to duplicate an error message from %p\n", err_msg);
+ if (current_path) {
+ g_free(current_path);
+ }
+ g_free(err_msg);
+ return NULL;
+ }
+
+ for (i = (total_len - 1); dos_err_msg[i]; i++) {
+ if (dos_err_msg[i] == '/') {
+ dos_err_msg[i] = '\\';
+ }
+ }
+ strncpy(err_msg, dos_err_msg, strlen(dos_err_msg));
+ free(dos_err_msg);
+ }
+#endif
+ if (current_path) {
+ g_free(current_path);
+ }
+
+ return err_msg;
+}
+
// for pirnt 'backtrace'
#ifdef _WIN32
struct frame_layout {
void maru_register_exit_msg(int maru_exit_status, char* additional_msg);
void maru_atexit(void);
+char* maru_convert_path(char *msg, const char *path);
void maru_dump_backtrace(void* ptr, int depth);
#endif /* __EMUL_ERR_TABLE_H__ */