* fixed the formatting - both in the source and in the generated config
authorBernd Petrovitsch <bernd@firmix.at>
Tue, 11 Nov 2008 14:43:18 +0000 (15:43 +0100)
committerBernd Petrovitsch <bernd@firmix.at>
Tue, 11 Nov 2008 14:43:18 +0000 (15:43 +0100)
src/cfgparser/cfgfile_gen.c

index 87496c7..cf1212a 100644 (file)
@@ -89,29 +89,29 @@ olsrd_write_cnf_buf(struct autobuf *abuf, const struct olsrd_config *cnf, olsr_b
   char ipv6_buf[INET6_ADDRSTRLEN];             /* buffer for IPv6 inet_ntop */
 
   abuf_appendf(abuf, "#\n"
-                        "# Configuration file for %s\n"
-                        "# automatically generated by olsrd-cnf parser v.  %s\n"
-                        "#\n\n", olsrd_version, PARSER_VERSION);
+                     "# Configuration file for %s\n"
+                     "# automatically generated by olsrd-cnf parser v.  %s\n"
+                     "#\n\n", olsrd_version, PARSER_VERSION);
 
   /* Debug level */
   abuf_appendf(abuf, "# Debug level(0-9)\n"
-                        "# If set to 0 the daemon runs in the background\n"
-                        "DebugLevel\t%d\n\n", cnf->debug_level);
+                     "# If set to 0 the daemon runs in the background\n"
+                     "DebugLevel\t%d\n\n", cnf->debug_level);
 
   /* IP version */
   abuf_appendf(abuf, "# IP version to use (4 or 6)\n"
-                        "IpVersion\t%d\n\n", cnf->ip_version == AF_INET ? 4 : 6);
+                     "IpVersion\t%d\n\n", cnf->ip_version == AF_INET ? 4 : 6);
 
   /* FIB Metric */
   abuf_appendf(abuf, "# FIBMetric (\"%s\", \"%s\", or \"%s\")\n"
-                        "FIBMetric\t\"%s\"\n\n",
-                        CFG_FIBM_FLAT, CFG_FIBM_CORRECT, CFG_FIBM_APPROX,
-                        FIBM_FLAT == cnf->fib_metric ? CFG_FIBM_FLAT : FIBM_CORRECT == cnf->fib_metric ? CFG_FIBM_CORRECT : CFG_FIBM_APPROX);
+                     "FIBMetric\t\"%s\"\n\n",
+                     CFG_FIBM_FLAT, CFG_FIBM_CORRECT, CFG_FIBM_APPROX,
+                     FIBM_FLAT == cnf->fib_metric ? CFG_FIBM_FLAT : FIBM_CORRECT == cnf->fib_metric ? CFG_FIBM_CORRECT : CFG_FIBM_APPROX);
 
   /* HNA IPv4/IPv6 */
   abuf_appendf(abuf, "# HNA IPv%d routes\n"
-                        "# syntax: netaddr/prefix\n"
-                        "Hna%d {\n", cnf->ip_version == AF_INET ? 4 : 6, cnf->ip_version == AF_INET ? 4 : 6);
+                     "# syntax: netaddr/prefix\n"
+                     "Hna%d {\n", cnf->ip_version == AF_INET ? 4 : 6, cnf->ip_version == AF_INET ? 4 : 6);
   if (cnf->hna_entries) {
     struct ip_prefix_list *h;
     for (h  = cnf->hna_entries; h != NULL; h = h->next) {
@@ -123,34 +123,34 @@ olsrd_write_cnf_buf(struct autobuf *abuf, const struct olsrd_config *cnf, olsr_b
 
   /* No interfaces */
   abuf_appendf(abuf, "# Should olsrd keep on running even if there are\n"
-                        "# no interfaces available? This is a good idea\n"
-                        "# for a PCMCIA/USB hotswap environment.\n"
-                        "# \"yes\" OR \"no\"\n"
-                        "AllowNoInt\t%s\n\n", cnf->allow_no_interfaces ? "yes" : "no");
+                     "# no interfaces available? This is a good idea\n"
+                     "# for a PCMCIA/USB hotswap environment.\n"
+                     "# \"yes\" OR \"no\"\n"
+                     "AllowNoInt\t%s\n\n", cnf->allow_no_interfaces ? "yes" : "no");
 
   /* TOS */
   abuf_appendf(abuf, "# TOS(type of service) to use. Default is 16\n"
-                         "TosValue\t%d\n\n", cnf->tos);
+                      "TosValue\t%d\n\n", cnf->tos);
 
   /* RtTable */
   abuf_appendf(abuf, "# Policy Routing Table to use. Default is 254\n"
-                        "RtTable\t\t%d\n\n", cnf->rttable);
+                     "RtTable\t\t%d\n\n", cnf->rttable);
 
   /* RtTableDefault */
   abuf_appendf(abuf, "# Policy Routing Table to use for the default Route. Default is 0 (Take the same table as specified by RtTable)\n"
-                        "RtTableDefault\t\t%d\n\n", cnf->rttable_default);
+                     "RtTableDefault\t\t%d\n\n", cnf->rttable_default);
 
   /* Willingness */
   abuf_appendf(abuf, "# The fixed willingness to use(0-7)\n"
-                        "# If not set willingness will be calculated\n"
-                        "# dynammically based on battery/power status\n"
-                        "%sWillingness\t%d\n\n", cnf->willingness_auto ? "#" : "", cnf->willingness_auto ? 4 : cnf->willingness);
+                     "# If not set willingness will be calculated\n"
+                     "# dynammically based on battery/power status\n"
+                     "%sWillingness\t%d\n\n", cnf->willingness_auto ? "#" : "", cnf->willingness_auto ? 4 : cnf->willingness);
 
   /* IPC */
   abuf_appendf(abuf, "# Allow processes like the GUI front-end\n"
-                        "# to connect to the daemon.\n"
-                        "IpcConnect {\n"
-                        "    MaxConnections\t%d\n", cnf->ipc_connections);
+                     "# to connect to the daemon.\n"
+                     "IpcConnect {\n"
+                     "    MaxConnections\t%d\n", cnf->ipc_connections);
 
   if (cnf->ipc_nets) {
     struct ip_prefix_list *ie;
@@ -169,90 +169,90 @@ olsrd_write_cnf_buf(struct autobuf *abuf, const struct olsrd_config *cnf, olsr_b
 
   /* Hysteresis */
   abuf_appendf(abuf, "# Hysteresis adds more robustness to the\n"
-                        "# link sensing.\n"
-                        "# Used by default. 'yes' or 'no'\n"
-                        "UseHysteresis\t%s\n\n", cnf->use_hysteresis ? "yes" : "no");
+                     "# link sensing.\n"
+                     "# Used by default. 'yes' or 'no'\n"
+                     "UseHysteresis\t%s\n\n", cnf->use_hysteresis ? "yes" : "no");
 
   abuf_appendf(abuf, "# Hysteresis parameters\n"
-                        "# Do not alter these unless you know \n"
-                        "# what you are doing!\n"
-                        "# Set to auto by default. Allowed\n"
-                        "# values are floating point values\n"
-                        "# in the interval 0,1\n"
-                        "# THR_LOW must always be lower than\n"
-                        "# THR_HIGH!!\n"
-                        "%sHystScaling\t%0.2f\n"
-                        "%sHystThrHigh\t%0.2f\n"
-                        "%sHystThrLow\t%0.2f\n\n",
-                        cnf->use_hysteresis ? "#" : "", cnf->hysteresis_param.scaling,
-                        cnf->use_hysteresis ? "#" : "", cnf->hysteresis_param.thr_high,
-                        cnf->use_hysteresis ? "#" : "", cnf->hysteresis_param.thr_low);
+                     "# Do not alter these unless you know \n"
+                     "# what you are doing!\n"
+                     "# Set to auto by default. Allowed\n"
+                     "# values are floating point values\n"
+                     "# in the interval 0,1\n"
+                     "# THR_LOW must always be lower than\n"
+                     "# THR_HIGH!!\n"
+                     "%sHystScaling\t%0.2f\n"
+                     "%sHystThrHigh\t%0.2f\n"
+                     "%sHystThrLow\t%0.2f\n\n",
+                     cnf->use_hysteresis ? "#" : "", cnf->hysteresis_param.scaling,
+                     cnf->use_hysteresis ? "#" : "", cnf->hysteresis_param.thr_high,
+                     cnf->use_hysteresis ? "#" : "", cnf->hysteresis_param.thr_low);
 
   /* Pollrate */
   abuf_appendf(abuf, "# Polling rate in seconds(float).\n"
-                        "# Auto uses default value 0.05 sec\n"
-                        "Pollrate\t%0.2f\n", conv_pollrate_to_secs(cnf->pollrate));
+                     "# Auto uses default value 0.05 sec\n"
+                     "Pollrate\t%0.2f\n", conv_pollrate_to_secs(cnf->pollrate));
 
   /* NIC Changes Pollrate */
   abuf_appendf(abuf, "# Interval to poll network interfaces for configuration\n"
-                        "# changes. Defaults to 2.5 seconds\n"
-                        "NicChgsPollInt\t%0.2f\n", cnf->nic_chgs_pollrate);
+                     "# changes. Defaults to 2.5 seconds\n"
+                     "NicChgsPollInt\t%0.2f\n", cnf->nic_chgs_pollrate);
 
   /* TC redundancy */
   abuf_appendf(abuf, "# TC redundancy\n"
-                        "# Specifies how much neighbor info should\n"
-                        "# be sent in TC messages\n"
-                        "# Possible values are:\n"
-                        "# 0 - only send MPR selectors\n"
-                        "# 1 - send MPR selectors and MPRs\n"
-                        "# 2 - send all neighbors\n"
-                        "# defaults to 0\n"
-                        "TcRedundancy\t%d\n\n", cnf->tc_redundancy);
+                     "# Specifies how much neighbor info should\n"
+                     "# be sent in TC messages\n"
+                     "# Possible values are:\n"
+                     "# 0 - only send MPR selectors\n"
+                     "# 1 - send MPR selectors and MPRs\n"
+                     "# 2 - send all neighbors\n"
+                     "# defaults to 0\n"
+                     "TcRedundancy\t%d\n\n", cnf->tc_redundancy);
 
   /* MPR coverage */
   abuf_appendf(abuf, "# MPR coverage\n"
-                        "# Specifies how many MPRs a node should\n"
-                        "# try select to reach every 2 hop neighbor\n"
-                        "# Can be set to any integer >0\n"
-                        "# defaults to 1\n"
-                        "MprCoverage\t%d\n\n", cnf->mpr_coverage);
+                     "# Specifies how many MPRs a node should\n"
+                     "# try select to reach every 2 hop neighbor\n"
+                     "# Can be set to any integer >0\n"
+                     "# defaults to 1\n"
+                     "MprCoverage\t%d\n\n", cnf->mpr_coverage);
 
   abuf_appendf(abuf, "# Link quality level\n"
-                        "# 0 = do not use link quality\n"
-                        "# 1 = use link quality for MPR selection\n"
-                        "# 2 = use link quality for MPR selection and routing\n"
-                        "LinkQualityLevel\t%d\n\n", cnf->lq_level);
+                     "# 0 = do not use link quality\n"
+                     "# 1 = use link quality for MPR selection\n"
+                     "# 2 = use link quality for MPR selection and routing\n"
+                     "LinkQualityLevel\t%d\n\n", cnf->lq_level);
 
   abuf_appendf(abuf, "# Fish Eye algorithm\n"
-                        "# 0 = do not use fish eye\n"
-                        "# 1 = use fish eye\n"
-                        "LinkQualityFishEye\t%d\n\n", cnf->lq_fish);
+                     "# 0 = do not use fish eye\n"
+                     "# 1 = use fish eye\n"
+                     "LinkQualityFishEye\t%d\n\n", cnf->lq_fish);
 
   if (cnf->lq_algorithm != NULL) {
     abuf_appendf(abuf, "# Link quality algorithm (if LinkQualityLevel > 0)\n"
-                          "# etx_fpm (hello loss, fixed point math)\n"
-                          "# etx_float (hello loss, floating point)\n"
-                          "# etx_ff (packet loss for freifunk compat)\n"
-                          "LinkQualityAlgorithm\t\"%s\"\n\n", cnf->lq_algorithm);
+                       "# etx_fpm (hello loss, fixed point math)\n"
+                       "# etx_float (hello loss, floating point)\n"
+                       "# etx_ff (packet loss for freifunk compat)\n"
+                       "LinkQualityAlgorithm\t\"%s\"\n\n", cnf->lq_algorithm);
   }
 
   abuf_appendf(abuf, "# Link quality aging factor\n"
-                        "LinkQualityAging\t%f\n\n", cnf->lq_aging);
+                     "LinkQualityAging\t%f\n\n", cnf->lq_aging);
 
   abuf_appendf(abuf, "# NAT threshold\n"
-                        "NatThreshold\t%f\n\n", cnf->lq_nat_thresh);
+                     "NatThreshold\t%f\n\n", cnf->lq_nat_thresh);
 
   abuf_appendf(abuf, "# Clear screen when printing debug output?\n"
-                        "ClearScreen\t%s\n\n", cnf->clear_screen ? "yes" : "no");
+                     "ClearScreen\t%s\n\n", cnf->clear_screen ? "yes" : "no");
 
   /* Plugins */
   abuf_appendf(abuf, "# Olsrd plugins to load\n"
-                        "# This must be the absolute path to the file\n"
-                        "# or the loader will use the following scheme:\n"
-                        "# - Try the paths in the LD_LIBRARY_PATH \n"
-                        "#   environment variable.\n"
-                        "# - The list of libraries cached in /etc/ld.so.cache\n"
-                        "# - /lib, followed by /usr/lib\n\n");
+                     "# This must be the absolute path to the file\n"
+                     "# or the loader will use the following scheme:\n"
+                     "# - Try the paths in the LD_LIBRARY_PATH \n"
+                     "#   environment variable.\n"
+                     "# - The list of libraries cached in /etc/ld.so.cache\n"
+                     "# - /lib, followed by /usr/lib\n\n");
   if (cnf->plugins) {
     struct plugin_entry *pe;
     for (pe = cnf->plugins; pe != NULL; pe = pe->next) {
@@ -268,9 +268,9 @@ olsrd_write_cnf_buf(struct autobuf *abuf, const struct olsrd_config *cnf, olsr_b
 
   /* Interfaces */
   abuf_appendf(abuf, "# Interfaces\n"
-                        "# Multiple interfaces with the same configuration\n"
-                        "# can shar the same config block. Just list the\n"
-                        "# interfaces(e.g. Interface \"eth0\" \"eth2\"\n");
+                     "# Multiple interfaces with the same configuration\n"
+                     "# can shar the same config block. Just list the\n"
+                     "# interfaces(e.g. Interface \"eth0\" \"eth2\"\n");
   /* Interfaces */
   if (cnf->interfaces) {
     struct olsr_if *in;
@@ -282,9 +282,9 @@ olsrd_write_cnf_buf(struct autobuf *abuf, const struct olsrd_config *cnf, olsr_b
 
       if (first) {
         abuf_appendf(abuf, "    # IPv4 broadcast address to use. The\n"
-                              "    # one usefull example would be 255.255.255.255\n"
-                              "    # If not defined the broadcastaddress\n"
-                              "    # every card is configured with is used\n\n");
+                           "    # one usefull example would be 255.255.255.255\n"
+                           "    # If not defined the broadcastaddress\n"
+                           "    # every card is configured with is used\n\n");
       }
 
       if (in->cnf->ipv4_broadcast.v4.s_addr) {
@@ -295,35 +295,35 @@ olsrd_write_cnf_buf(struct autobuf *abuf, const struct olsrd_config *cnf, olsr_b
           
       if (first) {
         abuf_appendf(abuf, "\n    # IPv6 address scope to use.\n"
-                              "    # Must be 'site-local' or 'global'\n\n");
+                           "    # Must be 'site-local' or 'global'\n\n");
       }
       abuf_appendf(abuf, "    Ip6AddrType \t%s\n", in->cnf->ipv6_addrtype ? "site-local" : "global");
 
       if (first) {
         abuf_appendf(abuf, "\n"
-                              "    # IPv6 multicast address to use when\n"
-                              "    # using site-local addresses.\n"
-                              "    # If not defined, ff05::15 is used\n");
+                           "    # IPv6 multicast address to use when\n"
+                           "    # using site-local addresses.\n"
+                           "    # If not defined, ff05::15 is used\n");
       }
       abuf_appendf(abuf, "    Ip6MulticastSite\t%s\n", inet_ntop(AF_INET6, &in->cnf->ipv6_multi_site.v6, ipv6_buf, sizeof(ipv6_buf)));
       if (first) {
         abuf_appendf(abuf, "\n    # IPv6 multicast address to use when\n"
-                              "    # using global addresses\n"
-                              "    # If not defined, ff0e::1 is used\n");
+                           "    # using global addresses\n"
+                           "    # If not defined, ff0e::1 is used\n");
       }
       abuf_appendf(abuf, "    Ip6MulticastGlobal\t%s\n", inet_ntop(AF_INET6, &in->cnf->ipv6_multi_glbl.v6, ipv6_buf, sizeof(ipv6_buf)));
       if (first) {
         abuf_appendf(abuf, "\n");
       }
       abuf_appendf(abuf, "    # Olsrd can autodetect changes in\n"
-                            "    # interface configurations. Enabled by default\n"
-                            "    # turn off to save CPU.\n"
-                            "    AutoDetectChanges: %s\n", in->cnf->autodetect_chg ? "yes" : "no");
+                         "    # interface configurations. Enabled by default\n"
+                         "    # turn off to save CPU.\n"
+                         "    AutoDetectChanges: %s\n\n", in->cnf->autodetect_chg ? "yes" : "no");
 
       if (first) {
         abuf_appendf(abuf, "    # Emission and validity intervals.\n"
-                              "    # If not defined, RFC proposed values will\n"
-                              "    # in most cases be used.\n\n");
+                           "    # If not defined, RFC proposed values will\n"
+                           "    # in most cases be used.\n");
       }
       append_float(abuf, "HelloInterval", in->cnf->hello_params.emission_interval, HELLO_INTERVAL, first);
       append_float(abuf, "HelloValidityTime", in->cnf->hello_params.validity_time, NEIGHB_HOLD_TIME, first);
@@ -339,22 +339,24 @@ olsrd_write_cnf_buf(struct autobuf *abuf, const struct olsrd_config *cnf, olsr_b
       } else {
         struct olsr_lq_mult *mult;
         for (mult = in->cnf->lq_mult; mult != NULL; mult = mult->next) {
-          abuf_appendf(abuf, "    LinkQualityMult\t%s %0.2f\n", inet_ntop(cnf->ip_version, &mult->addr, ipv6_buf, sizeof(ipv6_buf)), (float)mult->value / 65536.0);
+          abuf_appendf(abuf, "    LinkQualityMult\t%s %0.2f\n",
+                            inet_ntop(cnf->ip_version, &mult->addr, ipv6_buf, sizeof(ipv6_buf)),
+                            (float)mult->value / 65536.0);
         }
       }
 
       if (first) {
         abuf_appendf(abuf, "    # When multiple links exist between hosts\n"
-                              "    # the weight of interface is used to determine\n"
-                              "    # the link to use. Normally the weight is\n"
-                              "    # automatically calculated by olsrd based\n"
-                              "    # on the characteristics of the interface,\n"
-                              "    # but here you can specify a fixed value.\n"
-                              "    # Olsrd will choose links with the lowest value.\n"
-                              "    # Note:\n"
-                              "    # Interface weight is used only when LinkQualityLevel is 0.\n"
-                              "    # For any other value of LinkQualityLevel, the interface ETX\n"
-                              "    # value is used instead.\n\n");
+                           "    # the weight of interface is used to determine\n"
+                           "    # the link to use. Normally the weight is\n"
+                           "    # automatically calculated by olsrd based\n"
+                           "    # on the characteristics of the interface,\n"
+                           "    # but here you can specify a fixed value.\n"
+                           "    # Olsrd will choose links with the lowest value.\n"
+                           "    # Note:\n"
+                           "    # Interface weight is used only when LinkQualityLevel is 0.\n"
+                           "    # For any other value of LinkQualityLevel, the interface ETX\n"
+                           "    # value is used instead.\n\n");
       }
       if (in->cnf->weight.fixed) {
         abuf_appendf(abuf, "    Weight\t %d\n", in->cnf->weight.value);