dir.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 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: Thies C. Arntzen <thies@thieso.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. /* $Id$ */
  19. /* {{{ includes/startup/misc */
  20. #include "php.h"
  21. #include "fopen_wrappers.h"
  22. #include "file.h"
  23. #include "php_dir.h"
  24. #include "php_string.h"
  25. #include "php_scandir.h"
  26. #include "basic_functions.h"
  27. #ifdef HAVE_DIRENT_H
  28. #include <dirent.h>
  29. #endif
  30. #if HAVE_UNISTD_H
  31. #include <unistd.h>
  32. #endif
  33. #include <errno.h>
  34. #ifdef PHP_WIN32
  35. #include "win32/readdir.h"
  36. #endif
  37. #ifdef HAVE_GLOB
  38. #ifndef PHP_WIN32
  39. #include <glob.h>
  40. #else
  41. #include "win32/glob.h"
  42. #endif
  43. #endif
  44. typedef struct {
  45. int default_dir;
  46. } php_dir_globals;
  47. #ifdef ZTS
  48. #define DIRG(v) TSRMG(dir_globals_id, php_dir_globals *, v)
  49. int dir_globals_id;
  50. #else
  51. #define DIRG(v) (dir_globals.v)
  52. php_dir_globals dir_globals;
  53. #endif
  54. #if 0
  55. typedef struct {
  56. int id;
  57. DIR *dir;
  58. } php_dir;
  59. static int le_dirp;
  60. #endif
  61. static zend_class_entry *dir_class_entry_ptr;
  62. #define FETCH_DIRP() \
  63. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &id) == FAILURE) { \
  64. return; \
  65. } \
  66. if (ZEND_NUM_ARGS() == 0) { \
  67. myself = getThis(); \
  68. if (myself) { \
  69. if (zend_hash_find(Z_OBJPROP_P(myself), "handle", sizeof("handle"), (void **)&tmp) == FAILURE) { \
  70. php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find my handle property"); \
  71. RETURN_FALSE; \
  72. } \
  73. ZEND_FETCH_RESOURCE(dirp, php_stream *, tmp, -1, "Directory", php_file_le_stream()); \
  74. } else { \
  75. ZEND_FETCH_RESOURCE(dirp, php_stream *, 0, DIRG(default_dir), "Directory", php_file_le_stream()); \
  76. } \
  77. } else { \
  78. dirp = (php_stream *) zend_fetch_resource(&id TSRMLS_CC, -1, "Directory", NULL, 1, php_file_le_stream()); \
  79. if (!dirp) \
  80. RETURN_FALSE; \
  81. }
  82. /* {{{ arginfo */
  83. ZEND_BEGIN_ARG_INFO_EX(arginfo_dir, 0, 0, 0)
  84. ZEND_ARG_INFO(0, dir_handle)
  85. ZEND_END_ARG_INFO()
  86. /* }}} */
  87. static const zend_function_entry php_dir_class_functions[] = {
  88. PHP_FALIAS(close, closedir, arginfo_dir)
  89. PHP_FALIAS(rewind, rewinddir, arginfo_dir)
  90. PHP_NAMED_FE(read, php_if_readdir, arginfo_dir)
  91. {NULL, NULL, NULL}
  92. };
  93. static void php_set_default_dir(int id TSRMLS_DC)
  94. {
  95. if (DIRG(default_dir)!=-1) {
  96. zend_list_delete(DIRG(default_dir));
  97. }
  98. if (id != -1) {
  99. zend_list_addref(id);
  100. }
  101. DIRG(default_dir) = id;
  102. }
  103. PHP_RINIT_FUNCTION(dir)
  104. {
  105. DIRG(default_dir) = -1;
  106. return SUCCESS;
  107. }
  108. PHP_MINIT_FUNCTION(dir)
  109. {
  110. static char dirsep_str[2], pathsep_str[2];
  111. zend_class_entry dir_class_entry;
  112. INIT_CLASS_ENTRY(dir_class_entry, "Directory", php_dir_class_functions);
  113. dir_class_entry_ptr = zend_register_internal_class(&dir_class_entry TSRMLS_CC);
  114. #ifdef ZTS
  115. ts_allocate_id(&dir_globals_id, sizeof(php_dir_globals), NULL, NULL);
  116. #endif
  117. dirsep_str[0] = DEFAULT_SLASH;
  118. dirsep_str[1] = '\0';
  119. REGISTER_STRING_CONSTANT("DIRECTORY_SEPARATOR", dirsep_str, CONST_CS|CONST_PERSISTENT);
  120. pathsep_str[0] = ZEND_PATHS_SEPARATOR;
  121. pathsep_str[1] = '\0';
  122. REGISTER_STRING_CONSTANT("PATH_SEPARATOR", pathsep_str, CONST_CS|CONST_PERSISTENT);
  123. REGISTER_LONG_CONSTANT("SCANDIR_SORT_ASCENDING", PHP_SCANDIR_SORT_ASCENDING, CONST_CS | CONST_PERSISTENT);
  124. REGISTER_LONG_CONSTANT("SCANDIR_SORT_DESCENDING", PHP_SCANDIR_SORT_DESCENDING, CONST_CS | CONST_PERSISTENT);
  125. REGISTER_LONG_CONSTANT("SCANDIR_SORT_NONE", PHP_SCANDIR_SORT_NONE, CONST_CS | CONST_PERSISTENT);
  126. #ifdef HAVE_GLOB
  127. #ifdef GLOB_BRACE
  128. REGISTER_LONG_CONSTANT("GLOB_BRACE", GLOB_BRACE, CONST_CS | CONST_PERSISTENT);
  129. #else
  130. # define GLOB_BRACE 0
  131. #endif
  132. #ifdef GLOB_MARK
  133. REGISTER_LONG_CONSTANT("GLOB_MARK", GLOB_MARK, CONST_CS | CONST_PERSISTENT);
  134. #else
  135. # define GLOB_MARK 0
  136. #endif
  137. #ifdef GLOB_NOSORT
  138. REGISTER_LONG_CONSTANT("GLOB_NOSORT", GLOB_NOSORT, CONST_CS | CONST_PERSISTENT);
  139. #else
  140. # define GLOB_NOSORT 0
  141. #endif
  142. #ifdef GLOB_NOCHECK
  143. REGISTER_LONG_CONSTANT("GLOB_NOCHECK", GLOB_NOCHECK, CONST_CS | CONST_PERSISTENT);
  144. #else
  145. # define GLOB_NOCHECK 0
  146. #endif
  147. #ifdef GLOB_NOESCAPE
  148. REGISTER_LONG_CONSTANT("GLOB_NOESCAPE", GLOB_NOESCAPE, CONST_CS | CONST_PERSISTENT);
  149. #else
  150. # define GLOB_NOESCAPE 0
  151. #endif
  152. #ifdef GLOB_ERR
  153. REGISTER_LONG_CONSTANT("GLOB_ERR", GLOB_ERR, CONST_CS | CONST_PERSISTENT);
  154. #else
  155. # define GLOB_ERR 0
  156. #endif
  157. #ifndef GLOB_ONLYDIR
  158. # define GLOB_ONLYDIR (1<<30)
  159. # define GLOB_EMULATE_ONLYDIR
  160. # define GLOB_FLAGMASK (~GLOB_ONLYDIR)
  161. #else
  162. # define GLOB_FLAGMASK (~0)
  163. #endif
  164. /* This is used for checking validity of passed flags (passing invalid flags causes segfault in glob()!! */
  165. #define GLOB_AVAILABLE_FLAGS (0 | GLOB_BRACE | GLOB_MARK | GLOB_NOSORT | GLOB_NOCHECK | GLOB_NOESCAPE | GLOB_ERR | GLOB_ONLYDIR)
  166. REGISTER_LONG_CONSTANT("GLOB_ONLYDIR", GLOB_ONLYDIR, CONST_CS | CONST_PERSISTENT);
  167. REGISTER_LONG_CONSTANT("GLOB_AVAILABLE_FLAGS", GLOB_AVAILABLE_FLAGS, CONST_CS | CONST_PERSISTENT);
  168. #endif /* HAVE_GLOB */
  169. return SUCCESS;
  170. }
  171. /* }}} */
  172. /* {{{ internal functions */
  173. static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject)
  174. {
  175. char *dirname;
  176. int dir_len;
  177. zval *zcontext = NULL;
  178. php_stream_context *context = NULL;
  179. php_stream *dirp;
  180. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|r", &dirname, &dir_len, &zcontext) == FAILURE) {
  181. RETURN_NULL();
  182. }
  183. context = php_stream_context_from_zval(zcontext, 0);
  184. dirp = php_stream_opendir(dirname, REPORT_ERRORS, context);
  185. if (dirp == NULL) {
  186. RETURN_FALSE;
  187. }
  188. dirp->flags |= PHP_STREAM_FLAG_NO_FCLOSE;
  189. php_set_default_dir(dirp->rsrc_id TSRMLS_CC);
  190. if (createobject) {
  191. object_init_ex(return_value, dir_class_entry_ptr);
  192. add_property_stringl(return_value, "path", dirname, dir_len, 1);
  193. add_property_resource(return_value, "handle", dirp->rsrc_id);
  194. php_stream_auto_cleanup(dirp); /* so we don't get warnings under debug */
  195. } else {
  196. php_stream_to_zval(dirp, return_value);
  197. }
  198. }
  199. /* }}} */
  200. /* {{{ proto mixed opendir(string path[, resource context])
  201. Open a directory and return a dir_handle */
  202. PHP_FUNCTION(opendir)
  203. {
  204. _php_do_opendir(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
  205. }
  206. /* }}} */
  207. /* {{{ proto object dir(string directory[, resource context])
  208. Directory class with properties, handle and class and methods read, rewind and close */
  209. PHP_FUNCTION(getdir)
  210. {
  211. _php_do_opendir(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
  212. }
  213. /* }}} */
  214. /* {{{ proto void closedir([resource dir_handle])
  215. Close directory connection identified by the dir_handle */
  216. PHP_FUNCTION(closedir)
  217. {
  218. zval *id = NULL, **tmp, *myself;
  219. php_stream *dirp;
  220. int rsrc_id;
  221. FETCH_DIRP();
  222. if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
  223. php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid Directory resource", dirp->rsrc_id);
  224. RETURN_FALSE;
  225. }
  226. rsrc_id = dirp->rsrc_id;
  227. zend_list_delete(dirp->rsrc_id);
  228. if (rsrc_id == DIRG(default_dir)) {
  229. php_set_default_dir(-1 TSRMLS_CC);
  230. }
  231. }
  232. /* }}} */
  233. #if defined(HAVE_CHROOT) && !defined(ZTS) && ENABLE_CHROOT_FUNC
  234. /* {{{ proto bool chroot(string directory)
  235. Change root directory */
  236. PHP_FUNCTION(chroot)
  237. {
  238. char *str;
  239. int ret, str_len;
  240. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &str, &str_len) == FAILURE) {
  241. RETURN_FALSE;
  242. }
  243. ret = chroot(str);
  244. if (ret != 0) {
  245. php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s (errno %d)", strerror(errno), errno);
  246. RETURN_FALSE;
  247. }
  248. php_clear_stat_cache(1, NULL, 0 TSRMLS_CC);
  249. ret = chdir("/");
  250. if (ret != 0) {
  251. php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s (errno %d)", strerror(errno), errno);
  252. RETURN_FALSE;
  253. }
  254. RETURN_TRUE;
  255. }
  256. /* }}} */
  257. #endif
  258. /* {{{ proto bool chdir(string directory)
  259. Change the current directory */
  260. PHP_FUNCTION(chdir)
  261. {
  262. char *str;
  263. int ret, str_len;
  264. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &str, &str_len) == FAILURE) {
  265. RETURN_FALSE;
  266. }
  267. if (php_check_open_basedir(str TSRMLS_CC)) {
  268. RETURN_FALSE;
  269. }
  270. ret = VCWD_CHDIR(str);
  271. if (ret != 0) {
  272. php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s (errno %d)", strerror(errno), errno);
  273. RETURN_FALSE;
  274. }
  275. if (BG(CurrentStatFile) && !IS_ABSOLUTE_PATH(BG(CurrentStatFile), strlen(BG(CurrentStatFile)))) {
  276. efree(BG(CurrentStatFile));
  277. BG(CurrentStatFile) = NULL;
  278. }
  279. if (BG(CurrentLStatFile) && !IS_ABSOLUTE_PATH(BG(CurrentLStatFile), strlen(BG(CurrentLStatFile)))) {
  280. efree(BG(CurrentLStatFile));
  281. BG(CurrentLStatFile) = NULL;
  282. }
  283. RETURN_TRUE;
  284. }
  285. /* }}} */
  286. /* {{{ proto mixed getcwd(void)
  287. Gets the current directory */
  288. PHP_FUNCTION(getcwd)
  289. {
  290. char path[MAXPATHLEN];
  291. char *ret=NULL;
  292. if (zend_parse_parameters_none() == FAILURE) {
  293. return;
  294. }
  295. #if HAVE_GETCWD
  296. ret = VCWD_GETCWD(path, MAXPATHLEN);
  297. #elif HAVE_GETWD
  298. ret = VCWD_GETWD(path);
  299. #endif
  300. if (ret) {
  301. RETURN_STRING(path, 1);
  302. } else {
  303. RETURN_FALSE;
  304. }
  305. }
  306. /* }}} */
  307. /* {{{ proto void rewinddir([resource dir_handle])
  308. Rewind dir_handle back to the start */
  309. PHP_FUNCTION(rewinddir)
  310. {
  311. zval *id = NULL, **tmp, *myself;
  312. php_stream *dirp;
  313. FETCH_DIRP();
  314. if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
  315. php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid Directory resource", dirp->rsrc_id);
  316. RETURN_FALSE;
  317. }
  318. php_stream_rewinddir(dirp);
  319. }
  320. /* }}} */
  321. /* {{{ proto string readdir([resource dir_handle])
  322. Read directory entry from dir_handle */
  323. PHP_NAMED_FUNCTION(php_if_readdir)
  324. {
  325. zval *id = NULL, **tmp, *myself;
  326. php_stream *dirp;
  327. php_stream_dirent entry;
  328. FETCH_DIRP();
  329. if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
  330. php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid Directory resource", dirp->rsrc_id);
  331. RETURN_FALSE;
  332. }
  333. if (php_stream_readdir(dirp, &entry)) {
  334. RETURN_STRINGL(entry.d_name, strlen(entry.d_name), 1);
  335. }
  336. RETURN_FALSE;
  337. }
  338. /* }}} */
  339. #ifdef HAVE_GLOB
  340. /* {{{ proto array glob(string pattern [, int flags])
  341. Find pathnames matching a pattern */
  342. PHP_FUNCTION(glob)
  343. {
  344. int cwd_skip = 0;
  345. #ifdef ZTS
  346. char cwd[MAXPATHLEN];
  347. char work_pattern[MAXPATHLEN];
  348. char *result;
  349. #endif
  350. char *pattern = NULL;
  351. int pattern_len;
  352. long flags = 0;
  353. glob_t globbuf;
  354. int n;
  355. int ret;
  356. zend_bool basedir_limit = 0;
  357. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &pattern, &pattern_len, &flags) == FAILURE) {
  358. return;
  359. }
  360. if (pattern_len >= MAXPATHLEN) {
  361. php_error_docref(NULL TSRMLS_CC, E_WARNING, "Pattern exceeds the maximum allowed length of %d characters", MAXPATHLEN);
  362. RETURN_FALSE;
  363. }
  364. if ((GLOB_AVAILABLE_FLAGS & flags) != flags) {
  365. php_error_docref(NULL TSRMLS_CC, E_WARNING, "At least one of the passed flags is invalid or not supported on this platform");
  366. RETURN_FALSE;
  367. }
  368. #ifdef ZTS
  369. if (!IS_ABSOLUTE_PATH(pattern, pattern_len)) {
  370. result = VCWD_GETCWD(cwd, MAXPATHLEN);
  371. if (!result) {
  372. cwd[0] = '\0';
  373. }
  374. #ifdef PHP_WIN32
  375. if (IS_SLASH(*pattern)) {
  376. cwd[2] = '\0';
  377. }
  378. #endif
  379. cwd_skip = strlen(cwd)+1;
  380. snprintf(work_pattern, MAXPATHLEN, "%s%c%s", cwd, DEFAULT_SLASH, pattern);
  381. pattern = work_pattern;
  382. }
  383. #endif
  384. memset(&globbuf, 0, sizeof(glob_t));
  385. globbuf.gl_offs = 0;
  386. if (0 != (ret = glob(pattern, flags & GLOB_FLAGMASK, NULL, &globbuf))) {
  387. #ifdef GLOB_NOMATCH
  388. if (GLOB_NOMATCH == ret) {
  389. /* Some glob implementation simply return no data if no matches
  390. were found, others return the GLOB_NOMATCH error code.
  391. We don't want to treat GLOB_NOMATCH as an error condition
  392. so that PHP glob() behaves the same on both types of
  393. implementations and so that 'foreach (glob() as ...'
  394. can be used for simple glob() calls without further error
  395. checking.
  396. */
  397. goto no_results;
  398. }
  399. #endif
  400. RETURN_FALSE;
  401. }
  402. /* now catch the FreeBSD style of "no matches" */
  403. if (!globbuf.gl_pathc || !globbuf.gl_pathv) {
  404. no_results:
  405. #ifndef PHP_WIN32
  406. /* Paths containing '*', '?' and some other chars are
  407. illegal on Windows but legit on other platforms. For
  408. this reason the direct basedir check against the glob
  409. query is senseless on windows. For instance while *.txt
  410. is a pretty valid filename on EXT3, it's invalid on NTFS. */
  411. if (PG(open_basedir) && *PG(open_basedir)) {
  412. if (php_check_open_basedir_ex(pattern, 0 TSRMLS_CC)) {
  413. RETURN_FALSE;
  414. }
  415. }
  416. #endif
  417. array_init(return_value);
  418. return;
  419. }
  420. array_init(return_value);
  421. for (n = 0; n < globbuf.gl_pathc; n++) {
  422. if (PG(open_basedir) && *PG(open_basedir)) {
  423. if (php_check_open_basedir_ex(globbuf.gl_pathv[n], 0 TSRMLS_CC)) {
  424. basedir_limit = 1;
  425. continue;
  426. }
  427. }
  428. /* we need to do this every time since GLOB_ONLYDIR does not guarantee that
  429. * all directories will be filtered. GNU libc documentation states the
  430. * following:
  431. * If the information about the type of the file is easily available
  432. * non-directories will be rejected but no extra work will be done to
  433. * determine the information for each file. I.e., the caller must still be
  434. * able to filter directories out.
  435. */
  436. if (flags & GLOB_ONLYDIR) {
  437. struct stat s;
  438. if (0 != VCWD_STAT(globbuf.gl_pathv[n], &s)) {
  439. continue;
  440. }
  441. if (S_IFDIR != (s.st_mode & S_IFMT)) {
  442. continue;
  443. }
  444. }
  445. add_next_index_string(return_value, globbuf.gl_pathv[n]+cwd_skip, 1);
  446. }
  447. globfree(&globbuf);
  448. if (basedir_limit && !zend_hash_num_elements(Z_ARRVAL_P(return_value))) {
  449. zval_dtor(return_value);
  450. RETURN_FALSE;
  451. }
  452. }
  453. /* }}} */
  454. #endif
  455. /* {{{ proto array scandir(string dir [, int sorting_order [, resource context]])
  456. List files & directories inside the specified path */
  457. PHP_FUNCTION(scandir)
  458. {
  459. char *dirn;
  460. int dirn_len;
  461. long flags = 0;
  462. char **namelist;
  463. int n, i;
  464. zval *zcontext = NULL;
  465. php_stream_context *context = NULL;
  466. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|lr", &dirn, &dirn_len, &flags, &zcontext) == FAILURE) {
  467. return;
  468. }
  469. if (dirn_len < 1) {
  470. php_error_docref(NULL TSRMLS_CC, E_WARNING, "Directory name cannot be empty");
  471. RETURN_FALSE;
  472. }
  473. if (zcontext) {
  474. context = php_stream_context_from_zval(zcontext, 0);
  475. }
  476. if (flags == PHP_SCANDIR_SORT_ASCENDING) {
  477. n = php_stream_scandir(dirn, &namelist, context, (void *) php_stream_dirent_alphasort);
  478. } else if (flags == PHP_SCANDIR_SORT_NONE) {
  479. n = php_stream_scandir(dirn, &namelist, context, NULL);
  480. } else {
  481. n = php_stream_scandir(dirn, &namelist, context, (void *) php_stream_dirent_alphasortr);
  482. }
  483. if (n < 0) {
  484. php_error_docref(NULL TSRMLS_CC, E_WARNING, "(errno %d): %s", errno, strerror(errno));
  485. RETURN_FALSE;
  486. }
  487. array_init(return_value);
  488. for (i = 0; i < n; i++) {
  489. add_next_index_string(return_value, namelist[i], 0);
  490. }
  491. if (n) {
  492. efree(namelist);
  493. }
  494. }
  495. /* }}} */
  496. /*
  497. * Local variables:
  498. * tab-width: 4
  499. * c-basic-offset: 4
  500. * End:
  501. * vim600: sw=4 ts=4 fdm=marker
  502. * vim<600: sw=4 ts=4
  503. */