1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2009 Apple Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 Change History (most recent first):
19 $Log: safe_vproc.c,v $
20 Revision 1.3 2009/02/14 00:09:53 cheshire
21 Only log "Compiled without vproc_transaction support" when running on a system
22 where we expect that to be available -- if running on a system that doesn't even
23 have vproc_transaction, then it doesn't matter that the code was compiled without it.
25 Revision 1.2 2009/02/09 21:16:17 mcguire
26 <rdar://problem/5858533> Adopt vproc_transaction API in mDNSResponder
27 additional cleanup: don't alloc memory since we currently only expect to have one transaction
29 Revision 1.1 2009/02/06 03:06:49 mcguire
30 <rdar://problem/5858533> Adopt vproc_transaction API in mDNSResponder
37 #include "safe_vproc.h"
38 #include "mDNSDebug.h"
40 #ifdef VPROC_HAS_TRANSACTIONS
42 static vproc_transaction_t transaction
= NULL
;
44 void safe_vproc_transaction_begin(void)
46 if (vproc_transaction_begin
)
48 if (transaction
) { LogMsg("safe_vproc_transaction_begin: Already have a transaction"); }
49 else transaction
= vproc_transaction_begin(NULL
);
53 void safe_vproc_transaction_end(void)
55 if (vproc_transaction_end
)
57 if (transaction
) { vproc_transaction_end(NULL
, transaction
); transaction
= NULL
; }
58 else LogMsg("safe_vproc_transaction_end: No current transaction");
65 #include <CoreFoundation/CFString.h>
67 CF_EXPORT CFDictionaryRef
_CFCopySystemVersionDictionary(void);
68 CF_EXPORT
const CFStringRef _kCFSystemVersionBuildVersionKey
;
69 #define OSXVers_10_6_SnowLeopard 10
71 void safe_vproc_transaction_begin(void)
73 static int majorversion
= 0;
76 CFDictionaryRef vers
= _CFCopySystemVersionDictionary();
80 CFStringRef cfbuildver
= CFDictionaryGetValue(vers
, _kCFSystemVersionBuildVersionKey
);
81 if (cfbuildver
&& CFStringGetCString(cfbuildver
, buildver
, sizeof(buildver
), kCFStringEncodingUTF8
))
82 sscanf(buildver
, "%d", &majorversion
);
85 if (!majorversion
|| majorversion
>= OSXVers_10_6_SnowLeopard
)
86 LogMsg("Compiled without vproc_transaction support");
90 void safe_vproc_transaction_end(void) { }