K5_KEY_CCAPI_REQUEST_PORT,
K5_KEY_CCAPI_REPLY_STREAM,
K5_KEY_CCAPI_SERVER_DIED,
+ K5_KEY_COM_ERR_REENTER,
#endif
K5_KEY_MAX
} k5_key_t;
--- /dev/null
+/*
+ * Copyright 2005-2008 Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ */
+
+
+#ifndef KIM_LIBRARY_H
+#define KIM_LIBRARY_H
+
+#include <kim/kim.h>
+
+
+kim_error kim_library_set_allow_home_directory_access (kim_boolean in_allow_access);
+
+kim_boolean kim_library_allow_home_directory_access (void);
+
+kim_error kim_library_set_allow_automatic_prompting (kim_boolean in_allow_automatic_prompting);
+
+kim_boolean kim_library_allow_automatic_prompting (void);
+
+#endif /* KIM_LIBRARY_H */
}
}
- if (err == KIM_NO_CREDENTIALS_ECODE) {
+ if (err == KIM_NO_CREDENTIALS_ERR) {
/* ccache is empty, just ignore it */
err = KIM_NO_ERROR;
}
kim_error err = KIM_NO_ERROR;
kim_ccache_iterator ccache_iterator = NULL;
- if (!err && !out_ccache_iterator) { err = param_error (1, "out_ccache_iterator", "NULL"); }
+ if (!err && !out_ccache_iterator) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
ccache_iterator = malloc (sizeof (*ccache_iterator));
if (ccache_iterator) {
*ccache_iterator = kim_ccache_iterator_initializer;
} else {
- err = os_error (errno);
+ err = KIM_OUT_OF_MEMORY_ERR;
}
}
kim_error err = KIM_NO_ERROR;
krb5_ccache ccache = NULL;
- if (!err && !in_ccache_iterator) { err = param_error (1, "in_ccache_iterator", "NULL"); }
- if (!err && !out_ccache ) { err = param_error (2, "out_ccache", "NULL"); }
+ if (!err && !in_ccache_iterator) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
krb5_error_code terr = krb5_cccol_cursor_next (in_ccache_iterator->context,
{
kim_error err = KIM_NO_ERROR;
- if (!err && !out_resolve_name) { err = param_error (1, "out_resolve_name", "NULL"); }
- if (!err && !in_name ) { err = param_error (2, "in_name", "NULL"); }
- if (!err && !in_type ) { err = param_error (2, "in_type", "NULL"); }
+ if (!err && !out_resolve_name) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_name ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_type ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_string_create_from_format (out_resolve_name, "%s:%s",
kim_error err = KIM_NO_ERROR;
kim_ccache ccache = NULL;
- if (!err && !out_ccache) { err = param_error (1, "out_ccache", "NULL"); }
+ if (!err && !out_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
ccache = malloc (sizeof (*ccache));
- if (!ccache) { err = os_error (errno); }
+ if (!ccache) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_credential credential = NULL;
kim_identity client_identity = NULL;
- if (!err && !out_ccache) { err = param_error (1, "out_ccache", "NULL"); }
+ if (!err && !out_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_credential_create_new (&credential, in_client_identity, in_options);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !out_ccache ) { err = param_error (1, "out_ccache", "NULL"); }
- if (!err && !in_client_identity) { err = param_error (2, "in_client_identity", "NULL"); }
+ if (!err && !out_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_client_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_create_from_client_identity (out_ccache, in_client_identity);
kim_ccache_iterator iterator = NULL;
kim_boolean found = FALSE;
- if (!err && !out_ccache ) { err = param_error (1, "out_ccache", "NULL"); }
- if (!err && !in_client_identity) { err = param_error (2, "in_client_identity", "NULL"); }
+ if (!err && !out_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_client_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_iterator_create (&iterator);
err = kim_identity_get_display_string (in_client_identity, &string);
if (!err) {
- err = kim_error_set_message_for_code (KIM_NO_SUCH_PRINCIPAL_ECODE,
+ err = kim_error_set_message_for_code (KIM_NO_SUCH_PRINCIPAL_ERR,
string);
}
kim_credential credential = NULL;
kim_identity client_identity = NULL;
- if (!err && !out_ccache) { err = param_error (1, "out_ccache", "NULL"); }
+ if (!err && !out_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_credential_create_from_keytab (&credential, in_identity,
kim_error err = KIM_NO_ERROR;
kim_ccache ccache = NULL;
- if (!err && !out_ccache) { err = param_error (1, "out_ccache", "NULL"); }
+ if (!err && !out_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_allocate (&ccache);
kim_error err = KIM_NO_ERROR;
kim_ccache ccache = NULL;
- if (!err && !out_ccache ) { err = param_error (1, "out_ccache", "NULL"); }
- if (!err && !in_display_name) { err = param_error (2, "in_display_name", "NULL"); }
+ if (!err && !out_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_display_name) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_allocate (&ccache);
kim_error err = KIM_NO_ERROR;
kim_string resolve_name = NULL;
- if (!err && !out_ccache) { err = param_error (1, "out_ccache", "NULL"); }
- if (!err && !in_name ) { err = param_error (2, "in_name", "NULL"); }
- if (!err && !in_type ) { err = param_error (2, "in_type", "NULL"); }
+ if (!err && !out_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_name ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_type ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_create_resolve_name (&resolve_name, in_name, in_type);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !out_ccache ) { err = param_error (1, "out_ccache", "NULL"); }
- if (!err && !in_krb5_ccache ) { err = param_error (2, "in_krb5_ccache", "NULL"); }
- if (!err && !in_krb5_context) { err = param_error (3, "in_krb5_context", "NULL"); }
+ if (!err && !out_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_krb5_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_krb5_context) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
kim_string type = krb5_cc_get_type (in_krb5_context, in_krb5_ccache);
kim_string name = NULL;
kim_string type = NULL;
- if (!err && !out_ccache) { err = param_error (1, "out_ccache", "NULL"); }
- if (!err && !in_ccache ) { err = param_error (2, "in_ccache", "NULL"); }
+ if (!err && !out_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_get_name (in_ccache, &name);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_ccache ) { err = param_error (1, "in_ccache", "NULL"); }
- if (!err && !in_compare_to_ccache) { err = param_error (2, "in_compare_to_ccache", "NULL"); }
- if (!err && !out_equal ) { err = param_error (3, "out_equal", "NULL"); }
+ if (!err && !in_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_compare_to_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_equal ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_equal = kim_ccache_k5ccaches_are_equal (in_ccache->context,
kim_error err = KIM_NO_ERROR;
kim_string resolve_name = NULL;
- if (!err && !in_ccache ) { err = param_error (1, "in_ccache", "NULL"); }
- if (!err && !in_krb5_context) { err = param_error (2, "in_krb5_context", "NULL"); }
- if (!err && !out_krb5_ccache) { err = param_error (2, "out_krb5_ccache", "NULL"); }
+ if (!err && !in_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_krb5_context) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_krb5_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_get_display_name (in_ccache, &resolve_name);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_ccache) { err = param_error (1, "in_ccache", "NULL"); }
- if (!err && !out_type ) { err = param_error (2, "out_type", "NULL"); }
+ if (!err && !in_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_type ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_string_copy (out_type, krb5_cc_get_type (in_ccache->context,
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_ccache) { err = param_error (1, "in_ccache", "NULL"); }
- if (!err && !out_name ) { err = param_error (2, "out_name", "NULL"); }
+ if (!err && !in_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_name ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_string_copy (out_name, krb5_cc_get_name (in_ccache->context,
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_ccache ) { err = param_error (1, "in_ccache", "NULL"); }
- if (!err && !out_display_name) { err = param_error (2, "out_display_name", "NULL"); }
+ if (!err && !in_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_display_name) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
kim_string type = krb5_cc_get_type (in_ccache->context,
kim_error err = KIM_NO_ERROR;
krb5_principal principal = NULL;
- if (!err && !in_ccache ) { err = param_error (1, "in_ccache", "NULL"); }
- if (!err && !out_client_identity) { err = param_error (2, "out_client_identity", "NULL"); }
+ if (!err && !in_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_client_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = krb5_error (in_ccache->context,
kim_credential_state dominant_state = kim_credentials_state_valid;
kim_credential dominant_credential = NULL;
- if (!err && !in_ccache) { err = param_error (1, "in_ccache", "NULL"); }
+ if (!err && !in_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_credential_iterator_create (&iterator, in_ccache);
}
if (!err) {
- err = kim_error_set_message_for_code (KIM_NO_CREDENTIALS_ECODE,
+ err = kim_error_set_message_for_code (KIM_NO_CREDENTIALS_ERR,
identity_string);
}
kim_credential_state state = kim_credentials_state_valid;
kim_credential credential = NULL;
- if (!err && !in_ccache ) { err = param_error (1, "in_ccache", "NULL"); }
- if (!err && !out_credential) { err = param_error (2, "out_credential", "NULL"); }
+ if (!err && !in_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_get_dominant_credential (in_ccache,
if (!err) {
if (state == kim_credentials_state_expired) {
- err = kim_error_set_message_for_code (KIM_CREDENTIALS_EXPIRED_ECODE,
+ err = kim_error_set_message_for_code (KIM_CREDENTIALS_EXPIRED_ERR,
identity_string);
} else if (state == kim_credentials_state_not_yet_valid ||
state == kim_credentials_state_needs_validation) {
- err = kim_error_set_message_for_code (KIM_NEEDS_VALIDATION_ECODE,
+ err = kim_error_set_message_for_code (KIM_NEEDS_VALIDATION_ERR,
identity_string);
} else if (state == kim_credentials_state_address_mismatch) {
- err = kim_error_set_message_for_code (KIM_BAD_IP_ADDRESS_ECODE,
+ err = kim_error_set_message_for_code (KIM_BAD_IP_ADDRESS_ERR,
identity_string);
} else {
/* just default to this */
- err = kim_error_set_message_for_code (KIM_NEEDS_VALIDATION_ECODE,
+ err = kim_error_set_message_for_code (KIM_NEEDS_VALIDATION_ERR,
identity_string);
}
}
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_ccache) { err = param_error (1, "in_ccache", "NULL"); }
- if (!err && !out_state) { err = param_error (2, "out_state", "NULL"); }
+ if (!err && !in_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_state) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_get_dominant_credential (in_ccache,
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
- if (!err && !in_ccache ) { err = param_error (1, "in_ccache", "NULL"); }
- if (!err && !out_start_time) { err = param_error (2, "out_start_time", "NULL"); }
+ if (!err && !in_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_start_time) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_get_dominant_credential (in_ccache, NULL, NULL,
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
- if (!err && !in_ccache ) { err = param_error (1, "in_ccache", "NULL"); }
- if (!err && !out_expiration_time) { err = param_error (2, "out_expiration_time", "NULL"); }
+ if (!err && !in_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_expiration_time) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_get_dominant_credential (in_ccache, NULL, NULL,
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
- if (!err && !in_ccache ) { err = param_error (1, "in_ccache", "NULL"); }
- if (!err && !out_renewal_expiration_time) { err = param_error (2, "out_renewal_expiration_time", "NULL"); }
+ if (!err && !in_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_renewal_expiration_time) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_get_dominant_credential (in_ccache, NULL, NULL,
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_ccache) { err = param_error (1, "io_ccache", "NULL"); }
+ if (!err && !io_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
char *environment_ccache_name = getenv ("KRB5CCNAME");
err = kim_ccache_get_display_name (io_ccache, &display_name);
if (!err) {
- err = kim_error_set_message_for_code (KIM_CANT_BECOME_DEFAULT_ECODE,
+ err = kim_error_set_message_for_code (KIM_CANT_BECOME_DEFAULT_ERR,
display_name);
}
/* get a CCAPI ccache for this cache */
if (!err) {
- err = ccapi_error (cc_initialize (&cc_context, ccapi_version_4,
- NULL, NULL));
+ err = cc_initialize (&cc_context, ccapi_version_4, NULL, NULL);
}
if (!err) {
- err = ccapi_error (cc_context_open_ccache (cc_context, name,
- &cc_ccache));
+ err = cc_context_open_ccache (cc_context, name, &cc_ccache);
}
if (!err) {
- err = ccapi_error (cc_ccache_set_default (cc_ccache));
+ err = cc_ccache_set_default (cc_ccache);
}
if (cc_context) { cc_context_release (cc_context); }
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
- if (!err && !in_ccache) { err = param_error (1, "in_ccache", "NULL"); }
+ if (!err && !in_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_get_valid_credential (in_ccache, &credential);
kim_credential credential = NULL;
kim_identity client_identity = NULL;
- if (!err && !in_ccache) { err = param_error (1, "in_ccache", "NULL"); }
+ if (!err && !in_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_get_valid_credential (in_ccache, &credential);
kim_credential credential = NULL;
kim_identity client_identity = NULL;
- if (!err && !in_ccache) { err = param_error (1, "in_ccache", "NULL"); }
+ if (!err && !in_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_ccache_get_valid_credential (in_ccache, &credential);
kim_error err = KIM_NO_ERROR;
kim_credential_iterator credential_iterator = NULL;
- if (!err && !out_credential_iterator) { err = param_error (1, "out_credential_iterator", "NULL"); }
- if (!err && !in_ccache ) { err = param_error (2, "in_ccache", "NULL"); }
+ if (!err && !out_credential_iterator) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_ccache ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
credential_iterator = malloc (sizeof (*credential_iterator));
if (credential_iterator) {
*credential_iterator = kim_credential_iterator_initializer;
} else {
- err = os_error (errno);
+ err = KIM_OUT_OF_MEMORY_ERR;
}
}
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_credential_iterator) { err = param_error (1, "in_credential_iterator", "NULL"); }
- if (!err && !out_credential ) { err = param_error (2, "out_credential", "NULL"); }
+ if (!err && !in_credential_iterator) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_credential ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
krb5_creds creds;
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
- if (!err && !out_credential) { err = param_error (1, "out_credential", "NULL"); }
+ if (!err && !out_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
credential = malloc (sizeof (*credential));
- if (!credential) { err = os_error (errno); }
+ if (!credential) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
- if (!err && !out_credential) { err = param_error (1, "out_credential", "NULL"); }
+ if (!err && !out_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_credential_allocate (&credential);
kim_string service_name = NULL;
krb5_get_init_creds_opt *init_cred_options = NULL;
- if (!err && !out_credential) { err = param_error (1, "out_credential", "NULL"); }
+ if (!err && !out_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_credential_allocate (&credential);
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
- if (!err && !out_credential ) { err = param_error (1, "out_credential", "NULL"); }
- if (!err && !in_krb5_creds ) { err = param_error (2, "in_krb5_creds", "NULL"); }
- if (!err && !in_krb5_context) { err = param_error (3, "in_krb5_context", "NULL"); }
+ if (!err && !out_credential ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_krb5_creds ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_krb5_context) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_credential_allocate (&credential);
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
- if (!err && !out_credential) { err = param_error (1, "out_credential", "NULL"); }
- if (!err && !in_credential ) { err = param_error (2, "in_credential", "NULL"); }
+ if (!err && !out_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_credential ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_credential_allocate (&credential);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_credential ) { err = param_error (1, "in_credential", "NULL"); }
- if (!err && !in_krb5_context) { err = param_error (2, "in_krb5_context", "NULL"); }
- if (!err && !out_krb5_creds ) { err = param_error (3, "out_krb5_creds", "NULL"); }
+ if (!err && !in_credential ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_krb5_context) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_krb5_creds ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = krb5_error (in_krb5_context,
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_credential ) { err = param_error (1, "in_credential", "NULL"); }
- if (!err && !out_client_identity) { err = param_error (2, "out_client_identity", "NULL"); }
+ if (!err && !in_credential ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_client_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_identity_create_from_krb5_principal (out_client_identity,
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_credential ) { err = param_error (1, "in_credential", "NULL"); }
- if (!err && !out_service_identity) { err = param_error (2, "out_service_identity", "NULL"); }
+ if (!err && !in_credential ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_service_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_identity_create_from_krb5_principal (out_service_identity,
kim_error err = KIM_NO_ERROR;
kim_identity service = NULL;
- if (!err && !in_credential) { err = param_error (1, "in_credential", "NULL"); }
- if (!err && !out_is_tgt ) { err = param_error (2, "out_is_tgt", "NULL"); }
+ if (!err && !in_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_is_tgt ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_credential_get_service_identity (in_credential, &service);
kim_time start_time = 0;
krb5_timestamp now = 0;
- if (!err && !in_credential) { err = param_error (1, "in_credential", "NULL"); }
- if (!err && !out_state ) { err = param_error (2, "out_state", "NULL"); }
+ if (!err && !in_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_state ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_credential_get_expiration_time (in_credential, &expiration_time);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_credential) { err = param_error (1, "in_credential", "NULL"); }
+ if (!err && !in_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_start_time = (in_credential->creds->times.starttime ?
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_credential) { err = param_error (1, "in_credential", "NULL"); }
+ if (!err && !in_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_expiration_time = in_credential->creds->times.endtime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_credential) { err = param_error (1, "in_credential", "NULL"); }
+ if (!err && !in_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_renewal_expiration_time = in_credential->creds->times.renew_till;
krb5_principal client_principal = NULL;
kim_boolean destroy_ccache_on_error = FALSE;
- if (!err && !in_credential ) { err = param_error (1, "in_credential", "NULL"); }
- if (!err && !in_client_identity) { err = param_error (2, "in_client_identity", "NULL"); }
+ if (!err && !in_credential ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_client_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = krb5_error (NULL, krb5_init_context (&context));
if (!err) {
err = kim_ccache_get_krb5_ccache (ccache, context, &k5ccache);
- } else if (err == KIM_NO_SUCH_PRINCIPAL_ECODE) {
+ } else if (err == KIM_NO_SUCH_PRINCIPAL_ERR) {
/* Nothing to replace, create a new ccache */
err = krb5_error (context,
krb5_cc_new_unique (context, "API", NULL,
krb5_principal service_principal = NULL;
krb5_keytab keytab = NULL;
- if (!err && !in_credential) { err = param_error (1, "in_credential", "NULL"); }
+ if (!err && !in_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = krb5_error (NULL, krb5_init_secure_context (&scontext));
kim_string service_name = NULL;
krb5_ccache ccache = NULL;
- if (!err && !io_credential) { err = param_error (1, "io_credential", "NULL"); }
+ if (!err && !io_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
kim_options options = in_options;
kim_string service_name = NULL;
krb5_ccache ccache = NULL;
- if (!err && !io_credential) { err = param_error (1, "io_credential", "NULL"); }
+ if (!err && !io_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
kim_options options = in_options;
kim_string format = NULL;
kim_string string = NULL;
- if (!err && !in_function) { err = param_error (1, "in_function", "NULL"); }
- if (!err && !in_format ) { err = param_error (2, "in_format", "NULL"); }
+ if (!err && !in_function) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_format ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_string_create_from_format (&format, "%s(): %s",
if (!last_error) {
last_error = malloc (sizeof (*last_error));
if (!last_error) {
- err = KIM_OUT_OF_MEMORY_ECODE;
+ err = KIM_OUT_OF_MEMORY_ERR;
} else {
last_error->code = KIM_NO_ERROR;
err = k5_setspecific (K5_KEY_KIM_ERROR_MESSAGE, last_error);
static kim_boolean kim_error_is_builtin (kim_error in_error)
{
return (in_error == KIM_NO_ERROR ||
- in_error == KIM_OUT_OF_MEMORY_ECODE);
-}
-
-#pragma mark -- Helper Functions --
-
-/* These helper functions exist so we get type checking on common errors */
-
-/* ------------------------------------------------------------------------ */
-
-kim_error _kim_error_set_message_for_param (kim_string in_function,
- unsigned int in_argument_position,
- kim_string in_argument_name,
- kim_string in_invalid_value)
-{
- return kim_error_set_message_for_code (KIM_PARAMETER_ECODE,
- in_function,
- in_argument_position,
- in_argument_name,
- in_invalid_value);
+ in_error == KIM_OUT_OF_MEMORY_ERR);
}
#pragma mark -- Generic Functions --
error_table KIM
# Configuration and System Errors
-error_code KIM_OUT_OF_MEMORY_ECODE, "Out of memory"
-error_code KIM_PARAMETER_ECODE, "%s(): argument %d (%s) may not be %s. Please consult the KIM API documentation"
-error_code KIM_KRB5_INIT_FAILED_ECODE, "Unable to initialize Kerberos v5"
-error_code KIM_NO_REALMS_ECODE, "There are no Kerberos realms configured"
-error_code KIM_NO_SUCH_REALM_ECODE, "The realm '%s' is not in your configuration file or does not exist"
-error_code KIM_UNSUPPORTED_HINT_ECODE, "The hint '%s' is not supported by this version of KIM"
+error_code KIM_OUT_OF_MEMORY_ERR, "Out of memory"
+error_code KIM_NULL_PARAMETER_ERR, "Parameter may not be NULL. Please consult the KIM API documentation"
+error_code KIM_KRB5_INIT_FAILED_ERR, "Unable to initialize Kerberos v5"
+error_code KIM_NO_REALMS_ERR, "There are no Kerberos realms configured"
+error_code KIM_NO_SUCH_REALM_ERR, "The realm '%s' is not in your configuration file or does not exist"
+error_code KIM_UNSUPPORTED_HINT_ERR, "The hint '%s' is not supported by this version of KIM"
index 25
# Principal Errors
-error_code KIM_BAD_PRINCIPAL_STRING_ECODE, "'%s' is not a valid Kerberos principal"
-error_code KIM_BAD_COMPONENT_INDEX_ECODE, "Principal does not have a component at index %d"
-error_code KIM_PASSWORD_MISMATCH_ECODE, "New and verify passwords do not match"
-error_code KIM_INSECURE_PASSWORD_ECODE, "Your new password for '%s' is insecure; please pick another one"
-error_code KIM_PASSWORD_CHANGE_FAILED_ECODE, "Unable to change password for %s"
+error_code KIM_BAD_PRINCIPAL_STRING_ERR, "'%s' is not a valid Kerberos principal"
+error_code KIM_BAD_COMPONENT_INDEX_ERR, "Principal does not have a component at index %d"
+error_code KIM_PASSWORD_MISMATCH_ERR, "New and verify passwords do not match"
+error_code KIM_INSECURE_PASSWORD_ERR, "Your new password for '%s' is insecure; please pick another one"
+error_code KIM_PASSWORD_CHANGE_FAILED_ERR, "Unable to change password for %s"
index 50
# Options Errors
-error_code KIM_BAD_OPTIONS_ECODE, "Invalid options"
-error_code KIM_BAD_OPTIONS_VALUE_ECODE, "Invalid value for Kerberos default login option"
+error_code KIM_BAD_OPTIONS_ERR, "Invalid options"
+error_code KIM_BAD_OPTIONS_VALUE_ERR, "Invalid value for Kerberos default login option"
index 75
# User Interface Errors
-error_code KIM_CAPS_LOCK_ECODE, "Password Incorrect (check your Caps Lock)"
-error_code KIM_USER_CANCELED_ECODE, "The user cancelled the operation"
-error_code KIM_NO_SERVER_ECODE, "Unable to launch or contact %s"
-error_code KIM_NO_GUI_ECODE, "Unable to display a graphical user interface from this environment"
-error_code KIM_NO_CLI_ECODE, "Unable to display a command line user interface from this environment"
+error_code KIM_CAPS_LOCK_ERR, "Password Incorrect (check your Caps Lock)"
+error_code KIM_USER_CANCELED_ERR, "The user cancelled the operation"
+error_code KIM_NO_SERVER_ERR, "KerberosAgent is not responding"
+error_code KIM_NO_GUI_ERR, "Unable to display a graphical user interface from this environment"
+error_code KIM_NO_CLI_ERR, "Unable to display a command line user interface from this environment"
index 100
# Preferences Errors
-error_code KIM_PREFERENCES_READ_ECODE, "Unable to read user preferences. The file may be missing, inaccessible or corrupted"
-error_code KIM_PREFERENCES_WRITE_ECODE, "Unable to write user preferences. The file may be inaccessible"
-error_code KIM_IDENTITY_NOT_IN_IDENTITIES_LIST, "Identity %s is not in the favorite identities list"
-error_code KIM_IDENTITY_ALREADY_IN_IDENTITIES_LIST, "Identity %s is already in the favorite identities list"
-error_code KIM_BAD_IDENTITY_INDEX_ECODE, "No identity at index %d in the favorite identities list"
+error_code KIM_PREFERENCES_READ_ERR, "Unable to read user preferences. The file may be missing, inaccessible or corrupted"
+error_code KIM_PREFERENCES_WRITE_ERR, "Unable to write user preferences. The file may be inaccessible"
+error_code KIM_IDENTITY_NOT_IN_LIST_ERR, "Identity %s is not in the favorite identities list"
+error_code KIM_IDENTITY_ALREADY_IN_LIST_ERR, "Identity %s is already in the favorite identities list"
+error_code KIM_BAD_IDENTITY_INDEX_ERR, "No identity at index %d in the favorite identities list"
index 125
# Cache Collection Errors
-error_code KIM_NO_SUCH_PRINCIPAL_ECODE, "Principal '%s' does not exist in the cache collection"
-error_code KIM_CANT_BECOME_DEFAULT_ECODE, "The credentials cache '%s' cannot become the system default cache"
-error_code KIM_CREDENTIALS_EXPIRED_ECODE, "The Kerberos credentials for '%s' have expired"
-error_code KIM_NO_CREDENTIALS_ECODE, "No Kerberos credentials for '%s' available"
-error_code KIM_BAD_IP_ADDRESS_ECODE, "The IP addresses in the Kerberos credentials for '%s' do not match any of your computer's IP addresses"
-error_code KIM_NO_SUCH_CCACHE_ECODE, "The credentials cache '%s' does not exist"
-error_code KIM_BAD_HOST_CONFIGURATION_ECODE, "Unable to get local hostname or address information"
-error_code KIM_NEEDS_VALIDATION_ECODE, "The Kerberos credentials for '%s' need to be validated"
+error_code KIM_NO_SUCH_PRINCIPAL_ERR, "Principal '%s' does not exist in the cache collection"
+error_code KIM_CANT_BECOME_DEFAULT_ERR, "The credentials cache '%s' cannot become the system default cache"
+error_code KIM_CREDENTIALS_EXPIRED_ERR, "The Kerberos credentials for '%s' have expired"
+error_code KIM_NO_CREDENTIALS_ERR, "No Kerberos credentials for '%s' available"
+error_code KIM_BAD_IP_ADDRESS_ERR, "The IP addresses in the Kerberos credentials for '%s' do not match any of your computer's IP addresses"
+error_code KIM_NO_SUCH_CCACHE_ERR, "The credentials cache '%s' does not exist"
+error_code KIM_BAD_HOST_CONFIGURATION_ERR, "Unable to get local hostname or address information"
+error_code KIM_NEEDS_VALIDATION_ERR, "The Kerberos credentials for '%s' need to be validated"
end
#include <kim/kim.h>
-kim_error _kim_error_set_message_for_param (kim_string in_function,
- unsigned int in_argument_position,
- kim_string in_argument_name,
- kim_string in_invalid_value);
-#define param_error(pos, name, value) _kim_error_set_message_for_param(__FUNCTION__,\
- pos, name, \
- value)
-
kim_error kim_error_set_message_for_code (kim_error in_code,
...);
kim_error kim_error_set_message_for_code_va (kim_error in_code,
krb5_error_code in_code);
#define krb5_error(context,code) kim_error_set_message_for_krb5_error(context, code)
-#define ccapi_error(code) kim_error_set_message_for_code(code)
-#define os_error(code) kim_error_set_message_for_code(code)
kim_string kim_error_message (kim_error in_error);
kim_error err = KIM_NO_ERROR;
kim_identity identity = NULL;
- if (!err && !out_identity) { err = param_error (1, "out_identity", "NULL"); }
+ if (!err && !out_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
identity = malloc (sizeof (*identity));
- if (!identity) { err = os_error (errno); }
+ if (!identity) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_error err = KIM_NO_ERROR;
kim_identity identity = NULL;
- if (!err && !out_identity) { err = param_error (1, "out_identity", "NULL"); }
- if (!err && !in_string ) { err = param_error (2, "in_string", "NULL"); }
+ if (!err && !out_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_identity_allocate (&identity);
if (!err) {
krb5_error_code code = krb5_parse_name (identity->context, in_string, &identity->principal);
if (code == KRB5_PARSE_MALFORMED) {
- err = kim_error_set_message_for_code (KIM_BAD_PRINCIPAL_STRING_ECODE,
+ err = kim_error_set_message_for_code (KIM_BAD_PRINCIPAL_STRING_ERR,
in_string);
} else if (code) {
err = krb5_error (identity->context, code);
kim_identity identity = NULL;
krb5_principal_data principal_data; /* allocated by KIM so can't be returned */
- if (!err && !out_identity ) { err = param_error (1, "out_identity", "NULL"); }
- if (!err && !in_realm ) { err = param_error (2, "in_realm", "NULL"); }
- if (!err && !in_1st_component) { err = param_error (3, "in_1st_component", "NULL"); }
+ if (!err && !out_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_realm ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_1st_component) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_identity_allocate (&identity);
principal_data.length = component_count;
principal_data.data = (krb5_data *) malloc (component_count * sizeof (krb5_data));
- if (!principal_data.data) { err = os_error (errno); }
+ if (!principal_data.data) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_error err = KIM_NO_ERROR;
kim_identity identity = NULL;
- if (!err && !out_identity ) { err = param_error (1, "out_identity", "NULL"); }
- if (!err && !in_krb5_principal) { err = param_error (2, "in_krb5_principal", "NULL"); }
- if (!err && !in_krb5_context ) { err = param_error (3, "in_krb5_context", "NULL"); }
+ if (!err && !out_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_krb5_principal) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_krb5_context ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_identity_allocate (&identity);
kim_error err = KIM_NO_ERROR;
kim_identity identity = KIM_IDENTITY_ANY;
- if (!err && !out_identity) { err = param_error (1, "out_identity", "NULL"); }
+ if (!err && !out_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err && in_identity != KIM_IDENTITY_ANY) {
err = kim_identity_allocate (&identity);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_identity ) { err = param_error (1, "in_identity", "NULL"); }
- if (!err && !in_compare_to_identity) { err = param_error (2, "in_compare_to_identity", "NULL"); }
- if (!err && !out_comparison ) { err = param_error (3, "out_comparison", "NULL"); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_compare_to_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_comparison ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
if (krb5_principal_compare (in_identity->context,
kim_error err = KIM_NO_ERROR;
char *unparsed_name = NULL;
- if (!err && !in_identity) { err = param_error (1, "in_identity", "NULL"); }
- if (!err && !out_string ) { err = param_error (2, "out_string", "NULL"); }
+ if (!err && !in_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = krb5_error (in_identity->context,
kim_error err = KIM_NO_ERROR;
kim_string string = NULL;
- if (!err && !in_identity ) { err = param_error (1, "in_identity", "NULL"); }
- if (!err && !out_display_string) { err = param_error (2, "out_display_string", "NULL"); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_display_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_identity_get_string (in_identity, &string);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_identity ) { err = param_error (1, "in_identity", "NULL"); }
- if (!err && !out_realm_string) { err = param_error (2, "out_realm_string", "NULL"); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_realm_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
krb5_data *realm = krb5_princ_realm (in_identity->context, in_identity->principal);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_identity ) { err = param_error (1, "in_identity", "NULL"); }
- if (!err && !out_number_of_components) { err = param_error (2, "out_number_of_components", "NULL"); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_number_of_components) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_number_of_components = krb5_princ_size (in_identity->context, in_identity->principal);
kim_error err = KIM_NO_ERROR;
krb5_data *component = NULL;
- if (!err && !in_identity ) { err = param_error (1, "in_identity", "NULL"); }
- if (!err && !out_component_string) { err = param_error (3, "out_component_string", "NULL"); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_component_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
krb5_int32 i = in_index;
component = krb5_princ_component (in_identity->context, in_identity->principal, i);
if (!component) {
- err = kim_error_set_message_for_code (KIM_BAD_COMPONENT_INDEX_ECODE, i);
+ err = kim_error_set_message_for_code (KIM_BAD_COMPONENT_INDEX_ERR, i);
}
}
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_identity ) { err = param_error (1, "in_identity", "NULL"); }
- if (!err && !in_krb5_context ) { err = param_error (2, "in_krb5_context", "NULL"); }
- if (!err && !out_krb5_principal) { err = param_error (3, "out_krb5_principal", "NULL"); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_krb5_context ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_krb5_principal) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = krb5_error (in_identity->context,
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_identity ) { err = param_error (1, "in_identity", "NULL"); }
- if (!err && !out_gss_name) { err = param_error (2, "out_gss_name", "NULL"); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_gss_name) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
#warning kim_identity_get_gss_name not implemented
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_identity ) { err = param_error (1, "in_identity", "NULL"); }
- if (!err && !out_is_tgt_service) { err = param_error (2, "out_is_tgt_service", "NULL"); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_is_tgt_service) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
kim_count count = krb5_princ_size (in_identity->context, in_identity->principal);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_identity) { err = param_error (1, "in_identity", "NULL"); }
+ if (!err && !in_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
return check_error (err);
}
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_identity ) { err = param_error (1, "in_identity", "NULL"); }
- if (!err && !in_new_password) { err = param_error (3, "in_new_password", "NULL"); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_new_password) { err = check_error (KIM_NULL_PARAMETER_ERR); }
return check_error (err);
}
#define KRB5_PRIVATE 1
-#include <pthread.h>
-#include <stdarg.h>
-#include <k5-int.h>
+#include "k5-int.h"
+#include "k5-thread.h"
#include <krb5/krb5.h>
#include <profile.h>
#include "kim_private.h"
#include "kim_os_private.h"
-#pragma mark -- Allow Home Directory Access --
+static k5_mutex_t g_allow_home_directory_access_mutex = K5_MUTEX_PARTIAL_INITIALIZER;
+static k5_mutex_t g_allow_automatic_prompting_mutex = K5_MUTEX_PARTIAL_INITIALIZER;
-static pthread_mutex_t g_allow_home_directory_access_mutex = PTHREAD_MUTEX_INITIALIZER;
kim_boolean g_allow_home_directory_access = TRUE;
+kim_boolean g_allow_automatic_prompting = TRUE;
+
+MAKE_INIT_FUNCTION(kim_thread_init);
+MAKE_FINI_FUNCTION(kim_thread_fini);
/* ------------------------------------------------------------------------ */
-kim_error kim_library_set_allow_home_directory_access (kim_boolean in_allow_access)
+static int kim_thread_init (void)
{
kim_error err = KIM_NO_ERROR;
- int mutex_err = pthread_mutex_lock (&g_allow_home_directory_access_mutex);
- if (mutex_err) { err = os_error (mutex_err); }
+ if (!err) {
+ err = k5_mutex_finish_init (&g_allow_home_directory_access_mutex);
+ }
+
+ if (!err) {
+ err = k5_mutex_finish_init (&g_allow_automatic_prompting_mutex);
+ }
+
+ return err;
+}
+
+/* ------------------------------------------------------------------------ */
+
+static void kim_thread_fini (void)
+{
+ if (!INITIALIZER_RAN (kim_thread_init) || PROGRAM_EXITING ()) {
+ return;
+ }
+
+ k5_mutex_destroy (&g_allow_home_directory_access_mutex);
+ k5_mutex_destroy (&g_allow_automatic_prompting_mutex);
+}
+
+#pragma mark -- Allow Home Directory Access --
+
+/* ------------------------------------------------------------------------ */
+
+kim_error kim_library_set_allow_home_directory_access (kim_boolean in_allow_access)
+{
+ kim_error err = CALL_INIT_FUNCTION (kim_thread_init);
+ kim_error mutex_err = KIM_NO_ERROR;
+
+ if (!err) {
+ mutex_err = k5_mutex_lock (&g_allow_home_directory_access_mutex);
+ if (mutex_err) { err = mutex_err; }
+ }
if (!err) {
g_allow_home_directory_access = in_allow_access;
}
- if (!mutex_err) { pthread_mutex_unlock (&g_allow_home_directory_access_mutex); }
+ if (!mutex_err) { k5_mutex_unlock (&g_allow_home_directory_access_mutex); }
return check_error (err);
}
/* ------------------------------------------------------------------------ */
-kim_error kim_library_get_allow_home_directory_access (kim_boolean *out_allow_access)
+static kim_error kim_library_get_allow_home_directory_access (kim_boolean *out_allow_access)
{
- kim_error err = KIM_NO_ERROR;
- int mutex_err = 0;
+ kim_error err = CALL_INIT_FUNCTION (kim_thread_init);
+ kim_error mutex_err = KIM_NO_ERROR;
- if (!err && !out_allow_access) { err = param_error (3, "out_allow_access", "NULL"); }
+ if (!err && !out_allow_access) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
- mutex_err = pthread_mutex_lock (&g_allow_home_directory_access_mutex);;
- if (mutex_err) { err = os_error (mutex_err); }
+ mutex_err = k5_mutex_lock (&g_allow_home_directory_access_mutex);;
+ if (mutex_err) { err = mutex_err; }
}
if (!err) {
*out_allow_access = g_allow_home_directory_access;
}
- if (!mutex_err) { pthread_mutex_unlock (&g_allow_home_directory_access_mutex); }
+ if (!mutex_err) { k5_mutex_unlock (&g_allow_home_directory_access_mutex); }
return check_error (err);
}
#pragma mark -- Allow Automatic Prompting --
-static pthread_mutex_t g_allow_automatic_prompting_mutex = PTHREAD_MUTEX_INITIALIZER;
-kim_boolean g_allow_automatic_prompting = TRUE;
/* ------------------------------------------------------------------------ */
kim_error kim_library_set_allow_automatic_prompting (kim_boolean in_allow_automatic_prompting)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = CALL_INIT_FUNCTION (kim_thread_init);
+ kim_error mutex_err = KIM_NO_ERROR;
- int mutex_err = pthread_mutex_lock (&g_allow_automatic_prompting_mutex);
- if (mutex_err) { err = os_error (mutex_err); }
+ if (!err) {
+ mutex_err = k5_mutex_lock (&g_allow_automatic_prompting_mutex);
+ if (mutex_err) { err = mutex_err; }
+ }
if (!err) {
g_allow_automatic_prompting = in_allow_automatic_prompting;
}
- if (!mutex_err) { pthread_mutex_unlock (&g_allow_automatic_prompting_mutex); }
+ if (!mutex_err) { k5_mutex_unlock (&g_allow_automatic_prompting_mutex); }
return check_error (err);
}
/* ------------------------------------------------------------------------ */
-kim_error kim_library_get_allow_automatic_prompting (kim_boolean *out_allow_automatic_prompting)
+static kim_error kim_library_get_allow_automatic_prompting (kim_boolean *out_allow_automatic_prompting)
{
- kim_error err = KIM_NO_ERROR;
- int mutex_err = 0;
+ kim_error err = CALL_INIT_FUNCTION (kim_thread_init);
+ kim_error mutex_err = KIM_NO_ERROR;
- if (!err && !out_allow_automatic_prompting) { err = param_error (3, "out_allow_automatic_prompting", "NULL"); }
+ if (!err && !out_allow_automatic_prompting) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
- mutex_err = pthread_mutex_lock (&g_allow_automatic_prompting_mutex);;
- if (mutex_err) { err = os_error (mutex_err); }
+ mutex_err = k5_mutex_lock (&g_allow_automatic_prompting_mutex);;
+ if (mutex_err) { err = mutex_err; }
}
if (!err) {
*out_allow_automatic_prompting = g_allow_automatic_prompting;
}
- if (!mutex_err) { pthread_mutex_unlock (&g_allow_automatic_prompting_mutex); }
+ if (!mutex_err) { k5_mutex_unlock (&g_allow_automatic_prompting_mutex); }
return check_error (err);
}
/*
* $Header$
*
- * Copyright 2006 Massachusetts Institute of Technology.
+ * Copyright 2006-2008 Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
#include <kim/kim.h>
-
-kim_error kim_library_set_allow_home_directory_access (kim_boolean in_allow_access);
-
-kim_error kim_library_get_allow_home_directory_access (kim_boolean *out_allow_access);
-
-kim_boolean kim_library_allow_home_directory_access (void);
-
-kim_error kim_library_set_allow_automatic_prompting (kim_boolean in_allow_automatic_prompting);
-
-kim_error kim_library_get_allow_automatic_prompting (kim_boolean *out_allow_automatic_prompting);
-
-kim_boolean kim_library_allow_automatic_prompting (void);
-
-void kim_os_library_debug_print (kim_string in_string);
-
kim_boolean kim_os_library_caller_is_server (void);
#endif /* KIM_LIBRARY_PRIVATE_H */
kim_error err = KIM_NO_ERROR;
kim_options options = NULL;
- if (!err && !out_options) { err = param_error (1, "out_options", "NULL"); }
+ if (!err && !out_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
options = malloc (sizeof (*options));
- if (!options) { err = os_error (errno); }
+ if (!options) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_error err = KIM_NO_ERROR;
kim_options options = NULL;
- if (!err && !out_options) { err = param_error (1, "out_options", "NULL"); }
+ if (!err && !out_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_options_allocate (&options);
kim_error err = KIM_NO_ERROR;
kim_preferences preferences = NULL;
- if (!err && !out_options) { err = param_error (1, "out_options", "NULL"); }
+ if (!err && !out_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_preferences_create (&preferences);
kim_error err = KIM_NO_ERROR;
kim_options options = NULL;
- if (!err && !out_options) { err = param_error (1, "out_options", "NULL"); }
- if (!err && !in_options ) { err = param_error (2, "in_options", "NULL"); }
+ if (!err && !out_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_options_allocate (&options);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options) { err = param_error (1, "io_options", "NULL"); }
+ if (!err && !io_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_options->prompt_callback = in_prompt_callback;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_options ) { err = param_error (1, "in_options", "NULL"); }
- if (!err && !out_prompt_callback) { err = param_error (2, "out_prompt_callback", "NULL"); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_prompt_callback) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_prompt_callback = in_options->prompt_callback;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options) { err = param_error (1, "io_options", "NULL"); }
+ if (!err && !io_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_options->prompt_callback_data = in_data;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_options) { err = param_error (1, "in_options", "NULL"); }
- if (!err && !out_data ) { err = param_error (2, "out_data", "NULL"); }
+ if (!err && !in_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_data ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_data = in_options->prompt_callback_data;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options ) { err = param_error (1, "io_options", "NULL"); }
- if (!err && !in_response) { err = param_error (2, "in_response", "NULL"); }
+ if (!err && !io_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_response) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
#warning kim_options_set_prompt_response unimplemented
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_options ) { err = param_error (1, "in_options", "NULL"); }
- if (!err && !out_response) { err = param_error (2, "out_response", "NULL"); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_response) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
#warning kim_options_get_prompt_response unimplemented
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options) { err = param_error (1, "io_options", "NULL"); }
+ if (!err && !io_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_options->start_time = in_start_time;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_options ) { err = param_error (1, "in_options", "NULL"); }
- if (!err && !out_start_time) { err = param_error (2, "out_start_time", "NULL"); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_start_time) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_start_time = in_options->start_time;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options) { err = param_error (1, "io_options", "NULL"); }
+ if (!err && !io_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_options->lifetime = in_lifetime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_options ) { err = param_error (1, "in_options", "NULL"); }
- if (!err && !out_lifetime) { err = param_error (2, "out_lifetime", "NULL"); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_lifetime) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_lifetime = in_options->lifetime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options) { err = param_error (1, "io_options", "NULL"); }
+ if (!err && !io_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_options->renewable = in_renewable;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_options ) { err = param_error (1, "in_options", "NULL"); }
- if (!err && !out_renewable) { err = param_error (2, "out_renewable", "NULL"); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_renewable) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_renewable = in_options->renewable;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options) { err = param_error (1, "io_options", "NULL"); }
+ if (!err && !io_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_options->renewal_lifetime = in_renewal_lifetime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_options ) { err = param_error (1, "in_options", "NULL"); }
- if (!err && !out_renewal_lifetime) { err = param_error (2, "out_renewal_lifetime", "NULL"); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_renewal_lifetime) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_renewal_lifetime = in_options->renewal_lifetime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options) { err = param_error (1, "io_options", "NULL"); }
+ if (!err && !io_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_options->forwardable = in_forwardable;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_options ) { err = param_error (1, "in_options", "NULL"); }
- if (!err && !out_forwardable) { err = param_error (2, "out_forwardable", "NULL"); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_forwardable) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_forwardable = in_options->forwardable;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options) { err = param_error (1, "io_options", "NULL"); }
+ if (!err && !io_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_options->proxiable = in_proxiable;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_options ) { err = param_error (1, "in_options", "NULL"); }
- if (!err && !out_proxiable) { err = param_error (2, "out_proxiable", "NULL"); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_proxiable) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_proxiable = in_options->proxiable;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options) { err = param_error (1, "io_options", "NULL"); }
+ if (!err && !io_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_options->addressless = in_addressless;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_options ) { err = param_error (1, "in_options", "NULL"); }
- if (!err && !out_addressless) { err = param_error (2, "out_addressless", "NULL"); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_addressless) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_addressless = in_options->addressless;
kim_error err = KIM_NO_ERROR;
kim_string service_name = NULL;
- if (!err && !io_options ) { err = param_error (1, "io_options", "NULL"); }
- if (!err && !in_service_name) { err = param_error (2, "in_service_name", "NULL"); }
+ if (!err && !io_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_service_name) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_string_copy (&service_name, in_service_name);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_options ) { err = param_error (1, "in_options", "NULL"); }
- if (!err && !out_service_name) { err = param_error (2, "out_service_name", "NULL"); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_service_name) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_string_copy (out_service_name, in_options->service_name);
krb5_get_init_creds_opt *init_cred_options;
krb5_address **addresses = NULL;
- if (!err && !in_options ) { err = param_error (1, "in_options", "NULL"); }
- if (!err && !in_context ) { err = param_error (2, "in_context", "NULL"); }
- if (!err && !out_init_cred_options) { err = param_error (3, "out_init_cred_options", "NULL"); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_context ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_init_cred_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err && !in_options->addressless) {
err = krb5_error (in_context,
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_context) { err = param_error (1, "in_context", "NULL"); }
+ if (!err && !in_context) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err && io_init_cred_options && *io_init_cred_options) {
if ((*io_init_cred_options)->address_list) {
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options) { err = param_error (1, "io_options", "NULL"); }
- if (!err && !out_reply ) { err = param_error (6, "out_reply", "NULL"); }
+ if (!err && !io_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_reply ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
}
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options) { err = param_error (1, "io_options", "NULL"); }
- if (!err && !out_reply ) { err = param_error (6, "out_reply", "NULL"); }
+ if (!err && !io_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_reply ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
}
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_options) { err = param_error (1, "io_options", "NULL"); }
- if (!err && !out_reply ) { err = param_error (6, "out_reply", "NULL"); }
+ if (!err && !io_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_reply ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
}
kim_string in_description,
void **out_reply)
{
- return KIM_USER_CANCELED_ECODE;
+ return KIM_USER_CANCELED_ERR;
}
kim_error err = KIM_NO_ERROR;
kim_favorite_identities favorite_identities = NULL;
- if (!err && !out_favorite_identities) { err = param_error (1, "out_favorite_identities", "NULL"); }
+ if (!err && !out_favorite_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
favorite_identities = malloc (sizeof (*favorite_identities));
- if (!favorite_identities) { err = os_error (errno); }
+ if (!favorite_identities) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_favorite_identities) { err = param_error (1, "io_favorite_identities", "NULL"); }
+ if (!err && !io_favorite_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err && io_favorite_identities->count != in_new_count) {
kim_identity *identities = NULL;
identities = realloc (io_favorite_identities->identities,
sizeof (*identities) * in_new_count);
}
- if (!identities) { err = os_error (errno); }
+ if (!identities) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_error err = KIM_NO_ERROR;
kim_favorite_identities favorite_identities = NULL;
- if (!err && !out_favorite_identities) { err = param_error (1, "out_favorite_identities", "NULL"); }
+ if (!err && !out_favorite_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_favorite_identities_allocate (&favorite_identities);
kim_error err = KIM_NO_ERROR;
kim_favorite_identities favorite_identities = NULL;
- if (!err && !out_favorite_identities) { err = param_error (1, "out_favorite_identities", "NULL"); }
- if (!err && !in_favorite_identities ) { err = param_error (2, "in_favorite_identities", "NULL"); }
+ if (!err && !out_favorite_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_favorite_identities ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_favorite_identities_allocate (&favorite_identities);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_favorite_identities ) { err = param_error (1, "in_favorite_identities", "NULL"); }
- if (!err && !out_number_of_identities) { err = param_error (2, "out_number_of_identities", "NULL"); }
+ if (!err && !in_favorite_identities ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_number_of_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_number_of_identities = in_favorite_identities->count;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_favorite_identities) { err = param_error (1, "in_favorite_identities", "NULL"); }
- if (!err && !out_identity ) { err = param_error (3, "out_identity", "NULL"); }
+ if (!err && !in_favorite_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
if (in_index >= in_favorite_identities->count) {
- err = kim_error_set_message_for_code (KIM_BAD_IDENTITY_INDEX_ECODE,
+ err = kim_error_set_message_for_code (KIM_BAD_IDENTITY_INDEX_ERR,
in_index);
}
}
kim_identity identity = NULL;
kim_count insert_at = 0;
- if (!err && !io_favorite_identities) { err = param_error (1, "io_favorite_identities", "NULL"); }
- if (!err && !in_identity ) { err = param_error (2, "in_identity", "NULL"); }
+ if (!err && !io_favorite_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_identity_copy (&identity, in_identity);
err = kim_identity_get_display_string (in_identity, &display_string);
if (!err) {
- err = kim_error_set_message_for_code (KIM_IDENTITY_ALREADY_IN_IDENTITIES_LIST,
+ err = kim_error_set_message_for_code (KIM_IDENTITY_ALREADY_IN_LIST_ERR,
display_string);
}
kim_boolean found = FALSE;
kim_count i;
- if (!err && !io_favorite_identities) { err = param_error (1, "io_favorite_identities", "NULL"); }
- if (!err && !in_identity ) { err = param_error (2, "in_identity", "NULL"); }
+ if (!err && !io_favorite_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
for (i = 0; !err && !found && i < io_favorite_identities->count; i++) {
err = kim_identity_get_display_string (in_identity, &display_string);
if (!err) {
- err = kim_error_set_message_for_code (KIM_IDENTITY_NOT_IN_IDENTITIES_LIST,
+ err = kim_error_set_message_for_code (KIM_IDENTITY_NOT_IN_LIST_ERR,
display_string);
}
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_favorite_identities) { err = param_error (1, "io_favorite_identities", "NULL"); }
+ if (!err && !io_favorite_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
kim_count i;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_preferences) { err = param_error (1, "in_preferences", "NULL"); }
+ if (!err && !in_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
kim_lifetime lifetime = kim_default_lifetime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_preferences) { err = param_error (1, "in_preferences", "NULL"); }
+ if (!err && !in_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err && in_preferences->remember_options && in_preferences->options_changed) {
kim_lifetime lifetime = kim_default_lifetime;
kim_error err = KIM_NO_ERROR;
kim_preferences preferences = NULL;
- if (!err && !out_preferences) { err = param_error (1, "out_preferences", "NULL"); }
+ if (!err && !out_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
preferences = malloc (sizeof (*preferences));
- if (!preferences) { err = os_error (errno); }
+ if (!preferences) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_error err = KIM_NO_ERROR;
kim_preferences preferences = NULL;
- if (!err && !out_preferences) { err = param_error (1, "out_preferences", "NULL"); }
+ if (!err && !out_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_preferences_allocate (&preferences);
kim_error err = KIM_NO_ERROR;
kim_preferences preferences = NULL;
- if (!err && !out_preferences) { err = param_error (1, "out_preferences", "NULL"); }
- if (!err && !in_preferences ) { err = param_error (2, "in_preferences", "NULL"); }
+ if (!err && !out_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_preferences ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_preferences_allocate (&preferences);
kim_error err = KIM_NO_ERROR;
kim_options options = NULL;
- if (!err && !io_preferences) { err = param_error (1, "io_preferences", "NULL"); }
- if (!err && !in_options ) { err = param_error (2, "in_options", "NULL"); }
+ if (!err && !io_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_options_copy (&options, in_options);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_preferences) { err = param_error (1, "in_preferences", "NULL"); }
- if (!err && !out_options ) { err = param_error (2, "out_options", "NULL"); }
+ if (!err && !in_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_options_copy (out_options, in_preferences->options);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_preferences) { err = param_error (1, "io_preferences", "NULL"); }
+ if (!err && !io_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_preferences->remember_options = in_remember_options;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_preferences ) { err = param_error (1, "in_preferences", "NULL"); }
- if (!err && !out_remember_options) { err = param_error (2, "out_remember_options", "NULL"); }
+ if (!err && !in_preferences ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_remember_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_remember_options = in_preferences->remember_options;
kim_error err = KIM_NO_ERROR;
kim_identity identity = KIM_IDENTITY_ANY;
- if (!err && !io_preferences ) { err = param_error (1, "io_preferences", "NULL"); }
+ if (!err && !io_preferences ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
/* in_client_identity may be KIM_IDENTITY_ANY */
if (!err && in_client_identity) {
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_preferences ) { err = param_error (1, "in_preferences", "NULL"); }
- if (!err && !out_client_identity) { err = param_error (2, "out_client_identity", "NULL"); }
+ if (!err && !in_preferences ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_client_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_identity_copy (out_client_identity, in_preferences->client_identity);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_preferences) { err = param_error (1, "io_preferences", "NULL"); }
+ if (!err && !io_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_preferences->remember_client_identity = in_remember_client_identity;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_preferences ) { err = param_error (1, "in_preferences", "NULL"); }
- if (!err && !out_remember_client_identity) { err = param_error (2, "out_remember_client_identity", "NULL"); }
+ if (!err && !in_preferences ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_remember_client_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_remember_client_identity = in_preferences->remember_client_identity;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_preferences) { err = param_error (1, "io_preferences", "NULL"); }
+ if (!err && !io_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_preferences->minimum_lifetime = in_minimum_lifetime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_preferences ) { err = param_error (1, "in_preferences", "NULL"); }
- if (!err && !out_minimum_lifetime) { err = param_error (2, "out_minimum_lifetime", "NULL"); }
+ if (!err && !in_preferences ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_minimum_lifetime) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_minimum_lifetime = in_preferences->minimum_lifetime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_preferences) { err = param_error (1, "io_preferences", "NULL"); }
+ if (!err && !io_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_preferences->maximum_lifetime = in_maximum_lifetime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_preferences ) { err = param_error (1, "in_preferences", "NULL"); }
- if (!err && !out_maximum_lifetime) { err = param_error (2, "out_maximum_lifetime", "NULL"); }
+ if (!err && !in_preferences ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_maximum_lifetime) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_maximum_lifetime = in_preferences->maximum_lifetime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_preferences) { err = param_error (1, "io_preferences", "NULL"); }
+ if (!err && !io_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_preferences->minimum_renewal_lifetime = in_minimum_renewal_lifetime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_preferences ) { err = param_error (1, "in_preferences", "NULL"); }
- if (!err && !out_minimum_renewal_lifetime) { err = param_error (2, "out_minimum_renewal_lifetime", "NULL"); }
+ if (!err && !in_preferences ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_minimum_renewal_lifetime) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_minimum_renewal_lifetime = in_preferences->minimum_renewal_lifetime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_preferences) { err = param_error (1, "io_preferences", "NULL"); }
+ if (!err && !io_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_preferences->maximum_renewal_lifetime = in_maximum_renewal_lifetime;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_preferences ) { err = param_error (1, "in_preferences", "NULL"); }
- if (!err && !out_maximum_renewal_lifetime) { err = param_error (2, "out_maximum_renewal_lifetime", "NULL"); }
+ if (!err && !in_preferences ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_maximum_renewal_lifetime) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_maximum_renewal_lifetime = in_preferences->maximum_renewal_lifetime;
kim_error err = KIM_NO_ERROR;
kim_favorite_identities favorite_identities = NULL;
- if (!err && !io_preferences ) { err = param_error (1, "io_preferences", "NULL"); }
- if (!err && !in_favorite_identities) { err = param_error (2, "in_favorite_identities", "NULL"); }
+ if (!err && !io_preferences ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_favorite_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_favorite_identities_copy (&favorite_identities, in_favorite_identities);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_preferences ) { err = param_error (1, "in_preferences", "NULL"); }
- if (!err && !out_favorite_identities) { err = param_error (2, "out_favorite_identities", "NULL"); }
+ if (!err && !in_preferences ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_favorite_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_favorite_identities_copy (out_favorite_identities, in_preferences->favorite_identities);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_preferences) { err = param_error (1, "in_preferences", "NULL"); }
+ if (!err && !in_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_preferences_write (in_preferences);
#include <errno.h>
#include <kim/kim.h>
+#include <kim/kim_library.h>
#include "kim_library_private.h"
#include "kim_debug_private.h"
};
struct kim_selection_hints_opaque kim_selection_hints_initializer = {
-NULL,
-NULL,
-NULL,
-KIM_OPTIONS_DEFAULT,
-TRUE,
-TRUE,
-NULL,
-NULL,
-NULL,
-NULL,
-NULL,
-NULL
+ NULL,
+ NULL,
+ NULL,
+ KIM_OPTIONS_DEFAULT,
+ TRUE,
+ TRUE,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
};
/* ------------------------------------------------------------------------ */
kim_error err = KIM_NO_ERROR;
kim_selection_hints selection_hints = NULL;
- if (!err && !out_selection_hints) { err = param_error (1, "out_selection_hints", "NULL"); }
+ if (!err && !out_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
selection_hints = malloc (sizeof (*selection_hints));
- if (!selection_hints) { err = os_error (errno); }
+ if (!selection_hints) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_error err = KIM_NO_ERROR;
kim_selection_hints selection_hints = NULL;
- if (!err && !out_selection_hints ) { err = param_error (1, "out_selection_hints", "NULL"); }
- if (!err && !in_application_identifier) { err = param_error (1, "in_application_identifier", "NULL"); }
+ if (!err && !out_selection_hints ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_application_identifier) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_selection_hints_allocate (&selection_hints);
kim_error err = KIM_NO_ERROR;
kim_selection_hints selection_hints = NULL;
- if (!err && !out_selection_hints) { err = param_error (1, "out_selection_hints", "NULL"); }
- if (!err && !in_selection_hints ) { err = param_error (1, "in_selection_hints", "NULL"); }
+ if (!err && !out_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_selection_hints ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_selection_hints_allocate (&selection_hints);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_selection_hints) { err = param_error (1, "io_selection_hints", "NULL"); }
- if (!err && !in_hint_key ) { err = param_error (2, "in_hint_key", "NULL"); }
- if (!err && !in_hint_string ) { err = param_error (3, "in_hint_string", "NULL"); }
+ if (!err && !io_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_hint_key ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_hint_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
if (!strcmp (in_hint_key, kim_hint_key_client_realm)) {
in_hint_string);
} else {
- err = kim_error_set_message_for_code (KIM_UNSUPPORTED_HINT_ECODE,
+ err = kim_error_set_message_for_code (KIM_UNSUPPORTED_HINT_ERR,
in_hint_key);
}
}
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_selection_hints) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !in_hint_key ) { err = param_error (2, "in_hint_key", "NULL"); }
- if (!err && !out_hint_string ) { err = param_error (3, "out_hint_string", "NULL"); }
+ if (!err && !in_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_hint_key ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_hint_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
if (!strcmp (in_hint_key, kim_hint_key_client_realm)) {
in_selection_hints->service_identity);
} else {
- err = kim_error_set_message_for_code (KIM_UNSUPPORTED_HINT_ECODE,
+ err = kim_error_set_message_for_code (KIM_UNSUPPORTED_HINT_ERR,
in_hint_key);
}
}
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_selection_hints ) { err = param_error (1, "io_selection_hints", "NULL"); }
- if (!err && !in_application_name) { err = param_error (2, "in_application_name", "NULL"); }
+ if (!err && !io_selection_hints ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_application_name) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_string_copy (&io_selection_hints->application_name, in_application_name);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_selection_hints ) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !out_application_name) { err = param_error (2, "out_application_name", "NULL"); }
+ if (!err && !in_selection_hints ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_application_name) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
if (in_selection_hints->application_name) {
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_selection_hints) { err = param_error (1, "io_selection_hints", "NULL"); }
- if (!err && !in_explanation ) { err = param_error (2, "in_explanation", "NULL"); }
+ if (!err && !io_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_explanation ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_string_copy (&io_selection_hints->explanation, in_explanation);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_selection_hints) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !out_explanation ) { err = param_error (2, "out_explanation", "NULL"); }
+ if (!err && !in_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_explanation ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
if (in_selection_hints->explanation) {
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_selection_hints) { err = param_error (1, "io_selection_hints", "NULL"); }
- if (!err && !in_options ) { err = param_error (2, "in_options", "NULL"); }
+ if (!err && !io_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_options_copy (&io_selection_hints->options, in_options);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_selection_hints) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !out_options ) { err = param_error (2, "out_options", "NULL"); }
+ if (!err && !in_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
if (in_selection_hints->options) {
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_selection_hints ) { err = param_error (1, "io_selection_hints", "NULL"); }
+ if (!err && !io_selection_hints ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_selection_hints->allow_user_interaction = in_allow_user_interaction;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_selection_hints ) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !out_allow_user_interaction) { err = param_error (2, "out_allow_user_interaction", "NULL"); }
+ if (!err && !in_selection_hints ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_allow_user_interaction) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_allow_user_interaction = in_selection_hints->allow_user_interaction;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !io_selection_hints ) { err = param_error (1, "io_selection_hints", "NULL"); }
+ if (!err && !io_selection_hints ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_selection_hints->use_cached_results = in_use_cached_results;
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_selection_hints ) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !out_use_cached_results) { err = param_error (2, "out_use_cached_results", "NULL"); }
+ if (!err && !in_selection_hints ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_use_cached_results) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
*out_use_cached_results = in_selection_hints->use_cached_results;
kim_identity identity = NULL;
kim_ccache ccache = NULL;
- if (!err && !in_selection_hints) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !out_identity ) { err = param_error (2, "out_identity", "NULL"); }
+ if (!err && !in_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err && in_selection_hints->use_cached_results) {
err = kim_os_selection_hints_lookup_identity (in_selection_hints, &identity);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_selection_hints) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !in_identity ) { err = param_error (2, "in_identity", "NULL"); }
+ if (!err && !in_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_selection_hints_remember_identity (in_selection_hints,
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_selection_hints) { err = param_error (1, "in_selection_hints", "NULL"); }
+ if (!err && !in_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_selection_hints_forget_identity (in_selection_hints);
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_selection_hints ) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !io_preference_strings) { err = param_error (2, "io_preference_strings", "NULL"); }
+ if (!err && !in_selection_hints ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !io_preference_strings) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
io_preference_strings->application_identifier = in_selection_hints->application_identifier;
kim_error err = KIM_NO_ERROR;
int count = vasprintf ((char **) out_string, in_format, in_args);
- if (count < 0) { err = os_error (ENOMEM); }
+ if (count < 0) { err = check_error (KIM_OUT_OF_MEMORY_ERR); }
return err;
}
kim_error err = KIM_NO_ERROR;
kim_string string = NULL;
- if (!err && !out_string) { err = param_error (1, "out_string", "NULL"); }
- if (!err && !in_format ) { err = param_error (2, "in_format", "NULL"); }
+ if (!err && !out_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_format ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_string_create_from_format_va_retcode (&string,
kim_error err = KIM_NO_ERROR;
kim_string string = NULL;
- if (!err && !out_string) { err = param_error (1, "out_string", "NULL"); }
- if (!err && !in_buffer ) { err = param_error (2, "in_buffer", "NULL"); }
+ if (!err && !out_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_buffer ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
string = calloc (in_length + 1, sizeof (char *));
- if (!string) { err = os_error (ENOMEM); }
+ if (!string) { err = check_error (KIM_OUT_OF_MEMORY_ERR); }
}
if (!err) {
kim_error err = KIM_NO_ERROR;
kim_string string = NULL;
- if (!err && !out_string) { err = param_error (1, "out_string", "NULL"); }
- if (!err && !in_string ) { err = param_error (2, "in_string", "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) {
string = calloc (strlen (in_string) + 1, sizeof (char *));
- if (!string) { err = os_error (ENOMEM); }
+ if (!string) { err = check_error (KIM_OUT_OF_MEMORY_ERR); }
}
if (!err) {
{
kim_error err = KIM_NO_ERROR;
- if (!err && !out_identity) { err = param_error (1, "out_identity", "NULL"); }
+ if (!err && !out_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
struct passwd *pw = getpwuid (getuid ());
* or implied warranty.
*/
-#include <CoreServices/CoreServices.h>
-#include <Kerberos/KerberosDebug.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include "k5-int.h"
+#include "k5-thread.h"
+#include <krb5/krb5.h>
#include "kim_os_private.h"
+
+static k5_mutex_t g_bundle_lookup_mutex = K5_MUTEX_PARTIAL_INITIALIZER;
+
+MAKE_INIT_FUNCTION(kim_os_library_thread_init);
+MAKE_FINI_FUNCTION(kim_os_library_thread_fini);
+
+/* ------------------------------------------------------------------------ */
+
+static int kim_os_library_thread_init (void)
+{
+ kim_error err = KIM_NO_ERROR;
+
+ if (!err) {
+ err = k5_mutex_finish_init (&g_bundle_lookup_mutex);
+ }
+
+ return err;
+}
+
+/* ------------------------------------------------------------------------ */
+
+static void kim_os_library_thread_fini (void)
+{
+ if (!INITIALIZER_RAN (kim_os_library_thread_init) || PROGRAM_EXITING ()) {
+ return;
+ }
+ k5_mutex_destroy (&g_bundle_lookup_mutex);
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+kim_error kim_os_library_lock_for_bundle_lookup (void)
+{
+ kim_error err = CALL_INIT_FUNCTION (kim_os_library_thread_init);
+
+ if (!err) {
+ err = k5_mutex_lock (&g_bundle_lookup_mutex);
+ }
+
+ return err;
+}
+
+/* ------------------------------------------------------------------------ */
+
+kim_error kim_os_library_unlock_for_bundle_lookup (void)
+{
+ kim_error err = CALL_INIT_FUNCTION (kim_os_library_thread_init);
+
+ if (!err) {
+ err = k5_mutex_unlock (&g_bundle_lookup_mutex);
+ }
+
+ return err;
+}
+
+#pragma mark -
+
/* ------------------------------------------------------------------------ */
kim_boolean kim_os_library_caller_is_server (void)
/* ------------------------------------------------------------------------ */
-static kim_error kim_os_preferences_cfstring_for_key (kim_preference_key in_key,
- CFStringRef *out_kim_string_key,
- CFStringRef *out_kll_string_key)
+static kim_error kim_os_preferences_cfstring_for_key (kim_preference_key in_key,
+ CFStringRef *out_kim_string_key,
+ CFStringRef *out_kll_string_key)
{
kim_error err = KIM_NO_ERROR;
- if (!err && !out_kim_string_key) { err = param_error (2, "out_kim_string_key", "NULL"); }
- if (!err && !out_kll_string_key) { err = param_error (3, "out_kll_string_key", "NULL"); }
+ if (!err && !out_kim_string_key) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_kll_string_key) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
if (in_key == kim_preference_key_lifetime) {
*out_kll_string_key = CFSTR ("KLMaximumRenewableLifetime");
} else {
- err = param_error (1, "in_key", "not in kim_preference_key_enum");
+ /* ignore unsupported keys */
+ kim_debug_printf ("Unsupported preference key %d", in_key);
+ *out_kim_string_key = NULL;
+ *out_kll_string_key = NULL;
}
}
/* ------------------------------------------------------------------------ */
static kim_error kim_os_preferences_get_value (kim_preference_key in_key,
- CFTypeID in_type,
- CFPropertyListRef *out_value)
+ CFTypeID in_type,
+ CFPropertyListRef *out_value)
{
kim_error err = KIM_NO_ERROR;
CFStringRef hosts[] = { kCFPreferencesCurrentHost, kCFPreferencesAnyHost, NULL };
CFStringRef keys[] = { NULL, NULL, NULL };
- if (!err && !out_value) { err = param_error (3, "out_value", "NULL"); }
+ if (!err && !out_value) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
/* Index must correspond to the appropriate file */
}
for (u = 0; !value && users[u]; u++) {
- for (f = 0; !value && files[f]; f++) {
+ for (f = 0; !value && files[f] && keys[f]; f++) {
for (h = 0; !value && hosts[h]; h++) {
value = CFPreferencesCopyValue (keys[f], files[f], users[u], hosts[h]);
}
}
if (value && CFGetTypeID (value) != in_type) {
- err = check_error (KIM_PREFERENCES_READ_ECODE);
+ err = check_error (KIM_PREFERENCES_READ_ERR);
}
}
CFStringRef kim_key = NULL;
CFStringRef kll_key = NULL;
- if (!err && !in_value) { err = param_error (2, "in_value", "NULL"); }
+ if (!err && !in_value) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_preferences_cfstring_for_key (in_key, &kim_key, &kll_key);
}
- if (!err) {
+ if (!err && kim_key) {
kim_boolean homedir_ok = kim_library_allow_home_directory_access();
CFStringRef user = homedir_ok ? kCFPreferencesCurrentUser : kCFPreferencesAnyUser;
CFStringRef host = homedir_ok ? kCFPreferencesAnyHost : kCFPreferencesCurrentHost;
CFPreferencesSetValue (kim_key, in_value, KIM_PREFERENCES_FILE, user, host);
if (!CFPreferencesSynchronize (KIM_PREFERENCES_FILE, user, host)) {
- err = check_error (KIM_PREFERENCES_WRITE_ECODE);
+ err = check_error (KIM_PREFERENCES_WRITE_ERR);
}
}
kim_string string = NULL;
CFStringRef value = NULL;
- if (!err && !out_identity) { err = param_error (2, "out_identity", "NULL"); }
+ if (!err && !out_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_preferences_get_value (in_key, CFStringGetTypeID (),
kim_error err = KIM_NO_ERROR;
CFArrayRef value = NULL;
- if (!err && !out_favorite_identities) { err = param_error (2, "out_favorite_identities", "NULL"); }
+ if (!err && !out_favorite_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_preferences_get_value (in_key, CFArrayGetTypeID (),
cfstring = (CFStringRef) CFArrayGetValueAtIndex (value, i);
if (!cfstring || CFGetTypeID (cfstring) != CFStringGetTypeID ()) {
- err = check_error (KIM_PREFERENCES_READ_ECODE);
+ err = check_error (KIM_PREFERENCES_READ_ERR);
}
if (!err) {
kim_count count = 0;
CFMutableArrayRef value = NULL;
- if (!err && !in_favorite_identities) { err = param_error (2, "in_favorite_identities", "NULL"); }
+ if (!err && !in_favorite_identities) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_favorite_identities_get_number_of_identities (in_favorite_identities, &count);
if (!err) {
value = CFArrayCreateMutable (kCFAllocatorDefault, count, &kCFTypeArrayCallBacks);
- if (!value) { err = os_error (ENOMEM); }
+ if (!value) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_error err = KIM_NO_ERROR;
CFNumberRef value = NULL;
- if (!err && !out_time) { err = param_error (2, "out_time", "NULL"); }
+ if (!err && !out_time) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_preferences_get_value (in_key, CFNumberGetTypeID (),
if (value) {
SInt32 number; // CFNumbers are signed so we need to cast
if (CFNumberGetValue (value, kCFNumberSInt32Type, &number) != TRUE) {
- err = os_error (ENOMEM);
+ err = KIM_OUT_OF_MEMORY_ERR;
} else {
*out_time = number;
}
if (!err) {
value = CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt32Type, &number);
- if (!value) { err = os_error (ENOMEM); }
+ if (!value) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_error err = KIM_NO_ERROR;
CFNumberRef value = NULL;
- if (!err && !out_lifetime) { err = param_error (2, "out_lifetime", "NULL"); }
+ if (!err && !out_lifetime) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_preferences_get_value (in_key, CFNumberGetTypeID (),
if (value) {
SInt32 number; // CFNumbers are signed so we need to cast
if (CFNumberGetValue (value, kCFNumberSInt32Type, &number) != TRUE) {
- err = os_error (ENOMEM);
+ err = KIM_OUT_OF_MEMORY_ERR;
} else {
*out_lifetime = number;
}
if (!err) {
value = CFNumberCreate (kCFAllocatorDefault, kCFNumberSInt32Type, &number);
- if (!value) { err = os_error (ENOMEM); }
+ if (!value) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_error err = KIM_NO_ERROR;
CFBooleanRef value = NULL;
- if (!err && !out_boolean) { err = param_error (2, "out_boolean", "NULL"); }
+ if (!err && !out_boolean) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_preferences_get_value (in_key, CFBooleanGetTypeID (),
#include <CoreFoundation/CoreFoundation.h>
#include "kim_private.h"
+kim_error kim_os_library_lock_for_bundle_lookup (void);
+kim_error kim_os_library_unlock_for_bundle_lookup (void);
-CFStringEncoding kim_os_string_get_encoding (void);
-CFStringRef kim_os_string_get_cfstring_for_key_and_dictionary (CFStringRef in_key,
- CFBundleRef in_bundle);
-
-CFStringRef kim_os_string_get_cfstring_for_key (kim_string in_key_string);
+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);
-kim_error kim_os_string_create_for_key (kim_string *out_string,
- kim_string in_key_string);
-
kim_error kim_os_string_get_cfstring (kim_string in_string,
CFStringRef *out_cfstring);
CFStringRef users[] = { kCFPreferencesCurrentUser, kCFPreferencesAnyUser, NULL };
CFStringRef hosts[] = { kCFPreferencesCurrentHost, kCFPreferencesAnyHost, NULL };
- if (!err && !out_selection_hints_array) { err = param_error (1, "out_selection_hints_array", "NULL"); }
+ if (!err && !out_selection_hints_array) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
kim_count u, h;
}
if (value && CFGetTypeID (value) != CFArrayGetTypeID ()) {
- err = check_error (KIM_PREFERENCES_READ_ECODE);
+ err = check_error (KIM_PREFERENCES_READ_ERR);
}
}
{
kim_error err = KIM_NO_ERROR;
- if (!err && !in_selection_hints_array) { err = param_error (1, "in_selection_hints_array", "NULL"); }
+ if (!err && !in_selection_hints_array) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
kim_boolean homedir_ok = kim_library_allow_home_directory_access();
CFPreferencesSetValue (KIM_SELECTION_HINTS_ARRAY, in_selection_hints_array,
KIM_SELECTION_HINTS_FILE, user, host);
if (!CFPreferencesSynchronize (KIM_SELECTION_HINTS_FILE, user, host)) {
- err = check_error (KIM_PREFERENCES_WRITE_ECODE);
+ err = check_error (KIM_PREFERENCES_WRITE_ERR);
}
}
CFStringRef values[KIM_MAX_HINTS] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
CFIndex i = 0;
- if (!err && !in_selection_hints ) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !in_identity ) { err = param_error (2, "in_selection_hints", "NULL"); }
- if (!err && !out_hints_dictionary) { err = param_error (3, "out_hints_dictionary", "NULL"); }
+ if (!err && !in_selection_hints ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_hints_dictionary) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_selection_hints_get_preference_strings (in_selection_hints, &preference_strings);
kim_selection_hints_preference_strings preference_strings = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
kim_boolean hints_equal = 1;
- if (!err && !in_selection_hints ) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !in_hints_dictionary) { err = param_error (2, "in_hints_dictionary", "NULL"); }
- if (!err && !out_hints_equal ) { err = param_error (3, "out_hints_equal", "NULL"); }
+ if (!err && !in_selection_hints ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_hints_dictionary) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_hints_equal ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_selection_hints_get_preference_strings (in_selection_hints, &preference_strings);
identity_cfstr = CFDictionaryGetValue (in_dictionary, KIM_IDENTITY_HINT);
if (!identity_cfstr || CFGetTypeID (identity_cfstr) != CFStringGetTypeID ()) {
kim_debug_printf ("%s: Malformed hints dictionary (invalid identity).", __FUNCTION__);
- err = check_error (KIM_PREFERENCES_READ_ECODE);
+ err = check_error (KIM_PREFERENCES_READ_ERR);
}
if (!err) {
kim_boolean found = 0;
CFDictionaryRef found_dictionary = NULL;
- if (!err && !in_selection_hints) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !out_identity ) { err = param_error (2, "out_identity", "NULL"); }
+ if (!err && !in_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_selection_hints_get_selection_hints_array (&hints_array);
CFDictionaryRef dictionary = NULL;
dictionary = CFArrayGetValueAtIndex (hints_array, i);
- if (!dictionary) { err = os_error (ENOMEM); }
+ if (!dictionary) { err = KIM_OUT_OF_MEMORY_ERR; }
if (!err && CFGetTypeID (dictionary) != CFDictionaryGetTypeID ()) {
kim_debug_printf ("%s: Malformed entry in hints array.", __FUNCTION__);
kim_boolean hint_already_exists = 0;
kim_boolean hints_array_changed = 0;
- if (!err && !in_selection_hints) { err = param_error (1, "in_selection_hints", "NULL"); }
- if (!err && !in_identity ) { err = param_error (2, "in_identity", "NULL"); }
+ if (!err && !in_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_identity ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_selection_hints_get_selection_hints_array (&old_hints_array);
new_hints_array = CFArrayCreateMutable (kCFAllocatorDefault, 0,
&kCFTypeArrayCallBacks);
}
- if (!new_hints_array) { err = os_error (ENOMEM); }
+ if (!new_hints_array) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_boolean hints_equal = 0;
dictionary = CFArrayGetValueAtIndex (new_hints_array, i);
- if (!dictionary) { err = os_error (ENOMEM); }
+ if (!dictionary) { err = KIM_OUT_OF_MEMORY_ERR; }
if (!err && CFGetTypeID (dictionary) != CFDictionaryGetTypeID ()) {
kim_debug_printf ("%s: Malformed entry in hints array.", __FUNCTION__);
CFIndex count = 0;
CFIndex i = 0;
- if (!err && !in_selection_hints) { err = param_error (1, "in_selection_hints", "NULL"); }
+ if (!err && !in_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_selection_hints_get_selection_hints_array (&old_hints_array);
if (!err) {
new_hints_array = CFArrayCreateMutableCopy (kCFAllocatorDefault, 0,
old_hints_array);
- if (!new_hints_array) { err = os_error (ENOMEM); }
+ if (!new_hints_array) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
kim_boolean hints_equal = 0;
dictionary = CFArrayGetValueAtIndex (new_hints_array, i);
- if (!dictionary) { err = os_error (ENOMEM); }
+ if (!dictionary) { err = KIM_OUT_OF_MEMORY_ERR; }
if (!err && CFGetTypeID (dictionary) != CFDictionaryGetTypeID ()) {
kim_debug_printf ("%s: Malformed entry in hints array.", __FUNCTION__);
* or implied warranty.
*/
-#include <CoreServices/CoreServices.h>
+#include <CoreFoundation/CoreFoundation.h>
#include "kim_os_private.h"
/* ------------------------------------------------------------------------ */
-/* WARNING: DO NOT CALL check_error() -- it is called by error_message()!! */
-
-CFStringEncoding kim_os_string_get_encoding (void)
+static kim_error kim_os_string_for_key_in_bundle (CFBundleRef in_bundle,
+ CFStringRef in_key,
+ kim_string *out_string)
{
- typedef TextEncoding (*GetApplicationTextEncodingProcPtr) (void);
- GetApplicationTextEncodingProcPtr GetApplicationTextEncodingPtr = NULL;
- CFBundleRef carbonBundle = NULL;
+ kim_error lock_err = kim_os_library_lock_for_bundle_lookup ();
+ kim_error err = lock_err;
+ kim_string string = NULL;
- if (kim_os_library_caller_is_server ()) {
- return kCFStringEncodingUTF8; /* server only does UTF8 */
- }
+ 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); }
- carbonBundle = CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.Carbon"));
- if (carbonBundle != NULL && CFBundleIsExecutableLoaded (carbonBundle)) {
- GetApplicationTextEncodingPtr = (GetApplicationTextEncodingProcPtr) CFBundleGetFunctionPointerForName (carbonBundle,
- CFSTR ("GetApplicationTextEncoding"));
+ 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 (GetApplicationTextEncodingPtr) {
- return (CFStringEncoding) (*GetApplicationTextEncodingPtr) ();
+ if (!err) {
+ /* set to NULL if no string found */
+ *out_string = string;
+ string = NULL;
}
- return CFStringGetSystemEncoding ();
+ kim_string_free (&string);
+
+ if (!lock_err) { kim_os_library_unlock_for_bundle_lookup (); }
+
+ return check_error (err);
}
+#pragma mark -
+
/* ------------------------------------------------------------------------ */
-/* WARNING: DO NOT CALL check_error() -- it is called by error_message()!! */
-CFStringRef kim_os_string_get_cfstring_for_key_and_dictionary (CFStringRef in_key,
- CFBundleRef in_bundle)
+kim_error kim_os_string_create_for_key (kim_string *out_string,
+ kim_string in_key_string)
{
- CFDictionaryRef dictionary = NULL;
- CFStringRef value = NULL;
-
- if (kim_library_allow_home_directory_access ()) {
- // Accesses user's homedir to get localization information
- dictionary = CFBundleGetLocalInfoDictionary (in_bundle);
- } else {
- dictionary = CFBundleGetInfoDictionary (in_bundle);
- }
+ kim_error err = KIM_NO_ERROR;
+ CFStringRef key = NULL;
+ kim_string string = NULL;
- if (dictionary) {
- value = (CFTypeRef) CFDictionaryGetValue (dictionary, in_key);
- }
+ if (!err && !out_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_key_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
- if (value && (CFGetTypeID (value) != CFStringGetTypeID ())) {
- value = NULL; // Only return CFStrings
+ if (!err) {
+ err = kim_os_string_get_cfstring (in_key_string, &key);
}
- return value;
-}
-
-/* ------------------------------------------------------------------------ */
-/* WARNING: DO NOT CALL check_error() -- it is called by error_message()!! */
-
-CFStringRef kim_os_string_get_cfstring_for_key (kim_string in_key_string)
-{
- CFStringRef key = NULL;
- CFStringRef value = NULL;
+ if (!err) {
+ /* Try to find the key, first searching in the framework */
+ CFBundleRef framework = CFBundleGetBundleWithIdentifier (CFSTR ("edu.mit.Kerberos"));
+ if (framework) {
+ err = kim_os_string_for_key_in_bundle (framework, key, &string);
+ }
+ }
- if (in_key_string) {
- key = CFStringCreateWithCString (kCFAllocatorDefault, in_key_string, kCFStringEncodingASCII);
-
- if (key) {
- // Try to find the key, first searching in the framework, then in the main bundle
- CFBundleRef frameworkBundle = CFBundleGetBundleWithIdentifier (CFSTR ("edu.mit.Kerberos"));
- if (frameworkBundle) {
- value = kim_os_string_get_cfstring_for_key_and_dictionary (key, frameworkBundle);
- }
-
- if (!value) {
- CFBundleRef mainBundle = CFBundleGetMainBundle ();
-
- if (mainBundle) {
- value = kim_os_string_get_cfstring_for_key_and_dictionary (key, mainBundle);
- }
- }
-
- if (value && (CFGetTypeID (value) != CFStringGetTypeID ())) {
- value = NULL; // Only return CFStrings
- }
-
- CFRelease (key);
+ 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);
}
}
- return value;
+ if (!err) {
+ *out_string = string;
+ string = NULL;
+ }
+
+ kim_string_free (&string);
+ if (key) { CFRelease (key); }
+
+ return check_error (err);
}
-#pragma mark -
-
/* ------------------------------------------------------------------------ */
kim_error kim_os_string_create_from_cfstring (kim_string *out_string,
{
kim_error err = KIM_NO_ERROR;
kim_string string = NULL;
- CFStringEncoding encoding = kim_os_string_get_encoding ();
CFIndex length = 0;
- if (!err && !out_string ) { err = param_error (1, "out_string", "NULL"); }
- if (!err && !in_cfstring) { err = param_error (2, "in_cfstring", "NULL"); }
+ if (!err && !out_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_cfstring) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
- length = CFStringGetMaximumSizeForEncoding (CFStringGetLength (in_cfstring), encoding) + 1;
+ length = CFStringGetMaximumSizeForEncoding (CFStringGetLength (in_cfstring),
+ kCFStringEncodingUTF8) + 1;
string = (char *) calloc (length, sizeof (char));
- if (!string) { err = os_error (errno); }
+ if (!string) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
- if (!CFStringGetCString (in_cfstring, (char *) string, length, encoding)) {
- err = os_error (ENOMEM);
+ if (!CFStringGetCString (in_cfstring,
+ (char *) string,
+ length,
+ kCFStringEncodingUTF8)) {
+ err = KIM_OUT_OF_MEMORY_ERR;
}
}
/* ------------------------------------------------------------------------ */
-kim_error kim_os_string_create_for_key (kim_string *out_string,
- kim_string in_key_string)
-{
- kim_error err = KIM_NO_ERROR;
- CFStringRef value = NULL;
-
- if (!err && !out_string ) { err = param_error (1, "out_string", "NULL"); }
- if (!err && !in_key_string) { err = param_error (2, "in_key_string", "NULL"); }
-
- if (!err) {
- value = kim_os_string_get_cfstring_for_key (in_key_string);
- if (value) {
- err = kim_os_string_create_from_cfstring (out_string, value);
- } else {
- // We failed to look it up. Use the key so we return something.
- err = kim_string_copy (out_string, in_key_string);
- }
- }
-
- return check_error (err);
-}
-
-/* ------------------------------------------------------------------------ */
-
kim_error kim_os_string_get_cfstring (kim_string in_string,
CFStringRef *out_cfstring)
{
kim_error err = KIM_NO_ERROR;
CFStringRef cfstring = NULL;
- if (!err && !in_string ) { err = param_error (1, "in_string", "NULL"); }
- if (!err && !out_cfstring) { err = param_error (2, "out_cfstring", "NULL"); }
+ if (!err && !in_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_cfstring) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
cfstring = CFStringCreateWithCString (kCFAllocatorDefault,
in_string,
kCFStringEncodingUTF8);
- if (!cfstring) { err = os_error (ENOMEM); }
+ if (!cfstring) { err = KIM_OUT_OF_MEMORY_ERR; }
}
if (!err) {
CFStringRef cfstring = NULL;
CFStringRef compare_to_cfstring = NULL;
- if (!err && !in_string ) { err = param_error (1, "in_string", "NULL"); }
- if (!err && !in_compare_to_string) { err = param_error (2, "in_compare_to_string", "NULL"); }
- if (!err && !out_comparison ) { err = param_error (3, "out_comparison", "NULL"); }
+ if (!err && !in_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_compare_to_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_comparison ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
- err = kim_os_string_get_cfstring (in_string, &cfstring);
+ err = kim_os_string_get_cfstring (in_string,
+ &cfstring);
}
if (!err) {
- err = kim_os_string_get_cfstring (in_compare_to_string, &compare_to_cfstring);
+ err = kim_os_string_get_cfstring (in_compare_to_string,
+ &compare_to_cfstring);
}
if (!err) {
if (cfstring ) { CFRelease (cfstring); }
if (compare_to_cfstring) { CFRelease (compare_to_cfstring); }
- return check_error (err);
+ return check_error (err);
}
/* ------------------------------------------------------------------------ */
kim_error err = KIM_NO_ERROR;
CFStringRef cfstring = NULL;
- if (!err && !in_string ) { err = param_error (1, "in_string", "NULL"); }
- if (!err && !in_compare_to_cfstring) { err = param_error (2, "in_compare_to_cfstring", "NULL"); }
- if (!err && !out_comparison ) { err = param_error (3, "out_comparison", "NULL"); }
+ if (!err && !in_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !in_compare_to_cfstring) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !out_comparison ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_os_string_get_cfstring (in_string, &cfstring);
if (cfstring) { CFRelease (cfstring); }
- return check_error (err);
+ return check_error (err);
}