Reformat some lines;
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 16 Nov 2013 03:16:57 +0000 (03:16 +0000)
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 16 Nov 2013 03:16:57 +0000 (03:16 +0000)
Tweak some whitespace.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@53361 f5534014-38df-0310-8fa8-9805f1628bb7

conditions.c
conditions.h

index ac7963cc7d79e6aa9431061560e7f23ee6bac81a..4d583b227986a38cdd5b046646f04475c2b62037 100644 (file)
 #include "conditions.h"
 
 /* container for condition classes */
-static GHashTableclasses = NULL;
+static GHashTable *classes = NULL;
 
 /* condition data structure declaration */
 struct condition{
-  charclass_id;
-  voiduser_data;
-  _cnd_eval eval_func;
-  _cnd_reset reset_func;
+  char       *class_id;
+  void       *user_data;
+  _cnd_eval   eval_func;
+  _cnd_reset  reset_func;
 };
 
 /* structure used to store class functions in GHashTable */
 typedef struct _cnd_class{
   _cnd_constr constr_func;
-  _cnd_destr destr_func;
-  _cnd_eval eval_func;
-  _cnd_reset reset_func;
+  _cnd_destr  destr_func;
+  _cnd_eval   eval_func;
+  _cnd_reset  reset_func;
 } _cnd_class;
 
 /* helper function prototypes */
 static void _cnd_init(void);
 static void _cnd_find_hash_key_for_class_id(gpointer, gpointer, gpointer);
 
-condition* cnd_new(const char* class_id, ...){
-  va_list ap;
-  condition *cnd = NULL, *cnd_ref = NULL;
-  _cnd_class *cls = NULL;
-  char* id = NULL;
+condition *cnd_new(const char *class_id, ...) {
+  va_list     ap;
+  condition  *cnd     = NULL;
+  condition  *cnd_ref = NULL;
+  _cnd_class *cls     = NULL;
+  char       *id      = NULL;
 
   /* check if hash table is already initialized */
   _cnd_init();
 
   /* get class structure for this id */
-  if((cls = (_cnd_class*)g_hash_table_lookup(classes, class_id)) == NULL) {
+  if ((cls = (_cnd_class *)g_hash_table_lookup(classes, class_id)) == NULL) {
     g_warning("cnd_new: Couldn't find class ID \"%s\"", class_id);
     return NULL;
   }
 
   /* initialize the basic structure */
-  if((cnd_ref = (condition*)g_malloc(sizeof(condition))) == NULL) return NULL;
-  cnd_ref->user_data = NULL;
-  cnd_ref->eval_func = cls->eval_func;
+  if ((cnd_ref = (condition *)g_malloc(sizeof(condition))) == NULL)
+    return NULL;
+  cnd_ref->user_data  = NULL;
+  cnd_ref->eval_func  = cls->eval_func;
   cnd_ref->reset_func = cls->reset_func;
 
   cnd_ref->class_id = g_strdup(class_id);
@@ -81,37 +83,40 @@ condition* cnd_new(const char* class_id, ...){
   va_end(ap);
 
   /* check for successful construction */
-  if(cnd == NULL){
+  if (cnd == NULL) {
     g_free(cnd_ref);
     g_free(id);
   }
   return cnd;
 } /* END cnd_new() */
 
-void cnd_delete(condition *cnd){
+void cnd_delete(condition *cnd) {
   _cnd_class *cls = NULL;
   const char* class_id;
   /* check for valid pointer */
-  if(cnd == NULL) return;
+  if (cnd == NULL)
+    return;
 
   class_id = cnd->class_id;
   /* check if hash table is already initialized */
   _cnd_init();
   /* get the condition class */
-  cls = (_cnd_class*)g_hash_table_lookup(classes, class_id);
+  cls = (_cnd_class *)g_hash_table_lookup(classes, class_id);
   /* call class specific destructor */
-  if(cls != NULL) (cls->destr_func)(cnd);
+  if (cls != NULL)
+    (cls->destr_func)(cnd);
   /* free memory */
   g_free(cnd->class_id);
   /* free basic structure */
   g_free(cnd);
 } /* END cnd_delete() */
 
-gboolean cnd_eval(condition *cnd, ...){
+gboolean cnd_eval(condition *cnd, ...) {
   va_list ap;
   gboolean ret_val = FALSE;
   /* validate cnd */
-  if(cnd == NULL) return FALSE;
+  if (cnd == NULL)
+    return FALSE;
   /* call specific handler */
   va_start(ap, cnd);
   ret_val = (cnd->eval_func)(cnd, ap);
@@ -119,33 +124,34 @@ gboolean cnd_eval(condition *cnd, ...){
   return ret_val;
 } /*  END cnd_eval() */
 
-void cnd_reset(condition *cnd){
-  if(cnd != NULL) (cnd->reset_func)(cnd);
+void cnd_reset(condition *cnd) {
+  if (cnd != NULL)
+    (cnd->reset_func)(cnd);
 } /* END cnd_reset() */
 
-void* cnd_get_user_data(condition *cnd){
+void* cnd_get_user_data(condition *cnd) {
   return cnd->user_data;
 } /* END cnd_get_user_data() */
 
-void cnd_set_user_data(condition *cnd, void* user_data){
+void cnd_set_user_data(condition *cnd, void *user_data) {
   cnd->user_data = user_data;
 } /* END cnd_set_user_data() */
 
-gboolean cnd_register_class(const charclass_id,
+gboolean cnd_register_class(const char *class_id,
                             _cnd_constr constr_func,
-                            _cnd_destr destr_func,
-                            _cnd_eval eval_func,
-                            _cnd_reset reset_func){
-  charkey = NULL;
+                            _cnd_destr  destr_func,
+                            _cnd_eval   eval_func,
+                            _cnd_reset  reset_func) {
+  char *key = NULL;
   _cnd_class *cls = NULL;
   /* check for valid parameters */
-  if((constr_func == NULL) || (destr_func == NULL) ||
-     (eval_func == NULL) || (reset_func == NULL) || (class_id == NULL))
+  if ((constr_func == NULL) || (destr_func == NULL) ||
+      (eval_func == NULL) || (reset_func == NULL) || (class_id == NULL))
     return FALSE;
   /* check if hash table is already initialized */
   _cnd_init();
   /* check for unique class id */
-  if(g_hash_table_lookup(classes, class_id) != NULL) {
+  if (g_hash_table_lookup(classes, class_id) != NULL) {
     g_warning("cnd_register_class: Duplicate class ID \"%s\"", class_id);
     return FALSE;
   }
@@ -153,21 +159,21 @@ gboolean cnd_register_class(const char* class_id,
      table. Allocate memory and copy the class id which we use as key. */
   key = g_strdup(class_id);
   /* initialize class structure */
-  if((cls = (_cnd_class*)g_malloc(sizeof(_cnd_class))) == NULL){
+  if ((cls = (_cnd_class*)g_malloc(sizeof(_cnd_class))) == NULL) {
     g_free(key);
     return FALSE;
   }
   cls->constr_func = constr_func;
-  cls->destr_func = destr_func;
-  cls->eval_func = eval_func;
-  cls->reset_func = reset_func;
+  cls->destr_func  = destr_func;
+  cls->eval_func   = eval_func;
+  cls->reset_func  = reset_func;
   /* insert new class */
   g_hash_table_insert(classes, key, cls);
   return TRUE;
 } /* END cnd_register_class() */
 
-static charpkey = NULL;
-void cnd_unregister_class(const char* class_id){
+static char *pkey = NULL;
+void cnd_unregister_class(const char* class_id) {
   const char *key = (const char*)class_id;
   _cnd_class *cls = NULL;
   /* check if hash table is already initialized */
@@ -190,8 +196,9 @@ void cnd_unregister_class(const char* class_id){
 /*
  * Initialize hash table.
  */
-static void _cnd_init(void){
-  if(classes != NULL) return;
+static void _cnd_init(void) {
+  if (classes != NULL)
+    return;
   /* create hash table, we use strings as keys */
   classes = g_hash_table_new(g_str_hash, g_str_equal);
 } /* END _cnd_init() */
@@ -205,10 +212,11 @@ static void _cnd_init(void){
  */
 void _cnd_find_hash_key_for_class_id(gpointer key,
                                      gpointer value _U_,
-                                     gpointer user_data){
-  char* class_id = (char*)user_data;
-  char* key_value = (char*)key;
-  if(strcmp(class_id, key_value) == 0) pkey = key_value;
+                                     gpointer user_data) {
+  char *class_id  = (char *)user_data;
+  char *key_value = (char *)key;
+  if (strcmp(class_id, key_value) == 0)
+    pkey = key_value;
 } /* END _cnd_find_hash_key_for_class_id() */
 
 /*
index 79c2cfad3d2dfae83066717c8c9321cd77d2f72f..018f16d9a5e1dcaecc32184ae2509a5b25c18a71 100644 (file)
 typedef struct condition condition;
 
 /* condition evaluation handler type */
-typedef gboolean (*_cnd_eval)(condition*, va_list);
+typedef gboolean (*_cnd_eval)(condition *, va_list);
 
 /* condition reset handler type */
-typedef void (*_cnd_reset)(condition*);
+typedef void (*_cnd_reset)(condition *);
 
 /* condition class constructor type */
-typedef condition* (*_cnd_constr)(condition*, va_list);
+typedef condition *(*_cnd_constr)(condition *, va_list);
 
 /* condition class destructor type */
-typedef void (*_cnd_destr)(condition*);
+typedef void (*_cnd_destr)(condition *);
 
 /*
  * Conditions must be created with this function. They can be created for
  * registered classes only.
  *
- * parameter: const char* - Identification of a registered condition class.
- *            ...         - Any number of class specific initial values.
+ * parameter: const char * - Identification of a registered condition class.
+ *            ...          - Any number of class specific initial values.
  * returns:   Pointer to a initialized condition of the particular class on
  *            success or NULL on failure.
  */
-condition* cnd_new(const char*, ...);
+condition *cnd_new(const char *, ...);
 
 /*
  * Conditions must be deleted with this function when not used anymore.
  *
- * parameter: condition* - Pointer to a condition created with 'cnd_new()'.
+ * parameter: condition * - Pointer to a condition created with 'cnd_new()'.
  * returns:   -
  */
-void cnd_delete(condition*);
+void cnd_delete(condition *);
 
 /*
  * Call this function to check whether or not a particular condition is true.
  *
- * parameter: condition* - Pointer to an initialized condition.
- *            ...        - Any number of condition specific arguments.
+ * parameter: condition * - Pointer to an initialized condition.
+ *            ...         - Any number of condition specific arguments.
  * returns:   TRUE  - Condition is true.
  *            FALSE - Condition is false.
  */
-gboolean cnd_eval(condition*, ...);
+gboolean cnd_eval(condition *, ...);
 
 /*
  * Call this function to reset this condition to its initial state, i.e. the
  * state it was in right after creation.
  *
- * parameter: condition* - Pointer to an initialized condition.
+ * parameter: condition * - Pointer to an initialized condition.
  * returns:   -
  */
-void cnd_reset(condition*);
+void cnd_reset(condition *);
 
 /*
  * Register a new conditon class.
  * New conditions of this class can be created by calling 'cnd_new()' and
  * supplying the appropriate class id.
  *
- * parameter: const char - The class id.
+ * parameter: const char * - The class id.
  *            _cnd_constr  - User supplied constructor function for this
  *                           class.
  *            _cnd_destr   - User supplied destructor function for this
@@ -98,7 +98,7 @@ void cnd_reset(condition*);
  * returns:   TRUE  - Success.
  *            FALSE - Failure.
  */
-gboolean cnd_register_class(const char*,
+gboolean cnd_register_class(const char *,
                             _cnd_constr,
                             _cnd_destr,
                             _cnd_eval,
@@ -109,26 +109,26 @@ gboolean cnd_register_class(const char*,
  * of a class it is no longer possible to create conditions of this kind by
  * calling 'cnd_new()'.
  *
- * parameter: const char* - An identification for this condition class.
+ * parameter: const char * - An identification for this condition class.
  * returns:   -
  */
-void cnd_unregister_class(const char*);
+void cnd_unregister_class(const char *);
 
 /*
  * This function returns the user data of the condition.
  *
- * parameter: condition* - Pointer to an initialized condition.
- * returns:   void*      - Pointer to user data of this condition.
+ * parameter: condition * - Pointer to an initialized condition.
+ * returns:   void *      - Pointer to user data of this condition.
  */
 void* cnd_get_user_data(condition*);
 
 /*
  * This function sets the user data of the condition.
  *
- * parameter: condition* - Pointer to an initialized condition.
- *            void*      - Pointer to user specified data structure.
+ * parameter: condition * - Pointer to an initialized condition.
+ *            void *      - Pointer to user specified data structure.
  * returns:   -
  */
-void cnd_set_user_data(condition*, void*);
+void cnd_set_user_data(condition *, void *);
 
 #endif /* CONDITIONS_H */