/***********************************************************************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*/2627#include "univlib.h"2829#ifdef UNIV_MAX3031#include <ctype.h>3233#endif3435/*36* return external representation for symbolic link text of name in buf37* the link text string length is returned38*/3940int41pathgetlink(const char* name, char* buf, int siz)42{43int n;4445if ((n = readlink(name, buf, siz)) < 0) return(-1);46if (n >= siz)47{48errno = EINVAL;49return(-1);50}51buf[n] = 0;52#ifdef UNIV_MAX53if (isspace(*buf))54{55register char* s;56register char* t;57register char* u;58register char* v;59int match = 0;60char tmp[PATH_MAX];6162s = buf;63t = tmp;64while (isalnum(*++s) || *s == '_' || *s == '.');65if (*s++)66{67for (;;)68{69if (!*s || isspace(*s))70{71if (match)72{73*t = 0;74n = t - tmp;75strcpy(buf, tmp);76}77break;78}79if (t >= &tmp[sizeof(tmp)]) break;80*t++ = *s++;81if (!match && t < &tmp[sizeof(tmp) - univ_size + 1]) for (n = 0; n < UNIV_MAX; n++)82{83if (*(v = s - 1) == *(u = univ_name[n]))84{85while (*u && *v++ == *u) u++;86if (!*u)87{88match = 1;89strcpy(t - 1, univ_cond);90t += univ_size - 1;91s = v;92break;93}94}95}96}97}98}99#endif100return(n);101}102103104