summaryrefslogtreecommitdiffstats
path: root/src/kim/lib/mac
diff options
context:
space:
mode:
authorAlexandra Ellwood <lxs@mit.edu>2008-09-30 20:05:17 +0000
committerAlexandra Ellwood <lxs@mit.edu>2008-09-30 20:05:17 +0000
commit6b6d24e1ae0aadffb9062ac94ae8e600e09dbef0 (patch)
tree2bddd1c4440a027ef8f1ee702bc53c0872de3703 /src/kim/lib/mac
parent7dea4900af23686834aa9c899206438a8d27076a (diff)
krb5 library-side changes for com_err based error strings
ticket: 6138 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20786 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/kim/lib/mac')
-rw-r--r--src/kim/lib/mac/kim_os_private.h4
-rw-r--r--src/kim/lib/mac/kim_os_string.c144
2 files changed, 25 insertions, 123 deletions
diff --git a/src/kim/lib/mac/kim_os_private.h b/src/kim/lib/mac/kim_os_private.h
index 039502a7e..f14440df4 100644
--- a/src/kim/lib/mac/kim_os_private.h
+++ b/src/kim/lib/mac/kim_os_private.h
@@ -41,10 +41,6 @@ kim_error kim_os_library_unlock_for_bundle_lookup (void);
kim_error kim_os_library_get_application_path (kim_string *out_path);
-
-kim_error kim_os_string_create_for_key (kim_string *out_string,
- kim_string in_key_string);
-
kim_error kim_os_string_create_from_cfstring (kim_string *out_string,
CFStringRef in_cfstring);
diff --git a/src/kim/lib/mac/kim_os_string.c b/src/kim/lib/mac/kim_os_string.c
index d51bc48b2..0529f3920 100644
--- a/src/kim/lib/mac/kim_os_string.c
+++ b/src/kim/lib/mac/kim_os_string.c
@@ -29,142 +29,48 @@
#include "kim_os_private.h"
/* ------------------------------------------------------------------------ */
-static kim_error kim_os_string_for_key_in_bundle (CFBundleRef in_bundle,
- CFStringRef in_key,
- kim_string *out_string)
-{
- kim_error err = KIM_NO_ERROR;
- kim_string string = NULL;
-
- if (!err && !in_bundle ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
- if (!err && !in_key ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
- if (!err && !out_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
-
- if (!err) {
- CFDictionaryRef dictionary = NULL;
- int release_dictionary = 0;
- CFStringRef cfstring = NULL;
-
-#if !KERBEROS_LITE
- if (kim_library_allow_home_directory_access ()) {
-#endif
- /* Accesses user's homedir to get localization information */
- dictionary = CFBundleGetLocalInfoDictionary (in_bundle);
-
-#if !KERBEROS_LITE
- } else {
- CFURLRef url = NULL;
- CFDataRef data = NULL;
- CFAllocatorRef allocator = CFGetAllocator (in_bundle);
- SInt32 code = 0;
-
- url = CFBundleCopyResourceURLForLocalization (in_bundle,
- CFSTR("InfoPlist"),
- CFSTR("strings"),
- NULL,
- CFSTR("English"));
-
- if (url && CFURLCreateDataAndPropertiesFromResource (allocator,
- url, &data,
- NULL, NULL,
- &code)) {
-
- dictionary = CFPropertyListCreateFromXMLData (allocator,
- data,
- kCFPropertyListImmutable,
- NULL);
- release_dictionary = 1;
- }
-
- if (data) { CFRelease (data); }
- if (url ) { CFRelease (url); }
- }
-#endif
-
- if (dictionary && (CFGetTypeID(dictionary) == CFDictionaryGetTypeID())) {
- cfstring = (CFStringRef) CFDictionaryGetValue (dictionary, in_key);
- }
-
- if (cfstring && (CFGetTypeID (cfstring) == CFStringGetTypeID ())) {
- err = kim_os_string_create_from_cfstring (&string, cfstring);
- }
-
- if (dictionary && release_dictionary) { CFRelease (dictionary); }
- }
-
- if (!err) {
- /* set to NULL if no string found */
- *out_string = string;
- string = NULL;
- }
-
- kim_string_free (&string);
-
- return check_error (err);
-}
-
-#pragma mark -
-
-/* ------------------------------------------------------------------------ */
kim_error kim_os_string_create_localized (kim_string *out_string,
kim_string in_string)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error lock_err = kim_os_library_lock_for_bundle_lookup ();
+ kim_error err = lock_err;
kim_string string = NULL;
+ CFStringRef cfkey = NULL;
if (!err && !out_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err && !in_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
- err = kim_os_string_create_for_key (&string, in_string);
- }
-
- if (!err && !string) {
- err = kim_string_copy (&string, in_string);
- }
-
- if (!err) {
- *out_string = string;
- string = NULL;
+ err = kim_os_string_get_cfstring (in_string, &cfkey);
}
- kim_string_free (&string);
-
- return check_error (err);
-}
-
-/* ------------------------------------------------------------------------ */
-
-kim_error kim_os_string_create_for_key (kim_string *out_string,
- kim_string in_key_string)
-{
- kim_error lock_err = kim_os_library_lock_for_bundle_lookup ();
- kim_error err = lock_err;
- CFStringRef key = NULL;
- kim_string string = NULL;
-
- if (!err && !out_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
- if (!err && !in_key_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
-
- if (!err) {
- err = kim_os_string_get_cfstring (in_key_string, &key);
- }
-
- if (!err) {
- /* Try to find the key, first searching in the framework */
+ if (!err && kim_library_allow_home_directory_access ()) {
+ CFStringRef cfstring = NULL;
CFBundleRef framework = CFBundleGetBundleWithIdentifier (CFSTR ("edu.mit.Kerberos"));
+ CFBundleRef main_bundle = CFBundleGetMainBundle ();
+
if (framework) {
- err = kim_os_string_for_key_in_bundle (framework, key, &string);
+ cfstring = CFCopyLocalizedStringFromTableInBundle (cfkey,
+ CFSTR ("InfoPlist"),
+ framework,
+ "");
+ }
+
+ if (main_bundle && !cfstring) {
+ cfstring = CFCopyLocalizedStringFromTableInBundle (cfkey,
+ CFSTR ("InfoPlist"),
+ main_bundle,
+ "");
+ }
+
+ if (!err && cfstring) {
+ err = kim_os_string_create_from_cfstring (&string, cfstring);
}
}
if (!err && !string) {
- /* If we didn't find it in the framwork, try in the main bundle */
- CFBundleRef main_bundle = CFBundleGetMainBundle ();
- if (main_bundle) {
- err = kim_os_string_for_key_in_bundle (main_bundle, key, &string);
- }
+ err = kim_string_copy (&string, in_string);
}
if (!err) {
@@ -172,8 +78,8 @@ kim_error kim_os_string_create_for_key (kim_string *out_string,
string = NULL;
}
+ if (cfkey) { CFRelease (cfkey); }
kim_string_free (&string);
- if (key) { CFRelease (key); }
if (!lock_err) { kim_os_library_unlock_for_bundle_lookup (); }