1N/A/***********************************************************************
1N/A* *
1N/A* This software is part of the ast package *
1N/A* Copyright (c) 1985-2011 AT&T Intellectual Property *
1N/A* and is licensed under the *
1N/A* Common Public License, Version 1.0 *
1N/A* by AT&T Intellectual Property *
1N/A* *
1N/A* A copy of the License is available at *
1N/A* http://www.opensource.org/licenses/cpl1.0.txt *
1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
1N/A* *
1N/A* Information and Software Systems Research *
1N/A* AT&T Research *
1N/A* Florham Park NJ *
1N/A* *
1N/A* Glenn Fowler <gsf@research.att.com> *
1N/A* David Korn <dgk@research.att.com> *
1N/A* Phong Vo <kpv@research.att.com> *
1N/A* *
1N/A***********************************************************************/
1N/A#pragma prototyped
1N/A/*
1N/A * Glenn Fowler
1N/A * AT&T Research
1N/A *
1N/A * convert path to native fs representation in <buf,siz>
1N/A * length of converted path returned
1N/A * if return length >= siz then buf is indeterminate, but another call
1N/A * with siz=length+1 would work
1N/A * if buf==0 then required size is returned
1N/A */
1N/A
1N/A#include <ast.h>
1N/A
1N/A#if _UWIN
1N/A
1N/Aextern int uwin_path(const char*, char*, int);
1N/A
1N/Asize_t
1N/Apathnative(const char* path, char* buf, size_t siz)
1N/A{
1N/A return uwin_path(path, buf, siz);
1N/A}
1N/A
1N/A#else
1N/A
1N/A#if __CYGWIN__
1N/A
1N/Aextern void cygwin_conv_to_win32_path(const char*, char*);
1N/A
1N/Asize_t
1N/Apathnative(const char* path, char* buf, size_t siz)
1N/A{
1N/A size_t n;
1N/A
1N/A if (!buf || siz < PATH_MAX)
1N/A {
1N/A char tmp[PATH_MAX];
1N/A
1N/A cygwin_conv_to_win32_path(path, tmp);
1N/A if ((n = strlen(tmp)) < siz && buf)
1N/A memcpy(buf, tmp, n + 1);
1N/A return n;
1N/A }
1N/A cygwin_conv_to_win32_path(path, buf);
1N/A return strlen(buf);
1N/A}
1N/A
1N/A#else
1N/A
1N/A#if __EMX__
1N/A
1N/Asize_t
1N/Apathnative(const char* path, char* buf, size_t siz)
1N/A{
1N/A char* s;
1N/A size_t n;
1N/A
1N/A if (!_fullpath(buf, path, siz))
1N/A {
1N/A for (s = buf; *s; s++)
1N/A if (*s == '/')
1N/A *s = '\\';
1N/A }
1N/A else if ((n = strlen(path)) < siz && buf)
1N/A memcpy(buf, path, n + 1);
1N/A return n;
1N/A}
1N/A
1N/A#else
1N/A
1N/A#if __INTERIX
1N/A
1N/A#include <interix/interix.h>
1N/A
1N/Asize_t
1N/Apathnative(const char* path, char* buf, size_t siz)
1N/A{
1N/A *buf = 0;
1N/A if (path[1] == ':')
1N/A strlcpy(buf, path, siz);
1N/A else
1N/A unixpath2win(path, 0, buf, siz);
1N/A return strlen(buf);
1N/A}
1N/A
1N/A#else
1N/A
1N/Asize_t
1N/Apathnative(const char* path, char* buf, size_t siz)
1N/A{
1N/A size_t n;
1N/A
1N/A if ((n = strlen(path)) < siz && buf)
1N/A memcpy(buf, path, n + 1);
1N/A return n;
1N/A}
1N/A
1N/A#endif
1N/A
1N/A#endif
1N/A
1N/A#endif
1N/A
1N/A#endif