portable Namespace Reference


Enumerations

enum  process_launch_flags {
  HIDE_APP_WINDOW = 0x1, AWAIT_APP_EXIT = 0x2, RETURN_IMMEDIATELY = 0x4, AWAIT_VIA_POLLING = 0x8,
  SHELL_EXECUTE = 0x10
}

Functions

double rolling_uptime ()
 like system_uptime(), but tracks rollovers to provide continuity.
u_int system_uptime ()
 the length of time (in milliseconds) since this computer booted.
void sleep_ms (u_int msec)
 a system independent name for a forced snooze measured in milliseconds.
istring null_device ()
 returns the name of the system's NULL device.
bool event_poll (MSG &message)
istring get_cmdline_from_proc ()
 returns the command line that /proc has recorded for our process.
istring query_for_process_info ()
istring application_name ()
 returns the full name of the current application.
istring module_name (const void *module_handle=NIL)
 returns the name of the module for the "module_handle" where supported.
u_int system_error ()
 gets the most recent system error reported on this thread.
istring system_error_text (u_int error_to_show)
 returns the OS's string form of the "error_to_show".
bool is_address_valid (const void *address, int size_expected, bool writable)
version get_OS_version ()
 returns the operating system's version information.
u_int process_id ()
 returns the process id for this task, if that's relevant on the OS.
istring current_directory ()
 returns the current directory as reported by the operating system.
istring env_string (const istring &variable_name)
 looks up the "variable_name" in the current environment variables.
bool set_environ (const istring &variable_name, const istring &value)
 adds or creates "variable_name" in the environment.
timeval fill_timeval_ms (int milliseconds)
 returns a timeval system object that represents the "milliseconds".
char_star_array break_line (istring &app, const istring &parameters)
 prepares an "app" to launch with the "parameters" (via exec).
void exiting_child_signal_handler (int sig_num)
u_int launch_process (const istring &app_name, const istring &command_line, int flag, u_int &child_id)
 starts an application using the "app_name" as the executable to run.
char * itoa (int to_convert, char *buffer, int radix)
 turns the integer "to_convert" into a string stored in the "buffer".
void show_wait_cursor ()
void show_normal_cursor ()
istring rc_string (UINT id, application_instance instance)
istring rc_string (u_int id)
bool has_win95_style_shell ()
known_operating_systems determine_OS ()

Variables

application_instance _i_handle
 dll_root.cpp defines this for all dlls.


Enumeration Type Documentation

enum portable::process_launch_flags

Enumerator:
HIDE_APP_WINDOW  launches the application invisibly if possible.
AWAIT_APP_EXIT  stays in the function until the launched application has exited.
RETURN_IMMEDIATELY  starts the application and comes right back to the caller.
AWAIT_VIA_POLLING  launches the app but polls and doesn't block on its exit.
SHELL_EXECUTE  only valid on windows--uses ShellExecute instead of CreateProcess.

Definition at line 208 of file portable.h.


Function Documentation

istring portable::application_name (  ) 

returns the full name of the current application.

Definition at line 417 of file portable.cpp.

References FUNCDEF, get_cmdline_from_proc(), NIL, and istring::to_lower().

Referenced by path_configuration::application_name(), locked_logger::locked_logger(), query_handler::login_to_database(), main(), module_name(), shared_memory::unique_shared_mem_identifier(), and critical_events::write_to_critical_events().

char_star_array portable::break_line ( istring app,
const istring parameters 
)

prepares an "app" to launch with the "parameters" (via exec).

this breaks the strings for an application named "app" and its "parameters" into an array of char * that is appropriate for the execv function.

Definition at line 600 of file portable.cpp.

References istring::end(), array< contents >::last(), istring::length(), NIL, istring::stuff(), istring::substring(), and istring::zap().

Referenced by launch_process(), and string_manipulation::split_lines().

istring portable::current_directory (  ) 

returns the current directory as reported by the operating system.

Definition at line 529 of file portable.cpp.

References getcwd.

Referenced by main(), and version_ini::one_stop_version_stamp().

known_operating_systems portable::determine_OS (  ) 

Definition at line 897 of file portable.cpp.

References get_OS_version(), version::v_major(), version::v_minor(), and version::v_revision().

Referenced by debugging_base::buffer_limit(), and debugging_base::get_contents().

istring portable::env_string ( const istring variable_name  ) 

looks up the "variable_name" in the current environment variables.

this returns the value for "variable_name" as it was found in the operating system's environment variables that are defined at this point in time for the user and process. the returned string will be empty if no variable under that name could be found.

Definition at line 547 of file portable.cpp.

References istring::observe(), and istring::upper().

Referenced by write_build_config::execute(), version_checker::good_version(), main(), hoople_api::low_level_methods::make_allusers_path(), ini_configurator::name(), and parser_bits::substitute_env_vars().

bool portable::event_poll ( MSG &  message  ) 

Definition at line 300 of file portable.cpp.

References NIL.

Referenced by launch_process().

void portable::exiting_child_signal_handler ( int  sig_num  ) 

Definition at line 646 of file portable.cpp.

References __our_kids(), __process_synchronizer(), FUNCDEF, array< contents >::length(), and array< contents >::zap().

Referenced by launch_process().

timeval portable::fill_timeval_ms ( int  milliseconds  ) 

returns a timeval system object that represents the "milliseconds".

if "milliseconds" is zero, then the returned timeval will represent zero time passing (rather than infinite duration as some functions assume).

Definition at line 573 of file portable.cpp.

Referenced by raw_socket::select().

istring portable::get_cmdline_from_proc (  ) 

returns the command line that /proc has recorded for our process.

Definition at line 327 of file portable.cpp.

References FUNCDEF, getline(), istring::length(), negative(), process_id(), istring::s(), and istring::zap().

Referenced by application_name(), and command_line::get_command_line().

version portable::get_OS_version (  ) 

returns the operating system's version information.

for linux, this has: major/minor/release/revision as components. for ms-windows, this has: major/minor/platform_ID/build_number.

Definition at line 499 of file portable.cpp.

Referenced by determine_OS(), process_control::find_process_in_list(), and process_control::process_control().

bool portable::has_win95_style_shell (  ) 

Definition at line 882 of file portable.cpp.

References low_byte, and low_short.

bool portable::is_address_valid ( const void *  address,
int  size_expected,
bool  writable 
)

Definition at line 491 of file portable.cpp.

char * portable::itoa ( int  to_convert,
char *  buffer,
int  radix 
)

turns the integer "to_convert" into a string stored in the "buffer".

this is needed on linux since there doesn't seem to be a builtin version of it. the buffer must be long enough to hold the number's textual representation! the buffer's length must also account for the chosen "radix" (the base for the number system, where 10 is decimal, 16 is hexadecimal, etc).

Definition at line 853 of file portable.cpp.

References printed.

u_int portable::launch_process ( const istring app_name,
const istring command_line,
int  flag,
u_int child_id 
)

starts an application using the "app_name" as the executable to run.

the "command_line" is the set of parameters to be passed to the app. the return value is OS specific but can be identified using system_error_text(). usually a zero return means success and non-zero codes are errors. the "flag" is an XORed value from the process launch flags that dictates how the app is to be started. in practice, only the HIDE_APP_WINDOW flag can be combined with other values. if either AWAIT flag is used, then the return value will be the launched process's own exit value. the thread or process_id of the launched process is stored in "child_id" if appropriate.

Definition at line 673 of file portable.cpp.

References __our_kids(), __process_synchronizer(), AWAIT_APP_EXIT, AWAIT_VIA_POLLING, break_line(), istring::end(), event_poll(), execv, exiting_child_signal_handler(), HIDE_APP_WINDOW, istring::insert(), NIL, array< contents >::observe(), process_id(), RETURN_IMMEDIATELY, istring::s(), SHELL_EXECUTE, sleep_ms(), system_error(), and system_error_text().

Referenced by process_manager::launch_now(), and whacking_spider().

istring portable::module_name ( const void *  module_handle = NIL  ) 

returns the name of the module for the "module_handle" where supported.

if the handle is NIL, then the program name is returned.

Definition at line 438 of file portable.cpp.

References application_name(), and istring::to_lower().

Referenced by version_checker::complain_wrong_version(), version_checker::get_name(), and service_root::install().

istring portable::null_device (  ) 

returns the name of the system's NULL device.

this device is a black hole where output can be sent, never to be seen again. this is /dev/null on unix and null: on win32.

Definition at line 290 of file portable.cpp.

u_int portable::process_id (  ) 

returns the process id for this task, if that's relevant on the OS.

Definition at line 523 of file portable.cpp.

References getpid.

Referenced by get_cmdline_from_proc(), octopus::issue_identity(), launch_process(), locked_logger::locked_logger(), query_for_process_info(), octopus_request_id::randomized_id(), shared_memory::unique_shared_mem_identifier(), and stdio_redirecter::zap_program().

istring portable::query_for_process_info (  ) 

Definition at line 355 of file portable.cpp.

References FUNCDEF, chaos::inclusive(), MAXIMUM_COMMAND_LINE, negative(), process_id(), rando, istring::reset(), unlink, and istring::UNTERMINATED.

istring portable::rc_string ( u_int  id  ) 

Definition at line 880 of file portable.cpp.

References GET_INSTANCE_HANDLE, and rc_string().

Referenced by run_test_18().

istring portable::rc_string ( UINT  id,
application_instance  instance 
)

Definition at line 872 of file portable.cpp.

Referenced by debugger::log(), rc_string(), and WinMain().

double portable::rolling_uptime (  ) 

like system_uptime(), but tracks rollovers to provide continuity.

Definition at line 131 of file portable.cpp.

References __uptime_synchronizer(), absolute_value(), system_uptime(), and UPTIME_REPORT_FILE.

bool portable::set_environ ( const istring variable_name,
const istring value 
)

adds or creates "variable_name" in the environment.

changes the current set of environment variables by adding or modifying the "variable_name". its new value will be "value".

Definition at line 562 of file portable.cpp.

References putenv, and istring::s().

Referenced by main().

void portable::show_normal_cursor (  ) 

Definition at line 870 of file portable.cpp.

References NULL.

void portable::show_wait_cursor (  ) 

Definition at line 868 of file portable.cpp.

References NULL.

void portable::sleep_ms ( u_int  msec  ) 

a system independent name for a forced snooze measured in milliseconds.

the application will do nothing on the current thread for the amount of time specified. on some systems, if "msec" is zero, then the sleep will yield the current thread's remaining timeslice back to other threads.

Definition at line 280 of file portable.cpp.

Referenced by spocket_tester::accept(), spocket_tester::connect(), spocket::connect(), broadcast_spocket_tester::do_a_receive(), broadcast_spocket_tester::do_a_send(), cromp_client::keep_alive_pause(), shutdown_alerter::launch_console(), process_manager::launch_now(), launch_process(), cromp_server::look_for_clients(), main(), service_root::remove(), octopus::remove_tentacle(), smtp_client::send_email(), ithread::start(), ithread::stop(), thread_cabinet::stop_all(), semaphore::wait(), and timer_driver::~timer_driver().

u_int portable::system_error (  ) 

gets the most recent system error reported on this thread.

Definition at line 456 of file portable.cpp.

Referenced by spocket::accept(), spocket::connect(), basic_window::create(), tcpip_stack::full_resolve(), tcpip_stack::hostname(), launch_process(), socket_minder::push_receives(), socket_minder::push_sends(), spocket::receive(), spocket::receive_from(), rendezvous::rendezvous(), raw_socket::select(), spocket::send(), spocket::send_to(), shared_memory::shared_memory(), service_control::show_system_error(), ithread::start(), and process_control::zap_process().

istring portable::system_error_text ( u_int  error_to_show  ) 

returns the OS's string form of the "error_to_show".

this often comes from the value reported by system_error().

Definition at line 468 of file portable.cpp.

References istring::end(), NIL, and istring::zap().

Referenced by spocket::accept(), spocket::connect(), basic_window::create(), spocket_tester::do_a_receive(), broadcast_spocket_tester::do_a_receive(), service_root::install(), process_manager::launch_now(), launch_process(), spocket::receive(), spocket::receive_from(), service_root::remove(), rendezvous::rendezvous(), run_as_service(), spocket::send(), shared_memory::shared_memory(), service_control::show_system_error(), ithread::start(), tcpip_stack::tcpip_error_name(), and process_control::zap_process().

u_int portable::system_uptime (  ) 

the length of time (in milliseconds) since this computer booted.

Definition at line 170 of file portable.cpp.

References __uptime_synchronizer(), absolute_value(), DAY_ms, HOUR_ms, MINUTE_ms, and UPTIME_REPORT_FILE.

Referenced by chaos::retrain(), and rolling_uptime().


Variable Documentation

application_instance portable::_i_handle

dll_root.cpp defines this for all dlls.


Generated on Fri Nov 28 04:31:08 2008 for HOOPLE Libraries by  doxygen 1.5.1