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