* Makefile.in (OBJS): Add new object.
* PickCategoryLine.cc (PickCategoryLine::paint): Print a "+" before the name.
* PickCategoryLine.h (PickCategoryLine::bucket): Use the String class.
* PickLine.h (Pickline::key): Change to a String to help plug leaks.
(PickLine::Pickline): Accept a String for the key.
* PickPackageLine.cc (PickPackageLine::paint): Convert all char use to Strings.
* PickPackageLine.h (PickPackageLine::PickPackageLine): The key is automatically
initialisednow.
* PickView.cc (PickView::note_width): Convert all char * use to Strings.
(PickView::init_header): Move category length checking out of the inner loop for
efficiency.
Convert all char use to Strings.
* PickView.h: Include the String++ header.
(PickView::note_width): Update the prototype.
* String++.cc: New file, implements a reference counting string class.
* String++.h: New file, declares a reference counting string class.
* archive.cc: Include String++ instead of concat.
(archive::extract_file): Convert char * usage to Strings.
* archive.h: Inlude the String++ header.
(archive::extract_file): Update prototype.
(archive::next_file_name): Convert to a String.
(archive::linktarget): Ditto.
* archive_tar.cc (archive_tar::next_file_name): Convert to String usage.
(archive_tar::linktarget): Ditto.
* arhive_tar.h: Update the copyright.
Explicitly include the relevant headers.
(tar_map_result_type): Convert to String usage.
(archive_tar::next_file_name): Update prototype.
(archive_tar::linktarget): Ditto.
* category.cc (Category::Category): Update initialisers.
Convert to String usage.
(Categorycmp): Update to String usage.
* category.h: Include the String++ header.
(Category::Category): Update to String usage.
(Category::name): Ditto.
(Category::key): Ditto.
* choose.cc: Remove concat.h, it's not needed.
(scan2): Update to String usage.
(do_choose): Ditto.
* cygpackage.cc: Update includes for use of String class.
(cygpackage::cygpackage): Update for String usage.
(cygpackage::set_canonical_version): Ditto.
(cygpackage::destroy): Ditto.
(cygpackage::getfirstfile): Ditto.
(cygpackage::getnextfile): Ditto.
(cygpackage::Name): Ditto.
(cygpackage::Vendor_version): Ditto.
(cygpackage::Package_version): Ditto.
(cygpackage::Canonical_version): Ditto.
(cygpackage::set_sdesc): Ditto.
(cygpackage::set_ldesc): Ditto.
* cygpackage.h: Include String++.h for parsing this file.
(cygpackage::cygpackage): Update for String usage.
(cygpackage::set_canonical_version): Ditto.
(cygpackage::destroy): Ditto.
(cygpackage::getfirstfile): Ditto.
(cygpackage::getnextfile): Ditto.
(cygpackage::Name): Ditto.
(cygpackage::Vendor_version): Ditto.
(cygpackage::Package_version): Ditto.
(cygpackage::Canonical_version): Ditto.
(cygpackage::set_sdesc): Ditto.
(cygpackage::set_ldesc): Ditto.
(cygpackage::name): Ditto.
(cygpackage::vendor): Ditto.
(cygpackage::packagev): Ditto.
(cygpackage::canonical): Ditto.
(cygpackage::fn): Ditto.
(cygpackage::sdesc): Ditto.
(cygpackage::ldesc): Ditto.
* desktop.cc: Update includes for use of String class.
(batname): Update for String usage.
(iconname): Ditto.
(make_link): Ditto.
(start)menu): Ditto.
(desktop_icon): Ditto.
(make_cygwin_bat): Ditto.
(make_etc_profile): Ditto.
(uexists): Ditto.
(make_passwd_group): Ditto.
(save_icon): Ditto.
(check_desktop): Ditto.
(check_startmenu): Ditto.
* dialog.cc (eget): Update for String usage.
(egetString): New function.
(eset): New variant for Strings.
* dialog.h: Include String++.h for parsing this file.
(egetString): New function.
(eset): New variant for Strings.
* diskfull.cc (diskfull): Update for String usage.
* diskfull.h: Include String++.h for parsing this file.
(diskfull): Update for String usage.
* download.cc: Update includes for use of String class.
(check_for_cached): Update for String usage.
(download_one): Ditto.
* filemanip.cc (get_file_size): Ditto.
(base): Ditto.
(parse_filename): Ditto.
(backslash): Ditto.
* filemanip.h: Include String++.h for parsing this file.
(fileparse): Update for String usage.
(base): Ditto.
(parse_filename): Ditto.
Don't consider '_' to be a separator.
(backslash): Ditto.
* find.cc: Update includes for use of String class.
(find_sub): Make more flexible.
(find): Update for String usage.
* find.h (find): Use Strings.
* fromcwd.cc (found_file): Update for String usage.
* geturl.cc: Ditto.
(init_dialog): Ditto.
(get_url_to_membuf): Ditto.
(get_url_to_string): Ditto.
(get_url_to_file): Ditto.
* geturl.h: Ditto.
(get_url_to_membuf): Ditto.
(get_url_to_string): Ditto.
(get_url_to_file): Ditto.
* hash.h: Ditto.
(add_subdirs): Ditto.
* ini.cc: Update includes for String usage.
(find_routine): Update for String usage.
(do_remote_ini): Ditto.
(do_ini_thread): Ditto.
* ini.h (ini_init): Ditto.
* inilex.l: Update includes for String usage.
(ini_init): Update for String usage.
* iniparse.y: Ditto.
(add_correct_version): Ditto.
* install.cc: Update includes for String usage.
(install_one_source): Update for String usage.
(uninstall_one): Ditto.
(replace_one): Ditto.
(install_one_source): Ditto.
(do_install_thread): Ditto.
* io_stream.cc: Update includes for String usage.
(io_stream::open): Update for String usage.
(io_stream::mkpath_p): Ditto.
(io_stream::remove): Ditto.
(io_stream::mklink): Ditto.
(io_stream::move_copy): Ditto.
(io_stream::move): Ditto.
(io_stream::exists): Ditto.
* io_stream.h: Update includes to allow correct parsing.
(io_stream::open): Update for String usage.
(io_stream::mkpath_p): Ditto.
(io_stream::remove): Ditto.
(io_stream::mklink): Ditto.
(io_stream::move_copy): Ditto.
(io_stream::move): Ditto.
(io_stream::exists): Ditto.
* io_stream_cygfile.cc: Update includes for String usage.
(get_root_dir_now): Update for String usage.
(io_stream_cygfile::io_stream_cygfile): Ditto.
(io_stream_cygfile::~io_stream_cygfile): Ditto.
(io_stream_cygfile::exists): Ditto.
(io_stream_cygfile::remove): Ditto.
(io_stream_cygfile::mklink): Ditto.
(cygmkdir_p): Ditto.
(io_stream_cygfile::set_mtime): Ditto.
(io_stream_cygfile::move): Ditto.
(io_stream_cygfile::get_size): Ditto.
* io_stream_cygfile.h: Update includes for String usage.
(io_stream_cygfile::io_stream_cygfile): Update for String usage.
(io_stream_cygfile::~io_stream_cygfile): Ditto.
(io_stream_cygfile::exists): Ditto.
(io_stream_cygfile::remove): Ditto.
(io_stream_cygfile::mklink): Ditto.
(cygmkdir_p): Ditto.
(io_stream_cygfile::set_mtime): Ditto.
(io_stream_cygfile::move): Ditto.
(io_stream_cygfile::get_size): Ditto.
(io_stream_cygfile::fname): Ditto.
(io_stream_cygfile::lmode): Ditto.
* io_stream_file.cc: Update includes for String usage.
(io_stream_file::io_stream_file): Update for String usage.
(io_stream_file::~io_stream_file): Ditto.
(io_stream_file::exists): Ditto.
(io_stream_file::remove): Ditto.
(io_stream_file::mklink): Ditto.
(io_stream_file::set_mtime): Ditto.
(io_stream_file::move): Ditto.
(io_stream_file::get_size): Ditto.
* io_stream_file.h: Update includes for String usage.
* io_stream_file.cc: Update includes for String usage.
(io_stream_file::io_stream_file): Update for String usage.
(io_stream_file::~io_stream_file): Ditto.
(io_stream_file::exists): Ditto.
(io_stream_file::remove): Ditto.
(io_stream_file::mklink): Ditto.
(io_stream_file::set_mtime): Ditto.
(io_stream_file::move): Ditto.
(io_stream_file::get_size): Ditto.
(io_stream_file::fname): Ditto.
(io_stream_file::lmode): Ditto.
* localdir.cc: Update includes for String usage.
(save_local_dir): Update for String usage.
(check_if_enable_next): Ditto.
(load_dialog): Ditto.
(browse_cb): Ditto.
(LocalDirPage::OnInit): Ditto.
(LocalDirPage::OnNext): Ditto.
* log.cc: Update includes for String usage.
(struct LogEnt): Update for String usage.
(log): Ditto.
(log_save): Ditto.
(exit_setup): Ditto.
* log.h: Update includes for String usage.
(log_level): Update for String usage.
(log): Ditto.
(log_save): Ditto.
* main.cc (WinMain): Update for String usage.
* mklink2.c (make_link_2): Update for String usage.
* mklink2.h (make_link_2): Update for String usage.
* mount.cc: Update includes for String usage.
(mount_table): Update for String usage.
(find2): Ditto.
(create_mount): Ditto.
(remove1): Ditto.
(remove_mount): Ditto.
(read_mounts): Ditto.
(set_root_dir): Ditto.
(get_root_dir): Ditto.
(path_prefix_p): Ditto.
(cygpath): Ditto.
* mount.h: Update includes for String usage.
(create_mount): Update for String usage.
(remove_mount): Ditto.
(cygpath): Ditto.
(set_root_dir): Ditto.
(get_root_dir): Ditto.
* msg.cc (mbox): Ditto.
* net.cc (NetPage::OnNext): Ditto.
* package_db.cc (packagedb::flush): Ditto.
(packagedb::packages): Ditto.
(packagedb::categories): Ditto.
* package_db.h: Update includes for String usage.
(packagedb::packages): Update for String usage.
(packagedb::categories): Ditto.
* package_meta.cc: Update includes for String usage.
(hash::add_subdirs): Update for String usage.
(packagemeta::uninstall): Ditto.
(packagemeta::SDesc): Ditto.
(packagemeta::action_caption): Ditto.
* package_meta.h: Update includes for String usage.
(packagemeta::packagemeta): Update for String usage.
(packagemeta::~packagemeta): Ditto.
(packagemeta::uninstall): Ditto.
(packagemeta::SDesc): Ditto.
(packagemeta::action_caption): Ditto.
(package_source.cc site::site): Ditto.
(packagesource::set_canonical): Ditto.
(packagesource::set_cached): Ditto.
* package_source.h: Update includes for String usage.
(site::site): Update for String usage.
(packagesource::set_canonical): Ditto.
(packagesource::set_cached): Ditto.
(packagesource::packagesource): Ditto.
(packagesource::sites): Ditto.
(packagesource::cached): Ditto.
* package_version.h: Update includes for String usage.
(Dependency): Update for String usage.
(packageversion): Ditto.
* postinstall.cc: Update includes for String usage.
(do_postinstall): Update for String usage.
* res.rc (IDD_LOCAL_DIR): Fix typo again!
* rfc1738.cc (rfc1738_escape_part): Update for String usage.
* rfc1738.h: Update includes for String usage.
(rfc1738_escape_part): Update for String usage.
* root.cc: Update includes for String usage.
(check_if_enable_next): Update for String usage.
(save_dialog): Ditto.
(browse_cb): Ditto.
(directory_is_absolute): Ditto.
(directory_is_rootdir): Ditto.
(directory_has_spaces): Ditto.
(RootPage::OnInit): Ditto.
(RootPage::OnNext): Ditto.
* script.cc: Update includes for String usage.
(init_run_script): Update for String usage.
(run): Ditto.
(run_script): Ditto.
(try_run_script): Ditto.
* script.h: Update includes for String usage.
(run_script): Update for String usage.
(try_run_script): Ditto.
* site.cc site_list): Ditto.
(all_site_list): Ditto.
(other_url): Eliminate.
(site_list_type::init): Update for String usage.
(site_list_type::site_list_type): Ditto.
(get_site_list): Ditto.
(get_saved_sites): Ditto.
(do_download_site_info_thread): Ditto.
(SitePage::OnNext): Ditto.
(SitePage::OnActivate): Ditto.
(SitePage::PopulateListBox): Ditto.
(SitePage::OnMessageCmd): Handle empty url's.
* site.h: Update includes for String usage.
(site_list_type::site_list_type): Update for String usage.
(site_list_type::init): Ditto.
(site_list_type::~site_list_type): Ditto.
(site_list_type::url): Ditto.
(site_list_type::displayed_url): Ditto.
(site_list_type::key): Ditto.
* source.cc (SourcePage::OnDeactivate): Ditto.
* state.h: Update includes for String usage.
(local_dir): Update for String usage.
(trust_level): Remove.
* version.cc: Update includes for String usage.
(canonicalize_version): Update for String usage.
* version.h: Update includes for String usage.
(canonicalize_version): Update for String usage.
+2002-02-19 Robert Collins <rbtcollins@hotmail.com>
+
+ * Makefile.in (OBJS): Add new object.
+ * PickCategoryLine.cc (PickCategoryLine::paint): Print a "+" before the name.
+ * PickCategoryLine.h (PickCategoryLine::bucket): Use the String class.
+ * PickLine.h (Pickline::key): Change to a String to help plug leaks.
+ (PickLine::Pickline): Accept a String for the key.
+ * PickPackageLine.cc (PickPackageLine::paint): Convert all char use to Strings.
+ * PickPackageLine.h (PickPackageLine::PickPackageLine): The key is automatically
+ initialisednow.
+ * PickView.cc (PickView::note_width): Convert all char * use to Strings.
+ (PickView::init_header): Move category length checking out of the inner loop for
+ efficiency.
+ Convert all char use to Strings.
+ * PickView.h: Include the String++ header.
+ (PickView::note_width): Update the prototype.
+ * String++.cc: New file, implements a reference counting string class.
+ * String++.h: New file, declares a reference counting string class.
+ * archive.cc: Include String++ instead of concat.
+ (archive::extract_file): Convert char * usage to Strings.
+ * archive.h: Inlude the String++ header.
+ (archive::extract_file): Update prototype.
+ (archive::next_file_name): Convert to a String.
+ (archive::linktarget): Ditto.
+ * archive_tar.cc (archive_tar::next_file_name): Convert to String usage.
+ (archive_tar::linktarget): Ditto.
+ * arhive_tar.h: Update the copyright.
+ Explicitly include the relevant headers.
+ (tar_map_result_type): Convert to String usage.
+ (archive_tar::next_file_name): Update prototype.
+ (archive_tar::linktarget): Ditto.
+ * category.cc (Category::Category): Update initialisers.
+ Convert to String usage.
+ (Categorycmp): Update to String usage.
+ * category.h: Include the String++ header.
+ (Category::Category): Update to String usage.
+ (Category::name): Ditto.
+ (Category::key): Ditto.
+ * choose.cc: Remove concat.h, it's not needed.
+ (scan2): Update to String usage.
+ (do_choose): Ditto.
+ * cygpackage.cc: Update includes for use of String class.
+ (cygpackage::cygpackage): Update for String usage.
+ (cygpackage::set_canonical_version): Ditto.
+ (cygpackage::destroy): Ditto.
+ (cygpackage::getfirstfile): Ditto.
+ (cygpackage::getnextfile): Ditto.
+ (cygpackage::Name): Ditto.
+ (cygpackage::Vendor_version): Ditto.
+ (cygpackage::Package_version): Ditto.
+ (cygpackage::Canonical_version): Ditto.
+ (cygpackage::set_sdesc): Ditto.
+ (cygpackage::set_ldesc): Ditto.
+ * cygpackage.h: Include String++.h for parsing this file.
+ (cygpackage::cygpackage): Update for String usage.
+ (cygpackage::set_canonical_version): Ditto.
+ (cygpackage::destroy): Ditto.
+ (cygpackage::getfirstfile): Ditto.
+ (cygpackage::getnextfile): Ditto.
+ (cygpackage::Name): Ditto.
+ (cygpackage::Vendor_version): Ditto.
+ (cygpackage::Package_version): Ditto.
+ (cygpackage::Canonical_version): Ditto.
+ (cygpackage::set_sdesc): Ditto.
+ (cygpackage::set_ldesc): Ditto.
+ (cygpackage::name): Ditto.
+ (cygpackage::vendor): Ditto.
+ (cygpackage::packagev): Ditto.
+ (cygpackage::canonical): Ditto.
+ (cygpackage::fn): Ditto.
+ (cygpackage::sdesc): Ditto.
+ (cygpackage::ldesc): Ditto.
+ * desktop.cc: Update includes for use of String class.
+ (batname): Update for String usage.
+ (iconname): Ditto.
+ (make_link): Ditto.
+ (start)menu): Ditto.
+ (desktop_icon): Ditto.
+ (make_cygwin_bat): Ditto.
+ (make_etc_profile): Ditto.
+ (uexists): Ditto.
+ (make_passwd_group): Ditto.
+ (save_icon): Ditto.
+ (check_desktop): Ditto.
+ (check_startmenu): Ditto.
+ * dialog.cc (eget): Update for String usage.
+ (egetString): New function.
+ (eset): New variant for Strings.
+ * dialog.h: Include String++.h for parsing this file.
+ (egetString): New function.
+ (eset): New variant for Strings.
+ * diskfull.cc (diskfull): Update for String usage.
+ * diskfull.h: Include String++.h for parsing this file.
+ (diskfull): Update for String usage.
+ * download.cc: Update includes for use of String class.
+ (check_for_cached): Update for String usage.
+ (download_one): Ditto.
+ * filemanip.cc (get_file_size): Ditto.
+ (base): Ditto.
+ (parse_filename): Ditto.
+ (backslash): Ditto.
+ * filemanip.h: Include String++.h for parsing this file.
+ (fileparse): Update for String usage.
+ (base): Ditto.
+ (parse_filename): Ditto.
+ Don't consider '_' to be a separator.
+ (backslash): Ditto.
+ * find.cc: Update includes for use of String class.
+ (find_sub): Make more flexible.
+ (find): Update for String usage.
+ * find.h (find): Use Strings.
+ * fromcwd.cc (found_file): Update for String usage.
+ * geturl.cc: Ditto.
+ (init_dialog): Ditto.
+ (get_url_to_membuf): Ditto.
+ (get_url_to_string): Ditto.
+ (get_url_to_file): Ditto.
+ * geturl.h: Ditto.
+ (get_url_to_membuf): Ditto.
+ (get_url_to_string): Ditto.
+ (get_url_to_file): Ditto.
+ * hash.h: Ditto.
+ (add_subdirs): Ditto.
+ * ini.cc: Update includes for String usage.
+ (find_routine): Update for String usage.
+ (do_remote_ini): Ditto.
+ (do_ini_thread): Ditto.
+ * ini.h (ini_init): Ditto.
+ * inilex.l: Update includes for String usage.
+ (ini_init): Update for String usage.
+ * iniparse.y: Ditto.
+ (add_correct_version): Ditto.
+ * install.cc: Update includes for String usage.
+ (install_one_source): Update for String usage.
+ (uninstall_one): Ditto.
+ (replace_one): Ditto.
+ (install_one_source): Ditto.
+ (do_install_thread): Ditto.
+ * io_stream.cc: Update includes for String usage.
+ (io_stream::open): Update for String usage.
+ (io_stream::mkpath_p): Ditto.
+ (io_stream::remove): Ditto.
+ (io_stream::mklink): Ditto.
+ (io_stream::move_copy): Ditto.
+ (io_stream::move): Ditto.
+ (io_stream::exists): Ditto.
+ * io_stream.h: Update includes to allow correct parsing.
+ (io_stream::open): Update for String usage.
+ (io_stream::mkpath_p): Ditto.
+ (io_stream::remove): Ditto.
+ (io_stream::mklink): Ditto.
+ (io_stream::move_copy): Ditto.
+ (io_stream::move): Ditto.
+ (io_stream::exists): Ditto.
+ * io_stream_cygfile.cc: Update includes for String usage.
+ (get_root_dir_now): Update for String usage.
+ (io_stream_cygfile::io_stream_cygfile): Ditto.
+ (io_stream_cygfile::~io_stream_cygfile): Ditto.
+ (io_stream_cygfile::exists): Ditto.
+ (io_stream_cygfile::remove): Ditto.
+ (io_stream_cygfile::mklink): Ditto.
+ (cygmkdir_p): Ditto.
+ (io_stream_cygfile::set_mtime): Ditto.
+ (io_stream_cygfile::move): Ditto.
+ (io_stream_cygfile::get_size): Ditto.
+ * io_stream_cygfile.h: Update includes for String usage.
+ (io_stream_cygfile::io_stream_cygfile): Update for String usage.
+ (io_stream_cygfile::~io_stream_cygfile): Ditto.
+ (io_stream_cygfile::exists): Ditto.
+ (io_stream_cygfile::remove): Ditto.
+ (io_stream_cygfile::mklink): Ditto.
+ (cygmkdir_p): Ditto.
+ (io_stream_cygfile::set_mtime): Ditto.
+ (io_stream_cygfile::move): Ditto.
+ (io_stream_cygfile::get_size): Ditto.
+ (io_stream_cygfile::fname): Ditto.
+ (io_stream_cygfile::lmode): Ditto.
+ * io_stream_file.cc: Update includes for String usage.
+ (io_stream_file::io_stream_file): Update for String usage.
+ (io_stream_file::~io_stream_file): Ditto.
+ (io_stream_file::exists): Ditto.
+ (io_stream_file::remove): Ditto.
+ (io_stream_file::mklink): Ditto.
+ (io_stream_file::set_mtime): Ditto.
+ (io_stream_file::move): Ditto.
+ (io_stream_file::get_size): Ditto.
+ * io_stream_file.h: Update includes for String usage.
+ * io_stream_file.cc: Update includes for String usage.
+ (io_stream_file::io_stream_file): Update for String usage.
+ (io_stream_file::~io_stream_file): Ditto.
+ (io_stream_file::exists): Ditto.
+ (io_stream_file::remove): Ditto.
+ (io_stream_file::mklink): Ditto.
+ (io_stream_file::set_mtime): Ditto.
+ (io_stream_file::move): Ditto.
+ (io_stream_file::get_size): Ditto.
+ (io_stream_file::fname): Ditto.
+ (io_stream_file::lmode): Ditto.
+ * localdir.cc: Update includes for String usage.
+ (save_local_dir): Update for String usage.
+ (check_if_enable_next): Ditto.
+ (load_dialog): Ditto.
+ (browse_cb): Ditto.
+ (LocalDirPage::OnInit): Ditto.
+ (LocalDirPage::OnNext): Ditto.
+ * log.cc: Update includes for String usage.
+ (struct LogEnt): Update for String usage.
+ (log): Ditto.
+ (log_save): Ditto.
+ (exit_setup): Ditto.
+ * log.h: Update includes for String usage.
+ (log_level): Update for String usage.
+ (log): Ditto.
+ (log_save): Ditto.
+ * main.cc (WinMain): Update for String usage.
+ * mklink2.c (make_link_2): Update for String usage.
+ * mklink2.h (make_link_2): Update for String usage.
+ * mount.cc: Update includes for String usage.
+ (mount_table): Update for String usage.
+ (find2): Ditto.
+ (create_mount): Ditto.
+ (remove1): Ditto.
+ (remove_mount): Ditto.
+ (read_mounts): Ditto.
+ (set_root_dir): Ditto.
+ (get_root_dir): Ditto.
+ (path_prefix_p): Ditto.
+ (cygpath): Ditto.
+ * mount.h: Update includes for String usage.
+ (create_mount): Update for String usage.
+ (remove_mount): Ditto.
+ (cygpath): Ditto.
+ (set_root_dir): Ditto.
+ (get_root_dir): Ditto.
+ * msg.cc (mbox): Ditto.
+ * net.cc (NetPage::OnNext): Ditto.
+ * package_db.cc (packagedb::flush): Ditto.
+ (packagedb::packages): Ditto.
+ (packagedb::categories): Ditto.
+ * package_db.h: Update includes for String usage.
+ (packagedb::packages): Update for String usage.
+ (packagedb::categories): Ditto.
+ * package_meta.cc: Update includes for String usage.
+ (hash::add_subdirs): Update for String usage.
+ (packagemeta::uninstall): Ditto.
+ (packagemeta::SDesc): Ditto.
+ (packagemeta::action_caption): Ditto.
+ * package_meta.h: Update includes for String usage.
+ (packagemeta::packagemeta): Update for String usage.
+ (packagemeta::~packagemeta): Ditto.
+ (packagemeta::uninstall): Ditto.
+ (packagemeta::SDesc): Ditto.
+ (packagemeta::action_caption): Ditto.
+ (package_source.cc site::site): Ditto.
+ (packagesource::set_canonical): Ditto.
+ (packagesource::set_cached): Ditto.
+ * package_source.h: Update includes for String usage.
+ (site::site): Update for String usage.
+ (packagesource::set_canonical): Ditto.
+ (packagesource::set_cached): Ditto.
+ (packagesource::packagesource): Ditto.
+ (packagesource::sites): Ditto.
+ (packagesource::cached): Ditto.
+ * package_version.h: Update includes for String usage.
+ (Dependency): Update for String usage.
+ (packageversion): Ditto.
+ * postinstall.cc: Update includes for String usage.
+ (do_postinstall): Update for String usage.
+ * res.rc (IDD_LOCAL_DIR): Fix typo again!
+ * rfc1738.cc (rfc1738_escape_part): Update for String usage.
+ * rfc1738.h: Update includes for String usage.
+ (rfc1738_escape_part): Update for String usage.
+ * root.cc: Update includes for String usage.
+ (check_if_enable_next): Update for String usage.
+ (save_dialog): Ditto.
+ (browse_cb): Ditto.
+ (directory_is_absolute): Ditto.
+ (directory_is_rootdir): Ditto.
+ (directory_has_spaces): Ditto.
+ (RootPage::OnInit): Ditto.
+ (RootPage::OnNext): Ditto.
+ * script.cc: Update includes for String usage.
+ (init_run_script): Update for String usage.
+ (run): Ditto.
+ (run_script): Ditto.
+ (try_run_script): Ditto.
+ * script.h: Update includes for String usage.
+ (run_script): Update for String usage.
+ (try_run_script): Ditto.
+ * site.cc site_list): Ditto.
+ (all_site_list): Ditto.
+ (other_url): Eliminate.
+ (site_list_type::init): Update for String usage.
+ (site_list_type::site_list_type): Ditto.
+ (get_site_list): Ditto.
+ (get_saved_sites): Ditto.
+ (do_download_site_info_thread): Ditto.
+ (SitePage::OnNext): Ditto.
+ (SitePage::OnActivate): Ditto.
+ (SitePage::PopulateListBox): Ditto.
+ (SitePage::OnMessageCmd): Handle empty url's.
+ * site.h: Update includes for String usage.
+ (site_list_type::site_list_type): Update for String usage.
+ (site_list_type::init): Ditto.
+ (site_list_type::~site_list_type): Ditto.
+ (site_list_type::url): Ditto.
+ (site_list_type::displayed_url): Ditto.
+ (site_list_type::key): Ditto.
+ * source.cc (SourcePage::OnDeactivate): Ditto.
+ * state.h: Update includes for String usage.
+ (local_dir): Update for String usage.
+ (trust_level): Remove.
+ * version.cc: Update includes for String usage.
+ (canonicalize_version): Update for String usage.
+ * version.h: Update includes for String usage.
+ (canonicalize_version): Update for String usage.
+
2002-02-15 Christopher Faylor <cgf@redhat.com>
* filemanip.c (parse_filename): Revert previous change.
source.o \
splash.o \
state.o \
+ String++.o \
threebar.o \
version.o \
win32.o \
if (show_label)
{
int by = r + theView.tm.tmHeight - 11;
+ String temp=(String("+ ") +cat.name);
TextOut (hdc,
x + theView.headers[theView.cat_col].x + HMARGIN / 2 +
- depth * 8, r, cat.name, strlen (cat.name));
+ depth * 8, r, temp.cstr_oneuse(), temp.size());
if (!labellength)
{
SIZE s;
- GetTextExtentPoint32 (hdc, cat.name, strlen (cat.name), &s);
+ GetTextExtentPoint32 (hdc, temp.cstr_oneuse(), temp.size(), &s);
labellength = s.cx;
}
SelectObject (theView.bitmap_dc, theView.bm_spin);
size_t depth;
PickCategoryLine (PickCategoryLine const &);
PickCategoryLine & operator= (PickCategoryLine const &);
- list < PickLine, char const *, strcasecmp > bucket;
+ list < PickLine, String, String::casecompare > bucket;
PickView& theView;
};
#endif // _PICKCATEGORYLINE_H_
// this may indicate bad inheritance model.
virtual bool IsContainer (void) const = 0;
virtual void insert (PickLine &) = 0;
- // Never allocate to key, always allocated elsewhere
- char const *key;
+ String const key;
virtual ~ PickLine ()
{
};
PickLine ()
{
};
- PickLine (char const *aKey):key (aKey)
+ PickLine (String const &aKey):key (aKey)
{
};
PickLine (PickLine const &);
theView.headers[theView.current_col].width, by + 11);
TextOut (hdc,
x + theView.headers[theView.current_col].x + HMARGIN / 2, r,
- pkg.installed->Canonical_version (),
- strlen (pkg.installed->Canonical_version ()));
+ pkg.installed->Canonical_version ().cstr_oneuse(),
+ pkg.installed->Canonical_version ().size());
SelectObject (theView.bitmap_dc, theView.bm_rtarrow);
BitBlt (hdc, x + theView.headers[theView.new_col].x + HMARGIN / 2,
by, 11, 11, theView.bitmap_dc, 0, 0, SRCCOPY);
SelectClipRgn (hdc, oldClip2);
}
- const char *s = pkg.action_caption ();
+ String s = pkg.action_caption ();
IntersectClipRect (hdc, x + theView.headers[theView.new_col].x,
by,
x + theView.headers[theView.new_col].x +
theView.headers[theView.new_col].width, by + 11);
TextOut (hdc,
x + theView.headers[theView.new_col].x + HMARGIN / 2 +
- NEW_COL_SIZE_SLOP, r, s, strlen (s));
+ NEW_COL_SIZE_SLOP, r, s.cstr_oneuse(), s.size());
SelectObject (theView.bitmap_dc, theView.bm_spin);
BitBlt (hdc,
x + theView.headers[theView.new_col].x + ICON_MARGIN / 2 +
if (pkg.Categories.number () && show_cat)
{
int index = 1;
- if (!strcasecmp (pkg.Categories[1]->key.name, "All"))
+ if (!pkg.Categories[1]->key.name.casecompare( "All"))
index = 2;
IntersectClipRect (hdc, x + theView.headers[theView.cat_col].x, by,
x + theView.headers[theView.cat_col].x +
theView.headers[theView.cat_col].x, by + 11);
TextOut (hdc, x + theView.headers[theView.cat_col].x + HMARGIN / 2, r,
- pkg.Categories[index]->key.name,
- strlen (pkg.Categories[index]->key.name));
+ pkg.Categories[index]->key.name.cstr_oneuse(),
+ pkg.Categories[index]->key.name.size());
SelectClipRgn (hdc, oldClip2);
}
- if (!pkg.SDesc ())
- s = pkg.name;
- else
- {
- static char buf[512];
- strcpy (buf, pkg.name);
- strcat (buf, ": ");
- strcat (buf, pkg.SDesc ());
- s = buf;
- }
+ s = pkg.name;
+ if (pkg.SDesc ().size())
+ s += String(": ") + pkg.SDesc ();
IntersectClipRect (hdc, x + theView.headers[theView.pkg_col].x, by,
x + theView.headers[theView.pkg_col].x +
theView.headers[theView.pkg_col].width, by + 11);
- TextOut (hdc, x + theView.headers[theView.pkg_col].x + HMARGIN / 2, r, s,
- strlen (s));
+ TextOut (hdc, x + theView.headers[theView.pkg_col].x + HMARGIN / 2, r, s.cstr_oneuse(),
+ s.size());
DeleteObject (oldClip);
DeleteObject (oldClip2);
RestoreDC (hdc, oldDC);
class PickPackageLine:public PickLine
{
public:
- PickPackageLine (PickView &aView, packagemeta & apkg):pkg (apkg), theView (aView)
+ PickPackageLine (PickView &aView, packagemeta & apkg):PickLine (apkg.key), pkg (apkg), theView (aView)
{
- key = apkg.key;
};
virtual void paint (HDC hdc, int x, int y, int row, int show_cat);
virtual int click (int const myrow, int const ClickedRow, int const x);
}
void
-PickView::note_width (PickView::Header *hdrs, HDC dc, const char *string, int addend,
+PickView::note_width (PickView::Header *hdrs, HDC dc, String const &string, int addend,
int column)
{
- if (!string)
+ if (!string.size())
{
if (hdrs[column].width < addend)
hdrs[column].width = addend;
return;
}
SIZE s;
- GetTextExtentPoint32 (dc, string, strlen (string), &s);
+ GetTextExtentPoint32 (dc, string.cstr_oneuse(), string.size(), &s);
if (hdrs[column].width < s.cx + addend)
hdrs[column].width = s.cx + addend;
}
/* src checkbox */
note_width (headers, dc, 0, HMARGIN + 11, src_col);
packagedb db;
+ for (size_t n = 1; n <= db.categories.number (); n++)
+ note_width (headers, dc, String ("+ ")+db.categories[n]->name, HMARGIN, cat_col);
for (size_t n = 1; n <= db.packages.number (); n++)
{
packagemeta & pkg = *db.packages[n];
note_width (headers, dc,
pkg.versions[n]->Canonical_version (),
NEW_COL_SIZE_SLOP + HMARGIN, new_col);
- for (size_t n = 1; n <= db.categories.number (); n++)
- note_width (headers, dc, db.categories[n]->name, HMARGIN, cat_col);
- if (!pkg.SDesc ())
- note_width (headers, dc, pkg.name, HMARGIN, pkg_col);
- else
- {
- static char buf[512];
- strcpy (buf, pkg.name);
- strcat (buf, ": ");
- strcat (buf, pkg.SDesc ());
- note_width (headers, dc, buf, HMARGIN, pkg_col);
- }
+ String s = pkg.name;
+ if (pkg.SDesc ().size())
+ s += String (": ") + pkg.SDesc ();
+ note_width (headers, dc, s, HMARGIN, pkg_col);
}
note_width (headers, dc, "keep", NEW_COL_SIZE_SLOP + HMARGIN, new_col);
note_width (headers, dc, "uninstall", NEW_COL_SIZE_SLOP + HMARGIN, new_col);
#define _PICKVIEW_H_
#include "win32.h"
+#include "String++.h"
#define HMARGIN 10
#define ROW_MARGIN 5
views view_mode;
void set_headers ();
void init_headers (HDC dc);
- void note_width (Header *hdrs, HDC dc, const char *string, int addend,
+ void note_width (Header *hdrs, HDC dc, String const &string, int addend,
int column);
};
--- /dev/null
+/*
+ * Copyright (c) 2002, Robert Collins.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * A copy of the GNU General Public License can be found at
+ * http://www.gnu.org/
+ *
+ * Written by Robert Collins.
+ *
+ */
+
+// A String class to replace all the char * manipulation.
+
+#include "String++.h"
+#include <string.h>
+#include <ctype.h>
+#include "concat.h"
+#include "io_stream.h"
+
+// _data
+
+String::_data::_data(_data const &aData) : count (1), theString (new unsigned char[aData.length]), cstr(0), length (aData.length) {
+ memcpy (theString, aData.theString, aData.length);
+}
+
+String::_data::_data(): count (1), theString(new unsigned char[0]), cstr (0), length (0) {}
+String::_data::_data(size_t aLength): count (1), theString(new unsigned char[aLength]), cstr(0), length (aLength) {}
+String::_data::~_data ()
+{
+ if (theString)
+ delete[] theString;
+ if (cstr)
+ delete[] cstr;
+}
+
+//String
+
+String::String (const char *acString) : theData (new _data(acString ? strlen(acString) : 0))
+{
+ memcpy (theData->theString, acString, theData->length);
+}
+
+String::~String ()
+{
+ if (--theData->count == 0)
+ delete theData;
+}
+
+// able to cache the result if needed.
+char *
+String::cstr ()
+{
+ if (theData->length == 0)
+ return NULL;
+ char * tempcStr =new char[theData->length + 1];
+ // remove when exceptions are done
+ if (!tempcStr)
+ exit (100);
+ tempcStr[theData->length] = '\0';
+ memcpy (tempcStr, theData->theString, theData->length);
+ return tempcStr;
+}
+
+char *
+String::cstr () const
+{
+ if (theData->length == 0)
+ return NULL;
+ char * tempcStr =new char[theData->length + 1];
+ // remove when exceptions are done
+ if (!tempcStr)
+ exit (100);
+ tempcStr[theData->length] = '\0';
+ memcpy (tempcStr, theData->theString, theData->length);
+ return tempcStr;
+}
+
+// able to cache the result if needed.
+char const *
+String::cstr_oneuse () const
+{
+ if (theData->length == 0)
+ return NULL;
+ if (theData->cstr)
+ delete[] theData->cstr;
+ theData->cstr = new char[theData->length + 1];
+ theData->cstr[theData->length] = '\0';
+ memcpy (theData->cstr, theData->theString, theData->length);
+ return theData->cstr;
+}
+
+// does this character exist in the string?
+// 0 is false, 1 is the first position...
+// XXX FIXME: Introduce npos, and change all
+// if (size) calls to be if (size()==npos)
+size_t
+String::find(char aChar) const
+{
+ for (size_t i=0; i < theData->length; ++i)
+ if (theData->theString[i] == aChar)
+ return i+1;
+ return 0;
+}
+
+int
+String::compare (String const &aString, size_t const count) const
+{
+ // trivial cases:
+ if (theData == aString.theData)
+ return 0;
+ size_t length = count ? count : theData->length;
+ if (length > theData->length)
+ length = theData->length;
+ if (length > aString.theData->length)
+ length = aString.theData->length;
+ size_t i;
+ for (i=0; i < length ; ++i)
+ if (theData->theString[i] < aString.theData->theString[i])
+ return -1;
+ else if (theData->theString[i] > aString.theData->theString[i])
+ return 1;
+ // equal for length
+ if (i == count && count != 0)
+ return 0;
+ if (theData->length < aString.theData->length)
+ return -1;
+ else if (theData->length > aString.theData->length)
+ return 1;
+ return 0;
+}
+
+int
+String::casecompare (String const &aString, size_t const count) const
+{
+ // trivial cases:
+ if (theData == aString.theData)
+ return 0;
+ size_t length = count ? count : theData->length;
+ if (length > theData->length)
+ length = theData->length;
+ if (length > aString.theData->length)
+ length = aString.theData->length;
+ size_t i;
+ for (i=0; i < length; ++i)
+ if (toupper(theData->theString[i]) < toupper(aString.theData->theString[i]))
+ return -1;
+ else if (toupper(theData->theString[i]) > toupper(aString.theData->theString[i]))
+ return 1;
+ // equal for length
+ if (i == count && count != 0)
+ return 0;
+ if (theData->length < aString.theData->length)
+ return -1;
+ else if (theData->length > aString.theData->length)
+ return 1;
+ return 0;
+}
+
+String
+String::concat (const char *aString, ...)
+{
+ va_list aList;
+ va_start (aList, aString);
+
+ return vconcat (aString, aList);
+}
+
+String
+String::vconcat (const char *aString, va_list aList)
+{
+ char *tempString = ::vconcat(aString, aList);
+ String theString = String (tempString);
+ delete[] tempString;
+ return theString;
+}
+
+String &
+String::operator+= (String const &aString)
+{
+ if (theData->count > 1)
+ {
+ _data * someData = new _data(*theData);
+ --theData->count;
+ theData = someData;
+ }
+
+ unsigned char *tempString = theData->theString;
+ theData->theString = new unsigned char [theData->length + aString.theData->length];
+ // remove when exceptions are done
+ if (!theData->theString)
+ exit (100);
+ memcpy (theData->theString, tempString, theData->length);
+ delete[] tempString;
+ memcpy (&theData->theString[theData->length], aString.theData->theString, aString.theData->length);
+ theData->length += aString.theData->length;
+ return *this;
+}
+
+String
+String::operator + (String const &aString) const
+{
+ unsigned char *tempcString = new unsigned char [theData->length + aString.theData->length];
+ // remove when exceptions are done
+ if (!tempcString)
+ exit (100);
+ memcpy (tempcString, theData->theString, theData->length);
+ memcpy (&tempcString[theData->length], aString.theData->theString, aString.theData->length);
+ return absorb (tempcString, theData->length + aString.theData->length);
+}
+
+String
+String::operator + (char const *aString) const
+{
+ // expensive, but quick to code.
+ return *this + String (aString);
+}
+
+bool
+String::operator == (String const &rhs) const
+{
+ return compare (rhs) ? false : true;
+}
+
+bool
+String::operator == (char const *rhs) const
+{
+ return compare (rhs) ? false : true;
+}
+
+String
+String::absorb (unsigned char *aString, size_t aLength)
+{
+ String theString;
+ theString.theData->theString = aString;
+ theString.theData->length = aLength;
+ return theString;
+}
+
+int
+String::casecompare (String const lhs, String const rhs)
+{
+ return lhs.casecompare (rhs);
+}
--- /dev/null
+/*
+ * Copyright (c) 2002, Robert Collins.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * A copy of the GNU General Public License can be found at
+ * http://www.gnu.org/
+ *
+ * Written by Robert Collins.
+ *
+ */
+
+// A String class to replace all the char * manipulation.
+
+#ifndef CINSTALL_STRING_H
+#define CINSTALL_STRING_H
+
+#include <stdarg.h>
+#include "sys/types.h"
+
+class io_stream;
+class String {
+ class _data;
+public:
+ // Static members first
+ static String concat (const char *s, ...);
+ static String vconcat (const char *, va_list);
+
+ inline String();
+ inline String (String const &);
+ // We're notperformance bottlenecked.
+ String (const char *);
+ inline String & operator = (String const &);
+ ~String();
+ // Up to the user to delete[] these.
+ char * cstr();
+ char * cstr() const; // may be less optimal
+ char const * cstr_oneuse() const; // only valid until the next mutator call
+ // pretends to be const !!
+ inline size_t size() const; // number of characters (!= storage size).
+ size_t find (char) const;
+ // operator == and != can be done if/when we have a 'casesensitive' flag to
+ // the constructors
+ // - means this sorts to the left of the parameter
+ int compare (String const &, size_t const = 0) const;
+ static int compare (String const &, String const &, size_t const = 0);
+ int casecompare (String const &, size_t const = 0) const;
+ static int casecompare (String const &, String const &, size_t const = 0);
+ static int casecompare (String const, String const);
+ String &append (String const &);
+ String &operator += (String const &);
+ String operator + (String const &) const;
+ String operator + (char const *) const;
+ bool operator == (String const &) const;
+ bool operator == (char const *) const;
+
+private:
+ class _data {
+ public:
+ _data ();
+ _data (size_t);
+ _data (_data const &);
+ ~_data ();
+ unsigned count; //Invariant: all constructors set to 1;
+ // For now, char *, but can be TCHAR, or even UNICODE
+ // when time permits.
+ unsigned char *theString;
+ char *cstr; // cached/oneuse Cstr encoded version
+ size_t length;
+ } *theData; // Invariant, there is always an
+ static String absorb (unsigned char *, size_t);
+};
+
+String::String() : theData (new _data) {}
+String::String(String const &aString) : theData (aString.theData)
+{
+ ++theData->count;
+}
+
+String &
+String::operator= (String const &aString)
+{
+ // Don't touch the order
+ ++aString.theData->count;
+ if (--theData->count == 0)
+ delete theData;
+ theData = aString.theData;
+ return *this;
+}
+
+size_t
+String::size() const
+{
+ return theData->length;
+}
+
+#endif // CINSTALL_STRING_H
#include <stdlib.h>
#include "log.h"
#include "port.h"
-#include "concat.h"
+#include "String++.h"
#include "io_stream.h"
#include "archive.h"
}
int
-archive::extract_file (archive * source, const char *prefixURL, const char *prefixPath, const char *suffix)
+archive::extract_file (archive * source, String const &prefixURL, String const &prefixPath, String suffix)
{
if (!source)
return 1;
- const char *destfilename = concat (prefixURL,prefixPath, source->next_file_name (), suffix, 0);
+ String const destfilename = prefixURL+prefixPath+ source->next_file_name ()+ suffix;
switch (source->next_file_type ())
{
case ARCHIVE_FILE_REGULAR:
/* TODO: remove in-the-way directories via mkpath_p */
if (io_stream::mkpath_p (PATH_TO_FILE, destfilename))
{
- log (LOG_TIMESTAMP, "Failed to make the path for %s", destfilename);
+ log (LOG_TIMESTAMP, String ("Failed to make the path for ") + destfilename);
return 1;}
io_stream::remove (destfilename);
io_stream *tmp = io_stream::open (destfilename, "wb");
if (!tmp)
{
- log (LOG_TIMESTAMP, "Failed to open %s for writing", destfilename);
+ log (LOG_TIMESTAMP, String ("Failed to open ") + destfilename + " for writing.");
return 1;
}
io_stream *in = source->extract_file ();
if (!in)
{
delete tmp;
- log (LOG_TIMESTAMP, "Failed to extract the file %s from the archive",destfilename);
+ log (LOG_TIMESTAMP, String("Failed to extract the file ") + destfilename + " from the archive");
return 1;
}
if (io_stream::copy (in, tmp))
{
- log (LOG_TIMESTAMP, "Failed to output %s", destfilename);
+ log (LOG_TIMESTAMP, String("Failed to output ") + destfilename);
delete tmp;
io_stream::remove (destfilename);
return 1;
case ARCHIVE_FILE_SYMLINK:
{
if (io_stream::mkpath_p (PATH_TO_FILE, destfilename))
- {log (LOG_TIMESTAMP, "Failed to make the path for %s", destfilename);
+ {log (LOG_TIMESTAMP, "Failed to make the path for %s", destfilename.cstr_oneuse());
return 1;}
io_stream::remove (destfilename);
int ok =
io_stream::mklink (destfilename,
- concat (prefixURL, source->linktarget (), 0),
+ prefixURL+ source->linktarget (),
IO_STREAM_SYMLINK);
/* FIXME: check what tar's filelength is set to for symlinks */
source->skip_file ();
case ARCHIVE_FILE_HARDLINK:
{
if (io_stream::mkpath_p (PATH_TO_FILE, destfilename))
- {log (LOG_TIMESTAMP, "Failed to make the path for %s", destfilename);
+ {log (LOG_TIMESTAMP, "Failed to make the path for %s", destfilename.cstr_oneuse());
return 1;}
io_stream::remove (destfilename);
int ok =
io_stream::mklink (destfilename,
- concat (prefixURL, source->linktarget (), 0),
+ prefixURL + source->linktarget (),
IO_STREAM_HARDLINK);
/* FIXME: check what tar's filelength is set to for hardlinks */
source->skip_file ();
}
case ARCHIVE_FILE_DIRECTORY:
{
- char *path = (char *) alloca (strlen (destfilename));
- strcpy (path, destfilename);
+ char *path = (char *) alloca (destfilename.size());
+ strcpy (path, destfilename.cstr_oneuse());
while (path[0] && path[strlen (path) - 1] == '/')
path[strlen (path) - 1] = 0;
source->skip_file ();
* It
*/
+#include "String++.h"
+
/* The read/write the archive stream to get the archive data is flawed.
* The problem is that you then need a *different* gzip etc class to be able
* to ungzip a gzip from within an archive.
* given suffix.
* returns 1 on failure.
*/
- static int extract_file (archive *, const char *, const char *, const char * = NULL);
+ static int extract_file (archive *, String const &, String const &, String const = String());
/*
* To create a stream that will be compressed, you should open the url, and then get a new stream
* The way this works is that when read returns 0, you are at the end of *a* file.
* next_file_name will allow read to be called again, if it returns !NULL
*/
- virtual const char *next_file_name () = NULL;
+ virtual String const next_file_name () = NULL;
virtual archive_file_t next_file_type () = ARCHIVE_FILE_INVALID;
- virtual const char *linktarget () = NULL;
+ virtual String const linktarget () = NULL;
virtual int skip_file () = 0;
/* if you are still needing these hints... give up now! */
// virtual ~compress ();
return 0;
}
-const char *
+String const
archive_tar::next_file_name ()
{
char *c;
return state.filename;
else
/* End of tar */
- return NULL;
+ return String();
int r = state.parent->read (&state.tar_header, 512);
}
}
-const char *
+String const
archive_tar::linktarget ()
{
/* TODO: consider .. path traversal issues */
if (next_file_type () == ARCHIVE_FILE_SYMLINK ||
next_file_type () == ARCHIVE_FILE_HARDLINK)
return state.tar_header.linkname;
- return NULL;
+ return String();
}
io_stream *
/*
* Copyright (c) 2000, Red Hat, Inc.
+ * Copyright (c) 2002, Robert Collins.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#ifndef __TAR_H_
#define __TAR_H_
+#include "io_stream.h"
+#include "archive.h"
+#include "String++.h"
+
typedef struct
{
char name[100]; /* 0 */
typedef struct tar_map_result_type_s
{
struct tar_map_result_type_s *next;
- char *stored_name;
- char *mapped_name;
+ String stored_name;
+ String mapped_name;
}
tar_map_result_type;
virtual int seek (long where, io_stream_seek_t whence);
/* try guessing this one */
virtual int error ();
- virtual char *next_file_name ()
+ virtual String next_file_name ()
{
return NULL;
};
* for foobar that is an compress, next_file_name is the next
* extractable filename.
*/
- virtual const char *next_file_name ();
+ virtual String const next_file_name ();
virtual archive_file_t next_file_type ();
/* returns the mtime of the archive file, not of the current file */
virtual int get_mtime ();
{
return 1;
};
- virtual const char *linktarget ();
+ virtual String const linktarget ();
virtual int skip_file ();
/* if you are still needing these hints... give up now! */
virtual ~ archive_tar ();
/* normal members */
-Category::Category ():next (0), name (0), key (0), packages (0)
+Category::Category ():next (0), name (), key (), packages (0)
{
}
-Category::Category (const char *categoryname):
+Category::Category (String const &categoryname):
next (0),
+name (categoryname), key(categoryname),
packages (0)
{
- /* FIXME: search the global category list for name, and reuse that pointer */
- char *t = new char [strlen(categoryname) + 1];
- strcpy (t, categoryname);
- name = t;
- key = name;
}
int
Categorycmp (Category const & a, Category const & b)
{
- return strcasecmp (a.name, b.name);
+ return a.name.casecompare (b.name);
}
int
Categorycmp (Category & a, Category & b)
{
- return strcasecmp (a.name, b.name);
+ return a.name.casecompare (b.name);
}
#ifndef _CATEGORY_H_
#define _CATEGORY_H_
+#include "String++.h"
+
class Category;
class CategoryPackage;
{
public:
Category ();
- Category (char const *);
+ Category (String const &);
bool operator== (Category const &rhs) const {return Categorycmp (*this, rhs) ? false : true;}
Category *next; /* the next category in the list */
- const char *name; /* the category */
- const char *key; /* always == name */
+ String const name; /* the category */
+ String const key; /* always == name */
CategoryPackage *packages; /* the packages in this category */
};
#include "resource.h"
#include "state.h"
#include "ini.h"
-#include "concat.h"
#include "msg.h"
#include "log.h"
#include "find.h"
if (!parse_filename (path, f))
return;
- if (f.what[0] != '\0' && f.what[0] != 's')
+ if (f.what.size() != 0 && f.what.cstr_oneuse()[0] != 's')
return;
packagedb db;
int added = 0;
for (size_t n = 1; n <= pkg->versions.number (); n++)
{
- if (!strcasecmp (f.ver, pkg->versions[n]->Canonical_version ()))
+ if (!f.ver.casecompare (pkg->versions[n]->Canonical_version ()))
{
- /* FIXME: Add a mirror entry */
+ /* FIXME: Add a cached entry */
added = 1;
}
}
const char *trust = ((pkg.desired == pkg.prev) ? "prev"
: (pkg.desired == pkg.curr) ? "curr"
: (pkg.desired == pkg.exp) ? "test" : "unknown");
- const char *action = pkg.action_caption ();
- const char *installed =
+ String action = pkg.action_caption ();
+ String const installed =
pkg.installed ? pkg.installed->Canonical_version () : "none";
log (LOG_BABBLE, "[%s] action=%s trust=%s installed=%s"
" src?=%s",
- pkg.name, action, trust, installed,
+ pkg.name.cstr_oneuse(), action.cstr_oneuse(), trust, installed.cstr_oneuse(),
pkg.desired && pkg.desired->srcpicked ? "yes" : "no");
if (pkg.Categories.number ())
{
/* List categories the package belongs to */
- int categories_len = 0;
- for (size_t n = 1; n <= pkg.Categories.number (); n++)
- categories_len += strlen (pkg.Categories[n]->key.name) + 2;
+ String all_categories = pkg.Categories[1]->key.name;
+ for (size_t n = 2; n <= pkg.Categories.number (); n++)
+ all_categories += String(", ") + pkg.Categories[n]->key.name;
- if (categories_len > 0)
- {
- char *categories = new char [categories_len];
- strcpy (categories, pkg.Categories[1]->key.name);
- for (size_t n = 2; n <= pkg.Categories.number (); n++)
- {
- strcat (categories, ", ");
- strcat (categories, pkg.Categories[n]->key.name);
- }
- log (LOG_BABBLE, " categories=%s", categories);
- delete[] categories;
- }
+ log (LOG_BABBLE, String (" categories=") + all_categories);
}
if (pkg.desired && pkg.desired->required)
{
/* List other packages this package depends on */
- int requires_len = 0;
- Dependency *dp;
- for (dp = pkg.desired->required; dp; dp = dp->next)
- if (dp->package)
- requires_len += strlen (dp->package) + 2;
+ Dependency *dp=pkg.desired->required;
+ String requires = dp->package;
+ for (dp = dp->next ; dp; dp = dp->next)
+ if (dp->package.size())
+ requires += String (", ") + dp->package;
- if (requires_len > 0)
- {
- char *requires = new char [requires_len];
- strcpy (requires, pkg.desired->required->package);
- for (dp = pkg.desired->required->next; dp; dp = dp->next)
- if (dp->package)
- {
- strcat (requires, ", ");
- strcat (requires, dp->package);
- }
- log (LOG_BABBLE, " requires=%s", requires);
- delete[] requires;
- }
+ log (LOG_BABBLE, String(" requires=")+ requires);
}
#if 0
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <strings.h>
-#include "concat.h"
+#include "String++.h"
#include "io_stream.h"
#include "compress.h"
#include "cygpackage.h"
/* this constructor creates an invalid package - further details MUST be provided */
-cygpackage::cygpackage (const char *pkgname):
+cygpackage::cygpackage (String const &pkgname):
+name (pkgname),
vendor (0),
packagev (0),
canonical (0),
listdata (0),
listfile (0)
{
- name = new char [strlen (pkgname) +1];
- strcpy (name, pkgname);
memset( getfilenamebuffer, '\0', _MAX_PATH);
/* FIXME: query the install database for the currently installed
/* create a package given explicit details - perhaps should be modified to take the
filename and do it's own parsing? */
-cygpackage::cygpackage (const char *pkgname, const char *filename, size_t fs,
- const char *version, package_status_t newstatus,
- package_type_t newtype):
-fn (0),
+cygpackage::cygpackage (String const &pkgname, String const &filename, size_t const fs,
+ String const &version, package_status_t const newstatus,
+ package_type_t const newtype):
+name (pkgname),
+fn (filename),
sdesc (0),
ldesc (0),
status (newstatus),
listfile (0),
filesize (fs)
{
- name = new char [strlen (pkgname) +1];
- strcpy (name, pkgname);
- fn = new char [strlen (filename) +1];
- strcpy (fn, filename);
memset( getfilenamebuffer, '\0', _MAX_PATH);
set_canonical_version (version);
}
/* tell the version */
void
-cygpackage::set_canonical_version (char const *version)
+cygpackage::set_canonical_version (String const &version)
{
- char *curr = strchr (version, '-');
- canonical = new char [strlen (version) +1];
- strcpy (canonical, version);
+ canonical = version;
+ char *start = strchr (canonical.cstr_oneuse(), '-');
+ char*curr=start;
if (curr)
{
char *next;
while ((next = strchr (curr + 1, '-')))
curr = next;
/* curr = last - in the version string */
- packagev = new char [strlen (curr + 1) +1];
- strcpy (packagev, curr + 1);
- vendor = new char [strlen (version) +1];
- strcpy (vendor, version);
- vendor[curr - version] = '\0';
+ packagev = curr + 1;
+ char tvendor [version.size() +1];
+ strcpy (tvendor, version.cstr_oneuse());
+ tvendor[curr - start] = '\0';
+ vendor=tvendor;
}
else
{
packagev = 0;
- vendor = new char [strlen (version) +1];
- strcpy (vendor, version);
+ vendor = version;
}
key = canonical;
}
void
cygpackage::destroy ()
{
-
- if (name)
- delete[] name;
- if (vendor)
- delete[] vendor;
- if (packagev)
- delete[] packagev;
- if (canonical)
- delete[] canonical;
- if (fn)
- delete[] fn;
- if (listdata)
- delete listdata;
- if (sdesc)
- delete[] sdesc;
- if (ldesc)
- delete[] ldesc;
}
-const char *
+String const
cygpackage::getfirstfile ()
{
if (listdata)
delete listdata;
listfile =
- io_stream::open (concat ("cygfile:///etc/setup/", name, ".lst.gz", 0),
- "rb");
+ io_stream::open (String ("cygfile:///etc/setup/") + name + ".lst.gz", "rb");
listdata = compress::decompress (listfile);
if (!listdata)
return 0;
return listdata->gets (getfilenamebuffer, sizeof (getfilenamebuffer));
}
-const char *
+String const
cygpackage::getnextfile ()
{
if (listdata)
if (listdata)
delete listdata;
listdata = 0;
- io_stream::remove (concat ("cygfile:///etc/setup/", name, ".lst.gz", 0));
+ io_stream::remove (String("cygfile:///etc/setup/") + name + ".lst.gz");
}
-const char *
+String const
cygpackage::Name ()
{
return name;
}
-const char *
+String const
cygpackage::Vendor_version ()
{
return vendor;
}
-const char *
+String const
cygpackage::Package_version ()
{
return packagev;
}
-const char *
+String const
cygpackage::Canonical_version ()
{
return canonical;
}
void
-cygpackage::set_sdesc (char const *desc)
+cygpackage::set_sdesc (String const &desc)
{
- if (sdesc)
- delete sdesc;
- sdesc = new char[strlen (desc) + 1];
- strcpy (sdesc, desc);
+ sdesc = desc;
}
void
-cygpackage::set_ldesc (char const *desc)
+cygpackage::set_ldesc (String const &desc)
{
- if (ldesc)
- delete ldesc;
- ldesc = new char[strlen (desc) + 1];
- strcpy (ldesc, desc);
+ ldesc = desc;
}
#if 0
#ifndef _CYGPACKAGE_H_
#define _CYGPACKAGE_H_
+#include "String++.h"
+
class cygpackage:public packageversion
{
public:
- virtual const char *Name ();
- virtual const char *Vendor_version ();
- virtual const char *Package_version ();
- virtual char const *Canonical_version ();
+ virtual String const Name ();
+ virtual String const Vendor_version ();
+ virtual String const Package_version ();
+ virtual String const Canonical_version ();
virtual package_status_t Status ()
{
return status;
{
return type;
};
- virtual void set_sdesc (char const *);
- virtual void set_ldesc (char const *);
- virtual char const *SDesc ()
+ virtual void set_sdesc (String const &);
+ virtual void set_ldesc (String const &);
+ virtual String const SDesc ()
{
return sdesc;
};
- virtual char const *LDesc ()
+ virtual String const LDesc ()
{
return ldesc;
};
/* pass the name of the package when constructing */
- cygpackage (const char *);
- cygpackage (const char *, const char *, size_t, const char *,
- package_status_t, package_type_t);
- void set_canonical_version (char const *);
+ cygpackage (String const &);
+ cygpackage (String const &, String const &, size_t const, String const &,
+ package_status_t const, package_type_t const);
+ void set_canonical_version (String const &);
virtual ~ cygpackage ();
/* TODO: we should probably return a metaclass - file name & path & size & type
- ie doc/script/binary
*/
- virtual const char *getfirstfile ();
- virtual const char *getnextfile ();
+ virtual String const getfirstfile ();
+ virtual String const getnextfile ();
private:
void destroy ();
- char *name;
- char *vendor;
- char *packagev;
- char *canonical;
- char *fn;
- char *sdesc, *ldesc;
+ String name;
+ String vendor;
+ String packagev;
+ String canonical;
+ String fn;
+ String sdesc, ldesc;
char getfilenamebuffer[_MAX_PATH];
// package_stability_t stability;
#include "ini.h"
#include "msg.h"
#include "state.h"
-#include "concat.h"
-#include "mkdir.h"
#include "dialog.h"
#include "version.h"
#include "mount.h"
#include "package_meta.h"
#include "package_version.h"
+#include "filemanip.h"
+#include "String++.h"
+#include "io_stream.h"
+
#include "desktop.h"
+
static OSVERSIONINFO verinfo;
/* Lines starting with '@' are conditionals - include 'N' for NT,
0
};
-#define COMMAND9XARGS "/E:4096 /c"
-#define COMMAND9XEXE "\\command.com"
+#define COMMAND9XARGS String("/E:4096 /c")
+#define COMMAND9XEXE String("\\command.com")
-static char *batname;
-static char *iconname;
+static String batname;
+static String iconname;
static void
-make_link (const char *linkpath, const char *title, const char *target)
+make_link (String const &linkpath, String const &title, String const &target)
{
- char argbuf[_MAX_PATH];
- char *fname = concat (linkpath, "/", title, ".lnk", 0);
+ String fname = linkpath + "/" + title + ".lnk";
- if (_access (fname, 0) == 0)
+ if (_access (fname.cstr_oneuse(), 0) == 0)
return; /* already exists */
- msg ("make_link %s, %s, %s\n", fname, title, target);
+ msg ("make_link %s, %s, %s\n", fname.cstr_oneuse(), title.cstr_oneuse(), target.cstr_oneuse());
- mkdir_p (0, fname);
+ io_stream::mkpath_p (PATH_TO_FILE, fname);
- char *exepath;
+ String exepath;
+ String argbuf;
/* If we are running Win9x, build a command line. */
if (verinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
- exepath = concat (target, 0);
- sprintf (argbuf, " ");
+ exepath = target;
+ argbuf = " ";
+// sprintf (argbuf, " ");
}
else
{
char windir[MAX_PATH];
GetWindowsDirectory (windir, sizeof (windir));
- exepath = concat (windir, COMMAND9XEXE, 0);
- sprintf (argbuf, "%s %s", COMMAND9XARGS, target);
+ exepath = String(windir) + COMMAND9XEXE;
+ argbuf = COMMAND9XARGS + " " + target;
+// sprintf (argbuf, "%s %s", COMMAND9XARGS, target.cstr_oneuse());
}
- msg ("make_link_2 (%s, %s, %s, %s)", exepath, argbuf, iconname, fname);
- make_link_2 (exepath, argbuf, iconname, fname);
+ msg ("make_link_2 (%s, %s, %s, %s)", exepath.cstr_oneuse(), argbuf.cstr_oneuse(), iconname.cstr_oneuse(), fname.cstr_oneuse());
+ make_link_2 (exepath.cstr_oneuse(), argbuf.cstr_oneuse(), iconname.cstr_oneuse(), fname.cstr_oneuse());
}
static void
-start_menu (const char *title, const char *target)
+start_menu (String const &title, String const &target)
{
- char path[_MAX_PATH];
LPITEMIDLIST id;
int issystem = (root_scope == IDC_ROOT_SYSTEM) ? 1 : 0;
SHGetSpecialFolderLocation (NULL,
issystem ? CSIDL_COMMON_PROGRAMS :
CSIDL_PROGRAMS, &id);
- SHGetPathFromIDList (id, path);
-// following lines added because it appears Win95 does not use common programs
-// unless it comes into play when multiple users for Win95 is enabled
- msg ("Program directory for program link: %s", path);
- if (strlen (path) == 0)
+ char _path[_MAX_PATH];
+ SHGetPathFromIDList (id, _path);
+ String path(_path);
+ // Win95 does not use common programs unless multiple users for Win95 is enabled
+ msg ("Program directory for program link: %s", path.cstr_oneuse());
+ if (path.size() == 0)
{
SHGetSpecialFolderLocation (NULL, CSIDL_PROGRAMS, &id);
- SHGetPathFromIDList (id, path);
- msg ("Program directory for program link changed to: %s", path);
+ SHGetPathFromIDList (id, _path);
+ path = String(_path);
+ msg ("Program directory for program link changed to: %s", path.cstr_oneuse());
}
// end of Win95 addition
- strcat (path, "/Cygwin");
+ path += "/Cygwin";
make_link (path, title, target);
}
static void
-desktop_icon (const char *title, const char *target)
+desktop_icon (String const &title, String const &target)
{
char path[_MAX_PATH];
LPITEMIDLIST id;
batname = backslash (cygpath ("/cygwin.bat", 0));
/* if the batch file exists, don't overwrite it */
- if (_access (batname, 0) == 0)
+ if (_access (batname.cstr_oneuse(), 0) == 0)
return;
- FILE *bat = fopen (batname, "wt");
+ FILE *bat = fopen (batname.cstr_oneuse(), "wt");
if (!bat)
return;
fprintf (bat, "@echo off\n\n");
- fprintf (bat, "%.2s\n", get_root_dir ());
+ fprintf (bat, "%.2s\n", get_root_dir ().cstr_oneuse());
fprintf (bat, "chdir %s\n\n",
- backslash (concat (get_root_dir () + 2, "/bin", 0)));
+ backslash (get_root_dir () + "/bin").cstr_oneuse());
fprintf (bat, "bash --login -i\n");
static void
make_etc_profile ()
{
- char *fname = cygpath ("/etc/profile", 0);
+ String fname = cygpath ("/etc/profile", 0);
/* if the file exists, don't overwrite it */
- if (_access (fname, 0) == 0)
+ if (_access (fname.cstr_oneuse(), 0) == 0)
return;
char os;
}
msg ("os is %c", os);
- FILE *p = fopen (fname, "wb");
+ FILE *p = fopen (fname.cstr_oneuse(), "wb");
if (!p)
return;
static int
uexists (const char *path)
{
- char *f = cygpath (path, 0);
- int a = _access (f, 0);
- delete[] f;
+ String f = cygpath (path, 0);
+ int a = _access (f.cstr_oneuse(), 0);
if (a == 0)
return 1;
return 0;
static void
make_passwd_group ()
{
- char *fname = cygpath ("/etc/postinstall/passwd-grp.bat", 0);
- mkdir_p (0, fname);
+ String fname = cygpath ("/etc/postinstall/passwd-grp.bat", 0);
+ io_stream::mkpath_p (PATH_TO_FILE, fname);
- FILE *p = fopen (fname, "wt");
+ FILE *p = fopen (fname.cstr_oneuse(), "wt");
if (!p)
return;
if (verinfo.dwPlatformId != VER_PLATFORM_WIN32_NT)
if (pkg && pkg->installed)
{
/* mkpasswd and mkgroup are not working on 9x/ME up to 1.1.5-4 */
- char *border_version = canonicalize_version ("1.1.5-4");
- char *inst_version =
+ String border_version = canonicalize_version ("1.1.5-4");
+ String inst_version =
canonicalize_version (pkg->installed->Canonical_version ());
- if (strcmp (inst_version, border_version) <= 0)
+ if (inst_version.compare(border_version) <= 0)
goto out;
}
}
char *data = (char *) LockResource (res);
int len = SizeofResource (NULL, rsrc);
- FILE *f = fopen (iconname, "wb");
+ FILE *f = fopen (iconname.cstr_oneuse(), "wb");
if (f)
{
fwrite (data, 1, len, f);
}
static int
-check_desktop (const char *title, const char *target)
+check_desktop (String const title, String const target)
{
char path[_MAX_PATH];
LPITEMIDLIST id;
msg ("Desktop directory for deskop link changed to: %s", path);
}
// end of Win95 addition
- char *fname = concat (path, "/", title, ".lnk", 0);
+ String fname = String::concat (path, "/", title.cstr_oneuse(), ".lnk", 0);
- if (_access (fname, 0) == 0)
+ if (_access (fname.cstr_oneuse(), 0) == 0)
return 0; /* already exists */
- fname = concat (path, "/", title, ".pif", 0); /* check for a pif as well */
+ fname = String::concat (path, "/", title.cstr_oneuse(), ".pif", 0); /* check for a pif as well */
- if (_access (fname, 0) == 0)
+ if (_access (fname.cstr_oneuse(), 0) == 0)
return 0; /* already exists */
return IDC_ROOT_DESKTOP;
}
static int
-check_startmenu (const char *title, const char *target)
+check_startmenu (String const title, String const target)
{
char path[_MAX_PATH];
LPITEMIDLIST id;
}
// end of Win95 addition
strcat (path, "/Cygwin");
- char *fname = concat (path, "/", title, ".lnk", 0);
+ String fname = String::concat (path, "/", title.cstr_oneuse(), ".lnk", 0);
- if (_access (fname, 0) == 0)
+ if (_access (fname.cstr_oneuse(), 0) == 0)
return 0; /* already exists */
- fname = concat (path, "/", title, ".pif", 0); /* check for a pif as well */
+ fname = String::concat (path, "/", title.cstr_oneuse(), ".pif", 0); /* check for a pif as well */
- if (_access (fname, 0) == 0)
+ if (_access (fname.cstr_oneuse(), 0) == 0)
return 0; /* already exists */
return IDC_ROOT_MENU;
eget (HWND h, int id, char *var)
{
char tmp[4000];
- if (var && var != get_root_dir ())
+ if (var && var != get_root_dir ().cstr_oneuse())
{
delete [] var;
var = NULL;
return var;
}
+String
+egetString (HWND h, int id)
+{
+ String aString;
+ char tmp[4000];
+ if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0)
+ aString = String (tmp);
+ return aString;
+}
+
int
eget (HWND h, int id)
{
SetDlgItemText (h, id, val);
}
+void
+eset (HWND h, int id, String const aString)
+{
+ SetDlgItemText (h, id, aString.cstr_oneuse());
+}
+
void
eset (HWND h, int id, int val)
{
*
*/
+#include "String++.h"
+
/* global instance for the application; set in main.cc */
extern HINSTANCE hinstance;
char *eget (HWND h, int id, char *var);
+/* Get the value of an EditText control. */
+
+String egetString (HWND h, int id);
+
/* Same, but convert the value to an integer */
int eget (HWND h, int id);
-/* Set the EditText control to the given string or integer */
+/* Set the EditText control to the given value */
void eset (HWND h, int id, const char *var);
+void eset (HWND h, int id, String const);
void eset (HWND h, int id, int var);
/* RadioButtons. ids is a null-terminated list of IDs. Get
PULARGE_INTEGER);
int
-diskfull (const char *path)
+diskfull (String const &path)
{
WINAPI GDFS gdfs = 0;
if (gdfs)
{
ULARGE_INTEGER avail, total, free;
- if (gdfs (path, &avail, &total, &free))
+ if (gdfs (path.cstr_oneuse(), &avail, &total, &free))
{
int perc = avail.QuadPart * 100 / total.QuadPart;
return 100 - perc;
}
char root[4];
- if (path[1] != ':')
+ if (path.cstr_oneuse()[1] != ':')
return 0;
- root[0] = path[0];
+ root[0] = path.cstr_oneuse()[0];
root[1] = ':';
root[2] = '\\';
root[3] = 0;
*
*/
+#include "String++.h"
+
/* returns 0..100 (percent) */
-int diskfull (const char *path);
+int diskfull (String const &path);
#include "msg.h"
#include "ini.h"
#include "dialog.h"
-#include "concat.h"
+#include "String++.h"
#include "geturl.h"
#include "state.h"
#include "mkdir.h"
DWORD size;
if ((size =
- get_file_size (concat (local_dir, "/", pkgsource.Canonical (), 0))) >
+ get_file_size (local_dir + "/" + pkgsource.Canonical ())) >
0)
if (size == pkgsource.size)
{
pkgsource.
- set_cached (concat
- ("file://", local_dir, "/", pkgsource.Canonical (), 0));
+ set_cached (String ("file://") + local_dir + "/" + pkgsource.Canonical ());
return 1;
}
*/
for (size_t n = 1; n <= pkgsource.sites.number (); n++)
if ((size =
- get_file_size (concat
- (local_dir, "/",
- rfc1738_escape_part (pkgsource.sites[n]->key), "/",
- pkgsource.Canonical (), 0))) > 0)
+ get_file_size (local_dir + "/" +
+ rfc1738_escape_part (pkgsource.sites[n]->key) + "/" +
+ pkgsource.Canonical ())) > 0)
if (size == pkgsource.size)
{
pkgsource.
- set_cached (concat
- ("file://", local_dir, "/",
+ set_cached (String ("file://") + local_dir + "/" +
rfc1738_escape_part (pkgsource.sites[n]->
- key), "/",
- pkgsource.Canonical (), 0));
+ key) + "/" +
+ pkgsource.Canonical ());
return 1;
}
int success = 0;
for (size_t n = 1; n <= pkgsource.sites.number () && !success; n++)
{
- const char *local = concat (local_dir, "/",
+ String const local = local_dir + "/" +
rfc1738_escape_part (pkgsource.sites[n]->
- key), "/",
- pkgsource.Canonical (), 0);
- io_stream::mkpath_p (PATH_TO_FILE, concat ("file://", local, 0));
-
- if (get_url_to_file
- (concat
- (pkgsource.sites[n]->key, "/", pkgsource.Canonical (), 0),
- concat (local, ".tmp", 0), pkgsource.size, owner))
+ key) + "/" +
+ pkgsource.Canonical ();
+ io_stream::mkpath_p (PATH_TO_FILE, (String ("file://") + local).cstr_oneuse());
+
+ if (get_url_to_file(String (pkgsource.sites[n]->key) + "/" + pkgsource.Canonical (),
+ local + ".tmp", pkgsource.size, owner))
{
/* FIXME: note new source ? */
continue;
}
else
{
- size_t size = get_file_size (concat (local, ".tmp", 0));
+ size_t size = get_file_size (local + ".tmp");
if (size == pkgsource.size)
{
- log (0, "Downloaded %s", local);
- if (_access (local, 0) == 0)
- remove (local);
- rename (concat (local, ".tmp", 0), local);
+ log (LOG_TIMESTAMP, "Downloaded %s", local.cstr_oneuse());
+ if (_access (local.cstr_oneuse(), 0) == 0)
+ remove (local.cstr_oneuse());
+ rename ((local + ".tmp").cstr_oneuse(), local.cstr_oneuse());
success = 1;
- pkgsource.set_cached (concat ("file://", local, 0));
+ pkgsource.set_cached (String ("file://") + local);
+ // FIXME: move the downloaded file to the
+ // original locations - without the mirror site dir in the way
continue;
}
else
{
- log (0, "Download %s wrong size (%u actual vs %d expected)",
- local, size, pkgsource.size);
- remove (concat (local, ".tmp", 0));
+ log (LOG_TIMESTAMP, "Download %s wrong size (%u actual vs %d expected)",
+ local.cstr_oneuse(), size, pkgsource.size);
+ remove ((local + ".tmp").cstr_oneuse());
continue;
}
}
#include "filemanip.h"
unsigned int
-get_file_size (const char *name)
+get_file_size (String const &name)
{
HANDLE h;
WIN32_FIND_DATA buf;
DWORD ret = 0;
- h = FindFirstFileA (name, &buf);
+ h = FindFirstFileA (name.cstr_oneuse(), &buf);
if (h != INVALID_HANDLE_VALUE)
{
if (buf.nFileSizeHigh == 0)
return ret;
}
-char *
-base (const char *s)
+String
+base (String const &aString)
{
- if (!s)
+ if (!aString.size())
return 0;
- const char *rv = s;
+ const char *t = aString.cstr();
+ const char *s = t;
+ String rv = s;
while (*s)
{
if ((*s == '/' || *s == ':' || *s == '\\') && s[1])
rv = s + 1;
s++;
}
- return (char *) rv;
+ delete[] t;
+ return rv;
}
/* returns the number of characters of path that
/* Parse a filename into package, version, and extension components. */
int
-parse_filename (const char *in_fn, fileparse & f)
+parse_filename (String const &in_fn, fileparse & f)
{
char *p, *ver;
- char fn[strlen (in_fn) + 1];
-
- strcpy (fn, in_fn);
+ char fn[in_fn.size() + 1];
+ strcpy (fn, in_fn.cstr_oneuse());
+
int n = find_tar_ext (fn);
if (!n)
return 0;
- strcpy (f.tail, fn + n);
+ f.tail = fn + n;
fn[n] = '\0';
- f.pkg[0] = f.what[0] = '\0';
- p = base (fn);
+ f.pkg = f.what = String();
+ p = base (fn).cstr();
for (ver = p; *ver; ver++)
- if (*ver == '-' || *ver == '_')
+ if (*ver == '-')
if (isdigit (ver[1]))
{
*ver++ = 0;
- strcpy (f.pkg, p);
+ f.pkg = p;
break;
}
else if (strcasecmp (ver, "-src") == 0 ||
strcasecmp (ver, "-patch") == 0)
{
*ver++ = 0;
- strcpy (f.pkg, p);
- strcpy (f.what, strlwr (ver));
- strcpy (f.pkgtar, p);
- strcat (f.pkgtar, f.tail);
+ f.pkg = p;
+ f.what = strlwr (ver);
+ f.pkgtar = String(p) + f.tail;
ver = strchr (ver, '\0');
break;
}
- if (!f.pkg[0])
- strcpy (f.pkg, p);
+ if (!f.pkg.size())
+ f.pkg = p;
- if (!f.what[0])
+ if (!f.what.size())
{
int n;
- p = strchr (ver, '\0');
- strcpy (f.pkgtar, in_fn);
- if ((p -= 4) >= ver && strcasecmp (p, "-src") == 0)
+ char *p1 = strchr (ver, '\0');
+ f.pkgtar = in_fn;
+ if ((p1 -= 4) >= ver && strcasecmp (p1, "-src") == 0)
n = 4;
- else if ((p -= 2) >= ver && strcasecmp (p, "-patch") == 0)
+ else if ((p1 -= 2) >= ver && strcasecmp (p1, "-patch") == 0)
n = 6;
else
n = 0;
if (n)
{
- strcpy (f.what, p + 1);
- *p = '\0';
- p = f.pkgtar + (p - fn) + n;
- memmove (p - n, p, strlen (p));
+ // XXX This maybe broken. What does it do?
+ f.what = p1 + 1;
+ *p1 = '\0';
+ p1 = p + (p1 - fn) + n;
+ memmove (p1 - n, p1, strlen (p1));
+ f.pkgtar = p;
}
}
- strcpy (f.ver, *ver ? ver : "0.0");
+ f.ver = *ver ? ver : "0.0";
+ delete[] p;
return 1;
}
+
+String
+backslash (String const & aString)
+{
+ char * tempString = aString.cstr();
+ for (char *t = tempString; *t; t++)
+ if (*t == '/')
+ *t = '\\';
+ String theString(tempString);
+ delete[] tempString;
+ return theString;
+}
*
*/
+#include "String++.h"
+
extern int find_tar_ext (const char *path);
typedef struct
{
- char pkgtar[MAX_PATH + 1];
- char pkg[MAX_PATH + 1];
- char ver[MAX_PATH + 1];
- char tail[MAX_PATH + 1];
- char what[16];
+ String pkgtar;
+ String pkg;
+ String ver;
+ String tail;
+ String what;
}
fileparse;
-int parse_filename (const char *in_fn, fileparse & f);
-char *base (const char *name);
-unsigned int get_file_size (const char *name);
+int parse_filename (String const & in_fn, fileparse & f);
+String base (String const &);
+unsigned int get_file_size (String const &);
+String backslash (String const &);
#include "port.h"
-static void (*for_each) (char *, unsigned int);
+#include "String++.h"
+#include "find.h"
+
static char dir[_MAX_PATH], *found_part;
static int
-find_sub ()
+find_sub (void (*for_each) (char *, unsigned int))
{
WIN32_FIND_DATA wfd;
HANDLE h;
strcpy (end, wfd.cFileName);
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- find_sub ();
+ find_sub (for_each);
else
{
for_each (found_part, wfd.nFileSizeLow);
}
int
-find (const char *starting_dir, void (*_for_each) (char *, unsigned int))
+find (String const &starting_dir, void (*_for_each) (char *, unsigned int))
{
- strcpy (dir, starting_dir);
- for_each = _for_each;
+ strcpy (dir, starting_dir.cstr_oneuse());
found_part = dir + strlen (dir) + 1;
- return find_sub ();
+ return find_sub (_for_each);
}
(bytes). find() returns the number of files found. Directories
are scanned but not included in the "found" files. */
-extern int find (const char *starting_dir,
+class String;
+extern int find (String const &starting_dir,
void (*for_each) (char *, unsigned int));
if (!parse_filename (path, f))
return;
- if (f.what[0] != '\0')
+ if (f.what.size() != 0)
return;
packagedb db;
packagemeta &p = db.packages.registerbykey (f.pkg);
packageversion *pv = new cygpackage (f.pkg);
((cygpackage *)pv)->set_canonical_version (f.ver);
- if (!f.what[0])
- pv->bin.set_cached (concat ("file://", path, 0));
+ if (!f.what.size())
+ pv->bin.set_cached (String ("file://") + path);
else
// patch or src, assume src until someone complains
- pv->src.set_cached (concat ("file://", path, 0));
+ pv->src.set_cached (String ("file://") + path);
// check for a duplciate version FIXME make this a method or friend
int merged = 0;
for (size_t n = 1; !merged && n <= p.versions.number (); n++)
- if (!strcasecmp(p.versions[n]->Canonical_version(), pv->Canonical_version()))
+ if (!p.versions[n]->Canonical_version().casecompare (pv->Canonical_version()))
{
/* Copy the binary mirror across if this site claims to have an install */
if (pv->bin.sites.number ())
if (pv->src.sites.number ())
p.versions[n]->src.sites.registerbykey (pv->src.sites[1]->key);
/* Copy the descriptions across */
- if (pv->SDesc () && !p.versions[n]->SDesc ())
+ if (pv->SDesc ().size() && !p.versions[n]->SDesc ().size())
p.versions[n]->set_sdesc (pv->SDesc ());
- if (pv->LDesc () && !p.versions[n]->LDesc ())
+ if (pv->LDesc ().size() && !p.versions[n]->LDesc ().size())
p.versions[n]->set_ldesc (pv->LDesc ());
pv = p.versions[n];
merged = 1;
#include "mount.h"
#include "threebar.h"
+
+#include "String++.h"
+
extern ThreeBarProgressPage Progress;
static int max_bytes = 0;
static DWORD start_tics;
static void
-init_dialog (char const *url, int length, HWND owner)
+init_dialog (String const &url, int length, HWND owner)
{
if (is_local_install)
return;
- char const *sl = url;
+ char const *temp = url.cstr();
+ char const *sl = temp;
char const *cp;
- for (cp = url; *cp; cp++)
+ for (cp = sl; *cp; cp++)
if (*cp == '/' || *cp == '\\' || *cp == ':')
sl = cp + 1;
max_bytes = length;
Progress.SetText3("Connecting...");
Progress.SetBar1(0);
start_tics = GetTickCount ();
+ delete[] temp;
}
}
io_stream *
-get_url_to_membuf (char const *_url, HWND owner)
+get_url_to_membuf (String const &_url, HWND owner)
{
- log (LOG_BABBLE, "get_url_to_membuf %s", _url);
+ log (LOG_BABBLE, "get_url_to_membuf %s", _url.cstr_oneuse());
is_local_install = (source == IDC_SOURCE_CWD);
init_dialog (_url, 0, owner);
- NetIO *n = NetIO::open (_url);
+ NetIO *n = NetIO::open (_url.cstr_oneuse());
if (!n || !n->ok ())
{
delete n;
return membuf;
}
-char *
-get_url_to_string (char const *_url, HWND owner)
+// predicate: url has no '\0''s in it.
+String
+get_url_to_string (String const &_url, HWND owner)
{
io_stream *stream = get_url_to_membuf (_url, owner);
if (!stream)
- return 0;
+ return String();
size_t bytes = stream->get_size ();
if (!bytes)
{
/* zero length, or error retrieving length */
delete stream;
log (LOG_BABBLE, "get_url_to_string(): couldn't retrieve buffer size, or zero length buffer");
- return 0;
- }
- char *rv = new char [bytes + 1];
- if (!rv)
- {
- delete stream;
- log (LOG_BABBLE, "get_url_to_string(): new failed for rv!");
- return 0;
+ return String();
}
+ char temp [bytes + 1];
/* membufs are quite safe */
- stream->read (rv, bytes);
- rv [bytes] = '\0';
+ stream->read (temp, bytes);
+ temp [bytes] = '\0';
delete stream;
- return rv;
+ return String(temp);
}
int
-get_url_to_file (char *_url, char *_filename, int expected_length,
+get_url_to_file (String const &_url, String const &_filename, int expected_length,
HWND owner, BOOL allow_ftp_auth)
{
- log (LOG_BABBLE, "get_url_to_file %s %s", _url, _filename);
+ log (LOG_BABBLE, "get_url_to_file %s %s", _url.cstr_oneuse(), _filename.cstr_oneuse());
if (total_download_bytes > 0)
{
- int df = diskfull (get_root_dir ());
- Progress.SetBar3(df);
+ int df = diskfull (get_root_dir ().cstr_oneuse());
+ Progress.SetBar3(df);
}
init_dialog (_url, expected_length, owner);
- remove (_filename); /* but ignore errors */
+ remove (_filename.cstr_oneuse()); /* but ignore errors */
- NetIO *n = NetIO::open (_url, allow_ftp_auth);
+ NetIO *n = NetIO::open (_url.cstr_oneuse(), allow_ftp_auth);
if (!n || !n->ok ())
{
delete n;
return 1;
}
- FILE *f = fopen (_filename, "wb");
+ FILE *f = fopen (_filename.cstr_oneuse(), "wb");
if (!f)
{
const char *err = strerror (errno);
if (!err)
err = "(unknown error)";
- fatal (owner, IDS_ERR_OPEN_WRITE, _filename, err);
+ fatal (owner, IDS_ERR_OPEN_WRITE, _filename.cstr_oneuse(), err);
}
if (n->file_size)
if (total_download_bytes > 0)
{
- int df = diskfull (get_root_dir ());
+ int df = diskfull (get_root_dir ().cstr_oneuse());
Progress.SetBar3(df);
}
extern int total_download_bytes_sofar;
class io_stream;
+class String;
-io_stream *get_url_to_membuf (char const *, HWND owner);
-char *get_url_to_string (char const *, HWND owner);
-int get_url_to_file (char *_url, char *_filename, int expected_size,
+io_stream *get_url_to_membuf (String const &, HWND owner);
+String get_url_to_string (String const&, HWND owner);
+int get_url_to_file (String const &_url, String const &_filename, int expected_size,
HWND owner, BOOL allow_ftp_auth = FALSE);
void dismiss_url_status_dialog ();
/* Simple hash class for install.cc */
+#include "String++.h"
+
class hash_internals;
class hash
/* FIXME: this specialty should be done via a derived class */
/* specialty for install.cc */
- void add_subdirs (char const *path);
+ void add_subdirs (String const &path);
void reverse_sort ();
char *enumerate (char const *prev = 0);
#include "ini.h"
#include "resource.h"
-#include "concat.h"
+#include "String++.h"
#include "state.h"
#include "geturl.h"
#include "dialog.h"
{
if (!strstr (path, "setup.ini") )
return;
- io_stream *ini_file = io_stream::open (concat ("file://", local_dir,"/", path, 0), "rb");
+ io_stream *ini_file = io_stream::open (String ("file://") + local_dir + "/" + path, "rb");
if (!ini_file)
{
- note (NULL, IDS_SETUPINI_MISSING, path);
+ note (NULL, IDS_SETUPINI_MISSING, (String ("file://") + local_dir + "/" + path).cstr_oneuse());
return;
}
+ else
+ log (LOG_BABBLE, String ("Found ini file - file://") + local_dir + "/" + path);
/* FIXME: only use most recent copy */
setup_timestamp = 0;
setup_version = 0;
- ini_init (ini_file, concat ("file://", local_dir,"/", path, 0));
+ ini_init (ini_file, String ("file://") + local_dir + "/" + path);
/*yydebug = 1; */
for (size_t n = 1; n <= site_list.number (); n++)
{
io_stream *ini_file =
- get_url_to_membuf (concat (site_list[n]->url, "/setup.ini", 0), owner);
+ get_url_to_membuf (site_list[n]->url + "/setup.ini", owner);
if (!ini_file)
{
- note (owner, IDS_SETUPINI_MISSING, site_list[n]->url);
+ note (owner, IDS_SETUPINI_MISSING, site_list[n]->url.cstr_oneuse());
continue;
}
else
{
/* save known-good setup.ini locally */
- char const *fp = concat ("file://", local_dir, "/",
- rfc1738_escape_part (site_list[n]->url),
- "/setup.ini", 0);
+ String const fp = String ("file://") + local_dir + "/" +
+ rfc1738_escape_part (site_list[n]->url) +
+ "/setup.ini";
io_stream::mkpath_p (PATH_TO_FILE, fp);
io_stream *inistream = io_stream::open (fp, "wb");
if (inistream && !ini_file->seek (0, IO_SEEK_SET))
{
if (io_stream::copy (ini_file, inistream))
- io_stream::remove (fp);
+ io_stream::remove (fp.cstr_oneuse());
delete ini_file;
delete inistream;
}
- delete[] fp;
++ini_count;
}
}
return;
}
- if (get_root_dir ())
+ if (get_root_dir ().cstr_oneuse())
{
io_stream::mkpath_p (PATH_TO_DIR, "cygfile:///etc/setup");
version);
if (setup_version)
{
- char *ini_version = canonicalize_version (setup_version);
- char *our_version = canonicalize_version (version);
- if (strcmp (our_version, ini_version) < 0)
+ String ini_version = canonicalize_version (setup_version);
+ String our_version = canonicalize_version (version);
+ // XXX useversion < operator
+ if (our_version.compare (ini_version) < 0)
note (owner, IDS_OLD_SETUP_VERSION, version, setup_version);
}
#define _INI_H_
class io_stream;
-void ini_init (io_stream *, char const *);
+class String;
+void ini_init (io_stream *, String const &);
#define YYSTYPE char *
#ifdef __cplusplus
#include "ini.h"
#include "iniparse.h"
+#include "String++.h"
#define YY_INPUT(buf,result,max_size) { result = ini_getchar(buf, max_size); }
extern char *parse_mirror;
void
-ini_init(io_stream *stream, char const *mirror)
+ini_init(io_stream *stream, String const &mirror)
{
input_stream = stream;
if (parse_mirror)
delete[] parse_mirror;
- parse_mirror = new char[strlen (mirror) + 1];
- strcpy (parse_mirror, mirror);
+ parse_mirror = mirror.cstr();
}
static int
| LDESC STRING { cpv->set_ldesc ($2); }
| CATEGORY categories
| REQUIRES requires
- | INSTALL STRING STRING { if (!cpv->Canonical_version ())
+ | INSTALL STRING STRING { if (!cpv->Canonical_version ().size())
{
fileparse f;
if (parse_filename ($2, f))
| T_UNKNOWN { trust = TRUST_UNKNOWN; }
| /* empty */
| error '\n' { yylineno --;
- yyerror ("unrecognized line in package %s (do you have the latest setup?)", cp->name);
+ yyerror ("unrecognized line in package %s (do you have the latest setup?)", cp->name.cstr_oneuse());
yylineno ++;
}
;
{
int merged = 0;
for (size_t n = 1; !merged && n <= cp->versions.number (); n++)
- if (!strcasecmp(cp->versions[n]->Canonical_version(), cpv->Canonical_version()))
+ if (!cp->versions[n]->Canonical_version().casecompare(cpv->Canonical_version()))
{
/* ASSUMPTIONS:
categories and requires are consistent for the same version across
if (cpv->src.sites.number ())
cp->versions[n]->src.sites.registerbykey (cpv->src.sites[1]->key);
/* Copy the descriptions across */
- if (cpv->SDesc () && !cp->versions[n]->SDesc ())
+ if (cpv->SDesc ().size() && !cp->versions[n]->SDesc ().size())
cp->versions[n]->set_sdesc (cpv->SDesc ());
- if (cpv->LDesc () && !cp->versions[n]->LDesc ())
+ if (cpv->LDesc ().size() && !cp->versions[n]->LDesc ().size())
cp->versions[n]->set_ldesc (cpv->LDesc ());
cpv = (cygpackage *)cp->versions[n];
merged = 1;
#include "dialog.h"
#include "concat.h"
#include "geturl.h"
-#include "mkdir.h"
#include "state.h"
#include "diskfull.h"
#include "msg.h"
static int num_installs, num_replacements, num_uninstalls;
static void uninstall_one (packagemeta &);
static int replace_one (packagemeta &);
-static int install_one_source (packagemeta &, packagesource &, char const *,
- char const *, package_type_t);
+static int install_one_source (packagemeta &, packagesource &, String const &,
+ String const &, package_type_t);
static bool rebootneeded;
/* FIXME: upgrades should be a method too */
uninstall_one (packagemeta & pkgm)
{
Progress.SetText1 ("Uninstalling...");
- Progress.SetText2 (pkgm.name);
- log (0, "Uninstalling %s", pkgm.name);
+ Progress.SetText2 (pkgm.name.cstr_oneuse());
+ log (LOG_TIMESTAMP, String("Uninstalling ") + pkgm.name);
pkgm.uninstall ();
num_uninstalls++;
}
{
int errors = 0;
Progress.SetText1 ("Replacing...");
- Progress.SetText2 (pkg.name);
- log (0, "Replacing %s", pkg.name);
+ Progress.SetText2 (pkg.name.cstr_oneuse());
+ log (LOG_TIMESTAMP, String( "Replacing ") + pkg.name);
pkg.uninstall ();
errors +=
/* install one source at a given prefix. */
static int
install_one_source (packagemeta & pkgm, packagesource & source,
- char const *prefixURL, char const *prefixPath, package_type_t type)
+ String const &prefixURL, String const &prefixPath, package_type_t type)
{
int errors = 0;
Progress.SetText2 (source.Base ());
{
io_stream *tmp =
io_stream::
- open (concat ("cygfile:///etc/setup/", pkgm.name, ".lst.gz", 0),
+ open (String ("cygfile:///etc/setup/") + pkgm.name + ".lst.gz",
"wb");
lst = new compress_gz (tmp, "w9");
if (lst->error ())
char msg[64];
strcpy (msg, "Installing");
Progress.SetText1 (msg);
- log (0, "%s %s", msg, source.Cached ());
+ log (LOG_TIMESTAMP, "%s %s", msg, source.Cached ());
io_stream *tmp = io_stream::open (source.Cached (), "rb");
archive *thefile = 0;
if (tmp)
/* FIXME: potential leak of either *tmp or *tmp2 */
if (thefile)
{
- const char *fn;
- while ((fn = thefile->next_file_name ()))
+ String fn;
+ while ((fn = thefile->next_file_name ()).size())
{
if (lst)
- lst->write (concat (fn, "\n", 0), strlen (fn) + 1);
+ {
+ String tmp=fn + "\n";
+ lst->write (tmp.cstr_oneuse(), tmp.size() + 1);
+ }
+
+ String canonicalfn = prefixPath + fn;
- /* FIXME: concat leaks memory */
- Progress.SetText3 (concat (prefixPath, fn, 0));
- log (LOG_BABBLE, "Installing file %s%s%s", prefixURL,prefixPath, fn);
+ Progress.SetText3 (canonicalfn.cstr_oneuse());
+ log (LOG_BABBLE, String("Installing file ") + prefixURL + prefixPath + fn);
if (archive::extract_file (thefile, prefixURL, prefixPath) != 0)
{
//extract to temp location
if (archive::extract_file (thefile, prefixURL, prefixPath, ".new") != 0)
{
- log (0, "Unable to install file %s%s%s", prefixURL,prefixPath, fn);
+ log (LOG_TIMESTAMP, String("Unable to install file ")+ prefixURL+prefixPath+ fn);
errors++;
}
else
/* Get the short file names */
char source[MAX_PATH];
unsigned int len =
- GetShortPathName (cygpath ("/", fn, ".new", 0),
+ GetShortPathName (cygpath ("/", fn.cstr_oneuse(), ".new", 0).cstr_oneuse(),
source, MAX_PATH);
if (!len || len > MAX_PATH)
{
- log (0,
+ log (LOG_TIMESTAMP,
"Unable to schedule reboot replacement of file %s with %s (Win32 Error %ld)",
- cygpath ("/", fn, 0), cygpath ("/", fn, ".new",
- 0),
+ cygpath ("/", fn.cstr_oneuse(), 0).cstr_oneuse(), cygpath ("/", fn.cstr_oneuse(), ".new", 0).cstr_oneuse(),
GetLastError ());
++errors;
}
{
char dest[MAX_PATH];
len =
- GetShortPathName (cygpath ("/", fn, 0), dest,
+ GetShortPathName (cygpath ("/", fn.cstr_oneuse(), 0).cstr_oneuse(), dest,
MAX_PATH);
if (!len || len > MAX_PATH)
{
- log (0,
+ log (LOG_TIMESTAMP,
"Unable to schedule reboot replacement of file %s with %s (Win32 Error %ld)",
- cygpath ("/", fn, 0), cygpath ("/", fn,
- ".new", 0),
+ cygpath ("/", fn.cstr_oneuse(), 0).cstr_oneuse(), cygpath ("/", fn.cstr_oneuse(),
+ ".new", 0).cstr_oneuse(),
GetLastError ());
++errors;
if (!WritePrivateProfileString
("rename", dest, source, "WININIT.INI"))
{
- log (0,
+ log (LOG_TIMESTAMP,
"Unable to schedule reboot replacement of file %s with %s (Win32 Error %ld)",
- cygpath ("/", fn, 0), cygpath ("/", fn,
- ".new", 0),
+ cygpath ("/", fn.cstr_oneuse(), 0).cstr_oneuse(), cygpath ("/", fn.cstr_oneuse(),
+ ".new", 0).cstr_oneuse(),
GetLastError ());
++errors;
}
* - we need a io method to get win32 paths
* or to wrap this system call
*/
- if (!MoveFileEx (cygpath ("/", fn, ".new", 0),
- cygpath ("/", fn, 0),
+ if (!MoveFileEx (cygpath ("/", fn.cstr_oneuse(), ".new", 0).cstr_oneuse(),
+ cygpath ("/", fn.cstr_oneuse(), 0).cstr_oneuse(),
MOVEFILE_DELAY_UNTIL_REBOOT |
MOVEFILE_REPLACE_EXISTING))
{
- log (0,
+ log (LOG_TIMESTAMP,
"Unable to schedule reboot replacement of file %s with %s (Win32 Error %ld)",
- cygpath ("/", fn, 0), cygpath ("/", fn, ".new",
- 0),
+ cygpath ("/", fn.cstr_oneuse(), 0).cstr_oneuse(), cygpath ("/", fn.cstr_oneuse(), ".new", 0).cstr_oneuse(),
GetLastError ());
++errors;
}
progress (0);
- int df = diskfull (get_root_dir ());
+ int df = diskfull (get_root_dir ().cstr_oneuse());
Progress.SetBar3 (df);
if (lst)
next_dialog = IDD_DESKTOP;
- mkdir_p (1, get_root_dir ());
+ io_stream::mkpath_p (PATH_TO_DIR, get_root_dir ());
for (i = 0; standard_dirs[i]; i++)
{
- char *p = cygpath (standard_dirs[i], 0);
- if (p)
- mkdir_p (1, p);
- delete[] p;
+ String p = cygpath (standard_dirs[i], 0);
+ if (p.size())
+ io_stream::mkpath_p (PATH_TO_DIR, p);
}
/* Create /var/run/utmp */
total_bytes = 0;
total_bytes_sofar = 0;
- int df = diskfull (get_root_dir ());
+ int df = diskfull (get_root_dir ().cstr_oneuse());
Progress.SetBar3 (df);
int istext = (root_text == IDC_ROOT_TEXT) ? 1 : 0;
int issystem = (root_scope == IDC_ROOT_SYSTEM) ? 1 : 0;
- create_mount ("/", get_root_dir (), istext, issystem);
+ create_mount ("/", get_root_dir ().cstr_oneuse(), istext, issystem);
create_mount ("/usr/bin", cygpath ("/bin", 0), istext, issystem);
create_mount ("/usr/lib", cygpath ("/lib", 0), istext, issystem);
set_cygdrive_flags (istext, issystem);
const char *err = strerror (temperr);
if (!err)
err = "(unknown error)";
- fatal (owner, IDS_ERR_OPEN_WRITE, err);
+ fatal (owner, IDS_ERR_OPEN_WRITE, "Package Database",
+ err);
}
if (!errors)
#include "io_stream_file.h"
#include "io_stream_cygfile.h"
#include "mkdir.h"
+#include "String++.h"
/* Static members */
io_stream *
}
io_stream *
-io_stream::open (const char *name, const char *mode)
+io_stream::open (String const &name, String const &mode)
{
- if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0] ||
- !mode || IsBadStringPtr (mode, 5) || !mode[0])
+ if (name.size() < 7 ||
+ mode.size() == 0)
return NULL;
/* iterate through the known url prefix's */
- if (!strncasecmp ("file://", name, 7))
+ if (!name.casecompare ("file://", 7))
{
- io_stream_file *rv = new io_stream_file (&name[7], mode);
+ io_stream_file *rv = new io_stream_file (&name.cstr_oneuse()[7], mode.cstr_oneuse());
if (!rv->error ())
return rv;
delete rv;
return NULL;
}
- if (!strncasecmp ("cygfile://", name, 10))
+ if (!name.casecompare ("cygfile://", 10))
{
- io_stream_cygfile *rv = new io_stream_cygfile (&name[10], mode);
+ io_stream_cygfile *rv = new io_stream_cygfile (&name.cstr_oneuse()[10], mode.cstr_oneuse());
if (!rv->error ())
return rv;
delete rv;
}
int
-io_stream::mkpath_p (path_type_t isadir, const char *name)
+io_stream::mkpath_p (path_type_t isadir, String const &name)
{
- if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0])
+ if (name.size() < 7)
return 1;
/* iterate through the known url prefix's */
- if (!strncasecmp ("file://", name, 7))
+ if (!name.casecompare ("file://", 7))
{
- return mkdir_p (isadir == PATH_TO_DIR ? 1 : 0, &name[7]);
+ return mkdir_p (isadir == PATH_TO_DIR ? 1 : 0, &name.cstr_oneuse()[7]);
}
- if (!strncasecmp ("cygfile://", name, 10))
+ if (!name.casecompare ("cygfile://", 10))
{
- return cygmkdir_p (isadir == PATH_TO_DIR ? 1 : 0, &name[10]);
+ return cygmkdir_p (isadir, &name.cstr_oneuse()[10]);
}
return 1;
}
/* remove a file or directory. */
int
-io_stream::remove (const char *name)
+io_stream::remove (String const &name)
{
- if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0])
+ if (!name.size())
return 1;
/* iterate through the known url prefix's */
- if (!strncasecmp ("file://", name, 7))
- return io_stream_file::remove (&name[7]);
- if (!strncasecmp ("cygfile://", name, 10))
- return io_stream_cygfile::remove (&name[10]);
+ if (!name.casecompare ("file://", 7))
+ return io_stream_file::remove (&name.cstr_oneuse()[7]);
+ if (!name.casecompare ("cygfile://", 10))
+ return io_stream_cygfile::remove (&name.cstr_oneuse()[10]);
return 1;
}
int
-io_stream::mklink (const char *from, const char *to,
+io_stream::mklink (String const &from, String const &to,
io_stream_link_t linktype)
{
- log (LOG_BABBLE, "io_stream::mklink (%s->%s)", from, to);
- if (!from || IsBadStringPtr (from, MAX_PATH) ||
- !to || IsBadStringPtr (to, MAX_PATH))
+ log (LOG_BABBLE, String("io_stream::mklink (") + from + "->" + to + ")");
+ if (!from.size() || !to.size())
{
- log (LOG_TIMESTAMP,
- "invalid string in from or to parameters to mklink");
+ log (LOG_TIMESTAMP, "invalid string in from or to parameters to mklink");
return 1;
}
/* iterate through the known url prefixes */
- if (!strncasecmp ("file://", from, 7))
+ if (!from.casecompare ("file://", 7))
{
/* file urls can symlink or hardlink to file url's. */
/* TODO: allow linking to cygfile url's */
- if (!strncasecmp ("file://", to, 7))
- return io_stream_file::mklink (&from[7], &to[7], linktype);
+ if (!to.casecompare ("file://", 7))
+ return io_stream_file::mklink (&from.cstr_oneuse()[7], &to.cstr_oneuse()[7], linktype);
log (LOG_TIMESTAMP, "Attempt to link across url providers");
return 1;
}
- if (!strncasecmp ("cygfile://", from, 10))
+ if (!from.casecompare ("cygfile://", 10))
{
/* cygfile urls can symlink or hardlink to cygfile urls's. */
/* TODO: allow -> file urls */
- if (!strncasecmp ("cygfile://", to, 10))
- return io_stream_cygfile::mklink (&from[10], &to[10], linktype);
+ if (!to.casecompare ("cygfile://", 10))
+ return io_stream_cygfile::mklink (&from.cstr_oneuse()[10], &to.cstr_oneuse()[10], linktype);
log (LOG_TIMESTAMP, "Attempt to link across url providers");
return 1;
}
/* http urls can symlink to http or ftp url's */
}
#endif
- log (LOG_TIMESTAMP, "Unsupported url providers for %s", from);
+ log (LOG_TIMESTAMP, String ("Unsupported url providers for ") + from);
return 1;
}
int
-io_stream::move_copy (const char *from, const char *to)
+io_stream::move_copy (String const &from, String const &to)
{
/* parameters are ok - checked before calling us, and we are private */
io_stream *in = io_stream::open (to, "wb");
io_stream *out = io_stream::open (from, "rb");
if (io_stream::copy (in, out))
{
- log (LOG_TIMESTAMP, "Failed copy of %s to %s", from, to);
+ log (LOG_TIMESTAMP, String("Failed copy of ") + from + " to "+ to);
delete out;
io_stream::remove (to);
delete in;
return countout ? countout : -1;
}
}
+ // XXX FIXME: What if countin < 0? return an error
/* TODO:
out->set_mtime (in->get_mtime ());
}
int
-io_stream::move (const char *from, const char *to)
+io_stream::move (String const &from, String const &to)
{
- if (!from || IsBadStringPtr (from, MAX_PATH) ||
- !to || IsBadStringPtr (to, MAX_PATH))
+ if (!from.size() || !to.size())
{
log (LOG_TIMESTAMP, "invalid string in from or to parameters to move");
return 1;
}
/* iterate through the known url prefixes */
- if (!strncasecmp ("file://", from, 7))
+ if (!from.casecompare ("file://", 7))
{
/* TODO: allow 'move' to cygfile url's */
- if (strncasecmp ("file://", to, 7))
+ if (to.casecompare ("file://", 7))
return io_stream::move_copy (from, to);
- return io_stream_file::move (&from[7], &to[7]);
+ return io_stream_file::move (&from.cstr_oneuse()[7], &to.cstr_oneuse()[7]);
}
- if (!strncasecmp ("cygfile://", from, 10))
+ if (!from.casecompare ("cygfile://", 10))
{
/* TODO: allow -> file urls */
- if (strncasecmp ("cygfile://", to, 10))
+ if (to.casecompare ("cygfile://", 10))
return io_stream::move_copy (from, to);
- return io_stream_cygfile::move (&from[10], &to[10]);
+ return io_stream_cygfile::move (&from.cstr_oneuse()[10], &to.cstr_oneuse()[10]);
}
#if 0
if (!strmcasecmp ("http://", from, 7))
/* http urls can symlink to http or ftp url's */
}
#endif
- log (LOG_TIMESTAMP, "Unsupported url providers for %s", from);
+ log (LOG_TIMESTAMP, "Unsupported url providers for %s", from.cstr_oneuse());
return 1;
}
}
int
-io_stream::exists (const char *name)
+io_stream::exists (String const &name)
{
- if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0])
+ if (!name.size())
return 1;
/* iterate through the known url prefix's */
- if (!strncasecmp ("file://", name, 7))
- return io_stream_file::exists (&name[7]);
- if (!strncasecmp ("cygfile://", name, 10))
- return io_stream_cygfile::exists (&name[10]);
+ if (!name.casecompare ("file://", 7))
+ return io_stream_file::exists (&name.cstr_oneuse()[7]);
+ if (!name.casecompare ("cygfile://", 10))
+ return io_stream_cygfile::exists (&name.cstr_oneuse()[10]);
return 1;
}
* case.
*/
+#include <stdio.h>
+#include "String++.h"
+
/* Some things don't fit cleanly just - TODO
* make mkdir_p fit in the hierarchy
*/
* will return non-NULL. To access the files within the archive use io_stream::factory
* to create a new stream that will read from the archive.
*/
- static io_stream *open (const char *, const char *);
- static int remove (const char *);
- static int exists (const char *);
+ static io_stream *open (String const &, String const &);
+ static int remove (String const &);
+ static int exists (String const &);
/* moves physical stream source to dest. A copy will be attempted if a
* pointer flip fails.
*/
- static int move (char const *, char const *);
+ static int move (String const &, String const &);
/* ensure that we have access to the entire path */
/* Create a directory, and any needed parent directories.
* returns 1 on failure.
*/
- static int mkpath_p (path_type_t, const char *);
+ static int mkpath_p (path_type_t, String const &);
/* link from, to, type. Returns 1 on failure */
- static int mklink (const char *, const char *, io_stream_link_t);
+ static int mklink (String const &, String const &, io_stream_link_t);
/* copy from stream to stream - 0 on success */
static ssize_t copy (io_stream *, io_stream *);
/* TODO: we may need two versions of each of these:
*/
// virtual const char* next_file_name() = NULL;
/* if you are still needing these hints... give up now! */
- virtual ~ io_stream () = 0;
+ virtual ~ io_stream () = 0;
+
+ io_stream& operator << (io_stream&);
+
protected:
void operator= (const io_stream &);
io_stream () : destroyed (0)
io_stream (const io_stream &);
unsigned int destroyed;
private:
- static int move_copy (char const *, char const *);
+ static int move_copy (String const &, String const &);
};
#endif /* _IO_STREAM_H_ */
static void
get_root_dir_now ()
{
- if (get_root_dir ())
+ if (get_root_dir ().size())
return;
read_mounts ();
}
-io_stream_cygfile::io_stream_cygfile (const char *name, const char *mode)
+io_stream_cygfile::io_stream_cygfile (String const &name, String const &mode) : fp(), fname()
{
- fname = NULL;
- fp = NULL;
errno = 0;
- if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0] ||
- !mode || IsBadStringPtr (mode, 5) || !mode[0])
+ if (!name.size() || !mode.size())
return;
/* do this every time because the mount points may change due to fwd/back button use...
* TODO: make this less...manual
*/
get_root_dir_now ();
- if (!get_root_dir ())
+ if (!get_root_dir ().size())
/* TODO: assign a errno for "no mount table :} " */
return;
- fname = cygpath (name, 0);
- lmode = new char[strlen(mode) + 1];
- strcpy (lmode,mode);
- fp = fopen (fname, mode);
+ fname = cygpath (name.cstr_oneuse(), 0);
+ lmode = mode;
+ fp = fopen (fname.cstr_oneuse(), mode.cstr_oneuse());
if (!fp)
lasterr = errno;
}
io_stream_cygfile::~io_stream_cygfile ()
{
- if (lmode)
- delete[] lmode;
- if (fname)
- delete[] fname;
if (fp)
fclose (fp);
destroyed = 1;
/* Static members */
int
-io_stream_cygfile::exists (const char *path)
+io_stream_cygfile::exists (String const &path)
{
get_root_dir_now ();
- if (get_root_dir () && _access (cygpath (path, 0), 0) == 0)
+ if (get_root_dir ().size() && _access (cygpath (path.cstr_oneuse(), 0).cstr_oneuse(), 0) == 0)
return 1;
return 0;
}
int
-io_stream_cygfile::remove (const char *path)
+io_stream_cygfile::remove (String const &path)
{
- if (!path)
+ if (!path.size())
return 1;
get_root_dir_now ();
- if (!get_root_dir ())
+ if (!get_root_dir ().size())
/* TODO: assign a errno for "no mount table :} " */
return 1;
- unsigned long w = GetFileAttributes (cygpath (path, 0));
+ unsigned long w = GetFileAttributes (cygpath (path.cstr_oneuse(),0).cstr_oneuse());
if (w != 0xffffffff && w & FILE_ATTRIBUTE_DIRECTORY)
{
- char *tmp = new char [strlen (cygpath (path, 0)) + 10];
+ char tmp[cygpath (path.cstr_oneuse(),0).size() + 10];
int i = 0;
do
{
- i++;
- sprintf (tmp, "%s.old-%d", cygpath (path, 0), i);
+ ++i;
+ sprintf (tmp, "%s.old-%d", cygpath (path.cstr_oneuse(),0).cstr_oneuse(), i);
}
while (GetFileAttributes (tmp) != 0xffffffff);
fprintf (stderr, "warning: moving directory \"%s\" out of the way.\n",
- path);
- MoveFile (cygpath (path, 0), tmp);
- delete[] tmp;
+ path.cstr_oneuse());
+ MoveFile (cygpath (path.cstr_oneuse(),0).cstr_oneuse(), tmp);
}
- return !DeleteFileA (cygpath (path, 0));
+ return !DeleteFileA (cygpath (path.cstr_oneuse(),0).cstr_oneuse());
}
int
-io_stream_cygfile::mklink (const char *from, const char *to,
+io_stream_cygfile::mklink (String const &from, String const &to,
io_stream_link_t linktype)
{
- /* FIXME: badstring check */
- if (!from || !to)
+ if (!from.size() || !to.size())
return 1;
switch (linktype)
{
case IO_STREAM_SYMLINK:
- return mkcygsymlink (cygpath (from, 0), to);
+ return mkcygsymlink (cygpath (from.cstr_oneuse(),0).cstr_oneuse(), to.cstr_oneuse());
case IO_STREAM_HARDLINK:
{
/* For now, just copy */
/* textmode alert: should we translate when linking from an binmode to a
text mode mount and vice verca?
*/
- io_stream *in = io_stream::open (cygpath (to, 0), "rb");
+ io_stream *in = io_stream::open (cygpath (to.cstr_oneuse(),0), "rb");
if (!in)
{
- log (LOG_TIMESTAMP, "could not open %s for reading in mklink",
- to);
+ log (LOG_TIMESTAMP, String("could not open ") + to +" for reading in mklink");
return 1;
}
- io_stream *out = io_stream::open (cygpath (from, 0), "wb");
+ io_stream *out = io_stream::open (cygpath (from.cstr_oneuse(),0), "wb");
if (!out)
{
- log (LOG_TIMESTAMP, "could not open %s for writing in mklink",
- from);
+ log (LOG_TIMESTAMP, String("could not open ")+ from + " for writing in mklink");
delete in;
return 1;
}
- ssize_t len;
- char buf[16384];
- while ((len = in->read (buf, 16384)) > 0)
+ if (io_stream::copy (in, out))
{
- ssize_t wrote = out->write (buf, len);
- if (wrote != len)
- {
- log (LOG_TIMESTAMP, "error writing to %s in mklink", from);
- delete in;
- delete out;
- return 1;
- }
+ log (LOG_TIMESTAMP, String ("Failed to hardlink ")+ from + "->" +to +
+ " during file copy.");
+ delete in;
+ delete out;
+ return 1;
}
delete in;
delete out;
- if (len == 0)
- return 0;
- log (LOG_TIMESTAMP,
- "read error reading %s while copying to %s (emulated hardlink)",
- to, from);
- return 1;
+ return 0;
}
}
return 1;
}
int
-cygmkdir_p (int isadir, const char *name)
+cygmkdir_p (enum path_type_t isadir, String const &name)
{
- if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0])
+ if (!name.size())
return 1;
get_root_dir_now ();
- if (!get_root_dir ())
+ if (!get_root_dir ().size())
/* TODO: assign a errno for "no mount table :} " */
return 1;
- return mkdir_p (isadir, cygpath (name, 0));
+ return mkdir_p (isadir == PATH_TO_DIR ? 1 : 0, cygpath (name.cstr_oneuse(),0).cstr_oneuse());
}
int
io_stream_cygfile::set_mtime (int mtime)
{
- if (!fname)
+ if (!fname.size())
return 1;
if (fp)
fclose (fp);
ftime.dwHighDateTime = ftimev >> 32;
ftime.dwLowDateTime = ftimev;
HANDLE h =
- CreateFileA (fname, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ CreateFileA (fname.cstr_oneuse(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
0, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, 0);
if (h)
}
int
-io_stream_cygfile::move (char const *from, char const *to)
+io_stream_cygfile::move (String const &from, String const &to)
{
- if (!from || IsBadStringPtr (from, MAX_PATH) || !from[0] ||
- !to || IsBadStringPtr (to, MAX_PATH) || !to[0])
+ if (!from.size() || !to.size())
return 1;
get_root_dir_now ();
- if (!get_root_dir ())
+ if (!get_root_dir ().size())
/* TODO: assign a errno for "no mount table :} " */
return 1;
- return rename (cygpath (from, 0), cygpath (to, 0));
+ return rename (cygpath (from.cstr_oneuse(),0).cstr_oneuse(), cygpath (to.cstr_oneuse(),0).cstr_oneuse());
}
size_t
io_stream_cygfile::get_size ()
{
- if (!fname)
+ if (!fname.size() )
return 0;
return get_file_size (fname);
}
#ifndef _IO_STREAM_CYGFILE_H_
#define _IO_STREAM_CYGFILE_H_
+#include "io_stream.h"
+#include "String++.h"
/* io_stream on disk files using cygwin paths
* and potentially understanding links in the future
*/
-extern int cygmkdir_p (int isadir, const char *path);
+extern int cygmkdir_p (enum path_type_t isadir, String const &path);
class io_stream_cygfile:public io_stream
{
public:
- static int exists (const char *);
- static int remove (const char *);
- static int mklink (const char *, const char *, io_stream_link_t);
- io_stream_cygfile (const char *, const char *);
+ static int exists (String const &);
+ static int remove (String const &);
+ static int mklink (String const &, String const &, io_stream_link_t);
+ io_stream_cygfile (String const &, String const &);
virtual ~ io_stream_cygfile ();
/* read data (duh!) */
virtual ssize_t read (void *buffer, size_t len);
};
virtual size_t get_size ();
/* dummy for io_stream_file */
- virtual const char *next_file_name ()
+ virtual String next_file_name ()
{
return NULL;
};
- static int move (char const *, char const *);
+ static int move (String const &,String const &);
private:
/* always require parameters */
io_stream_cygfile ()
};
FILE *fp;
int lasterr;
- char *fname;
- char *lmode;
+ String fname;
+ String lmode;
};
#endif /* _IO_STREAM_CYGFILE_H_ */
#define FACTOR (0x19db1ded53ea710LL)
#define NSPERSEC 10000000LL
-io_stream_file::io_stream_file (const char *name, const char *mode)
+io_stream_file::io_stream_file (String const &name, String const &mode):
+fp(), fname(name),lmode (mode)
{
- fname = NULL;
- fp = NULL;
errno = 0;
- if (!name || IsBadStringPtr (name, MAX_PATH) || !name[0] ||
- !mode || IsBadStringPtr (mode, 5) || !mode[0])
+ if (!name.size() || !mode.size())
return;
- lmode = new char[strlen(mode) + 1];
- strcpy (lmode,mode);
- fname = new char[strlen(name) + 1];
- strcpy (fname,name);
- fp = fopen (name, mode);
+ fp = fopen (name.cstr_oneuse(), mode.cstr_oneuse());
if (!fp)
lasterr = errno;
}
io_stream_file::~io_stream_file ()
{
- if (fname)
- delete[] fname;
- if (lmode)
- delete[] lmode;
if (fp)
fclose (fp);
destroyed = 1;
}
int
-io_stream_file::exists (const char *path)
+io_stream_file::exists (String const &path)
{
- if (_access (path, 0) == 0)
+ if (_access (path.cstr_oneuse(), 0) == 0)
return 1;
return 0;
}
int
-io_stream_file::remove (const char *path)
+io_stream_file::remove (String const &path)
{
- if (!path)
+ if (!path.size())
return 1;
- unsigned long w = GetFileAttributes (path);
+ unsigned long w = GetFileAttributes (path.cstr_oneuse());
if (w != 0xffffffff && w & FILE_ATTRIBUTE_DIRECTORY)
{
- char *tmp = new char [strlen (path) + 10];
+ char *tmp = new char [path.size() + 10];
int i = 0;
do
{
i++;
- sprintf (tmp, "%s.old-%d", path, i);
+ sprintf (tmp, "%s.old-%d", path.cstr_oneuse(), i);
}
while (GetFileAttributes (tmp) != 0xffffffff);
fprintf (stderr, "warning: moving directory \"%s\" out of the way.\n",
- path);
- MoveFile (path, tmp);
+ path.cstr_oneuse());
+ MoveFile (path.cstr_oneuse(), tmp);
delete[] tmp;
}
- return !DeleteFileA (path);
+ return !DeleteFileA (path.cstr_oneuse());
}
int
-io_stream_file::mklink (const char *from, const char *to,
+io_stream_file::mklink (String const &from, String const &to,
io_stream_link_t linktype)
{
- /* FIXME: badstring check */
- if (!from || !to)
+ if (!from.size() || !to.size())
return 1;
switch (linktype)
{
case IO_STREAM_SYMLINK:
- return mkcygsymlink (from, to);
+ return mkcygsymlink (from.cstr_oneuse(), to.cstr_oneuse());
case IO_STREAM_HARDLINK:
return 1;
}
int
io_stream_file::set_mtime (int mtime)
{
- if (!fname)
+ if (!fname.size())
return 1;
if (fp)
fclose (fp);
ftime.dwHighDateTime = ftimev >> 32;
ftime.dwLowDateTime = ftimev;
HANDLE h =
- CreateFileA (fname, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ CreateFileA (fname.cstr_oneuse(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
0, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, 0);
if (h)
}
int
-io_stream_file::move (char const *from, char const *to)
+io_stream_file::move (String const &from, String const &to)
{
- if (!from || IsBadStringPtr (from, MAX_PATH) || !from[0] ||
- !to || IsBadStringPtr (to, MAX_PATH) || !to[0])
+ if (!from.size()|| !to.size())
return 1;
- return rename (from, to);
+ return rename (from.cstr_oneuse(), to.cstr_oneuse());
}
size_t
io_stream_file::get_size ()
{
- if (!fname)
+ if (!fname.size())
return 0;
return get_file_size (fname);
}
#ifndef _IO_STREAM_FILE_H_
#define _IO_STREAM_FILE_H_
+#include "io_stream.h"
+#include "String++.h"
/* io_stream on disk files
*/
class io_stream_file:public io_stream
{
public:
- static int exists (const char *);
- static int remove (const char *);
- static int mklink (const char *, const char *, io_stream_link_t);
- io_stream_file (const char *, const char *);
+ static int exists (String const &);
+ static int remove (String const &);
+ static int mklink (String const &, String const &, io_stream_link_t);
+ io_stream_file (String const &,String const &);
virtual ~ io_stream_file ();
/* read data (duh!) */
virtual ssize_t read (void *buffer, size_t len);
};
virtual size_t get_size ();
/* dummy for io_stream_file */
- virtual const char *next_file_name ()
+ virtual String next_file_name ()
{
return NULL;
};
- static int move (char const *, char const *);
+ static int move (String const &,String const &);
private:
/* always require parameters */
io_stream_file ()
};
FILE *fp;
int lasterr;
- char *fname;
- char *lmode;
+ String fname;
+ String lmode;
};
#endif /* _IO_STREAM_FILE_H_ */
#include "mount.h"
#include "concat.h"
#include "log.h"
-#include "mkdir.h"
#include "io_stream.h"
#include "localdir.h"
void
save_local_dir ()
{
- mkdir_p (1, local_dir);
+ io_stream::mkpath_p (PATH_TO_DIR, local_dir);
io_stream *f;
- if (get_root_dir ())
+ if (get_root_dir ().size())
{
f = io_stream::open ("cygfile:///etc/setup/last-cache", "wb");
io_stream::remove ("file://last-cache");
f = io_stream::open ("file://last-cache", "wb");
if (f)
{
- char temp[1000];
- sprintf (temp, "%s", local_dir);
- f->write (temp, strlen (temp));
+ f->write (local_dir.cstr_oneuse(), local_dir.size());
delete f;
}
}
static void
check_if_enable_next (HWND h)
{
- EnableWindow (GetDlgItem (h, IDOK), local_dir != 0);
+ EnableWindow (GetDlgItem (h, IDOK), local_dir.size() != 0);
}
static void
static void
save_dialog (HWND h)
{
- local_dir = eget (h, IDC_LOCAL_DIR, local_dir);
+ local_dir = egetString (h, IDC_LOCAL_DIR);
}
switch (msg)
{
case BFFM_INITIALIZED:
- if (local_dir)
- SendMessage (h, BFFM_SETSELECTION, TRUE, (LPARAM) local_dir);
+ if (local_dir.size())
+ SendMessage (h, BFFM_SETSELECTION, TRUE, (LPARAM) local_dir.cstr_oneuse());
break;
}
return 0;
char *fg_ret = f->gets (localdir, 1000);
delete f;
if (fg_ret)
- {
- delete [] local_dir;
- local_dir = new char [strlen(localdir) +1];
- local_dir[strlen(localdir)] = '\0';
- strcpy (local_dir, localdir);
- }
+ local_dir = String (localdir);
}
inited = 1;
}
save_dialog (h);
save_local_dir ();
- log (0, "Selected local directory: %s", local_dir);
- if (SetCurrentDirectoryA (local_dir))
+ log (LOG_TIMESTAMP, "Selected local directory: %s", local_dir.cstr_oneuse());
+ if (SetCurrentDirectoryA (local_dir.cstr_oneuse()))
{
if (source == IDC_SOURCE_CWD)
{
}
}
else
- note (h, IDS_ERR_CHDIR, local_dir);
+ note (h, IDS_ERR_CHDIR, local_dir.cstr_oneuse());
return 0;
}
#include "mkdir.h"
#include "mount.h"
+#include "io_stream.h"
+
struct LogEnt
{
LogEnt *next;
- int flags;
+ enum log_level level;
time_t when;
- char msg[1];
+ String msg;
};
static LogEnt *first_logent = 0;
static LogEnt **next_logent = &first_logent;
-void
-log (int flags, const char *fmt, ...)
+void
+log (enum log_level level, String const &message)
{
- char buf[1000];
- va_list args;
- va_start (args, fmt);
- vsprintf (buf, fmt, args);
-
- LogEnt *l = (LogEnt *) malloc (sizeof (LogEnt) + strlen (buf) + 20);
+ LogEnt *l = new LogEnt;
l->next = 0;
- l->flags = flags;
+ l->level = level;
time (&(l->when));
*next_logent = l;
next_logent = &(l->next);
+ l->msg = message;
- char *b = l->msg;
- if (flags & LOG_TIMESTAMP)
+ char b[100];
+ b[0]='\0';
+ if (level == LOG_TIMESTAMP)
{
struct tm *tm = localtime (&(l->when));
strftime (b, 1000, "%Y/%m/%d %H:%M:%S ", tm);
- b += strlen (b);
}
+ l->msg = String (b) + message;
- strcpy (b, buf);
- msg ("LOG: %d %s", l->flags, l->msg);
+ msg ("LOG: %d %s", l->level, l->msg.cstr_oneuse());
+}
+
+void
+log (enum log_level level, const char *fmt, ...)
+{
+ char buf[1000];
+ va_list args;
+ va_start (args, fmt);
+ vsprintf (buf, fmt, args);
+ log (level, String(buf));
}
void
-log_save (int babble, const char *filename, int append)
+log_save (int babble, String const &filename, int append)
{
static int been_here = 0;
if (been_here)
return;
been_here = 1;
- mkdir_p (0, filename);
+ io_stream::mkpath_p (PATH_TO_FILE, filename);
- FILE *f = fopen (filename, append ? "at" : "wt");
+ io_stream *f = io_stream::open(String("file://")+filename, append ? "at" : "wt");
if (!f)
{
- fatal (NULL, IDS_NOLOGFILE, filename);
+ fatal (NULL, IDS_NOLOGFILE, filename.cstr_oneuse());
return;
}
for (l = first_logent; l; l = l->next)
{
- if (babble || !(l->flags & LOG_BABBLE))
+ if (babble || !(l->level == LOG_BABBLE))
{
- fputs (l->msg, f);
- if (l->msg[strlen (l->msg) - 1] != '\n')
- fputc ('\n', f);
+ char *tstr = l->msg.cstr();
+ f->write (tstr, strlen (tstr));
+ if (tstr[strlen (tstr) - 1] != '\n')
+ f->write ("'\n", 1);
}
}
- fclose (f);
+ delete f;
been_here = 0;
}
log (LOG_TIMESTAMP, "Ending cygwin install");
- if (source == IDC_SOURCE_DOWNLOAD || !get_root_dir ())
+ if (source == IDC_SOURCE_DOWNLOAD || !get_root_dir ().size())
{
- log_save (LOG_BABBLE, concat (local_dir, "/setup.log.full", 0), 0);
- log_save (0, concat (local_dir, "/setup.log", 0), 1);
+ log_save (LOG_BABBLE, local_dir + "/setup.log.full", 0);
+ log_save (0, local_dir + "/setup.log", 1);
}
else
{
- log_save (LOG_BABBLE, cygpath ("/setup.log.full", 0), 0);
- log_save (0, cygpath ("/setup.log", 0), 1);
+ log_save (LOG_BABBLE, cygpath ("/var/log/setup.log.full", 0), 0);
+ log_save (0, cygpath ("/var/log/setup.log", 0), 1);
}
ExitProcess (exit_code);
until they're written out. "babble" means the message is just idle
babbling; it can be ignored for shorter logs. */
-#define LOG_BABBLE 1
-#define LOG_TIMESTAMP 2
+#include "String++.h"
-void log (int flags, const char *fmt, ...)
+enum log_level {
+ LOG_BABBLE = 1,
+ LOG_TIMESTAMP = 2
+};
+
+void log (enum log_level level, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
+void log (enum log_level level, String const &);
/* Here, "babble" means to write out the babble also. If "append" is
nonzero, the log is appended to any existing file. */
-void log_save (int babble, const char *filename, int append);
+void log_save (int writebabble, String const &filename, int append);
/* This is the only legal way to exit. It writes out all the logs and things */
char cwd[_MAX_PATH];
GetCurrentDirectory (sizeof (cwd), cwd);
- local_dir = new char [strlen (cwd) + 1];
- local_dir [strlen (cwd)] = '\0';
- strcpy (local_dir, cwd);
- log (0, "Current Directory: %s", cwd);
+ local_dir = String (cwd);
+ log (LOG_TIMESTAMP, "Current Directory: %s", cwd);
char **argv;
int argc;
doesn't work. */
void
-make_link_2 (char *exepath, char *args, char *icon, char *lname)
+make_link_2 (char const *exepath, char const *args, char const *icon, char const *lname)
{
IShellLink *sl;
IPersistFile *pf;
extern "C"
{
#endif
- void make_link_2 (char *exepath, char *args, char *icon, char *lname);
+ void make_link_2 (char const *exepath, char const *args, char const *icon, char const *lname);
int mkcygsymlink (const char *from, const char *to);
changes, this is the file to change to match it. */
#if 0
-static const char *cvsid =
- "\n%%% $Id$\n";
+static const char *cvsid = "\n%%% $Id$\n";
#endif
#include "win32.h"
#include "state.h"
#include "concat.h"
+#include "String++.h"
+
static struct mnt
{
- const char *native;
- char *posix;
+ String native;
+ String posix;
int istext;
}
mount_table[255];
struct mnt *root_here = NULL;
-static char *
-find2 (HKEY rkey, int *istext, char *what)
+static String
+find2 (HKEY rkey, int *istext, String const &what)
{
- char *retval = 0;
- DWORD retvallen = 0;
- DWORD flags = 0;
- DWORD type;
HKEY key;
- if (RegOpenKeyEx (rkey, what, 0, KEY_READ, &key) != ERROR_SUCCESS)
+ if (RegOpenKeyEx (rkey, what.cstr_oneuse (), 0, KEY_READ, &key) !=
+ ERROR_SUCCESS)
return 0;
+ DWORD retvallen = 0;
+ DWORD type;
+
+ String Sretval;
if (RegQueryValueEx (key, "native", 0, &type, 0, &retvallen)
== ERROR_SUCCESS)
{
- retval = new char [MAX_PATH + 1];
+ char retval[retvallen];
if (RegQueryValueEx
(key, "native", 0, &type, (BYTE *) retval,
- &retvallen) != ERROR_SUCCESS)
- {
- delete[] retval;
- retval = 0;
- }
+ &retvallen) == ERROR_SUCCESS)
+ Sretval = String (retval);
}
+ DWORD flags = 0;
retvallen = sizeof (flags);
RegQueryValueEx (key, "flags", 0, &type, (BYTE *) & flags, &retvallen);
RegCloseKey (key);
- if (retval)
+ if (Sretval.size ())
*istext = (flags & MOUNT_BINARY) ? 0 : 1;
- return retval;
+ return Sretval;
}
void
-create_mount (const char *posix, const char *win32, int istext, int issystem)
+create_mount (String const posix, String const win32, int istext,
+ int issystem)
{
char buf[1000];
HKEY key;
sprintf (buf, "Software\\%s\\%s\\%s\\%s",
CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
CYGWIN_INFO_CYGWIN_REGISTRY_NAME,
- CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, posix);
+ CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, posix.cstr_oneuse ());
HKEY kr = issystem ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
- if (RegCreateKeyEx (kr, buf, 0, (char *) "Cygwin", 0, KEY_ALL_ACCESS,
+ if (RegCreateKeyEx (kr, buf, 0, "Cygwin", 0, KEY_ALL_ACCESS,
0, &key, &disposition) != ERROR_SUCCESS)
fatal ("mount");
- RegSetValueEx (key, "native", 0, REG_SZ, (BYTE *) win32,
- strlen (win32) + 1);
+ RegSetValueEx (key, "native", 0, REG_SZ, (BYTE *) win32.cstr_oneuse (),
+ win32.size () + 1);
flags = 0;
if (!istext)
flags |= MOUNT_BINARY;
}
static void
-remove1 (HKEY rkey, const char *posix)
+remove1 (HKEY rkey, String const posix)
{
char buf[1000];
sprintf (buf, "Software\\%s\\%s\\%s\\%s",
CYGWIN_INFO_CYGNUS_REGISTRY_NAME,
CYGWIN_INFO_CYGWIN_REGISTRY_NAME,
- CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, posix);
+ CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME, posix.cstr_oneuse ());
RegDeleteKey (rkey, buf);
}
void
-remove_mount (const char *posix)
+remove_mount (String const posix)
{
remove1 (HKEY_LOCAL_MACHINE, posix);
remove1 (HKEY_CURRENT_USER, posix);
in_table (struct mnt *m)
{
for (struct mnt * m1 = mount_table; m1 < m; m1++)
- if (strcasecmp (m1->posix, m->posix) == 0)
+ if (m1->posix.casecompare (m->posix) == 0)
return 1;
return 0;
}
char buf[10000];
root_here = NULL;
- for (mnt * m1 = mount_table; m1->posix; m1++)
+ for (mnt * m1 = mount_table; m1->posix.size (); m1++)
{
- delete[] m1->posix;
- if (m1->native)
- delete[] m1->native;
- m1->posix = NULL;
+ m1->posix = String (); //empty string;
+ m1->native = String ();
}
/* Loop through subkeys */
CYGWIN_INFO_CYGWIN_MOUNT_REGISTRY_NAME);
HKEY key = issystem ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
- if (RegCreateKeyEx (key, buf, 0, (char *) "Cygwin", 0, KEY_ALL_ACCESS,
+ if (RegCreateKeyEx (key, buf, 0, "Cygwin", 0, KEY_ALL_ACCESS,
0, &key, &disposition) != ERROR_SUCCESS)
break;
for (int i = 0;; i++, m++)
{
- m->posix = new char [MAX_PATH + 1];
+ char aBuffer[MAX_PATH + 1];
posix_path_size = MAX_PATH;
/* FIXME: if maximum posix_path_size is 256, we're going to
run into problems if we ever try to store a mount point that's
over 256 but is under MAX_PATH. */
- res = RegEnumKeyEx (key, i, m->posix, &posix_path_size, NULL,
+ res = RegEnumKeyEx (key, i, aBuffer, &posix_path_size, NULL,
NULL, NULL, NULL);
if (res == ERROR_NO_MORE_ITEMS)
{
- delete[] m->posix;
- m->posix = NULL;
+ m->posix = String ();
break;
}
+ m->posix = String (aBuffer);
- if (!*m->posix || in_table (m))
+ if (!m->posix.size () || in_table (m))
goto no_go;
else if (res != ERROR_SUCCESS)
break;
else
{
m->native = find2 (key, &m->istext, m->posix);
- if (!m->native)
+ if (!m->native.size ())
goto no_go;
- if (strcmp (m->posix, "/") == 0)
+ if (m->posix == "/")
{
root_here = m;
if (m->istext)
}
continue;
no_go:
- delete[] m->posix;
- m->posix = NULL;
- m--;
+ m->posix = String ();
+ --m;
}
RegCloseKey (key);
}
if (!root_here)
{
root_here = m;
- m->posix = new char [2];
- strcpy (m->posix, "/");
+ m->posix = String ("/");
char windir[_MAX_PATH];
root_text = IDC_ROOT_BINARY;
root_scope = (is_admin ())? IDC_ROOT_SYSTEM : IDC_ROOT_USER;
GetWindowsDirectory (windir, sizeof (windir));
windir[2] = 0;
- set_root_dir (concat (windir, "\\cygwin", 0));
+ set_root_dir (String (windir) + "\\cygwin");
m++;
}
}
void
-set_root_dir (const char *val)
+set_root_dir (String const val)
{
root_here->native = val;
}
-const char *
+String const
get_root_dir ()
{
- return root_here ? root_here->native : NULL;
+ return root_here ? root_here->native : String ();
}
/* Return non-zero if PATH1 is a prefix of PATH2.
Both are assumed to be of the same path style and / vs \ usage.
Neither may be "".
- LEN1 = strlen (PATH1). It's passed because often it's already known.
Examples:
/foo/ is a prefix of /foo <-- may seem odd, but desired
*/
static int
-path_prefix_p (const char *path1, const char *path2, int len1)
+path_prefix_p (String const path1, String const path2)
{
+ size_t len1 = path1.size ();
/* Handle case where PATH1 has trailing '/' and when it doesn't. */
- if (len1 > 0 && SLASH_P (path1[len1 - 1]))
- len1--;
+ if (len1 > 0 && SLASH_P (path1.cstr_oneuse ()[len1 - 1]))
+ --len1;
if (len1 == 0)
- return SLASH_P (path2[0]) && !SLASH_P (path2[1]);
+ return SLASH_P (path2.cstr_oneuse ()[0])
+ && !SLASH_P (path2.cstr_oneuse ()[1]);
- if (strncasecmp (path1, path2, len1) != 0)
+ if (path1.casecompare (path2, len1) != 0)
return 0;
- return SLASH_P (path2[len1]) || path2[len1] == 0 || path1[len1 - 1] == ':';
+ return SLASH_P (path2.cstr_oneuse ()[len1]) || path2.size () == len1
+ || path1.cstr_oneuse ()[len1 - 1] == ':';
}
-char *
-cygpath (const char *s, ...)
+static String
+cygpath (String const &thePath)
{
- va_list v;
- int max_len = -1;
+ size_t max_len = 0;
struct mnt *m, *match = NULL;
-
- va_start (v, s);
- char *path = vconcat (s, v);
- if (strncmp (path, "./", 2) == 0)
- memmove (path, path + 2, strlen (path + 2) + 1);
- if (strncmp (path, "/./", 3) == 0)
- memmove (path + 1, path + 3, strlen (path + 3) + 1);
-
- for (m = mount_table; m->posix; m++)
+ for (m = mount_table; m->posix.size (); m++)
{
- int n = strlen (m->posix);
- if (n < max_len || !path_prefix_p (m->posix, path, n))
+ size_t n = m->posix.size ();
+ if (n <= max_len || !path_prefix_p (m->posix, thePath))
continue;
max_len = n;
match = m;
if (!match)
return NULL;
- char *native;
- if (max_len == (int) strlen (path))
- {
- native = new char [strlen (match->native) + 1];
- strcpy (native, match->native);
- }
+ String native;
+ if (max_len == thePath.size ())
+ {
+ native = match->native;
+ }
else
- native = concat (match->native, "/", path + max_len, NULL);
- delete[] path;
+ native = match->native + "/" + String (thePath.cstr_oneuse () + max_len);
return native;
}
+
+String
+cygpath (const char *s, ...)
+{
+ va_list v;
+
+ va_start (v, s);
+ char *path = vconcat (s, v);
+ if (strncmp (path, "./", 2) == 0)
+ memmove (path, path + 2, strlen (path + 2) + 1);
+ if (strncmp (path, "/./", 3) == 0)
+ memmove (path + 1, path + 3, strlen (path + 3) + 1);
+
+ String thePath (path);
+ delete[]path;
+ return cygpath (thePath);
+}
nonzero if the existing mount is a text mount, else zero for
binary. */
+#include "String++.h"
+
char *find_mount (int *istext, int *issystem, char *path);
/* Similar to the mount and umount functions, but simplified */
-void create_mount (const char *posix, const char *win32, int istext,
+void create_mount (String const posix, String const win32, int istext,
int issystem);
-void remove_mount (const char *posix);
+void remove_mount (String const posix);
void read_mounts ();
/* Sets the cygdrive flags. Used to make the automounted drives' binary/text
mode consistent with the standard Cygwin mounts. */
void set_cygdrive_flags (int istext, int issystem);
-char *cygpath (const char *s, ...);
-void set_root_dir (const char *);
-const char *get_root_dir ();
+String cygpath (const char *s, ...);
+void set_root_dir (String const);
+String const get_root_dir ();
ExitProcess (0);
vsprintf (buf, fmt, args);
- log (0, "mbox %s: %s", name, buf);
+ log (LOG_TIMESTAMP, "mbox %s: %s", name, buf);
return MessageBox (owner, buf, "Cygwin Setup", type);
}
{
save_dialog (GetHWND ());
- log (0, "net: %s",
+ log (LOG_TIMESTAMP, "net: %s",
(net_method == IDC_NET_IE5) ? "IE5" :
(net_method == IDC_NET_DIRECT) ? "Direct" : "Proxy");
io_stream *ndb = io_stream::open (ndbn, "wb");
+ // XXX if this failed, try removing any existing .new database?
if (!ndb)
return errno ? errno : 1;
* also note that we are writing a fictional install source
* to keep cygcheck happy.
*/
- sprintf (line, "%s %s %d\n", pkgm.name,
- concat (pkgm.name, "-",
- pkgm.installed->Canonical_version (),
+ sprintf (line, "%s %s %d\n", pkgm.name.cstr_oneuse(),
+ concat (pkgm.name.cstr_oneuse(), "-",
+ pkgm.installed->Canonical_version ().cstr_oneuse(),
".tar.bz2", 0), 0);
ndb->write (line, strlen (line));
}
int
packagedb::installeddbread =
0;
-list < packagemeta, char const *,
- strcasecmp >
+list < packagemeta, String,
+ String::casecompare >
packagedb::packages;
-list < Category, char const *,
- strcasecmp >
+list < Category, String,
+ String::casecompare >
packagedb::categories;
PackageDBActions
packagedb::task =
/* required to parse this file */
#include "list.h"
-#include <string.h>
-//class CategoryList;
+#include <String++.h>
class Category;
class packagemeta;
class io_stream;
/* 0 on success */
int flush ();
/* all seen packages */
- static list < packagemeta, char const *, strcasecmp > packages;
+ static list < packagemeta, String, String::casecompare > packages;
/* all seen categories */
- static list < Category, char const *, strcasecmp > categories;
+ static list < Category, String, String::casecompare > categories;
static PackageDBActions task;
private:
static int installeddbread; /* do we have to reread this */
};
void
-hash::add_subdirs (char const *tpath)
+hash::add_subdirs (String const &tpath)
{
char *nonp, *pp;
- char *path = new char[strlen (tpath) + 1];
- strcpy (path, tpath);
+ char *path = tpath.cstr();
for (nonp = path; *nonp == '\\' || *nonp == '/'; nonp++);
for (pp = path + strlen (path) - 1; pp > nonp; pp--)
if (*pp == '/' || *pp == '\\')
* but for now: here is ok
*/
hash dirs;
- const char *line = installed->getfirstfile ();
+ String line = installed->getfirstfile ();
try_run_script ("/etc/preremove/", name);
- while (line)
+ while (line.size())
{
dirs.add_subdirs (line);
- char *d = cygpath ("/", line, NULL);
- DWORD dw = GetFileAttributes (d);
+ String d = cygpath ("/", line.cstr_oneuse(),0);
+ DWORD dw = GetFileAttributes (d.cstr_oneuse());
if (dw != INVALID_FILE_ATTRIBUTES
&& !(dw & FILE_ATTRIBUTE_DIRECTORY))
{
- log (LOG_BABBLE, "unlink %s", d);
- SetFileAttributes (d, dw & ~FILE_ATTRIBUTE_READONLY);
- DeleteFile (d);
+ log (LOG_BABBLE, String("unlink ")+ d);
+ SetFileAttributes (d.cstr_oneuse(), dw & ~FILE_ATTRIBUTE_READONLY);
+ DeleteFile (d.cstr_oneuse());
}
/* Check for Windows shortcut of same name. */
- d = concat (d, ".lnk", NULL);
- dw = GetFileAttributes (d);
+ d += ".lnk";
+ dw = GetFileAttributes (d.cstr_oneuse());
if (dw != INVALID_FILE_ATTRIBUTES
&& !(dw & FILE_ATTRIBUTE_DIRECTORY))
{
- log (LOG_BABBLE, "unlink %s", d);
- SetFileAttributes (d, dw & ~FILE_ATTRIBUTE_READONLY);
- DeleteFile (d);
+ log (LOG_BABBLE, String("unlink ") + d);
+ SetFileAttributes (d.cstr_oneuse(), dw & ~FILE_ATTRIBUTE_READONLY);
+ DeleteFile (d.cstr_oneuse());
}
line = installed->getnextfile ();
}
char *subdir = 0;
while ((subdir = dirs.enumerate (subdir)) != 0)
{
- char *d = cygpath ("/", subdir, NULL);
- if (RemoveDirectory (d))
- log (LOG_BABBLE, "rmdir %s", d);
+ String d = cygpath ("/", subdir,0);
+ if (RemoveDirectory (d.cstr_oneuse()))
+ log (LOG_BABBLE, String("rmdir ")+ d);
}
try_run_script ("/etc/postremove/", name);
}
catpack.pkg = this;
}
-char const *
+String const
packagemeta::SDesc () const
{
for (size_t n = 1; n <= versions.number (); ++n)
- if (versions[n]->SDesc ())
+ if (versions[n]->SDesc ().size())
return versions[n]->SDesc ();
return NULL;
};
/* Return an appropriate caption given the current action. */
-char const *
+String
packagemeta::action_caption ()
{
if (!desired && installed)
/* Required to parse this completely */
#include "list.h"
-#include "strings.h"
+#include "String++.h"
#include "category.h"
/*
class packagemeta
{
public:
- packagemeta (char const *pkgname):installed_from (0),
+ packagemeta (String const &pkgname):name (pkgname), key(pkgname), installed_from (0),
//versions (0),
// versioncount (0), versionspace (0),
installed (0), prev (0), prevtimestamp (0), curr (0), currtimestamp (0),
exp (0), exptimestamp (0), desired (0)
{
- name = new char[strlen (pkgname) + 1];
- strcpy (name, pkgname);
- key = name;
- };
+ }
- packagemeta (char const *pkgname,
- char const *installedfrom):installed_from (0),
+ packagemeta (String const &pkgname,
+ String const &installedfrom):name (pkgname), key(pkgname),
+ installed_from (installedfrom),
//versions (0), versioncount (0), versionspace (0),
installed (0), prev (0), prevtimestamp (0), curr (0), currtimestamp (0),
exp (0), exptimestamp (0), desired (0)
{
- name = new char[strlen (pkgname) + 1];
- key = name;
- strcpy (name, pkgname);
- installed_from = new char[strlen (installedfrom) + 1];
- strcpy (installed_from, installedfrom);
};
~packagemeta ()
{
- delete[] name;
- if (installed_from)
- delete[] installed_from;
};
void add_version (packageversion &);
void uninstall ();
int set_requirements (trusts deftrust = TRUST_CURR, size_t depth = 0);
- char const *action_caption ();
+ String action_caption ();
packageversion * trustp (trusts const t) const
{
return t == TRUST_PREV ? (prev ? prev : (curr ? curr : installed))
: exp;
}
- char *name; /* package name, like "cygwin" */
- char *key;
+ String name; /* package name, like "cygwin" */
+ String key;
/* legacy variable used to output data for installed.db versions <= 2 */
- char *installed_from;
+ String installed_from;
/* SDesc is global in theory, across all package versions.
LDesc is not: it can be different per version */
- char const *SDesc () const;
+ String const SDesc () const;
/* what categories does this package belong in. Note that if multiple versions
* of a package disagree.... the first one read in will take precedence.
*/
void add_category (Category &);
list < CategoryPackage, Category &, Categorycmp > Categories;
- list < packageversion, char const *, strcasecmp > versions;
+ list < packageversion, String, String::casecompare > versions;
/* which one is installed. */
packageversion *installed;
/* which one is listed as "prev" in our available packages db */
#include <strings.h>
#include "package_source.h"
-site::site (char const *newkey)
+site::site (String const &newkey) : key(newkey)
{
- key = new char[strlen (newkey) + 1];
- strcpy (key, newkey);
};
void
memcpy (filename, bstart + 1, end - bstart - 1);
filename[end - bstart - 1] = '\0';
- if (cached)
- delete[] cached;
- cached = 0;
+ cached = String();
}
void
-packagesource::set_cached (char const *fp)
+packagesource::set_cached (String const &fp)
{
- if (cached)
- delete[] cached;
- cached = new char[strlen (fp) + 1];
- strcpy (cached, fp);
+ cached = fp;
}
/* required to parse this file */
#include "list.h"
#include "strings.h"
+#include "String++.h"
/* standard binary package metadata:
* Name (ie mutt
class site
{
public:
- site (char const *newkey);
+ site (String const &newkey);
~site ()
{
- if (key)
- delete[] key;
};
- char *key;
+ String key;
};
class packagesource
{
public:
- packagesource ():size (0), canonical (0), base (0), filename (0), cached (0)
+ packagesource ():size (0), canonical (0), base (0), filename (0), cached ()
{
};
/* how big is the source file */
/* what is the cached filename, to prevent directory scanning during install */
virtual char const *Cached ()
{
- return cached;
+ return cached.cstr_oneuse();
};
/* sets the canonical path, and parses and creates base and filename */
virtual void set_canonical (char const *);
- virtual void set_cached (char const *);
- list < site, char const *, strcasecmp > sites;
+ virtual void set_cached (String const &);
+ list < site, String, String::casecompare > sites;
virtual ~ packagesource ()
{
delete []base;
if (filename)
delete []filename;
- if (cached)
- delete []cached;
};
private:
char *canonical;
char *base;
char *filename;
- char *cached;
+ String cached;
};
#endif /* _PACKAGE_SOURCE_H_ */
/* Required for parsing */
#include "package_source.h"
+#include "String++.h"
class Dependency
{
public:
+ Dependency (String const &aPackage) : package (aPackage) {}
+ Dependency (Dependency const &);
Dependency * next; /* the next package in this dependency list */
- char const *package; /* the name of the package that is depended on */
+ String const package; /* the name of the package that is depended on */
}
; /* Dependencies can be used for
recommended/required/related... */
{
public:
/* for list inserts/mgmt. */
- const char *key;
+ String key;
/* name is needed here, because if we are querying a file, the data may be embedded in
the file */
- virtual const char *Name () = 0;
- virtual const char *Vendor_version () = 0;
- virtual const char *Package_version () = 0;
- virtual const char *Canonical_version () = 0;
+ virtual String const Name () = 0;
+ virtual String const Vendor_version () = 0;
+ virtual String const Package_version () = 0;
+ virtual String const Canonical_version () = 0;
virtual package_status_t Status () = 0;
// virtual package_stability_t Stability () = 0;
virtual package_type_t Type () = 0;
/* TODO: we should probably return a metaclass - file name & path & size & type
- ie doc/script/binary
*/
- virtual const char *getfirstfile () = 0;
- virtual const char *getnextfile () = 0;
- virtual char const *SDesc () = 0;
- virtual void set_sdesc (char const *) = 0;
- virtual char const *LDesc () = 0;
- virtual void set_ldesc (char const *) = 0;
+ virtual String const getfirstfile () = 0;
+ virtual String const getnextfile () = 0;
+ virtual String const SDesc () = 0;
+ virtual void set_sdesc (String const &) = 0;
+ virtual String const LDesc () = 0;
+ virtual void set_ldesc (String const &) = 0;
/* FIXME: review this - these are UI variables, should be consistent across all
* children package types
*/
- void new_requirement (char const *dependson)
+ void new_requirement (String const &dependson)
{
- Dependency *dp;
- if (!dependson)
+ if (!dependson.size())
return;
- dp = new Dependency;
+ Dependency *dp = new Dependency (dependson);
dp->next = required;
- dp->package = dependson;
required = dp;
}
Dependency *required;
{
next_dialog = 0;
init_run_script ();
- SetCurrentDirectory (get_root_dir ());
+ SetCurrentDirectory (get_root_dir ().cstr_oneuse());
find (cygpath ("/etc/postinstall", 0), run_script_in_etc_postinstall);
}
ICON IDI_CYGWIN,IDC_STATIC,290,0,21,20
CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,0,28,
317,1
- LTEXT "Select a directory where you want Setup to store the installation files it dowmloads. The directory will be created if it does not already exist.",
+ LTEXT "Select a directory where you want Setup to store the installation files it downloads. The directory will be created if it does not already exist.",
IDC_STATIC,21,9,248,16,NOT WS_GROUP
LTEXT "Select Local Package Directory",IDC_STATIC_HEADER_TITLE,
7,0,258,8,NOT WS_GROUP
{
return rfc1738_do_escape (url, 1);
}
+String
+rfc1738_escape_part (String const &url)
+{
+ char const *t = rfc1738_do_escape (url.cstr_oneuse(), 1);
+ return String (t);
+}
/*
* rfc1738_unescape() - Converts escaped characters (%xy numbers) in
#ifndef _RFC1738_H_
#define _RFC1738_H_
+#include "String++.h"
char const *rfc1738_escape_part (char const *);
+String rfc1738_escape_part (String const &);
#endif
#include "state.h"
#include "msg.h"
#include "mount.h"
-#include "concat.h"
#include "log.h"
#include "root.h"
static void
check_if_enable_next (HWND h)
{
- EnableWindow (GetDlgItem (h, IDOK), root_text && get_root_dir ()
+ EnableWindow (GetDlgItem (h, IDOK), root_text && get_root_dir ().size()
&& root_scope);
}
{
root_text = rbget (h, rb);
root_scope = rbget (h, su);
- set_root_dir (eget (h, IDC_ROOT_DIR, (char *) get_root_dir ()));
+ set_root_dir (egetString (h, IDC_ROOT_DIR));
}
static int CALLBACK
switch (msg)
{
case BFFM_INITIALIZED:
- if (get_root_dir ())
- SendMessage (h, BFFM_SETSELECTION, TRUE, (LPARAM) get_root_dir ());
+ if (get_root_dir ().size())
+ SendMessage (h, BFFM_SETSELECTION, TRUE, (LPARAM) get_root_dir ().cstr_oneuse());
break;
}
return 0;
static int
directory_is_absolute ()
{
- const char *r = get_root_dir ();
+
+ const char *r = get_root_dir ().cstr();
if (isalpha (r[0]) && r[1] == ':' && (r[2] == '\\' || r[2] == '/'))
- return 1;
+ {
+ delete [] r;
+ return 1;
+ }
+ delete[]r;
return 0;
}
static int
directory_is_rootdir ()
{
+ char *t=get_root_dir ().cstr();
const char *c;
- for (c = get_root_dir (); *c; c++)
+ for (c = t; *c; c++)
if (isslash (c[0]) && c[1] && !isslash (c[1]))
- return 0;
+ {delete[]t;
+ return 0;}
+ delete[]t;
return 1;
}
static int
directory_has_spaces ()
{
- if (strchr (get_root_dir (), ' '))
+ if (get_root_dir ().find(' '))
return 1;
return 0;
}
void
RootPage::OnInit ()
{
- if (!get_root_dir ())
+ if (!get_root_dir ().size())
read_mounts ();
load_dialog (GetHWND ());
}
NEXT (IDD_LOCAL_DIR);
- log (0, "root: %s %s %s", get_root_dir (),
- (root_text == IDC_ROOT_TEXT) ? "text" : "binary",
- (root_scope == IDC_ROOT_USER) ? "user" : "system");
+ log (LOG_TIMESTAMP, String ("root: ") + get_root_dir () +
+ (root_text == IDC_ROOT_TEXT ? " text" : " binary") +
+ (root_scope == IDC_ROOT_USER ? " user" : " system"));
return 0;
}
#include <stdio.h>
#include "log.h"
#include "concat.h"
+#include "filemanip.h"
#include "mount.h"
#include "io_stream.h"
-static char *sh = 0;
+static String sh = String();
static const char *cmd = 0;
static OSVERSIONINFO verinfo;
{
for (int i = 0; shells[i]; i++)
{
- sh = backslash (cygpath (shells[i], 0));
- if (_access (sh, 0) == 0)
+ sh = backslash (cygpath (shells[i],0).cstr_oneuse());
+ if (_access (sh.cstr_oneuse(), 0) == 0)
break;
- delete[] sh;
- sh = 0;
+ sh = String();
}
char old_path[_MAX_PATH];
GetEnvironmentVariable ("PATH", old_path, sizeof (old_path));
SetEnvironmentVariable ("PATH",
backslash (cygpath ("/bin;",
- get_root_dir (), "/usr/bin;",
- old_path, 0)));
+ get_root_dir ().cstr_oneuse(), "/usr/bin;",
+ old_path, 0)).cstr_oneuse());
- SetEnvironmentVariable ("CYGWINROOT", get_root_dir ());
+ SetEnvironmentVariable ("CYGWINROOT", get_root_dir ().cstr_oneuse());
verinfo.dwOSVersionInfoSize = sizeof (verinfo);
GetVersionEx (&verinfo);
si.dwFlags = STARTF_USEPOSITION;
b = CreateProcess (0, cmdline, 0, 0, 0,
- CREATE_NEW_CONSOLE, 0, get_root_dir (), &si, &pi);
+ CREATE_NEW_CONSOLE, 0, get_root_dir ().cstr_oneuse(), &si, &pi);
if (b)
WaitForSingleObject (pi.hProcess, INFINITE);
}
void
-run_script (char const *dir, char const *fname)
+run_script (String const &dir, String const &fname)
{
- char *ext = strrchr (fname, '.');
+ char *ext = strrchr (fname.cstr_oneuse(), '.');
if (!ext)
return;
- if (sh && strcmp (ext, ".sh") == 0)
+ if (sh.size() && strcmp (ext, ".sh") == 0)
{
- char *f2 = concat (dir, fname, 0);
- log (0, "running: %s -c %s", sh, f2);
- run (sh, "-c", f2);
+ char *f2 = concat (dir.cstr_oneuse(), fname.cstr_oneuse(), 0);
+ log (LOG_TIMESTAMP, "running: %s -c %s", sh.cstr_oneuse(), f2);
+ run (sh.cstr_oneuse(), "-c", f2);
delete[] f2;
}
else if (cmd && strcmp (ext, ".bat") == 0)
{
- char *f2 = backslash (cygpath (dir, fname, 0));
- log (0, "running: %s /c %s", cmd, f2);
+ char *f2 = backslash (cygpath (dir.cstr_oneuse(), fname.cstr_oneuse(),0)).cstr();
+ log (LOG_TIMESTAMP, "running: %s /c %s", cmd, f2);
run (cmd, "/c", f2);
delete[] f2;
}
return;
/* if file exists then delete it otherwise just ignore no file error */
- io_stream::remove (concat ("cygfile://", dir, fname, ".done", 0));
+ io_stream::remove (String ("cygfile://") + dir+ fname+ ".done");
- io_stream::move (concat ("cygfile://", dir, fname, 0),
- concat ("cygfile://", dir, fname, ".done", 0));
+ io_stream::move (String ("cygfile://")+ dir+ fname,
+ String ("cygfile://")+ dir+ fname+ ".done");
}
void
-try_run_script (char const *dir, char const *fname)
+try_run_script (String const &dir, String const &fname)
{
- if (io_stream::exists (concat ("cygfile://", dir, fname, ".sh", 0)))
- run_script (dir, concat (fname, ".sh", 0));
- if (io_stream::exists (concat ("cygfile://", dir, fname, ".bat", 0)))
- run_script (dir, concat (fname, ".bat", 0));
+ if (io_stream::exists (String ("cygfile://")+ dir+ fname+ ".sh"))
+ run_script (dir.cstr_oneuse(), concat (fname.cstr_oneuse(), ".sh", 0));
+ if (io_stream::exists (String ("cygfile://")+ dir+ fname+ ".bat"))
+ run_script (dir.cstr_oneuse(), concat (fname.cstr_oneuse(), ".bat", 0));
}
#ifndef SCRIPT_H
#define SCRIPT_H
+#include "String++.h"
+
/* Run the script fname, found in dir. If fname has suffix .sh, and
we have a Bourne shell, execute it using sh. Otherwise, if fname
has suffix .bat, execute using cmd */
-void run_script (char const *dir, char const *fname);
+void run_script (String const &dir, String const &fname);
/* Initialisation stuff for run_script: sh, cmd, CYGWINROOT and PATH */
void init_run_script ();
/* Run the scripts fname.sh and fname.bat, found in dir. */
-void try_run_script (char const *dir, char const *fname);
+void try_run_script (String const &dir, String const &fname);
#endif /* SCRIPT_H */
#include "threebar.h"
extern ThreeBarProgressPage Progress;
-list < site_list_type, const char *, strcasecmp > site_list;
-list < site_list_type, const char *, strcasecmp > all_site_list;
-
-static char *other_url = 0;
+list < site_list_type, String, String::casecompare > site_list;
+list < site_list_type, String, String::casecompare > all_site_list;
void
-site_list_type::init (char const *newurl)
+site_list_type::init (String const &newurl)
{
- url = new char [strlen (newurl) +1];
- strcpy (url, newurl);
- displayed_url = new char [strlen (newurl) +1];
- strcpy (displayed_url, newurl);
- char *dot = strchr (displayed_url, '.');
- if (dot)
- {
- dot = strchr (dot, '/');
- if (dot)
- *dot = 0;
- }
- key = new char[2 * strlen (newurl) + 3];
+ url = newurl;
- dot = displayed_url;
- dot += strlen (dot);
- char *dp = key;
- while (dot != displayed_url)
+ char *dots = newurl.cstr();
+ char *dot = strchr (dots, '.');
+ if (dot)
+ {
+ dot = strchr (dot, '/');
+ if (dot)
+ *dot = 0;
+ }
+ displayed_url = String (dots);
+
+
+ dot = dots + strlen (dots);
+ char *dp = new char[2 * newurl.size() + 3];
+ while (dot != dots)
{
if (*dot == '.' || *dot == '/')
{
*dp++ = *sp++;
*dp++ = ' ';
}
- dot--;
+ --dot;
}
*dp++ = ' ';
- strcpy (dp, displayed_url);
+ strcpy (dp, dots);
+ delete[] dots;
+ key = String (dp);
+ delete[] dp;
}
-site_list_type::site_list_type (char const *newurl)
+site_list_type::site_list_type (String const &newurl)
{
init (newurl);
}
save_site_url ()
{
io_stream *f = io_stream::open ("cygfile:///etc/setup/last-mirror", "wb");
- for (size_t n = 1; n <= site_list.number (); n++)
+ if (f)
{
- if (f)
- {
- // FIXME: write all selected sites
- TCHAR *temp;
- temp = new TCHAR[sizeof (TCHAR) * (strlen (site_list[n]->url) + 2)];
- sprintf (temp, "%s\n", site_list[n]->url);
- f->write (temp, strlen (temp));
- delete[] temp;
- }
+ for (size_t n = 1; n <= site_list.number (); n++)
+ f->write ((site_list[n]->url + "\n").cstr_oneuse(), site_list[n]->url.size() + 1);
+ delete f;
}
- delete f;
}
static int
if (LoadString (h, IDS_MIRROR_LST, mirror_url, sizeof (mirror_url)) <= 0)
return 1;
- char *mirrors = get_url_to_string (mirror_url, owner);
- if (!mirrors)
+ char *bol, *eol, *nl, *theString;
+ {
+ String mirrors = get_url_to_string (mirror_url, owner);
+ if (!mirrors.size())
return 1;
- char *bol, *eol, *nl;
+ nl = theString = mirrors.cstr();}
- nl = mirrors;
while (*nl)
{
bol = nl;
delete newsite;
}
}
- delete[] mirrors;
+ delete[] theString;
return 0;
}
if (eos < site)
continue;
- bool found = false;
- for (size_t i = 1; !found && i <= all_site_list.number (); i++)
- if (!strcasecmp (site, all_site_list[i]->url))
- found = true;
-
- if (!found)
+ String tempKey = site_list_type (String(site)).key;
+ if (!all_site_list.getbykey (tempKey))
{
/* Don't default to certain machines ever since they suffer
from bandwidth limitations. */
/* TODO: make a site_type method to create a serach key on-the-fly from a
URL
*/
- found = false;
- for (size_t i = 1; !found && i <= all_site_list.number (); i++)
- if (!strcasecmp (site, all_site_list[i]->url))
- site_list.registerbyobject (*all_site_list[i]);
+ // Was it an allowed URL?
+ site_list_type *tempSite;
+ if ((tempSite = all_site_list.getbykey (tempKey)))
+ site_list.registerbyobject (*tempSite);
}
delete f;
hinst = (HINSTANCE) (context[0]);
h = (HWND) (context[1]);
- if (all_site_list.number () == 0)
- {
- if (get_site_list (hinst, h))
+ if (all_site_list.number () == 0
+ && get_site_list (hinst, h))
{
// Error: Couldn't download the site info. Go back to the Net setup page.
MessageBox (h, TEXT ("Can't get list of download sites.\n\
Progress.PostMessage (WM_APP_SITE_INFO_DOWNLOAD_COMPLETE, 0,
IDD_NET);
- _endthread ();
}
- }
-
+ else
// Everything worked, go to the site select page
-
// Tell the progress page that we're done downloading
Progress.PostMessage (WM_APP_SITE_INFO_DOWNLOAD_COMPLETE, 0, IDD_SITE);
// Log all the selected URLs from the list.
for (size_t n = 1; n <= site_list.number (); n++)
- log (0, "site: %s", site_list[n]->url);
+ log (LOG_TIMESTAMP, "site: %s", site_list[n]->url.cstr_oneuse());
Progress.SetActivateTask (WM_APP_START_SETUP_INI_DOWNLOAD);
return IDD_INSTATUS;
// Fill the list box with all known sites.
PopulateListBox ();
- // Load the user URL box with whatever it was last time.
- eset (GetHWND (), IDC_EDIT_USER_URL, other_url);
+ // Load the user URL box with nothing - it is in the list already.
+ eset (GetHWND (), IDC_EDIT_USER_URL, "");
// Get the enabled/disabled states of the controls set accordingly.
CheckControlsAndDisableAccordingly ();
for (size_t i = 1; i <= all_site_list.number (); i++)
{
j = SendMessage (listbox, LB_ADDSTRING, 0,
- (LPARAM) all_site_list[i]->displayed_url);
+ (LPARAM) all_site_list[i]->displayed_url.cstr_oneuse());
SendMessage (listbox, LB_SETITEMDATA, j, i);
}
for (size_t n = 1; n <= site_list.number (); n++)
{
int index = SendMessage (listbox, LB_FINDSTRING, (WPARAM) - 1,
- (LPARAM) site_list[n]->displayed_url);
+ (LPARAM) site_list[n]->displayed_url.cstr_oneuse());
if (index != LB_ERR)
{
// Highlight the selected item
{
case IDC_EDIT_USER_URL:
{
- if (code == EN_CHANGE)
- {
- // Text in edit box may have changed.
- other_url = eget (GetHWND (), IDC_EDIT_USER_URL, other_url);
- }
+ // FIXME: Make Enter here cause an ADD, not a NEXT.
break;
}
case IDC_URL_LIST:
if (code == LBN_SELCHANGE)
{
CheckControlsAndDisableAccordingly ();
+ save_dialog (GetHWND ());
}
break;
}
if (code == BN_CLICKED)
{
// User pushed the Add button.
- other_url = eget (GetHWND (), IDC_EDIT_USER_URL, other_url);
+ String other_url = egetString (GetHWND (), IDC_EDIT_USER_URL);
+ if (other_url.size())
+ {
site_list_type *
newsite =
new
else
{
// Log the adding of this new URL.
- log (0, "Adding site: %s", other_url);
+ log (LOG_BABBLE, "Adding site: %s", other_url.cstr_oneuse());
}
// Assume the user wants to use it and select it for him.
// Update the list box.
PopulateListBox ();
+ eset (GetHWND (), IDC_EDIT_USER_URL, "");
+ }
}
break;
}
#include <string.h>
#include <stdlib.h>
#include "list.h"
+#include "String++.h"
#include "proppage.h"
class site_list_type
{
public:
- site_list_type ():url (0), displayed_url (0), key (0)
+ site_list_type ():url (), displayed_url (0), key (0)
{
};
- site_list_type (char const *);
+ site_list_type (String const &);
/* workaround for missing placement new in gcc 2.95 */
- void init (char const *);
- ~site_list_type ()
- {
- if (url)
- delete[] url;
- if (displayed_url)
- delete[] displayed_url;
- if (key)
- delete[] key;
- };
- char *url;
- char *displayed_url;
- char *key;
+ void init (String const &);
+ ~site_list_type () {};
+ String url;
+ String displayed_url;
+ String key;
};
/* user chosen sites */
-extern list < site_list_type, const char *, strcasecmp > site_list;
+extern list < site_list_type, String, String::casecompare > site_list;
/* potential sites */
-extern list < site_list_type, const char *, strcasecmp > all_site_list;
+extern list < site_list_type, String, String::casecompare > all_site_list;
void save_site_url ();
void
SourcePage::OnDeactivate ()
{
- log (0, "source: %s",
+ log (LOG_TIMESTAMP, "source: %s",
(source == IDC_SOURCE_DOWNLOAD) ? "download" :
(source == IDC_SOURCE_NETINST) ? "network install" : "from cwd");
}
*/
+#include "String++.h"
+
extern int source;
-extern char *local_dir;
+extern String local_dir;
extern int root_text;
extern int root_scope;
extern char *net_ftp_user;
extern char *net_ftp_passwd;
-extern int trust_level;
#include <ctype.h>
#include "port.h"
-char *
-canonicalize_version (const char *v)
+#include "version.h"
+
+String
+canonicalize_version (String const &aString)
{
+ char *v =aString.cstr();
static char nv[3][100];
static int idx = 0;
char *np;
*np++ = *v++;
}
*np++ = 0;
+ delete[] v;
return nv[idx];
}
/* misc version-related things */
+#include "String++.h"
+
extern char *version;
-extern char *canonicalize_version (const char *);
+extern String canonicalize_version (String const &);