source: vis_dev/vis-2.3/src/vm/vmVers.c @ 64

Last change on this file since 64 was 14, checked in by cecile, 13 years ago

vis2.3

File size: 6.8 KB
Line 
1/**CFile***********************************************************************
2
3  FileName    [vmVers.c]
4
5  PackageName [vm]
6
7  Synopsis    [Supplies the compile date and version information.]
8
9  Author      [Originated from SIS]
10
11  Copyright   [Copyright (c) 1994-1996 The Regents of the Univ. of California.
12  All rights reserved.
13
14  Permission is hereby granted, without written agreement and without license
15  or royalty fees, to use, copy, modify, and distribute this software and its
16  documentation for any purpose, provided that the above copyright notice and
17  the following two paragraphs appear in all copies of this software.
18
19  IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
20  DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
21  OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
22  CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
24  THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
25  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
26  FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN
27  "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE
28  MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.]
29
30******************************************************************************/
31
32#include "vmInt.h"
33
34static char rcsid[] UNUSED = "$Id: vmVers.c,v 1.3 2002/09/08 21:47:31 fabio Exp $";
35
36/*---------------------------------------------------------------------------*/
37/* Constant declarations                                                     */
38/*---------------------------------------------------------------------------*/
39#ifndef CUR_DATE
40#define CUR_DATE        "<compile date not supplied>"
41#endif
42
43#ifndef CUR_VER
44#define CUR_VER         "UC Berkeley, VIS Release 1.0"
45#endif
46
47#ifndef LIBRARY
48#define LIBRARY         "/projects/vis/vis/common/vis_lib"
49#endif
50
51
52/**AutomaticStart*************************************************************/
53
54/*---------------------------------------------------------------------------*/
55/* Static function prototypes                                                */
56/*---------------------------------------------------------------------------*/
57
58static char * DateReadFromDateString(char * datestr);
59
60/**AutomaticEnd***************************************************************/
61
62
63/*---------------------------------------------------------------------------*/
64/* Definition of exported functions                                          */
65/*---------------------------------------------------------------------------*/
66
67
68/**Function********************************************************************
69
70  Synopsis    [Returns the current VIS version.]
71
72  Description [Returns a static string giving the VIS version and compile
73  timestamp.  The user should not free this string.]
74 
75  SideEffects []
76
77  SeeAlso     [Vm_VisObtainLibrary]
78
79******************************************************************************/
80char *
81Vm_VisReadVersion(void)
82{
83  static char version[1024];
84
85  (void) sprintf(version, "%s (compiled %s)", CUR_VER, DateReadFromDateString(CUR_DATE));
86  return version;
87}
88
89
90/**Function********************************************************************
91
92  Synopsis    [Returns the VIS library path.]
93
94  Description [Returns a string giving the directory which contains the
95  standard VIS library.  Used to find things like the default .visrc, the
96  on-line help files, etc. It is the responsibility of the user to free the
97  returned string.]
98
99  SideEffects []
100
101  SeeAlso     [Vm_VisReadVersion]
102
103******************************************************************************/
104char *
105Vm_VisObtainLibrary(void)
106{
107  char * vis_lib_path;
108
109  vis_lib_path = getenv("VIS_LIBRARY_PATH");
110  if (vis_lib_path) {
111    return util_tilde_expand(vis_lib_path);
112  } else {
113    return util_tilde_expand(LIBRARY);
114  }
115}
116
117/**Function********************************************************************
118
119  Synopsis           [Start piping stdout through the "more" command]
120
121  Description        [This function is  called to initialize piping
122  stdout through "more". It is important to call Vm_VisEndPrintMore before
123  returning from your function and after
124  calling Vm_VisInitPrintMore (preferably at the end of your printing;
125  failing to do so will cause the stdin lines not to appear).]
126
127  SideEffects        []
128
129  SeeAlso            [ Vm_VisEndPrintMore]
130
131******************************************************************************/
132void
133Vm_VisInitPrintMore(void)
134{
135    fflush(vis_stdout);
136    vis_stdpipe = popen("more","w"); 
137}
138/**Function********************************************************************
139
140  Synopsis           [Stop piping stdout through the "more" command]
141
142  Description        [This function is  called to terminate piping
143  stdout through "more". It is important to call Vm_VisEndPrintMore  before exiting
144  your function (preferably at the end of your printing; failing to do so will cause
145  the stdin lines not to appear). The function returns a 0 if it fails.]
146
147  SideEffects        []
148
149  SeeAlso            [ Vm_VisInitPrintMore]
150
151******************************************************************************/
152int
153Vm_VisEndPrintMore(void)
154{
155    if (vis_stdpipe != NIL(FILE)) { 
156    (void) pclose(vis_stdpipe);
157    return 1;
158    }
159    return 0;
160}
161
162/*---------------------------------------------------------------------------*/
163/* Definition of internal functions                                          */
164/*---------------------------------------------------------------------------*/
165
166
167/*---------------------------------------------------------------------------*/
168/* Definition of static functions                                            */
169/*---------------------------------------------------------------------------*/
170
171/**Function********************************************************************
172
173  Synopsis    [Returns the date in a brief format assuming its coming from
174  the program `date'.]
175
176  Description [optional]
177
178  SideEffects []
179
180******************************************************************************/
181static char *
182DateReadFromDateString(
183  char * datestr)
184{
185  static char result[25];
186  char        day[10];
187  char        month[10];
188  char        zone[10];
189  char       *at;
190  int         date;
191  int         hour;
192  int         minute;
193  int         second;
194  int         year;
195
196  if (sscanf(datestr, "%s %s %2d %2d:%2d:%2d %s %4d",
197             day, month, &date, &hour, &minute, &second, zone, &year) == 8) {
198    if (hour >= 12) {
199      if (hour >= 13) hour -= 12;
200      at = "PM";
201    }
202    else {
203      if (hour == 0) hour = 12;
204      at = "AM";
205    }
206    (void) sprintf(result, "%d-%3s-%02d at %d:%02d %s", 
207                   date, month, year % 100, hour, minute, at);
208    return result;
209  }
210  else {
211    return datestr;
212  }
213}
214
215
216
217
218
Note: See TracBrowser for help on using the repository browser.