Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_xctx.h
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework Execution Context (xctx) Implementation Header
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 #ifndef __AFW_XCTX_H__
10 #define __AFW_XCTX_H__
11 
12 #include "afw_interface.h"
13 
29 
31 #define AFW_XCTX_Q_NAME_BASE "base"
32 
34 #define AFW_XCTX_s_NAME_BASE afw_s_base
35 
37 #define AFW_XCTX_Q_NAME_REQUEST_THREAD "request_thread"
38 
40 #define AFW_XCTX_s_NAME_REQUEST_THREAD afw_s_request_thread
41 
43 #define AFW_XCTX_Q_NAME_REQUEST_SESSION "request_session"
44 
46 #define AFW_XCTX_s_NAME_REQUEST_SESSION afw_s_request_session
47 
48 
49 
60  union {
61  const afw_utf8_t *entry_id;
62  afw_size_t parameter_number;
63  const afw_value_t *value;
64  };
65 };
66 
67 
68 AFW_STACK_STRUCT(afw_xctx_evaluation_stack_s,
70 
71 
78 #define afw_xctx_evaluation_stack_push_value(VALUE, xctx) \
79  afw_stack_push_direct(xctx->evaluation_stack, xctx); \
80  (xctx)->evaluation_stack->top->value = VALUE
81 
82 
88 #define afw_xctx_evaluation_stack_push_parameter_number( \
89  PARAMETER_NUMBER, xctx) \
90  afw_stack_push_direct(xctx->evaluation_stack, xctx); \
91  (xctx)->evaluation_stack->top->parameter_number =PARAMETER_NUMBER; \
92  afw_stack_push_direct(xctx->evaluation_stack, xctx); \
93  (xctx)->evaluation_stack->top->entry_id = &afw_s_parameter_number
94 
95 
100 #define afw_xctx_evaluation_stack_pop(xctx) \
101 if (xctx->evaluation_stack->top->entry_id == &afw_s_parameter_number) { \
102  afw_stack_pop(xctx->evaluation_stack, xctx); \
103 } \
104 afw_stack_pop(xctx->evaluation_stack, xctx)
105 
106 
113 #define afw_xctx_evaluation_stack_pop_value(xctx) \
114 afw_stack_pop(xctx->evaluation_stack, xctx)
115 
116 
117 
124 #define afw_xctx_evaluation_stack_pop_parameter_number(xctx) \
125 afw_stack_pop(xctx->evaluation_stack, xctx); \
126 afw_stack_pop(xctx->evaluation_stack, xctx)
127 
128 
133 #define afw_xctx_evaluation_stack_save_top(xctx) \
134 afw_xctx_evaluation_stack_entry_t *evaluation_stack_save_top = \
135 xctx->evaluation_stack->top
136 
137 
142 #define afw_xctx_evaluation_stack_restore_top(xctx) \
143 xctx->evaluation_stack->top = evaluation_stack_save_top
144 
145 
164  const afw_utf8_t *name, afw_integer_t number, afw_xctx_t *xctx);
165 
166 
172 AFW_DEFINE_STATIC_INLINE(afw_boolean_t)
174 {
175  return xctx->env->terminating;
176 }
177 
178 
185 #define afw_xctx_calloc(size, xctx) \
186  afw_pool_calloc((xctx)->p, (size), (xctx))
187 
188 
199 #define afw_xctx_calloc_type(type, xctx) \
200  (type *) afw_pool_calloc((xctx)->p, sizeof(type), (xctx))
201 
202 
209 #define afw_xctx_malloc(size, xctx) \
210  afw_pool_malloc((xctx)->p, (size), (xctx))
211 
212 
223 #define afw_xctx_malloc_type(type, xctx) \
224  (type *) afw_pool_malloc((xctx)->p, sizeof(type), (xctx))
225 
239 #define AFW_XCTX_SECURE_BEGIN \
240 do { \
241  afw_boolean_t this_SCOPE_save_secure = xctx->secure; \
242  xctx->secure = true; \
243  AFW_TRY
244 
245 
246 
250 #define AFW_XCTX_SECURE_END \
251  AFW_FINALLY { \
252  xctx->secure = this_SCOPE_save_secure; \
253  } \
254  AFW_ENDTRY; \
255 } while(0)
256 
257 
267 AFW_DECLARE(const afw_value_t *)
269  const afw_utf8_t *qualifier,
270  const afw_utf8_t *name,
271  afw_xctx_t *xctx);
272 
273 
286 AFW_DECLARE(void)
288  const afw_value_t *value, afw_xctx_t *xctx);
289 
290 
302 AFW_DECLARE(void)
304  const afw_value_t *value, afw_xctx_t *xctx);
305 
306 
318 AFW_DECLARE(void)
320  const afw_value_t *value, afw_xctx_t *xctx);
321 
322 
328 AFW_DEFINE_STATIC_INLINE(int)
330  afw_xctx_t *xctx)
331 {
332  xctx->current_frame_index = xctx->stack->nelts;
333  return xctx->stack->nelts;
334 }
335 
336 
342 AFW_DEFINE_STATIC_INLINE(void)
344  int top, afw_xctx_t *xctx)
345 {
346  xctx->stack->nelts = top;
347  xctx->current_frame_index = top;
348 }
349 
350 
353 
355  const afw_pool_t *p;
356 
359 
362 
365 
367  void *data;
368 
370  void *wa;
371 
374 
375 };
376 
377 
378 
384 AFW_DECLARE(int)
386  afw_xctx_t *xctx);
387 
388 
389 
396 AFW_DECLARE(void)
398 
399 
400 
419 AFW_DECLARE(void)
421  const afw_object_t *context_object,
422  afw_boolean_t secure,
423  const afw_pool_t *p,
424  afw_xctx_t *xctx);
425 
426 
460  const afw_utf8_t *qualifier,
461  const afw_object_t *qualifier_object,
462  afw_boolean_t secure,
464  void * data,
465  const afw_pool_t *p,
466  afw_xctx_t *xctx);
467 
468 
484 AFW_DECLARE(void)
486  const afw_utf8_t *qualifier_name,
487  const afw_object_t *qualifier_object,
488  afw_boolean_t secure,
489  const afw_pool_t *p,
490  afw_xctx_t *xctx);
491 
492 
493 
507 #define AFW_XCTX_AUTHORIZATION_MODE_BEGIN(modeId) \
508 const afw_value_t *this_PREVIOUS_MODE = \
509  xctx->mode = afw_authorization_mode_id_ ## modeId ## _value; \
510 AFW_TRY
511 
512 
518 #define AFW_XCTX_AUTHORIZATION_MODE_END \
519 AFW_FINALLY { \
520  xctx->mode = this_PREVIOUS_MODE; \
521 } \
522 AFW_ENDTRY
523 
524 
533 AFW_DEFINE(const afw_object_t *)
535  const afw_utf8_t *qualifier,
536  afw_boolean_t for_testing,
537  const afw_pool_t *p,
538  afw_xctx_t *xctx);
539 
540 
541 
549 AFW_DEFINE(const afw_object_t *)
551  afw_boolean_t for_testing,
552  const afw_pool_t *p,
553  afw_xctx_t *xctx);
554 
555 
556 
557 AFW_END_DECLARES
558 
561 #endif /* __AFW_XCTX_H__ */
AFW_DEFINE(const afw_object_t *)
#define AFW_BEGIN_DECLARES
#define AFW_DECLARE(type)
Declare a public afw function.
Interfaceafw_interface header.
#define AFW_STACK_STRUCT(struct_name, entry_type)
Define a struct for a stack with the specified entry type.
Definition: afw_common.h:718
_Bool afw_boolean_t
Definition: afw_common.h:373
apr_size_t afw_size_t
size_t.
Definition: afw_common.h:151
const afw_value_t *(* afw_xctx_get_variable_t)(const afw_xctx_qualifier_stack_entry_t *entry, const afw_utf8_t *name, afw_xctx_t *xctx)
Typedef for function to get a qualified variable.
Definition: afw_common.h:969
apr_int64_t afw_integer_t
typedef for big signed int.
Definition: afw_common.h:321
void afw_xctx_define_variable(const afw_utf8_t *name, const afw_value_t *value, afw_xctx_t *xctx)
Defined a variable in current xctx frame.
Definition: afw_xctx.c:235
int afw_xctx_begin_stack_frame(afw_xctx_t *xctx)
Begin stack frame.
Definition: afw_xctx.h:329
afw_xctx_qualifiers_object_create(afw_boolean_t for_testing, const afw_pool_t *p, afw_xctx_t *xctx)
Create object to access active qualified variables.
void afw_xctx_set_local_variable(const afw_utf8_t *name, const afw_value_t *value, afw_xctx_t *xctx)
Set a variable then current xctx frame.
Definition: afw_xctx.c:289
const afw_value_t * afw_xctx_get_qualified_variable(const afw_utf8_t *qualifier, const afw_utf8_t *name, afw_xctx_t *xctx)
Get a variable from xctx stack.
Definition: afw_xctx.c:176
int afw_xctx_get_qualifier_stack_top(afw_xctx_t *xctx)
Get qualifier stack top.
Definition: afw_xctx.c:316
void afw_xctx_push_qualifier_object(const afw_utf8_t *qualifier_name, const afw_object_t *qualifier_object, afw_boolean_t secure, const afw_pool_t *p, afw_xctx_t *xctx)
Push qualifier object on to stack.
Definition: afw_xctx.c:406
afw_boolean_t afw_xctx_environment_is_terminating(afw_xctx_t *xctx)
Test for environment terminating.
Definition: afw_xctx.h:173
afw_xctx_qualifier_object_create(const afw_utf8_t *qualifier, afw_boolean_t for_testing, const afw_pool_t *p, afw_xctx_t *xctx)
Create object to access active variables for a qualifier.
void afw_xctx_push_qualifiers_object(const afw_object_t *context_object, afw_boolean_t secure, const afw_pool_t *p, afw_xctx_t *xctx)
Push qualifiers object on to stack.
Definition: afw_xctx.c:336
void afw_xctx_set_qualifier_stack_top(int top, afw_xctx_t *xctx)
Set stack top index.
Definition: afw_xctx.c:325
void afw_xctx_end_stack_frame(int top, afw_xctx_t *xctx)
Set stack top.
Definition: afw_xctx.h:343
afw_xctx_t * afw_xctx_create(const afw_utf8_t *name, afw_integer_t number, afw_xctx_t *xctx)
Create an Adaptive Framework xctx.
Definition: afw_xctx.c:145
void afw_xctx_set_defined_variable(const afw_utf8_t *name, const afw_value_t *value, afw_xctx_t *xctx)
Set a defined variable in xctx.
Definition: afw_xctx.c:263
afw_xctx_qualifier_stack_entry_t * afw_xctx_push_qualifier(const afw_utf8_t *qualifier, const afw_object_t *qualifier_object, afw_boolean_t secure, afw_xctx_get_variable_t get, void *data, const afw_pool_t *p, afw_xctx_t *xctx)
Push qualifier on to stack.
Definition: afw_xctx.c:359
Interface afw_object public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_value public struct.
The execution context (xctx) evaluation stack entry.
Definition: afw_xctx.h:59
Definition: afw_xctx.h:352
const afw_object_t * qualifier_object
qualifier_object. This may be NULL now.
Definition: afw_xctx.h:361
void * data
Data that will be passed to get/set.
Definition: afw_xctx.h:367
const afw_pool_t * p
Pool used while processing entry.
Definition: afw_xctx.h:355
afw_utf8_t qualifier
qualifier or len=0 if unqualified.
Definition: afw_xctx.h:358
afw_xctx_get_variable_t get
Get routine or NULL if get not allowed.
Definition: afw_xctx.h:364
void * wa
Work area used by get/set.
Definition: afw_xctx.h:370
afw_boolean_t secure
Secure access to this qualifier is allowed.
Definition: afw_xctx.h:373
Interface afw_xctx public struct.