Check-in [495af83ca7]
Overview
Comment:Updated documentation to reflect addition of addr and hostname var types Updated addr and hostname types to be in network byte order
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 495af83ca76266f7b585bfa63fad2a91ee4365ff
User & Date: rkeene on 2006-12-17 15:30:30
Other Links: manifest | tags
Context
2006-12-17
19:15
libconfig 0.2.0 released check-in: f205c925b8 user: rkeene tags: trunk, 0.2.0
15:30
Updated documentation to reflect addition of addr and hostname var types Updated addr and hostname types to be in network byte order check-in: 495af83ca7 user: rkeene tags: trunk
03:48
Removed attempts to set lc_errno to NONE check-in: 8e434a0cbf user: rkeene tags: trunk
Changes

Modified lc_register_var.3.in from [26c717cf6a] to [218061b43e].

    79     79   LC_VAR_BOOL_BY_EXISTANCE
    80     80   This type of variable takes no arguments, it is set to true (1) by its existance in a configuration file, environment variable, or on the command line.  If it is not specified, the value of the data passed is not changed.  The data passed should be of type "int *".
    81     81   .TP
    82     82   LC_VAR_CIDR
    83     83   This type of variable accepts a CIDR format netmask and IP.  This is not yet implemented. (XXX)
    84     84   .TP
    85     85   LC_VAR_IP
    86         -This type of variable accepts an IP address in decimal-dot format.  The value is stored in a uint32_t.
           86  +This type of variable accepts an IP address in decimal-dot format.  The value is stored in a uint32_t in network byte order.
           87  +.TP
           88  +LC_VAR_HOSTNAME
           89  +This type of variable accepts an address in hostname format.  The value is stored in a uint32_t in network byte order.
    87     90   .TP
    88     91   LC_VAR_ADDR
    89         -This type of variable accepts an address in either host or decimal-dot format.  The value is stored in a uint32_t.  This is not yet implemented. (XXX)
           92  +This type of variable accepts an address in either hostname or decimal-dot format.  The value is stored in a uint32_t in network byte order.
    90     93   
    91     94   .SH "RETURN VALUE"
    92     95   On success 0 is returned, otherwise -1 is returned.
    93     96   
    94     97   .SH EXAMPLE
    95     98   .nf
    96     99   #include <libconfig.h>

Modified libconfig.c from [b750f5ace4] to [41938c6e31].

    71     71   	if (ghbn_ret == NULL) {
    72     72   		return(-1);
    73     73   	}
    74     74   
    75     75   	if (ghbn_ret->h_length != 4) {
    76     76   		return(-1);
    77     77   	}
           78  +
           79  +	if (ghbn_ret->h_addr_list[0] == 0) {
           80  +		return(-1);
           81  +	}
    78     82   
    79     83   	memcpy(data, ghbn_ret->h_addr_list[0], sizeof(*data));
    80     84   
    81         -	*data = ntohl(*data);
    82         -
    83     85   	return(0);
    84     86   }
    85     87   
    86     88   static int lc_process_var_hostname6(void *data, const char *value, const char **endptr) {
    87     89   	return(-1);
    88     90   }
    89     91   
................................................................................
   103    105   				}
   104    106   
   105    107   				if (curr_ipval > 255) {
   106    108   					retval = -1;
   107    109   					break;
   108    110   				}
   109    111   
   110         -				ipval <<= 8;
   111         -				ipval |= curr_ipval;
   112         -				curr_ipval = 0;
   113         -
   114    112   				/* For lists */
   115    113   				if (*valptr == ',') {
   116    114   					break;
   117    115   				}
          116  +
          117  +				ipval |= curr_ipval << ((dotcount - 1) * 8);
          118  +				curr_ipval = 0;
   118    119   
   119    120   				continue;
   120    121   			} else {
   121    122   				retval = -1;
   122    123   				break;
   123    124   			}
   124    125   		}
   125    126   
   126    127   		curr_ipval *= 10;
   127    128   		curr_ipval += *valptr - '0';
   128    129   	}
          130  +
          131  +	if (curr_ipval > 255) {
          132  +		retval = -1;
          133  +	}
   129    134   
   130    135   	if (retval == 0) {
   131         -		ipval <<= 8;
   132         -		ipval |= curr_ipval;
   133         -
          136  +		ipval |= curr_ipval << 24;
   134    137   		*data = ipval;
   135    138   	}
   136    139   
   137    140   	return(retval);
   138    141   }
   139    142   
   140    143   static int lc_process_var_ip6(void *data, const char *value, const char **endptr) {