Move generic list functions to common/generic_lists.c
authorJeffrey Altman <jaltman@secure-endpoints.com>
Mon, 22 May 2006 17:18:27 +0000 (17:18 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Mon, 22 May 2006 17:18:27 +0000 (17:18 +0000)
so they can be used by both the client dll and the server.

Fix type utilization in serv_ops.c

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ccapi@18029 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/ccapi/server/ccs_lists.c
src/lib/ccapi/server/serv_ops.c

index 06f8ced87395a7c49fe5aa4103291fd6dd3465a0..95ca398fb205b56e41a6c1185c8faaf4f654c26a 100644 (file)
 #include "CredentialsCache.h"\r
 #include "datastore.h"\r
 \r
-/**\r
- * cci_generic_iterate_has_next()\r
- *\r
- * Purpose: Determine if an iterator has a next element\r
- *\r
- * Return:  1 if another element exists\r
- *          0 if no additional elements exist\r
- *\r
- * Errors:  None\r
- *\r
- */\r
-cc_int32 \r
-cci_generic_iterate_has_next(cc_generic_iterate_t *iterate) \r
-{\r
-    return ((iterate == NULL || iterate->next == NULL) ? 0 : 1);\r
-}\r
-\r
-/**\r
- * cci_generic_iterate_next()\r
- *\r
- * Purpose: Retrieve the next element from an iterator and advance\r
- *          the iterator\r
- *\r
- * Return:  non-NULL, the next element in the iterator\r
- *          NULL, the iterator list is empty or iterator is invalid\r
- *\r
- * Errors:  ccErrBadParam\r
- *\r
- */\r
-cc_int32\r
-cci_generic_iterate_next(cc_generic_iterate_t *iterator, cc_generic_list_node_t** nodepp) \r
-{\r
-    cc_generic_list_node_t* ret;\r
-    \r
-    if (iterator == NULL || nodepp == NULL)\r
-        return ccErrBadParam;\r
-\r
-    ret = iterator->next;\r
-    if (iterator->next != NULL)\r
-        iterator->next = iterator->next->next;\r
-\r
-    *nodepp = ret;\r
-    return ccNoError;\r
-}\r
-\r
 /**\r
  * ccs_context_iterate_has_next()\r
  *\r
@@ -219,214 +174,6 @@ ccs_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_l
     return cci_generic_iterate_next((cc_generic_iterate_t*)iterate, (cc_credentials_list_node_t**)nodepp);\r
 }\r
 \r
-/**\r
- * cci_generic_list_new()\r
- *\r
- * Purpose: Allocate new generic list\r
- *\r
- * Return:  non-NULL, an empty list\r
- *          NULL, failure\r
- *\r
- * Errors:  ccErrNoMem\r
- *\r
- */\r
-cc_int32\r
-cci_generic_list_new(cc_generic_list_head_t ** listpp) \r
-{\r
-    cc_generic_list_head_t* ret = (cc_generic_list_head_t *)malloc(sizeof(cc_generic_list_head_t));\r
-    if (ret == NULL)\r
-        return ccErrNoMem;\r
-       \r
-       ret->type = generic;\r
-    ret->head = ret->tail = NULL;\r
-    *listpp = ret;\r
-\r
-    return ccNoError;\r
-}\r
-\r
-/**\r
- * cci_generic_list_append()\r
- *\r
- * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' \r
- *\r
- * Return:  non-NULL, a pointer to the newly allocated node\r
- *          NULL, failure\r
- *\r
- * Errors:  ccErrNoMem,ccErrBadParam\r
- *\r
- */\r
-cc_int32\r
-cci_generic_list_append(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) \r
-{\r
-    cc_generic_list_node_t* new_node;\r
-\r
-    if ( data == NULL || len == 0 )\r
-        return ccErrBadParam;\r
-\r
-    new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t));\r
-    if (new_node == NULL)\r
-        return ccErrNoMem;\r
-\r
-    new_node->data = malloc(len);\r
-    if ( new_node->data == NULL ) {\r
-        free(new_node);\r
-        return ccErrNoMem;         \r
-    }\r
-    \r
-    memcpy(new_node->data,data,len);\r
-    new_node->len = len;\r
-\r
-    if (head->head == NULL) { /*empty list*/\r
-        head->head = new_node;\r
-        head->tail = new_node;\r
-           new_node->next = new_node->prev = NULL;\r
-    } else {\r
-        new_node->prev = head->tail;\r
-        head->tail->next = new_node;\r
-        head->tail = new_node;\r
-               new_node->next = NULL;\r
-    }\r
-       if (nodepp != NULL)\r
-           *nodepp = new_node;\r
-    return ccNoError;\r
-}\r
-\r
-/**\r
- * cci_generic_list_prepend()\r
- *\r
- * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data'\r
- *\r
- * Return:  non-NULL, a pointer to the newly allocated node\r
- *          NULL, failure\r
- *\r
- * Errors:  ccErrNoMem, ccErrBadParam\r
- *\r
- */\r
-cc_int32 \r
-cci_generic_list_prepend(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) \r
-{\r
-    cc_generic_list_node_t* new_node;\r
-\r
-    if ( data == NULL || len == 0 )\r
-        return ccErrBadParam;\r
-\r
-    new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t));\r
-    if (new_node == NULL)\r
-        return ccErrNoMem;\r
-\r
-    new_node->data = malloc(len);\r
-    if ( new_node->data == NULL ) {\r
-        free(new_node);\r
-        return ccErrNoMem;\r
-    }\r
-    \r
-    memcpy(new_node->data,data,len);\r
-    new_node->len = len;\r
-       \r
-    if (head->head == NULL) { /*empty list*/\r
-        head->head = new_node;\r
-        head->tail = new_node;\r
-        new_node->prev = new_node->next = NULL;\r
-    } else {\r
-        new_node->next = head->head;\r
-        head->head->prev = new_node;\r
-        new_node->prev = NULL;\r
-        head->head = new_node;\r
-    }\r
-\r
-       if (nodepp != NULL)\r
-               *nodepp = new_node;\r
-\r
-    return ccNoError;\r
-}\r
-\r
-/**\r
- * cci_generic_list_remove_element()\r
- *\r
- * Purpose: Remove a node from the list\r
- *\r
- * Return:  0, success\r
- *         -1, failure\r
- *\r
- * Errors:  ccErrBadParam\r
- *\r
- */\r
-cc_int32 \r
-cci_generic_list_remove_element(cc_generic_list_head_t* head, cc_generic_list_node_t* rem) \r
-{\r
-    if (head->head == NULL || rem == NULL)\r
-        return ccErrBadParam;\r
-\r
-    if (head->head == rem && head->tail == rem) { /*removing only element of list*/\r
-        head->head = head->tail = NULL;\r
-    } else if (head->head == rem) { /*removing head*/\r
-        head->head = head->head->next;\r
-    } else if (head->tail == rem) { /*removing tail*/\r
-        head->tail = head->tail->prev;\r
-        head->tail->next = NULL;\r
-    } else {\r
-        rem->prev->next = rem->next;\r
-        rem->next->prev = rem->prev;\r
-    }\r
-    free(rem);\r
-    return ccNoError;\r
-}\r
-\r
-/**\r
- * cci_generic_free_element()\r
- *\r
- * Purpose: Free the memory associated with a node\r
- *\r
- * Return:  0, success\r
- *         -1, failure\r
- *\r
- * Errors:  ccErrBadParam\r
- *\r
- */\r
-cc_int32\r
-cci_generic_free_element(cc_generic_list_node_t* node)\r
-{\r
-    if ( node == NULL )\r
-        return ccErrBadParam;\r
-\r
-    if ( node->data ) {\r
-        free(node->data);\r
-        node->data = NULL;\r
-    }\r
-    node->len = 0;\r
-    node->next = node->prev = NULL;\r
-    free(node);\r
-    return ccNoError;\r
-}\r
-\r
-\r
-/**\r
- * cci_generic_list_destroy()\r
- *\r
- * Purpose: Deallocate a list and all of its contents\r
- *\r
- * Return:  0, success\r
- *         -1, failure\r
- *\r
- * Errors:  ccErrBadParam\r
- */\r
-cc_int32\r
-cci_generic_list_destroy(cc_generic_list_head_t* head) \r
-{\r
-    cc_generic_list_node_t *cur, *next;\r
-    cc_int32 ret = ccNoError;\r
-\r
-    if ( head == NULL )\r
-        return ccErrBadParam;\r
-       \r
-    for (cur = head->head; ret == ccNoError && cur != NULL; cur = next) {\r
-        next = cur->next;\r
-        ret = cci_generic_free_element(cur);\r
-    }       \r
-    free(head);\r
-    return(ret);\r
-}\r
-\r
 /**\r
  * ccs_context_list_destroy()\r
  *\r
@@ -475,42 +222,6 @@ ccs_credentials_list_destroy(cc_credentials_list_head_t* head)
     return cci_generic_list_destroy((cc_generic_list_head_t*)head);\r
 }\r
 \r
-/**\r
- * cci_generic_list_copy()\r
- *\r
- * Purpose: Copy a list\r
- *\r
- * Return:  non-NULL, a new list\r
- *          NULL, failure\r
- *\r
- * Errors:  ccErrBadParam, ccErrNoMem\r
- *\r
- */\r
-cc_int32\r
-cci_generic_list_copy(cc_generic_list_head_t* head, cc_generic_list_head_t** headpp) \r
-{\r
-    cc_generic_list_head_t* copy;\r
-    cc_generic_list_node_t *src_node, *dst_node;\r
-    cc_int32 code;\r
-\r
-    if (head == NULL || headpp == NULL)\r
-        return ccErrBadParam;\r
-\r
-    code = cci_generic_list_new(&copy);\r
-    if (code != ccNoError)\r
-        return code;\r
-\r
-    for (src_node = head->head; src_node != NULL; src_node = src_node->next) {\r
-        code = cci_generic_list_append(copy, src_node->data, src_node->len, &dst_node);\r
-        if (code != ccNoError) {\r
-            cci_generic_list_destroy(copy);\r
-            return code;\r
-        }\r
-    }\r
-    *headpp = copy;\r
-    return ccNoError;\r
-}\r
-\r
 /**\r
  * ccs_context_list_copy()\r
  *\r
@@ -562,57 +273,6 @@ ccs_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_
 }\r
 \r
 \r
-/**\r
- * cci_generic_list_iterator()\r
- *\r
- * Purpose: Allocate an iterator for the specified list\r
- *\r
- * Return:  non-NULL, an iterator\r
- *          NULL, failure\r
- *\r
- * Errors:  ccErrNoMem\r
- *\r
- */\r
-cc_int32\r
-cci_generic_list_iterator(cc_generic_list_head_t *head, cc_generic_iterate_t** headpp) \r
-{\r
-    cc_generic_iterate_t* iterator;\r
-\r
-    if ( head == NULL || headpp == NULL )\r
-        return ccErrBadParam;\r
-\r
-    iterator = (cc_generic_iterate_t*)malloc(sizeof(cc_generic_iterate_t));\r
-    if (iterator == NULL)\r
-        return ccErrNoMem;\r
-    \r
-    iterator->next = head->head;\r
-    *headpp = iterator;\r
-    return ccNoError;\r
-}\r
-\r
-/**\r
- * cci_generic_free_iterator()\r
- *\r
- * Purpose: Deallocate memory associated with an iterator\r
- *\r
- * Return:  0, success\r
- *         -1, failure\r
- *\r
- * Errors:  ccErrBadParam\r
- *\r
- */\r
-cc_int32\r
-cci_generic_free_iterator(cc_generic_iterate_t* iterator)\r
-{\r
-    if ( iterator == NULL )\r
-        return ccErrBadParam;\r
-\r
-    iterator->next = NULL;\r
-    free(iterator);\r
-    return ccNoError;\r
-}\r
-\r
-\r
 /**\r
  * ccs_context_list_new()\r
  *\r
index 01a9742cd25ac88451e3ce85af6a6f7822ea502f..9c544fc58dfca9b782bf08f75b8ec6bea74bcd76 100644 (file)
@@ -549,7 +549,7 @@ ccop_CTX_COMPARE(cc_server_context_t* ctx,
 {
     cc_server_context_t *ctx2;
     ccmsg_ctx_compare_resp_t* resp_header;
-    ccmsg_ctx_compare_t* header = (ccmsg_ctx_compare_t *)(ntohll(msg->header));
+    ccmsg_ctx_compare_t* header = (ccmsg_ctx_compare_t *)msg->header;
     cc_uint32 header_len = ntohl(msg->header_len);
     cc_int32 code;