Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / service_runtime / include / sys / dirent.h
1 /*
2  * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_INCLUDE_SYS_DIRENT_H
8 #define NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_INCLUDE_SYS_DIRENT_H
9
10 #if defined(NACL_IN_TOOLCHAIN_HEADERS)
11 #include <sys/types.h>
12 #else
13 #include "native_client/src/trusted/service_runtime/include/machine/_types.h"
14 #endif
15
16 #if defined(NACL_IN_TOOLCHAIN_HEADERS)
17 /* check the compiler toolchain */
18 # ifdef NACL_ABI_MAXNAMLEN
19 #  if NACL_ABI_MAXNAMLEN != 255
20 #   error "MAXNAMLEN inconsistent"
21 #  endif
22 #  ifdef NAME_MAX
23 #   if NAME_MAX != 255
24 #    error "NAME_MAX inconsistent"
25 #   endif
26 #  endif
27 # else
28 #  define NACL_ABI_MAXNAMLEN 255
29 # endif
30 #else /* defined(NACL_IN_TOOLCHAIN_HEADERS) */
31 # define NACL_ABI_MAXNAMLEN 255
32 #endif
33
34 /*
35  * _dirdesc contains the state used by opendir/readdir/closedir.
36  */
37 typedef struct nacl_abi__dirdesc {
38   int   nacl_abi_dd_fd;
39   long  nacl_abi_dd_loc;
40   long  nacl_abi_dd_size;
41   char  *nacl_abi_dd_buf;
42   int   nacl_abi_dd_len;
43   long  nacl_abi_dd_seek;
44 } nacl_abi_DIR;
45
46 /*
47  * dirent represents a single directory entry.
48  */
49 struct nacl_abi_dirent {
50   nacl_abi_ino_t nacl_abi_d_ino;
51   nacl_abi_off_t nacl_abi_d_off;
52   uint16_t       nacl_abi_d_reclen;
53   char           nacl_abi_d_name[NACL_ABI_MAXNAMLEN + 1];
54 };
55
56 /*
57  * external function declarations
58  */
59 extern nacl_abi_DIR           *nacl_abi_opendir(const char *dirpath);
60 extern struct nacl_abi_dirent *nacl_abi_readdir(nacl_abi_DIR *direntry);
61 extern int                    nacl_abi_closedir(nacl_abi_DIR *direntry);
62 extern void                   nacl_abi_rewinddir(nacl_abi_DIR *direntry);
63 extern int                    nacl_abi_readdir_r(nacl_abi_DIR *direntry,
64                                                  struct nacl_abi_dirent *entry,
65                                                  struct nacl_abi_dirent **res);
66
67 #endif