VIS
|
00001 00032 #include "vmInt.h" 00033 00034 static char rcsid[] UNUSED = "$Id: vmVers.c,v 1.3 2002/09/08 21:47:31 fabio Exp $"; 00035 00036 /*---------------------------------------------------------------------------*/ 00037 /* Constant declarations */ 00038 /*---------------------------------------------------------------------------*/ 00039 #ifndef CUR_DATE 00040 #define CUR_DATE "<compile date not supplied>" 00041 #endif 00042 00043 #ifndef CUR_VER 00044 #define CUR_VER "UC Berkeley, VIS Release 1.0" 00045 #endif 00046 00047 #ifndef LIBRARY 00048 #define LIBRARY "/projects/vis/vis/common/vis_lib" 00049 #endif 00050 00051 00054 /*---------------------------------------------------------------------------*/ 00055 /* Static function prototypes */ 00056 /*---------------------------------------------------------------------------*/ 00057 00058 static char * DateReadFromDateString(char * datestr); 00059 00063 /*---------------------------------------------------------------------------*/ 00064 /* Definition of exported functions */ 00065 /*---------------------------------------------------------------------------*/ 00066 00067 00080 char * 00081 Vm_VisReadVersion(void) 00082 { 00083 static char version[1024]; 00084 00085 (void) sprintf(version, "%s (compiled %s)", CUR_VER, DateReadFromDateString(CUR_DATE)); 00086 return version; 00087 } 00088 00089 00104 char * 00105 Vm_VisObtainLibrary(void) 00106 { 00107 char * vis_lib_path; 00108 00109 vis_lib_path = getenv("VIS_LIBRARY_PATH"); 00110 if (vis_lib_path) { 00111 return util_tilde_expand(vis_lib_path); 00112 } else { 00113 return util_tilde_expand(LIBRARY); 00114 } 00115 } 00116 00132 void 00133 Vm_VisInitPrintMore(void) 00134 { 00135 fflush(vis_stdout); 00136 vis_stdpipe = popen("more","w"); 00137 } 00152 int 00153 Vm_VisEndPrintMore(void) 00154 { 00155 if (vis_stdpipe != NIL(FILE)) { 00156 (void) pclose(vis_stdpipe); 00157 return 1; 00158 } 00159 return 0; 00160 } 00161 00162 /*---------------------------------------------------------------------------*/ 00163 /* Definition of internal functions */ 00164 /*---------------------------------------------------------------------------*/ 00165 00166 00167 /*---------------------------------------------------------------------------*/ 00168 /* Definition of static functions */ 00169 /*---------------------------------------------------------------------------*/ 00170 00181 static char * 00182 DateReadFromDateString( 00183 char * datestr) 00184 { 00185 static char result[25]; 00186 char day[10]; 00187 char month[10]; 00188 char zone[10]; 00189 char *at; 00190 int date; 00191 int hour; 00192 int minute; 00193 int second; 00194 int year; 00195 00196 if (sscanf(datestr, "%s %s %2d %2d:%2d:%2d %s %4d", 00197 day, month, &date, &hour, &minute, &second, zone, &year) == 8) { 00198 if (hour >= 12) { 00199 if (hour >= 13) hour -= 12; 00200 at = "PM"; 00201 } 00202 else { 00203 if (hour == 0) hour = 12; 00204 at = "AM"; 00205 } 00206 (void) sprintf(result, "%d-%3s-%02d at %d:%02d %s", 00207 date, month, year % 100, hour, minute, at); 00208 return result; 00209 } 00210 else { 00211 return datestr; 00212 } 00213 } 00214 00215 00216 00217 00218