LibJuno 0.42.0
LibJuno is a lightweight C99 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
status.h
Go to the documentation of this file.
1/*
2 MIT License
3
4 Copyright (c) 2025 Robin A. Onsay
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files
8 (the "Software"), to deal in the Software without restriction,
9 including without limitation the rights to use, copy, modify, merge,
10 publish, distribute, sublicense, and/or sell copies of the Software,
11 and to permit persons to whom the Software is furnished to do so,
12 subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16*/
17#ifndef JUNO_STATUS_H
18#define JUNO_STATUS_H
19#include <stdint.h>
20#ifdef __cplusplus
21extern "C" {
22#endif
23typedef int32_t JUNO_STATUS_T;
24#define JUNO_STATUS_SUCCESS 0
25#define JUNO_STATUS_ERR 1
26#define JUNO_STATUS_NULLPTR_ERROR 2
27#define JUNO_STATUS_MEMALLOC_ERROR 3
28#define JUNO_STATUS_MEMFREE_ERROR 4
29#define JUNO_STATUS_INVALID_TYPE_ERROR 5
30#define JUNO_STATUS_INVALID_SIZE_ERROR 6
31#define JUNO_STATUS_TABLE_FULL_ERROR 7
32#define JUNO_STATUS_DNE_ERROR 8
33#define JUNO_STATUS_FILE_ERROR 9
34#define JUNO_STATUS_READ_ERROR 10
35#define JUNO_STATUS_WRITE_ERROR 11
36#define JUNO_STATUS_CRC_ERROR 12
37#define JUNO_STATUS_INVALID_REF_ERROR 13
38#define JUNO_STATUS_REF_IN_USE_ERROR 14
39#define JUNO_STATUS_INVALID_DATA_ERROR 15
40#define JUNO_STATUS_TIMEOUT_ERROR 16
41
42typedef void JUNO_USER_DATA_T;
43typedef void (*JUNO_FAILURE_HANDLER_T)(JUNO_STATUS_T tStatus, const char *pcCustomMessage, JUNO_USER_DATA_T *pvUserData);
44
45#ifndef JUNO_FAIL_MESSAGE_LEN
46#define JUNO_FAIL_MESSAGE_LEN 256
47#endif
48#define JUNO_FAIL(tStatus, pfcnFailureHandler, pvFailureUserData, pcMessage)\
49if(pfcnFailureHandler){pfcnFailureHandler(tStatus, pcMessage, pvFailureUserData);}
50
51#define JUNO_FAIL_MODULE(tStatus, ptMod, pcMessage)\
52if(ptMod && ptMod->JUNO_MODULE_SUPER.JUNO_FAILURE_HANDLER){ptMod->JUNO_MODULE_SUPER.JUNO_FAILURE_HANDLER(tStatus, pcMessage, ptMod->JUNO_MODULE_SUPER.JUNO_FAILURE_USER_DATA);}
53
54#define JUNO_FAIL_ROOT(tStatus, ptMod, pcMessage)\
55if(ptMod && ptMod->JUNO_FAILURE_HANDLER){ptMod->JUNO_FAILURE_HANDLER(tStatus, pcMessage, ptMod->JUNO_FAILURE_USER_DATA);}
56
57#ifdef __cplusplus
58}
59#endif
60#endif
void(* JUNO_FAILURE_HANDLER_T)(JUNO_STATUS_T tStatus, const char *pcCustomMessage, JUNO_USER_DATA_T *pvUserData)
Definition status.h:43
int32_t JUNO_STATUS_T
Definition status.h:23
void JUNO_USER_DATA_T
Definition status.h:42