Project

General

Profile

Feature #1966 » lighttpd-1.4.x-add-T_CONFIG_INT.patch

adds T_CONFIG_INT (code duplicated from T_CONFIG_SHORT) - virbyte, 2009-06-16 13:11

View differences:

src/configfile-glue.c (working copy)
116 116
				return -1;
117 117
			}
118 118
			break;
119
		case T_CONFIG_INT:
120
			switch(du->type) {
121
			case TYPE_INTEGER: {
122
				data_integer *di = (data_integer *)du;
123

  
124
				*((unsigned int *)(cv[i].destination)) = di->value;
125
				break;
126
			}
127
			case TYPE_STRING: {
128
				data_string *ds = (data_string *)du;
129

  
130
				/* If the value came from an environment variable, then it is a
131
				 * data_string, although it may contain a number in ASCII
132
				 * decimal format.  We try to interpret the string as a decimal
133
				 * int before giving up, in order to support setting numeric
134
				 * values with environment variables (eg, port number).
135
				 */
136
				if (ds->value->ptr && *ds->value->ptr) {
137
					char *e;
138
					long l = strtol(ds->value->ptr, &e, 10);
139
					if (e != ds->value->ptr && !*e && l >=0 && l <= 65535) {
140
						*((unsigned int *)(cv[i].destination)) = l;
141
						break;
142

  
143
					}
144
				}
145

  
146
				log_error_write(srv, __FILE__, __LINE__, "ssb", "got a string but expected an int:", cv[i].key, ds->value);
147

  
148
				return -1;
149
			}
150
			default:
151
				log_error_write(srv, __FILE__, __LINE__, "ssds", "unexpected type for key:", cv[i].key, du->type, "expected a integer, range 0 ... 65535");
152
				return -1;
153
			}
154
			break;
119 155
		case T_CONFIG_BOOLEAN:
120 156
			if (du->type == TYPE_STRING) {
121 157
				data_string *ds = (data_string *)du;
src/base.h (working copy)
84 84
typedef enum { T_CONFIG_UNSET,
85 85
		T_CONFIG_STRING,
86 86
		T_CONFIG_SHORT,
87
		T_CONFIG_INT,
87 88
		T_CONFIG_BOOLEAN,
88 89
		T_CONFIG_ARRAY,
89 90
		T_CONFIG_LOCAL,
(2-2/4)