Code cleanup and a few source code comments

darcs-hash:20051003132446-ac50b-53f8231b18fced8371781ad41c9485983e1c5cdc.gz
This commit is contained in:
axel 2005-10-03 23:24:46 +10:00
parent 101205900b
commit 96f0cd9946
4 changed files with 55 additions and 20 deletions

24
env.c
View file

@ -52,7 +52,6 @@
*/
extern char **environ;
static int c1=0;
/**
Struct representing one level in the function variable stack
@ -264,16 +263,15 @@ void env_init()
free(key);
}
env_universal_init( env_get( L"FISHD_SOKET_DIR"), env_get(L"USER"), &start_fishd );
env_universal_init( env_get( L"FISHD_SOKET_DIR"),
env_get( L"USER" ),
&start_fishd );
}
void env_destroy()
{
char **ptr;
env_universal_destroy();
// fwprintf( stderr, L"Filled %d exported vars\n", c1 );
sb_destroy( &dyn_var );
@ -345,7 +343,7 @@ void env_set( const wchar_t *key,
/*
Zero element arrays are internaly not coded as null but as this placeholder string
*/
if( !val && (var_mode & ENV_USER))
if( !val && ( var_mode & ENV_USER ) )
{
val = ENV_NULL;
}
@ -651,13 +649,6 @@ void env_push( int new_scope )
}
/*static int scope_count( env_node_t *n )
{
if( n == global_env )
return 0;
return( scope_count( n->next) + 1 );
}
*/
void env_pop()
{
@ -773,7 +764,9 @@ void env_get_names( array_list_t *l, int flags )
hash_destroy( &names );
}
/**
Function used by env_export_arr to iterate over hashtable of variables
*/
static void export_func1( const void *k, const void *v, void *aux )
{
var_entry_t *val_entry = (var_entry_t *)v;
@ -787,6 +780,9 @@ static void export_func1( const void *k, const void *v, void *aux )
}
/**
Function used by env_export_arr to iterate over hashtable of variables
*/
static void export_func2( const void *k, const void *v, void *aux )
{
wchar_t *key = (wchar_t *)k;

View file

@ -37,12 +37,15 @@ static int init = 0;
*/
static int get_socket_count = 0;
wchar_t * path;
wchar_t *user;
void (*start_fishd)();
static wchar_t * path;
static wchar_t *user;
static void (*start_fishd)();
int env_universal_update=0;
/**
Flag set to 1 when a barrier reply is recieved
*/
static int barrier_reply = 0;
void env_universal_barrier();
@ -137,6 +140,9 @@ static int get_socket( int fork_ok )
return s;
}
/**
Callback function used whenever a new fishd message is recieved
*/
static void callback( int type, const wchar_t *name, const wchar_t *val )
{
@ -151,6 +157,10 @@ static void callback( int type, const wchar_t *name, const wchar_t *val )
}
}
/**
Make sure the connection is healthy. If not, close it, and try to
establish a new connection.
*/
static void check_connection()
{
if( !init )
@ -167,10 +177,15 @@ static void check_connection()
}
}
/**
Try to establish a new connection to fishd. If successfull, end
with call to env_universal_barrier(), to make sure everything is in
sync.
*/
static void reconnect()
{
if( get_socket_count >= RECONNECT_COUNT )
return 0;
return;
debug( 2, L"Get new fishd connection" );
@ -239,6 +254,8 @@ int env_universal_read_all()
if( env_universal_server.fd == -1 )
{
reconnect();
if( env_universal_server.fd == -1 )
return 0;
}
if( env_universal_server.fd != -1 )

View file

@ -46,12 +46,25 @@ void env_universal_set( const wchar_t *name, const wchar_t *val, int export );
*/
void env_universal_remove( const wchar_t *name );
/**
Read all available messages from the server.
*/
int env_universal_read_all();
/**
Get the names of all universal variables
\param l the list to insert the names into
\param show_exported whether exported variables should be shown
\param show_unexported whether unexported variables should be shown
*/
void env_universal_get_names( array_list_t *l,
int show_exported,
int show_unexported );
/**
Synchronize with fishd
*/
void env_universal_barrier();
#endif

13
exec.h
View file

@ -49,8 +49,17 @@ void exec( job_t *j );
int exec_subshell( const wchar_t *cmd,
array_list_t *l );
/**
Free all resources used by a IO_BUFFER type io redirection.
*/
void exec_free_io_buffer( io_data_t *io_buffer );
/**
Create a IO_BUFFER type io redirection.
*/
io_data_t *exec_make_io_buffer();
/**
Close writing end of IO_BUFFER type io redirection, and fully read the reading end.
*/
void exec_read_io_buffer( io_data_t *d );