a188c72002-03-12Martin Stjernholm // -*- pike -*- //
6d05fc2006-04-20Henrik Grubbström (Grubba) // $Id: roxen.h,v 1.30 2006/04/20 09:41:42 grubba Exp $
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
0e78081998-10-13Henrik Grubbström (Grubba) // Localization support
16188f2000-07-15Henrik Grubbström (Grubba)  #ifndef __LOCALEOBJECT #ifdef IN_ROXEN
c6ea9e2000-11-21Per Hedbor mixed get_locale(); #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
3983d42003-11-25Anders Johansson #ifdef DEBUG_CACHEABLE
6d05fc2006-04-20Henrik Grubbström (Grubba) # define CACHE(seconds) do { \ int old_cacheable = \ ([mapping(string:mixed)]REQUESTID->misc)->cacheable; \ ([mapping(string:mixed)]REQUESTID->misc)->cacheable = \ min(([mapping(string:mixed)]REQUESTID->misc)->cacheable,seconds); \ report_debug("%s:%d lowered cacheable to %d (was: %d, now: %d)\n", \ __FILE__, __LINE__, seconds, old_cacheable, \ ([mapping(string:mixed)]REQUESTID->misc)->cacheable); \ } while(0) # define RAISE_CACHE(seconds) do { \ int old_cacheable = \ ([mapping(string:mixed)]REQUESTID->misc)->cacheable; \ ([mapping(string:mixed)]REQUESTID->misc)->cacheable = \ max(([mapping(string:mixed)]REQUESTID->misc)->cacheable,seconds); \ report_debug("%s:%d raised cacheable to %d (was: %d, now: %d)\n", \ __FILE__, __LINE__, seconds, old_cacheable, \ ([mapping(string:mixed)]REQUESTID->misc)->cacheable); \ } while(0) # define NOCACHE() do { \ int old_cacheable = \ ([mapping(string:mixed)]REQUESTID->misc)->cacheable; \ ([mapping(string:mixed)]REQUESTID->misc)->cacheable = 0; \ report_debug("%s:%d set cacheable to 0 (was: %d)\n", \ __FILE__, __LINE__, old_cacheable, \ ([mapping(string:mixed)]REQUESTID->misc)->cacheable); \ } while(0) # 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 CACHE(seconds) \ ([mapping(string:mixed)]REQUESTID->misc)->cacheable = \ min(([mapping(string:mixed)]REQUESTID->misc)->cacheable,seconds) # define RAISE_CACHE(seconds) \ ([mapping(string:mixed)]REQUESTID->misc)->cacheable = \ max(([mapping(string:mixed)]REQUESTID->misc)->cacheable,seconds) # define NOCACHE() \ ([mapping(string:mixed)]REQUESTID->misc)->cacheable=0 # 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 */
16188f2000-07-15Henrik Grubbström (Grubba) #endif /* !_ROXEN_H_ */