[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to "redirect" error/output mesages

From: Alejandro Forero Cuervo
Subject: Re: How to "redirect" error/output mesages
Date: Mon, 11 Jun 2001 00:51:06 -0500
User-agent: Mutt/1.2.5i

    I'd like to know how to redirect error (and exception) messages
    from guile (called from C code, without interactive shell) to a
    custom view - i.e. is there some "standard" way to register sort
    of a callback that gets called from guile if output is done?

    I need something similar for standard output stuff.

You can do that with string ports.  It would look like the following
(depending on your exact needs, you may have to adjust this code).
Note that this does it only for the "standard output stuff", not for
the errors.  I don't know how to do it for the errors, but I would bet
that for every *_output_port function in the example below there is a
corresponding *_error_port or something like that.

<c code example>

  SCM oldport; /* Variable for the original output port */
  SCM str; /* Variable to hold the results (ie. the output) */

  /* Record the old output port. */
  oldport = scm_current_output_port();

  /* Now make a new empty string open for writing and set it as the
   * current output port. */
                  scm_make_string(SCM_INUM0, SCM_UNDEFINED),
                  SCM_OPN | SCM_WRTNG,

  /* Evaluate your code here. */

  /* Now get the output: */
  str = scm_strport_to_string(scm_current_output_port());

  /* At this point you can get the chars using SCM_CHARS(str) and the
   * length of the string doing SCM_LENGTH(str). */

  /* Restore the initial output port. */

</c code example>

Good luck! :)


The mere formulation of a problem is far more essential than its solution.
      -- Albert Einstein.

$0='!/sfldbi!yjoV0msfQ!sfiupob!utvK'x44;print map{("\e[7m \e[0m",chr ord
"219CC1CCC033E7E660198CCE4E66798303873CCE60F3387$F"#Don't you love Perl?

Attachment: pgpEYfitq6wep.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]