bool parse_entity(const char * & ptr,pfc::string8 & name,pfc::string8 & value) { char delimiter = '\0'; char tmp; t_size n = 0; while(isspace((unsigned char) *ptr)) ptr++; while(tmp = ptr[n], tmp && !isspace((unsigned char) tmp) && tmp != '=') n++; if (!ptr[n]) return false; name.set_string(ptr, n); ptr += n; while(isspace((unsigned char) *ptr)) ptr++; if (*ptr != '=') return false; ptr++; while(isspace((unsigned char) *ptr)) ptr++; // check delimiter if (*ptr == '\'' || *ptr == '"') { delimiter = *ptr; ptr++; } if (!*ptr) return false; n = 0; if (delimiter == '\0') { while(tmp = ptr[n], tmp && !isspace((unsigned char) tmp) && tmp != ';') n++; } else { while(tmp = ptr[n], tmp && tmp != delimiter) n++; } //if (!ptr[n]) return false; value.set_string(ptr, n); ptr += n; if (delimiter && *ptr == delimiter) ptr++; while(*ptr == ';' || isspace((unsigned char) *ptr)) ptr++; return true; }
pfc::string8 get_url(pfc::string8 url, abort_callback &p_abort) { pfc::string8 data; http_client::ptr client; try { if (!service_enum_t<http_client>().first(client)) { console::print("feed downloading: error, unable to start http service"); return data; } http_request::ptr request = client->create_request("GET"); file::ptr file_ptr = request->run(url.get_ptr(), p_abort); char buffer[1025]; t_size bytes_read; while (bytes_read = file_ptr->read(buffer, 1024, p_abort)) { data.add_string(buffer, bytes_read); } return data; } catch (exception_aborted) { console::print("feed downloading: aborted"); throw exception_aborted(); } catch (...) { console::print("feed downloading: error, aborted"); return data; } }
void reset() { path.reset(); command = 0; // files.delete_all(); // commands.free_all(); }
void toolbar_extension::button::custom_image::get_path(pfc::string8 & p_out) const { p_out.reset(); bool b_absolute = pfc::string_find_first(m_path, ':') != pfc_infinite || (m_path.length() > 1 && m_path.get_ptr()[0] == '\\' && m_path.get_ptr()[1] == '\\'); bool b_relative_to_drive = !b_absolute && m_path.get_ptr()[0] == '\\'; pfc::string8 fb2kexe; uGetModuleFileName(NULL, fb2kexe); //pfc::string8 fullPath; if (b_relative_to_drive) { t_size index_colon = fb2kexe.find_first(':'); if (index_colon != pfc_infinite) p_out.add_string(fb2kexe.get_ptr(), index_colon + 1); } else if (!b_absolute) p_out << pfc::string_directory(fb2kexe) << "\\"; p_out += m_path; }
bool find_menu_path( GUID & parent, pfc::string8 & out ) { if ( parent == pfc::guid_null ) { out.set_string( "main menu" ); return true; } else { service_enum_t<mainmenu_group> e; service_ptr_t<mainmenu_group> ptr; while ( e.next( ptr ) ) { if ( ptr->get_guid() == parent ) { pfc::string8 tmp; service_ptr_t<mainmenu_group_popup> popup; if ( ptr->service_query_t( popup ) ) { popup->get_display_string( tmp ); find_menu_path( ptr->get_parent(), out ); out.add_string( "/" ); out.add_string( tmp ); return true; } else { find_menu_path( ptr->get_parent(), out ); return true; } } } } out.set_string( "main menu" ); return false; }
void update() { pfc::string8 title; if ( path.length() ) { title = pfc::string_filename_ext( path ); title += " - "; } title += "DUMB"; uSetWindowText( wnd, title ); BOOL enable = song_renderer != 0 && cfg_control_override; HWND w; for ( unsigned i = 0; i < DUMB_IT_N_CHANNELS; ++i ) { w = GetDlgItem( wnd, IDC_VOICE1 + i ); uSendMessage( w, BM_SETCHECK, ! ( ( mute_mask >> i ) & 1 ) , 0 ); EnableWindow( w, enable ); ShowWindow( w, ( ( t_uint64(1) << i ) & channels_allowed ) ? SW_SHOWNA : SW_HIDE ); } }
void make_path(const char * parent,const char * filename,const char * extension,bool allow_new_dirs,pfc::string8 & out,bool really_create_dirs,abort_callback & p_abort) { out.reset(); if (parent && *parent) { out = parent; out.fix_dir_separator('\\'); } bool last_char_is_dir_sep = true; while(*filename) { #ifdef WIN32 if (allow_new_dirs && is_bad_dirchar(*filename)) { const char * ptr = filename+1; while(is_bad_dirchar(*ptr)) ptr++; if (*ptr!='\\' && *ptr!='/') out.add_string(filename,ptr-filename); filename = ptr; if (*filename==0) break; } #endif if (pfc::is_path_bad_char(*filename)) { if (allow_new_dirs && (*filename=='\\' || *filename=='/')) { if (!last_char_is_dir_sep) { if (really_create_dirs) try { filesystem::g_create_directory(out,p_abort); } catch(exception_io_already_exists) {} out.add_char('\\'); last_char_is_dir_sep = true; } } else out.add_char('_'); } else { out.add_byte(*filename); last_char_is_dir_sep = false; } filename++; } if (out.length()>0 && out[out.length()-1]=='\\') { out.add_string("noname"); } if (extension && *extension) { out.add_char('.'); out.add_string(extension); } }
String^ FromUtf8String(pfc::string8 &value) { return FromUtf8String(value.get_ptr()); }
} String^ FromUtf8String(pfc::string8 &value) { return FromUtf8String(value.get_ptr()); } pfc::string8 ToUtf8String(String ^value) { if (String::IsNullOrEmpty(value)) return pfc::string8(); cli::array<unsigned char>^ bytes = Encoding::UTF8->GetBytes(value); int len = bytes->Length; pfc::string8 buffer; void* ptr = buffer.lock_buffer(len); Marshal::Copy(bytes, 0, (IntPtr)ptr, len); buffer.unlock_buffer(); return buffer; } } namespace _console {
void alert(pfc::string8 msg) { console::complain("boom", msg.toString()); }