]> err.no Git - sope/blob - sope-appserver/NGObjWeb/common.h
minor code cleanups
[sope] / sope-appserver / NGObjWeb / common.h
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #ifndef __NGObjWeb_common_H__
23 #define __NGObjWeb_common_H__
24
25 // common include files
26
27 #if !defined(__MINGW32__)
28 #  include <strings.h>
29 #endif
30
31 #include <unistd.h>
32 #include <sys/stat.h>
33
34 #if NeXT_Foundation_LIBRARY
35 #  include <NGExtensions/NGObjectMacros.h>
36 #  include <NGExtensions/NSString+Ext.h>
37 #  include <NGExtensions/NSRunLoop+FileObjects.h>
38 #  include "UnixSignalHandler.h"
39 #endif
40
41 #if !LIB_FOUNDATION_LIBRARY
42 #  include <NGExtensions/NGPropertyListParser.h>
43 #endif
44
45 #include <objc/objc-api.h>
46 #import <Foundation/Foundation.h>
47 #import <Foundation/NSDateFormatter.h>
48 #import <Foundation/NSNumberFormatter.h>
49 #import <Foundation/NSHost.h>
50
51 #include <NGExtensions/NGExtensions.h>
52 #include <NGExtensions/NGLogging.h>
53 #include <NGStreams/NGStreams.h>
54
55 #if NeXT_RUNTIME || APPLE_RUNTIME
56 #  ifndef sel_get_name
57 #    define sel_get_name(__XXX__)    sel_getName(__XXX__)
58 #    define sel_get_any_uid(__XXX__) sel_getUid(__XXX__)
59 #  endif
60 #endif
61
62 #define IS_DEPRECATED \
63   [self warnWithFormat:@"used deprecated method: %s:%i.", \
64           __PRETTY_FUNCTION__, __LINE__];
65
66 #if PROFILE
67 #  define BEGIN_PROFILE \
68      { NSTimeInterval __ti = [[NSDate date] timeIntervalSince1970],__last=__ti;
69
70 #  define END_PROFILE \
71      __ti = [[NSDate date] timeIntervalSince1970] - __ti;\
72      if (__ti > 0.05) \
73        printf("***PROF[%s]: %0.3fs\n", __PRETTY_FUNCTION__, __ti);\
74      else if (__ti > 0.005) \
75        printf("PROF[%s]: %0.3fs\n", __PRETTY_FUNCTION__, __ti);\
76      }
77
78 #  define PROFILE_CHECKPOINT(__key__) \
79      {\
80        NSTimeInterval __new = [[NSDate date] timeIntervalSince1970];\
81        printf("---PROF[%s] CP %s: %0.3fs %0.3fs\n", __PRETTY_FUNCTION__,\
82               __key__, __new - __ti, __new - __last);\
83        __last=__new; \
84      }
85
86 #else
87 #  define BEGIN_PROFILE {
88 #  define END_PROFILE   }
89 #  define PROFILE_CHECKPOINT(__key__)
90 #endif
91
92 @interface NSException(setUserInfo)
93 - (id)setReason:(NSString *)_reason;
94 - (id)setUserInfo:(NSDictionary *)_userInfo;
95 @end
96
97 #endif /* __NGObjWeb_common_H__ */