/***********************************************************************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* return Sfio_t stream pointer to host info file25* if line!=0 then it points to current line number in file26*/2728#include "cslib.h"2930Sfio_t*31csinfo(register Cs_t* state, const char* file, int* line)32{33int n;34Sfio_t* sp = 0;35char buf[PATH_MAX];36char tmp[PATH_MAX];37struct stat st;3839messagef((state->id, NiL, -8, "info(%s) call", file));40if (!file || streq(file, "-")) file = CS_SVC_INFO;41if (strmatch(file, "*[ \t\n=]*")) sp = tokline(file, SF_STRING, line);42else if (!strchr(file, '/') || stat(file, &st) || S_ISDIR(st.st_mode) || !(sp = tokline(file, SF_READ, line)))43for (n = 0; n <= 1; n++)44{45sfsprintf(tmp, sizeof(tmp), "%s/%s", n ? csvar(state, CS_VAR_SHARE, 0) : CS_SVC_DIR, file);46if (pathpath(tmp, "", PATH_REGULAR|PATH_READ, buf, sizeof(buf)))47{48sp = tokline(buf, SF_READ, line);49break;50}51}52if (!sp) messagef((state->id, NiL, -1, "info: %s: not found", file));53return sp;54}5556Sfio_t*57_cs_info(const char* file, int* line)58{59return csinfo(&cs, file, line);60}616263