2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
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
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.
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
22 #include "EOGlobalID.h"
26 #if !defined(__MINGW32__)
30 @implementation EOGlobalID
36 - (id)copyWithZone:(NSZone *)_zone {
37 [self doesNotRecognizeSelector:_cmd];
43 @implementation EOTemporaryGlobalID
45 static unsigned short sequence = 0;
46 static unsigned int ip;
49 static BOOL isInitialized = NO;
52 struct hostent *hostEntry;
55 gethostname(buf, 1024);
57 if ((hostEntry = gethostbyname(buf))) {
60 ptr = hostEntry->h_addr_list;
62 NSAssert((unsigned)hostEntry->h_length >= sizeof(ip),
63 @"invalid host address !");
64 memcpy(&ip, *ptr, sizeof(ip));
67 NSLog(@"WARNING: set IP address for EO key generation to 0.0.0.0 !");
72 NSLog(@"WARNING: set IP address for EO key generation to 0.0.0.0 !");
78 + (void)assignGloballyUniqueBytes:(unsigned char *)_buffer {
80 unsigned short sequence;
86 bufPtr = (void *)_buffer;
87 bufPtr->sequence = sequence++;
88 #if defined(__WIN32__)
89 bufPtr->pid = (unsigned short)GetCurrentProcessId();
91 bufPtr->pid = getpid();
93 bufPtr->time = time(NULL);
98 [self->isa assignGloballyUniqueBytes:&(self->idbuffer[0])];
102 - (BOOL)isTemporary {
106 - (BOOL)isEqual:(id)_other {
107 return _other == self ? YES : NO;
109 EOTemporaryGlobalID *otherKey;
111 if (_other == nil) return NO;
112 if (_other == self) return YES;
114 if (otherKey->isa != self->isa) return NO;
120 @end /* EOTemporaryGlobalID */