/usr/lib/ats2-postiats-0.1.3/libc/SATS/dirent.sats is in ats2-lang 0.1.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | (***********************************************************************)
(* *)
(* Applied Type System *)
(* *)
(***********************************************************************)
(*
** ATS/Postiats - Unleashing the Potential of Types!
** Copyright (C) 2011-2013 Hongwei Xi, ATS Trustful Software, Inc.
** All rights reserved
**
** ATS is free software; you can redistribute it and/or modify it under
** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
** Free Software Foundation; either version 3, or (at your option) any
** later version.
**
** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
** WARRANTY; without even the implied warranty of MERCHANTABILITY or
** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
** for more details.
**
** You should have received a copy of the GNU General Public License
** along with ATS; see the file COPYING. If not, please write to the
** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
** 02110-1301, USA.
*)
(* ****** ****** *)
//
// Author: Hongwei Xi (gmhwxi AT gmail DOT com)
// Start Time: March, 2013
//
(* ****** ****** *)
%{#
#include "libc/CATS/dirent.cats"
%} // end of [%{#]
(* ****** ****** *)
#define ATS_PACKNAME "ATSLIB.libc"
#define ATS_EXTERN_PREFIX "atslib_" // prefix for external names
(* ****** ****** *)
#define RD(x) x // for commenting: read-only
#define NSH(x) x // for commenting: no sharing
#define SHR(x) x // for commenting: it is shared
(* ****** ****** *)
staload
TYPES = "libc/sys/SATS/types.sats"
typedef ino_t = $TYPES.ino_t
typedef off_t = $TYPES.off_t
(* ****** ****** *)
(*
abst@ype
DIR_t0ype = $extype"atslib_DIR_type" // = DIR
typedef DIR = DIR_t0ype
*)
absvtype DIRptr_vtype (l:addr) = ptr
vtypedef DIRptr (l:addr) = DIRptr_vtype (l)
vtypedef DIRptr0 = [l:addr | l >= null] DIRptr (l)
vtypedef DIRptr1 = [l:addr | l > null] DIRptr (l)
absview DIR_view (l:addr)
viewdef DIR_v (l:addr) = DIR_view (l)
(* ****** ****** *)
praxi
DIRptr_free_null (dirp: DIRptr (null)): void
(* ****** ****** *)
castfn
DIRptr2ptr{l:addr} (dirp: !DIRptr l):<> ptr (l)
overload ptrcast with DIRptr2ptr
(* ****** ****** *)
abst@ype
dirent_t0ype =
$extype"atslib_dirent_type" // = struct dirent
typedef dirent = dirent_t0ype
(* ****** ****** *)
fun{}
dirent$PC_NAME_MAX (): intGte(0) // HX: default=256
(* ****** ****** *)
absvtype direntp_vtype (l:addr) = ptr
vtypedef direntp (l:addr) = direntp_vtype (l)
vtypedef Direntp0 = [l:addr] direntp (l)
vtypedef Direntp1 = [l:addr | l > null] direntp (l)
(* ****** ****** *)
//
castfn
direntp2ptr{l:addr} (x: !direntp (l)):<> ptr (l)
overload ptrcast with direntp2ptr
//
(* ****** ****** *)
castfn
direntp_get_viewptr{l:agz}
(
x: !direntp l
) :<> (
dirent @ l, minus (direntp l, dirent @ l) | ptr l
) // end of [direntp_get_viewptr]
praxi
direntp_free_null (direntp (null)): void
fun direntp_free (x: Direntp0): void = "mac#%"
(* ****** ****** *)
fun dirent_get_d_ino (ent: &RD(dirent)):<> ino_t = "mac#%"
(* ****** ****** *)
//
fun
dirent_get_d_name
(ent: &RD(dirent)):<> vStrptr1 = "mac#%"
fun{}
dirent_get_d_name_gc (ent: &RD(dirent)):<!wrt> Strptr1
//
(* ****** ****** *)
//
fun
direntp_get_d_name
(entp: !Direntp1):<> vStrptr1 = "mac#%"
fun{}
direntp_get_d_name_gc (entp: !Direntp1):<!wrt> Strptr1
//
(* ****** ****** *)
//
fun{}
compare_dirent_string
(ent: &RD(dirent), str: NSH(string)):<> int
//
(* ****** ****** *)
fun opendir (dname: NSH(string)): DIRptr0 = "mac#%"
fun opendir_exn (dname: NSH(string)): DIRptr1 = "ext#%"
(* ****** ****** *)
fun closedir{l:agz}
(
dirp: !DIRptr (l) >> ptr l
) :<!wrt>
[i:int | i <= 0]
(
option_v (DIR_v (l), i < 0) | int i
) = "mac#%" // end of [closedir]
fun closedir_exn (dirp: DIRptr1):<!exnwrt> void = "ext#%"
(* ****** ****** *)
fun readdir
(
dirp: !DIRptr1
) :<!refwrt> [l:addr]
(
option_v (vtakeout0 (dirent@l), l > null) | ptr (l)
) = "mac#%" // end of [readdir]
(* ****** ****** *)
fun readdir_r
(
dirp: !DIRptr1
, ent: &dirent? >> opt (dirent, l > null)
, result: &ptr? >> ptr(l)
) :<!wrt> #[l:addr;i:int | i >= 0] int(i) = "mac#%"
fun{} readdir_r_gc (dirp: !DIRptr1): Direntp0
(* ****** ****** *)
/*
int scandir
(
const char *dirp
, struct dirent ***namelist
, int (*filter)(const struct dirent *)
, int (*compar)(const struct dirent **, const struct dirent**)
) ;
*/
fun scandir
(
dirp: NSH(string)
, namelst: &(ptr?) >> ptr(*direntpp*)
, filter: (&dirent) -> int
, compar: (&ptr(*direntp*), &ptr(*direntp*)) -> int
) : int = "mac#%" // endfun
fun alphasort // POSIX-2008
(entp1: &ptr, entp2: &ptr):<> int = "mac#%"
fun versionsort // GNU-extension
(entp1: &ptr, entp2: &ptr):<> int = "mac#%"
(* ****** ****** *)
fun rewinddir (dirp: !DIRptr1): void = "mac#%"
(* ****** ****** *)
fun seekdir
(dirp: !DIRptr1, off: off_t): void = "mac#%"
// end of [seekdir]
(* ****** ****** *)
fun telldir (dirp: !DIRptr1): off_t = "mac#%"
(* ****** ****** *)
(* end of [dirent.sats] *)
|