2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo 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
11 OGo 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.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #ifndef __NGExtensions_common_h__
23 #define __NGExtensions_common_h__
25 #import <Foundation/Foundation.h>
26 #import <Foundation/NSMapTable.h>
30 #elif defined(NeXT) || NeXT_Foundation_LIBRARY
31 # include <netinet/in.h>
33 # include <arpa/inet.h>
40 #if defined(__MINGW32__)
41 # define WITH_OPENSTEP 0
43 #elif defined(NeXT) || defined(WIN32)
44 # define WITH_OPENSTEP 1
47 # define NeXT_RUNTIME 1
50 # define WITH_OPENSTEP 0
54 #if LIB_FOUNDATION_LIBRARY
56 # import <objc/objc-api.h>
57 # import <objc/objc.h>
58 # import <objc/encoding.h>
59 # import <extensions/objc-runtime.h>
63 # define ASSIGN(object, value) \
64 ({id __object = (id)object; \
65 id __value = (id)value; \
66 if (__value != __object) { if (__value) [__value retain]; \
67 if (__object) [__object release]; \
71 # define ASSIGNCOPY(object, value) \
72 ({id __object = (id)object; \
73 id __value = (id)value; \
74 if (__value != __object) { if (__value) __value = [__value copy]; \
75 if (__object) [__object release]; \
79 #if defined(LIB_FOUNDATION_LIBRARY)
96 static inline const char *index(const char *str, char c) __attribute__((unused));
98 static const char *index(const char *str, char c) {
99 while ((*str != '\0') && (*str != c)) str++;
100 if (*str == '\0') return NULL;
106 # define BEGIN_PROFILE \
107 { NSTimeInterval __ti = [[NSDate date] timeIntervalSince1970];
109 # define END_PROFILE \
110 __ti = [[NSDate date] timeIntervalSince1970] - __ti;\
112 printf("***PROF[%s]: %0.3fs\n", __PRETTY_FUNCTION__, __ti);\
113 else if (__ti > 0.005) \
114 printf("PROF[%s]: %0.3fs\n", __PRETTY_FUNCTION__, __ti);\
117 # define PROFILE_CHECKPOINT(__key__) \
118 printf("---PROF[%s] CP %s: %0.3fs\n", __PRETTY_FUNCTION__, __key__,\
119 [[NSDate date] timeIntervalSince1970] - __ti)
122 # define BEGIN_PROFILE {
123 # define END_PROFILE }
124 # define PROFILE_CHECKPOINT(__key__)