mod_include.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * @file mod_include.h
  18. * @brief Server Side Include Filter Extension Module for Apache
  19. *
  20. * @defgroup MOD_INCLUDE mod_include
  21. * @ingroup APACHE_MODS
  22. * @{
  23. */
  24. #ifndef _MOD_INCLUDE_H
  25. #define _MOD_INCLUDE_H 1
  26. #include "apr_pools.h"
  27. #include "apr_optional.h"
  28. /*
  29. * Constants used for ap_ssi_get_tag_and_value's decode parameter
  30. */
  31. #define SSI_VALUE_DECODED 1
  32. #define SSI_VALUE_RAW 0
  33. /*
  34. * Constants used for ap_ssi_parse_string's leave_name parameter
  35. */
  36. #define SSI_EXPAND_LEAVE_NAME 1
  37. #define SSI_EXPAND_DROP_NAME 0
  38. /*
  39. * This macro creates a bucket which contains an error message and appends it
  40. * to the current pass brigade
  41. */
  42. #define SSI_CREATE_ERROR_BUCKET(ctx, f, bb) APR_BRIGADE_INSERT_TAIL((bb), \
  43. apr_bucket_pool_create(apr_pstrdup((ctx)->pool, (ctx)->error_str), \
  44. strlen((ctx)->error_str), (ctx)->pool, \
  45. (f)->c->bucket_alloc))
  46. /*
  47. * These constants are used to set or clear flag bits.
  48. */
  49. #define SSI_FLAG_PRINTING (1<<0) /* Printing conditional lines. */
  50. #define SSI_FLAG_COND_TRUE (1<<1) /* Conditional eval'd to true. */
  51. #define SSI_FLAG_SIZE_IN_BYTES (1<<2) /* Sizes displayed in bytes. */
  52. #define SSI_FLAG_NO_EXEC (1<<3) /* No Exec in current context. */
  53. #define SSI_FLAG_SIZE_ABBREV (~(SSI_FLAG_SIZE_IN_BYTES))
  54. #define SSI_FLAG_CLEAR_PRINT_COND (~((SSI_FLAG_PRINTING) | \
  55. (SSI_FLAG_COND_TRUE)))
  56. #define SSI_FLAG_CLEAR_PRINTING (~(SSI_FLAG_PRINTING))
  57. /*
  58. * The public SSI context structure
  59. */
  60. typedef struct {
  61. /* permanent pool, use this for creating bucket data */
  62. apr_pool_t *pool;
  63. /* temp pool; will be cleared after the execution of every directive */
  64. apr_pool_t *dpool;
  65. /* See the SSI_FLAG_XXXXX definitions. */
  66. int flags;
  67. /* nesting of *invisible* ifs */
  68. int if_nesting_level;
  69. /* if true, the current buffer will be passed down the filter chain before
  70. * continuing with next input bucket and the variable will be reset to
  71. * false.
  72. */
  73. int flush_now;
  74. /* argument counter (of the current directive) */
  75. unsigned argc;
  76. /* currently configured error string */
  77. const char *error_str;
  78. /* currently configured time format */
  79. const char *time_str;
  80. /* the current request */
  81. request_rec *r;
  82. /* pointer to internal (non-public) data, don't touch */
  83. struct ssi_internal_ctx *intern;
  84. } include_ctx_t;
  85. typedef apr_status_t (include_handler_fn_t)(include_ctx_t *, ap_filter_t *,
  86. apr_bucket_brigade *);
  87. APR_DECLARE_OPTIONAL_FN(void, ap_ssi_get_tag_and_value,
  88. (include_ctx_t *ctx, char **tag, char **tag_val,
  89. int dodecode));
  90. APR_DECLARE_OPTIONAL_FN(char*, ap_ssi_parse_string,
  91. (include_ctx_t *ctx, const char *in, char *out,
  92. apr_size_t length, int leave_name));
  93. APR_DECLARE_OPTIONAL_FN(void, ap_register_include_handler,
  94. (char *tag, include_handler_fn_t *func));
  95. #endif /* MOD_INCLUDE */
  96. /** @} */