Blame extension/gawkdirfd.h

Packit Service f629e6
/* dirfd.c -- return the file descriptor associated with an open DIR*
Packit Service f629e6
Packit Service f629e6
   Copyright (C) 2001, 2006, 2008-2013 Free Software Foundation, Inc.
Packit Service f629e6
Packit Service f629e6
   This program is free software: you can redistribute it and/or modify
Packit Service f629e6
   it under the terms of the GNU General Public License as published by
Packit Service f629e6
   the Free Software Foundation; either version 3 of the License, or
Packit Service f629e6
   (at your option) any later version.
Packit Service f629e6
Packit Service f629e6
   This program is distributed in the hope that it will be useful,
Packit Service f629e6
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service f629e6
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service f629e6
   GNU General Public License for more details.
Packit Service f629e6
Packit Service f629e6
   You should have received a copy of the GNU General Public License
Packit Service f629e6
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit Service f629e6
Packit Service f629e6
/* Written by Jim Meyering. */
Packit Service f629e6
Packit Service f629e6
/* Modified for gawk */
Packit Service f629e6
Packit Service f629e6
#include <config.h>
Packit Service f629e6
Packit Service f629e6
#ifndef ENOTSUP
Packit Service f629e6
# define ENOTSUP ENOSYS
Packit Service f629e6
#endif
Packit Service f629e6
Packit Service f629e6
/*
Packit Service f629e6
 * This is for fake directory file descriptors on systems that don't
Packit Service f629e6
 * allow to open() a directory.
Packit Service f629e6
 *
Packit Service f629e6
 * Including a header from the main gawk source to share the definition
Packit Service f629e6
 * of FAKE_FD_VALUE is the least of all evils that I can see.
Packit Service f629e6
 *
Packit Service f629e6
 * Unlike the main gawk code base, this include is NOT dependant
Packit Service f629e6
 * upon MinGW or EMX.
Packit Service f629e6
 */
Packit Service f629e6
#ifndef __VMS
Packit Service f629e6
#include "../nonposix.h"
Packit Service f629e6
#else
Packit Service f629e6
#include "nonposix.h"
Packit Service f629e6
#endif
Packit Service f629e6
Packit Service f629e6
#ifndef DIR_TO_FD
Packit Service f629e6
# define DIR_TO_FD(d) (FAKE_FD_VALUE)
Packit Service f629e6
#endif
Packit Service f629e6
Packit Service f629e6
#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0)
Packit Service f629e6
int
Packit Service f629e6
dirfd (DIR *dir_p)
Packit Service f629e6
{
Packit Service f629e6
  int fd = DIR_TO_FD (dir_p);
Packit Service f629e6
  if (fd == -1)
Packit Service f629e6
    errno = ENOTSUP;
Packit Service f629e6
  return fd;
Packit Service f629e6
}
Packit Service f629e6
#endif /* HAVE_DIRFD */