a188c72002-03-12Martin Stjernholm // -*- pike -*- //
0917d32013-03-04Anders Johansson // $Id$
16188f2000-07-15Henrik Grubbström (Grubba) 
b1fca01996-11-12Per Hedbor #ifndef _ROXEN_H_
b878961999-11-06Per Hedbor 
b1fca01996-11-12Per Hedbor #define _ROXEN_H_ #include <config.h> #define HOST_TO_IP 'H' #define IP_TO_HOST 'I'
6d05fc2006-04-20Henrik Grubbström (Grubba) #ifndef REQUESTID #define REQUESTID id #endif
1e6cb62008-11-05Martin Stjernholm // Various useful macros #define TOSTR2(X) #X #define TOSTR(X) TOSTR2(X)
0e78081998-10-13Henrik Grubbström (Grubba) // Localization support
16188f2000-07-15Henrik Grubbström (Grubba)  #ifndef __LOCALEOBJECT #ifdef IN_ROXEN
7d41ae2017-11-17Karl Gustav Sterneberg string get_locale();
c6ea9e2000-11-21Per Hedbor #define __LOCALE (get_locale)
16188f2000-07-15Henrik Grubbström (Grubba) #else /* !IN_ROXEN */
c6ea9e2000-11-21Per Hedbor #define __LOCALE (roxen.get_locale)
16188f2000-07-15Henrik Grubbström (Grubba) #endif /* IN_ROXEN */ #endif /* !__LOCALEOBJECT */
d05f9c2000-07-11Martin Nilsson #ifndef _STR_LOCALE
c6ea9e2000-11-21Per Hedbor #define _STR_LOCALE(X, Y, Z) Locale.translate(X, __LOCALE(), Y, Z)
16188f2000-07-15Henrik Grubbström (Grubba) #endif /* !_STR_LOCALE */
d05f9c2000-07-11Martin Nilsson 
b9a7022000-07-15Andreas Lange #ifndef _DEF_LOCALE
79ca872000-11-24Per Hedbor # define _DEF_LOCALE(X, Y, Z) ([object(Locale.DeferredLocale)|string]((mixed)Locale.DeferredLocale(X,__LOCALE,Y,Z)))
16188f2000-07-15Henrik Grubbström (Grubba) #endif /* !_DEF_LOCALE */
b9a7022000-07-15Andreas Lange 
1c783c2000-07-15Andreas Lange #ifndef _LOCALE_FUN
c6ea9e2000-11-21Per Hedbor #define _LOCALE_FUN(X, Y, Z) Locale.call(X, __LOCALE(), Y, Z)
16188f2000-07-15Henrik Grubbström (Grubba) #endif /* !_LOCALE_FUN */
a188c72002-03-12Martin Stjernholm // Debug macros. #ifdef DEBUG #define DO_IF_DEBUG(X...) X
9674ab2004-04-21Martin Stjernholm #define ASSERT_IF_DEBUG(TEST, ARGS...) do { \
322f592004-04-21Martin Stjernholm  if (!(TEST)) error ("Assertion failed: " #TEST "\n", ARGS); \
9674ab2004-04-21Martin Stjernholm  } while (0)
a188c72002-03-12Martin Stjernholm #else #define DO_IF_DEBUG(X...)
9674ab2004-04-21Martin Stjernholm #define ASSERT_IF_DEBUG(TEST, ARGS...) do {} while (0)
a188c72002-03-12Martin Stjernholm #endif
1f88ef2009-04-17Martin Stjernholm // These macros are for compatibility. The recommended way is to call // the functions in RequestID directly instead. #define CACHE(seconds) REQUESTID->lower_max_cache (seconds) #define RAISE_CACHE(seconds) REQUESTID->raise_max_cache (seconds) #define NOCACHE() REQUESTID->set_max_cache (0)
0c401e2021-05-05Jonas Walldén // In some cases it's good to signal that caching is indefinite, e.g. to // avoid installing a call-out to expire an image cache entry in RAM that // is declared safe for years to come (since the server will restart long // before then). // // Code that wishes to check for use of indefinite caching should compare // to the absolute or relative timestamp which is lower to accomodate the // case where a delta is added to a timestamp from the past. #define CACHE_INDEF_SECS (5 * 365 * 86400) #define CACHE_INDEF_REL_LIMIT (4 * 365 * 86400) #define CACHE_INDEF_ABS_LIMIT (time() + 4 * 365 * 86400) #define CACHE_INDEFINITELY() REQUESTID->raise_max_cache(CACHE_INDEF_SECS)
3983d42003-11-25Anders Johansson #ifdef DEBUG_CACHEABLE
6d05fc2006-04-20Henrik Grubbström (Grubba) # define NO_PROTO_CACHE() do { \ ([mapping(string:mixed)]REQUESTID->misc)->no_proto_cache = 1; \ report_debug("%s:%d disabled proto cache\n", __FILE__, __LINE__); \ } while(0) # define PROTO_CACHE() do { \ ([mapping(string:mixed)]REQUESTID->misc)->no_proto_cache = 0; \ report_debug("%s:%d enabled proto cache\n", __FILE__, __LINE__); \ } while(0)
3983d42003-11-25Anders Johansson #else
6d05fc2006-04-20Henrik Grubbström (Grubba) # define NO_PROTO_CACHE() \ ([mapping(string:mixed)]REQUESTID->misc)->no_proto_cache = 1 # define PROTO_CACHE() \ ([mapping(string:mixed)]REQUESTID->misc)->no_proto_cache = 0
3983d42003-11-25Anders Johansson #endif /* DEBUG_CACHEABLE */
d584002009-10-31Martin Stjernholm // The OBJ_COUNT_DEBUG define adds a suffix "[xxx]" to the end of many // _sprintf('O') strings, where xxx is a unique number for the object // instance. Useful to see the real lifetime of objects. #ifdef OBJ_COUNT_DEBUG #define DECLARE_OBJ_COUNT \ protected int __object_count = ++all_constants()->_obj_count #define OBJ_COUNT ("[" + this_program::__object_count + "]") #else #define DECLARE_OBJ_COUNT ; #define OBJ_COUNT "" #endif
16188f2000-07-15Henrik Grubbström (Grubba) #endif /* !_ROXEN_H_ */