summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2008-05-19 16:19:37 +0200
committerKai Blin <kai@samba.org>2008-06-10 09:46:53 +0200
commitb1ef38de9fcfc5299f7963a4200ac4b3807e73a0 (patch)
tree74bd0727822d081429f3f89aba5b8f103bec3100 /source3/utils
parent6468d3671696702e74ef20f11493417a6a8e8ab5 (diff)
downloadsamba-b1ef38de9fcfc5299f7963a4200ac4b3807e73a0.tar.gz
samba-b1ef38de9fcfc5299f7963a4200ac4b3807e73a0.tar.bz2
samba-b1ef38de9fcfc5299f7963a4200ac4b3807e73a0.zip
net: Make "net time" use functable3
(This used to be commit 28991ad74a387ebfe931860b380d25d5b0b67c7d)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_time.c70
1 files changed, 57 insertions, 13 deletions
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index f8eb2b45a0..a60e308867 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -93,10 +93,10 @@ static const char *systime(time_t t)
int net_time_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
-"net time\n\tdisplays time on a server\n\n"\
-"net time system\n\tdisplays time on a server in a format ready for /bin/date\n\n"\
-"net time set\n\truns /bin/date with the time from the server\n\n"\
-"net time zone\n\tdisplays the timezone in hours from GMT on the remote computer\n\n"\
+"net time\n\tdisplays time on a server\n\n"
+"net time system\n\tdisplays time on a server in a format ready for /bin/date\n\n"
+"net time set\n\truns /bin/date with the time from the server\n\n"
+"net time zone\n\tdisplays the timezone in hours from GMT on the remote computer\n\n"
"\n");
net_common_flags_usage(c, argc, argv);
return -1;
@@ -127,8 +127,17 @@ static int net_time_set(struct net_context *c, int argc, const char **argv)
/* display the time on a remote box in a format ready for /bin/date */
static int net_time_system(struct net_context *c, int argc, const char **argv)
{
- time_t t = nettime(c, NULL);
+ time_t t;
+
+ if (c->display_usage) {
+ d_printf("Usage:\n"
+ "net time system\n"
+ " Output remote time server time in a format ready "
+ "for /bin/date\n");
+ return 0;
+ }
+ t = nettime(c, NULL);
if (t == 0) return -1;
printf("%s\n", systime(t));
@@ -144,6 +153,13 @@ static int net_time_zone(struct net_context *c, int argc, const char **argv)
char zsign;
time_t t;
+ if (c->display_usage) {
+ d_printf("Usage:\n"
+ "net time zone\n"
+ " Display the remote time server's offset to UTC\n");
+ return 0;
+ }
+
t = nettime(c, &zone);
if (t == 0) return -1;
@@ -164,21 +180,49 @@ static int net_time_zone(struct net_context *c, int argc, const char **argv)
int net_time(struct net_context *c, int argc, const char **argv)
{
time_t t;
- struct functable func[] = {
- {"SYSTEM", net_time_system},
- {"SET", net_time_set},
- {"ZONE", net_time_zone},
- {"HELP", net_time_usage},
- {NULL, NULL}
+ struct functable3 func[] = {
+ {
+ "system",
+ net_time_system,
+ NET_TRANSPORT_LOCAL,
+ "Display time ready for /bin/date",
+ "net time system\n"
+ " Display time ready for /bin/date"
+ },
+ {
+ "set",
+ net_time_set,
+ NET_TRANSPORT_LOCAL,
+ "Set the system time from time server",
+ "net time set\n"
+ " Set the system time from time server"
+ },
+ {
+ "zone",
+ net_time_zone,
+ NET_TRANSPORT_LOCAL,
+ "Display timezone offset from UTC",
+ "net time zone\n"
+ " Display timezone offset from UTC"
+ },
+ {NULL, NULL, 0, NULL, NULL}
};
if (argc != 0) {
- return net_run_function(c, argc, argv, func, net_time_usage);
+ return net_run_function3(c, argc, argv, "net time", func);
+ }
+
+ if (c->display_usage) {
+ d_printf("Usage:\n");
+ d_printf("net time\n"
+ " Display the remote time server's time\n");
+ net_display_usage_from_functable(func);
+ return 0;
}
if (!c->opt_host && !c->opt_have_ip &&
!find_master_ip(c->opt_target_workgroup, &c->opt_dest_ip)) {
- d_fprintf(stderr, "Could not locate a time server. Try "\
+ d_fprintf(stderr, "Could not locate a time server. Try "
"specifying a target host.\n");
net_time_usage(c, argc,argv);
return -1;