/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1990-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* *18***********************************************************************/19#pragma prototyped20/*21* Glenn Fowler22* AT&T Research23*24* run time cs var support25*/2627#include "cslib.h"2829#ifndef TRUST30#define TRUST "/usr/local:/usr" /* trusted root dirs */31#endif3233typedef struct34{35const char* name;36const char* trust;37const char* value;38} Var_t;3940static Var_t var[] =41{4243{ /* CS_VAR_LOCAL */ "CS_MOUNT_LOCAL", "/tmp/cs" },44{ /* CS_VAR_PROXY */ "CS_MOUNT_PROXY", "/dev/tcp/proxy/inet.proxy" },45{ /* CS_VAR_SHARE */ "CS_MOUNT_SHARE", "share/lib/cs" },46{ /* CS_VAR_TRUST */ "CS_MOUNT_TRUST", TRUST },4748};4950char*51csvar(Cs_t* state, int index, int trust)52{53register char* s;54register Var_t* p;5556if (index < 0 || index >= elementsof(var))57return 0;58p = &var[index];59if (!p->name || trust)60return (char*)p->trust;61if (!p->value)62p->value = ((s = getenv(p->name)) && *s) ? (const char*)s : p->trust;63return (char*)p->value;64}6566char*67_cs_var(int index, int trust)68{69return csvar(&cs, index, trust);70}717273