Index: trunk/psLib/src/sys/psTrace.c
===================================================================
--- trunk/psLib/src/sys/psTrace.c	(revision 928)
+++ trunk/psLib/src/sys/psTrace.c	(revision 1013)
@@ -1,7 +1,18 @@
-/*****************************************************************************
-    A simple implementation of a tracing facility for Pan-STARRS.  Tracing
-    is controlled on a per "component" basis, where a "component" is a name
-    of the form aaa.bbb.ccc where aaa is the most significant part.
- 
+/** @file psTrace.c
+ *  \brief basic run-time trace facilities
+ *  \ingroup LogTrace
+ *
+ *  This file will hold the code for procedures to insert
+ *  trace messages into the code.
+ *
+ *  @author Robert Lupton, Princeton University
+ *  @author George Gusciora, MHPCC
+ *
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-06-12 05:50:01 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+/*****************************************************************************
     NOTES:
  In the SRD, higher trace levels correspond to a numerically lower trace
@@ -16,12 +27,4 @@
  trace level of that node.
  
- This code is obfuscated by the fact that component names are of the form
- ".a.b.c.d" where "." is always the root of the tree, and for tree that have
- a depth of 3 or higher (including the root ".") the "."  character is also
- the deliminator between different individual nodes in the full component
- name.  So, for ".a.b.c.d", the first "." signifies the root of the tree,
- while the last three dots merely act as separators between the node names
- "b", "c", and "d".
- 
  I added a function psTraceFree() which frees all nodes in the trace component
  tree.  Previously, there had been no function in the API which accomplished
@@ -32,5 +35,4 @@
 #include <string.h>
 #include <stdarg.h>
-/* #include "pslib.h" */
 #include "psMemory.h"
 #include "psTrace.h"
@@ -38,8 +40,8 @@
 #include "psError.h"
 
-static Component *croot = NULL;           // The root of the trace component
-static FILE *traceFP = NULL;
-/*****************************************************************************
-    componentAlloc(): allocate memory for a new node, and initialize members.
+static Component *p_psCroot = NULL;       // The root of the trace component
+static FILE *p_psTraceFP = NULL;          // File destination for messages.
+/*****************************************************************************
+componentAlloc(): allocate memory for a new node, and initialize members.
  *****************************************************************************/
 Component *componentAlloc(const char *name,
@@ -56,6 +58,6 @@
 
 /*****************************************************************************
-    componentFree(): free the current node in the root tree, and all
- children nodes as well.
+componentFree(): free the current node in the root tree, and all children
+nodes as well.
  *****************************************************************************/
 static void componentFree(Component *comp)
@@ -78,16 +80,16 @@
 
 /*****************************************************************************
-    initTrace(): simply initialize the component root tree.
+initTrace(): simply initialize the component root tree.
 *****************************************************************************/
 static void initTrace(void)
 {
-    if (croot == NULL) {
-        croot = componentAlloc(".", DEFAULT_TRACE_LEVEL);
-    }
-}
-
-
-/*****************************************************************************
-    Set all trace levels to zero.
+    if (p_psCroot == NULL) {
+        p_psCroot = componentAlloc(".", DEFAULT_TRACE_LEVEL);
+    }
+}
+
+
+/*****************************************************************************
+Set all trace levels to zero.
  *****************************************************************************/
 void p_psTraceReset(Component *currentNode)
@@ -112,36 +114,41 @@
 }
 
+/*****************************************************************************
+Set all trace levels to zero.
+ *****************************************************************************/
 void psTraceReset()
 {
-    p_psTraceReset(croot);
-}
-
-
+    p_psTraceReset(p_psCroot);
+}
+
+
+/*****************************************************************************
+Free all nodes in the component tree.
+ *****************************************************************************/
 void psTraceFree()
 {
-    componentFree(croot);
-}
-
-
-/*****************************************************************************
-    componentAdd(): Adds the component named "addNodeName" to the root tree.
+    componentFree(p_psCroot);
+}
+
+
+/*****************************************************************************
+componentAdd(): Adds the component named "addNodeName" to the root tree.
  
-    NOTE: replace the call to strsep() with a call to strtok(), which conforms
-    to ANSI-C.
+NOTE: replace the call to strsep() with a call to strtok(), which conforms
+to ANSI-C.
  *****************************************************************************/
 static void componentAdd(const char *addNodeName,
                          int         level)
 {
-    int        i = 0;
-    char       name[strlen(addNodeName) + 1];
-    // buffer for writeable copy.
+    int        i = 0;                         // Loop index variable.
+    char       name[strlen(addNodeName) + 1]; // buffer for writeable copy.
     char      *pname=name;
     char      *firstComponent = NULL;       // first component of name
-    Component *currentNode = croot;
+    Component *currentNode = p_psCroot;
     int        nodeExists = 0;
 
     // Is this the root node?  If so, simply set level and return.
     if (strcmp(".", addNodeName) == 0) {
-        croot->level = level;
+        p_psCroot->level = level;
         return;
     }
@@ -199,5 +206,5 @@
 {
     // If the root component tree does not exist, then initialize it.
-    if (croot == NULL) {
+    if (p_psCroot == NULL) {
         initTrace();
     }
@@ -230,5 +237,5 @@
     char      *pname=name;
     char      *firstComponent = NULL;   // first component of name
-    Component *currentNode = croot;
+    Component *currentNode = p_psCroot;
     int        i = 0;
 
@@ -238,5 +245,5 @@
 
     if (strcmp(".", aname) == 0) {
-        return(croot->level);
+        return(p_psCroot->level);
     }
 
@@ -282,5 +289,5 @@
 int psTraceGetLevel(const char *name)
 {
-    if (croot == NULL) {
+    if (p_psCroot == NULL) {
         return(UNKNOWN_TRACE_LEVEL);
     }
@@ -328,35 +335,35 @@
 
 /*****************************************************************************
-    psPrintTraceLevels()
- Simply print all the trace levels in the trace level component tree.
-    Inputs:
- none
-    Outputs:
- none
-    Returns:
+psPrintTraceLevels(): Simply print all the trace levels in the trace level
+component tree.
+Inputs:
+ none
+Outputs:
+ none
+Returns:
  null
 *****************************************************************************/
 void psTracePrintLevels(void)
 {
-    if (croot == NULL) {
+    if (p_psCroot == NULL) {
         return;
     }
 
-    doPrintTraceLevels(croot, 0);
-}
-
-
-/*****************************************************************************
-    p_psTrace(): we display the trace message to standard output if the trace
- level of that message, supplied by the parameter "level" is higher
- than the trace level that is currently associated with the component
- named by the parameter "comp".
-    Input:
+    doPrintTraceLevels(p_psCroot, 0);
+}
+
+
+/*****************************************************************************
+p_psTrace(): we display the trace message to standard output if the trace
+level of that message, supplied by the parameter "level" is higher than the
+trace level that is currently associated with the component named by the
+parameter "comp".
+Input:
  comp
  level
  ...  a printf-style output string.
-    Output:
- none
-    Return:
+Output:
+ none
+Return:
  null
  *****************************************************************************/
@@ -384,10 +391,10 @@
         fmt = va_arg(ap, char *);
 
-        if (traceFP != NULL) {
+        if (p_psTraceFP != NULL) {
             // We indent each message one space for each level of the message.
             for (i = 0; i < level; i++) {
-                fprintf(traceFP, " ");
+                fprintf(p_psTraceFP, " ");
             }
-            vfprintf(traceFP, fmt, ap);
+            vfprintf(p_psTraceFP, fmt, ap);
         } else {
             // We indent each message one space for each level of the message.
@@ -405,4 +412,4 @@
 void psTraceSetDestination(FILE *fp)
 {
-    traceFP = fp;
-}
+    p_psTraceFP = fp;
+}
