OSSP CVS Repository

ossp - Difference in ossp-pkg/cfg/cfg_syn.c versions 1.17 and 1.18
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/cfg/cfg_syn.c 1.17 -> 1.18

--- cfg_syn.c    2004/07/17 07:37:55     1.17
+++ cfg_syn.c    2004/11/20 12:02:32     1.18
@@ -25,7 +25,7 @@
 **  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 **  SUCH DAMAGE.
 **
-**  cfg_syn.c: syntax parsing
+**  cfg_syn.c: syntax parsing and formatting
 */
 
 #include <stdio.h>
@@ -170,12 +170,14 @@
     return;
 }
 
+/* internal cfg_syn_export structure */
 typedef struct {
     cfg_t *cfg;
     cfg_buf_t *buf;
     int indent;
 } export_t;
 
+/* internal cfg_syn_export helper function: sprintf(3) style output formatting */
 static void export_format(export_t *ctx, char *fmt, ...)
 {
     int i;
@@ -201,6 +203,7 @@
     return;
 }
 
+/* internal cfg_syn_export helper function: indentation handling */
 static void export_indent(export_t *ctx, signed int n)
 {
     if (n > 0) {
@@ -219,6 +222,7 @@
     }
 }
 
+/* internal cfg_syn_export helper function: token output formatting */
 static void export_token(export_t *ctx, const char *token)
 {
     const char *cp;
@@ -264,6 +268,7 @@
     return;
 }
 
+/* internal cfg_syn_export helper function: recursive node processing */
 static void export_node(export_t *ctx, cfg_node_t *node)
 {
     cfg_node_type_t type;
@@ -274,20 +279,22 @@
     if ((rc = cfg_node_get(ctx->cfg, node, CFG_NODE_ATTR_TYPE, &type)) != CFG_OK)
         return;
     if (type == CFG_NODE_TYPE_SEQ) {
+        /* node is a sequence */
         export_format(ctx, "{\n");
         export_indent(ctx, 1);
         cfg_node_get(ctx->cfg, node, CFG_NODE_ATTR_CHILD1, &node2);
         while (node2 != NULL) {
-            export_node(ctx, node2);
+            export_node(ctx, node2); /* recursion */
             cfg_node_get(ctx->cfg, node2, CFG_NODE_ATTR_RBROTH, &node2);
         }
         export_indent(ctx, -1);
         export_format(ctx, "}");
     }
     else if (type == CFG_NODE_TYPE_DIR) {
+        /* node is a directive */
         cfg_node_get(ctx->cfg, node, CFG_NODE_ATTR_CHILD1, &node2);
         while (node2 != NULL) {
-            export_node(ctx, node2);
+            export_node(ctx, node2); /* recursion */
             cfg_node_get(ctx->cfg, node2, CFG_NODE_ATTR_RBROTH, &node2);
             if (node2 != NULL)
                 export_format(ctx, " ");
@@ -298,6 +305,7 @@
         export_format(ctx, "\n");
     }
     else if (type == CFG_NODE_TYPE_ARG) {
+        /* node is a token */
         cfg_node_get(ctx->cfg, node, CFG_NODE_ATTR_TOKEN, &token);
         if (token != NULL)
             export_token(ctx, token);
@@ -307,6 +315,7 @@
     return;
 }
 
+/* export configuration node tree into textual OSSP cfg syntax */
 cfg_rc_t cfg_syn_export(
     cfg_t *cfg,
     cfg_node_t *node,
@@ -348,18 +357,20 @@
     return CFG_OK;
 }
 
+/* internal cfg_syn_destroy helper function: recursive node destruction */
 static cfg_rc_t cfg_syn_destroy_node(cfg_t *cfg, cfg_node_t *node)
 {
     if (node == NULL)
         return CFG_ERR_ARG;
     if (node->child1 != NULL)
-        cfg_syn_destroy_node(cfg, node->child1);
+        cfg_syn_destroy_node(cfg, node->child1); /* recursion */
     if (node->rbroth != NULL)
-        cfg_syn_destroy_node(cfg, node->rbroth);
+        cfg_syn_destroy_node(cfg, node->rbroth); /* recursion */
     cfg_node_destroy(cfg, node);
     return CFG_OK;
 }
 
+/* destroy syntax node tree */
 cfg_rc_t cfg_syn_destroy(cfg_t *cfg, cfg_node_t *node)
 {
     if (node == NULL)

CVSTrac 2.0.1