/* libsizzle/posix-ext.if - interface spec for additional posix calls -*-c-*-
 
  Copyright (C) 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.  */

/*:doc
  dup
  (dup oldfd) => *unspecified*
  Apply the C function @code{dup} to the following parameters:
  oldfd: integer
  doc:*/
#define FUNC_NAME "dup"
static result_t 
dup_func (zzz_scm_t env, zzz_scm_t oldfd, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t __retval;

  CHECK_TYPE (1, integer_p (oldfd), zzz_integer_type_name);
  {
    int res = dup (integer_val (oldfd));
    if (res == -1)
      {
        *result = zzz_make_system_exception ();
        return RESULT_EXCEPTION;
      }
    __retval = zzz_unspecified;
  }
  *result = __retval;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

/*:doc
  dup2
  (dup2 oldfd newfd) => *unspecified*
  Apply the C function @code{dup2} to the following parameters:
  oldfd: integer
  newfd: integer
  doc:*/
#define FUNC_NAME "dup2"
static result_t 
dup2_func (zzz_scm_t env, zzz_scm_t oldfd, zzz_scm_t newfd, zzz_scm_t * result)
{
  static char * s_func_name = FUNC_NAME;
  zzz_scm_t __retval;

  CHECK_TYPE (1, integer_p (oldfd), zzz_integer_type_name);
  CHECK_TYPE (2, integer_p (newfd), zzz_integer_type_name);
  {
    int res = dup2 (integer_val (oldfd), integer_val (newfd));
    if (res == -1)
      {
        *result = zzz_make_system_exception ();
        return RESULT_EXCEPTION;
      }
    __retval = zzz_unspecified;
  }
  *result = __retval;
  return RESULT_SUCCESS;
}
#undef FUNC_NAME

