int check_segd_option(char_t const* option/*, char const* option_value, unsigned option_value_size*/)
{
	int i_ret = APP_FAULT;
	int i = 0;
	size_t size = 0;
	char tmp_buf[MAX_STRING_SIZE*2] = {0}; 	
	errno_t err_code = 0x0;

#if defined(UNICODE) || defined(_UNICODE)
	
	err_code = wcstombs_s(&size, tmp_buf, sizeof(tmp_buf), option, MAX_STRING_SIZE);
	if(err_code != 0){
		set_last_error(IDS_STRING5010);
		output_log(IDS_STRING5010, option);
		return i_ret;
	}

	tmp_buf[size] = 0x0;
#else 
	strcpy(tmp_buf, option, strlen(option) + 1);
#endif //defined(UNICODE) || defined(_UNICODE)

	size = sizeof(__segd_option_items)/sizeof(__segd_option_items[0]);

	for(i = 0; i < size; ++i){
		if(_stricmp(tmp_buf, __segd_option_items[i].key_name_) == 0)
		{	i_ret = APP_SUCCESS; break; }
	}

	if(i_ret != APP_SUCCESS){
		set_last_error(IDS_STRING5009);
		output_log(IDS_STRING5009, option);
	}
	return i_ret;
}
int save_config_file(char_t const* config_path)
{
	int i = 0;
	int size = 0;
	HANDLE file_handle = NULL;
	char tmp_buf[MAX_STRING_SIZE] = {0};

	file_handle	= CreateFile(config_path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 
		NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

	if(file_handle == INVALID_HANDLE_VALUE){

		set_last_error(IDS_STRING5008);
		output_log(IDS_STRING5008, get_last_error());
		return APP_FAULT;
	}

	for(i = 0; i < __config_file_line_size; ++i){
		strcpy(tmp_buf, __config_file_lines[i].line_);
		size = strlen(tmp_buf);
		tmp_buf[size++] = 0xd;
		tmp_buf[size++] = 0xa;
		tmp_buf[size] = NULL;
		if(!WriteFile(file_handle, tmp_buf, size, (DWORD*)&size, NULL)){
			set_last_error(IDS_STRING5011);
			output_log(IDS_STRING5011, get_last_error());
		}
	}

	if(file_handle != INVALID_HANDLE_VALUE) CloseHandle(file_handle);
	return APP_SUCCESS;
}
/*! \file
 *  \brief jpip_to_jp2 is a program to convert JPT- JPP- stream to JP2 file
 *
 *  \section impinst Implementing instructions
 *  This program takes two arguments. \n
 *   -# Input JPT or JPP file
 *   -# Output JP2 file\n
 *   % ./jpip_to_jp2 input.jpt output.jp2
 *   or
 *   % ./jpip_to_jp2 input.jpp output.jp2
 */
static int jpip_to_jp2(int argc,char *argv[])
{
  jpip_dec_param_t *dec;
    
  if( argc < 3){
    fprintf( stderr, "Too few arguments:\n");
    fprintf( stderr, " - input  jpt or jpp file\n");
    fprintf( stderr, " - output jp2 file\n");
    return -1;
  }
  
  dec = init_jpipdecoder( OPJ_TRUE);
  
  if(!( fread_jpip( argv[1], dec)))
    return -1;
  
  decode_jpip( dec);
  
  if(!(fwrite_jp2k( argv[2], dec)))
    return -1;

  output_log( OPJ_TRUE, OPJ_FALSE, OPJ_TRUE, dec);

  destroy_jpipdecoder( &dec);

  return 0;
}
int assign_unicode_string(void* value_ptr, const char* value_string)
{
	int i_ret = APP_SUCCESS;
	char tmp_value[MAX_STRING_SIZE] = {0};
	char* ch_ptr = tmp_value;
	size_t size = 0;
	wchar_t wc_tmp_value[MAX_STRING_SIZE] = {0};

	strcpy_s(tmp_value, MAX_STRING_SIZE - 1, value_string);

	while(*ch_ptr)
		if(*ch_ptr == '\"') *ch_ptr++ = ' ';
		else				++ch_ptr;

	StrTrimA(tmp_value, " 	");
	mbstowcs_s(&size, NULL, 0, tmp_value, 0);
	mbstowcs_s(&size, wc_tmp_value, size, tmp_value, size);
	wc_tmp_value[size] = 0x0;

	if(size == (size_t) -1){
		set_last_error(IDS_STRING5012);
		output_log(IDS_STRING5012);
		return i_ret = APP_FAULT;
	}

	StrCpy((wchar_t*)value_ptr, wc_tmp_value);
	return i_ret;
}
sdl_renderer::sdl_renderer()
{
/*
	m_hwnd=hwnd;
	m_hinst=hInst;
*/
	b_window=true;
	render_pass_type=2;

	init_sdlvideo();
	init_sdlaudio();
	init_sdlevent();

	cur_time=0;
	now_sensor_x=now_sensor_y=2047;
	b_pad_update=true;

	save_resurve=-1;
	load_resurve=-1;

	b_sound=b_graphics=false;
	b_bibrating=false;
///	wav=NULL;

	key_list.clear();
	movie_playing=movie_recording=false;
	movie_start=mov_cur_pos=0;
	movie_file=NULL;

	output_log("SDL レンダラ 初期化完了\n\n");
}
Esempio n. 6
0
dx_renderer::dx_renderer(HWND hwnd,HINSTANCE hInst)
{
	m_hwnd=hwnd;
	m_hinst=hInst;

	b_window=true;
	vsync=false;
	render_pass_type=2;

	init_dd();
	init_ds();
	init_di();

	cur_time=0;
	now_sensor_x=now_sensor_y=2047;
	b_pad_update=true;
	b_time_fix=false;
	fixed_time=0;

	save_resurve=-1;
	load_resurve=-1;

	b_sound=b_graphics=false;
	b_bibrating=false;
	wav=NULL;

	key_list.clear();
	movie_playing=movie_recording=false;
	movie_start=mov_cur_pos=0;
	movie_file=NULL;

	output_log("DirectX レンダラ 初期化完了\n\n");
}
Esempio n. 7
0
void
idn_log_warning(const char *fmt, ...) {
	va_list args;

	va_start(args, fmt);
	output_log(idn_log_level_warning, fmt, args);
	va_end(args);
}
Esempio n. 8
0
void
idn_log_dump(const char *fmt, ...) {
	va_list args;

	va_start(args, fmt);
	output_log(idn_log_level_dump, fmt, args);
	va_end(args);
}
Esempio n. 9
0
void
idn_log_fatal(const char *fmt, ...) {
	va_list args;

	va_start(args, fmt);
	output_log(idn_log_level_fatal, fmt, args);
	va_end(args);
	exit(1);
}
Esempio n. 10
0
dx_renderer::~dx_renderer()
{
	if (wav)
		delete wav;

	uninit_dd();
	uninit_ds();
	uninit_di();
	output_log("DirectX レンダラ 破棄しました\n\n");
}
sdl_renderer::~sdl_renderer()
{
///	if (wav)
///		delete wav;

	uninit_sdlvideo();
	uninit_sdlaudio();
	uninit_sdlevent();
	output_log("SDL レンダラ 破棄しました\n\n");
}
Esempio n. 12
0
int init_module(__in__ SEGD_API_INFO_PTR config_info_ptr)
{
	int error_code = APP_SUCCESS;

	memset(__config_file_path, 0x0, sizeof(__config_file_path));
	StrCpy(__config_file_path, config_info_ptr->config_path_);
	error_code = check_config_file(__config_file_path);
	if(error_code == APP_FAULT){
		__last_error_code = get_last_error();
		output_log(IDS_STRING5017, __last_error_code);
		__last_error_code = IDS_STRING5017;
		return error_code = APP_FAULT;
	}

	if(config_info_ptr->listen_port_ == 0x0){	
		output_log(__last_error_code = IDS_STRING5018);		
		error_code = APP_FAULT;	
	}
	else{	__listen_port = config_info_ptr->listen_port_;}

	return error_code;
}
int modify_segd_option(char_t const* option, char const* option_value/*, unsigned option_value_size*/)
{
	int i_ret = APP_SUCCESS;
	int i = 0;
	size_t size = 0;

	char tmp_buf[MAX_STRING_SIZE*2] = {0}; 	
	errno_t err_code = 0x0;

#if defined(UNICODE) || defined(_UNICODE)
	err_code = wcstombs_s(&size, tmp_buf, sizeof(tmp_buf), option, MAX_STRING_SIZE);
	if(err_code != 0){
		set_last_error(IDS_STRING5010);
		output_log(IDS_STRING5010, option);
		return i_ret = APP_FAULT;
	}

#else 
	strcpy(tmp_buf, option);
#endif //defined(UNICODE) || defined(_UNICODE)

	tmp_buf[size] = 0x0;
	size = sizeof(__segd_option_items)/sizeof(__segd_option_items[0]);

	for(i = 0; i < size; ++i)	if(strcmp(tmp_buf, __segd_option_items[i].key_name_) == 0)	break;

	i_ret = __segd_option_items[i].function_ptr_(__segd_option_items[i].value_ptr_, option_value);
	if(i_ret != APP_SUCCESS){	set_last_error(IDS_STRING5009);		output_log(IDS_STRING5009, option);	return i_ret;}

	for(i = 0; i < __config_file_line_size; ++i)
		if(strcmp(tmp_buf, __config_file_lines[i].key_name_) == 0) break;

	
	StrCpyA(__config_file_lines[i].value_, option_value);
	wnsprintfA(__config_file_lines[i].line_, sizeof(__config_file_lines[i].line_), "%s %s", tmp_buf, option_value);

	return i_ret;
}
Esempio n. 14
0
void validate_program(GLuint program) {
  glValidateProgram(program);
  // check if validation was successfull
  GLint success = 0;
  glGetProgramiv(program, GL_VALIDATE_STATUS, &success);
  if(success == 0) {
    // get log length
    GLint log_size = 0;
    glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_size);
    // get log
    GLchar* log_buffer = (GLchar*)malloc(sizeof(GLchar) * log_size);
    glGetProgramInfoLog(program, log_size, &log_size, log_buffer);
    // output errors
    output_log(log_buffer, "program nr. " + std::to_string(program));
    // free broken program
    glDeleteProgram(program);
    free(log_buffer);

    throw std::logic_error("Validation of program nr. " + std::to_string(program));
  }
}
int check_config_file(char_t const* config_path)
{
	int i_ret = APP_SUCCESS, is_ok = APP_SUCCESS;
	HANDLE file_handle = NULL;
	char buf[MAX_STRING_SIZE] = {0};
	char line[MAX_STRING_SIZE * 2] = {0};
	char *ptr = NULL;
	DWORD size = 0x0, i = 0, cur_line_size = 0x0, j = 0, arg_size = 0;

	wchar_t tmp_value[MAX_STRING_SIZE] = {0};
	size_t mbcs_size = 0x0;

	__matrix_zero_Memory(&__config_file_lines, sizeof(__config_file_lines));
	__config_file_line_size = 0x0;

	file_handle = CreateFile(config_path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 
		NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if(file_handle == INVALID_HANDLE_VALUE){

		set_last_error(IDS_STRING5008);
		output_log(IDS_STRING5008, get_last_error());
		return APP_FAULT;
	}

	//read all lines
	while(ReadFile(file_handle, buf, sizeof(buf), &size,NULL)){

		if(size == 0) break;
		for(i = 0; i < size; ++i){
			if(buf[i] == 0x0d){

				if(cur_line_size == 0) continue;

				memcpy(__config_file_lines[__config_file_line_size].line_, line, cur_line_size);
				__config_file_lines[__config_file_line_size].line_[cur_line_size] = NULL;

				StrTrimA(line, " 	");
				cur_line_size = strlen(line);
				if(cur_line_size == 0) continue;

				//parse all option
				ptr = __config_file_lines[__config_file_line_size].key_name_;
				for(arg_size = 1, j = 0; j < cur_line_size; ++j){

					if(line[j] == '#'){	break;}
					else if(line[j] == ' '){

						if(line[j] == line[j+1]) continue;
						if(arg_size == 2){ *ptr++ = line[j];}
						else{
							*++ptr = NULL;
							ptr = __config_file_lines[__config_file_line_size].value_;
							++arg_size;
						}
					}
					else{	*ptr++ = line[j];	}
				}

				cur_line_size = 0x0;
				memset(line, 0x0, sizeof(line));
				++__config_file_line_size;
			}
			else{

				if(buf[i] != 0xa){
					line[cur_line_size] = buf[i];
					++cur_line_size;
				}
			}
		}
	}

	if(file_handle != INVALID_HANDLE_VALUE)	CloseHandle(file_handle);

	arg_size = sizeof(__segd_option_items) / sizeof(__segd_option_items[0]);
	for(i = 0; i < __config_file_line_size; ++i){

		is_ok = APP_FAULT;
		if(strlen(__config_file_lines[i].key_name_) == 0) continue;
		for(j = 0; j < arg_size; ++j){			
			if(strcmp(__config_file_lines[i].key_name_, __segd_option_items[j].key_name_) == 0){
				is_ok = APP_SUCCESS;
				break;
			}
		}

		if(is_ok == APP_FAULT){
			set_last_error(IDS_STRING5013);
			mbstowcs_s(&mbcs_size, NULL, 0, __config_file_lines[i].key_name_, 0);
			mbstowcs_s(&mbcs_size, tmp_value, mbcs_size, __config_file_lines[i].key_name_, mbcs_size);
			tmp_value[mbcs_size] = 0x0;
			output_log(IDS_STRING5013, tmp_value);
			if(i_ret == APP_SUCCESS && is_ok == APP_FAULT)  i_ret = is_ok;
		}
	}

	__config_file_line_size = 0x0;
	__matrix_zero_Memory(__config_file_lines, sizeof(__config_file_lines));

	return i_ret;
}
bool log::output_log(const char_t* info, log::LOG_INFO_TYPE type)
{
	const char_t* arg_arry[] = {(char_t*)info};
	return output_log(arg_arry, 1, type);
}
Esempio n. 17
0
JNIEXPORT jboolean JNICALL Java_com_bkc_android_mdxplayer_PCMRender_sdrv_1open
  (JNIEnv *env, jobject obj, jstring path)
{
	int err;
	
	// kick double
	if ( op_mode )
		return JNI_TRUE;
		
	if ( !pmdinit_flag )
	{
		pmd_init();
		pmdinit_flag = 1;
	}
	
	const char *file = (*env)->GetStringUTFChars( env , path , NULL );
	
	if ( pmd_is_pmd( file ) )
	{
		op_mode = MODE_PMD;
		pmd_setrate ( freq );
		err = pmd_play ( file , pcmdir ); 
	}
	else
	{
		op_mode = MODE_MDX;
		mdx_set_rate ( freq );

		err = mdx_open( &mdx_data , (char *)file , pcmdir );
	}
	
	output_log("freq = %d MAX_SIZE=%d",
               freq,
               MAX_SIZE);
    
    output_log("Library : DATE:%s TIME:%s",
               __DATE__,
               __TIME__);
	
	(*env)->ReleaseStringUTFChars( env , path , file );
	
	
	if ( op_mode == MODE_MDX )
	{
		song_len = mdx_get_length( &mdx_data );
		mdx_set_max_loop( &mdx_data , 0 );
		
			
	}
	if ( op_mode == MODE_PMD )
		song_len = ( pmd_length_sec() + pmd_loop_sec() );
		
	
	
	fade_init();
	
	
	if (err)
	{
		op_mode = MODE_NONE;
		return JNI_TRUE;		
	}

	return JNI_FALSE;
}
int load_config_file(char_t const* config_path)
{
	int is_ok = APP_SUCCESS;
	HANDLE file_handle = NULL;
	char buf[MAX_STRING_SIZE] = {0};
	char line[MAX_STRING_SIZE * 2] = {0};
	char *ptr = NULL;
	DWORD size = 0x0, i = 0, cur_line_size = 0x0, j = 0, arg_size = 0;

	__matrix_zero_Memory(&__segd_file, sizeof(__segd_file));
	__matrix_zero_Memory(&__config_file_lines, sizeof(__config_file_lines));
	__config_file_line_size = 0x0;

	__matrix_strcpy_s(__segd_file.config_path_, sizeof(__segd_file.config_path_)/sizeof(__segd_file.config_path_[0]), config_path);

	file_handle = CreateFile(config_path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 
										NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if(file_handle == INVALID_HANDLE_VALUE){
		set_last_error(IDS_STRING5008);
		output_log(IDS_STRING5008, get_last_error());
		is_ok = APP_FAULT;
		goto GOTO;
	}

	//read all lines
	while(ReadFile(file_handle, buf, sizeof(buf), &size,NULL)){
		
		if(size == 0) break;
		for(i = 0; i < size; ++i){
			if(buf[i] == 0x0d){
			
				if(cur_line_size == 0) continue;

				memcpy(__config_file_lines[__config_file_line_size].line_, line, cur_line_size);
				__config_file_lines[__config_file_line_size].line_[cur_line_size] = NULL;

				StrTrimA(line, " 	");
				cur_line_size = strlen(line);
				if(cur_line_size == 0) continue;

				//parse all option
				ptr = __config_file_lines[__config_file_line_size].key_name_;
				for(arg_size = 1, j = 0; j < cur_line_size; ++j){

					if(line[j] == '#'){	break;}
					else if(line[j] == ' '){

						if(line[j] == line[j+1]) continue;
						if(arg_size == 2){ *ptr++ = line[j];}
						else{
							*++ptr = NULL;
							ptr = __config_file_lines[__config_file_line_size].value_;
							++arg_size;
						}
					}
					else{	*ptr++ = line[j];	}
				}

				cur_line_size = 0x0;
				memset(line, 0x0, sizeof(line));
				++__config_file_line_size;
			}
			else{

				if(buf[i] != 0xa){
					line[cur_line_size] = buf[i];
					++cur_line_size;
				}
			}
		}
	}

	size = sizeof(__segd_option_items) / sizeof(__segd_option_items[0]);
	for(i = 0; i < __config_file_line_size; ++i){

		if(strlen(__config_file_lines[i].key_name_) == 0) continue;
		for(j = 0; j < size; ++j){			
			if(strcmp(__config_file_lines[i].key_name_, __segd_option_items[j].key_name_) == 0){				
				__segd_option_items[j].function_ptr_(__segd_option_items[j].value_ptr_, __config_file_lines[i].value_);
				break;
			}
		}
	}
GOTO:
	if(file_handle != INVALID_HANDLE_VALUE)	CloseHandle(file_handle);
	return is_ok;
}