2022-06-26 22:58:56 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
|
2010-08-01 07:35:58 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2010 by Øyvind Harboe *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/* this file contains various functionality useful to standalone systems */
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
#include "time_support.h"
|
|
|
|
|
2021-04-25 20:38:32 +00:00
|
|
|
static int jim_util_ms(Jim_Interp *interp,
|
2012-01-30 14:31:21 +00:00
|
|
|
int argc,
|
|
|
|
Jim_Obj * const *argv)
|
2010-08-01 07:35:58 +00:00
|
|
|
{
|
2012-01-30 14:31:21 +00:00
|
|
|
if (argc != 1) {
|
2010-08-01 07:35:58 +00:00
|
|
|
Jim_WrongNumArgs(interp, 1, argv, "ls ?dir?");
|
|
|
|
return JIM_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cast from 64 to 32 bit int works for 2's-compliment
|
|
|
|
* when calculating differences*/
|
|
|
|
Jim_SetResult(interp, Jim_NewIntObj(interp, (int)timeval_ms()));
|
|
|
|
|
|
|
|
return JIM_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct command_registration util_command_handlers[] = {
|
2012-01-30 14:31:21 +00:00
|
|
|
/* jim handlers */
|
2010-08-01 07:35:58 +00:00
|
|
|
{
|
|
|
|
.name = "ms",
|
|
|
|
.mode = COMMAND_ANY,
|
2021-04-25 20:38:32 +00:00
|
|
|
.jim_handler = jim_util_ms,
|
2012-01-30 14:31:21 +00:00
|
|
|
.help =
|
2020-07-11 22:57:34 +00:00
|
|
|
"Returns ever increasing milliseconds. Used to calculate differences in time.",
|
2010-08-01 07:35:58 +00:00
|
|
|
.usage = "",
|
|
|
|
},
|
|
|
|
COMMAND_REGISTRATION_DONE
|
|
|
|
};
|
|
|
|
|
|
|
|
int util_init(struct command_context *cmd_ctx)
|
|
|
|
{
|
|
|
|
return register_commands(cmd_ctx, NULL, util_command_handlers);
|
|
|
|
}
|