Ignore:
Timestamp:
Apr 13, 2018, 1:00:30 PM (6 years ago)
Author:
coas-nagasima
Message:

NTPクライアント処理を追加

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/usrcmd.c

    r337 r340  
    790790}
    791791
     792int usrcmd_date(int argc, char **argv)
     793{
     794        int ret;
     795        struct timespec tp;
     796        char buf[30];
     797
     798        ret = shell_clock_gettime(CLOCK_REALTIME, &tp);
     799        if (ret != 0) {
     800                ntstdio_printf(&ntstdio, "clock_gettime error %d", ret);
     801                return 0;
     802        }
     803
     804        memset(buf, 0, sizeof(buf));
     805        if (ctime_r(&tp.tv_sec, buf) == NULL) {
     806                ntstdio_printf(&ntstdio, "ctime_r error");
     807                return 0;
     808        }
     809
     810        /* 改行コードの削除 */
     811        ret = ntlibc_strlen(buf);
     812        buf[ret - 1] = '\0';
     813
     814        ntstdio_printf(&ntstdio, "%s .%09u\n", buf, tp.tv_nsec);
     815        return 0;
     816}
     817
    792818int usrcmd_info(int argc, char **argv)
    793819{
Note: See TracChangeset for help on using the changeset viewer.