Diff

Differences From Artifact [a6cd32cb12]:

To Artifact [ccb1bb4c78]:


31
32
33
34
35
36
37




38
39
40
41
42
43
44
..
56
57
58
59
60
61
62
63




64
65
66
67

68
69
70
71
72

73

74
75
76
77
78
79
80
81
82
83

84
85

86
87






88
89
90
91



92
93
94
95
96

97
98
99


100
101
102




103
104
105
106
107








108
109
110
111




112































113
114
115
116
117
118
119
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif

#ifdef HAVE_PWD_H
#include <pwd.h>
#endif





struct lc_varhandler_st *varhandlers = NULL;
lc_err_t lc_errno = LC_ERR_NONE;
const char *lc_err_usererrmsg = NULL;
const char *lc_errfile = NULL;
int lc_optind = 0;
int lc_errline = 0;
................................................................................
	return(0);
}

static int lc_process_var_cidr(void *data, const char *value, const char **endptr) {
	return(-1);
}

static int lc_process_var_addr4(uint32_t *data, const char *value, const char **endptr) {




	return(-1);
}

static int lc_process_var_addr6(void *data, const char *value, const char **endptr) {

	return(-1);
}

static int lc_process_var_hostname4(uint32_t *data, const char *value, const char **endptr) {
	return(-1);

}


static int lc_process_var_hostname6(void *data, const char *value, const char **endptr) {
	return(-1);
}

static int lc_process_var_ip6(void *data, const char *value, const char **endptr) {
	return(-1);
}

static int lc_process_var_ip4(uint32_t *data, const char *value, const char **endptr) {

	const char *dotptr = NULL;
	int tmpval = -1, retval = 0;


	dotptr = value;







	while (1) {
		tmpval = atoi(dotptr);
		if (tmpval < 0) {



			break;
		}

		retval <<= 8;
		retval |= tmpval;


		dotptr = strpbrk(dotptr, "./ \t");
		if (dotptr == NULL) {


			break;
		}
		if (*dotptr != '.') {




			break;
		}
		dotptr++;
	}









	*data = retval;

	*endptr = (char *) dotptr;





	return(0);































}

static int lc_process_var_longlong(long long *data, const char *value, const char **endptr) {
	*data = strtoll(value, (char **) endptr, 10);

	return(0);
}







>
>
>
>







 







|
>
>
>
>
|
|

<
>
|
|

<
<
>
|
>

<
|


|




>
|
|
>

|
>
>
>
>
>
>
|
<
<
<
>
>
>
|
|

|
|
>

<
<
>
>
|
|
<
>
>
>
>
|
|
<
|

>
>
>
>
>
>
>
>
|
|
<

>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
..
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

75
76
77
78


79
80
81
82

83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103



104
105
106
107
108
109
110
111
112
113


114
115
116
117

118
119
120
121
122
123

124
125
126
127
128
129
130
131
132
133
134
135

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif

#ifdef HAVE_PWD_H
#include <pwd.h>
#endif

#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif

struct lc_varhandler_st *varhandlers = NULL;
lc_err_t lc_errno = LC_ERR_NONE;
const char *lc_err_usererrmsg = NULL;
const char *lc_errfile = NULL;
int lc_optind = 0;
int lc_errline = 0;
................................................................................
	return(0);
}

static int lc_process_var_cidr(void *data, const char *value, const char **endptr) {
	return(-1);
}

static int lc_process_var_hostname4(uint32_t *data, const char *value, const char **endptr) {
	struct hostent *ghbn_ret;

	ghbn_ret = gethostbyname(value);
	if (ghbn_ret == NULL) {
		return(-1);
	}


	if (ghbn_ret->h_length != 4) {
		return(-1);
	}



	memcpy(data, ghbn_ret->h_addr_list[0], sizeof(*data));

	*data = ntohl(*data);


	return(0);
}

static int lc_process_var_hostname6(void *data, const char *value, const char **endptr) {
	return(-1);
}

static int lc_process_var_ip4(uint32_t *data, const char *value, const char **endptr) {
	uint32_t ipval = 0, curr_ipval = 0;
	const char *valptr;
	int retval = 0;
	int dotcount = 0;

	for (valptr = value; *valptr; valptr++) {
		if (!isdigit(*valptr)) {
			if (*valptr == '.' || *valptr == ',') {
				dotcount++;
				if (dotcount >= 4) {
					retval = -1;
					break;
				}




				if (curr_ipval > 255) {
					retval = -1;
					break;
				}

				ipval <<= 8;
				ipval |= curr_ipval;
				curr_ipval = 0;



				/* For lists */
				if (*valptr == ',') {
					break;
				}


				continue;
			} else {
				retval = -1;
				break;
			}

		}

		curr_ipval *= 10;
		curr_ipval += *valptr - '0';
	}

	if (retval == 0) {
		ipval <<= 8;
		ipval |= curr_ipval;

		*data = ipval;
	}


	return(retval);
}

static int lc_process_var_ip6(void *data, const char *value, const char **endptr) {
	return(-1);
}

static int lc_process_var_addr4(uint32_t *data, const char *value, const char **endptr) {
	int lc_pv_ret;

	lc_pv_ret = lc_process_var_ip4(data, value, endptr);
	if (lc_pv_ret == 0) {
		return(lc_pv_ret);
	}

	lc_pv_ret = lc_process_var_hostname4(data, value, endptr);
	if (lc_pv_ret == 0) {
		return(lc_pv_ret);
	}

	return(-1);
}

static int lc_process_var_addr6(void *data, const char *value, const char **endptr) {
	int lc_pv_ret;

	lc_pv_ret = lc_process_var_ip6(data, value, endptr);
	if (lc_pv_ret == 0) {
		return(lc_pv_ret);
	}

	lc_pv_ret = lc_process_var_hostname6(data, value, endptr);
	if (lc_pv_ret == 0) {
		return(lc_pv_ret);
	}
	return(-1);
}

static int lc_process_var_longlong(long long *data, const char *value, const char **endptr) {
	*data = strtoll(value, (char **) endptr, 10);

	return(0);
}