Blame extension/gawkdirfd.h

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