llapr.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**
  2. * @file llapr.h
  3. * @author Phoenix
  4. * @date 2004-11-28
  5. * @brief Helper functions for using the apache portable runtime library.
  6. *
  7. * $LicenseInfo:firstyear=2004&license=viewergpl$
  8. *
  9. * Copyright (c) 2004-2009, Linden Research, Inc.
  10. *
  11. * Second Life Viewer Source Code
  12. * The source code in this file ("Source Code") is provided by Linden Lab
  13. * to you under the terms of the GNU General Public License, version 2.0
  14. * ("GPL"), unless you have obtained a separate licensing agreement
  15. * ("Other License"), formally executed by you and Linden Lab. Terms of
  16. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  17. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  18. *
  19. * There are special exceptions to the terms and conditions of the GPL as
  20. * it is applied to this Source Code. View the full text of the exception
  21. * in the file doc/FLOSS-exception.txt in this software distribution, or
  22. * online at
  23. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  24. *
  25. * By copying, modifying or distributing this software, you acknowledge
  26. * that you have read and understood your obligations described above,
  27. * and agree to abide by those obligations.
  28. *
  29. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  30. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  31. * COMPLETENESS OR PERFORMANCE.
  32. * $/LicenseInfo$
  33. */
  34. #ifndef LL_LLAPR_H
  35. #define LL_LLAPR_H
  36. // Modifies APR declarations for static linking under Windows
  37. #include "llpreprocessor.h"
  38. #if LL_LINUX
  39. # include <sys/param.h> // Need PATH_MAX in APR headers...
  40. #endif
  41. #include "apr.h"
  42. #include "apr_errno.h"
  43. #include "apr_pools.h"
  44. #include "apr_dso.h"
  45. #include "llstring.h"
  46. extern bool gAPRInitialized;
  47. // Function which appropriately logs error or remains quiet on APR_SUCCESS.
  48. // Returns true if status is an error condition.
  49. bool ll_apr_warn_status(apr_status_t status);
  50. // There is a whole other APR error-message function if you pass a DSO handle.
  51. bool ll_apr_warn_status(apr_status_t status, apr_dso_handle_t* handle);
  52. extern "C" apr_pool_t* gAPRPoolp; // Global APR memory pool
  53. // Initializes the common APR constructs: APR itself, the global pool and a
  54. // mutex.
  55. void ll_init_apr();
  56. // Cleans up those common APR constructs.
  57. void ll_cleanup_apr();
  58. // This class manages apr_pool_t and destroys the allocated APR pool in its
  59. // destructor.
  60. class LLAPRPool
  61. {
  62. public:
  63. LLAPRPool(apr_pool_t* parent = NULL, apr_size_t size = 0,
  64. bool release_pool = true);
  65. virtual ~LLAPRPool();
  66. virtual apr_pool_t* getAPRPool();
  67. LL_INLINE apr_status_t getStatus() { return mStatus; }
  68. protected:
  69. void releaseAPRPool();
  70. void createAPRPool();
  71. protected:
  72. apr_pool_t* mPool; // Pointing to an apr_pool
  73. apr_pool_t* mParent; // Parent pool
  74. // Max size of mPool, mPool should return memory to system if allocated
  75. // memory beyond this limit. However it seems not to work.
  76. apr_size_t mMaxSize;
  77. apr_status_t mStatus; // Status when creating the pool
  78. // If set, mPool is destroyed when LLAPRPool is deleted. Default value is
  79. // true.
  80. bool mReleasePoolFlag;
  81. };
  82. #endif // LL_LLAPR_H