198937Sdes/*
2250739Sdes * Copyright (c) 2000, 2001, 2011, 2013 Corinna Vinschen <vinschen@redhat.com>
398937Sdes *
498937Sdes * Redistribution and use in source and binary forms, with or without
598937Sdes * modification, are permitted provided that the following conditions
698937Sdes * are met:
798937Sdes * 1. Redistributions of source code must retain the above copyright
898937Sdes *    notice, this list of conditions and the following disclaimer.
998937Sdes * 2. Redistributions in binary form must reproduce the above copyright
1098937Sdes *    notice, this list of conditions and the following disclaimer in the
1198937Sdes *    documentation and/or other materials provided with the distribution.
1298937Sdes *
1398937Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1498937Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1598937Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1698937Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1798937Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1898937Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1998937Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2098937Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2198937Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2298937Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2398937Sdes *
2498937Sdes * Created: Sat Sep 02 12:17:00 2000 cv
2598937Sdes *
2698937Sdes * This file contains functions for forcing opened file descriptors to
2798937Sdes * binary mode on Windows systems.
2898937Sdes */
2998937Sdes
3098937Sdes#ifndef _BSD_CYGWIN_UTIL_H
3198937Sdes#define _BSD_CYGWIN_UTIL_H
3298937Sdes
3398937Sdes#ifdef HAVE_CYGWIN
3498937Sdes
35124208Sdes#undef ERROR
36124208Sdes
37250739Sdes/* Avoid including windows headers. */
38250739Sdestypedef void *HANDLE;
39250739Sdes#define INVALID_HANDLE_VALUE ((HANDLE) -1)
40294328Sdes#define DNLEN 16
41294328Sdes#define UNLEN 256
42240075Sdes
43261320Sdes/* Cygwin functions for which declarations are only available when including
44261320Sdes   windows headers, so we have to define them here explicitely. */
45261320Sdesextern HANDLE cygwin_logon_user (const struct passwd *, const char *);
46261320Sdesextern void cygwin_set_impersonation_token (const HANDLE);
47261320Sdes
48124208Sdes#include <sys/cygwin.h>
4998937Sdes#include <io.h>
5098937Sdes
51294328Sdes#define CYGWIN_SSH_PRIVSEP_USER (cygwin_ssh_privsep_user())
52294328Sdesconst char *cygwin_ssh_privsep_user();
53261320Sdes
54124208Sdesint binary_open(const char *, int , ...);
55124208Sdesint check_ntsec(const char *);
56146998Sdeschar **fetch_windows_environment(void);
57146998Sdesvoid free_windows_environment(char **);
5898937Sdes
59250739Sdes#ifndef NO_BINARY_OPEN
6098937Sdes#define open binary_open
61250739Sdes#endif
6298937Sdes
6398937Sdes#endif /* HAVE_CYGWIN */
6498937Sdes
6598937Sdes#endif /* _BSD_CYGWIN_UTIL_H */
66