WRAP_API int wrap_mvwinsnstr(WINDOW *win, int y, int x, uchar2 *str, int n) { #if defined(CURSES_WIDE) && SIZEOF_WCHAR_T == 2 return mvwins_nwstr(win, y, x, str, n); #elif defined(CURSES_WIDE) wchar_t stackbuf[BUFFER_SIZE]; xbuffer xinput, xoutput; int ret; xbuf_init_uc(&xinput, str, n, XBUF_FILL); xbuf_init_wc(&xoutput, stackbuf, BUFFER_SIZE, XBUF_EXPANDABLE); ret = unicode_to_wchar(&xinput, &xoutput); if (ret < 0) goto do_exit; ret = xbuf_tzero_wc(&xoutput); if (ret < 0) goto do_exit; ret = mvwins_nwstr(win, y, x, xbuf_data_wc(&xoutput), xbuf_len_wc(&xoutput)); do_exit: xbuf_free(&xoutput); return ret; #else char stackbuf[BUFFER_SIZE]; xbuffer xinput, xoutput; int ret; xbuf_init_uc(&xinput, str, n, XBUF_FILL); xbuf_init(&xoutput, stackbuf, BUFFER_SIZE, XBUF_EXPANDABLE); ret = unicode_to_char(&xinput, &xoutput); if (ret < 0) goto do_exit; ret = xbuf_tzero(&xoutput); if (ret < 0) goto do_exit; ret = mvwinsnstr(win, y, x, xbuf_data(&xoutput), xbuf_len(&xoutput)); do_exit: xbuf_free(&xoutput); return ret; #endif }
static void epdf_index_fill (Ecore_List *items, GooList *gitems) { if (!items || !gitems) return; for (int i = 0; i < gitems->getLength (); i++) { Epdf_Index_Item *item; OutlineItem *oitem = (OutlineItem *)gitems->get (i); Unicode *utitle = oitem->getTitle (); item = epdf_index_item_new (); item->title = unicode_to_char (utitle, oitem->getTitleLength ()); item->action = oitem->getAction (); oitem->open (); if (oitem->hasKids () && oitem->getKids ()) { item->children = ecore_list_new (); epdf_index_fill (item->children, oitem->getKids ()); } ecore_list_append (items, item); } }
javacall_result javacall_security_keystore_start(javacall_handle* jc_h) { javacall_utf16 rootPath[JAVACALL_MAX_FILE_NAME_LENGTH]; unsigned short unicode_main_ks[] = {'\\','_','m','a','i','n','.','k','s'}; int unicode_main_ks_name_length = sizeof(unicode_main_ks)/sizeof(unsigned short); javacall_result result; javacall_handle handle; int rootPathLen = JAVACALL_MAX_FILE_NAME_LENGTH; int res; int i; memset(rootPath, 0, JAVACALL_MAX_FILE_NAME_LENGTH); result = javacall_dir_get_root_path(rootPath, &rootPathLen); if(result == JAVACALL_FAIL) { return JAVACALL_FAIL; } if(rootPathLen < (JAVACALL_MAX_FILE_NAME_LENGTH - unicode_main_ks_name_length)) { for(i = 0; i < unicode_main_ks_name_length; i++) { rootPath[rootPathLen+i] = unicode_main_ks[i]; } rootPathLen+=i; } else { printf("javacall_security.c : File name %d, is to long.\n", unicode_to_char(rootPath)); return JAVACALL_FAIL; } javacall_set_local_variables(); currentPosition = NULL; printf("Opening %s.\n", unicode_to_char(rootPath)); result = javacall_file_open(rootPath, rootPathLen, JAVACALL_FILE_O_RDONLY, &handle); if(result == JAVACALL_FAIL) { printf("Can't open %s.\n", unicode_to_char(rootPath)); return JAVACALL_FAIL; } main_ks_size = (int)javacall_file_sizeofopenfile(handle); if(-1 == main_ks_size) { javacall_file_close(handle); printf("Can't get javacall_file_sizeofopenfile() %s\n", unicode_to_char(rootPath)); return JAVACALL_FAIL; } _main_ks_content = (unsigned char *) malloc(main_ks_size); if(_main_ks_content == NULL) { javacall_file_close(handle); return JAVACALL_FAIL; } res = javacall_file_read(handle, _main_ks_content, main_ks_size); if(res <= 0 ) { printf("Can't read %s\n", unicode_to_char(rootPath)); free(_main_ks_content); javacall_file_close(handle); return JAVACALL_FAIL; } javacall_file_close(handle); currentPosition = _main_ks_content; if(*currentPosition != CURRENT_VERSION) { printf("Can't read this key storage. Current version isn't correct\n"); free(_main_ks_content); currentPosition = NULL; return JAVACALL_FAIL; } currentPosition++; *jc_h = (javacall_handle)(¤tPosition); return JAVACALL_OK; } /* end of javacall_security_keystore_start */