Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
time.c

Code example displaing time for 3 seconds.

Code example displaing time for 3 seconds.

#define BJ_AUTOMAIN_CALLBACKS
#include <banjo/log.h>
#include <banjo/main.h>
#include <banjo/system.h>
#include <banjo/time.h>
int bj_app_begin(void** user_data, int argc, char* argv[]) {
(void)user_data; (void)argc; (void)argv;
bj_error* p_error = 0;
if(!bj_begin(&p_error)) {
bj_err("Error 0x%08X: %s", p_error->code, p_error->message);
return bj_callback_exit_error;
}
return bj_callback_continue;
}
int bj_app_iterate(void* user_data) {
(void)user_data;
double elapsed = bj_get_time();
bj_trace("- %lf", elapsed);
bj_sleep(300);
return elapsed >= 3.0 ? bj_callback_exit_success : bj_callback_continue;
}
int bj_app_end(void* user_data, int status) {
(void)user_data;
bj_end(0);
return status;
}
uint32_t code
Error code.
Definition error.h:132
char message[BJ_ERROR_MESSAGE_MAX_LEN+1]
Optional error description.
Definition error.h:133
Error structure.
Definition error.h:131
#define bj_trace(...)
Log a message using the BJ_LOG_TRACE level.
Definition log.h:75
#define bj_err(...)
Log a message using the BJ_LOG_ERROR level.
Definition log.h:131
void bj_end(bj_error **p_error)
De-initializes the system.
bj_bool bj_begin(bj_error **p_error)
Initializes the system.
void bj_sleep(int milliseconds)
Suspends the current thread for a specified duration.
double bj_get_time(void)
Gets the current time in seconds.
Logging utility functions.
Header file for system interactions.
Header file for time manipulation.