1 /*
2 +----------------------------------------------------------------------+
3 | PHP Version 7 |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1997-2018 The PHP Group |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
15 | Author: Georg Richter <georg@php.net> |
16 | Andrey Hristov <andrey@php.net> |
17 +----------------------------------------------------------------------+
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <signal.h>
25
26 #include "php.h"
27 #include "php_ini.h"
28 #include "ext/standard/info.h"
29 #include "php_mysqli_structs.h"
30 #include "mysqli_priv.h"
31
32 #define CHECK_STATUS(value) \
33 if (!obj->ptr || ((MYSQLI_RESOURCE *)obj->ptr)->status < value ) { \
34 php_error_docref(NULL, E_WARNING, "Property access is not allowed yet"); \
35 ZVAL_NULL(retval); \
36 return retval; \
37 } \
38
39 #define MYSQLI_GET_MYSQL(statusval) \
40 MYSQL *p; \
41 if (!obj->ptr || !(MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { \
42 php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));\
43 ZVAL_NULL(retval);\
44 return retval; \
45 } else { \
46 CHECK_STATUS(statusval);\
47 p = (MYSQL *)((MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->mysql;\
48 }
49
50 #define MYSQLI_GET_RESULT(statusval) \
51 MYSQL_RES *p; \
52 if (!obj->ptr) { \
53 php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));\
54 ZVAL_NULL(retval);\
55 return retval; \
56 } else { \
57 CHECK_STATUS(statusval);\
58 p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr; \
59 }
60
61
62 #define MYSQLI_GET_STMT(statusval) \
63 MYSQL_STMT *p; \
64 if (!obj->ptr) { \
65 php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));\
66 ZVAL_NULL(retval);\
67 return retval; \
68 } else { \
69 CHECK_STATUS(statusval);\
70 p = (MYSQL_STMT *)((MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->stmt;\
71 }
72
73 #define MYSQLI_MAP_PROPERTY_FUNC_LONG( __func, __int_func, __get_type, __ret_type, __ret_type_sprint_mod)\
74 static zval *__func(mysqli_object *obj, zval *retval) \
75 {\
76 __ret_type l;\
77 __get_type;\
78 if (!p) {\
79 ZVAL_NULL(retval);\
80 } else {\
81 l = (__ret_type)__int_func(p);\
82 if (l < ZEND_LONG_MAX) {\
83 ZVAL_LONG(retval, (zend_long) l);\
84 } else { \
85 ZVAL_NEW_STR(retval, strpprintf(0, __ret_type_sprint_mod, l)); \
86 } \
87 }\
88 return retval;\
89 }
90
91 #define MYSQLI_MAP_PROPERTY_FUNC_STRING(__func, __int_func, __get_type)\
92 static zval *__func(mysqli_object *obj, zval *retval)\
93 {\
94 char *c;\
95 __get_type;\
96 if (!p) {\
97 ZVAL_NULL(retval);\
98 } else {\
99 c = (char *)__int_func(p);\
100 if (!c) {\
101 ZVAL_NULL(retval);\
102 } else {\
103 ZVAL_STRING(retval, c);\
104 }\
105 }\
106 return retval; \
107 }
108
109 /* {{{ property link_client_version_read */
link_client_version_read(mysqli_object * obj,zval * retval)110 static zval *link_client_version_read(mysqli_object *obj, zval *retval)
111 {
112 ZVAL_LONG(retval, MYSQL_VERSION_ID);
113 return retval;
114 }
115 /* }}} */
116
117 /* {{{ property link_client_info_read */
link_client_info_read(mysqli_object * obj,zval * retval)118 static zval *link_client_info_read(mysqli_object *obj, zval *retval)
119 {
120 CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
121 ZVAL_STRING(retval, MYSQL_SERVER_VERSION);
122 return retval;
123 }
124 /* }}} */
125
126 /* {{{ property link_connect_errno_read */
link_connect_errno_read(mysqli_object * obj,zval * retval)127 static zval *link_connect_errno_read(mysqli_object *obj, zval *retval)
128 {
129 ZVAL_LONG(retval, (zend_long)MyG(error_no));
130 return retval;
131 }
132 /* }}} */
133
134 /* {{{ property link_connect_error_read */
link_connect_error_read(mysqli_object * obj,zval * retval)135 static zval *link_connect_error_read(mysqli_object *obj, zval *retval)
136 {
137 if (MyG(error_msg)) {
138 ZVAL_STRING(retval, MyG(error_msg));
139 } else {
140 ZVAL_NULL(retval);
141 }
142 return retval;
143 }
144 /* }}} */
145
146 /* {{{ property link_affected_rows_read */
link_affected_rows_read(mysqli_object * obj,zval * retval)147 static zval *link_affected_rows_read(mysqli_object *obj, zval *retval)
148 {
149 MY_MYSQL *mysql;
150 my_ulonglong rc;
151
152 CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
153
154 mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
155
156 if (!mysql) {
157 ZVAL_NULL(retval);
158 } else {
159 CHECK_STATUS(MYSQLI_STATUS_VALID);
160
161 rc = mysql_affected_rows(mysql->mysql);
162
163 if (rc == (my_ulonglong) -1) {
164 ZVAL_LONG(retval, -1);
165 return retval;
166 }
167
168 if (rc < ZEND_LONG_MAX) {
169 ZVAL_LONG(retval, (zend_long) rc);
170 } else {
171 ZVAL_NEW_STR(retval, strpprintf(0, MYSQLI_LLU_SPEC, rc));
172 }
173 }
174 return retval;
175 }
176 /* }}} */
177
178 /* {{{ property link_error_list_read */
link_error_list_read(mysqli_object * obj,zval * retval)179 static zval *link_error_list_read(mysqli_object *obj, zval *retval)
180 {
181 MY_MYSQL *mysql;
182
183 CHECK_STATUS(MYSQLI_STATUS_VALID);
184
185 mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
186
187 array_init(retval);
188 if (mysql) {
189 #if defined(MYSQLI_USE_MYSQLND)
190 if (mysql->mysql->data->error_info->error_list) {
191 MYSQLND_ERROR_LIST_ELEMENT * message;
192 zend_llist_position pos;
193 for (message = (MYSQLND_ERROR_LIST_ELEMENT *) zend_llist_get_first_ex(mysql->mysql->data->error_info->error_list, &pos);
194 message;
195 message = (MYSQLND_ERROR_LIST_ELEMENT *) zend_llist_get_next_ex(mysql->mysql->data->error_info->error_list, &pos))
196 {
197 zval single_error;
198 array_init(&single_error);
199 add_assoc_long_ex(&single_error, "errno", sizeof("errno") - 1, message->error_no);
200 add_assoc_string_ex(&single_error, "sqlstate", sizeof("sqlstate") - 1, message->sqlstate);
201 add_assoc_string_ex(&single_error, "error", sizeof("error") - 1, message->error);
202 add_next_index_zval(retval, &single_error);
203 }
204 }
205 #else
206 if (mysql_errno(mysql->mysql)) {
207 zval single_error;
208 array_init(&single_error);
209 add_assoc_long_ex(&single_error, "errno", sizeof("errno") - 1, mysql_errno(mysql->mysql));
210 add_assoc_string_ex(&single_error, "sqlstate", sizeof("sqlstate") - 1, mysql_sqlstate(mysql->mysql));
211 add_assoc_string_ex(&single_error, "error", sizeof("error") - 1, mysql_error(mysql->mysql));
212 add_next_index_zval(retval, &single_error);
213 }
214 #endif
215 }
216
217 return retval;
218 }
219 /* }}} */
220
221 /* link properties */
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_errno_read,mysql_errno,MYSQLI_GET_MYSQL (MYSQLI_STATUS_INITIALIZED),zend_ulong,ZEND_ULONG_FMT)222 MYSQLI_MAP_PROPERTY_FUNC_LONG(link_errno_read, mysql_errno, MYSQLI_GET_MYSQL(MYSQLI_STATUS_INITIALIZED), zend_ulong, ZEND_ULONG_FMT)
223 MYSQLI_MAP_PROPERTY_FUNC_STRING(link_error_read, mysql_error, MYSQLI_GET_MYSQL(MYSQLI_STATUS_INITIALIZED))
224 MYSQLI_MAP_PROPERTY_FUNC_LONG(link_field_count_read, mysql_field_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
225 MYSQLI_MAP_PROPERTY_FUNC_STRING(link_host_info_read, mysql_get_host_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID))
226 MYSQLI_MAP_PROPERTY_FUNC_STRING(link_info_read, mysql_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID))
227 MYSQLI_MAP_PROPERTY_FUNC_LONG(link_insert_id_read, mysql_insert_id, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), my_ulonglong, MYSQLI_LLU_SPEC)
228 MYSQLI_MAP_PROPERTY_FUNC_LONG(link_protocol_version_read, mysql_get_proto_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
229 MYSQLI_MAP_PROPERTY_FUNC_STRING(link_server_info_read, mysql_get_server_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID))
230 MYSQLI_MAP_PROPERTY_FUNC_LONG(link_server_version_read, mysql_get_server_version, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
231 MYSQLI_MAP_PROPERTY_FUNC_STRING(link_sqlstate_read, mysql_sqlstate, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID))
232 MYSQLI_MAP_PROPERTY_FUNC_LONG(link_thread_id_read, mysql_thread_id, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
233 MYSQLI_MAP_PROPERTY_FUNC_LONG(link_warning_count_read, mysql_warning_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
234
235 /* {{{ property link_stat_read */
236 static zval *link_stat_read(mysqli_object *obj, zval *retval)
237 {
238 MY_MYSQL *mysql;
239
240 ZVAL_NULL(retval);
241
242 #if defined(MYSQLI_USE_MYSQLND)
243 CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
244 #else
245 CHECK_STATUS(MYSQLI_STATUS_VALID);
246 #endif
247
248 mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
249
250 if (mysql) {
251 #if defined(MYSQLI_USE_MYSQLND)
252 zend_string * stat_msg;
253 if (mysqlnd_stat(mysql->mysql, &stat_msg) == PASS) {
254 ZVAL_STR(retval, stat_msg);
255 }
256 #else
257 char * stat_msg;
258 if ((stat_msg = (char *)mysql_stat(mysql->mysql))) {
259 ZVAL_STRING(retval, stat_msg);
260 }
261 #endif
262 }
263 return retval;
264 }
265 /* }}} */
266
267 /* result properties */
268
269 /* {{{ property result_type_read */
result_type_read(mysqli_object * obj,zval * retval)270 static zval *result_type_read(mysqli_object *obj, zval *retval)
271 {
272 MYSQL_RES *p;
273
274 CHECK_STATUS(MYSQLI_STATUS_VALID);
275 p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
276
277 if (!p) {
278 ZVAL_NULL(retval);
279 } else {
280 ZVAL_LONG(retval, mysqli_result_is_unbuffered(p) ? MYSQLI_USE_RESULT:MYSQLI_STORE_RESULT);
281 }
282 return retval;
283 }
284 /* }}} */
285
286 /* {{{ property result_lengths_read */
result_lengths_read(mysqli_object * obj,zval * retval)287 static zval *result_lengths_read(mysqli_object *obj, zval *retval)
288 {
289 MYSQL_RES *p;
290 #if defined(MYSQLI_USE_MYSQLND)
291 const size_t *ret;
292 #else
293 const zend_ulong *ret;
294 #endif
295 uint32_t field_count;
296
297 CHECK_STATUS(MYSQLI_STATUS_VALID);
298 p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
299 field_count = mysql_num_fields(p);
300 if (!p || !field_count || !(ret = mysql_fetch_lengths(p))) {
301 ZVAL_NULL(retval);
302 } else {
303 zend_ulong i;
304
305 array_init(retval);
306
307 for (i = 0; i < field_count; i++) {
308 add_index_long(retval, i, ret[i]);
309 }
310 }
311 return retval;
312 }
313 /* }}} */
314
MYSQLI_MAP_PROPERTY_FUNC_LONG(result_current_field_read,mysql_field_tell,MYSQLI_GET_RESULT (MYSQLI_STATUS_VALID),zend_ulong,ZEND_ULONG_FMT)315 MYSQLI_MAP_PROPERTY_FUNC_LONG(result_current_field_read, mysql_field_tell, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
316 MYSQLI_MAP_PROPERTY_FUNC_LONG(result_field_count_read, mysql_num_fields, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
317 MYSQLI_MAP_PROPERTY_FUNC_LONG(result_num_rows_read, mysql_num_rows, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), my_ulonglong, MYSQLI_LLU_SPEC)
318
319 /* statement properties */
320
321 /* {{{ property stmt_id_read */
322 static zval *stmt_id_read(mysqli_object *obj, zval *retval)
323 {
324 MY_STMT *p;
325
326 CHECK_STATUS(MYSQLI_STATUS_VALID);
327
328 p = (MY_STMT*)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
329
330 if (!p) {
331 ZVAL_NULL(retval);
332 } else {
333 ZVAL_LONG(retval, mysqli_stmt_get_id(p->stmt));
334 }
335 return retval;
336 }
337 /* }}} */
338
339 /* {{{ property stmt_affected_rows_read */
stmt_affected_rows_read(mysqli_object * obj,zval * retval)340 static zval *stmt_affected_rows_read(mysqli_object *obj, zval *retval)
341 {
342 MY_STMT *p;
343 my_ulonglong rc;
344
345 CHECK_STATUS(MYSQLI_STATUS_VALID);
346
347 p = (MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
348
349 if (!p) {
350 ZVAL_NULL(retval);
351 } else {
352 rc = mysql_stmt_affected_rows(p->stmt);
353
354 if (rc == (my_ulonglong) -1) {
355 ZVAL_LONG(retval, -1);
356 return retval;
357 }
358
359 if (rc < ZEND_LONG_MAX) {
360 ZVAL_LONG(retval, (zend_long) rc);
361 } else {
362 ZVAL_NEW_STR(retval, strpprintf(0, MYSQLI_LLU_SPEC, rc));
363 }
364 }
365 return retval;
366 }
367 /* }}} */
368
369 /* {{{ property stmt_error_list_read */
stmt_error_list_read(mysqli_object * obj,zval * retval)370 static zval *stmt_error_list_read(mysqli_object *obj, zval *retval)
371 {
372 MY_STMT * stmt;
373
374 CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
375
376 stmt = (MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
377 array_init(retval);
378 if (stmt && stmt->stmt) {
379 #if defined(MYSQLI_USE_MYSQLND)
380 if (stmt->stmt->data && stmt->stmt->data->error_info->error_list) {
381 MYSQLND_ERROR_LIST_ELEMENT * message;
382 zend_llist_position pos;
383 for (message = (MYSQLND_ERROR_LIST_ELEMENT *) zend_llist_get_first_ex(stmt->stmt->data->error_info->error_list, &pos);
384 message;
385 message = (MYSQLND_ERROR_LIST_ELEMENT *) zend_llist_get_next_ex(stmt->stmt->data->error_info->error_list, &pos))
386 {
387 zval single_error;
388 array_init(&single_error);
389 add_assoc_long_ex(&single_error, "errno", sizeof("errno") - 1, message->error_no);
390 add_assoc_string_ex(&single_error, "sqlstate", sizeof("sqlstate") - 1, message->sqlstate);
391 add_assoc_string_ex(&single_error, "error", sizeof("error") - 1, message->error);
392 add_next_index_zval(retval, &single_error);
393 }
394 }
395 #else
396 if (mysql_stmt_errno(stmt->stmt)) {
397 zval single_error;
398 array_init(&single_error);
399 add_assoc_long_ex(&single_error, "errno", sizeof("errno") - 1, mysql_stmt_errno(stmt->stmt));
400 add_assoc_string_ex(&single_error, "sqlstate", sizeof("sqlstate") - 1, mysql_stmt_sqlstate(stmt->stmt));
401 add_assoc_string_ex(&single_error, "error", sizeof("error") - 1, mysql_stmt_error(stmt->stmt));
402 add_next_index_zval(retval, &single_error);
403 }
404 #endif
405 }
406 return retval;
407 }
408 /* }}} */
409
410 MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_insert_id_read, mysql_stmt_insert_id, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), my_ulonglong, MYSQLI_LLU_SPEC)
411 MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_num_rows_read, mysql_stmt_num_rows, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), my_ulonglong, MYSQLI_LLU_SPEC)
412 MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_param_count_read, mysql_stmt_param_count, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
413 MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_field_count_read, mysql_stmt_field_count, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
414 MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_errno_read, mysql_stmt_errno, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED), zend_ulong, ZEND_ULONG_FMT)
415 MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_error_read, mysql_stmt_error, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED))
416 MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_sqlstate_read, mysql_stmt_sqlstate, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED))
417
418 /* }}} */
419 const mysqli_property_entry mysqli_link_property_entries[] = {
420 {"affected_rows", sizeof("affected_rows") - 1, link_affected_rows_read, NULL},
421 {"client_info", sizeof("client_info") - 1, link_client_info_read, NULL},
422 {"client_version", sizeof("client_version") - 1, link_client_version_read, NULL},
423 {"connect_errno", sizeof("connect_errno") - 1, link_connect_errno_read, NULL},
424 {"connect_error", sizeof("connect_error") - 1, link_connect_error_read, NULL},
425 {"errno", sizeof("errno") - 1, link_errno_read, NULL},
426 {"error", sizeof("error") - 1, link_error_read, NULL},
427 {"error_list", sizeof("error_list") - 1, link_error_list_read, NULL},
428 {"field_count", sizeof("field_count") - 1, link_field_count_read, NULL},
429 {"host_info", sizeof("host_info") - 1, link_host_info_read, NULL},
430 {"info", sizeof("info") - 1, link_info_read, NULL},
431 {"insert_id", sizeof("insert_id") - 1, link_insert_id_read, NULL},
432 {"server_info", sizeof("server_info") - 1, link_server_info_read, NULL},
433 {"server_version", sizeof("server_version") - 1, link_server_version_read, NULL},
434 {"stat", sizeof("stat") - 1, link_stat_read, NULL},
435 {"sqlstate", sizeof("sqlstate") - 1, link_sqlstate_read, NULL},
436 {"protocol_version",sizeof("protocol_version") - 1, link_protocol_version_read, NULL},
437 {"thread_id", sizeof("thread_id") - 1, link_thread_id_read, NULL},
438 {"warning_count", sizeof("warning_count") - 1, link_warning_count_read, NULL},
439 {NULL, 0, NULL, NULL}
440 };
441
442
443 const mysqli_property_entry mysqli_result_property_entries[] = {
444 {"current_field",sizeof("current_field")-1, result_current_field_read, NULL},
445 {"field_count", sizeof("field_count") - 1, result_field_count_read, NULL},
446 {"lengths", sizeof("lengths") - 1, result_lengths_read, NULL},
447 {"num_rows", sizeof("num_rows") - 1, result_num_rows_read, NULL},
448 {"type", sizeof("type") - 1, result_type_read, NULL},
449 {NULL, 0, NULL, NULL}
450 };
451
452 const mysqli_property_entry mysqli_stmt_property_entries[] = {
453 {"affected_rows", sizeof("affected_rows")-1,stmt_affected_rows_read, NULL},
454 {"insert_id", sizeof("insert_id") - 1, stmt_insert_id_read, NULL},
455 {"num_rows", sizeof("num_rows") - 1, stmt_num_rows_read, NULL},
456 {"param_count", sizeof("param_count") - 1, stmt_param_count_read, NULL},
457 {"field_count", sizeof("field_count") - 1, stmt_field_count_read, NULL},
458 {"errno", sizeof("errno") - 1, stmt_errno_read, NULL},
459 {"error", sizeof("error") - 1, stmt_error_read, NULL},
460 {"error_list", sizeof("error_list") - 1, stmt_error_list_read, NULL},
461 {"sqlstate", sizeof("sqlstate") - 1, stmt_sqlstate_read, NULL},
462 {"id", sizeof("id") - 1, stmt_id_read, NULL},
463 {NULL, 0, NULL, NULL}
464 };
465
466 /*
467 * Local variables:
468 * tab-width: 4
469 * c-basic-offset: 4
470 * End:
471 * vim600: noet sw=4 ts=4 fdm=marker
472 * vim<600: noet sw=4 ts=4
473 */
474