MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_context.c
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2 * mrtk_context.c : MRTKLIB legacy context management
3 *
4 * Copyright (C) 2026 H.SHIONO (MRTKLIB Project)
5 * Copyright (C) 2023-2025 Cabinet Office, Japan
6 * Copyright (C) 2024-2025 Lighthouse Technology & Consulting Co. Ltd.
7 * Copyright (C) 2023-2025 Japan Aerospace Exploration Agency
8 * Copyright (C) 2023-2025 TOSHIBA ELECTRONIC TECHNOLOGIES CORPORATION
9 * Copyright (C) 2015- Mitsubishi Electric Corp.
10 * Copyright (C) 2014 Geospatial Information Authority of Japan
11 * Copyright (C) 2014 T.SUZUKI
12 * Copyright (C) 2007-2023 T.TAKASU
13 *
14 * SPDX-License-Identifier: BSD-2-Clause
15 *----------------------------------------------------------------------------*/
17
18#include <stdlib.h>
19#include <string.h>
20
21/*============================================================================
22 * Global Context (transitional)
23 *===========================================================================*/
24
26
27/*============================================================================
28 * Lifecycle Functions
29 *===========================================================================*/
30
32 mrtk_ctx_t* ctx = (mrtk_ctx_t*)calloc(1, sizeof(mrtk_ctx_t));
33 if (!ctx) {
34 return NULL;
35 }
36
37 ctx->is_running = 0;
38 ctx->cancel_requested = 0;
40 ctx->last_err_msg[0] = '\0';
41 ctx->trace_level = 0;
42 ctx->trace_fp = NULL;
43 ctx->tick_trace = 0;
44 ctx->user_data = NULL;
45 ctx->cb_showmsg = NULL;
46
47 return ctx;
48}
49
51 if (!ctx) {
52 return;
53 }
54
55 /* Close trace file if not stdout/stderr */
56 if (ctx->trace_fp && ctx->trace_fp != stdout && ctx->trace_fp != stderr) {
57 fclose(ctx->trace_fp);
58 ctx->trace_fp = NULL;
59 }
60
61 memset(ctx, 0, sizeof(mrtk_ctx_t));
62 free(ctx);
63}
void mrtk_ctx_destroy(mrtk_ctx_t *ctx)
Destroy a runtime context.
mrtk_ctx_t * g_mrtk_ctx
Global context pointer for transitional migration.
mrtk_ctx_t * mrtk_ctx_create(void)
Create a new runtime context.
MRTKLIB Context — runtime context for processing, trace, and error handling.
@ MRTK_OK
Runtime context for MRTKLIB processing.
mrtk_showmsg_cb_t cb_showmsg
mrtk_err_t last_err_code
volatile int is_running
FILE * trace_fp
uint32_t tick_trace
char last_err_msg[256]
void * user_data
volatile int cancel_requested
#define calloc(x, y)
Definition toml.c:54
#define free(x)
Definition toml.c:53