Пример #1
0
Файл: main.c Проект: BukinAN/All
/* главная функция программы */
void main()
{
	LIST List;		/* список (массив) структур */
	srand(time(NULL));	/* рандомизация */
	init_list(&List);	/* инициализация списка случайными значениями */
	list_edit(&List);	/* редактируем список */
}
Пример #2
0
/**
 * IronBee callback function to manipulate an HTTP header
 *
 * @param[in] tx - IronBee transaction
 * @param[in] dir - Request/Response
 * @param[in] action - Requested header manipulation
 * @param[in] hdr - Header
 * @param[in] value - Header Value
 * @param[in] rx - Compiled regexp of value (if applicable)
 * @return status (OK, Declined if called too late, Error if called with
 *                 invalid data).  NOTIMPL should never happen.
 */
static ib_status_t ib_header_callback(ib_tx_t *tx, ib_server_direction_t dir,
                                      ib_server_header_action_t action,
                                      const char *hdr, const char *value,
                                      ib_rx_t *rx, void *cbdata)
{
    /* This is more complex for nginx than for other servers because
     * headers_in and headers_out are different structs, and there
     * are lots of enumerated headers to watch out for.
     *
     * It appears the enumerated headers are in fact just pointers
     * into the generic lists.  So with luck it should be sufficient
     * to deal with just the lists.  Revisit if we seem to get
     * unexpected failures in manipulating headers.
     *
     * That won't work for setting/unsetting a header altogether.
     * It's no use if we set the list but leave the enumerated
     * pointers uninitialized or dangling.
     */
    ngxib_req_ctx *ctx = tx->sctx;

    /* the headers list is common between request and response */
    ngx_list_t *headers = (dir == IB_SERVER_REQUEST)
                          ? &ctx->r->headers_in.headers
                          : &ctx->r->headers_out.headers;

    if (ctx->hdrs_out || (ctx->hdrs_in && (dir == IB_SERVER_REQUEST)))
        return IB_DECLINED;  /* too late for requested op */

    switch (action) {
      case IB_HDR_SET:
        list_set(headers, hdr, value);
        return IB_OK;
      case IB_HDR_UNSET:
        list_unset(headers, hdr);
        return IB_OK;
      case IB_HDR_ADD:
        list_add(headers, hdr, value);
        return IB_OK;
      case IB_HDR_MERGE:
      case IB_HDR_APPEND:
        list_append(headers, hdr, value);
        return IB_OK;
      case IB_HDR_EDIT:
        return list_edit(headers, hdr, value, tx, rx);
    }
    return IB_ENOTIMPL;
}