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.
21 #include "safe_vproc.h"
22 #include "mDNSDebug.h"
23 #include <TargetConditionals.h>
25 #if defined(VPROC_HAS_TRANSACTIONS) && !TARGET_OS_EMBEDDED
27 static vproc_transaction_t transaction
= NULL
;
29 void safe_vproc_transaction_begin(void)
31 if (vproc_transaction_begin
)
33 if (transaction
) { LogMsg("safe_vproc_transaction_begin: Already have a transaction"); }
34 else transaction
= vproc_transaction_begin(NULL
);
38 void safe_vproc_transaction_end(void)
40 if (vproc_transaction_end
)
42 if (transaction
) { vproc_transaction_end(NULL
, transaction
); transaction
= NULL
; }
43 else LogMsg("safe_vproc_transaction_end: No current transaction");
49 #if ! TARGET_OS_EMBEDDED
51 #include <CoreFoundation/CFString.h>
53 CF_EXPORT CFDictionaryRef
_CFCopySystemVersionDictionary(void);
54 CF_EXPORT
const CFStringRef _kCFSystemVersionBuildVersionKey
;
55 #define OSXVers_10_6_SnowLeopard 10
57 void safe_vproc_transaction_begin(void)
59 static int majorversion
= 0;
62 CFDictionaryRef vers
= _CFCopySystemVersionDictionary();
66 CFStringRef cfbuildver
= CFDictionaryGetValue(vers
, _kCFSystemVersionBuildVersionKey
);
67 if (cfbuildver
&& CFStringGetCString(cfbuildver
, buildver
, sizeof(buildver
), kCFStringEncodingUTF8
))
68 sscanf(buildver
, "%d", &majorversion
);
71 if (!majorversion
|| majorversion
>= OSXVers_10_6_SnowLeopard
)
72 LogMsg("Compiled without vproc_transaction support");
78 void safe_vproc_transaction_begin(void) { }
82 void safe_vproc_transaction_end(void) { }