本文整理汇总了C++中scm_to_utf8_string函数的典型用法代码示例。如果您正苦于以下问题:C++ scm_to_utf8_string函数的具体用法?C++ scm_to_utf8_string怎么用?C++ scm_to_utf8_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scm_to_utf8_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: g_funcs_filesel
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
*
*/
SCM g_funcs_filesel(SCM scm_msg, SCM scm_templ, SCM scm_flags)
{
int c_flags;
char *r, *msg, *templ;
SCM v;
SCM_ASSERT (scm_is_string (scm_msg), scm_msg,
SCM_ARG1, "gschem-filesel");
SCM_ASSERT (scm_is_string (scm_templ), scm_templ,
SCM_ARG2, "gschem-filesel");
/*! \bug FIXME -- figure out the magic SCM_ASSERT for the flags */
/*! \bug FIXME -- how to deal with conflicting flags?
* Should I throw a scheme error? Just deal in the c code?
*/
for (c_flags = 0; scm_is_pair (scm_flags); scm_flags = SCM_CDR (scm_flags)) {
char *flag;
SCM scm_flag = SCM_CAR (scm_flags);
flag = scm_to_utf8_string (scm_flag);
if (strcmp (flag, "may_exist") == 0) {
c_flags |= FSB_MAY_EXIST;
} else if (strcmp (flag, "must_exist") == 0) {
c_flags |= FSB_MUST_EXIST;
} else if (strcmp (flag, "must_not_exist") == 0) {
c_flags |= FSB_SHOULD_NOT_EXIST;
} else if (strcmp (flag, "save") == 0) {
c_flags |= FSB_SAVE;
} else if (strcmp (flag, "open") == 0) {
c_flags |= FSB_LOAD;
} else {
free(flag);
scm_wrong_type_arg ("gschem-filesel", SCM_ARG3, scm_flag);
}
free(flag);
}
msg = scm_to_utf8_string (scm_msg);
templ = scm_to_utf8_string (scm_templ);
r = generic_filesel_dialog (msg, templ, c_flags);
free(msg);
free(templ);
v = scm_from_utf8_string (r);
g_free (r);
return v;
}
示例2: api_set_header
static SCM api_set_header(SCM s_, SCM key_, SCM value_)
{
servlet *s = scm_to_pointer(s_);
char *key = scm_to_utf8_string(key_);
char *value = scm_to_utf8_string(value_);
set_header(s, key, value);
free(key);
free(value);
return SCM_UNSPECIFIED;
}
示例3: g_rc_component_library
/*! \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;
}
示例4: guileKeyCode
SCM guileKeyCode(SCM keyName)
{
char* keyNameStr;
if(scm_is_symbol(keyName))
keyNameStr = scm_to_utf8_string(scm_symbol_to_string(keyName));
else if(scm_is_string(keyName))
keyNameStr = scm_to_utf8_string(keyName);
else
assert(false && "Key name must be a symbol or a string");
guihckKey keyCode = guihckContextGetKeyCode(threadLocalContext.ctx, keyNameStr);
free(keyNameStr);
return scm_from_int32(keyCode);
}
示例5: g_return_val_if_fail
/*! \brief Get symbol data from a Scheme-based component source.
* \par Function Description
* Get symbol data from a Scheme-based component source. The return
* value should be free()'d when no longer needed.
*
* Private function used only in s_clib.c.
*
* \param symbol Symbol to get data for.
* \return Allocated buffer containing symbol data.
*/
static gchar *get_data_scm (const CLibSymbol *symbol)
{
SCM symdata;
char *tmp;
gchar *result;
g_return_val_if_fail ((symbol != NULL), NULL);
g_return_val_if_fail ((symbol->source->type == CLIB_SCM), NULL);
symdata = scm_call_1 (symbol->source->get_fn,
scm_from_utf8_string (symbol->name));
if (!scm_is_string (symdata)) {
s_log_message (_("Failed to load symbol data [%1$s] from source [%2$s]"),
symbol->name, symbol->source->name);
return NULL;
}
/* Need to make sure that the correct free() function is called
* on strings allocated by Guile. */
tmp = scm_to_utf8_string (symdata);
result = g_strdup(tmp);
free (tmp);
return result;
}
示例6: g_rc_gschlas_version
SCM g_rc_gschlas_version(SCM scm_version)
{
char *version;
SCM ret = SCM_BOOL_T;
SCM_ASSERT (scm_is_string (scm_version), scm_version,
SCM_ARG1, "gschlas-version");
version = scm_to_utf8_string (scm_version);
if (g_strcasecmp (version, PACKAGE_DATE_VERSION) != 0) {
fprintf(stderr,
"You are running gEDA/gaf version [%s%s.%s],\n",
PREPEND_VERSION_STRING, PACKAGE_DOTTED_VERSION,
PACKAGE_DATE_VERSION);
fprintf(stderr,
"but you have a version [%s] gschlasrc file:\n[%s]\n",
version, rc_filename);
fprintf(stderr,
"Please be sure that you have the latest rc file.\n");
ret = SCM_BOOL_F;
}
free (version);
return ret;
}
示例7: g_rc_mode_general
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
*
*/
SCM g_rc_mode_general(SCM scmmode,
const char *rc_name,
int *mode_var,
const vstbl_entry *table,
int table_size)
{
SCM ret;
int index;
char *mode;
SCM_ASSERT (scm_is_string (scmmode), scmmode,
SCM_ARG1, rc_name);
mode = scm_to_utf8_string (scmmode);
index = vstbl_lookup_str(table, table_size, mode);
/* no match? */
if(index == table_size) {
fprintf(stderr,
"Invalid mode [%s] passed to %s\n",
mode,
rc_name);
ret = SCM_BOOL_F;
} else {
*mode_var = vstbl_get_val(table, index);
ret = SCM_BOOL_T;
}
free (mode);
return ret;
}
示例8: g_rc_bitmap_directory
/*! \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;
}
示例9: g_funcs_image
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
*
*/
SCM g_funcs_image(SCM scm_filename)
{
char *filename;
SCM_ASSERT (scm_is_string (scm_filename), scm_filename,
SCM_ARG1, "gschem-image");
GSCHEM_TOPLEVEL *w_current = g_current_window ();
if (output_filename) {
x_image_lowlevel (w_current, output_filename,
w_current->image_width,
w_current->image_height,
g_strdup("png"));
} else {
filename = scm_to_utf8_string (scm_filename);
x_image_lowlevel (w_current, filename,
w_current->image_width,
w_current->image_height,
g_strdup("png"));
free(filename);
}
return SCM_BOOL_T;
}
示例10: guihckGuileRunExpression
SCM guihckGuileRunExpression(guihckContext* ctx, SCM expression)
{
threadLocalContext.ctx = ctx;
threadLocalContext.ctxRefs += 1;
SCM result = scm_with_guile(runExpressionInGuile, expression);
#if 0
if(result)
{
char* resultStr = scm_to_utf8_string(scm_object_to_string(result, SCM_UNDEFINED));
printf("RESULT: %s\n", resultStr);
free(resultStr);
}
else
{
printf("RESULT: NULL\n");
}
#endif
threadLocalContext.ctxRefs -= 1;
if(threadLocalContext.ctxRefs <= 0)
{
threadLocalContext.ctx = NULL;
threadLocalContext.ctxRefs = 0;
}
return result;
}
示例11: g_rc_scheme_directory
/*! \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;
}
示例12: process_error_stack
/*! \brief Process a Scheme error into the log and/or a GError
* \par Function Description
* Process a captured Guile exception with the given \a s_key and \a
* s_args, and optionally the stack trace \a s_stack. The stack trace
* and source location are logged, and if a GError return location \a
* err is provided, it is populated with an informative error message.
*/
static void
process_error_stack (SCM s_stack, SCM s_key, SCM s_args, GError **err) {
char *long_message;
char *short_message;
SCM s_port, s_subr, s_message, s_message_args, s_rest, s_location;
/* Split s_args up */
s_rest = s_args;
s_subr = scm_car (s_rest); s_rest = scm_cdr (s_rest);
s_message = scm_car (s_rest); s_rest = scm_cdr (s_rest);
s_message_args = scm_car (s_rest); s_rest = scm_cdr (s_rest);
/* Capture short error message */
s_port = scm_open_output_string ();
scm_display_error_message (s_message, s_message_args, s_port);
short_message = scm_to_utf8_string (scm_get_output_string (s_port));
scm_close_output_port (s_port);
/* Capture long error message (including possible backtrace) */
s_port = scm_open_output_string ();
if (scm_is_true (scm_stack_p (s_stack))) {
scm_puts (_("\nBacktrace:\n"), s_port);
scm_display_backtrace (s_stack, s_port, SCM_BOOL_F, SCM_BOOL_F);
scm_puts ("\n", s_port);
}
s_location = SCM_BOOL_F;
#ifdef HAVE_SCM_DISPLAY_ERROR_STACK
s_location = s_stack;
#endif /* HAVE_SCM_DISPLAY_ERROR_STACK */
#ifdef HAVE_SCM_DISPLAY_ERROR_FRAME
s_location =
scm_is_true (s_stack) ? scm_stack_ref (s_stack, SCM_INUM0) : SCM_BOOL_F;
#endif /* HAVE_SCM_DISPLAY_ERROR_FRAME */
scm_display_error (s_location, s_port, s_subr,
s_message, s_message_args, s_rest);
long_message = scm_to_utf8_string (scm_get_output_string (s_port));
scm_close_output_port (s_port);
/* Send long message to log */
s_log_message ("%s", long_message);
/* Populate any GError */
g_set_error (err, EDA_ERROR, EDA_ERROR_SCHEME, "%s", short_message);
}
示例13: g_rc_always_promote_attributes
/*! \todo Finish function description!!!
* \brief
* \par Function Description
*
* \param [in] attrlist
* \return SCM_BOOL_T always.
*/
SCM g_rc_always_promote_attributes(SCM attrlist)
{
GList *list=NULL;
int length, i;
gchar *attr;
gchar **attr2;
g_list_foreach(default_always_promote_attributes, (GFunc)g_free, NULL);
g_list_free(default_always_promote_attributes);
if (scm_is_string (attrlist)) {
char *temp;
s_log_message(_("WARNING: using a string for 'always-promote-attributes'"
" is deprecated. Use a list of strings instead\n"));
/* convert the space separated strings into a GList */
temp = scm_to_utf8_string (attrlist);
attr2 = g_strsplit(temp," ", 0);
free (temp);
for (i=0; attr2[i] != NULL; i++) {
if (strlen(attr2[i]) > 0) {
list = g_list_prepend(list, g_strdup(attr2[i]));
}
}
g_strfreev(attr2);
} else {
SCM_ASSERT(scm_list_p(attrlist), attrlist, SCM_ARG1, "always-promote-attributes");
length = scm_ilength(attrlist);
/* convert the scm list into a GList */
for (i=0; i < length; i++) {
char *temp;
SCM_ASSERT(scm_is_string(scm_list_ref(attrlist, scm_from_int(i))),
scm_list_ref(attrlist, scm_from_int(i)), SCM_ARG1,
"always-promote-attribute: list element is not a string");
temp = scm_to_utf8_string (scm_list_ref (attrlist, scm_from_int (i)));
attr = g_strdup(temp);
free (temp);
list = g_list_prepend(list, attr);
}
}
default_always_promote_attributes = g_list_reverse(list);
return SCM_BOOL_T;
}
示例14: o_attrib_search_object_attribs_by_name
/* object being a pin */
char *s_net_return_connected_string(TOPLEVEL * pr_current, OBJECT * object,
char *hierarchy_tag)
{
OBJECT *o_current;
char *pinnum = NULL;
char *uref = NULL;
SCM scm_uref;
char *temp_uref = NULL;
char *string;
char *misc;
o_current = object;
pinnum = o_attrib_search_object_attribs_by_name (o_current, "pinnumber", 0);
#if DEBUG
printf("found pinnum: %s\n", pinnum);
#endif
scm_uref = g_scm_c_get_uref(pr_current, o_current->parent);
if (scm_is_string( scm_uref )) {
temp_uref = scm_to_utf8_string (scm_uref);
}
/* apply the hierarchy name to the uref */
uref = s_hierarchy_create_uref(pr_current, temp_uref, hierarchy_tag);
if (uref && pinnum) {
string = g_strdup_printf("%s %s", uref, pinnum);
} else {
if (pinnum) {
string = g_strdup_printf("POWER %s", pinnum);
} else {
if (hierarchy_tag) {
misc =
s_hierarchy_create_uref(pr_current, "U?",
hierarchy_tag);
string = g_strdup_printf("%s ?", misc);
g_free(misc);
} else {
string = g_strdup("U? ?");
}
fprintf(stderr, "Missing Attributes (refdes and pin number)\n");
}
}
g_free(pinnum);
g_free(uref);
g_free(temp_uref);
return (string);
}
示例15: update_report_list
/********************************************************************
* update_report_list
*
* this procedure does the real work of displaying a sorted list of
* available custom reports
********************************************************************/
static void
update_report_list(GtkListStore *store, CustomReportDialog *crd)
{
SCM get_rpt_guids = scm_c_eval_string("gnc:custom-report-template-guids");
SCM template_menu_name = scm_c_eval_string("gnc:report-template-menu-name/report-guid");
SCM rpt_guids;
int i;
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL (store);
gboolean valid_iter;
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), COL_NAME, GTK_SORT_ASCENDING);
crd->reportlist = scm_call_0(get_rpt_guids);
rpt_guids = crd->reportlist;
/* Empty current liststore */
valid_iter = gtk_tree_model_get_iter_first (model, &iter);
while (valid_iter)
{
GValue value = { 0, };
GncGUID *row_guid;
g_value_init ( &value, G_TYPE_POINTER);
gtk_tree_model_get_value (model, &iter, COL_NUM, &value);
row_guid = (GncGUID *) g_value_get_pointer (&value);
guid_free (row_guid);
g_value_unset (&value);
valid_iter = gtk_tree_model_iter_next (model, &iter);
}
gtk_list_store_clear(store);
if (scm_is_list(rpt_guids))
{
/* for all the report guids in the list, store them, with a reference,
in the gtkliststore */
for (i = 0; !scm_is_null(rpt_guids); i++)
{
GncGUID *guid = guid_malloc ();
gchar *guid_str = scm_to_utf8_string (SCM_CAR(rpt_guids));
gchar *name = gnc_scm_to_utf8_string (scm_call_2(template_menu_name, SCM_CAR(rpt_guids), SCM_BOOL_F));
if (string_to_guid (guid_str, guid))
{
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
COL_NAME, name,
COL_NUM, guid,
-1);
}
g_free (name);
g_free (guid_str);
rpt_guids = SCM_CDR(rpt_guids);
}
}
}