Path: blob/main/contrib/bsddialog/examples_library/timebox.c
39476 views
/*-1* SPDX-License-Identifier: CC0-1.02*3* Written in 2021 by Alfonso Sabato Siciliano.4* To the extent possible under law, the author has dedicated all copyright5* and related and neighboring rights to this software to the public domain6* worldwide. This software is distributed without any warranty, see:7* <http://creativecommons.org/publicdomain/zero/1.0/>.8*/910#include <bsddialog.h>11#include <stdio.h>12#include <time.h>1314int main()15{16int output;17unsigned int hh, mm, ss;18struct bsddialog_conf conf;19time_t clock;20struct tm *localtm;2122time(&clock);23localtm = localtime(&clock);24hh = localtm->tm_hour;25mm = localtm->tm_min;26ss = localtm->tm_sec;2728if (bsddialog_init() == BSDDIALOG_ERROR) {29printf("Error: %s\n", bsddialog_geterror());30return (1);31}32bsddialog_initconf(&conf);33conf.title = "timebox";34output = bsddialog_timebox(&conf, "Example", 9, 35, &hh, &mm, &ss);35bsddialog_end();36if (output == BSDDIALOG_ERROR) {37printf("Error: %s\n", bsddialog_geterror());38return (1);39}40printf("Time: %u:%u:%u\n", hh, mm, ss);4142return (0);43}4445