MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_context.h File Reference

MRTKLIB Context — runtime context for processing, trace, and error handling. More...

#include <stdint.h>
#include <stdio.h>
Include dependency graph for mrtk_context.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mrtk_ctx_t
 Runtime context for MRTKLIB processing. More...

Typedefs

typedef void(* mrtk_showmsg_cb_t) (const char *msg)
 Message display callback (for GUI/app-level status messages).

Enumerations

enum  mrtk_err_t {
  MRTK_OK = 0 , MRTK_ERR_VALUE = -1 , MRTK_ERR_IO = -2 , MRTK_ERR_MEMORY = -3 ,
  MRTK_ERR_FORMAT = -4 , MRTK_ERR_CANCEL = -5
}
 Error code enumeration for MRTKLIB functions. More...

Functions

mrtk_ctx_t * mrtk_ctx_create (void)
 Create a new runtime context.
void mrtk_ctx_destroy (mrtk_ctx_t *ctx)
 Destroy a runtime context.

Variables

mrtk_ctx_t * g_mrtk_ctx
 Global context pointer for transitional migration.

Detailed Description

MRTKLIB Context — runtime context for processing, trace, and error handling.

This header defines the non-opaque runtime context structure that replaces global variables for trace output, error state, and processing control. All trace functions and major processing pipeline functions accept a pointer to this context as their first argument.

Definition in file mrtk_context.h.

Typedef Documentation

◆ mrtk_showmsg_cb_t

typedef void(* mrtk_showmsg_cb_t) (const char *msg)

Message display callback (for GUI/app-level status messages).

Parameters
[in]msgNull-terminated message string

Definition at line 59 of file mrtk_context.h.

Enumeration Type Documentation

◆ mrtk_err_t

enum mrtk_err_t

Error code enumeration for MRTKLIB functions.

Enumerator
MRTK_OK 

Success

MRTK_ERR_VALUE 

Invalid parameter value

MRTK_ERR_IO 

I/O error (file, stream)

MRTK_ERR_MEMORY 

Memory allocation failure

MRTK_ERR_FORMAT 

Data format error

MRTK_ERR_CANCEL 

Processing cancelled

Definition at line 42 of file mrtk_context.h.

Function Documentation

◆ mrtk_ctx_create()

mrtk_ctx_t * mrtk_ctx_create ( void )

Create a new runtime context.

Allocates and zero-initialises a context. Default settings:

  • trace_level: 0 (off)
  • trace_fp: NULL (no trace output)
  • All other members: zero / NULL
Returns
Newly allocated context, or NULL on allocation failure.

Definition at line 31 of file mrtk_context.c.

References calloc, mrtk_ctx_t::cancel_requested, mrtk_ctx_t::cb_showmsg, mrtk_ctx_t::is_running, mrtk_ctx_t::last_err_code, mrtk_ctx_t::last_err_msg, MRTK_OK, mrtk_ctx_t::tick_trace, mrtk_ctx_t::trace_fp, mrtk_ctx_t::trace_level, and mrtk_ctx_t::user_data.

◆ mrtk_ctx_destroy()

void mrtk_ctx_destroy ( mrtk_ctx_t * ctx)

Destroy a runtime context.

Closes the trace file (unless stdout/stderr) and frees memory. Safe to call with NULL.

Parameters
[in]ctxContext to destroy, or NULL (no-op)

Definition at line 50 of file mrtk_context.c.

References free, and mrtk_ctx_t::trace_fp.

Variable Documentation

◆ g_mrtk_ctx

mrtk_ctx_t* g_mrtk_ctx
extern

Global context pointer for transitional migration.

Functions that have not yet received an explicit ctx parameter use this global as a fallback. Applications should set this at startup and clear it at shutdown.

Note
This pointer will be removed once all modules have been migrated to explicit context passing.

Definition at line 25 of file mrtk_context.c.

Referenced by rtksvrstart().