summaryrefslogtreecommitdiffstats
path: root/src/lib/ccapi/unit-test
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/ccapi/unit-test')
-rw-r--r--src/lib/ccapi/unit-test/NTMakefile53
-rw-r--r--src/lib/ccapi/unit-test/t_ccache.c115
-rw-r--r--src/lib/ccapi/unit-test/t_context.c115
-rw-r--r--src/lib/ccapi/unit-test/t_lists.c100
-rw-r--r--src/lib/ccapi/unit-test/t_msg.c88
-rw-r--r--src/lib/ccapi/unit-test/t_server.c185
6 files changed, 0 insertions, 656 deletions
diff --git a/src/lib/ccapi/unit-test/NTMakefile b/src/lib/ccapi/unit-test/NTMakefile
deleted file mode 100644
index 73f53f2e4..000000000
--- a/src/lib/ccapi/unit-test/NTMakefile
+++ /dev/null
@@ -1,53 +0,0 @@
-!include <win32.mak>
-
-CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsmt)
-
-WINLIBS = ws2_32.lib rpcrt4.lib $(guilibsdll)
-
-T_CCACHE = t_ccache.exe
-
-T_CONTEXT = t_context.exe
-
-T_LISTS = t_lists.exe
-
-T_MSG = t_msg.exe
-
-T_SERVER = t_server.exe
-
-T_CCAPI = t_ccapi.exe
-
-all: $(T_CCAPI) $(T_CCACHE) $(T_CONTEXT) $(T_LISTS) $(T_MSG) $(T_SERVER)
-
-ntccrpc_c.c ntccrpc_s.c ntccrpc.h: ntccrpc.idl ntccrpc.acf
- midl ntccrpc.idl /acf ntccrpc.acf
-
-CC_CLIENT_LIB = ..\client\cc_client.lib
-
-CC_COMMON_LIB = ..\common\cc_common.lib
-
-CC_SERVER_LIB = ..\server\cc_server.lib
-
-CC_API_LIB = ..\windows\krbcc32.lib
-
-$(T_CCACHE): t_ccache.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB)
- $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS)
-
-$(T_CONTEXT): t_context.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB)
- $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS)
-
-$(T_LISTS): t_lists.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB)
- $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS)
-
-$(T_MSG): t_msg.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB)
- $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS)
-
-$(T_SERVER): t_server.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB)
- $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS)
-
-$(T_CCAPI): t_ccapi.obj $(CC_API_LIB)
- $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS)
-
-clean:
- del *.exe *.dll *.lib *.exp *.obj ntccrpc_c.c ntccrpc_s.c ntccrpc.h
-
-
diff --git a/src/lib/ccapi/unit-test/t_ccache.c b/src/lib/ccapi/unit-test/t_ccache.c
deleted file mode 100644
index 175764e79..000000000
--- a/src/lib/ccapi/unit-test/t_ccache.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/* $Copyright:
- *
- * Copyright 2004 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include "CredentialsCache.h"
-#include "datastore.h"
-
-int main() {
- cc_server_credentials_t *cred1, *cred2, *cred3;
- cc_credentials_iterate_t* iterator;
- cc_server_credentials_t* stored_cred;
- cc_credentials_list_node_t *node;
- cc_server_ccache_t *c1, *c2;
- char p1[] = "Spike";
- char p2[] = "Jeff";
- int i;
- cc_int32 code;
-
- code = ccs_ccache_new("The first", p1, cc_credentials_v4_v5, &c1);
- code = ccs_ccache_new("The 2nd", p2, cc_credentials_v4_v5, &c2);
-
- cred1 = (cc_server_credentials_t*)malloc(sizeof(cc_server_credentials_t));
- memset(cred1,0,sizeof(cc_server_credentials_t));
- cred2 = (cc_server_credentials_t*)malloc(sizeof(cc_server_credentials_t));
- memset(cred2,0,sizeof(cc_server_credentials_t));
- cred3 = (cc_server_credentials_t*)malloc(sizeof(cc_server_credentials_t));
- memset(cred3,0,sizeof(cc_server_credentials_t));
-
- cred1->creds.version = cred2->creds.version = cc_credentials_v4;
- cred3->creds.version = cc_credentials_v5;
-
- cred1->creds.credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t));
- memset(cred1->creds.credentials.credentials_v4,0,sizeof(cc_credentials_v4_t));
- cred2->creds.credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t));
- memset(cred2->creds.credentials.credentials_v4,0,sizeof(cc_credentials_v4_t));
- cred3->creds.credentials.credentials_v5 = (cc_credentials_v5_t*)malloc(sizeof(cc_credentials_v5_t));
- memset(cred3->creds.credentials.credentials_v5,0,sizeof(cc_credentials_v5_t));
-
- strncpy(cred1->creds.credentials.credentials_v4->principal, p1, strlen(p1));
- strncpy(cred2->creds.credentials.credentials_v4->principal, p1, strlen(p1));
- cred3->creds.credentials.credentials_v5->client = p1;
-
- code = ccs_ccache_store_creds(c1, &cred1->creds);
- printf("(c1, cred1) -> %d\n",code);
-
- code = ccs_ccache_store_creds(c1, &cred2->creds);
- printf("(c1, cred2) -> %d\n",code);
-
- code = ccs_ccache_store_creds(c2, &cred3->creds);
- printf("(c2, cred3) -> %d\n",code);
-
- code = ccs_ccache_store_creds(c1, &cred3->creds);
- printf("(c1, cred3) -> %d\n",code);
-
- i = 0;
- code = ccs_ccache_move(c1, c2);
- code = ccs_ccache_destroy(c1);
- code = ccs_ccache_new_iterator(c2, &iterator);
- while (ccs_credentials_iterate_has_next(iterator)) {
- i++;
- code = ccs_credentials_iterate_next(iterator, &node);
- stored_cred = (cc_server_credentials_t *)node->data;
- printf("%d %d %s\n", stored_cred->is_default, stored_cred->creds.version, stored_cred->creds.credentials.credentials_v4->principal);
-
- if (i == 1) {
- code = ccs_ccache_rem_creds(c2,&cred2->creds);
- printf("(c2 rem cred2) -> %d\n",code);
- }
- }
- return 0;
-}
-
diff --git a/src/lib/ccapi/unit-test/t_context.c b/src/lib/ccapi/unit-test/t_context.c
deleted file mode 100644
index d76ff78d9..000000000
--- a/src/lib/ccapi/unit-test/t_context.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/* $Copyright:
- *
- * Copyright 2004 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 <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-
-#include "CredentialsCache.h"
-#include "datastore.h"
-
-
-/*testing code*/
-int main() {
- int uid = 1;
- int session = 1;
- cc_server_ccache_t *ccache;
- cc_credentials_union* creds;
- cc_ccache_iterate_t* ccache_iterator;
- cc_ccache_list_node_t* ccache_node;
- cc_credentials_iterate_t* creds_iterator;
- cc_credentials_list_node_t* creds_node;
- cc_server_credentials_t* server_creds;
- cc_auth_info_t* auth_info = NULL;
- cc_session_info_t* session_info = NULL;
- cc_server_context_t* ctx = NULL;
- char *name;
- int i;
- cc_int32 code;
-
- code = ccs_context_new(5, auth_info, session_info, &ctx);
- code = ccs_context_create_default_ccache(ctx, cc_credentials_v4, "Spike", &ccache);
- code = ccs_context_get_default_ccache_name(ctx, &name);
- code = ccs_context_open_ccache(ctx, name, &ccache);
-
- for (i = 0; i < 5; i++) {
- creds = (cc_credentials_union*)malloc(sizeof(cc_credentials_union));
- creds->version = cc_credentials_v4;
- creds->credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t));
- strcpy(creds->credentials.credentials_v4->principal, "Spike");
-
- code = ccs_ccache_store_creds(ccache, creds);
- }
-
- code = ccs_context_create_ccache(ctx, "ccache 2", cc_credentials_v4_v5, "Jeff", &ccache);
- code = ccs_context_open_ccache(ctx, "ccache 2", &ccache);
-
- for (i = 0; i < 5; i++) {
- creds = (cc_credentials_union*)malloc(sizeof(cc_credentials_union));
- creds->version = cc_credentials_v5;
- creds->credentials.credentials_v5 = (cc_credentials_v5_t*)malloc(sizeof(cc_credentials_v5_t));
- strcpy(creds->credentials.credentials_v5->principal, "Jeff");
-
- ccs_ccache_store_creds(ccache, creds);
- }
-
- code = ccs_context_ccache_iterator(ctx, &ccache_iterator);
- while (ccs_ccache_iterate_has_next(ccache_iterator)) {
- code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node);
- ccache = (cc_server_ccache_t *)ccache_node->data;
- printf("%x for %s %s default = %d v %d\n",
- ccache, ccache->principal_v4, ccache->principal_v5,
- ccache->is_default, ccache->versions);
-
- code = ccs_ccache_new_iterator(ccache, &creds_iterator);
- while (ccs_credentials_iterate_has_next(creds_iterator)) {
- code = ccs_credentials_iterate_next(creds_iterator, &creds_node);
- server_creds = (cc_server_credentials_t *)creds_node->data;
- printf("\t%s %d\n",
- server_creds->creds.credentials.credentials_v4->principal,
- creds->version);
- }
- }
- return 0;
-}
diff --git a/src/lib/ccapi/unit-test/t_lists.c b/src/lib/ccapi/unit-test/t_lists.c
deleted file mode 100644
index 4c8450bb7..000000000
--- a/src/lib/ccapi/unit-test/t_lists.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/* $Copyright:
- *
- * Copyright 2004 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 <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-
-#include "CredentialsCache.h"
-#include "datastore.h"
-
-
-int main() {
- cc_generic_list_head_t* head;
- cc_generic_list_head_t* copy;// = cc_generic_list_copy(head);
- cc_generic_list_node_t *head_node,*tail,*middle, *node;
- cc_generic_iterate_t* iterate;
- int x1 = 1;
- int x2 = 2;
- int x3 = 3;
- int x4 = 4;
- int x5 = 5;
- int x6 = 6;
- cc_int32 code;
-
- code = cci_generic_list_new(&head);
- code = cci_generic_list_append(head,&x4,sizeof(x4),NULL);
- code = cci_generic_list_append(head,&x5,sizeof(x5),NULL);
- code = cci_generic_list_append(head,&x6,sizeof(x6),&tail);
-
- code = cci_generic_list_prepend(head,&x3,sizeof(x3),&middle);
- code = cci_generic_list_prepend(head,&x2,sizeof(x2),NULL);
- code = cci_generic_list_prepend(head,&x1,sizeof(x1), &head_node);
-
- code = cci_generic_list_iterator(head, &iterate);
- while (cci_generic_iterate_has_next(iterate)) {
- code = cci_generic_iterate_next(iterate, &node);
- printf("%d\n",*((int *)(node->data)));
- }
- printf("----------\n");
- cci_generic_list_remove_element(head,head_node);
- cci_generic_list_remove_element(head,middle);
- cci_generic_list_remove_element(head,tail);
-
- code = cci_generic_list_iterator(head, &iterate);
- while (cci_generic_iterate_has_next(iterate)) {
- code = cci_generic_iterate_next(iterate, &node);
- printf("%d\n",*((int *)(node->data)));
- }
-
- printf("----------\n");
- code = cci_generic_list_copy(head, &copy);
- code = cci_generic_list_iterator(copy, &iterate);
- while (cci_generic_iterate_has_next(iterate)) {
- code = cci_generic_iterate_next(iterate, &node);
- printf("%d\n",*((int *)(node->data)));
- }
-
- cci_generic_list_destroy(copy);
- return 0;
-}
diff --git a/src/lib/ccapi/unit-test/t_msg.c b/src/lib/ccapi/unit-test/t_msg.c
deleted file mode 100644
index b3a31a871..000000000
--- a/src/lib/ccapi/unit-test/t_msg.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/* $Copyright:
- *
- * Copyright 2004 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 "CredentialsCache.h"
-#include "msg.h"
-#include "datastore.h"
-
-#include <stdlib.h>
-#include <memory.h>
-#include <stdio.h>
-#include <string.h>
-
-/*testing code*/
-int main()
-{
- cc_msg_t* msg;
- double header = 4.05;
- char blob1[] = "This is blob one.1234";
- int blob2 = 2;
- char blob3[] = "This is blob 3.";
- int pos1,pos2,pos3;
- void *flat;
- char *p;
- cc_uint32 valid = 0;
- cc_int32 code;
-
- code = cci_msg_new(ccmsg_INIT, &msg);
- code = cci_msg_add_header(msg, &header, sizeof(double));
- //cc_msg_add_header(msg, NULL, 0);
- code = cci_msg_add_data_blob(msg, blob1, strlen(blob1) + 1,&pos1);
- code = cci_msg_add_data_blob(msg, &blob2, sizeof(int),&pos2);
- code = cci_msg_add_data_blob(msg, blob3, strlen(blob3) + 1,&pos3);
-
- cci_msg_flatten(msg,&flat);
-
- printf("%s\n",(char *)((char *)msg->flat + pos1));
- printf("%d\n",*(int *)((char *)msg->flat + pos2));
- printf("%s\n",(char *)((char *)msg->flat + pos3));
-
- cci_msg_verify(msg->flat, msg->flat_len, &valid);
- printf("%d\n",valid);
-
- code = cci_msg_unflatten(msg->flat, msg->flat_len, &msg);
-
- code = cci_msg_retrieve_blob(msg, pos3, strlen(blob3) + 1, &p);
- printf("%s PPP\n",p);
- return 0;
-}
diff --git a/src/lib/ccapi/unit-test/t_server.c b/src/lib/ccapi/unit-test/t_server.c
deleted file mode 100644
index d6093941e..000000000
--- a/src/lib/ccapi/unit-test/t_server.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/* $Copyright:
- *
- * Copyright 2004 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 "CredentialsCache.h"
-#include "serv_ops.h"
-#include "datastore.h"
-#include "rpc_auth.h"
-#include "msg_headers.h"
-
-#include <stdlib.h>
-
-static int
-read_flat_msg(char ** flat_msg, cc_uint32 * flat_len)
-{
-
- /* TODO - read length of message */
- *flat_len = 999;
-
- *flat_msg = (char *)malloc(*flat_len);
-
- /* TODO - read message into buffer */
-
- return 0;
-}
-
-static int
-send_flat_msg(char * flag_msg, cc_uint32 flat_len)
-{
-
- return 0;
-}
-
-static int
-obtain_auth_info(cc_auth_info_t ** auth)
-{
- if (auth == NULL)
- return ccErrBadParam;
-
- *auth = malloc(sizeof(cc_auth_info_t));
- if (auth == NULL)
- return ccErrNoMem;
-
- memset(*auth,0,sizeof(cc_auth_info_t));
-
- /* TODO: obtain real auth data from connection */
-
- return ccNoError;
-}
-
-static int
-destroy_auth_info(cc_auth_info_t * auth)
-{
- if (auth == NULL)
- return ccErrBadParam;
-
- if (auth->info)
- free(auth->info);
-
- free(auth);
-
- return ccNoError;
-}
-
-static int
-obtain_session_info(cc_session_info_t ** session)
-{
- if (session == NULL)
- return ccErrBadParam;
-
- *session = malloc(sizeof(cc_session_info_t));
- if (session == NULL)
- return ccErrNoMem;
-
- memset(*session,0,sizeof(cc_session_info_t));
-
- /* TODO: obtain real session data from connection */
-
- return ccNoError;
-}
-
-static int
-destroy_session_info(cc_session_info_t * session)
-{
- if (session == NULL)
- return ccErrBadParam;
-
- if (session->info)
- free(session->info);
-
- free(session);
-
- return ccNoError;
-}
-
-
-int
-main(void)
-{
- cc_msg_t * msg;
- cc_msg_t * resp;
- cc_auth_info_t * auth_info;
- cc_session_info_t * session_info;
- cc_int32 code;
-
- if ( ccs_serv_initialize() != ccNoError )
- return 1;
-
- while ( 1 ) {
- msg = (cc_msg_t *)malloc(sizeof(cc_msg_t));
-
- /* read message */
- if (read_flat_msg(&msg->flat, &msg->flat_len))
- continue;
-
- /* unflatten message */
- code = cci_msg_unflatten(msg->flat, msg->flat_len, &msg);
-
- /* obtain auth info */
- code = obtain_auth_info(&auth_info);
-
- /* obtain session info */
- code = obtain_session_info(&session_info);
-
- /* process message */
- code = ccs_serv_process_msg(msg, auth_info, session_info, &resp);
-
- /* flatten response */
- code = cci_msg_flatten(resp, NULL);
-
- /* send response */
- code = send_flat_msg(resp->flat, resp->flat_len);
-
- code = destroy_auth_info(auth_info);
-
- code = destroy_session_info(session_info);
-
- /* free message */
- code = cci_msg_destroy(msg);
-
- /* free response */
- code = cci_msg_destroy(resp);
- }
- return 0;
-}