diff options
| -rw-r--r-- | mixguile/xmixguile_cmd_dispatcher.c | 60 | ||||
| -rw-r--r-- | mixlib/mix_vm_command.c | 7 | ||||
| -rw-r--r-- | mixlib/mix_vm_command.h | 5 | 
3 files changed, 59 insertions, 13 deletions
| diff --git a/mixguile/xmixguile_cmd_dispatcher.c b/mixguile/xmixguile_cmd_dispatcher.c index 744b76b..5590e5f 100644 --- a/mixguile/xmixguile_cmd_dispatcher.c +++ b/mixguile/xmixguile_cmd_dispatcher.c @@ -267,6 +267,50 @@ mix_set_cmp_ (SCM value)    return gh_symbol2scm ("ok");  } +static SCM +mix_basename_ (const gchar *path) +{ +  SCM result; +  gchar *name; +  if (!path) return gh_str02scm (""); +  SCM_DEFER_INTS; +  name = g_basename (path); +  result = gh_str02scm (name); +  g_free (name); +  SCM_ALLOW_INTS; +  return gh_str02scm (name); +} + +static SCM +mix_src_name_ (void) +{ +  return +    mix_basename_ (mix_vm_cmd_dispatcher_get_src_file_path (vm_dispatcher_)); +} + +static SCM +mix_src_path_ (void) +{ +  const gchar *path = mix_vm_cmd_dispatcher_get_src_file_path (vm_dispatcher_); +  return gh_str02scm (path? (char *)path : ""); +} + +static SCM +mix_prog_name_ (void) +{ +  return +    mix_basename_ (mix_vm_cmd_dispatcher_get_program_path (vm_dispatcher_)); +} + +static SCM +mix_prog_path_ (void) +{ +  const gchar *path = mix_vm_cmd_dispatcher_get_program_path (vm_dispatcher_); +  return gh_str02scm (path? (char *)path : ""); +} + + +  /* ----- hook functions ---- */  /* auxiliar arg list maker */  static SCM @@ -288,18 +332,8 @@ make_arg_list_ (const gchar *arg)  /* command hook auxiliar functions and types */  /*  static SCM -hook_error_handler_ (void *data, SCM tag, SCM args) -{ -  int len; -  mix_vm_cmd_dispatcher_t *dis = (mix_vm_cmd_dispatcher_t *)dis; -  gchar *argstr = gh_scm2newstr (args, &len); -  fprintf (mix_vm_cmd_dispatcher_get_err_stream (dis), "Error in hook: %s\n", -	   argstr); -  g_free (argstr); -  return SCM_BOOL_T; -} +hook_error_handler_ (void *data, SCM tag, SCM args){}  */ -  typedef struct  {    SCM function; @@ -430,6 +464,10 @@ const scm_command_t DEFAULT_SCM_COMMANDS_[] = {    {"mix-loc", mix_loc_, 0, 0, 0},    {"mix-set-over!", mix_set_over_, 1, 0, 0},    {"mix-cmp", mix_cmp_, 0, 0, 0}, +  {"mix-prog-name", mix_prog_name_, 0, 0, 0}, +  {"mix-prog-path", mix_prog_path_, 0, 0, 0}, +  {"mix-src-name", mix_src_name_, 0, 0, 0}, +  {"mix-src-path", mix_src_path_, 0, 0, 0},    {"mix-set-cmp!", mix_set_cmp_, 1, 0, 0},    {"mix-add-pre-hook", mix_add_pre_hook_, 2, 0, 0},    {"mix-add-post-hook", mix_add_post_hook_, 2, 0, 0}, diff --git a/mixlib/mix_vm_command.c b/mixlib/mix_vm_command.c index 56f381d..07496c0 100644 --- a/mixlib/mix_vm_command.c +++ b/mixlib/mix_vm_command.c @@ -369,6 +369,13 @@ mix_vm_cmd_dispatcher_get_src_file_path (const mix_vm_cmd_dispatcher_t *dis)    return PATH;  } +const gchar * +mix_vm_cmd_dispatcher_get_program_path (const mix_vm_cmd_dispatcher_t *dis) +{ +  g_return_val_if_fail (dis != NULL, NULL); +  return dis->program; +} +  /* install hooks */  void  mix_vm_cmd_dispatcher_pre_hook (mix_vm_cmd_dispatcher_t *dis, diff --git a/mixlib/mix_vm_command.h b/mixlib/mix_vm_command.h index 465ed3e..b6672a0 100644 --- a/mixlib/mix_vm_command.h +++ b/mixlib/mix_vm_command.h @@ -166,6 +166,9 @@ extern const gchar *  mix_vm_cmd_dispatcher_get_src_file_path (const mix_vm_cmd_dispatcher_t *dis);  extern const gchar * +mix_vm_cmd_dispatcher_get_program_path (const mix_vm_cmd_dispatcher_t *dis); + +extern const gchar *  mix_vm_cmd_dispatcher_get_editor (const mix_vm_cmd_dispatcher_t *dis);  extern const gchar * @@ -229,8 +232,6 @@ mix_vm_cmd_dispatcher_global_post_hook (mix_vm_cmd_dispatcher_t *dis,  					mix_vm_cmd_global_hook_t hook,  					gpointer data); - -  /* get the mix vm */  extern const mix_vm_t *  mix_vm_cmd_dispatcher_get_vm (const mix_vm_cmd_dispatcher_t *dis); | 
