/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped22/*23* Glenn Fowler24* AT&T Bell Laboratories25*26* single dir support for pathaccess()27*/2829#define _AST_API_H 13031#include <ast.h>3233/*34* building 3d flirts with the dark side35*/3637#if _BLD_3d3839#undef pathcat40#define pathcat_20100601 _3d_pathcat4142#else4344char*45pathcat(char* path, const char* dirs, int sep, const char* a, const char* b)46{47return pathcat_20100601(dirs, sep, a, b, path, PATH_MAX);48}4950#endif5152#undef _AST_API5354#include <ast_api.h>5556char*57pathcat_20100601(register const char* dirs, int sep, const char* a, register const char* b, char* path, size_t size)58{59register char* s;60register char* e;6162s = path;63e = path + size;64while (*dirs && *dirs != sep)65{66if (s >= e)67return 0;68*s++ = *dirs++;69}70if (s != path)71{72if (s >= e)73return 0;74*s++ = '/';75}76if (a)77{78while (*s = *a++)79if (++s >= e)80return 0;81if (b)82{83if (s >= e)84return 0;85*s++ = '/';86}87}88else if (!b)89b = ".";90if (b)91do92{93if (s >= e)94return 0;95} while (*s++ = *b++);96return *dirs ? (char*)++dirs : 0;97}9899100