1217309Snwhitehorn/* 2251843Sbapt * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H��gskolan 3217309Snwhitehorn * (Royal Institute of Technology, Stockholm, Sweden). 4217309Snwhitehorn * All rights reserved. 5217309Snwhitehorn * 6251843Sbapt * Redistribution and use in source and binary forms, with or without 7217309Snwhitehorn * modification, are permitted provided that the following conditions 8217309Snwhitehorn * are met: 9217309Snwhitehorn * 10217309Snwhitehorn * 1. Redistributions of source code must retain the above copyright 11217309Snwhitehorn * notice, this list of conditions and the following disclaimer. 12217309Snwhitehorn * 13217309Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright 14217309Snwhitehorn * notice, this list of conditions and the following disclaimer in the 15217309Snwhitehorn * documentation and/or other materials provided with the distribution. 16217309Snwhitehorn * 17217309Snwhitehorn * 3. Neither the name of the Institute nor the names of its contributors 18217309Snwhitehorn * may be used to endorse or promote products derived from this software 19217309Snwhitehorn * without specific prior written permission. 20217309Snwhitehorn * 21217309Snwhitehorn * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 22217309Snwhitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23217309Snwhitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24217309Snwhitehorn * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 25217309Snwhitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26217309Snwhitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27217309Snwhitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28217309Snwhitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29217309Snwhitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30217309Snwhitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31217309Snwhitehorn * SUCH DAMAGE. 32217309Snwhitehorn */ 33217309Snwhitehorn 34217309Snwhitehorn#include "login_locl.h" 35217309Snwhitehorn 36217309SnwhitehornRCSID("$Id$"); 37217309Snwhitehorn 38217309Snwhitehorn/* 39217309Snwhitehorn * Clean the tty name. Return a pointer to the cleaned version. 40217309Snwhitehorn */ 41217309Snwhitehorn 42217309Snwhitehornchar * 43217309Snwhitehornclean_ttyname (char *tty) 44217309Snwhitehorn{ 45217309Snwhitehorn char *res = tty; 46251843Sbapt 47251843Sbapt if (strncmp (res, _PATH_DEV, strlen(_PATH_DEV)) == 0) 48251843Sbapt res += strlen(_PATH_DEV); 49251843Sbapt if (strncmp (res, "pty/", 4) == 0) 50217309Snwhitehorn res += 4; 51217309Snwhitehorn if (strncmp (res, "ptym/", 5) == 0) 52217309Snwhitehorn res += 5; 53217309Snwhitehorn return res; 54217309Snwhitehorn} 55217309Snwhitehorn 56217309Snwhitehorn/* 57217309Snwhitehorn * Generate a name usable as an `ut_id', typically without `tty'. 58217309Snwhitehorn */ 59217309Snwhitehorn 60217309Snwhitehornchar * 61217309Snwhitehornmake_id (char *tty) 62217309Snwhitehorn{ 63217309Snwhitehorn char *res = tty; 64217309Snwhitehorn 65217309Snwhitehorn if (strncmp (res, "pts/", 4) == 0) 66217309Snwhitehorn res += 4; 67217309Snwhitehorn if (strncmp (res, "tty", 3) == 0) 68217309Snwhitehorn res += 3; 69217309Snwhitehorn return res; 70217309Snwhitehorn} 71217309Snwhitehorn