]> granicus.if.org Git - strace/commitdiff
Export sprinttime
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 6 Dec 2014 03:53:16 +0000 (03:53 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 11 Dec 2014 21:39:16 +0000 (21:39 +0000)
* defs.h (sprinttime): New prototype.
* file.c (sprinttime): Make global and move to util.c.

defs.h
file.c
util.c

diff --git a/defs.h b/defs.h
index bcdf6253e9b83e26f57e15c5eacf775dc99f6941..164842aa1f47455760ffb42ea9727954b2f3025d 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -673,6 +673,7 @@ extern void addflags(const struct xlat *, int);
 extern int printflags(const struct xlat *, int, const char *);
 extern const char *sprintflags(const char *, const struct xlat *, int);
 extern const char *sprintmode(int);
+extern const char *sprinttime(time_t);
 extern void dumpiov_in_msghdr(struct tcb *, long);
 extern void dumpiov_in_mmsghdr(struct tcb *, long);
 extern void dumpiov(struct tcb *, int, long);
diff --git a/file.c b/file.c
index 7dfe0a6934714fef220527339d5f33fb693562b1..af09189001e6b4acf68dcffe3fb99a33368446ba 100644 (file)
--- a/file.c
+++ b/file.c
@@ -506,27 +506,6 @@ sys_ftruncate64(struct tcb *tcp)
 
 /* several stats */
 
-static char *
-sprinttime(time_t t)
-{
-       struct tm *tmp;
-       static char buf[sizeof("yyyy/mm/dd-hh:mm:ss")];
-
-       if (t == 0) {
-               strcpy(buf, "0");
-               return buf;
-       }
-       tmp = localtime(&t);
-       if (tmp)
-               snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
-                       tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
-                       tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
-       else
-               snprintf(buf, sizeof buf, "%lu", (unsigned long) t);
-
-       return buf;
-}
-
 #if defined(SPARC) || defined(SPARC64)
 typedef struct {
        int     tv_sec;
diff --git a/util.c b/util.c
index cd4b802230a7b650ef965c0f0551923592da3bae..71e921d02cfda2bb4ad4bb307e153aaa5084cc4b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -421,6 +421,27 @@ printnum_int(struct tcb *tcp, long addr, const char *fmt)
        tprints("]");
 }
 
+const char *
+sprinttime(time_t t)
+{
+       struct tm *tmp;
+       static char buf[sizeof("yyyy/mm/dd-hh:mm:ss")];
+
+       if (t == 0) {
+               strcpy(buf, "0");
+               return buf;
+       }
+       tmp = localtime(&t);
+       if (tmp)
+               snprintf(buf, sizeof buf, "%02d/%02d/%02d-%02d:%02d:%02d",
+                       tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
+                       tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
+       else
+               snprintf(buf, sizeof buf, "%lu", (unsigned long) t);
+
+       return buf;
+}
+
 static char *
 getfdproto(struct tcb *tcp, int fd, char *buf, unsigned bufsize)
 {