/* libsizzle/fport.h - stdio file port handling
 
  Copyright (C) 1999, 2000 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
 
  This is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2, or (at your option)
  any later version.
  
  This software is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this package; see the file COPYING.  If not, write to the
  Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  MA 02111-1307, USA.  */

#ifndef __SIZZLE_FPORT_H__
#define __SIZZLE_FPORT_H__

#if HAVE_CONFIG_H
# include <config.h>
#endif 

#if __SIZZLE_IMPORT__
# define SIZZLE_API __declspec (dllimport)
#elif __SIZZLE_EXPORT__ 
# define SIZZLE_API __declspec (dllexport)
#else
# define SIZZLE_API
#endif

#include <stdio.h>

#include "node.h"

/* Type descriminator and accessor macros for file port objects.  */
#define fport_p(c)    (port_p(c) && port_ptype == zzz_fport_port_type)
#define fport_file(c) (((FILE *) port_info(c)))

/* The stdio file port type identifier.  */
SIZZLE_API extern zzz_object_t zzz_fport_port_type;

/* Stdio file ports connected to standard input/output/error.  */ 
SIZZLE_API extern zzz_scm_t zzz_stdin_fport;
SIZZLE_API extern zzz_scm_t zzz_stdout_fport;
SIZZLE_API extern zzz_scm_t zzz_stderr_fport;

/* Create a stdio file port for the stream @var{file}.  The port is
   readable if @var{read} is true and writable if @var{write} is true.  */
SIZZLE_API zzz_scm_t zzz_make_fport (FILE * file, int read, int write);

/* Initialize the stdio file port module.  Register the stdio file
   port type and create the standard ports.  */
SIZZLE_API result_t zzz_init_fport (void);

#endif /* not __SIZZLE_FPORT_H__ */
