# Cygwin API Reference

Copyright © 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Red Hat, Inc.

List of Examples

2.1. Example use of cygwin_conv_path
2.2. Example use of cygwin_split_path
2.3. Example use of cygwin_winpid_to_pid

## Chapter 1. Compatibility

## System interfaces compatible with the Single Unix Specification, Version 3:

Note that the core of the Single Unix Specification, Version 3 is also ISO/IEC 9945:2003 and IEEE Std 1003.1-2001 (POSIX.1-2001).

        FD_CLR
        FD_ISSET
        FD_SET
        FD_ZERO
        _Exit
        _exit
        _longjmp
        _setjmp
        _tolower
        _toupper
        a64l
        abort
        abs
        accept
        access
        acos
        acosf
        acosh
        acoshf
        alarm
        asctime
        asctime_r
        asin
        asinf
        asinh
        asinhf
        atan
        atan2
        atan2f
        atanf
        atanh
        atanhf
        atexit
        atof
        atoff
        atoi
        atol
        atoll
        basename
        bcmp
        bcopy
        bind
        bsearch
        btowc
        bzero
        cabs
        cabsf
        calloc
        catclose 			(available in external "catgets" library)
        catgets  			(available in external "catgets" library)
        catopen  			(available in external "catgets" library)
        cbrt
        cbrtf
        ceil
        ceilf
        cfgetispeed
        cfgetospeed
        cfsetispeed
        cfsetospeed
        chdir
        chmod
        chown
        chroot			(see chapter "Implementation Notes")
        clearerr
        clock
        clock_getres		(see chapter "Implementation Notes")
        clock_gettime		(see chapter "Implementation Notes")
        clock_setres		(see chapter "Implementation Notes")
        close
        closedir
        closelog
        confstr
        connect
        copysign
        copysignf
        cos
        cosf
        cosh
        coshf
        creat
        crypt			(available in external "crypt" library)
        ctermid
        ctime
        ctime_r
        daylight
        dbm_clearerr		(available in external "libgdbm" library)
        dbm_close			(available in external "libgdbm" library)
        dbm_delete			(available in external "libgdbm" library)
        dbm_error			(available in external "libgdbm" library)
        dbm_fetch			(available in external "libgdbm" library)
        dbm_firstkey		(available in external "libgdbm" library)
        dbm_nextkey			(available in external "libgdbm" library)
        dbm_open			(available in external "libgdbm" library)
        dbm_store			(available in external "libgdbm" library)
        difftime
        dirname
        div
        dlclose
        dlerror
        dlopen
        dlsym
        drand48
        dup
        dup2
        ecvt
        encrypt			(available in external "crypt" library)
        endgrent
        endhostent
        endprotoent
        endpwent
        endservent
        endutxent
        environ
        erand48
        erf
        erfc
        erfcf
        erff
        errno
        execl
        execle
        execlp
        execv
        execve
        execvp
        exit
        exp
        exp2
        exp2f
        expf
        expm1
        expm1f
        fabs
        fabsf
        fchdir
        fchmod
        fchown
        fclose
        fcntl
        fcvt
        fdatasync
        fdim
        fdimf
        fdopen
        feof
        ferror
        fflush
        ffs
        fgetc
        fgetpos
        fgets
        fileno
        flockfile
        floor
        floorf
        fma
        fmaf
        fmax
        fmaxf
        fmin
        fminf
        fmod
        fmodf
        fnmatch
        fopen
        fork
        fpathconf
        fpclassify			(see chapter "Implementation Notes")
        fprintf
        fputc
        fputs
        fread
        free
        freeaddrinfo
        freopen
        frexp
        frexpf
        fscanf
        fseek
        fseeko
        fsetpos
        fstat
        fstatvfs
        fsync
        ftell
        ftello
        ftime
        ftok
        ftruncate
        ftrylockfile
        ftw
        funlockfile
        futimes
        fwrite
        gai_strerror
        gcvt
        getaddrinfo
        getc
        getc_unlocked
        getchar
        getchar_unlocked
        getcwd
        getdelim
        getdomainname
        getegid
        getenv
        geteuid
        getgid
        getgrent
        getgrgid
        getgrgid_r
        getgrnam
        getgrnam_r
        getgroups
        gethostbyaddr
        gethostbyname
        gethostid
        gethostname
        getitimer			(see chapter "Implementation Notes")
        getlogin
        getlogin_r
        getnameinfo
        getopt
        getpeername
        getpgid
        getpgrp
        getpid
        getppid
        getpriority
        getprotobyname
        getprotobynumber
        getprotoent
        getpwent
        getpwnam
        getpwnam_r
        getpwuid
        getpwuid_r
        getrlimit
        getrusage
        gets
        getservbyname
        getservbyport
        getservent
        getsid
        getsockname
        getsockopt
        getsubopt
        gettimeofday
        getuid
        getutxent
        getutxid
        getutxline
        getwd
        glob
        globfree
        gmtime
        gmtime_r
        grantpt
        h_errno
        hcreate
        hdestroy
        hsearch
        hstrerror
        htonl
        htons
        hypot
        hypotf
        iconv			(available in external "libiconv" library)
        iconv_close			(available in external "libiconv" library)
        iconv_open			(available in external "libiconv" library)
        if_freenameindex
        if_indextoname
        if_nameindex
        if_nametoindex
        ilogb
        ilogbf
        imaxabs
        imaxdiv
        index
        inet_addr
        inet_ntoa
        inet_ntop
        inet_pton
        initstate
        insque
        ioctl
        isalnum
        isalpha
        isascii
        isatty
        isblank
        iscntrl
        isdigit
        isfinite			(see chapter "Implementation Notes")
        isgraph
        isgreater			(see chapter "Implementation Notes")
        isgreaterequal		(see chapter "Implementation Notes")
        isinf			(see chapter "Implementation Notes")
        isless
        islessequal			(see chapter "Implementation Notes")
        islessgreater		(see chapter "Implementation Notes")
        islower
        isnan			(see chapter "Implementation Notes")
        isnormal			(see chapter "Implementation Notes")
        isprint
        ispunct
        isspace
        isunordered			(see chapter "Implementation Notes")
        isupper
        iswalnum
        iswalpha
        iswblank
        iswcntrl
        iswctype
        iswdigit
        iswgraph
        iswlower
        iswprint
        iswpunct
        iswspace
        iswupper
        iswxdigit
        isxdigit
        j0
        j1
        jn
        jrand48
        kill
        killpg
        l64a
        labs
        lchown
        lcong48
        ldexp
        ldexpf
        ldiv
        lfind
        lgamma
        lgammaf
        link
        listen
        llabs
        lldiv
        llrint
        llrintf
        llrintl
        localeconv
        localtime
        localtime_r
        lockf
        log
        log10
        log10f
        log1p
        log1pf
        logb
        logbf
        logf
        longjmp
        lrand48
        lrint
        lrintf
        lrintl
        lround
        lroundf
        lsearch
        lseek
        lstat
        malloc
        mblen
        mbrlen
        mbrtowc
        mbsinit
        mbsrtowcs
        mbstowcs
        mbtowc
        memccpy
        memchr
        memcmp
        memcpy
        memmove
        memset
        mkdir
        mkfifo
        mknod
        mkstemp
        mktemp
        mktime
        mlock
        mmap
        modf
        modff
        mprotect
        mq_close
        mq_getattr
        mq_notify
        mq_open
        mq_receive
        mq_send
        mq_setattr
        mq_timedreceive
        mq_timedsend
        mq_unlink
        mrand48
        msgctl			(see chapter "Implementation Notes")
        msgget			(see chapter "Implementation Notes")
        msgrcv			(see chapter "Implementation Notes")
        msgsnd			(see chapter "Implementation Notes")
        msync
        munlock
        munmap
        nan
        nanf
        nanosleep
        nearbyint
        nearbyintf
        nextafter
        nextafterf
        nftw
        nice
        nl_langinfo
        nrand48
        ntohl
        ntohs
        open
        opendir
        openlog
        optarg
        opterr
        optind
        optopt
        pathconf
        pause
        pclose
        perror
        pipe
        poll
        popen
        posix_fadvise
        posix_fallocate
        posix_madvise
        posix_memalign
        posix_openpt
        pow
        powf
        pread
        printf
        pselect
        pthread_atfork
        pthread_attr_destroy
        pthread_attr_getdetachstate
        pthread_attr_getinheritsched
        pthread_attr_getschedparam
        pthread_attr_getschedpolicy
        pthread_attr_getscope
        pthread_attr_getstacksize
        pthread_attr_init
        pthread_attr_setdetachstate
        pthread_attr_setinheritsched
        pthread_attr_setschedparam
        pthread_attr_setschedpolicy
        pthread_attr_setscope
        pthread_attr_setstacksize
        pthread_cancel
        pthread_cond_broadcast
        pthread_cond_destroy
        pthread_cond_init
        pthread_cond_signal
        pthread_cond_timedwait
        pthread_cond_wait
        pthread_condattr_destroy
        pthread_condattr_getpshared
        pthread_condattr_init
        pthread_condattr_setpshared
        pthread_create
        pthread_detach
        pthread_equal
        pthread_exit
        pthread_getconcurrency
        pthread_getschedparam
        pthread_getspecific
        pthread_join
        pthread_key_create
        pthread_key_delete
        pthread_kill
        pthread_mutex_destroy
        pthread_mutex_getprioceiling
        pthread_mutex_init
        pthread_mutex_lock
        pthread_mutex_setprioceiling
        pthread_mutex_trylock
        pthread_mutex_unlock
        pthread_mutexattr_destroy
        pthread_mutexattr_getprioceiling
        pthread_mutexattr_getprotocol
        pthread_mutexattr_getpshared
        pthread_mutexattr_gettype
        pthread_mutexattr_init
        pthread_mutexattr_setprioceiling
        pthread_mutexattr_setprotocol
        pthread_mutexattr_setpshared
        pthread_mutexattr_settype
        pthread_once
        pthread_rwlock_destroy
        pthread_rwlock_init
        pthread_rwlock_rdlock
        pthread_rwlock_tryrdlock
        pthread_rwlock_trywrlock
        pthread_rwlock_unlock
        pthread_rwlock_wrlock
        pthread_rwlockattr_destroy
        pthread_rwlockattr_getpshared
        pthread_rwlockattr_init
        pthread_rwlockattr_setpshared
        pthread_self
        pthread_setcancelstate
        pthread_setcanceltype
        pthread_setconcurrency
        pthread_setschedparam
        pthread_setspecific
        pthread_sigmask
        pthread_testcancel
        ptsname
        putc
        putc_unlocked
        putchar
        putchar_unlocked
        putenv
        puts
        pututxline
        pwrite
        qsort
        raise
        rand
        rand_r
        random
        read
        readdir
        readdir_r
        readlink
        readv
        realloc
        realpath
        recv
        recvfrom
        recvmsg
        regcomp
        regerror
        regexec
        regfree
        remainder
        remainderf
        remove
        remque
        remquo
        remquof
        rename
        rewind
        rewinddir
        rindex
        rint
        rintf
        rintl
        rmdir
        round
        roundf
        scalb
        scalbln
        scalblnf
        scalbn
        scalbnf
        scandir
        scanf
        sched_get_priority_max
        sched_get_priority_min
        sched_getparam
        sched_getscheduler
        sched_rr_get_interval
        sched_setparam
        sched_setscheduler
        sched_yield
        seed48
        seekdir
        select
        sem_close
        sem_destroy
        sem_getvalue
        sem_init
        sem_open
        sem_post
        sem_timedwait
        sem_trywait
        sem_unlink
        sem_wait
        semctl			(see chapter "Implementation Notes")
        semget			(see chapter "Implementation Notes")
        semop			(see chapter "Implementation Notes")
        send
        sendmsg
        sendto
        setbuf
        setegid
        setenv
        seteuid
        setgid
        setgrent
        sethostent
        setitimer			(see chapter "Implementation Notes")
        setjmp
        setkey			(available in external "crypt" library)
        setlocale
        setlogmask
        setpgid
        setpgrp
        setpriority
        setprotoent
        setpwent
        setregid
        setreuid
        setrlimit
        setservent
        setsid
        setsockopt
        setstate
        setuid
        setutxent
        setvbuf
        shm_open
        shm_unlink
        shmat			(see chapter "Implementation Notes")
        shmctl			(see chapter "Implementation Notes")
        shmdt			(see chapter "Implementation Notes")
        shmget			(see chapter "Implementation Notes")
        shutdown
        sigaction
        sigaddset
        sigdelset
        sigemptyset
        sigfillset
        sighold
        sigignore
        siginterrupt
        sigismember
        siglongjmp
        signal
        signbit			(see chapter "Implementation Notes")
        signgam
        sigpause
        sigpending
        sigprocmask
        sigqueue
        sigrelse
        sigset
        sigsetjmp
        sigsuspend
        sigwait
        sigwaitinfo
        sin
        sinf
        sinh
        sinhf
        sleep
        snprintf
        socket
        socketpair
        sprintf
        sqrt
        sqrtf
        srand
        srand48
        srandom
        sscanf
        stat
        statvfs
        stderr
        stdin
        stdout
        strcasecmp
        strcat
        strchr
        strcmp
        strcoll
        strcpy
        strcspn
        strdup
        strerror
        strerror_r
        strftime
        strlen
        strncasecmp
        strncat
        strncmp
        strncpy
        strpbrk
        strptime
        strrchr
        strspn
        strstr
        strtod
        strtof
        strtoimax
        strtok
        strtok_r
        strtol
        strtoll
        strtoul
        strtoull
        strtoumax
        strxfrm
        swab
        symlink
        sync
        sysconf
        syslog
        system
        tan
        tanf
        tanh
        tanhf
        tcdrain
        tcflow
        tcflush
        tcgetattr
        tcgetpgrp
        tcsendbreak
        tcsetattr
        tcsetpgrp
        tdelete
        telldir
        tempnam
        tfind
        tgamma
        tgammaf
        time
        timer_create
        timer_delete
        timer_gettime
        timer_settime
        times
        timezone
        tmpfile
        tmpnam
        toascii
        tolower
        toupper
        towctrans
        towlower
        towupper
        trunc
        truncate
        truncf
        tsearch
        ttyname
        ttyname_r
        twalk
        tzname
        tzset
        ualarm
        umask
        uname
        ungetc
        unlink
        unlockpt
        unsetenv
        usleep
        utime
        utimes
        va_arg
        va_copy
        va_end
        va_start
        vfork			(see chapter "Implementation Notes")
        vfprintf
        vfscanf
        vprintf
        vscanf
        vsnprintf
        vsprintf
        vsscanf
        wait
        waitpid
        wcrtomb
        wcscat
        wcschr
        wcscmp
        wcscoll
        wcscpy
        wcscspn
        wcslen
        wcsncat
        wcsncmp
        wcsncpy
        wcspbrk
        wcsrchr
        wcsrtombs
        wcsspn
        wcsstr
        wcstol
        wcstoll
        wcstombs
        wcstoul
        wcstoull
        wcswidth
        wcsxfrm
        wctob
        wctomb
        wctrans
        wctype
        wcwidth
        wmemchr
        wmemcmp
        wmemcpy
        wmemmove
        wmemset
        wprintf
        write
        writev
        y0
        y1
        yn

## System interfaces compatible with BSD functions:

        alphasort
        bindresvport
        bindresvport_sa
        cfmakeraw
        daemon
        dn_comp
        dn_expand
        dn_skipname
        drem
        endusershell
        err
        errx
        finite
        finitef
        fiprintf
        flock
        forkpty
        freeifaddrs
        fstatfs
        fts_children
        fts_close
        fts_get_clientptr
        fts_get_stream
        fts_open
        fts_read
        fts_set
        fts_set_clientptr
        funopen
        gamma
        gamma_r
        gammaf
        gammaf_r
        getdtablesize
        getifaddrs
        getpagesize
        getpeereid
        getprogname
        getusershell
        herror
        inet_aton
        inet_makeaddr
        inet_netof
        inet_network
        initgroups
        iruserok
        iruserok_sa
        login
        login_tty
        logout
        logwtmp
        mkdtemp
        openpty
        rcmd
        rcmd_af
        res_close
        res_init
        res_mkquery
        res_nclose
        res_ninit
        res_nmkquery
        res_nquery
        res_nquerydomain
        res_nsearch
        res_nsend
        res_query
        res_querydomain
        res_search
        res_send
        revoke
        rexec
        rresvport
        rresvport_af
        ruserok
        sbrk
        setbuffer
        setgroups
        setlinebuf
        setpassent
        setprogname
        settimeofday
        setusershell
        statfs
        strcasestr
        strlcat
        strlcpy
        strsep
        strsignal
        updwtmp
        valloc
        verr
        verrx
        vhangup			(see chapter "Implementation Notes")
        vsyslog
        vwarn
        vwarnx
        wait3
        wait4
        warn
        warnx
        wcslcat
        wcslcpy

## System interfaces compatible with GNU or Linux extensions:

        argz_add
        argz_add_sep
        argz_append
        argz_count
        argz_create
        argz_create_sep
        argz_delete
        argz_extract
        argz_insert
        argz_next
        argz_replace
        argz_stringify
        asnprintf
        asprintf
        asprintf_r
        dprintf
        dremf
        envz_add
        envz_entry
        envz_get
        envz_merge
        envz_remove
        envz_strip
        exp10
        exp10f
        fcloseall
        fcloseall_r
        fgetxattr
        flistxattr
        fmemopen
        fopencookie
        fremovexattr
        fsetxattr
        getline
        getopt_long
        getopt_long_only
        getxattr
        lgetxattr
        listxattr
        llistxattr
        lremovexattr
        lsetxattr
        memmem
        mempcpy
        open_memstream
        pow10
        pow10f
        removexattr
        setxattr
        stpcpy
        stpncpy
        strndup
        strnlen
        tdestroy
        timegm
        timelocal
        updwtmpx
        utmpxname
        vasnprintf
        vasprintf
        vasprintf_r
        vdprintf
        wcpcpy
        wcpncpy

## System interfaces compatible with Solaris or SunOS functions:

        acl
        aclcheck
        aclfrommode
        aclfrompbits
        aclfromtext
        aclsort
        acltomode
        acltopbits
        acltotext
        endmntent
        faccessat
        facl
        fchmodat
        fchownat
        fdopendir
        fstatat
        futimesat
        getmntent
        linkat
        memalign
        mkdirat
        mkfifoat
        mknodat
        openat
        readlinkat
        renameat
        setmntent
        symlinkat
        unlinkat

## System interfaces compatible with the Draft Single Unix Specification, Version 4:

        futimens
        utimensat

## Other UNIX system interfaces, deprecated or not in POSIX.1-2001:

        cuserid			(POSIX.1-1988, SUSv2)
        endutent			(XPG2)
        getpass			(SUSv2)
        getutent			(XPG2)
        getutid			(XPG2)
        getutline			(XPG2)
        getw			(SVID)
        mallinfo			(SVID)
        mallopt			(SVID)
        on_exit			(SunOS)
        pthread_continue		(XPG2)
        pthread_getsequence_np	(Tru64)
        pthread_suspend		(XPG2)
        pututline			(XPG2)
        putw			(SVID)
        setutent			(XPG2)
        sys_errlist			(BSD)
        sys_nerr			(BSD)
        ttyslot			(SUSv2)
        utmpname			(XPG2)

## NOT implemented system interfaces from the Single Unix Specification, Volume 3:

        acoshl
        acosl
        aio_cancel
        aio_error
        aio_fsync
        aio_read
        aio_return
        aio_suspend
        aio_write
        asinhl
        asinl
        atan2l
        atanhl
        atanl
        bsd_signal
        cabsl
        cacos
        cacosf
        cacosh
        cacoshf
        cacoshl
        cacosl
        carg
        cargf
        cargl
        casin
        casinf
        casinh
        casinhf
        casinhl
        casinl
        catan
        catanf
        catanh
        catanhf
        catanhl
        catanl
        cbrtl
        ccos
        ccosf
        ccosh
        ccoshf
        ccoshl
        ccosl
        ceill
        cexp
        cexpf
        cexpl
        cimag
        cimagf
        cimagl
        clock_getcpuclockid
        clog
        clogf
        clogl
        conj
        conjf
        conjl
        copysignl
        coshl
        cosl
        cpow
        cpowf
        cpowl
        cproj
        cprojf
        cprojl
        creal
        crealf
        creall
        csin
        csinf
        csinh
        csinhf
        csinhl
        csinl
        csqrt
        csqrtf
        csqrtl
        ctan
        ctanf
        ctanh
        ctanhf
        ctanhl
        ctanl
        endnetent
        erfcl
        erfl
        exp2l
        expl
        expm1l
        fabsl
        fattach
        fdiml
        feclearexcept
        fegetenv
        fegetexceptflag
        fegetround
        feholdexcept
        feraiseexcept
        fesetenv
        fesetexceptflag
        fesetround
        fetestexcept
        feupdateenv
        fgetwc
        fgetws
        floorl
        fmal
        fmaxl
        fminl
        fmodl
        fmtmsg
        fputwc
        fputws
        frexpl
        fwide
        fwprintf
        fwscanf
        getcontext
        getdate
        getdate_err
        gethostent
        getmsg
        getnetbyaddr
        getnetbyname
        getnetent
        getpmsg
        getwc
        getwchar
        hypotl
        ilogbl
        initstate
        isastream
        ldexpl
        lgammal
        lio_listio
        llround
        llroundf
        llroundl
        log10l
        log1pl
        log2l
        logbl
        logl
        lroundl
        makecontext
        mlockall
        modfl
        munlockall
        nanl
        nearbyintl
        nextafterl
        nexttowardl
        posix_mem_offset
        posix_spawn[...]
        posix_trace[...]
        posix_typed_[...]
        powl
        pthread_attr_getguardsize
        pthread_attr_getstack
        pthread_attr_getstackaddr
        pthread_attr_setguardsize
        pthread_attr_setstack
        pthread_attr_setstackaddr
        pthread_barrier[...]
        pthread_condattr_getclock
        pthread_condattr_setclock
        pthread_getcpuclockid
        pthread_mutex_timedlock
        pthread_rwlock_timedrdlock
        pthread_rwlock_timedwrlock
        pthread_setschedprio
        pthread_spin_[...]
        putmsg
        reminderl
        remquol
        roundl
        scalblnl
        scalbnl
        setcontext
        setnetent
        sigaltstack
        sigtimedwait
        sinhl
        sinl
        sockatmark
        sqrtl
        strfmon
        strtold
        swabcontext
        swprintf
        swscanf
        tanhl
        tanl
        tcgetsid
        tgammal
        timer_getoverrun
        truncl
        ulimit
        vfwprintf
        vfwscanf
        vswprintf
        vswscanf
        vwprintf
        vwscanf
        waitid
        wcsftime
        wcstod
        wcstof
        wcstoimax
        wcstok
        wcstold
        wcstoumax
        wcswcs
        wordexp
        wordfree
        wscanf

## Implementation Notes

`chroot` only emulates a chroot function call by keeping track of the current root and accomodating this in the file related function calls. A real chroot functionality is not supported by Windows however.

`clock_getres`, `clock_gettime` and `clock_setres` only support CLOCK_REALTIME for now.

`fpclassify`, `isfinite`, `isgreater`, `isgreaterequal`, `isinf`, `isless`, `islessequal`, `islessgreater`, `isnan`, `isnormal`, `isunordered`, and `signbit` only support float and double arguments, not long double arguments.

`getitimer` and `setitimer` only support ITIMER_REAL for now.

`link` will copy the file if it can't implement a true hardlink. This is true at least for FAT and FAT32 filesystems. NTFS supports hardlinks.

`lseek` only works properly on binary files.

`setuid` is only safe against reverting the user switch after a call to one of the exec(2) functions took place. Windows doesn't support a non-revertable user switch within the context of Win32 processes.

`vfork` just calls `fork`.

`vhangup` always returns -1 and sets errno to ENOSYS.

The XSI IPC functions `semctl`, `semget`, `semop`, `shmat`, `shmctl`, `shmdt`, `shmget`, `msgctl`, `msgget`, `msgrcv` and `msgsnd` are only available when cygserver is running and the `CYGWIN` environment variable is set so that it contains the string `server`.

## Chapter 2. Cygwin Functions

These functions are specific to Cygwin itself, and probably won't be found anywhere else.

## cygwin_attach_handle_to_fd

`extern "C" int cygwin_attach_handle_to_fd(` | name, |
| fd, |
| handle, |
| bin, |
| access`)`; |

`char *name`;
`int fd`;
`HANDLE handle`;
`int bin`;
`int access`;

This function can be used to turn a Win32 "handle" into a posix-style file handle. `fd` may be -1 to make cygwin allocate a handle; the actual handle is returned in all cases.

## cygwin_conv_path

`extern "C" ssize_t cygwin_conv_path(` | what, |
| from, |
| to, |
| size`)`; |

`cygwin_conv_path_t what`;
`const void * from`;
`void * to`;
`size_t size`;

Use this function to convert POSIX paths in `from` to Win32 paths in `to` or, vice versa, Win32 paths in `from` to POSIX paths in `to`. `what` defines the direction of this conversion and can be any of the below values.

      CCP_POSIX_TO_WIN_A      /* from is char *posix, to is char *win32       */
      CCP_POSIX_TO_WIN_W,     /* from is char *posix, to is wchar_t *win32    */
      CCP_WIN_A_TO_POSIX,     /* from is char *win32, to is char *posix       */
      CCP_WIN_W_TO_POSIX,     /* from is wchar_t *win32, to is char *posix    */

You can additionally or the following values to `what`, to define whether you want the resulting path in `to` to be absolute or if you want to keep relative paths in relative notation. Creating absolute paths is the default.

      CCP_ABSOLUTE = 0,       /* Request absolute path (default).             */
      CCP_RELATIVE = 0x100    /* Request to keep path relative.               */

If `size` is 0, `cygwin_conv_path` just returns the required buffer size in bytes. Otherwise, it returns 0 on success, or -1 on error and errno is set to one of the below values.

        EINVAL        what has an invalid value.
        EFAULT        from or to point into nirvana.
        ENAMETOOLONG  the resulting path is longer than 32K, or, in case
                      of what == CCP_POSIX_TO_WIN_A, longer than MAX_PATH.
        ENOSPC        size is less than required for the conversion.

Example 2.1. Example use of cygwin_conv_path

    #include <sys/cygwin.h>

    /* Conversion from incoming Win32 path given as wchar_t *win32 to POSIX path.
       If incoming path is a relative path, stick to it.  First ask how big
       the output buffer has to be and allocate space dynamically. */
    ssize_t size;
    char *posix;
    size = cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_RELATIVE, win32, NULL, 0);
    if (size < 0)
      perror ("cygwin_conv_path");
    else
      {
        posix = (char *) malloc (size);
        if (cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_RELATIVE, win32,
                              posix, size))
          perror ("cygwin_conv_path");
      }

## cygwin_conv_path_list

`extern "C" ssize_t cygwin_conv_path(` | what, |
| from, |
| to, |
| size`)`; |

`cygwin_conv_path_t what`;
`const void * from`;
`void * to`;
`size_t size`;

This is the same as `cygwin_conv_path`, but the input is treated as a path list in $PATH or %PATH% notation.

If `what` is CCP_POSIX_TO_WIN_A or CCP_POSIX_TO_WIN_W, given a POSIX $PATH-style string (i.e. /foo:/bar) convert it to the equivalent Win32 %PATH%-style string (i.e. d:\;e:\bar).

If `what` is CCP_WIN_A_TO_POSIX or CCP_WIN_W_TO_POSIX, given a Win32 %PATH%-style string (i.e. d:\;e:\bar) convert it to the equivalent POSIX $PATH-style string (i.e. /foo:/bar).

See also cygwin_conv_path

## cygwin_create_path

`extern "C" void * cygwin_create_path(` | what, |
| from`)`; |

`cygwin_conv_path_t what`;
`const void * from`;

This is equivalent to the `cygwin_conv_path`, except that `cygwin_create_path` does not take a buffer pointer for the result of the conversion as input. Rather it allocates the buffer itself using `malloc`(3) and returns a pointer to this buffer. In case of error it returns NULL and sets errno to one of the values defined for `cygwin_conv_path`. Additionally errno can be set to the below value.

        ENOMEM        Insufficient memory was available.

When you don't need the returned buffer anymore, use `free`(3) to deallocate it.

See also cygwin_conv_path

## cygwin_detach_dll

`extern "C" void cygwin_detach_dll(` | dll_index`)`; |

`int dll_index`;

## cygwin_internal

`extern "C" DWORD cygwin_internal(` | t, |
| ...`)`; |

`cygwin_getinfo_types t`;
`...`;

This function gives you access to various internal data and functions. It takes two arguments. The first argument is a type from the 'cygwin_getinfo_types' enum. The second is an optional pointer.

Stay away unless you know what you're doing.

## cygwin_logon_user

`extern "C" HANDLE cygwin_logon_user(` | passwd_entry, |
| password`)`; |

`const struct passwd *passwd_entry`;
`const char *password`;

Given a pointer ot a passwd entry of a user and a cleartext password, returns a HANDLE to an impersonation token for this user which can be used in a subsequent call to `cygwin_set_impersonation_token` to impersonate that user. This function can only be called from a process which has the required NT user rights to perform a logon.

See also the chapter "New setuid concept" in the Cygwin user's guide.

See also cygwin_set_impersonation_token

## cygwin_posix_path_list_p

`extern "C" int posix_path_list_p(` | path`)`; |

`const char *path`;

This function tells you if the supplied `path` is a POSIX-style path (i.e. posix names, forward slashes, colon delimiters) or a Win32-style path (drive letters, reverse slashes, semicolon delimiters. The return value is true if the path is a POSIX path. Note that "_p" means "predicate", a lisp term meaning that the function tells you something about the parameter.

Rather than use a mode to say what the "proper" path list format is, we allow any, and give apps the tools they need to convert between the two. If a ';' is present in the path list it's a Win32 path list. Otherwise, if the first path begins with [letter]: (in which case it can be the only element since if it wasn't a ';' would be present) it's a Win32 path list. Otherwise, it's a POSIX path list.

## cygwin_set_impersonation_token

`extern "C" void cygwin_set_impersonation_token(` | token`)`; |

`const HANDLE token`;

Use this function to enable the token given as parameter as impersonation token for the next call to `setuid` or `seteuid`. Use `cygwin_set_impersonation_token` together with `cygwin_logon_user` to impersonate users using password authentication.

See also the chapter "New setuid concept" in the Cygwin user's guide.

See also cygwin_logon_user

## cygwin_split_path

`extern "C" void cygwin_split_path (` | path, |
| dir, |
| file`)`; |

`const char * path`;
`char * dir`;
`char * file`;

Split a path into the directory and the file portions. Both `dir` and `file` are expected to point to buffers of sufficient size.

Example 2.2. Example use of cygwin_split_path

    char dir[200], file[100];
    cygwin_split_path("c:/foo/bar.c", dir, file);
    printf("dir=%s, file=%s\n", dir, file);

## cygwin_stackdump

`extern "C" void cygwin_stackdump(` | `)`; |

Outputs a stackdump to stderr from the called location.

## cygwin_winpid_to_pid

`extern "C" pid_t cygwin_winpid_to_pid (` | winpid`)`; |

`int winpid`;

Given a windows pid, converts to the corresponding Cygwin pid, if any. Returns -1 if windows pid does not correspond to a cygwin pid.

Example 2.3. Example use of cygwin_winpid_to_pid

          extern "C" cygwin_winpid_to_pid (int winpid);
          pid_t mypid;
          mypid = cygwin_winpid_to_pid (windows_pid);