return 0;
}
+/** Set a new signal function for an existing function frame
+ *
+ * @private
+ *
+ * The function frame being modified must be at the top of the stack.
+ *
+ * @param[in] request The current request.
+ * @param[in] signal The signal function to set.
+ * @param[in] signal_name Name of the signal function call (for debugging).
+ * @return
+ * - 0 on success.
+ * - -1 on failure.
+ */
+int _unlang_function_signal_set(request_t *request, unlang_function_signal_t signal, char const *signal_name)
+{
+ unlang_stack_t *stack = request->stack;
+ unlang_stack_frame_t *frame = &stack->frame[stack->depth];
+ unlang_frame_state_func_t *state;
+
+ if (frame->instruction->type != UNLANG_TYPE_FUNCTION) {
+ RERROR("Can't set repeat function on non-function frame");
+ return -1;
+ }
+
+ state = talloc_get_type_abort(frame->state, unlang_frame_state_func_t);
+
+ /*
+ * If we're inside unlang_function_call,
+ * it'll pickup state->repeat and do the right thing
+ * once the current function returns.
+ */
+ state->signal = signal;
+ state->signal_name = signal_name;
+
+ return 0;
+}
+
/** Set a new repeat function for an existing function frame
+ *
+ * @private
*
* The function frame being modified must be at the top of the stack.
*
* - 0 on success.
* - -1 on failure.
*/
-int _unlang_function_repeat(request_t *request, unlang_function_t repeat, char const *repeat_name)
+int _unlang_function_repeat_set(request_t *request, unlang_function_t repeat, char const *repeat_name)
{
unlang_stack_t *stack = request->stack;
unlang_stack_frame_t *frame = &stack->frame[stack->depth];
}
/** Push a generic function onto the unlang stack
+ *
+ * @private
*
* These can be pushed by any other type of unlang op to allow a submodule or function
* deeper in the C call stack to establish a new resumption point.
int unlang_function_clear(request_t *request) CC_HINT(warn_unused_result);
-int _unlang_function_repeat(request_t *request, unlang_function_t repeat, char const *name) CC_HINT(warn_unused_result);
+/** Set a new signal function for an existing function frame
+ *
+ * The function frame being modified must be at the top of the stack.
+ *
+ * @param[in] request The current request.
+ * @param[in] signal The signal function to set.
+ * @param[in] signal_name Name of the signal function call (for debugging).
+ * @return
+ * - 0 on success.
+ * - -1 on failure.
+ */
+#define unlang_function_signal_set(_request, _signal) \
+ _unlang_function_signal_set(_request, _signal, STRINGIFY(_signal))
+int _unlang_function_signal_set(request_t *request, unlang_function_signal_t signal, char const *name)
+ CC_HINT(warn_unused_result);
/** Set a new repeat function for an existing function frame
*
* - 0 on success.
* - -1 on failure.
*/
-#define unlang_function_repeat(_request, _repeat) \
- _unlang_function_repeat(_request, _repeat, STRINGIFY(_repeat))
-
-unlang_action_t _unlang_function_push(request_t *request,
- unlang_function_t func, char const *func_name,
- unlang_function_t repeat, char const *repeat_name,
- unlang_function_signal_t signal, char const *signal_name,
- bool top_frame, void *uctx)
- CC_HINT(warn_unused_result);
+#define unlang_function_repeat_set(_request, _repeat) \
+ _unlang_function_repeat_set(_request, _repeat, STRINGIFY(_repeat))
+int _unlang_function_repeat_set(request_t *request, unlang_function_t repeat, char const *name)
+ CC_HINT(warn_unused_result);
/** Push a generic function onto the unlang stack
*
_repeat, STRINGIFY(_repeat), \
_signal, STRINGIFY(_signal), \
_top_frame, _uctx)
+unlang_action_t _unlang_function_push(request_t *request,
+ unlang_function_t func, char const *func_name,
+ unlang_function_t repeat, char const *repeat_name,
+ unlang_function_signal_t signal, char const *signal_name,
+ bool top_frame, void *uctx)
+ CC_HINT(warn_unused_result);
#ifdef __cplusplus
}