chiark / gitweb /
4d957cd3fb90473fa256bc6a1facc0ba919b125d
[elogind.git] / src / test / test-path-util.c
1 /***
2   This file is part of systemd.
3
4   Copyright 2013 Zbigniew JÄ™drzejewski-Szmek
5
6   systemd is free software; you can redistribute it and/or modify it
7   under the terms of the GNU Lesser General Public License as published by
8   the Free Software Foundation; either version 2.1 of the License, or
9   (at your option) any later version.
10
11   systemd is distributed in the hope that it will be useful, but
12   WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14   Lesser General Public License for more details.
15
16   You should have received a copy of the GNU Lesser General Public License
17   along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 ***/
19
20 #include <stdio.h>
21 #include <sys/mount.h>
22 #include <unistd.h>
23
24 #include "alloc-util.h"
25 #include "fd-util.h"
26 #include "macro.h"
27 #include "mount-util.h"
28 #include "path-util.h"
29 #include "rm-rf.h"
30 #include "string-util.h"
31 #include "strv.h"
32 #include "util.h"
33
34 #define test_path_compare(a, b, result) {                 \
35                 assert_se(path_compare(a, b) == result);  \
36                 assert_se(path_compare(b, a) == -result); \
37                 assert_se(path_equal(a, b) == !result);   \
38                 assert_se(path_equal(b, a) == !result);   \
39         }
40
41 static void test_path(void) {
42         _cleanup_close_ int fd = -1;
43
44         test_path_compare("/goo", "/goo", 0);
45         test_path_compare("/goo", "/goo", 0);
46         test_path_compare("//goo", "/goo", 0);
47         test_path_compare("//goo/////", "/goo", 0);
48         test_path_compare("goo/////", "goo", 0);
49
50         test_path_compare("/goo/boo", "/goo//boo", 0);
51         test_path_compare("//goo/boo", "/goo/boo//", 0);
52
53         test_path_compare("/", "///", 0);
54
55         test_path_compare("/x", "x/", 1);
56         test_path_compare("x/", "/", -1);
57
58         test_path_compare("/x/./y", "x/y", 1);
59         test_path_compare("x/.y", "x/y", -1);
60
61         test_path_compare("foo", "/foo", -1);
62         test_path_compare("/foo", "/foo/bar", -1);
63         test_path_compare("/foo/aaa", "/foo/b", -1);
64         test_path_compare("/foo/aaa", "/foo/b/a", -1);
65         test_path_compare("/foo/a", "/foo/aaa", -1);
66         test_path_compare("/foo/a/b", "/foo/aaa", -1);
67
68         assert_se(path_is_absolute("/"));
69         assert_se(!path_is_absolute("./"));
70
71         assert_se(is_path("/dir"));
72         assert_se(is_path("a/b"));
73         assert_se(!is_path("."));
74
75         assert_se(streq(basename("./aa/bb/../file.da."), "file.da."));
76         assert_se(streq(basename("/aa///.file"), ".file"));
77         assert_se(streq(basename("/aa///file..."), "file..."));
78         assert_se(streq(basename("file.../"), ""));
79
80         fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);
81         assert_se(fd >= 0);
82         assert_se(fd_is_mount_point(fd, "/", 0) > 0);
83
84         {
85                 char p1[] = "aaa/bbb////ccc";
86                 char p2[] = "//aaa/.////ccc";
87                 char p3[] = "/./";
88
89                 assert_se(path_equal(path_kill_slashes(p1), "aaa/bbb/ccc"));
90                 assert_se(path_equal(path_kill_slashes(p2), "/aaa/./ccc"));
91                 assert_se(path_equal(path_kill_slashes(p3), "/./"));
92         }
93
94         assert_se(PATH_IN_SET("/bin", "/", "/bin", "/foo"));
95         assert_se(PATH_IN_SET("/bin", "/bin"));
96         assert_se(PATH_IN_SET("/bin", "/foo/bar", "/bin"));
97         assert_se(PATH_IN_SET("/", "/", "/", "/foo/bar"));
98         assert_se(!PATH_IN_SET("/", "/abc", "/def"));
99
100         assert_se(path_equal_ptr(NULL, NULL));
101         assert_se(path_equal_ptr("/a", "/a"));
102         assert_se(!path_equal_ptr("/a", "/b"));
103         assert_se(!path_equal_ptr("/a", NULL));
104         assert_se(!path_equal_ptr(NULL, "/a"));
105 }
106
107 static void test_find_binary(const char *self) {
108         char *p;
109
110         assert_se(find_binary("/bin/sh", &p) == 0);
111         puts(p);
112         assert_se(path_equal(p, "/bin/sh"));
113         free(p);
114
115         assert_se(find_binary(self, &p) == 0);
116         puts(p);
117         /* libtool might prefix the binary name with "lt-" */
118         assert_se(endswith(p, "/lt-test-path-util") || endswith(p, "/test-path-util"));
119         assert_se(path_is_absolute(p));
120         free(p);
121
122         assert_se(find_binary("sh", &p) == 0);
123         puts(p);
124         assert_se(endswith(p, "/sh"));
125         assert_se(path_is_absolute(p));
126         free(p);
127
128         assert_se(find_binary("xxxx-xxxx", &p) == -ENOENT);
129         assert_se(find_binary("/some/dir/xxxx-xxxx", &p) == -ENOENT);
130 }
131
132 static void test_prefixes(void) {
133         static const char* values[] = { "/a/b/c/d", "/a/b/c", "/a/b", "/a", "", NULL};
134         unsigned i;
135         char s[PATH_MAX];
136         bool b;
137
138         i = 0;
139         PATH_FOREACH_PREFIX_MORE(s, "/a/b/c/d") {
140                 log_error("---%s---", s);
141                 assert_se(streq(s, values[i++]));
142         }
143         assert_se(values[i] == NULL);
144
145         i = 1;
146         PATH_FOREACH_PREFIX(s, "/a/b/c/d") {
147                 log_error("---%s---", s);
148                 assert_se(streq(s, values[i++]));
149         }
150         assert_se(values[i] == NULL);
151
152         i = 0;
153         PATH_FOREACH_PREFIX_MORE(s, "////a////b////c///d///////")
154                 assert_se(streq(s, values[i++]));
155         assert_se(values[i] == NULL);
156
157         i = 1;
158         PATH_FOREACH_PREFIX(s, "////a////b////c///d///////")
159                 assert_se(streq(s, values[i++]));
160         assert_se(values[i] == NULL);
161
162         PATH_FOREACH_PREFIX(s, "////")
163                 assert_not_reached("Wut?");
164
165         b = false;
166         PATH_FOREACH_PREFIX_MORE(s, "////") {
167                 assert_se(!b);
168                 assert_se(streq(s, ""));
169                 b = true;
170         }
171         assert_se(b);
172
173         PATH_FOREACH_PREFIX(s, "")
174                 assert_not_reached("wut?");
175
176         b = false;
177         PATH_FOREACH_PREFIX_MORE(s, "") {
178                 assert_se(!b);
179                 assert_se(streq(s, ""));
180                 b = true;
181         }
182 }
183
184 static void test_path_join(void) {
185
186 #define test_join(root, path, rest, expected) {  \
187                 _cleanup_free_ char *z = NULL;   \
188                 z = path_join(root, path, rest); \
189                 assert_se(streq(z, expected));   \
190         }
191
192         test_join("/root", "/a/b", "/c", "/root/a/b/c");
193         test_join("/root", "a/b", "c", "/root/a/b/c");
194         test_join("/root", "/a/b", "c", "/root/a/b/c");
195         test_join("/root", "/", "c", "/root/c");
196         test_join("/root", "/", NULL, "/root/");
197
198         test_join(NULL, "/a/b", "/c", "/a/b/c");
199         test_join(NULL, "a/b", "c", "a/b/c");
200         test_join(NULL, "/a/b", "c", "/a/b/c");
201         test_join(NULL, "/", "c", "/c");
202         test_join(NULL, "/", NULL, "/");
203 }
204
205 #if 0 /// UNNEEDED by elogind
206 static void test_fsck_exists(void) {
207         /* Ensure we use a sane default for PATH. */
208         unsetenv("PATH");
209
210         /* fsck.minix is provided by util-linux and will probably exist. */
211         assert_se(fsck_exists("minix") == 1);
212
213         assert_se(fsck_exists("AbCdE") == 0);
214         assert_se(fsck_exists("/../bin/") == 0);
215 }
216
217 static void test_make_relative(void) {
218         char *result;
219
220         assert_se(path_make_relative("some/relative/path", "/some/path", &result) < 0);
221         assert_se(path_make_relative("/some/path", "some/relative/path", &result) < 0);
222
223 #define test(from_dir, to_path, expected) {                \
224                 _cleanup_free_ char *z = NULL;             \
225                 path_make_relative(from_dir, to_path, &z); \
226                 assert_se(streq(z, expected));             \
227         }
228
229         test("/", "/", ".");
230         test("/", "/some/path", "some/path");
231         test("/some/path", "/some/path", ".");
232         test("/some/path", "/some/path/in/subdir", "in/subdir");
233         test("/some/path", "/", "../..");
234         test("/some/path", "/some/other/path", "../other/path");
235         test("//extra/////slashes///won't////fool///anybody//", "////extra///slashes////are/just///fine///", "../../../are/just/fine");
236 }
237 #endif // 0
238
239 static void test_strv_resolve(void) {
240         char tmp_dir[] = "/tmp/test-path-util-XXXXXX";
241         _cleanup_strv_free_ char **search_dirs = NULL;
242         _cleanup_strv_free_ char **absolute_dirs = NULL;
243         char **d;
244
245         assert_se(mkdtemp(tmp_dir) != NULL);
246
247         search_dirs = strv_new("/dir1", "/dir2", "/dir3", NULL);
248         assert_se(search_dirs);
249         STRV_FOREACH(d, search_dirs) {
250                 char *p = strappend(tmp_dir, *d);
251                 assert_se(p);
252                 assert_se(strv_push(&absolute_dirs, p) == 0);
253         }
254
255         assert_se(mkdir(absolute_dirs[0], 0700) == 0);
256         assert_se(mkdir(absolute_dirs[1], 0700) == 0);
257         assert_se(symlink("dir2", absolute_dirs[2]) == 0);
258
259         path_strv_resolve(search_dirs, tmp_dir);
260         assert_se(streq(search_dirs[0], "/dir1"));
261         assert_se(streq(search_dirs[1], "/dir2"));
262         assert_se(streq(search_dirs[2], "/dir2"));
263
264         assert_se(rm_rf(tmp_dir, REMOVE_ROOT|REMOVE_PHYSICAL) == 0);
265 }
266
267 static void test_path_startswith(void) {
268         const char *p;
269
270         p = path_startswith("/foo/bar/barfoo/", "/foo");
271         assert_se(streq_ptr(p, "bar/barfoo/"));
272
273         p = path_startswith("/foo/bar/barfoo/", "/foo/");
274         assert_se(streq_ptr(p, "bar/barfoo/"));
275
276         p = path_startswith("/foo/bar/barfoo/", "/");
277         assert_se(streq_ptr(p, "foo/bar/barfoo/"));
278
279         p = path_startswith("/foo/bar/barfoo/", "////");
280         assert_se(streq_ptr(p, "foo/bar/barfoo/"));
281
282         p = path_startswith("/foo/bar/barfoo/", "/foo//bar/////barfoo///");
283         assert_se(streq_ptr(p, ""));
284
285         p = path_startswith("/foo/bar/barfoo/", "/foo/bar/barfoo////");
286         assert_se(streq_ptr(p, ""));
287
288         p = path_startswith("/foo/bar/barfoo/", "/foo/bar///barfoo/");
289         assert_se(streq_ptr(p, ""));
290
291         p = path_startswith("/foo/bar/barfoo/", "/foo////bar/barfoo/");
292         assert_se(streq_ptr(p, ""));
293
294         p = path_startswith("/foo/bar/barfoo/", "////foo/bar/barfoo/");
295         assert_se(streq_ptr(p, ""));
296
297         p = path_startswith("/foo/bar/barfoo/", "/foo/bar/barfoo");
298         assert_se(streq_ptr(p, ""));
299
300         assert_se(!path_startswith("/foo/bar/barfoo/", "/foo/bar/barfooa/"));
301         assert_se(!path_startswith("/foo/bar/barfoo/", "/foo/bar/barfooa"));
302         assert_se(!path_startswith("/foo/bar/barfoo/", ""));
303         assert_se(!path_startswith("/foo/bar/barfoo/", "/bar/foo"));
304         assert_se(!path_startswith("/foo/bar/barfoo/", "/f/b/b/"));
305 }
306
307 static void test_prefix_root_one(const char *r, const char *p, const char *expected) {
308         _cleanup_free_ char *s = NULL;
309         const char *t;
310
311         assert_se(s = prefix_root(r, p));
312         assert_se(streq_ptr(s, expected));
313
314         t = prefix_roota(r, p);
315         assert_se(t);
316         assert_se(streq_ptr(t, expected));
317 }
318
319 static void test_prefix_root(void) {
320         test_prefix_root_one("/", "/foo", "/foo");
321         test_prefix_root_one(NULL, "/foo", "/foo");
322         test_prefix_root_one("", "/foo", "/foo");
323         test_prefix_root_one("///", "/foo", "/foo");
324         test_prefix_root_one("/", "////foo", "/foo");
325         test_prefix_root_one(NULL, "////foo", "/foo");
326
327         test_prefix_root_one("/foo", "/bar", "/foo/bar");
328         test_prefix_root_one("/foo", "bar", "/foo/bar");
329         test_prefix_root_one("foo", "bar", "foo/bar");
330         test_prefix_root_one("/foo/", "/bar", "/foo/bar");
331         test_prefix_root_one("/foo/", "//bar", "/foo/bar");
332         test_prefix_root_one("/foo///", "//bar", "/foo/bar");
333 }
334
335 static void test_path_is_mount_point(void) {
336         int fd;
337         char tmp_dir[] = "/tmp/test-path-is-mount-point-XXXXXX";
338         _cleanup_free_ char *file1 = NULL, *file2 = NULL, *link1 = NULL, *link2 = NULL;
339         _cleanup_free_ char *dir1 = NULL, *dir1file = NULL, *dirlink1 = NULL, *dirlink1file = NULL;
340         _cleanup_free_ char *dir2 = NULL, *dir2file = NULL;
341
342         assert_se(path_is_mount_point("/", NULL, AT_SYMLINK_FOLLOW) > 0);
343         assert_se(path_is_mount_point("/", NULL, 0) > 0);
344
345         assert_se(path_is_mount_point("/proc", NULL, AT_SYMLINK_FOLLOW) > 0);
346         assert_se(path_is_mount_point("/proc", NULL, 0) > 0);
347
348         assert_se(path_is_mount_point("/proc/1", NULL, AT_SYMLINK_FOLLOW) == 0);
349         assert_se(path_is_mount_point("/proc/1", NULL, 0) == 0);
350
351         assert_se(path_is_mount_point("/sys", NULL, AT_SYMLINK_FOLLOW) > 0);
352         assert_se(path_is_mount_point("/sys", NULL, 0) > 0);
353
354         /* we'll create a hierarchy of different kinds of dir/file/link
355          * layouts:
356          *
357          * <tmp>/file1, <tmp>/file2
358          * <tmp>/link1 -> file1, <tmp>/link2 -> file2
359          * <tmp>/dir1/
360          * <tmp>/dir1/file
361          * <tmp>/dirlink1 -> dir1
362          * <tmp>/dirlink1file -> dirlink1/file
363          * <tmp>/dir2/
364          * <tmp>/dir2/file
365          */
366
367         /* file mountpoints */
368         assert_se(mkdtemp(tmp_dir) != NULL);
369         file1 = path_join(NULL, tmp_dir, "file1");
370         assert_se(file1);
371         file2 = path_join(NULL, tmp_dir, "file2");
372         assert_se(file2);
373         fd = open(file1, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0664);
374         assert_se(fd > 0);
375         close(fd);
376         fd = open(file2, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0664);
377         assert_se(fd > 0);
378         close(fd);
379         link1 = path_join(NULL, tmp_dir, "link1");
380         assert_se(link1);
381         assert_se(symlink("file1", link1) == 0);
382         link2 = path_join(NULL, tmp_dir, "link2");
383         assert_se(link1);
384         assert_se(symlink("file2", link2) == 0);
385
386         assert_se(path_is_mount_point(file1, NULL, AT_SYMLINK_FOLLOW) == 0);
387         assert_se(path_is_mount_point(file1, NULL, 0) == 0);
388         assert_se(path_is_mount_point(link1, NULL, AT_SYMLINK_FOLLOW) == 0);
389         assert_se(path_is_mount_point(link1, NULL, 0) == 0);
390
391         /* directory mountpoints */
392         dir1 = path_join(NULL, tmp_dir, "dir1");
393         assert_se(dir1);
394         assert_se(mkdir(dir1, 0755) == 0);
395         dirlink1 = path_join(NULL, tmp_dir, "dirlink1");
396         assert_se(dirlink1);
397         assert_se(symlink("dir1", dirlink1) == 0);
398         dirlink1file = path_join(NULL, tmp_dir, "dirlink1file");
399         assert_se(dirlink1file);
400         assert_se(symlink("dirlink1/file", dirlink1file) == 0);
401         dir2 = path_join(NULL, tmp_dir, "dir2");
402         assert_se(dir2);
403         assert_se(mkdir(dir2, 0755) == 0);
404
405         assert_se(path_is_mount_point(dir1, NULL, AT_SYMLINK_FOLLOW) == 0);
406         assert_se(path_is_mount_point(dir1, NULL, 0) == 0);
407         assert_se(path_is_mount_point(dirlink1, NULL, AT_SYMLINK_FOLLOW) == 0);
408         assert_se(path_is_mount_point(dirlink1, NULL, 0) == 0);
409
410         /* file in subdirectory mountpoints */
411         dir1file = path_join(NULL, dir1, "file");
412         assert_se(dir1file);
413         fd = open(dir1file, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0664);
414         assert_se(fd > 0);
415         close(fd);
416
417         assert_se(path_is_mount_point(dir1file, NULL, AT_SYMLINK_FOLLOW) == 0);
418         assert_se(path_is_mount_point(dir1file, NULL, 0) == 0);
419         assert_se(path_is_mount_point(dirlink1file, NULL, AT_SYMLINK_FOLLOW) == 0);
420         assert_se(path_is_mount_point(dirlink1file, NULL, 0) == 0);
421
422         /* these tests will only work as root */
423         if (mount(file1, file2, NULL, MS_BIND, NULL) >= 0) {
424                 int rt, rf, rlt, rlf, rl1t, rl1f;
425
426                 /* files */
427                 /* capture results in vars, to avoid dangling mounts on failure */
428                 rf = path_is_mount_point(file2, NULL, 0);
429                 rt = path_is_mount_point(file2, NULL, AT_SYMLINK_FOLLOW);
430                 rlf = path_is_mount_point(link2, NULL, 0);
431                 rlt = path_is_mount_point(link2, NULL, AT_SYMLINK_FOLLOW);
432
433                 assert_se(umount(file2) == 0);
434
435                 assert_se(rf == 1);
436                 assert_se(rt == 1);
437                 assert_se(rlf == 0);
438                 assert_se(rlt == 1);
439
440                 /* dirs */
441                 dir2file = path_join(NULL, dir2, "file");
442                 assert_se(dir2file);
443                 fd = open(dir2file, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0664);
444                 assert_se(fd > 0);
445                 close(fd);
446
447                 assert_se(mount(dir2, dir1, NULL, MS_BIND, NULL) >= 0);
448
449                 rf = path_is_mount_point(dir1, NULL, 0);
450                 rt = path_is_mount_point(dir1, NULL, AT_SYMLINK_FOLLOW);
451                 rlf = path_is_mount_point(dirlink1, NULL, 0);
452                 rlt = path_is_mount_point(dirlink1, NULL, AT_SYMLINK_FOLLOW);
453                 /* its parent is a mount point, but not /file itself */
454                 rl1f = path_is_mount_point(dirlink1file, NULL, 0);
455                 rl1t = path_is_mount_point(dirlink1file, NULL, AT_SYMLINK_FOLLOW);
456
457                 assert_se(umount(dir1) == 0);
458
459                 assert_se(rf == 1);
460                 assert_se(rt == 1);
461                 assert_se(rlf == 0);
462                 assert_se(rlt == 1);
463                 assert_se(rl1f == 0);
464                 assert_se(rl1t == 0);
465
466         } else
467                 printf("Skipping bind mount file test: %m\n");
468
469         assert_se(rm_rf(tmp_dir, REMOVE_ROOT|REMOVE_PHYSICAL) == 0);
470 }
471
472 static void test_file_in_same_dir(void) {
473         char *t;
474
475         t = file_in_same_dir("/", "a");
476         assert_se(streq(t, "/a"));
477         free(t);
478
479         t = file_in_same_dir("/", "/a");
480         assert_se(streq(t, "/a"));
481         free(t);
482
483         t = file_in_same_dir("", "a");
484         assert_se(streq(t, "a"));
485         free(t);
486
487         t = file_in_same_dir("a/", "a");
488         assert_se(streq(t, "a/a"));
489         free(t);
490
491         t = file_in_same_dir("bar/foo", "bar");
492         assert_se(streq(t, "bar/bar"));
493         free(t);
494 }
495
496 static void test_filename_is_valid(void) {
497         char foo[FILENAME_MAX+2];
498         int i;
499
500         assert_se(!filename_is_valid(""));
501         assert_se(!filename_is_valid("/bar/foo"));
502         assert_se(!filename_is_valid("/"));
503         assert_se(!filename_is_valid("."));
504         assert_se(!filename_is_valid(".."));
505
506         for (i=0; i<FILENAME_MAX+1; i++)
507                 foo[i] = 'a';
508         foo[FILENAME_MAX+1] = '\0';
509
510         assert_se(!filename_is_valid(foo));
511
512         assert_se(filename_is_valid("foo_bar-333"));
513         assert_se(filename_is_valid("o.o"));
514 }
515
516 static void test_hidden_or_backup_file(void) {
517         assert_se(hidden_or_backup_file(".hidden"));
518         assert_se(hidden_or_backup_file("..hidden"));
519         assert_se(!hidden_or_backup_file("hidden."));
520
521         assert_se(hidden_or_backup_file("backup~"));
522         assert_se(hidden_or_backup_file(".backup~"));
523
524         assert_se(hidden_or_backup_file("lost+found"));
525         assert_se(hidden_or_backup_file("aquota.user"));
526         assert_se(hidden_or_backup_file("aquota.group"));
527
528         assert_se(hidden_or_backup_file("test.rpmnew"));
529         assert_se(hidden_or_backup_file("test.dpkg-old"));
530         assert_se(hidden_or_backup_file("test.dpkg-remove"));
531         assert_se(hidden_or_backup_file("test.swp"));
532
533         assert_se(!hidden_or_backup_file("test.rpmnew."));
534         assert_se(!hidden_or_backup_file("test.dpkg-old.foo"));
535 }
536
537 #if 0 /// UNNEEDED by elogind
538 static void test_systemd_installation_has_version(const char *path) {
539         int r;
540         const unsigned versions[] = {0, 231, atoi(PACKAGE_VERSION), 999};
541         unsigned i;
542
543         for (i = 0; i < ELEMENTSOF(versions); i++) {
544                 r = systemd_installation_has_version(path, versions[i]);
545                 assert_se(r >= 0);
546                 log_info("%s has systemd >= %u: %s",
547                          path ?: "Current installation", versions[i], yes_no(r));
548         }
549 }
550 #endif // 0
551
552 int main(int argc, char **argv) {
553         log_set_max_level(LOG_DEBUG);
554         log_parse_environment();
555         log_open();
556
557         test_path();
558         test_find_binary(argv[0]);
559         test_prefixes();
560         test_path_join();
561 #if 0 /// UNNEEDED by elogind
562         test_fsck_exists();
563         test_make_relative();
564 #endif // 0
565         test_strv_resolve();
566         test_path_startswith();
567         test_prefix_root();
568         test_path_is_mount_point();
569         test_file_in_same_dir();
570         test_filename_is_valid();
571         test_hidden_or_backup_file();
572
573 #if 0 /// UNNEEDED by elogind
574         test_systemd_installation_has_version(argv[1]); /* NULL is OK */
575 #endif // 0
576
577         return 0;
578 }