3
3
#include <string.h>
4
4
#include <stdlib.h>
5
5
#include <stdio.h>
6
+ #include <time.h>
6
7
7
8
#include "cwalk.h"
8
9
#include "whereami.h"
13
14
#define FILENAME_MAX_LENGTH 65536
14
15
#endif
15
16
17
+ #define TIME_MAX_LENGTH 42
18
+
16
19
static int help (const char * prgm )
17
20
{
18
21
fprintf (stdout , "usage: %s <OPTION>\n" , prgm );
@@ -74,6 +77,9 @@ int main(int argc, char *argv[])
74
77
{
75
78
static char cedev [FILENAME_MAX_LENGTH ];
76
79
static char buffer [FILENAME_MAX_LENGTH ];
80
+ static char timebuffer [TIME_MAX_LENGTH ];
81
+ time_t rawtime ;
82
+ struct tm * timeinfo ;
77
83
78
84
if (argc != 2 )
79
85
{
@@ -92,10 +98,11 @@ int main(int argc, char *argv[])
92
98
{"version" , no_argument , 0 , 'v' },
93
99
{"prefix" , no_argument , 0 , 'p' },
94
100
{"makefile" , no_argument , 0 , 'm' },
101
+ {"comment" , no_argument , 0 , 'c' },
95
102
{0 , 0 , 0 , 0 }
96
103
};
97
104
98
- c = getopt_long (argc , argv , "h " , long_options , NULL );
105
+ c = getopt_long (argc , argv , "hvpmc " , long_options , NULL );
99
106
if (c < 0 )
100
107
{
101
108
break ;
@@ -124,6 +131,13 @@ int main(int argc, char *argv[])
124
131
fprintf (stdout , "%s\n" , buffer );
125
132
break ;
126
133
134
+ case 'c' :
135
+ time (& rawtime );
136
+ timeinfo = localtime (& rawtime );
137
+ strftime (timebuffer , TIME_MAX_LENGTH , "%FT%T%z" , timeinfo );
138
+ fprintf (stdout , "%s " CEDEV_VERSION "\n" , timebuffer );
139
+ break ;
140
+
127
141
case 'h' :
128
142
default :
129
143
return help (argv [0 ]);
0 commit comments