summaryrefslogtreecommitdiffstats
path: root/src/ccapi/common
diff options
context:
space:
mode:
authorAlexandra Ellwood <lxs@mit.edu>2007-05-31 21:06:54 +0000
committerAlexandra Ellwood <lxs@mit.edu>2007-05-31 21:06:54 +0000
commitd45eeb7f708d5be2e9fbdbc54a04655776074f6c (patch)
tree5ab3d7e31f285ac4d6900d3abc647cbb53a05f8d /src/ccapi/common
parent66bd29f512b9bdd5e808d645118862112973d2d6 (diff)
downloadkrb5-d45eeb7f708d5be2e9fbdbc54a04655776074f6c.tar.gz
krb5-d45eeb7f708d5be2e9fbdbc54a04655776074f6c.tar.xz
krb5-d45eeb7f708d5be2e9fbdbc54a04655776074f6c.zip
Move CCAPI sources to krb5 repository
ticket: new status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19564 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/ccapi/common')
-rw-r--r--src/ccapi/common/cci_array_internal.c306
-rw-r--r--src/ccapi/common/cci_array_internal.h64
-rw-r--r--src/ccapi/common/cci_common.h55
-rw-r--r--src/ccapi/common/cci_cred_union.c679
-rw-r--r--src/ccapi/common/cci_cred_union.h41
-rw-r--r--src/ccapi/common/cci_debugging.c55
-rw-r--r--src/ccapi/common/cci_debugging.h40
-rw-r--r--src/ccapi/common/cci_identifier.c289
-rw-r--r--src/ccapi/common/cci_identifier.h65
-rw-r--r--src/ccapi/common/cci_message.c172
-rw-r--r--src/ccapi/common/cci_message.h48
-rw-r--r--src/ccapi/common/cci_os_debugging.h35
-rw-r--r--src/ccapi/common/cci_os_identifier.h34
-rw-r--r--src/ccapi/common/cci_stream.c490
-rw-r--r--src/ccapi/common/cci_stream.h77
-rw-r--r--src/ccapi/common/cci_types.h105
-rw-r--r--src/ccapi/common/mac/cci_mig.defs54
-rw-r--r--src/ccapi/common/mac/cci_mig_reply.defs58
-rw-r--r--src/ccapi/common/mac/cci_mig_request.defs62
-rw-r--r--src/ccapi/common/mac/cci_mig_types.h56
-rw-r--r--src/ccapi/common/mac/cci_os_debugging.c36
-rw-r--r--src/ccapi/common/mac/cci_os_identifier.c80
22 files changed, 2901 insertions, 0 deletions
diff --git a/src/ccapi/common/cci_array_internal.c b/src/ccapi/common/cci_array_internal.c
new file mode 100644
index 0000000000..8e6bcd7e24
--- /dev/null
+++ b/src/ccapi/common/cci_array_internal.c
@@ -0,0 +1,306 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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.
+ */
+
+#include "cci_common.h"
+#include "cci_array_internal.h"
+
+/* ------------------------------------------------------------------------ */
+
+struct cci_array_d {
+ cci_array_object_t *objects;
+ cc_uint64 count;
+ cc_uint64 max_count;
+
+ cci_array_object_release_t object_release;
+};
+
+struct cci_array_d cci_array_initializer = { NULL, 0, 0, NULL };
+
+#define CCI_ARRAY_COUNT_INCREMENT 16
+
+/* ------------------------------------------------------------------------ */
+
+static cc_int32 cci_array_resize (cci_array_t io_array,
+ cc_uint64 in_new_count)
+{
+ cc_int32 err = ccNoError;
+ cc_uint64 new_max_count = 0;
+ cci_array_object_t *objects = NULL;
+
+ if (!io_array) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ cc_uint64 old_max_count = io_array->max_count;
+ new_max_count = io_array->max_count;
+
+ if (in_new_count > old_max_count) {
+ /* Expand the array */
+ while (in_new_count > new_max_count) {
+ new_max_count += CCI_ARRAY_COUNT_INCREMENT;
+ }
+
+ } else if ((in_new_count + CCI_ARRAY_COUNT_INCREMENT) < old_max_count) {
+ /* Shrink the array, but never drop below CC_ARRAY_COUNT_INCREMENT */
+ while ((in_new_count + CCI_ARRAY_COUNT_INCREMENT) < new_max_count &&
+ (new_max_count > CCI_ARRAY_COUNT_INCREMENT)) {
+ new_max_count -= CCI_ARRAY_COUNT_INCREMENT;
+ }
+ }
+ }
+
+ if (!err) {
+ objects = io_array->objects;
+
+ if (!objects) {
+ objects = malloc (new_max_count * sizeof (*objects));
+ } else {
+ objects = realloc (objects, new_max_count * sizeof (*objects));
+ }
+ if (!objects) { err = cci_check_error (ccErrNoMem); }
+ }
+
+ if (!err) {
+ io_array->objects = objects;
+ io_array->max_count = new_max_count;
+ }
+
+ return cci_check_error (err);
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_array_new (cci_array_t *out_array,
+ cci_array_object_release_t in_array_object_release)
+{
+ cc_int32 err = ccNoError;
+ cci_array_t array = NULL;
+
+ if (!out_array) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ array = malloc (sizeof (*array));
+ if (array) {
+ *array = cci_array_initializer;
+ array->object_release = in_array_object_release;
+ } else {
+ err = cci_check_error (ccErrNoMem);
+ }
+ }
+
+ if (!err) {
+ *out_array = array;
+ array = NULL;
+ }
+
+ cci_array_release (array);
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_array_release (cci_array_t io_array)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_array) { err = ccErrBadParam; }
+
+ if (!err) {
+ cc_uint64 i;
+
+ for (i = 0; i < io_array->count; i++) {
+ io_array->object_release (io_array->objects[i]);
+ }
+ free (io_array->objects);
+ free (io_array);
+ }
+
+ return err;
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint64 cci_array_count (cci_array_t in_array)
+{
+ return in_array ? in_array->count : 0;
+}
+
+/* ------------------------------------------------------------------------ */
+
+cci_array_object_t cci_array_object_at_index (cci_array_t io_array,
+ cc_uint64 in_position)
+{
+ if (io_array && in_position < io_array->count) {
+ return io_array->objects[in_position];
+ } else {
+ if (!io_array) {
+ cci_debug_printf ("%s() got NULL array", __FUNCTION__);
+ } else {
+ cci_debug_printf ("%s() got bad index %lld (count = %lld)", __FUNCTION__,
+ in_position, io_array->count);
+ }
+ return NULL;
+ }
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_array_insert (cci_array_t io_array,
+ cci_array_object_t in_object,
+ cc_uint64 in_position)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_array ) { err = cci_check_error (ccErrBadParam); }
+ if (!in_object) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ /* Don't try to insert past the end and don't overflow the array */
+ if (in_position > io_array->count || io_array->count == UINT64_MAX) {
+ err = cci_check_error (ccErrBadParam);
+ }
+ }
+
+ if (!err) {
+ err = cci_array_resize (io_array, io_array->count + 1);
+ }
+
+ if (!err) {
+ unsigned char **objects = (unsigned char **)io_array->objects;
+ cc_uint64 move_count = io_array->count - in_position;
+
+ if (move_count > 0) {
+ memmove (&objects[in_position + 1], &objects[in_position],
+ move_count * sizeof (*objects));
+ }
+
+ objects[in_position] = in_object;
+ io_array->count++;
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_array_remove (cci_array_t io_array,
+ cc_uint64 in_position)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_array) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err && in_position >= io_array->count) {
+ err = cci_check_error (ccErrBadParam);
+ }
+
+ if (!err) {
+ unsigned char **objects = (unsigned char **)io_array->objects;
+ cc_uint64 move_count = io_array->count - in_position - 1;
+ cci_array_object_t object = objects[in_position];
+
+ if (move_count > 0) {
+ memmove (&objects[in_position], &objects[in_position + 1],
+ move_count * sizeof (*objects));
+ }
+
+ io_array->object_release (object);
+ io_array->count--;
+
+ cci_array_resize (io_array, io_array->count);
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_array_move (cci_array_t io_array,
+ cc_uint64 in_position,
+ cc_uint64 in_new_position,
+ cc_uint64 *out_real_new_position)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_array ) { err = cci_check_error (ccErrBadParam); }
+ if (!out_real_new_position) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err && in_position >= io_array->count) {
+ err = cci_check_error (ccErrBadParam);
+ }
+
+ if (!err && in_new_position > io_array->count) {
+ err = cci_check_error (ccErrBadParam);
+ }
+ if (!err) {
+ cc_uint64 move_from = 0;
+ cc_uint64 move_to = 0;
+ cc_uint64 move_count = 0;
+ cc_uint64 real_new_position = 0;
+
+ if (in_position < in_new_position) {
+ /* shift right, making an empty space so the
+ * actual new position is one less in_new_position */
+ move_from = in_position + 1;
+ move_to = in_position;
+ move_count = in_new_position - in_position - 1;
+ real_new_position = in_new_position - 1;
+ } else {
+ /* shift left */
+ move_from = in_new_position;
+ move_to = in_new_position + 1;
+ move_count = in_position - in_new_position;
+ real_new_position = in_new_position;
+ }
+
+ if (move_count > 0) {
+ unsigned char **objects = (unsigned char **)io_array->objects;
+ cci_array_object_t object = objects[in_position];
+
+ memmove (&objects[move_to], &objects[move_from],
+ move_count * sizeof (*objects));
+ objects[real_new_position] = object;
+ }
+
+ *out_real_new_position = real_new_position;
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_array_push_front (cci_array_t io_array,
+ cc_uint64 in_position)
+{
+ cc_uint64 real_new_position = 0;
+ return cci_array_move (io_array, in_position, 0, &real_new_position);
+}
+
diff --git a/src/ccapi/common/cci_array_internal.h b/src/ccapi/common/cci_array_internal.h
new file mode 100644
index 0000000000..a88e529518
--- /dev/null
+++ b/src/ccapi/common/cci_array_internal.h
@@ -0,0 +1,64 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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 CCI_ARRAY_INTERNAL_H
+#define CCI_ARRAY_INTERNAL_H
+
+#include "cci_types.h"
+
+typedef void *cci_array_object_t;
+typedef cc_int32 (*cci_array_object_release_t) (cci_array_object_t);
+
+struct cci_array_d;
+typedef struct cci_array_d *cci_array_t;
+
+cc_int32 cci_array_new (cci_array_t *out_array,
+ cci_array_object_release_t in_array_object_release);
+
+cc_int32 cci_array_release (cci_array_t io_array);
+
+cc_uint64 cci_array_count (cci_array_t in_array);
+
+cci_array_object_t cci_array_object_at_index (cci_array_t io_array,
+ cc_uint64 in_position);
+
+cc_int32 cci_array_insert (cci_array_t io_array,
+ cci_array_object_t in_object,
+ cc_uint64 in_position);
+
+cc_int32 cci_array_remove (cci_array_t io_array,
+ cc_uint64 in_position);
+
+cc_int32 cci_array_move (cci_array_t io_array,
+ cc_uint64 in_position,
+ cc_uint64 in_new_position,
+ cc_uint64 *out_real_new_position);
+
+cc_int32 cci_array_push_front (cci_array_t io_array,
+ cc_uint64 in_position);
+
+
+#endif /* CCI_ARRAY_INTERNAL_H */
diff --git a/src/ccapi/common/cci_common.h b/src/ccapi/common/cci_common.h
new file mode 100644
index 0000000000..a77b16c3e4
--- /dev/null
+++ b/src/ccapi/common/cci_common.h
@@ -0,0 +1,55 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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 CCI_COMMON_H
+#define CCI_COMMON_H
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <com_err.h>
+
+#include <CredentialsCache.h>
+
+#if TARGET_OS_MAC
+#define VECTOR_FUNCTIONS_INITIALIZER ,NULL
+#else
+#define VECTOR_FUNCTIONS_INITIALIZER
+#endif
+
+#define k_cci_context_initial_ccache_name "Initial default ccache"
+
+#include "cci_cred_union.h"
+#include "cci_debugging.h"
+#include "cci_identifier.h"
+#include "cci_message.h"
+#include "cci_stream.h"
+
+#endif /* CCI_COMMON_H */
diff --git a/src/ccapi/common/cci_cred_union.c b/src/ccapi/common/cci_cred_union.c
new file mode 100644
index 0000000000..74a87a6868
--- /dev/null
+++ b/src/ccapi/common/cci_cred_union.c
@@ -0,0 +1,679 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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.
+ */
+
+#include "cci_common.h"
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_credentials_v4_release (cc_credentials_v4_t *io_v4creds)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_v4creds) { err = ccErrBadParam; }
+
+ if (!err) {
+ memset (io_v4creds, 0, sizeof (*io_v4creds));
+ free (io_v4creds);
+ }
+
+ return err;
+}
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_credentials_v4_read (cc_credentials_v4_t **out_v4creds,
+ cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+ cc_credentials_v4_t *v4creds = NULL;
+
+ if (!io_stream ) { err = cci_check_error (ccErrBadParam); }
+ if (!out_v4creds) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ v4creds = malloc (sizeof (*v4creds));
+ if (!v4creds) { err = cci_check_error (ccErrNoMem); }
+ }
+
+ if (!err) {
+ err = cci_stream_read_uint32 (io_stream, &v4creds->version);
+ }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, v4creds->principal, cc_v4_name_size);
+ }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, v4creds->principal_instance, cc_v4_instance_size);
+ }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, v4creds->service, cc_v4_name_size);
+ }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, v4creds->service_instance, cc_v4_instance_size);
+ }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, v4creds->realm, cc_v4_realm_size);
+ }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, v4creds->session_key, cc_v4_key_size);
+ }
+
+ if (!err) {
+ err = cci_stream_read_int32 (io_stream, &v4creds->kvno);
+ }
+
+ if (!err) {
+ err = cci_stream_read_int32 (io_stream, &v4creds->string_to_key_type);
+ }
+
+ if (!err) {
+ err = cci_stream_read_time (io_stream, &v4creds->issue_date);
+ }
+
+ if (!err) {
+ err = cci_stream_read_int32 (io_stream, &v4creds->lifetime);
+ }
+
+ if (!err) {
+ err = cci_stream_read_uint32 (io_stream, &v4creds->address);
+ }
+
+ if (!err) {
+ err = cci_stream_read_int32 (io_stream, &v4creds->ticket_size);
+ }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, v4creds->ticket, cc_v4_ticket_size);
+ }
+
+ if (!err) {
+ *out_v4creds = v4creds;
+ v4creds = NULL;
+ }
+
+ free (v4creds);
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_credentials_v4_write (cc_credentials_v4_t *in_v4creds,
+ cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_stream ) { err = cci_check_error (ccErrBadParam); }
+ if (!in_v4creds) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_write_uint32 (io_stream, in_v4creds->version);
+ }
+
+ if (!err) {
+ err = cci_stream_write (io_stream, in_v4creds->principal, cc_v4_name_size);
+ }
+
+ if (!err) {
+ err = cci_stream_write (io_stream, in_v4creds->principal_instance, cc_v4_instance_size);
+ }
+
+ if (!err) {
+ err = cci_stream_write (io_stream, in_v4creds->service, cc_v4_name_size);
+ }
+
+ if (!err) {
+ err = cci_stream_write (io_stream, in_v4creds->service_instance, cc_v4_instance_size);
+ }
+
+ if (!err) {
+ err = cci_stream_write (io_stream, in_v4creds->realm, cc_v4_realm_size);
+ }
+
+ if (!err) {
+ err = cci_stream_write (io_stream, in_v4creds->session_key, cc_v4_key_size);
+ }
+
+ if (!err) {
+ err = cci_stream_write_int32 (io_stream, in_v4creds->kvno);
+ }
+
+ if (!err) {
+ err = cci_stream_write_int32 (io_stream, in_v4creds->string_to_key_type);
+ }
+
+ if (!err) {
+ err = cci_stream_write_time (io_stream, in_v4creds->issue_date);
+ }
+
+ if (!err) {
+ err = cci_stream_write_int32 (io_stream, in_v4creds->lifetime);
+ }
+
+ if (!err) {
+ err = cci_stream_write_uint32 (io_stream, in_v4creds->address);
+ }
+
+ if (!err) {
+ err = cci_stream_write_int32 (io_stream, in_v4creds->ticket_size);
+ }
+
+ if (!err) {
+ err = cci_stream_write (io_stream, in_v4creds->ticket, cc_v4_ticket_size);
+ }
+
+ return cci_check_error (err);
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_cc_data_contents_release (cc_data *io_ccdata)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_ccdata && io_ccdata->data) { err = ccErrBadParam; }
+
+ if (!err) {
+ if (io_ccdata->length) {
+ memset (io_ccdata->data, 0, io_ccdata->length);
+ }
+ free (io_ccdata->data);
+ }
+
+ return err;
+}
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_cc_data_release (cc_data *io_ccdata)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_ccdata) { err = ccErrBadParam; }
+
+ if (!err) {
+ cci_cc_data_contents_release (io_ccdata);
+ free (io_ccdata);
+ }
+
+ return err;
+}
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_cc_data_read (cc_data *io_ccdata,
+ cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+ cc_uint32 type = 0;
+ cc_uint32 length = 0;
+ char *data = NULL;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+ if (!io_ccdata) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_read_uint32 (io_stream, &type);
+ }
+
+ if (!err) {
+ err = cci_stream_read_uint32 (io_stream, &length);
+ }
+
+ if (!err && length > 0) {
+ data = malloc (length);
+ if (!data) { err = cci_check_error (ccErrNoMem); }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, data, length);
+ }
+ }
+
+ if (!err) {
+ io_ccdata->type = type;
+ io_ccdata->length = length;
+ io_ccdata->data = data;
+ data = NULL;
+ }
+
+ free (data);
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_cc_data_write (cc_data *in_ccdata,
+ cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+ if (!in_ccdata) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_write_uint32 (io_stream, in_ccdata->type);
+ }
+
+ if (!err) {
+ err = cci_stream_write_uint32 (io_stream, in_ccdata->length);
+ }
+
+ if (!err && in_ccdata->length > 0) {
+ err = cci_stream_write (io_stream, in_ccdata->data, in_ccdata->length);
+ }
+
+ return cci_check_error (err);
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_cc_data_array_release (cc_data **io_ccdata_array)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_ccdata_array) { err = ccErrBadParam; }
+
+ if (!err) {
+ cc_uint32 i;
+
+ for (i = 0; io_ccdata_array && io_ccdata_array[i]; i++) {
+ cci_cc_data_release (io_ccdata_array[i]);
+ }
+ free (io_ccdata_array);
+ }
+
+ return err;
+}
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_cc_data_array_read (cc_data ***io_ccdata_array,
+ cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+ cc_uint32 count = 0;
+ cc_data **array = NULL;
+ cc_uint32 i;
+
+ if (!io_stream ) { err = cci_check_error (ccErrBadParam); }
+ if (!io_ccdata_array) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_read_uint32 (io_stream, &count);
+ }
+
+ if (!err && count > 0) {
+ array = malloc ((count + 1) * sizeof (*array));
+ if (array) {
+ for (i = 0; i <= count; i++) { array[i] = NULL; }
+ } else {
+ err = cci_check_error (ccErrNoMem);
+ }
+ }
+
+ if (!err) {
+ for (i = 0; !err && i < count; i++) {
+ array[i] = malloc (sizeof (cc_data));
+ if (!array[i]) { err = cci_check_error (ccErrNoMem); }
+
+ if (!err) {
+ err = cci_cc_data_read (array[i], io_stream);
+ }
+ }
+ }
+
+ if (!err) {
+ *io_ccdata_array = array;
+ array = NULL;
+ }
+
+ cci_cc_data_array_release (array);
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_cc_data_array_write (cc_data **in_ccdata_array,
+ cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+ cc_uint32 count = 0;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+ /* in_ccdata_array may be NULL */
+
+ if (!err) {
+ for (count = 0; in_ccdata_array && in_ccdata_array[count]; count++);
+
+ err = cci_stream_write_uint32 (io_stream, count);
+ }
+
+ if (!err) {
+ cc_uint32 i;
+
+ for (i = 0; !err && i < count; i++) {
+ err = cci_cc_data_write (in_ccdata_array[i], io_stream);
+ }
+ }
+
+ return cci_check_error (err);
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_credentials_v5_t cci_credentials_v5_initializer = {
+ NULL,
+ NULL,
+ { 0, 0, NULL },
+ 0, 0, 0, 0, 0, 0,
+ NULL,
+ { 0, 0, NULL },
+ { 0, 0, NULL },
+ NULL
+};
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_credentials_v5_release (cc_credentials_v5_t *io_v5creds)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_v5creds) { err = ccErrBadParam; }
+
+ if (!err) {
+ free (io_v5creds->client);
+ free (io_v5creds->server);
+ cci_cc_data_contents_release (&io_v5creds->keyblock);
+ cci_cc_data_array_release (io_v5creds->addresses);
+ cci_cc_data_contents_release (&io_v5creds->ticket);
+ cci_cc_data_contents_release (&io_v5creds->second_ticket);
+ cci_cc_data_array_release (io_v5creds->authdata);
+ free (io_v5creds);
+ }
+
+ return err;
+}
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_credentials_v5_read (cc_credentials_v5_t **out_v5creds,
+ cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+ cc_credentials_v5_t *v5creds = NULL;
+
+ if (!io_stream ) { err = cci_check_error (ccErrBadParam); }
+ if (!out_v5creds) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ v5creds = malloc (sizeof (*v5creds));
+ if (v5creds) {
+ *v5creds = cci_credentials_v5_initializer;
+ } else {
+ err = cci_check_error (ccErrNoMem);
+ }
+ }
+
+ if (!err) {
+ err = cci_stream_read_string (io_stream, &v5creds->client);
+ }
+
+ if (!err) {
+ err = cci_stream_read_string (io_stream, &v5creds->server);
+ }
+
+ if (!err) {
+ err = cci_cc_data_read (&v5creds->keyblock, io_stream);
+ }
+
+ if (!err) {
+ err = cci_stream_read_time (io_stream, &v5creds->authtime);
+ }
+
+ if (!err) {
+ err = cci_stream_read_time (io_stream, &v5creds->starttime);
+ }
+
+ if (!err) {
+ err = cci_stream_read_time (io_stream, &v5creds->endtime);
+ }
+
+ if (!err) {
+ err = cci_stream_read_time (io_stream, &v5creds->renew_till);
+ }
+
+ if (!err) {
+ err = cci_stream_read_uint32 (io_stream, &v5creds->is_skey);
+ }
+
+ if (!err) {
+ err = cci_stream_read_uint32 (io_stream, &v5creds->ticket_flags);
+ }
+
+ if (!err) {
+ err = cci_cc_data_array_read (&v5creds->addresses, io_stream);
+ }
+
+ if (!err) {
+ err = cci_cc_data_read (&v5creds->ticket, io_stream);
+ }
+
+ if (!err) {
+ err = cci_cc_data_read (&v5creds->second_ticket, io_stream);
+ }
+
+ if (!err) {
+ err = cci_cc_data_array_read (&v5creds->authdata, io_stream);
+ }
+
+ if (!err) {
+ *out_v5creds = v5creds;
+ v5creds = NULL;
+ }
+
+ cci_credentials_v5_release (v5creds);
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_credentials_v5_write (cc_credentials_v5_t *in_v5creds,
+ cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_stream ) { err = cci_check_error (ccErrBadParam); }
+ if (!in_v5creds) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_write_string (io_stream, in_v5creds->client);
+ }
+
+ if (!err) {
+ err = cci_stream_write_string (io_stream, in_v5creds->server);
+ }
+
+ if (!err) {
+ err = cci_cc_data_write (&in_v5creds->keyblock, io_stream);
+ }
+
+ if (!err) {
+ err = cci_stream_write_time (io_stream, in_v5creds->authtime);
+ }
+
+ if (!err) {
+ err = cci_stream_write_time (io_stream, in_v5creds->starttime);
+ }
+
+ if (!err) {
+ err = cci_stream_write_time (io_stream, in_v5creds->endtime);
+ }
+
+ if (!err) {
+ err = cci_stream_write_time (io_stream, in_v5creds->renew_till);
+ }
+
+ if (!err) {
+ err = cci_stream_write_uint32 (io_stream, in_v5creds->is_skey);
+ }
+
+ if (!err) {
+ err = cci_stream_write_uint32 (io_stream, in_v5creds->ticket_flags);
+ }
+
+ if (!err) {
+ err = cci_cc_data_array_write (in_v5creds->addresses, io_stream);
+ }
+
+ if (!err) {
+ err = cci_cc_data_write (&in_v5creds->ticket, io_stream);
+ }
+
+ if (!err) {
+ err = cci_cc_data_write (&in_v5creds->second_ticket, io_stream);
+ }
+
+ if (!err) {
+ err = cci_cc_data_array_write (in_v5creds->authdata, io_stream);
+ }
+
+
+ return cci_check_error (err);
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_cred_union_release (cc_credentials_union *io_cred_union)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_cred_union) { err = ccErrBadParam; }
+
+ if (!err) {
+ if (io_cred_union->version == cc_credentials_v4) {
+ cci_credentials_v4_release (io_cred_union->credentials.credentials_v4);
+ } else if (io_cred_union->version == cc_credentials_v5) {
+ cci_credentials_v5_release (io_cred_union->credentials.credentials_v5);
+ }
+ free (io_cred_union);
+ }
+
+ return err;
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_cred_union_read (cc_credentials_union **out_credentials_union,
+ cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+ cc_credentials_union *cred_union = NULL;
+
+ if (!io_stream ) { err = cci_check_error (ccErrBadParam); }
+ if (!out_credentials_union) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ cred_union = malloc (sizeof (*cred_union));
+ if (!cred_union) { err = cci_check_error (ccErrNoMem); }
+ }
+
+ if (!err) {
+ err = cci_stream_read_uint32 (io_stream, &cred_union->version);
+ }
+
+ if (!err) {
+ if (cred_union->version == cc_credentials_v4) {
+ err = cci_credentials_v4_read (&cred_union->credentials.credentials_v4,
+ io_stream);
+
+ } else if (cred_union->version == cc_credentials_v5) {
+ err = cci_credentials_v5_read (&cred_union->credentials.credentials_v5,
+ io_stream);
+
+
+ } else {
+ err = ccErrBadCredentialsVersion;
+ }
+ }
+
+ if (!err) {
+ *out_credentials_union = cred_union;
+ cred_union = NULL;
+ }
+
+ if (cred_union) { cci_cred_union_release (cred_union); }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_cred_union_write (const cc_credentials_union *in_credentials_union,
+ cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_stream ) { err = cci_check_error (ccErrBadParam); }
+ if (!in_credentials_union) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_write_uint32 (io_stream, in_credentials_union->version);
+ }
+
+ if (!err) {
+ if (in_credentials_union->version == cc_credentials_v4) {
+ err = cci_credentials_v4_write (in_credentials_union->credentials.credentials_v4,
+ io_stream);
+
+ } else if (in_credentials_union->version == cc_credentials_v5) {
+ err = cci_credentials_v5_write (in_credentials_union->credentials.credentials_v5,
+ io_stream);
+
+ } else {
+ err = ccErrBadCredentialsVersion;
+ }
+ }
+
+ return cci_check_error (err);
+}
diff --git a/src/ccapi/common/cci_cred_union.h b/src/ccapi/common/cci_cred_union.h
new file mode 100644
index 0000000000..f734d6a355
--- /dev/null
+++ b/src/ccapi/common/cci_cred_union.h
@@ -0,0 +1,41 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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 CCI_CRED_UNION_H
+#define CCI_CRED_UNION_H
+
+#include "cci_types.h"
+
+cc_uint32 cci_cred_union_release (cc_credentials_union *io_credentials);
+
+cc_uint32 cci_cred_union_read (cc_credentials_union **out_credentials_union,
+ cci_stream_t io_stream);
+
+cc_uint32 cci_cred_union_write (const cc_credentials_union *in_credentials_union,
+ cci_stream_t io_stream);
+
+
+#endif /* CCI_CRED_UNION_H */
diff --git a/src/ccapi/common/cci_debugging.c b/src/ccapi/common/cci_debugging.c
new file mode 100644
index 0000000000..4545b402ef
--- /dev/null
+++ b/src/ccapi/common/cci_debugging.c
@@ -0,0 +1,55 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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.
+ */
+
+#include "cci_common.h"
+#include "cci_os_debugging.h"
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 _cci_check_error (cc_int32 in_error,
+ const char *in_function,
+ const char *in_file,
+ int in_line)
+{
+ /* Do not log for flow control errors or when there is no error at all */
+ if (in_error != ccNoError && in_error != ccIteratorEnd) {
+ cci_debug_printf ("%s() got %d at %s: %d", in_function,
+ in_error, in_file, in_line);
+ }
+
+ return in_error;
+}
+
+/* ------------------------------------------------------------------------ */
+
+void cci_debug_printf (const char *in_format, ...)
+{
+ va_list args;
+
+ va_start (args, in_format);
+ cci_os_debug_vprintf (in_format, args);
+ va_end (args);
+}
diff --git a/src/ccapi/common/cci_debugging.h b/src/ccapi/common/cci_debugging.h
new file mode 100644
index 0000000000..169981f65d
--- /dev/null
+++ b/src/ccapi/common/cci_debugging.h
@@ -0,0 +1,40 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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 CCI_DEBUGGING_H
+#define CCI_DEBUGGING_H
+
+#include "cci_types.h"
+
+cc_int32 _cci_check_error (cc_int32 in_err,
+ const char *in_function,
+ const char *in_file,
+ int in_line);
+#define cci_check_error(err) _cci_check_error(err, __FUNCTION__, __FILE__, __LINE__)
+
+void cci_debug_printf (const char *in_format, ...) __attribute__ ((format (printf, 1, 2)));
+
+#endif /* CCI_DEBUGGING_H */
diff --git a/src/ccapi/common/cci_identifier.c b/src/ccapi/common/cci_identifier.c
new file mode 100644
index 0000000000..8695d2171b
--- /dev/null
+++ b/src/ccapi/common/cci_identifier.c
@@ -0,0 +1,289 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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.
+ */
+
+#include "cci_common.h"
+#include "cci_os_identifier.h"
+
+struct cci_identifier_d {
+ cci_uuid_string_t server_id;
+ cci_uuid_string_t object_id;
+};
+
+struct cci_identifier_d cci_identifier_initializer = { NULL, NULL };
+
+#define cci_uninitialized_server_id "NEEDS_SYNC"
+#define cci_uninitialized_object_id "NEEDS_SYNC"
+
+struct cci_identifier_d cci_identifier_uninitialized_d = {
+ cci_uninitialized_server_id,
+ cci_uninitialized_object_id
+};
+const cci_identifier_t cci_identifier_uninitialized = &cci_identifier_uninitialized_d;
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_identifier_new_uuid (cci_uuid_string_t *out_uuid_string)
+{
+ return cci_os_identifier_new_uuid (out_uuid_string);
+}
+
+/* ------------------------------------------------------------------------ */
+
+static cc_int32 cci_identifier_alloc (cci_identifier_t *out_identifier,
+ cci_uuid_string_t in_server_id,
+ cci_uuid_string_t in_object_id)
+{
+ cc_int32 err = ccNoError;
+ cci_identifier_t identifier = NULL;
+
+ if (!out_identifier) { err = cci_check_error (ccErrBadParam); }
+ if (!in_server_id ) { err = cci_check_error (ccErrBadParam); }
+ if (!in_object_id ) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ identifier = malloc (sizeof (*identifier));
+ if (identifier) {
+ *identifier = cci_identifier_initializer;
+ } else {
+ err = cci_check_error (ccErrNoMem);
+ }
+ }
+
+ if (!err) {
+ identifier->server_id = strdup (in_server_id);
+ if (!identifier->server_id) { err = cci_check_error (ccErrNoMem); }
+ }
+
+ if (!err) {
+ identifier->object_id = strdup (in_object_id);
+ if (!identifier->object_id) { err = cci_check_error (ccErrNoMem); }
+ }
+
+ if (!err) {
+ *out_identifier = identifier;
+ identifier = NULL; /* take ownership */
+ }
+
+ cci_identifier_release (identifier);
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_identifier_new (cci_identifier_t *out_identifier,
+ cci_uuid_string_t in_server_id)
+{
+ cc_int32 err = ccNoError;
+ cci_uuid_string_t object_id = NULL;
+
+ if (!out_identifier) { err = cci_check_error (ccErrBadParam); }
+ if (!in_server_id ) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_os_identifier_new_uuid (&object_id);
+ }
+
+ if (!err) {
+ err = cci_identifier_alloc (out_identifier, in_server_id, object_id);
+ }
+
+ if (object_id) { free (object_id); }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_identifier_copy (cci_identifier_t *out_identifier,
+ cci_identifier_t in_identifier)
+{
+ cc_int32 err = ccNoError;
+
+ if (!out_identifier) { err = cci_check_error (ccErrBadParam); }
+ if (!in_identifier ) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_identifier_alloc (out_identifier,
+ in_identifier->server_id,
+ in_identifier->object_id);
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_identifier_release (cci_identifier_t in_identifier)
+{
+ cc_int32 err = ccNoError;
+
+ if (!in_identifier) { err = ccErrBadParam; }
+
+ /* Do not free the static "uninitialized" identifier */
+ if (!err && in_identifier != cci_identifier_uninitialized) {
+ free (in_identifier->server_id);
+ free (in_identifier->object_id);
+ free (in_identifier);
+ }
+
+ return err;
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_identifier_compare (cci_identifier_t in_identifier,
+ cci_identifier_t in_compare_to_identifier,
+ cc_uint32 *out_equal)
+{
+ cc_int32 err = ccNoError;
+
+ if (!in_identifier ) { err = cci_check_error (ccErrBadParam); }
+ if (!in_compare_to_identifier) { err = cci_check_error (ccErrBadParam); }
+ if (!out_equal ) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ *out_equal = (!strcmp (in_identifier->object_id,
+ in_compare_to_identifier->object_id) &&
+ !strcmp (in_identifier->server_id,
+ in_compare_to_identifier->server_id));
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_identifier_is_for_server (cci_identifier_t in_identifier,
+ cci_uuid_string_t in_server_id,
+ cc_uint32 *out_is_for_server)
+{
+ cc_int32 err = ccNoError;
+
+ if (!in_identifier ) { err = cci_check_error (ccErrBadParam); }
+ if (!in_server_id ) { err = cci_check_error (ccErrBadParam); }
+ if (!out_is_for_server) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ *out_is_for_server = (!strcmp (in_identifier->server_id, in_server_id) ||
+ !strcmp (in_identifier->server_id, cci_uninitialized_server_id));
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_identifier_compare_server_id (cci_identifier_t in_identifier,
+ cci_identifier_t in_compare_to_identifier,
+ cc_uint32 *out_equal_server_id)
+{
+ cc_int32 err = ccNoError;
+
+ if (!in_identifier ) { err = cci_check_error (ccErrBadParam); }
+ if (!in_compare_to_identifier) { err = cci_check_error (ccErrBadParam); }
+ if (!out_equal_server_id ) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ *out_equal_server_id = (!strcmp (in_identifier->server_id,
+ in_compare_to_identifier->server_id));
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_identifier_is_initialized (cci_identifier_t in_identifier,
+ cc_uint32 *out_is_initialized)
+{
+ cc_int32 err = ccNoError;
+
+ if (!in_identifier ) { err = cci_check_error (ccErrBadParam); }
+ if (!out_is_initialized) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ *out_is_initialized = (strcmp (in_identifier->server_id,
+ cci_uninitialized_server_id) != 0);
+ }
+
+ return cci_check_error (err);
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_identifier_read (cci_identifier_t *out_identifier,
+ cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+ cci_uuid_string_t server_id = NULL;
+ cci_uuid_string_t object_id = NULL;
+
+ if (!out_identifier) { err = cci_check_error (ccErrBadParam); }
+ if (!io_stream ) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_read_string (io_stream, &server_id);
+ }
+
+ if (!err) {
+ err = cci_stream_read_string (io_stream, &object_id);
+ }
+
+ if (!err) {
+ err = cci_identifier_alloc (out_identifier, server_id, object_id);
+ }
+
+ if (server_id) { free (server_id); }
+ if (object_id) { free (object_id); }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_identifier_write (cci_identifier_t in_identifier,
+ cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+
+ if (!in_identifier) { err = cci_check_error (ccErrBadParam); }
+ if (!io_stream ) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_write_string (io_stream, in_identifier->server_id);
+ }
+
+ if (!err) {
+ err = cci_stream_write_string (io_stream, in_identifier->object_id);
+ }
+
+ return cci_check_error (err);
+}
diff --git a/src/ccapi/common/cci_identifier.h b/src/ccapi/common/cci_identifier.h
new file mode 100644
index 0000000000..7d835de0a3
--- /dev/null
+++ b/src/ccapi/common/cci_identifier.h
@@ -0,0 +1,65 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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 CCI_IDENTIFIER_H
+#define CCI_IDENTIFIER_H
+
+#include "cci_types.h"
+
+extern const cci_identifier_t cci_identifier_uninitialized;
+
+cc_int32 cci_identifier_new_uuid (cci_uuid_string_t *out_uuid_string);
+
+cc_int32 cci_identifier_new (cci_identifier_t *out_identifier,
+ cci_uuid_string_t in_server_id);
+
+cc_int32 cci_identifier_copy (cci_identifier_t *out_identifier,
+ cci_identifier_t in_handle);
+
+cc_int32 cci_identifier_release (cci_identifier_t in_identifier);
+
+cc_int32 cci_identifier_compare (cci_identifier_t in_identifier,
+ cci_identifier_t in_compare_to_identifier,
+ cc_uint32 *out_equal);
+
+cc_int32 cci_identifier_is_for_server (cci_identifier_t in_identifier,
+ cci_uuid_string_t in_server_id,
+ cc_uint32 *out_is_for_server);
+
+cc_int32 cci_identifier_compare_server_id (cci_identifier_t in_identifier,
+ cci_identifier_t in_compare_to_identifier,
+ cc_uint32 *out_equal_server_id);
+
+cc_int32 cci_identifier_is_initialized (cci_identifier_t in_identifier,
+ cc_uint32 *out_is_initialized);
+
+cc_uint32 cci_identifier_read (cci_identifier_t *out_identifier,
+ cci_stream_t io_stream);
+
+cc_uint32 cci_identifier_write (cci_identifier_t in_identifier,
+ cci_stream_t io_stream);
+
+#endif /* CCI_IDENTIFIER_H */
diff --git a/src/ccapi/common/cci_message.c b/src/ccapi/common/cci_message.c
new file mode 100644
index 0000000000..4152e6c3cf
--- /dev/null
+++ b/src/ccapi/common/cci_message.c
@@ -0,0 +1,172 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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.
+ */
+
+#include "cci_common.h"
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_message_invalid_object_err (enum cci_msg_id_t in_request_name)
+{
+ cc_int32 err = ccNoError;
+
+ if (in_request_name > cci_context_first_msg_id &&
+ in_request_name < cci_context_last_msg_id) {
+ err = ccErrInvalidContext;
+
+ } else if (in_request_name > cci_ccache_first_msg_id &&
+ in_request_name < cci_ccache_last_msg_id) {
+ err = ccErrInvalidCCache;
+
+ } else if (in_request_name > cci_ccache_iterator_first_msg_id &&
+ in_request_name < cci_ccache_iterator_last_msg_id) {
+ err = ccErrInvalidCCacheIterator;
+
+ } else if (in_request_name > cci_credentials_iterator_first_msg_id &&
+ in_request_name < cci_credentials_iterator_last_msg_id) {
+ err = ccErrInvalidCredentialsIterator;
+
+ } else {
+ err = ccErrBadInternalMessage;
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_message_new_request_header (cci_stream_t *out_request,
+ enum cci_msg_id_t in_request_name,
+ cci_identifier_t in_identifier)
+{
+ cc_int32 err = ccNoError;
+ cci_stream_t request = NULL;
+
+ if (!out_request) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_new (&request);
+ }
+
+ if (!err) {
+ err = cci_stream_write_uint32 (request, in_request_name);
+ }
+
+ if (!err) {
+ err = cci_identifier_write (in_identifier, request);
+ }
+
+ if (!err) {
+ *out_request = request;
+ request = NULL;
+ }
+
+ cci_stream_release (request);
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_message_read_request_header (cci_stream_t in_request,
+ enum cci_msg_id_t *out_request_name,
+ cci_identifier_t *out_identifier)
+{
+ cc_int32 err = ccNoError;
+ cc_uint32 request_name;
+ cci_identifier_t identifier = NULL;
+
+ if (!in_request ) { err = cci_check_error (ccErrBadParam); }
+ if (!out_request_name) { err = cci_check_error (ccErrBadParam); }
+ if (!out_identifier ) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_read_uint32 (in_request, &request_name);
+ }
+
+ if (!err) {
+ err = cci_identifier_read (&identifier, in_request);
+ }
+
+ if (!err) {
+ *out_request_name = request_name;
+ *out_identifier = identifier;
+ identifier = NULL; /* take ownership */
+ }
+
+ cci_identifier_release (identifier);
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_message_new_reply_header (cci_stream_t *out_reply,
+ cc_int32 in_error)
+{
+ cc_int32 err = ccNoError;
+ cci_stream_t reply = NULL;
+
+ if (!out_reply) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_new (&reply);
+ }
+
+ if (!err) {
+ err = cci_stream_write_int32 (reply, in_error);
+ }
+
+ if (!err) {
+ *out_reply = reply;
+ reply = NULL;
+ }
+
+ cci_stream_release (reply);
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_message_read_reply_header (cci_stream_t in_reply,
+ cc_int32 *out_reply_error)
+{
+ cc_int32 err = ccNoError;
+ cc_int32 reply_err = 0;
+
+ if (!in_reply ) { err = cci_check_error (ccErrBadParam); }
+ if (!out_reply_error) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_read_int32 (in_reply, &reply_err);
+ }
+
+ if (!err) {
+ *out_reply_error = reply_err;
+ }
+
+ return cci_check_error (err);
+}
diff --git a/src/ccapi/common/cci_message.h b/src/ccapi/common/cci_message.h
new file mode 100644
index 0000000000..7cab2dc766
--- /dev/null
+++ b/src/ccapi/common/cci_message.h
@@ -0,0 +1,48 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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 CCI_MESSAGE_H
+#define CCI_MESSAGE_H
+
+#include "cci_types.h"
+
+cc_int32 cci_message_invalid_object_err (enum cci_msg_id_t in_request_name);
+
+cc_int32 cci_message_new_request_header (cci_stream_t *out_request,
+ enum cci_msg_id_t in_request_name,
+ cci_identifier_t in_identifier);
+
+cc_int32 cci_message_read_request_header (cci_stream_t in_request,
+ enum cci_msg_id_t *out_request_name,
+ cci_identifier_t *out_identifier);
+
+cc_int32 cci_message_new_reply_header (cci_stream_t *out_reply,
+ cc_int32 in_error);
+
+cc_int32 cci_message_read_reply_header (cci_stream_t in_reply,
+ cc_int32 *out_reply_error);
+
+#endif /* CCI_MESSAGE_H */
diff --git a/src/ccapi/common/cci_os_debugging.h b/src/ccapi/common/cci_os_debugging.h
new file mode 100644
index 0000000000..b08ee002e0
--- /dev/null
+++ b/src/ccapi/common/cci_os_debugging.h
@@ -0,0 +1,35 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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 CCI_OS_DEBUGGING_H
+#define CCI_OS_DEBUGGING_H
+
+#include "cci_types.h"
+#include <stdarg.h>
+
+inline void cci_os_debug_vprintf (const char *in_format, va_list in_args);
+
+#endif /* CCI_OS_DEBUGGING_H */
diff --git a/src/ccapi/common/cci_os_identifier.h b/src/ccapi/common/cci_os_identifier.h
new file mode 100644
index 0000000000..b607720958
--- /dev/null
+++ b/src/ccapi/common/cci_os_identifier.h
@@ -0,0 +1,34 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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 CCI_OS_IDENTIFIER_H
+#define CCI_OS_IDENTIFIER_H
+
+#include "cci_types.h"
+
+inline cc_int32 cci_os_identifier_new_uuid (cci_uuid_string_t *out_uuid_string);
+
+#endif /* CCI_OS_IDENTIFIER_H */
diff --git a/src/ccapi/common/cci_stream.c b/src/ccapi/common/cci_stream.c
new file mode 100644
index 0000000000..cac5431e79
--- /dev/null
+++ b/src/ccapi/common/cci_stream.c
@@ -0,0 +1,490 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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.
+ */
+
+#include "cci_common.h"
+
+#if TARGET_OS_MAC
+#include <architecture/byte_order.h>
+
+#if !defined(htonll)
+#define htonll(x) OSSwapHostToBigInt64(x)
+#endif
+
+#if !defined(ntohll)
+#define ntohll(x) OSSwapBigToHostInt64(x)
+#endif
+
+#endif /* TARGET_OS_MAC */
+
+struct cci_stream_d {
+ char *data;
+ cc_uint64 size;
+ cc_uint64 max_size;
+};
+
+const struct cci_stream_d cci_stream_initializer = { NULL, 0, 0 };
+
+#define CC_STREAM_SIZE_INCREMENT 128
+
+/* ------------------------------------------------------------------------ */
+
+static cc_uint32 cci_stream_reallocate (cci_stream_t io_stream,
+ cc_uint64 in_new_size)
+{
+ cc_int32 err = ccNoError;
+ cc_uint64 new_max_size = 0;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ cc_uint64 old_max_size = io_stream->max_size;
+ new_max_size = io_stream->max_size;
+
+ if (in_new_size > old_max_size) {
+ /* Expand the stream */
+ while (in_new_size > new_max_size) {
+ new_max_size += CC_STREAM_SIZE_INCREMENT;
+ }
+
+
+ } else if ((in_new_size + CC_STREAM_SIZE_INCREMENT) < old_max_size) {
+ /* Shrink the array, but never drop below CC_LIST_COUNT_INCREMENT */
+ while ((in_new_size + CC_STREAM_SIZE_INCREMENT) < new_max_size &&
+ (new_max_size > CC_STREAM_SIZE_INCREMENT)) {
+ new_max_size -= CC_STREAM_SIZE_INCREMENT;
+ }
+ }
+ }
+
+ if (!err && new_max_size != io_stream->max_size) {
+ char *data = io_stream->data;
+
+ if (!data) {
+ data = malloc (new_max_size * sizeof (*data));
+ } else {
+ data = realloc (data, new_max_size * sizeof (*data));
+ }
+
+ if (data) {
+ io_stream->data = data;
+ io_stream->max_size = new_max_size;
+ } else {
+ err = cci_check_error (ccErrNoMem);
+ }
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_int32 cci_stream_new (cci_stream_t *out_stream)
+{
+ cc_int32 err = ccNoError;
+ cci_stream_t stream = NULL;
+
+ if (!out_stream) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ stream = malloc (sizeof (*stream));
+ if (stream) {
+ *stream = cci_stream_initializer;
+ } else {
+ err = cci_check_error (ccErrNoMem);
+ }
+ }
+
+ if (!err) {
+ *out_stream = stream;
+ stream = NULL;
+ }
+
+ cci_stream_release (stream);
+
+ return cci_check_error (err);
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_release (cci_stream_t io_stream)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_stream) { err = ccErrBadParam; }
+
+ if (!err) {
+ free (io_stream->data);
+ free (io_stream);
+ }
+
+ return err;
+}
+
+/* ------------------------------------------------------------------------ */
+
+inline cc_uint64 cci_stream_size (cci_stream_t in_stream)
+{
+ return in_stream ? in_stream->size : 0;
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+inline const char *cci_stream_data (cci_stream_t in_stream)
+{
+ return in_stream ? in_stream->data : NULL;
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_read (cci_stream_t io_stream,
+ void *io_data,
+ cc_uint64 in_size)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+ if (!io_data ) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ if (in_size > io_stream->size) {
+ err = cci_check_error (ccErrBadInternalMessage);
+ }
+ }
+
+ if (!err) {
+ memcpy (io_data, io_stream->data, in_size);
+ memmove (io_stream->data, &io_stream->data[in_size],
+ io_stream->size - in_size);
+
+ err = cci_stream_reallocate (io_stream, io_stream->size - in_size);
+
+ if (!err) {
+ io_stream->size -= in_size;
+ }
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_write (cci_stream_t io_stream,
+ const void *in_data,
+ cc_uint64 in_size)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+ if (!in_data ) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ /* Security check: Do not let the caller overflow the length */
+ if (in_size > (UINT64_MAX - io_stream->size)) {
+ err = cci_check_error (ccErrBadParam);
+ }
+ }
+
+ if (!err) {
+ err = cci_stream_reallocate (io_stream, io_stream->size + in_size);
+ }
+
+ if (!err) {
+ memcpy (&io_stream->data[io_stream->size], in_data, in_size);
+ io_stream->size += in_size;
+ }
+
+ return cci_check_error (err);
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_read_string (cci_stream_t io_stream,
+ char **out_string)
+{
+ cc_int32 err = ccNoError;
+ cc_uint32 length = 0;
+ char *string = NULL;
+
+ if (!io_stream ) { err = cci_check_error (ccErrBadParam); }
+ if (!out_string) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_read_uint32 (io_stream, &length);
+ }
+
+ if (!err) {
+ string = malloc (length);
+ if (!string) { err = cci_check_error (ccErrNoMem); }
+ }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, string, length);
+ }
+
+ if (!err) {
+ *out_string = string;
+ string = NULL;
+ }
+
+ free (string);
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_write_string (cci_stream_t io_stream,
+ const char *in_string)
+{
+ cc_int32 err = ccNoError;
+ cc_uint32 length = 0;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+ if (!in_string) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ length = strlen (in_string) + 1;
+
+ err = cci_stream_write_uint32 (io_stream, length);
+ }
+
+ if (!err) {
+ err = cci_stream_write (io_stream, in_string, length);
+ }
+
+ return cci_check_error (err);
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_read_int32 (cci_stream_t io_stream,
+ cc_int32 *out_int32)
+{
+ cc_int32 err = ccNoError;
+ cc_int32 int32 = 0;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+ if (!out_int32) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, &int32, sizeof (int32));
+ }
+
+ if (!err) {
+ *out_int32 = ntohl (int32);
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_write_int32 (cci_stream_t io_stream,
+ cc_int32 in_int32)
+{
+ cc_int32 err = ccNoError;
+ cc_int32 int32 = htonl (in_int32);
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_write (io_stream, &int32, sizeof (int32));
+ }
+
+ return cci_check_error (err);
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_read_uint32 (cci_stream_t io_stream,
+ cc_uint32 *out_uint32)
+{
+ cc_int32 err = ccNoError;
+ cc_uint32 uint32 = 0;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+ if (!out_uint32) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, &uint32, sizeof (uint32));
+ }
+
+ if (!err) {
+ *out_uint32 = ntohl (uint32);
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_write_uint32 (cci_stream_t io_stream,
+ cc_uint32 in_uint32)
+{
+ cc_int32 err = ccNoError;
+ cc_int32 uint32 = htonl (in_uint32);
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_write (io_stream, &uint32, sizeof (uint32));
+ }
+
+ return cci_check_error (err);
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_read_int64 (cci_stream_t io_stream,
+ cc_int64 *out_int64)
+{
+ cc_int32 err = ccNoError;
+ cc_uint64 int64 = 0;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+ if (!out_int64) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, &int64, sizeof (int64));
+ }
+
+ if (!err) {
+ *out_int64 = ntohll (int64);
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_write_int64 (cci_stream_t io_stream,
+ cc_int64 in_int64)
+{
+ cc_int32 err = ccNoError;
+ cc_int64 int64 = htonll (in_int64);
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_write (io_stream, &int64, sizeof (int64));
+ }
+
+ return cci_check_error (err);
+}
+
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_read_uint64 (cci_stream_t io_stream,
+ cc_uint64 *out_uint64)
+{
+ cc_int32 err = ccNoError;
+ cc_uint64 uint64 = 0;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+ if (!out_uint64) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_read (io_stream, &uint64, sizeof (uint64));
+ }
+
+ if (!err) {
+ *out_uint64 = ntohll (uint64);
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_write_uint64 (cci_stream_t io_stream,
+ cc_uint64 in_uint64)
+{
+ cc_int32 err = ccNoError;
+ cc_int64 uint64 = htonll (in_uint64);
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_write (io_stream, &uint64, sizeof (uint64));
+ }
+
+ return cci_check_error (err);
+}
+
+#pragma mark -
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_read_time (cci_stream_t io_stream,
+ cc_time_t *out_time)
+{
+ cc_int32 err = ccNoError;
+ cc_int64 t = 0;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+ if (!out_time ) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_read_int64 (io_stream, &t);
+ }
+
+ if (!err) {
+ *out_time = t;
+ }
+
+ return cci_check_error (err);
+}
+
+/* ------------------------------------------------------------------------ */
+
+cc_uint32 cci_stream_write_time (cci_stream_t io_stream,
+ cc_time_t in_time)
+{
+ cc_int32 err = ccNoError;
+
+ if (!io_stream) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ err = cci_stream_write_int64 (io_stream, in_time);
+ }
+
+ return cci_check_error (err);
+}
diff --git a/src/ccapi/common/cci_stream.h b/src/ccapi/common/cci_stream.h
new file mode 100644
index 0000000000..9c37361cda
--- /dev/null
+++ b/src/ccapi/common/cci_stream.h
@@ -0,0 +1,77 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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 CCI_STREAM_H
+#define CCI_STREAM_H
+
+#include "cci_types.h"
+
+cc_int32 cci_stream_new (cci_stream_t *out_stream);
+
+cc_uint32 cci_stream_release (cci_stream_t io_stream);
+
+inline cc_uint64 cci_stream_size (cci_stream_t in_stream);
+
+inline const char *cci_stream_data (cci_stream_t in_stream);
+
+cc_uint32 cci_stream_read (cci_stream_t in_stream,
+ void *io_data,
+ cc_uint64 in_size);
+cc_uint32 cci_stream_write (cci_stream_t in_stream,
+ const void *in_data,
+ cc_uint64 in_size);
+
+cc_uint32 cci_stream_read_string (cci_stream_t io_stream,
+ char **out_string);
+cc_uint32 cci_stream_write_string (cci_stream_t io_stream,
+ const char *in_string);
+
+cc_uint32 cci_stream_read_int32 (cci_stream_t io_stream,
+ cc_int32 *out_int32);
+cc_uint32 cci_stream_write_int32 (cci_stream_t io_stream,
+ cc_int32 in_int32);
+
+cc_uint32 cci_stream_read_uint32 (cci_stream_t io_stream,
+ cc_uint32 *out_uint32);
+cc_uint32 cci_stream_write_uint32 (cci_stream_t io_stream,
+ cc_uint32 in_uint32);
+
+cc_uint32 cci_stream_read_int64 (cci_stream_t io_stream,
+ cc_int64 *out_int64);
+cc_uint32 cci_stream_write_int64 (cci_stream_t io_stream,
+ cc_int64 in_int64);
+
+cc_uint32 cci_stream_read_uint64 (cci_stream_t io_stream,
+ cc_uint64 *out_uint64);
+cc_uint32 cci_stream_write_uint64 (cci_stream_t io_stream,
+ cc_uint64 in_uint64);
+
+cc_uint32 cci_stream_read_time (cci_stream_t io_stream,
+ cc_time_t *out_time);
+cc_uint32 cci_stream_write_time (cci_stream_t io_stream,
+ cc_time_t in_time);
+
+#endif /* CCI_STREAM_H */
diff --git a/src/ccapi/common/cci_types.h b/src/ccapi/common/cci_types.h
new file mode 100644
index 0000000000..8ace67ce7b
--- /dev/null
+++ b/src/ccapi/common/cci_types.h
@@ -0,0 +1,105 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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 CCI_TYPES_H
+#define CCI_TYPES_H
+
+#include <CredentialsCache.h>
+
+struct cci_stream_d;
+typedef struct cci_stream_d *cci_stream_t;
+
+typedef char *cci_uuid_string_t;
+
+struct cci_identifier_d;
+typedef struct cci_identifier_d *cci_identifier_t;
+
+enum cci_msg_id_t {
+ /* cc_context_t */
+ cci_context_first_msg_id,
+
+ cci_context_release_msg_id,
+ cci_context_sync_msg_id,
+ cci_context_get_change_time_msg_id,
+ cci_context_wait_for_change_msg_id,
+ cci_context_get_default_ccache_name_msg_id,
+ cci_context_open_ccache_msg_id,
+ cci_context_open_default_ccache_msg_id,
+ cci_context_create_ccache_msg_id,
+ cci_context_create_default_ccache_msg_id,
+ cci_context_create_new_ccache_msg_id,
+ cci_context_new_ccache_iterator_msg_id,
+ cci_context_lock_msg_id,
+ cci_context_unlock_msg_id,
+
+ cci_context_last_msg_id,
+
+ /* cc_ccache_t */
+ cci_ccache_first_msg_id,
+
+ cci_ccache_destroy_msg_id,
+ cci_ccache_set_default_msg_id,
+ cci_ccache_get_credentials_version_msg_id,
+ cci_ccache_get_name_msg_id,
+ cci_ccache_get_principal_msg_id,
+ cci_ccache_set_principal_msg_id,
+ cci_ccache_store_credentials_msg_id,
+ cci_ccache_remove_credentials_msg_id,
+ cci_ccache_new_credentials_iterator_msg_id,
+ cci_ccache_move_msg_id,
+ cci_ccache_lock_msg_id,
+ cci_ccache_unlock_msg_id,
+ cci_ccache_get_last_default_time_msg_id,
+ cci_ccache_get_change_time_msg_id,
+ cci_ccache_wait_for_change_msg_id,
+ cci_ccache_get_kdc_time_offset_msg_id,
+ cci_ccache_set_kdc_time_offset_msg_id,
+ cci_ccache_clear_kdc_time_offset_msg_id,
+
+ cci_ccache_last_msg_id,
+
+ /* cc_ccache_iterator_t */
+ cci_ccache_iterator_first_msg_id,
+
+ cci_ccache_iterator_release_msg_id,
+ cci_ccache_iterator_next_msg_id,
+ cci_ccache_iterator_clone_msg_id,
+
+ cci_ccache_iterator_last_msg_id,
+
+ /* cc_credentials_iterator_t */
+ cci_credentials_iterator_first_msg_id,
+
+ cci_credentials_iterator_release_msg_id,
+ cci_credentials_iterator_next_msg_id,
+ cci_credentials_iterator_clone_msg_id,
+
+ cci_credentials_iterator_last_msg_id,
+
+ cci_max_msg_id /* must be last! */
+};
+
+#endif /* CCI_TYPES_H */
diff --git a/src/ccapi/common/mac/cci_mig.defs b/src/ccapi/common/mac/cci_mig.defs
new file mode 100644
index 0000000000..3a573681a9
--- /dev/null
+++ b/src/ccapi/common/mac/cci_mig.defs
@@ -0,0 +1,54 @@
+/* $Copyright:
+ *
+ * Copyright 2004-2006 by the 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 MIT 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.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Individual source code files are copyright MIT, Cygnus Support,
+ * OpenVision, Oracle, Sun Soft, FundsXpress, and others.
+ *
+ * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira,
+ * and Zephyr are trademarks of the Massachusetts Institute of Technology
+ * (MIT). No commercial use of these trademarks may be made without prior
+ * written permission of MIT.
+ *
+ * "Commercial use" means use of a name in a product or other for-profit
+ * manner. It does NOT prevent a commercial firm from referring to the MIT
+ * trademarks in order to convey information (although in doing so,
+ * recognition of their trademark status should be given).
+ * $
+ */
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+import "cci_mig_types.h";
+
+/* Note the 1024 must be the same as kCCAPIMaxILMsgSize */
+type cci_mipc_inl_request_t = array [ * : 1024 ] of char;
+type cci_mipc_ool_request_t = array [] of char;
+
+type cci_mipc_inl_reply_t = array [ * : 1024 ] of char;
+type cci_mipc_ool_reply_t = array [] of char;
diff --git a/src/ccapi/common/mac/cci_mig_reply.defs b/src/ccapi/common/mac/cci_mig_reply.defs
new file mode 100644
index 0000000000..f500ef9ac5
--- /dev/null
+++ b/src/ccapi/common/mac/cci_mig_reply.defs
@@ -0,0 +1,58 @@
+/* $Copyright:
+ *
+ * Copyright 2004-2006 by the 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 MIT 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.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Individual source code files are copyright MIT, Cygnus Support,
+ * OpenVision, Oracle, Sun Soft, FundsXpress, and others.
+ *
+ * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira,
+ * and Zephyr are trademarks of the Massachusetts Institute of Technology
+ * (MIT). No commercial use of these trademarks may be made without prior
+ * written permission of MIT.
+ *
+ * "Commercial use" means use of a name in a product or other for-profit
+ * manner. It does NOT prevent a commercial firm from referring to the MIT
+ * trademarks in order to convey information (although in doing so,
+ * recognition of their trademark status should be given).
+ * $
+ */
+
+#include "cci_mig.defs"
+
+subsystem cci 200;
+
+serverprefix cci_mipc_;
+userprefix ccs_mipc_;
+
+/* ",dealloc" means that the vm_read() memory will be moved to
+ * the other process rather than copied. This is necessary on the
+ * client side because we can't know when server has copied our
+ * buffers so we can't vm_deallocate() them ourselves. */
+
+simpleroutine reply (in_reply_port : mach_port_move_send_once_t;
+ in_inl_reply : cci_mipc_inl_reply_t;
+ in_ool_reply : cci_mipc_ool_reply_t, dealloc);
diff --git a/src/ccapi/common/mac/cci_mig_request.defs b/src/ccapi/common/mac/cci_mig_request.defs
new file mode 100644
index 0000000000..45887e1a1a
--- /dev/null
+++ b/src/ccapi/common/mac/cci_mig_request.defs
@@ -0,0 +1,62 @@
+/* $Copyright:
+ *
+ * Copyright 2004-2006 by the 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 MIT 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.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Individual source code files are copyright MIT, Cygnus Support,
+ * OpenVision, Oracle, Sun Soft, FundsXpress, and others.
+ *
+ * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira,
+ * and Zephyr are trademarks of the Massachusetts Institute of Technology
+ * (MIT). No commercial use of these trademarks may be made without prior
+ * written permission of MIT.
+ *
+ * "Commercial use" means use of a name in a product or other for-profit
+ * manner. It does NOT prevent a commercial firm from referring to the MIT
+ * trademarks in order to convey information (although in doing so,
+ * recognition of their trademark status should be given).
+ * $
+ */
+
+#include "cci_mig.defs"
+
+subsystem ccs 100;
+
+serverprefix ccs_mipc_;
+userprefix cci_mipc_;
+
+routine create_client_connection (in_server_port : mach_port_t;
+ out out_connection_port : mach_port_t = MACH_MSG_TYPE_MAKE_SEND);
+
+/* ",dealloc" means that the vm_read() memory will be moved to
+ * the other process rather than copied. This is necessary on the
+ * server side because we can't know when client has copied our
+ * buffers so we can't vm_deallocate() them ourselves. */
+
+simpleroutine request (in_connection_port : mach_port_t;
+ in_reply_port : mach_port_make_send_once_t;
+ in_inl_request : cci_mipc_inl_request_t;
+ in_ool_request : cci_mipc_ool_request_t, dealloc);
diff --git a/src/ccapi/common/mac/cci_mig_types.h b/src/ccapi/common/mac/cci_mig_types.h
new file mode 100644
index 0000000000..d82d5ac59d
--- /dev/null
+++ b/src/ccapi/common/mac/cci_mig_types.h
@@ -0,0 +1,56 @@
+/* $Copyright:
+*
+* Copyright 2004-2006 by the 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 MIT 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.
+*
+* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+*
+* Individual source code files are copyright MIT, Cygnus Support,
+* OpenVision, Oracle, Sun Soft, FundsXpress, and others.
+*
+* Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira,
+* and Zephyr are trademarks of the Massachusetts Institute of Technology
+* (MIT). No commercial use of these trademarks may be made without prior
+* written permission of MIT.
+*
+* "Commercial use" means use of a name in a product or other for-profit
+* manner. It does NOT prevent a commercial firm from referring to the MIT
+* trademarks in order to convey information (although in doing so,
+* recognition of their trademark status should be given).
+* $
+*/
+
+#ifndef CCI_MIG_TYPES_H
+#define CCI_MIG_TYPES_H
+
+#include "cci_common.h"
+
+#define kCCAPIMaxILMsgSize 1024
+
+typedef const char cci_mipc_inl_request_t[kCCAPIMaxILMsgSize];
+typedef const char *cci_mipc_ool_request_t;
+typedef char cci_mipc_inl_reply_t[kCCAPIMaxILMsgSize];
+typedef char *cci_mipc_ool_reply_t;
+
+#endif /* CCI_MIG_TYPES_H */
diff --git a/src/ccapi/common/mac/cci_os_debugging.c b/src/ccapi/common/mac/cci_os_debugging.c
new file mode 100644
index 0000000000..f64b83916b
--- /dev/null
+++ b/src/ccapi/common/mac/cci_os_debugging.c
@@ -0,0 +1,36 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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.
+ */
+
+
+#include "cci_os_debugging.h"
+#include <Kerberos/KerberosDebug.h>
+
+/* ------------------------------------------------------------------------ */
+
+inline void cci_os_debug_vprintf (const char *in_format, va_list in_args)
+{
+ dvprintf (in_format, in_args);
+}
diff --git a/src/ccapi/common/mac/cci_os_identifier.c b/src/ccapi/common/mac/cci_os_identifier.c
new file mode 100644
index 0000000000..c01e727bb1
--- /dev/null
+++ b/src/ccapi/common/mac/cci_os_identifier.c
@@ -0,0 +1,80 @@
+/*
+ * $Header$
+ *
+ * Copyright 2006 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.
+ */
+
+#include "cci_common.h"
+#include "cci_os_identifier.h"
+
+#include <CoreFoundation/CoreFoundation.h>
+
+/* ------------------------------------------------------------------------ */
+
+inline cc_int32 cci_os_identifier_new_uuid (cci_uuid_string_t *out_uuid_string)
+{
+ cc_int32 err = ccNoError;
+ cci_uuid_string_t uuid_string = NULL;
+ CFUUIDRef uuid = NULL;
+ CFStringRef uuid_stringref = NULL;
+ CFStringEncoding encoding = kCFStringEncodingUTF8;
+ CFIndex length = 0;
+
+ if (!out_uuid_string) { err = cci_check_error (ccErrBadParam); }
+
+ if (!err) {
+ uuid = CFUUIDCreate (kCFAllocatorDefault);
+ if (!uuid) { err = cci_check_error (ccErrNoMem); }
+ }
+
+ if (!err) {
+ uuid_stringref = CFUUIDCreateString (kCFAllocatorDefault, uuid);
+ if (!uuid_stringref) { err = cci_check_error (ccErrNoMem); }
+ }
+
+ if (!err) {
+ length = CFStringGetMaximumSizeForEncoding (CFStringGetLength (uuid_stringref),
+ encoding) + 1;
+
+ uuid_string = malloc (length);
+ if (!uuid_string) { err = cci_check_error (ccErrNoMem); }
+ }
+
+ if (!err) {
+ if (!CFStringGetCString (uuid_stringref, uuid_string, length, encoding)) {
+ err = cci_check_error (ccErrNoMem);
+ }
+ }
+
+ if (!err) {
+ *out_uuid_string = uuid_string;
+ uuid_string = NULL; /* take ownership */
+ }
+
+ if (uuid_string ) { free (uuid_string); }
+ if (uuid_stringref) { CFRelease (uuid_stringref); }
+ if (uuid ) { CFRelease (uuid); }
+
+ return cci_check_error (err);
+}
+