1167465Smp/* $Header: /p/tcsh/cvsroot/tcsh/tc.vers.c,v 3.54 2006/03/02 18:46:45 christos Exp $ */ 259243Sobrien/* 359243Sobrien * tc.vers.c: Version dependent stuff 459243Sobrien */ 559243Sobrien/*- 659243Sobrien * Copyright (c) 1980, 1991 The Regents of the University of California. 759243Sobrien * All rights reserved. 859243Sobrien * 959243Sobrien * Redistribution and use in source and binary forms, with or without 1059243Sobrien * modification, are permitted provided that the following conditions 1159243Sobrien * are met: 1259243Sobrien * 1. Redistributions of source code must retain the above copyright 1359243Sobrien * notice, this list of conditions and the following disclaimer. 1459243Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1559243Sobrien * notice, this list of conditions and the following disclaimer in the 1659243Sobrien * documentation and/or other materials provided with the distribution. 17100616Smp * 3. Neither the name of the University nor the names of its contributors 1859243Sobrien * may be used to endorse or promote products derived from this software 1959243Sobrien * without specific prior written permission. 2059243Sobrien * 2159243Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2259243Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2359243Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2459243Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2559243Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2659243Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2759243Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2859243Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2959243Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3059243Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3159243Sobrien * SUCH DAMAGE. 3259243Sobrien */ 3359243Sobrien#include "sh.h" 3459243Sobrien#include "tw.h" 3559243Sobrien 36167465SmpRCSID("$tcsh: tc.vers.c,v 3.54 2006/03/02 18:46:45 christos Exp $") 3759243Sobrien 3859243Sobrien#include "patchlevel.h" 3959243Sobrien 4059243Sobrien 4159243Sobrien/* fix_version(): 4259243Sobrien * Print a reasonable version string, printing all compile time 4359243Sobrien * options that might affect the user. 4459243Sobrien */ 4559243Sobrienvoid 46167465Smpfix_version(void) 4759243Sobrien{ 48145479Smp#ifdef WIDE_STRINGS 49145479Smp# define SSSTR "wide" 50145479Smp#elif defined (SHORT_STRINGS) 5159243Sobrien# define SSSTR "8b" 5259243Sobrien#else 5359243Sobrien# define SSSTR "7b" 5459243Sobrien#endif 5559243Sobrien#ifdef NLS 5659243Sobrien# define NLSSTR ",nls" 5759243Sobrien#else 5859243Sobrien# define NLSSTR "" 5959243Sobrien#endif 6059243Sobrien#ifdef LOGINFIRST 6159243Sobrien# define LFSTR ",lf" 6259243Sobrien#else 6359243Sobrien# define LFSTR "" 6459243Sobrien#endif 6559243Sobrien#ifdef DOTLAST 6659243Sobrien# define DLSTR ",dl" 6759243Sobrien#else 6859243Sobrien# define DLSTR "" 6959243Sobrien#endif 7059243Sobrien#ifdef VIDEFAULT 7159243Sobrien# define VISTR ",vi" 7259243Sobrien#else 7359243Sobrien# define VISTR "" 7459243Sobrien#endif 7559243Sobrien#ifdef TESLA 7659243Sobrien# define DTRSTR ",dtr" 7759243Sobrien#else 7859243Sobrien# define DTRSTR "" 7959243Sobrien#endif 8059243Sobrien#ifdef KAI 8159243Sobrien# define BYESTR ",bye" 8259243Sobrien#else 8359243Sobrien# define BYESTR "" 8459243Sobrien#endif 8559243Sobrien#ifdef AUTOLOGOUT 8659243Sobrien# define ALSTR ",al" 8759243Sobrien#else 8859243Sobrien# define ALSTR "" 8959243Sobrien#endif 9059243Sobrien#ifdef KANJI 9159243Sobrien# define KANSTR ",kan" 9259243Sobrien#else 9359243Sobrien# define KANSTR "" 9459243Sobrien#endif 9559243Sobrien#ifdef SYSMALLOC 9659243Sobrien# define SMSTR ",sm" 9759243Sobrien#else 9859243Sobrien# define SMSTR "" 9959243Sobrien#endif 10059243Sobrien#ifdef HASHBANG 10159243Sobrien# define HBSTR ",hb" 10259243Sobrien#else 10359243Sobrien# define HBSTR "" 10459243Sobrien#endif 10559243Sobrien#ifdef NEWGRP 10659243Sobrien# define NGSTR ",ng" 10759243Sobrien#else 10859243Sobrien# define NGSTR "" 10959243Sobrien#endif 11059243Sobrien#ifdef REMOTEHOST 11159243Sobrien# define RHSTR ",rh" 11259243Sobrien#else 11359243Sobrien# define RHSTR "" 11459243Sobrien#endif 11559243Sobrien#ifdef AFS 11659243Sobrien# define AFSSTR ",afs" 11759243Sobrien#else 11859243Sobrien# define AFSSTR "" 11959243Sobrien#endif 12059243Sobrien#ifdef NODOT 12159243Sobrien# define NDSTR ",nd" 12259243Sobrien#else 12359243Sobrien# define NDSTR "" 12459243Sobrien#endif 12559243Sobrien#ifdef COLOR_LS_F 12659243Sobrien# define COLORSTR ",color" 12759243Sobrien#else /* ifndef COLOR_LS_F */ 12859243Sobrien# define COLORSTR "" 12959243Sobrien#endif /* COLOR_LS_F */ 13059243Sobrien#ifdef DSPMBYTE 13159243Sobrien# define DSPMSTR ",dspm" 13259243Sobrien#else 13359243Sobrien# define DSPMSTR "" 13459243Sobrien#endif 13559243Sobrien#ifdef COLORCAT 13659243Sobrien# define CCATSTR ",ccat" 13759243Sobrien#else 13859243Sobrien# define CCATSTR "" 13959243Sobrien#endif 140100616Smp#if defined(FILEC) && defined(TIOCSTI) 141100616Smp# define FILECSTR ",filec" 142100616Smp#else 143100616Smp# define FILECSTR "" 144100616Smp#endif 14559243Sobrien/* if you want your local version to say something */ 14659243Sobrien#ifndef LOCALSTR 14759243Sobrien# define LOCALSTR "" 14859243Sobrien#endif /* LOCALSTR */ 149167465Smp char *version; 150167465Smp const Char *machtype = tgetenv(STRMACHTYPE); 151167465Smp const Char *vendor = tgetenv(STRVENDOR); 152167465Smp const Char *ostype = tgetenv(STROSTYPE); 15359243Sobrien 15459243Sobrien if (vendor == NULL) 15559243Sobrien vendor = STRunknown; 15659243Sobrien if (machtype == NULL) 15759243Sobrien machtype = STRunknown; 15859243Sobrien if (ostype == NULL) 15959243Sobrien ostype = STRunknown; 16059243Sobrien 16159243Sobrien 162167465Smp version = xasprintf( 163100616Smp"tcsh %d.%.2d.%.2d (%s) %s (%S-%S-%S) options %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", 16459243Sobrien REV, VERS, PATCHLEVEL, ORIGIN, DATE, machtype, vendor, ostype, 16559243Sobrien SSSTR, NLSSTR, LFSTR, DLSTR, VISTR, DTRSTR, BYESTR, 16659243Sobrien ALSTR, KANSTR, SMSTR, HBSTR, NGSTR, RHSTR, AFSSTR, NDSTR, 167100616Smp COLORSTR, DSPMSTR, CCATSTR, FILECSTR, LOCALSTR); 168167465Smp cleanup_push(version, xfree); 169167465Smp setcopy(STRversion, str2short(version), VAR_READWRITE); 170167465Smp cleanup_until(version); 171167465Smp version = xasprintf("%d.%.2d.%.2d", REV, VERS, PATCHLEVEL); 172167465Smp cleanup_push(version, xfree); 173167465Smp setcopy(STRtcsh, str2short(version), VAR_READWRITE); 174167465Smp cleanup_until(version); 17559243Sobrien} 176