/*! \todo Finish function description!!! * \brief * \par Function Description * * \param [in] path * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise. */ SCM g_rc_bitmap_directory(SCM path) { gchar *string; char *temp; SCM_ASSERT (scm_is_string (path), path, SCM_ARG1, "bitmap-directory"); /* take care of any shell variables */ temp = scm_to_utf8_string (path); string = s_expand_env_variables (temp); free (temp); /* invalid path? */ if (!g_file_test (string, G_FILE_TEST_IS_DIR)) { fprintf (stderr, "Invalid path [%s] passed to bitmap-directory\n", string); g_free(string); return SCM_BOOL_F; } g_free(default_bitmap_directory); default_bitmap_directory = string; return SCM_BOOL_T; }
/*! \brief Add a directory to the Guile load path. * \par Function Description * Prepends \a s_path to the Guile system '%load-path', after * expanding environment variables. * * \param [in] s_path Path to be added. * \return SCM_BOOL_T. */ SCM g_rc_scheme_directory(SCM s_path) { char *temp; gchar *expanded; SCM s_load_path_var; SCM s_load_path; SCM_ASSERT (scm_is_string (s_path), s_path, SCM_ARG1, "scheme-directory"); /* take care of any shell variables */ temp = scm_to_utf8_string (s_path); expanded = s_expand_env_variables (temp); s_path = scm_from_utf8_string (expanded); free (temp); g_free (expanded); s_load_path_var = scm_c_lookup ("%load-path"); s_load_path = scm_variable_ref (s_load_path_var); scm_variable_set_x (s_load_path_var, scm_cons (s_path, s_load_path)); scm_remember_upto_here_2 (s_load_path_var, s_load_path); scm_remember_upto_here_1 (s_path); return SCM_BOOL_T; }
/*! \brief Guile callback for adding library commands. * \par Function Description * Callback function for the "component-library-command" Guile * function, which can be used in the rc files to add a command to * the component library. * * \param [in] listcmd command to get a list of symbols * \param [in] getcmd command to get a symbol from the library * \param [in] name Optional descriptive name for component source. * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise. */ SCM g_rc_component_library_command (SCM listcmd, SCM getcmd, SCM name) { const CLibSource *src; gchar *lcmdstr, *gcmdstr; char *tmp_str, *namestr; SCM_ASSERT (scm_is_string (listcmd), listcmd, SCM_ARG1, "component-library-command"); SCM_ASSERT (scm_is_string (getcmd), getcmd, SCM_ARG2, "component-library-command"); SCM_ASSERT (scm_is_string (name), name, SCM_ARG3, "component-library-command"); scm_dynwind_begin(0); /* take care of any shell variables */ /*! \bug this may be a security risk! */ tmp_str = scm_to_utf8_string (listcmd); lcmdstr = s_expand_env_variables (tmp_str); scm_dynwind_unwind_handler (g_free, lcmdstr, SCM_F_WIND_EXPLICITLY); free (tmp_str); /* this should stay as free (allocated from guile) */ /* take care of any shell variables */ /*! \bug this may be a security risk! */ tmp_str = scm_to_utf8_string (getcmd); gcmdstr = s_expand_env_variables (tmp_str); scm_dynwind_unwind_handler (g_free, gcmdstr, SCM_F_WIND_EXPLICITLY); free (tmp_str); /* this should stay as free (allocated from guile) */ namestr = scm_to_utf8_string (name); src = s_clib_add_command (lcmdstr, gcmdstr, namestr); free (namestr); /* this should stay as free (allocated from guile) */ scm_dynwind_end(); if (src != NULL) return SCM_BOOL_T; return SCM_BOOL_F; }
/*! \brief * \par Function Description * * \param [in] path * \param [in] name Optional descriptive name for library directory. * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise. */ SCM g_rc_component_library(SCM path, SCM name) { gchar *string; char *temp; char *namestr = NULL; SCM_ASSERT (scm_is_string (path), path, SCM_ARG1, "component-library"); if (name != SCM_UNDEFINED) { SCM_ASSERT (scm_is_string (name), name, SCM_ARG2, "component-library"); namestr = scm_to_utf8_string (name); } /* take care of any shell variables */ temp = scm_to_utf8_string (path); string = s_expand_env_variables (temp); free (temp); /* invalid path? */ if (!g_file_test (string, G_FILE_TEST_IS_DIR)) { fprintf(stderr, "Invalid path [%s] passed to component-library\n", string); if (namestr != NULL) { free (namestr); } g_free(string); return SCM_BOOL_F; } if (g_path_is_absolute (string)) { s_clib_add_directory (string, namestr); } else { gchar *cwd = g_get_current_dir (); gchar *temp; temp = g_build_filename (cwd, string, NULL); s_clib_add_directory (temp, namestr); g_free(temp); g_free(cwd); } if (namestr != NULL) { free (namestr); } g_free(string); return SCM_BOOL_T; }
/*! \todo Finish function description!!! * \brief * \par Function Description * * \param [in] scmsymname * \return SCM_BOOL_T always. */ SCM g_rc_postscript_prolog(SCM scmsymname) { char *temp; SCM_ASSERT (scm_is_string (scmsymname), scmsymname, SCM_ARG1, "postsript-prolog"); g_free(default_postscript_prolog); /* take care of any shell variables */ temp = scm_to_utf8_string (scmsymname); default_postscript_prolog = s_expand_env_variables (temp); free (temp); return SCM_BOOL_T; }
/*! \todo Finish function description!!! * \brief * \par Function Description * * \param [in] path * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise. */ SCM g_rc_source_library(SCM path) { gchar *string; char *temp; SCM_ASSERT (scm_is_string (path), path, SCM_ARG1, "source-library"); /* take care of any shell variables */ temp = scm_to_utf8_string (path); string = s_expand_env_variables (temp); free (temp); /* invalid path? */ if (!g_file_test (string, G_FILE_TEST_IS_DIR)) { fprintf (stderr, "Invalid path [%s] passed to source-library\n", string); g_free(string); return SCM_BOOL_F; } if (g_path_is_absolute (string)) { s_slib_add_entry (string); } else { gchar *cwd = g_get_current_dir (); gchar *temp; temp = g_build_filename (cwd, string, NULL); s_slib_add_entry (temp); g_free(temp); g_free(cwd); } g_free(string); return SCM_BOOL_T; }
/*! \todo Finish function description!!! * \brief * \par Function Description * * \param [in] path * \return SCM_BOOL_T on success, SCM_BOOL_F otherwise. */ SCM g_rc_source_library_search(SCM path) { gchar *string; char *temp; GDir *dir; const gchar *entry; SCM_ASSERT (scm_is_string (path), path, SCM_ARG1, "source-library-search"); /* take care of any shell variables */ temp = scm_to_utf8_string (path); string = s_expand_env_variables (temp); free (temp); /* invalid path? */ if (!g_file_test (string, G_FILE_TEST_IS_DIR)) { fprintf (stderr, "Invalid path [%s] passed to source-library-search\n", string); g_free(string); return SCM_BOOL_F; } dir = g_dir_open (string, 0, NULL); if (dir == NULL) { fprintf (stderr, "Invalid path [%s] passed to source-library-search\n", string); g_free(string); return SCM_BOOL_F; } while ((entry = g_dir_read_name (dir))) { /* don't do . and .. and special case font */ if ((g_strcasecmp (entry, ".") != 0) && (g_strcasecmp (entry, "..") != 0) && (g_strcasecmp (entry, "font") != 0)) { gchar *fullpath = g_build_filename (string, entry, NULL); if (g_file_test (fullpath, G_FILE_TEST_IS_DIR)) { if (s_slib_uniq (fullpath)) { if (g_path_is_absolute (fullpath)) { s_slib_add_entry (fullpath); } else { gchar *cwd = g_get_current_dir (); gchar *temp; temp = g_build_filename (cwd, fullpath, NULL); s_slib_add_entry (temp); g_free(temp); g_free(cwd); } } } g_free(fullpath); } } g_free(string); g_dir_close(dir); return SCM_BOOL_T; }