ARB
Classes | Macros | Functions | Variables
adsocket.cxx File Reference
#include <unistd.h>
#include <climits>
#include <cstdarg>
#include <cctype>
#include <netdb.h>
#include <netinet/tcp.h>
#include <signal.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/un.h>
#include <arb_cs.h>
#include <arb_str.h>
#include <arb_strbuf.h>
#include <arb_file.h>
#include <arb_sleep.h>
#include <arb_pathlen.h>
#include "gb_comm.h"
#include "gb_data.h"
#include "gb_localdata.h"
#include <SigHandler.h>
#include <algorithm>
#include <arb_misc.h>
#include <arb_defs.h>
Include dependency graph for adsocket.cxx:

Go to the source code of this file.

Classes

struct  export_environment
 

Macros

#define GB_PATH_TMP   GB_path_in_arb_temp("tmp")
 

Functions

void gbcm_read_flush ()
 
static long gbcm_read_buffered (int socket, char *ptr, long size)
 
long gbcm_read (int socket, char *ptr, long size)
 
GBCM_ServerResult gbcm_write_flush (int socket)
 
GBCM_ServerResult gbcm_write (int socket, const char *ptr, long size)
 
GB_ERROR gbcm_open_socket (const char *path, bool do_connect, int *psocket, char **unix_name)
 
gbcmc_commgbcmc_open (const char *path)
 
long gbcm_write_two (int socket, long a, long c)
 
GBCM_ServerResult gbcm_read_two (int socket, long a, long *b, long *c)
 
GBCM_ServerResult gbcm_write_string (int socket, const char *key)
 
chargbcm_read_string (int socket)
 
GBCM_ServerResult gbcm_write_long (int socket, long data)
 
long gbcm_read_long (int socket)
 
charGB_read_fp (FILE *in)
 
charGB_read_file (const char *path)
 
charGB_map_FILE (FILE *in, int writeable)
 
charGB_map_file (const char *path, int writeable)
 
GB_ULONG GB_time_of_day ()
 
GB_ERROR GB_textprint (const char *path)
 
static GB_CSTR GB_getenvPATH ()
 
static charGB_find_executable (GB_CSTR description_of_executable,...)
 
static chargetenv_executable (GB_CSTR envvar)
 
static chargetenv_existing_directory (GB_CSTR envvar)
 
static void GB_setenv (const char *var, const char *value)
 
GB_CSTR GB_getenvARB_XTERM ()
 
static GB_CSTR GB_getenvARB_XCMD ()
 
GB_CSTR GB_getenvUSER ()
 
static GB_CSTR GB_getenvHOME ()
 
GB_CSTR GB_getenvARBHOME ()
 
GB_CSTR GB_getenvARBMACRO ()
 
static chargetenv_autodirectory (const char *envvar, const char *defaultDirectory)
 
static GB_CSTR GB_getenvARB_PROP ()
 
GB_CSTR GB_getenvARBMACROHOME ()
 
static GB_CSTR GB_getenvARBCONFIG ()
 
GB_CSTR GB_getenvARB_GS ()
 
GB_CSTR GB_getenvARB_PDFVIEW ()
 
GB_CSTR GB_getenvDOCPATH ()
 
GB_CSTR GB_getenvHTMLDOCPATH ()
 
NOT4PERL gb_getenv_hook GB_install_getenv_hook (gb_getenv_hook hook)
 
GB_CSTR GB_getenv (const char *env)
 
bool GB_host_is_local (const char *hostname)
 
static GB_ULONG get_physical_memory ()
 
static GB_ULONG parse_env_mem_definition (const char *env_override, GB_ERROR &error)
 
GB_ULONG GB_get_usable_memory ()
 
NOT4PERL GB_ERROR GB_xcmd (const char *cmd, XCMD_TYPE exectype)
 
static charuse_other_path_buf ()
 
GB_CSTR GB_append_suffix (const char *name, const char *suffix)
 
GB_CSTR GB_canonical_path (const char *anypath)
 
GB_CSTR GB_concat_path (GB_CSTR anypath_left, GB_CSTR anypath_right)
 
GB_CSTR GB_concat_full_path (const char *anypath_left, const char *anypath_right)
 
bool is_absolute_path (const char *path)
 
bool is_name_of_envvar (const char *name)
 
GB_CSTR GB_unfold_in_directory (const char *relative_directory, const char *path)
 
GB_CSTR GB_unfold_path (const char *pwd_envar, const char *path)
 
static GB_CSTR GB_path_in_ARBHOME (const char *relative_path_left, const char *anypath_right)
 
GB_CSTR GB_path_in_ARBHOME (const char *relative_path)
 
GB_CSTR GB_path_in_ARBLIB (const char *relative_path)
 
GB_CSTR GB_path_in_HOME (const char *relative_path)
 
GB_CSTR GB_path_in_arbprop (const char *relative_path)
 
GB_CSTR GB_path_in_ARBLIB (const char *relative_path_left, const char *anypath_right)
 
static GB_CSTR GB_path_in_arb_temp (const char *relative_path)
 
FILE * GB_fopen_tempfile (const char *filename, const char *fmode, char **res_fullname)
 
charGB_create_tempfile (const char *name)
 
charGB_unique_filename (const char *name_prefix, const char *suffix)
 
static void exit_remove_file (const char *file, long, void *)
 
static void exit_removal ()
 
void GB_remove_on_exit (const char *filename)
 
void GB_split_full_path (const char *fullpath, char **res_dir, char **res_fullname, char **res_name_only, char **res_suffix)
 

Variables

static gb_getenv_hook getenv_hook = NULp
 
static export_environment expenv
 
static int path_toggle = 0
 
static char path_buf [2][ARB_PATH_MAX]
 
static GB_HASHfiles_to_remove_on_exit = NULp
 

Macro Definition Documentation

#define GB_PATH_TMP   GB_path_in_arb_temp("tmp")

Definition at line 1140 of file adsocket.cxx.

Referenced by GB_fopen_tempfile().

Function Documentation

void gbcm_read_flush ( void  )
static long gbcm_read_buffered ( int  socket,
char ptr,
long  size 
)
static
long gbcm_read ( int  socket,
char ptr,
long  size 
)
GBCM_ServerResult gbcm_write_flush ( int  socket)
GBCM_ServerResult gbcm_write ( int  socket,
const char ptr,
long  size 
)
GB_ERROR gbcm_open_socket ( const char path,
bool  do_connect,
int psocket,
char **  unix_name 
)

Definition at line 144 of file adsocket.cxx.

References arb_open_socket(), GB_await_error(), and GBS_read_arb_tcp().

Referenced by gbcmc_open(), and GBCMS_open().

gbcmc_comm* gbcmc_open ( const char path)
long gbcm_write_two ( int  socket,
long  a,
long  c 
)
GBCM_ServerResult gbcm_read_two ( int  socket,
long  a,
long b,
long c 
)

read two values: length and any user long

if data is send by gbcm_write_two() then

Parameters
bshould be zero and is not used!

Definition at line 196 of file adsocket.cxx.

References GB_internal_error(), GB_internal_errorf(), gbcm_read(), GBCM_SERVER_FAULT, and GBCM_SERVER_OK.

Referenced by gbcm_unfold_client(), gbcmc_abort_transaction(), gbcmc_begin_transaction(), gbcmc_commit_transaction(), GBCMC_find(), gbcmc_init_transaction(), gbcmc_key_alloc(), gbcms_talking_undo(), and gbcms_talking_unfold().

GBCM_ServerResult gbcm_write_string ( int  socket,
const char key 
)
char* gbcm_read_string ( int  socket)
GBCM_ServerResult gbcm_write_long ( int  socket,
long  data 
)

Definition at line 260 of file adsocket.cxx.

References GBCM_SERVER_OK, and gbcm_write().

Referenced by gbcm_write_string(), and GBCMC_find().

long gbcm_read_long ( int  socket)

Definition at line 265 of file adsocket.cxx.

References gbcm_read().

Referenced by gbcm_read_string(), and gbcms_talking_find().

char* GB_read_fp ( FILE *  in)

like GB_read_file(), but works on already open file (useful together with GB_fopen_tempfile())

Note: File should be opened in text-mode (e.g. "rt")

Definition at line 271 of file adsocket.cxx.

References GBS_chrcat(), GBS_strclose(), and GBS_stropen().

Referenced by GB_read_file(), gbcms_sighup(), and read_export_format().

char* GB_read_file ( const char path)

read content of file 'path' into string (heap-copy)

if path is '-', read from STDIN

Returns
NULp in case of error (use GB_await_error() to get the message)

Definition at line 287 of file adsocket.cxx.

References GB_export_error(), GB_IO_error(), GB_read_fp(), GB_size_of_file(), GBS_eval_env(), NULp, and result.

Referenced by ARB_main(), aw_help_helpfile_changed_cb(), aw_help_search(), aw_ref_to_title(), AWT_show_file(), ed_submit_parse_event(), GB_get_arb_revision_tag(), AWT_configuration::Load(), main(), and RecordingMacro::RecordingMacro().

char* GB_map_FILE ( FILE *  in,
int  writeable 
)

Definition at line 323 of file adsocket.cxx.

References buffer, GB_export_error(), GB_export_errorf(), GB_size_of_FILE(), and NULp.

Referenced by GB_map_file(), and gb_recover_corrupt_file().

char* GB_map_file ( const char path,
int  writeable 
)

Definition at line 344 of file adsocket.cxx.

References buffer, GB_export_errorf(), GB_map_FILE(), and NULp.

Referenced by gb_map_mapfile(), and PTD_read_leafs_from_disk().

GB_ULONG GB_time_of_day ( void  )
GB_ERROR GB_textprint ( const char path)
static GB_CSTR GB_getenvPATH ( )
static
static char* GB_find_executable ( GB_CSTR  description_of_executable,
  ... 
)
static
static char* getenv_executable ( GB_CSTR  envvar)
static
static char* getenv_existing_directory ( GB_CSTR  envvar)
static
static void GB_setenv ( const char var,
const char value 
)
static

Definition at line 502 of file adsocket.cxx.

References GB_warningf().

Referenced by export_environment::export_environment().

GB_CSTR GB_getenvARB_XTERM ( void  )

Definition at line 509 of file adsocket.cxx.

References ARB_getenv_ignore_empty(), and NULp.

Referenced by AWT_console(), GB_getenv(), and GB_getenvARB_XCMD().

static GB_CSTR GB_getenvARB_XCMD ( )
static
GB_CSTR GB_getenvUSER ( void  )
static GB_CSTR GB_getenvHOME ( )
static

Definition at line 549 of file adsocket.cxx.

References ARB_strdup(), gb_assert, GB_getcwd(), and getenv_existing_directory().

Referenced by GB_canonical_path(), and GB_getenv().

GB_CSTR GB_getenvARBHOME ( void  )

Definition at line 565 of file adsocket.cxx.

References EXIT_FAILURE, and getenv_existing_directory().

Referenced by GB_getenv(), GBS_funptr2readable(), readXmlTree(), and unitTesterDir().

GB_CSTR GB_getenvARBMACRO ( void  )
static char* getenv_autodirectory ( const char envvar,
const char defaultDirectory 
)
static
static GB_CSTR GB_getenvARB_PROP ( )
static

Definition at line 608 of file adsocket.cxx.

References GB_path_in_HOME(), and getenv_autodirectory().

Referenced by GB_getenv().

GB_CSTR GB_getenvARBMACROHOME ( void  )
static GB_CSTR GB_getenvARBCONFIG ( )
static

Definition at line 620 of file adsocket.cxx.

References GB_path_in_arbprop(), and getenv_autodirectory().

Referenced by GB_getenv().

GB_CSTR GB_getenvARB_GS ( void  )
GB_CSTR GB_getenvARB_PDFVIEW ( void  )

Definition at line 635 of file adsocket.cxx.

References GB_find_executable(), getenv_executable(), and NULp.

Referenced by aw_help_helpfile_changed_cb(), and GB_getenv().

GB_CSTR GB_getenvDOCPATH ( void  )
GB_CSTR GB_getenvHTMLDOCPATH ( void  )

Definition at line 654 of file adsocket.cxx.

References ARB_strdup(), GB_path_in_ARBLIB(), getenv_existing_directory(), and NULp.

Referenced by get_local_help_url().

NOT4PERL gb_getenv_hook GB_install_getenv_hook ( gb_getenv_hook  hook)

Definition at line 667 of file adsocket.cxx.

References getenv_hook.

Referenced by AW_unfold_path(), and ignore_arb_prop().

GB_CSTR GB_getenv ( const char env)
bool GB_host_is_local ( const char hostname)

Definition at line 714 of file adsocket.cxx.

References arb_assert, arb_gethostname(), ARB_strBeginsWith(), and ARB_stricmp().

Referenced by createCallOnSocketHost().

static GB_ULONG get_physical_memory ( )
static
static GB_ULONG parse_env_mem_definition ( const char env_override,
GB_ERROR error 
)
static

Definition at line 798 of file adsocket.cxx.

References FALLTHROUGH, get_physical_memory(), NULp, and valid().

Referenced by GB_get_usable_memory().

GB_ULONG GB_get_usable_memory ( void  )
NOT4PERL GB_ERROR GB_xcmd ( const char cmd,
XCMD_TYPE  exectype 
)
static char* use_other_path_buf ( )
static

Definition at line 947 of file adsocket.cxx.

References path_toggle.

Referenced by GB_append_suffix(), GB_canonical_path(), and GB_concat_path().

GB_CSTR GB_append_suffix ( const char name,
const char suffix 
)
GB_CSTR GB_canonical_path ( const char anypath)
GB_CSTR GB_concat_path ( GB_CSTR  anypath_left,
GB_CSTR  anypath_right 
)
GB_CSTR GB_concat_full_path ( const char anypath_left,
const char anypath_right 
)
bool is_absolute_path ( const char path)
inline

Definition at line 1082 of file adsocket.cxx.

Referenced by GB_unfold_in_directory(), and GB_unfold_path().

bool is_name_of_envvar ( const char name)
inline

Definition at line 1083 of file adsocket.cxx.

Referenced by GB_unfold_path().

GB_CSTR GB_unfold_in_directory ( const char relative_directory,
const char path 
)

Definition at line 1091 of file adsocket.cxx.

References GB_canonical_path(), GB_concat_full_path(), and is_absolute_path().

GB_CSTR GB_unfold_path ( const char pwd_envar,
const char path 
)
static GB_CSTR GB_path_in_ARBHOME ( const char relative_path_left,
const char anypath_right 
)
static

Definition at line 1117 of file adsocket.cxx.

References GB_concat_path().

Referenced by GB_path_in_ARBLIB().

GB_CSTR GB_path_in_ARBHOME ( const char relative_path)
GB_CSTR GB_path_in_ARBLIB ( const char relative_path)
GB_CSTR GB_path_in_HOME ( const char relative_path)

Definition at line 1127 of file adsocket.cxx.

References GB_unfold_path().

Referenced by GB_getenvARB_PROP(), and GB_path_in_arb_temp().

GB_CSTR GB_path_in_arbprop ( const char relative_path)
GB_CSTR GB_path_in_ARBLIB ( const char relative_path_left,
const char anypath_right 
)

Definition at line 1133 of file adsocket.cxx.

References GB_concat_path(), and GB_path_in_ARBLIB().

static GB_CSTR GB_path_in_arb_temp ( const char relative_path)
static

Definition at line 1136 of file adsocket.cxx.

References GB_concat_path(), and GB_path_in_HOME().

FILE* GB_fopen_tempfile ( const char filename,
const char fmode,
char **  res_fullname 
)
char* GB_create_tempfile ( const char name)
char* GB_unique_filename ( const char name_prefix,
const char suffix 
)
static void exit_remove_file ( const char file,
long  ,
void *   
)
static

Definition at line 1212 of file adsocket.cxx.

References GB_IO_error().

Referenced by exit_removal().

static void exit_removal ( )
static

Definition at line 1217 of file adsocket.cxx.

References exit_remove_file(), GBS_free_hash(), GBS_hash_do_const_loop(), and NULp.

Referenced by GB_remove_on_exit().

void GB_remove_on_exit ( const char filename)
void GB_split_full_path ( const char fullpath,
char **  res_dir,
char **  res_fullname,
char **  res_name_only,
char **  res_suffix 
)

Variable Documentation

gb_getenv_hook getenv_hook = NULp
static

Definition at line 665 of file adsocket.cxx.

Referenced by GB_getenv(), and GB_install_getenv_hook().

export_environment expenv
static

Definition at line 712 of file adsocket.cxx.

int path_toggle = 0
static

Definition at line 944 of file adsocket.cxx.

Referenced by GB_canonical_path(), and use_other_path_buf().

char path_buf[2][ARB_PATH_MAX]
static

Definition at line 945 of file adsocket.cxx.

GB_HASH* files_to_remove_on_exit = NULp
static

Definition at line 1211 of file adsocket.cxx.