From 4440a86cfa359b8e40a484a2cd46d33db5455d8a Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Mon, 25 May 2020 20:09:04 +0200 Subject: Initial --- irc/str.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 irc/str.c (limited to 'irc/str.c') diff --git a/irc/str.c b/irc/str.c new file mode 100644 index 0000000..aaff546 --- /dev/null +++ b/irc/str.c @@ -0,0 +1,84 @@ +/************************************************************************ + * IRC - Internet Relay Chat, irc/str.c + * Copyright (C) 1990 Jarkko Oikarinen and + * University of Oulu, Computing Center + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef lint +static char rcsid[] = "@(#)$Id: str.c,v 1.2 1997/09/03 17:45:43 kalt Exp $"; +#endif + +#include "os.h" +#include "c_defines.h" +#define STR_C +#include "c_externs.h" +#undef STR_C + +char * center(buf,str,len) +char *buf, *str; +int len; +{ + char i,j,k; + if ((i = strlen(str)) > len) { + buf[len-1] = '\0'; + for(len--; len > 0; len--) buf[len-1] = str[len-1]; + return(buf); + } + j = (len-i)/2; + for (k=0; k, 16 March 1989 */ +char * +real_name(user) + struct passwd *user; +{ + char *bp, *cp; + static char name[REALLEN+1]; + + bp = user->pw_gecos; + cp = name; + + name[REALLEN] = '\0'; + do { + switch(*bp) { + case '&': + *cp = '\0'; + strncat(name, user->pw_name, REALLEN-strlen(name)); + name[REALLEN] = '\0'; + *cp = toupper(*cp); + cp = index(name, '\0'); + bp++; + break; + case ',': + *bp = *cp = '\0'; + break; + case '\0': + *cp = *bp; + break; + default: + *cp++ = *bp++; + } + } while (*bp != '\0' && strlen(name) < (size_t) REALLEN); + return(name); +} + -- cgit v1.2.3