-/*********************************************************************
- *
- * Function : client_cookie_adder
- *
- * Description : Used in the add_client_headers list to add "wafers".
- * Called from `sed'.
- *
- * Parameters :
- * 1 : csp = Current client state (buffers, headers, etc...)
- *
- * Returns : JB_ERR_OK on success, or
- * JB_ERR_MEMORY on out-of-memory error.
- *
- *********************************************************************/
-jb_err client_cookie_adder(struct client_state *csp)
-{
- char *tmp;
- struct list_entry *wafer;
- struct list_entry *wafer_list;
- jb_err err;
-
- /*
- * If the user has not supplied any wafers, and the user has not
- * told us to suppress the vanilla wafer, then send the vanilla wafer.
- */
- if ((0 != (csp->action->flags & ACTION_VANILLA_WAFER))
- && list_is_empty(csp->action->multi[ACTION_MULTI_WAFER]))
- {
- enlist(csp->action->multi[ACTION_MULTI_WAFER], VANILLA_WAFER);
- }
-
- wafer_list = csp->action->multi[ACTION_MULTI_WAFER]->first;
-
- if (NULL == wafer_list)
- {
- /* Nothing to do */
- return JB_ERR_OK;
- }
-
- tmp = strdup("Cookie: ");
-
- for (wafer = wafer_list; (NULL != tmp) && (NULL != wafer); wafer = wafer->next)
- {
- if (wafer != wafer_list)
- {
- /* As this isn't the first wafer, we need a delimiter. */
- string_append(&tmp, "; ");
- }
- string_join(&tmp, cookie_encode(wafer->str));
- }
-
- if (tmp == NULL)
- {
- return JB_ERR_MEMORY;
- }
-
- log_error(LOG_LEVEL_HEADER, "addh: %s", tmp);
- err = enlist(csp->headers, tmp);
- free(tmp);
- return err;
-}
-
-