Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions | Variables
except.h File Reference
#include <glib.h>
#include <setjmp.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
#include "ws_symbol_export.h"
#include "ws_attributes.h"

Go to the source code of this file.

Classes

struct  except_id_t
 
struct  except_t
 
struct  except_cleanup
 
struct  except_catch
 
struct  except_stacknode
 Represents a node in the exception handling stack. More...
 

Macros

#define XCEPT_GROUP_ANY   0
 
#define XCEPT_CODE_ANY   0
 
#define XCEPT_BAD_ALLOC   1
 
#define except_code(E)   ((E)->except_id.except_code)
 
#define except_group(E)   ((E)->except_id.except_group)
 
#define except_message(E)   ((E)->except_message)
 
#define except_data(E)   ((E)->except_dyndata)
 
#define except_cleanup_push(F, C)
 
#define except_cleanup_pop(E)
 
#define except_checked_cleanup_pop(F, E)
 
#define except_cleanup_push_pfx(pfx, F, C)
 
#define except_cleanup_pop_pfx(pfx, E)
 
#define except_checked_cleanup_pop_pfx(pfx, F, E)
 
#define except_try_push(ID, NUM, PPE)
 
#define except_try_pop()
 

Enumerations

enum  { except_no_call , except_call }
 
enum  except_stacktype { XCEPT_CLEANUP , XCEPT_CATCHER }
 

Functions

WS_DLL_PUBLIC void except_setup_clean (struct except_stacknode *, struct except_cleanup *, void(*)(void *), void *)
 Set up a cleanup handler for exception handling.
 
WS_DLL_PUBLIC void except_setup_try (struct except_stacknode *, struct except_catch *, const except_id_t[], size_t)
 Set up a try block for exception handling.
 
WS_DLL_PUBLIC struct except_stacknodeexcept_pop (void)
 Pop the top node from the exception stack.
 
WS_DLL_PUBLIC int except_init (void)
 Initialize the exception handling system.
 
WS_DLL_PUBLIC void except_deinit (void)
 Deinitialize the exception handling system.
 
WS_DLL_PUBLIC WS_NORETURN void except_rethrow (except_t *except)
 Rethrow an exception.
 
WS_DLL_PUBLIC WS_NORETURN void except_throw (long group, long code, const char *msg)
 Throw an exception with a message and optional data.
 
WS_DLL_PUBLIC WS_NORETURN void except_throwd (long, long, const char *, void *)
 
WS_DLL_PUBLIC WS_NORETURN void except_vthrowf (long group, long code, const char *fmt, va_list vl)
 
WS_DLL_PUBLIC WS_NORETURN void except_throwf (long, long, const char *,...)
 
unsigned long except_code (except_t *)
 
unsigned long except_group (except_t *)
 
const char * except_message (except_t *)
 
void * except_data (except_t *)
 
WS_DLL_PUBLIC void * except_take_data (except_t *ex)
 Take data from an exception object.
 
WS_DLL_PUBLIC void except_set_allocator (void *(*)(size_t), void(*)(void *))
 
WS_DLL_PUBLIC void * except_alloc (size_t)
 
WS_DLL_PUBLIC void except_free (void *ptr)
 Frees memory allocated for an exception node.
 
const struct except_stacknodeexcept_get_top (void)
 Get the top node from the exception stack.
 
void except_set_top (struct except_stacknode *node)
 Set the top node of an exception stack.
 

Variables

WS_DLL_PUBLIC void(*)(except_t *) except_unhandled_catcher (void(*)(except_t *))
 

Detailed Description

Portable Exception Handling for ANSI C.
Modified to support throwing an exception with a null message pointer, and to have the message not be const (as we generate messages with "ws_strdup_printf()", which means they need to be freed; using a null message means that we don't have to use a special string for exceptions with no message, and don't have to worry about not freeing that).

Macro Definition Documentation

◆ except_checked_cleanup_pop

#define except_checked_cleanup_pop (   F,
 
)
Value:
assert (except_cl.except_func == (F)); \
if (E) \
except_cl.except_func(except_cl.except_context); \
}
WS_DLL_PUBLIC struct except_stacknode * except_pop(void)
Pop the top node from the exception stack.
Definition except.c:270

◆ except_checked_cleanup_pop_pfx

#define except_checked_cleanup_pop_pfx (   pfx,
  F,
 
)
Value:
assert (pfx##_except_cl.except_func == (F)); \
if (E) \
pfx##_except_cl.except_func(pfx##_except_cl.except_context);\
}

◆ except_cleanup_pop

#define except_cleanup_pop (   E)
Value:
if (E) \
except_cl.except_func(except_cl.except_context); \
}

◆ except_cleanup_pop_pfx

#define except_cleanup_pop_pfx (   pfx,
 
)
Value:
if (E) \
pfx##_except_cl.except_func(pfx##_except_cl.except_context);\
}

◆ except_cleanup_push

#define except_cleanup_push (   F,
 
)
Value:
{ \
struct except_stacknode except_sn; \
struct except_cleanup except_cl; \
except_setup_clean(&except_sn, &except_cl, F, C)
Definition except.h:59
Represents a node in the exception handling stack.
Definition except.h:82

◆ except_cleanup_push_pfx

#define except_cleanup_push_pfx (   pfx,
  F,
 
)
Value:
{ \
struct except_stacknode pfx##_except_sn; \
struct except_cleanup pfx##_except_cl; \
except_setup_clean(&pfx##_except_sn, &pfx##_except_cl, F, C)

◆ except_try_pop

#define except_try_pop ( )
Value:
except_free(except_ch.except_obj.except_dyndata); \
except_pop(); \
}
WS_DLL_PUBLIC void except_free(void *ptr)
Frees memory allocated for an exception node.
Definition except.c:396

◆ except_try_push

#define except_try_push (   ID,
  NUM,
  PPE 
)
Value:
{ \
struct except_stacknode except_sn; \
struct except_catch except_ch; \
except_setup_try(&except_sn, &except_ch, ID, NUM); \
if (setjmp(except_ch.except_jmp)) \
*(PPE) = &except_ch.except_obj; \
else \
*(PPE) = 0
Definition except.h:64

Function Documentation

◆ except_free()

WS_DLL_PUBLIC void except_free ( void *  ptr)

Frees memory allocated for an exception node.

Parameters
ptrPointer to the memory to be freed.

◆ except_get_top()

const struct except_stacknode * except_get_top ( void  )

Get the top node from the exception stack.

Returns
const struct except_stacknode* Pointer to the top node in the exception stack.

◆ except_init()

WS_DLL_PUBLIC int except_init ( void  )

Initialize the exception handling system.

Returns
int 0 on success, -1 on failure.

◆ except_pop()

WS_DLL_PUBLIC struct except_stacknode * except_pop ( void  )

Pop the top node from the exception stack.

Returns
struct except_stacknode* Pointer to the popped node from the exception stack.

◆ except_rethrow()

WS_DLL_PUBLIC WS_NORETURN void except_rethrow ( except_t except)

Rethrow an exception.

Parameters
exceptPointer to the exception object.

◆ except_set_top()

void except_set_top ( struct except_stacknode node)

Set the top node of an exception stack.

Parameters
nodePointer to the new top node of the exception stack.

◆ except_take_data()

WS_DLL_PUBLIC void * except_take_data ( except_t ex)

Take data from an exception object.

Parameters
exPointer to the exception object.
Returns
The data that was stored in the exception object, or NULL if no data was stored.

◆ except_throw()

WS_DLL_PUBLIC WS_NORETURN void except_throw ( long  group,
long  code,
const char *  msg 
)

Throw an exception with a message and optional data.

Parameters
groupThe exception group identifier.
codeThe exception code identifier.
msgThe message associated with the exception.