From 519e9fd31b01096f23d2c935bad08554f24127ec Mon Sep 17 00:00:00 2001 From: skarg Date: Thu, 26 Jul 2007 14:25:25 +0000 Subject: [PATCH] Converted comments from c++ to c. --- bacnet-stack/key.c | 12 +- bacnet-stack/key.h | 6 +- bacnet-stack/keylist.c | 186 +++++++++++++++--------------- bacnet-stack/keylist.h | 48 ++++---- bacnet-stack/ports/linux/dlmstp.c | 2 +- bacnet-stack/ports/win32/dlmstp.c | 2 +- bacnet-stack/ports/win32/rs485.c | 2 +- 7 files changed, 129 insertions(+), 129 deletions(-) diff --git a/bacnet-stack/key.c b/bacnet-stack/key.c index 306eff5a..06047ace 100644 --- a/bacnet-stack/key.c +++ b/bacnet-stack/key.c @@ -31,8 +31,8 @@ License. ------------------------------------------- ####COPYRIGHTEND####*/ -//#define TEST -//#define TEST_KEY +/*#define TEST */ +/*#define TEST_KEY */ #include "key.h" #ifdef TEST @@ -41,7 +41,7 @@ #include "ctest.h" -// test the encode and decode macros +/* test the encode and decode macros */ void testKeys(Test * pTest) { int type, id; @@ -61,7 +61,7 @@ void testKeys(Test * pTest) return; } -// test the encode and decode macros +/* test the encode and decode macros */ void testKeySample(Test * pTest) { int type, id; @@ -99,8 +99,8 @@ int main(void) pTest = ct_create("key", NULL); /* add the individual tests */ -// rc = ct_addTestFunction(pTest, testKeys); -// assert(rc); +/* rc = ct_addTestFunction(pTest, testKeys); */ +/* assert(rc); */ rc = ct_addTestFunction(pTest, testKeySample); assert(rc); /* run all the tests */ diff --git a/bacnet-stack/key.h b/bacnet-stack/key.h index 1bb66000..cc11c4db 100644 --- a/bacnet-stack/key.h +++ b/bacnet-stack/key.h @@ -36,11 +36,11 @@ #include -// This file has the macros that encode and decode the -// keys for the keylist when used with BACnet Object Id's +/* This file has the macros that encode and decode the */ +/* keys for the keylist when used with BACnet Object Id's */ typedef uint32_t KEY; -// assuming a 32 bit KEY +/* assuming a 32 bit KEY */ #define KEY_TYPE_OFFSET 22 /* bits - for BACnet */ #define KEY_TYPE_MASK 0x000003FFL #define KEY_ID_MASK 0x003FFFFFL diff --git a/bacnet-stack/keylist.c b/bacnet-stack/keylist.c index c34293d3..511c8124 100644 --- a/bacnet-stack/keylist.c +++ b/bacnet-stack/keylist.c @@ -30,18 +30,18 @@ ------------------------------------------- ####COPYRIGHTEND####*/ -// Keyed Linked List Library -// -// This is an enhanced array of pointers to data. -// The list is sorted, indexed, and keyed. -// The array is much faster than a linked list. -// It stores a pointer to data, which you must -// malloc and free on your own, or just use -// static data +/* Keyed Linked List Library */ +/* */ +/* This is an enhanced array of pointers to data. */ +/* The list is sorted, indexed, and keyed. */ +/* The array is much faster than a linked list. */ +/* It stores a pointer to data, which you must */ +/* malloc and free on your own, or just use */ +/* static data */ #include -#include "keylist.h" // check for valid prototypes +#include "keylist.h" /* check for valid prototypes */ #ifndef FALSE #define FALSE 0 @@ -51,51 +51,51 @@ #define TRUE 1 #endif -///////////////////////////////////////////////////////////////////// -// Generic node routines -///////////////////////////////////////////////////////////////////// +/*/////////////////////////////////////////////////////////////////// */ +/* Generic node routines */ +/*/////////////////////////////////////////////////////////////////// */ -// grab memory for a node +/* grab memory for a node */ static struct Keylist_Node *NodeCreate(void) { return calloc(1, sizeof(struct Keylist_Node)); } -// grab memory for a list +/* grab memory for a list */ static struct Keylist *KeylistCreate(void) { return calloc(1, sizeof(struct Keylist)); } -// check to see if the array is big enough for an addition -// or is too big when we are deleting and we can shrink -// returns TRUE if success, FALSE if failed +/* check to see if the array is big enough for an addition */ +/* or is too big when we are deleting and we can shrink */ +/* returns TRUE if success, FALSE if failed */ static int CheckArraySize(OS_Keylist list) { - int new_size = 0; // set it up so that no size change is the default - const int chunk = 8; // minimum number of nodes to allocate memory for - struct Keylist_Node **new_array; // new array of nodes, if needed - int i; // counter + int new_size = 0; /* set it up so that no size change is the default */ + const int chunk = 8; /* minimum number of nodes to allocate memory for */ + struct Keylist_Node **new_array; /* new array of nodes, if needed */ + int i; /* counter */ if (!list) return FALSE; - // indicates the need for more memory allocation + /* indicates the need for more memory allocation */ if (list->count == list->size) new_size = list->size + chunk; - // allow for shrinking memory + /* allow for shrinking memory */ else if ((list->size > chunk) && (list->count < (list->size - chunk))) new_size = list->size - chunk; if (new_size) { - // Allocate more room for node pointer array + /* Allocate more room for node pointer array */ new_array = calloc((size_t) new_size, sizeof(new_array)); - // See if we got the memory we wanted + /* See if we got the memory we wanted */ if (!new_array) return FALSE; - // copy the nodes from the old array to the new array + /* copy the nodes from the old array to the new array */ if (list->array) { for (i = 0; i < list->count; i++) { new_array[i] = list->array[i]; @@ -109,29 +109,29 @@ static int CheckArraySize(OS_Keylist list) } -// find the index of the key that we are looking for -// since it is sorted, we can optimize the search -// returns TRUE if found, and FALSE not found -// returns the found key and the index where it was found in parameters -// If the key is not found, the nearest index from the bottom will be returned, -// allowing the ability to find where an key should go into the list. +/* find the index of the key that we are looking for */ +/* since it is sorted, we can optimize the search */ +/* returns TRUE if found, and FALSE not found */ +/* returns the found key and the index where it was found in parameters */ +/* If the key is not found, the nearest index from the bottom will be returned, */ +/* allowing the ability to find where an key should go into the list. */ static int FindIndex(OS_Keylist list, KEY key, int *pIndex) { - struct Keylist_Node *node; // holds the new node - int left = 0; // the left branch of tree, beginning of list - int right = 0; // the right branch on the tree, end of list - int index = 0; // our current search place in the array - KEY current_key = 0; // place holder for current node key - int status = FALSE; // return value + struct Keylist_Node *node; /* holds the new node */ + int left = 0; /* the left branch of tree, beginning of list */ + int right = 0; /* the right branch on the tree, end of list */ + int index = 0; /* our current search place in the array */ + KEY current_key = 0; /* place holder for current node key */ + int status = FALSE; /* return value */ if (!list || !list->array || !list->count) { *pIndex = 0; return (FALSE); } right = list->count - 1; - // assume that the list is sorted + /* assume that the list is sorted */ do { - // A binary search + /* A binary search */ index = (left + right) / 2; node = list->array[index]; if (!node) @@ -151,7 +151,7 @@ static int FindIndex(OS_Keylist list, KEY key, int *pIndex) else { - // where the index should be + /* where the index should be */ if (key > current_key) *pIndex = index + 1; @@ -162,29 +162,29 @@ static int FindIndex(OS_Keylist list, KEY key, int *pIndex) } -///////////////////////////////////////////////////////////////////// -// list data functions -///////////////////////////////////////////////////////////////////// -// inserts a node into its sorted position +/*/////////////////////////////////////////////////////////////////// */ +/* list data functions */ +/*/////////////////////////////////////////////////////////////////// */ +/* inserts a node into its sorted position */ int Keylist_Data_Add(OS_Keylist list, KEY key, void *data) { - struct Keylist_Node *node; // holds the new node - int index = -1; // return value - int i; // counts through the array + struct Keylist_Node *node; /* holds the new node */ + int index = -1; /* return value */ + int i; /* counts through the array */ if (list && CheckArraySize(list)) { - // figure out where to put the new node + /* figure out where to put the new node */ if (list->count) { (void) FindIndex(list, key, &index); - // Add to the beginning of the list + /* Add to the beginning of the list */ if (index < 0) index = 0; - // Add to the end of the list + /* Add to the end of the list */ else if (index > list->count) index = list->count; - // Move all the items up to make room for the new one + /* Move all the items up to make room for the new one */ for (i = list->count; i > index; i--) { list->array[i] = list->array[i - 1]; } @@ -194,7 +194,7 @@ int Keylist_Data_Add(OS_Keylist list, KEY key, void *data) index = 0; } - // create and add the node + /* create and add the node */ node = NodeCreate(); if (node) { list->count++; @@ -206,8 +206,8 @@ int Keylist_Data_Add(OS_Keylist list, KEY key, void *data) return index; } -// deletes a node specified by its index -// returns the data from the node +/* deletes a node specified by its index */ +/* returns the data from the node */ void *Keylist_Data_Delete_By_Index(OS_Keylist list, int index) { struct Keylist_Node *node; @@ -219,19 +219,19 @@ void *Keylist_Data_Delete_By_Index(OS_Keylist list, int index) if (node) data = node->data; - // move the nodes to account for the deleted one + /* move the nodes to account for the deleted one */ if (list->count == 1) { - // There is no node shifting to do + /* There is no node shifting to do */ } - // We are the last one + /* We are the last one */ else if (index == (list->count - 1)) { - // There is no node shifting to do + /* There is no node shifting to do */ } - // Move all the nodes down one + /* Move all the nodes down one */ else { - int i; // counter + int i; /* counter */ int count = list->count - 1; for (i = index; i < count; i++) { list->array[i] = list->array[i + 1]; @@ -241,19 +241,19 @@ void *Keylist_Data_Delete_By_Index(OS_Keylist list, int index) if (node) free(node); - // potentially reduce the size of the array + /* potentially reduce the size of the array */ (void) CheckArraySize(list); } return (data); } -// deletes a node specified by its key -// returns the data from the node +/* deletes a node specified by its key */ +/* returns the data from the node */ void *Keylist_Data_Delete(OS_Keylist list, KEY key) { - void *data = NULL; // return value - int index; // where the node is in the array + void *data = NULL; /* return value */ + int index; /* where the node is in the array */ if (list) { if (FindIndex(list, key, &index)) @@ -263,11 +263,11 @@ void *Keylist_Data_Delete(OS_Keylist list, KEY key) return data; } -// returns the data from last node, and removes it from the list +/* returns the data from last node, and removes it from the list */ void *Keylist_Data_Pop(OS_Keylist list) { - void *data = NULL; // return value - int index; // position in the array + void *data = NULL; /* return value */ + int index; /* position in the array */ if (list && list->count) { index = list->count - 1; @@ -277,11 +277,11 @@ void *Keylist_Data_Pop(OS_Keylist list) return data; } -// returns the data from the node specified by key +/* returns the data from the node specified by key */ void *Keylist_Data(OS_Keylist list, KEY key) { struct Keylist_Node *node = NULL; - int index = 0; // used to look up the index of node + int index = 0; /* used to look up the index of node */ if (list && list->array && list->count) { if (FindIndex(list, key, &index)) @@ -291,7 +291,7 @@ void *Keylist_Data(OS_Keylist list, KEY key) return node ? node->data : NULL; } -// returns the data specified by key +/* returns the data specified by key */ void *Keylist_Data_Index(OS_Keylist list, int index) { struct Keylist_Node *node = NULL; @@ -303,10 +303,10 @@ void *Keylist_Data_Index(OS_Keylist list, int index) return node ? node->data : NULL; } -// return the key at the given index +/* return the key at the given index */ KEY Keylist_Key(OS_Keylist list, int index) { - KEY key = 0; // return value + KEY key = 0; /* return value */ struct Keylist_Node *node; if (list && list->array && list->count && @@ -319,7 +319,7 @@ KEY Keylist_Key(OS_Keylist list, int index) return key; } -// returns the next empty key from the list +/* returns the next empty key from the list */ KEY Keylist_Next_Empty_Key(OS_Keylist list, KEY key) { int index; @@ -335,17 +335,17 @@ KEY Keylist_Next_Empty_Key(OS_Keylist list, KEY key) return key; } -// return the number of nodes in this list +/* return the number of nodes in this list */ int Keylist_Count(OS_Keylist list) { return list->count; } -///////////////////////////////////////////////////////////////////// -// Public List functions -///////////////////////////////////////////////////////////////////// +/*/////////////////////////////////////////////////////////////////// */ +/* Public List functions */ +/*/////////////////////////////////////////////////////////////////// */ -// returns head of the list or NULL on failure. +/* returns head of the list or NULL on failure. */ OS_Keylist Keylist_Create(void) { struct Keylist *list; @@ -357,11 +357,11 @@ OS_Keylist Keylist_Create(void) return list; } -// delete specified list -void Keylist_Delete(OS_Keylist list) // list number to be deleted +/* delete specified list */ +void Keylist_Delete(OS_Keylist list) /* list number to be deleted */ { if (list) { - // clean out the list + /* clean out the list */ while (list->count) { (void) Keylist_Data_Delete_By_Index(list, 0); } @@ -379,7 +379,7 @@ void Keylist_Delete(OS_Keylist list) // list number to be deleted #include "ctest.h" -// test the encode and decode macros +/* test the encode and decode macros */ void testKeySample(Test * pTest) { int type, id; @@ -411,7 +411,7 @@ void testKeySample(Test * pTest) return; } -// test the FIFO +/* test the FIFO */ void testKeyListFIFO(Test * pTest) { OS_Keylist list; @@ -454,7 +454,7 @@ void testKeyListFIFO(Test * pTest) return; } -// test the FILO +/* test the FILO */ void testKeyListFILO(Test * pTest) { OS_Keylist list; @@ -535,7 +535,7 @@ void testKeyListDataKey(Test * pTest) ct_test(pTest, Keylist_Count(list) == 3); - // look at the data + /* look at the data */ key = 2; data = Keylist_Data(list, key); ct_test(pTest, data != NULL); @@ -551,7 +551,7 @@ void testKeyListDataKey(Test * pTest) ct_test(pTest, data != NULL); ct_test(pTest, strcmp(data, data3) == 0); - // work the data + /* work the data */ key = 2; data = Keylist_Data_Delete(list, key); ct_test(pTest, data != NULL); @@ -570,7 +570,7 @@ void testKeyListDataKey(Test * pTest) ct_test(pTest, data != NULL); ct_test(pTest, strcmp(data, data3) == 0); - // cleanup + /* cleanup */ do { data = Keylist_Data_Pop(list); } @@ -605,7 +605,7 @@ void testKeyListDataIndex(Test * pTest) ct_test(pTest, Keylist_Count(list) == 3); - // look at the data + /* look at the data */ data = Keylist_Data_Index(list, 0); ct_test(pTest, data != NULL); ct_test(pTest, strcmp(data, data3) == 0); @@ -618,7 +618,7 @@ void testKeyListDataIndex(Test * pTest) ct_test(pTest, data != NULL); ct_test(pTest, strcmp(data, data1) == 0); - // work the data + /* work the data */ data = Keylist_Data_Delete_By_Index(list, 1); ct_test(pTest, data != NULL); ct_test(pTest, strcmp(data, data2) == 0); @@ -640,7 +640,7 @@ void testKeyListDataIndex(Test * pTest) data = Keylist_Data_Delete_By_Index(list, 1); ct_test(pTest, data == NULL); - // cleanup + /* cleanup */ do { data = Keylist_Data_Pop(list); } @@ -651,7 +651,7 @@ void testKeyListDataIndex(Test * pTest) return; } -// test access of a lot of entries +/* test access of a lot of entries */ void testKeyListLarge(Test * pTest) { int data1 = 42; diff --git a/bacnet-stack/keylist.h b/bacnet-stack/keylist.h index 9faa99d1..206e8d6c 100644 --- a/bacnet-stack/keylist.h +++ b/bacnet-stack/keylist.h @@ -36,58 +36,58 @@ #include "key.h" -// This is a key sorted linked list data library that -// uses a key or index to access the data. -// If the keys are duplicated, they can be added into the list like FIFO +/* This is a key sorted linked list data library that */ +/* uses a key or index to access the data. */ +/* If the keys are duplicated, they can be added into the list like FIFO */ -// list data and datatype +/* list data and datatype */ struct Keylist_Node { - KEY key; // unique number that is sorted in the list - void *data; // pointer to some data that is stored + KEY key; /* unique number that is sorted in the list */ + void *data; /* pointer to some data that is stored */ }; typedef struct Keylist { - struct Keylist_Node **array; // array of nodes - int count; // number of nodes in this list - more effecient than loop - int size; // number of available nodes on this list - can grow or shrink + struct Keylist_Node **array; /* array of nodes */ + int count; /* number of nodes in this list - more effecient than loop */ + int size; /* number of available nodes on this list - can grow or shrink */ } KEYLIST_TYPE; typedef KEYLIST_TYPE *OS_Keylist; -// returns head of the list or NULL on failure. +/* returns head of the list or NULL on failure. */ OS_Keylist Keylist_Create(void); -// delete specified list -// note: you should pop all the nodes off the list first. +/* delete specified list */ +/* note: you should pop all the nodes off the list first. */ void Keylist_Delete(OS_Keylist list); -// inserts a node into its sorted position -// returns the index where it was added +/* inserts a node into its sorted position */ +/* returns the index where it was added */ int Keylist_Data_Add(OS_Keylist list, KEY key, void *data); -// deletes a node specified by its key -// returns the data from the node +/* deletes a node specified by its key */ +/* returns the data from the node */ void *Keylist_Data_Delete(OS_Keylist list, KEY key); -// deletes a node specified by its index -// returns the data from the node +/* deletes a node specified by its index */ +/* returns the data from the node */ void *Keylist_Data_Delete_By_Index(OS_Keylist list, int index); -// returns the data from last node, and removes it from the list +/* returns the data from last node, and removes it from the list */ void *Keylist_Data_Pop(OS_Keylist list); -// returns the data from the node specified by key +/* returns the data from the node specified by key */ void *Keylist_Data(OS_Keylist list, KEY key); -// returns the data specified by key +/* returns the data specified by key */ void *Keylist_Data_Index(OS_Keylist list, int index); -// return the key at the given index +/* return the key at the given index */ KEY Keylist_Key(OS_Keylist list, int index); -// returns the next empty key from the list +/* returns the next empty key from the list */ KEY Keylist_Next_Empty_Key(OS_Keylist list, KEY key); -// returns the number of items in the list +/* returns the number of items in the list */ int Keylist_Count(OS_Keylist list); #endif diff --git a/bacnet-stack/ports/linux/dlmstp.c b/bacnet-stack/ports/linux/dlmstp.c index e690d3ba..5b16309c 100644 --- a/bacnet-stack/ports/linux/dlmstp.c +++ b/bacnet-stack/ports/linux/dlmstp.c @@ -83,7 +83,7 @@ static void *dlmstp_milliseconds_task(void *pArg) void dlmstp_reinit(void) { - //RS485_Reinit(); + /*RS485_Reinit(); */ dlmstp_set_mac_address(DEFAULT_MAC_ADDRESS); dlmstp_set_max_info_frames(DEFAULT_MAX_INFO_FRAMES); dlmstp_set_max_master(DEFAULT_MAX_MASTER); diff --git a/bacnet-stack/ports/win32/dlmstp.c b/bacnet-stack/ports/win32/dlmstp.c index eff4c6f8..221a0c02 100644 --- a/bacnet-stack/ports/win32/dlmstp.c +++ b/bacnet-stack/ports/win32/dlmstp.c @@ -63,7 +63,7 @@ void dlmstp_millisecond_timer(void) void dlmstp_reinit(void) { - //RS485_Reinit(); + /*RS485_Reinit(); */ dlmstp_set_mac_address(DEFAULT_MAC_ADDRESS); dlmstp_set_max_info_frames(DEFAULT_MAX_INFO_FRAMES); dlmstp_set_max_master(DEFAULT_MAX_MASTER); diff --git a/bacnet-stack/ports/win32/rs485.c b/bacnet-stack/ports/win32/rs485.c index 886b64d3..80b50af7 100644 --- a/bacnet-stack/ports/win32/rs485.c +++ b/bacnet-stack/ports/win32/rs485.c @@ -91,7 +91,7 @@ void RS485_Set_Interface(char *ifname) static void RS485_Print_Error(void) { - char * szExtended = ""; // error string translated from error code + char * szExtended = ""; /* error string translated from error code */ DWORD dwExtSize; DWORD dwErr;