2 Get the local name to use from the Taylor UUCP configuration files.
4 Copyright (C) 1992 Ian Lance Taylor
6 This file is part of the Taylor UUCP uuconf library.
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public License
10 as published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
18 You should have received a copy of the GNU Library General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 The author of the program may be contacted at ian@airs.com or
23 c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
29 const char _uuconf_tlocnm_rcsid[] = "$FreeBSD$";
34 /* Get the local name to use, based on the login name, from the Taylor
35 UUCP configuration files. This could probably be done in a
36 slightly more intelligent fashion, but no matter what it has to
37 read the systems files. */
40 uuconf_taylor_login_localname (pglobal, zlogin, pzname)
45 struct sglobal *qglobal = (struct sglobal *) pglobal;
49 if (! qglobal->qprocess->fread_syslocs)
51 iret = _uuconf_iread_locations (qglobal);
52 if (iret != UUCONF_SUCCESS)
56 /* As a simple optimization, if there is no "myname" command we can
57 simply return immediately. */
58 if (! qglobal->qprocess->fuses_myname)
61 return UUCONF_NOT_FOUND;
64 iret = uuconf_taylor_system_names (pglobal, &pznames, 0);
65 if (iret != UUCONF_SUCCESS)
69 iret = UUCONF_NOT_FOUND;
71 for (pz = pznames; *pz != NULL; pz++)
73 struct uuconf_system ssys;
74 struct uuconf_system *qsys;
76 iret = uuconf_system_info (pglobal, *pz, &ssys);
77 if (iret != UUCONF_SUCCESS)
80 for (qsys = &ssys; qsys != NULL; qsys = qsys->uuconf_qalternate)
82 if (qsys->uuconf_zlocalname != NULL
83 && qsys->uuconf_fcalled
84 && qsys->uuconf_zcalled_login != NULL
85 && strcmp (qsys->uuconf_zcalled_login, zlogin) == 0)
87 *pzname = strdup (qsys->uuconf_zlocalname);
89 iret = UUCONF_SUCCESS;
92 qglobal->ierrno = errno;
93 iret = UUCONF_MALLOC_FAILED | UUCONF_ERROR_ERRNO;
99 (void) uuconf_system_free (pglobal, &ssys);
104 iret = UUCONF_NOT_FOUND;
107 for (pz = pznames; *pz != NULL; pz++)
108 free ((pointer) *pz);
109 free ((pointer) pznames);