tc.vers.c revision 100616
1100616Smp/* $Header: /src/pub/tcsh/tc.vers.c,v 3.49 2002/05/16 13:51:26 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
36100616SmpRCSID("$Id: tc.vers.c,v 3.49 2002/05/16 13:51:26 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
4659243Sobrienfix_version()
4759243Sobrien{
4859243Sobrien#ifdef SHORT_STRINGS
4959243Sobrien# define SSSTR "8b"
5059243Sobrien#else
5159243Sobrien# define SSSTR "7b"
5259243Sobrien#endif
5359243Sobrien#ifdef NLS
5459243Sobrien# define NLSSTR ",nls"
5559243Sobrien#else
5659243Sobrien# define NLSSTR ""
5759243Sobrien#endif
5859243Sobrien#ifdef LOGINFIRST
5959243Sobrien# define LFSTR ",lf"
6059243Sobrien#else
6159243Sobrien# define LFSTR ""
6259243Sobrien#endif
6359243Sobrien#ifdef DOTLAST
6459243Sobrien# define DLSTR ",dl"
6559243Sobrien#else
6659243Sobrien# define DLSTR ""
6759243Sobrien#endif
6859243Sobrien#ifdef VIDEFAULT
6959243Sobrien# define VISTR ",vi"
7059243Sobrien#else
7159243Sobrien# define VISTR ""
7259243Sobrien#endif
7359243Sobrien#ifdef TESLA
7459243Sobrien# define DTRSTR ",dtr"
7559243Sobrien#else
7659243Sobrien# define DTRSTR ""
7759243Sobrien#endif
7859243Sobrien#ifdef KAI
7959243Sobrien# define BYESTR ",bye"
8059243Sobrien#else
8159243Sobrien# define BYESTR ""
8259243Sobrien#endif
8359243Sobrien#ifdef AUTOLOGOUT
8459243Sobrien# define ALSTR ",al"
8559243Sobrien#else
8659243Sobrien# define ALSTR ""
8759243Sobrien#endif
8859243Sobrien#ifdef KANJI
8959243Sobrien# define KANSTR ",kan"
9059243Sobrien#else
9159243Sobrien# define KANSTR ""
9259243Sobrien#endif
9359243Sobrien#ifdef SYSMALLOC
9459243Sobrien# define SMSTR	",sm"
9559243Sobrien#else
9659243Sobrien# define SMSTR  ""
9759243Sobrien#endif
9859243Sobrien#ifdef HASHBANG
9959243Sobrien# define HBSTR	",hb"
10059243Sobrien#else
10159243Sobrien# define HBSTR  ""
10259243Sobrien#endif
10359243Sobrien#ifdef NEWGRP
10459243Sobrien# define NGSTR	",ng"
10559243Sobrien#else
10659243Sobrien# define NGSTR	""
10759243Sobrien#endif
10859243Sobrien#ifdef REMOTEHOST
10959243Sobrien# define RHSTR	",rh"
11059243Sobrien#else
11159243Sobrien# define RHSTR	""
11259243Sobrien#endif
11359243Sobrien#ifdef AFS
11459243Sobrien# define AFSSTR	",afs"
11559243Sobrien#else
11659243Sobrien# define AFSSTR	""
11759243Sobrien#endif
11859243Sobrien#ifdef NODOT
11959243Sobrien# define NDSTR	",nd"
12059243Sobrien#else
12159243Sobrien# define NDSTR	""
12259243Sobrien#endif
12359243Sobrien#ifdef COLOR_LS_F
12459243Sobrien# define COLORSTR ",color"
12559243Sobrien#else /* ifndef COLOR_LS_F */
12659243Sobrien# define COLORSTR ""
12759243Sobrien#endif /* COLOR_LS_F */
12859243Sobrien#ifdef DSPMBYTE
12959243Sobrien# define DSPMSTR ",dspm"
13059243Sobrien#else
13159243Sobrien# define DSPMSTR ""
13259243Sobrien#endif
13359243Sobrien#ifdef COLORCAT
13459243Sobrien# define CCATSTR ",ccat"
13559243Sobrien#else
13659243Sobrien# define CCATSTR ""
13759243Sobrien#endif
138100616Smp#if defined(FILEC) && defined(TIOCSTI)
139100616Smp# define FILECSTR ",filec"
140100616Smp#else
141100616Smp# define FILECSTR ""
142100616Smp#endif
14359243Sobrien/* if you want your local version to say something */
14459243Sobrien#ifndef LOCALSTR
14559243Sobrien# define LOCALSTR ""
14659243Sobrien#endif /* LOCALSTR */
14759243Sobrien    char    version[BUFSIZE];
14859243Sobrien    Char    *machtype = tgetenv(STRMACHTYPE);
14959243Sobrien    Char    *vendor   = tgetenv(STRVENDOR);
15059243Sobrien    Char    *ostype   = tgetenv(STROSTYPE);
15159243Sobrien
15259243Sobrien    if (vendor == NULL)
15359243Sobrien	vendor = STRunknown;
15459243Sobrien    if (machtype == NULL)
15559243Sobrien	machtype = STRunknown;
15659243Sobrien    if (ostype == NULL)
15759243Sobrien	ostype = STRunknown;
15859243Sobrien
15959243Sobrien
16059243Sobrien    (void) xsnprintf(version, sizeof(version),
161100616Smp"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",
16259243Sobrien	     REV, VERS, PATCHLEVEL, ORIGIN, DATE, machtype, vendor, ostype,
16359243Sobrien	     SSSTR, NLSSTR, LFSTR, DLSTR, VISTR, DTRSTR, BYESTR,
16459243Sobrien	     ALSTR, KANSTR, SMSTR, HBSTR, NGSTR, RHSTR, AFSSTR, NDSTR,
165100616Smp	     COLORSTR, DSPMSTR, CCATSTR, FILECSTR, LOCALSTR);
16659243Sobrien    set(STRversion, SAVE(version), VAR_READWRITE);
16759243Sobrien    (void) xsnprintf(version, sizeof(version), "%d.%.2d.%.2d",
16859243Sobrien		     REV, VERS, PATCHLEVEL);
16959243Sobrien    set(STRtcsh, SAVE(version), VAR_READWRITE);
17059243Sobrien}
171