Show banners for execution of a program. More...
#include <misc.h>
Go to the source code of this file.
Functions | |
void | banner (char *pgm, char *verstat, char *type) |
Output banner on terminal for BEGIN and END of programs. |
Show banners for execution of a program.
Definition in file banner.c.
void banner | ( | char * | pgm, | |
char * | verstat, | |||
char * | type | |||
) |
Output banner on terminal for BEGIN and END of programs.
[in] | pgm | Program name. |
[in] | verstat | Program version. |
[in] | type | Type of banner: BEGIN or END. |
Definition at line 58 of file banner.c.
Referenced by main().
00059 { 00066 static clock_t clk; /* Store CPU clock time. */ 00067 time_t tim; /* To compute clock time. */ 00068 char buf[50]; /* Temporary buffer for reentrant subroutine access. */ 00069 char *ctim; /* Date/time string. */ 00070 00071 /* Get current time */ 00072 tim = time(NULL); 00073 00074 /* Create date/time string */ 00075 ctim = ctime_r(&tim, buf); 00076 ctim[strlen(ctim)-1] = '\0'; 00077 00078 /* Output banner */ 00079 if ( !strcmp(type, "BEGIN") ) { 00080 /* Initialize CPU clock time */ 00081 clk = clock(); 00082 /* (void) printf("1\n"); */ 00083 (void) printf(" ********************************************************************************************\n"); 00084 (void) printf(" * *\n"); 00085 (void) printf(" * %-50s V%-10s *\n", pgm, verstat); 00086 (void) printf(" * *\n"); 00087 (void) printf(" * *\n"); 00088 (void) printf(" * %-24s *\n", ctim); 00089 (void) printf(" * *\n"); 00090 (void) printf(" * BEGIN EXECUTION *\n"); 00091 (void) printf(" * *\n"); 00092 (void) printf(" ********************************************************************************************\n"); 00093 } 00094 else if ( !strcmp(type, "END") ) { 00095 00096 float clktime; 00097 00098 /* Compute elapsed CPU clock time */ 00099 clktime = (float) (clock() - clk) / (float) CLOCKS_PER_SEC; 00100 /* (void) printf("1\n"); */ 00101 (void) printf(" ********************************************************************************************\n"); 00102 (void) printf(" * *\n"); 00103 (void) printf(" * %-50s %-10s *\n", pgm, verstat); 00104 (void) printf(" * *\n"); 00105 (void) printf(" * %-24s *\n", ctim); 00106 (void) printf(" * *\n"); 00107 (void) printf(" * END EXECUTION *\n"); 00108 (void) printf(" * *\n"); 00109 (void) printf(" * CP SECS = %-10.3f *\n", 00110 clktime); 00111 (void) printf(" * *\n"); 00112 (void) printf(" ********************************************************************************************\n"); 00113 } 00114 }