PageRenderTime 35ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/runtime/ext/zlib/ext_zlib.php

https://github.com/tstarling/hiphop-php
PHP | 376 lines | 76 code | 28 blank | 272 comment | 0 complexity | 31bf7c385907d6fe9c18d431d2625377 MD5 | raw file
  1. <?hh
  2. // @generated by docskel.php
  3. /**
  4. * Close an open gz-file pointer
  5. *
  6. * @param resource $zp - The gz-file pointer. It must be valid, and must
  7. * point to a file successfully opened by gzopen().
  8. *
  9. * @return bool -
  10. */
  11. <<__Native>>
  12. function gzclose(resource $zp): bool;
  13. /**
  14. * Compress a string
  15. *
  16. * @param string $data - The data to compress.
  17. * @param int $level - The level of compression. Can be given as 0 for no
  18. * compression up to 9 for maximum compression. If -1 is used, the
  19. * default compression of the zlib library is used which is 6.
  20. *
  21. * @return string - The compressed string or FALSE if an error occurred.
  22. */
  23. <<__Native>>
  24. function gzcompress(string $data, int $level = -1): mixed;
  25. /**
  26. * Decodes a gzip compressed string
  27. *
  28. * @param string $data - The data to decode, encoded by gzencode().
  29. * @param int $length - The maximum length of data to decode.
  30. *
  31. * @return string - The decoded string, or FALSE if an error occurred.
  32. */
  33. <<__Native>>
  34. function gzdecode(string $data,
  35. int $length = 0): mixed;
  36. /**
  37. * Deflate a string
  38. *
  39. * @param string $data - The data to deflate.
  40. * @param int $level - The level of compression. Can be given as 0 for no
  41. * compression up to 9 for maximum compression. If not given, the default
  42. * compression level will be the default compression level of the zlib
  43. * library.
  44. *
  45. * @return string - The deflated string or FALSE if an error occurred.
  46. */
  47. <<__Native>>
  48. function gzdeflate(string $data, int $level = -1): mixed;
  49. /**
  50. * Create a gzip compressed string
  51. *
  52. * @param string $data - The data to encode.
  53. * @param int $level - The level of compression. Can be given as 0 for no
  54. * compression up to 9 for maximum compression. If not given, the default
  55. * compression level will be the default compression level of the zlib
  56. * library.
  57. * @param int $encoding_mode - The encoding mode. Can be FORCE_GZIP (the
  58. * default) or FORCE_DEFLATE. Prior to PHP 5.4.0, using FORCE_DEFLATE
  59. * results in a standard zlib deflated string (inclusive zlib headers)
  60. * after a gzip file header but without the trailing crc32 checksum. In
  61. * PHP 5.4.0 and later, FORCE_DEFLATE generates RFC 1950 compliant
  62. * output, consisting of a zlib header, the deflated data, and an Adler
  63. * checksum.
  64. *
  65. * @return string - The encoded string, or FALSE if an error occurred.
  66. */
  67. <<__Native>>
  68. function gzencode(string $data,
  69. int $level = -1,
  70. int $encoding_mode = FORCE_GZIP): mixed;
  71. /**
  72. * Test for on a gz-file pointer
  73. *
  74. * @param resource $zp - The gz-file pointer. It must be valid, and must
  75. * point to a file successfully opened by gzopen().
  76. *
  77. * @return bool - Returns TRUE if the gz-file pointer is at EOF or an
  78. * error occurs; otherwise returns FALSE.
  79. */
  80. <<__Native>>
  81. function gzeof(resource $zp): bool;
  82. /**
  83. * Read entire gz-file into an array
  84. *
  85. * @param string $filename - The file name.
  86. * @param int $use_include_path - You can set this optional parameter to
  87. * 1, if you want to search for the file in the include_path too.
  88. *
  89. * @return array - An array containing the file, one line per cell.
  90. */
  91. <<__Native>>
  92. function gzfile(string $filename,
  93. int $use_include_path = 0): mixed;
  94. /**
  95. * Get character from gz-file pointer
  96. *
  97. * @param resource $zp - The gz-file pointer. It must be valid, and must
  98. * point to a file successfully opened by gzopen().
  99. *
  100. * @return string - The uncompressed character or FALSE on EOF (unlike
  101. * gzeof()).
  102. */
  103. <<__Native>>
  104. function gzgetc(resource $zp): mixed;
  105. /**
  106. * Get line from file pointer
  107. *
  108. * @param resource $zp - The gz-file pointer. It must be valid, and must
  109. * point to a file successfully opened by gzopen().
  110. * @param int $length - The length of data to get.
  111. *
  112. * @return string - The uncompressed string, or FALSE on error.
  113. */
  114. <<__Native>>
  115. function gzgets(resource $zp,
  116. int $length = 1024): mixed;
  117. /**
  118. * Get line from gz-file pointer and strip HTML tags
  119. *
  120. *
  121. * @param resource $zp - The gz-file pointer. It must be valid, and must
  122. * point to a file successfully opened by gzopen().
  123. * @param int $length - The length of data to get.
  124. * @param string $allowable_tags - You can use this optional parameter to
  125. * specify tags which should not be stripped.
  126. *
  127. * @return string - The uncompressed and striped string, or FALSE on
  128. * error.
  129. */
  130. <<__Native>>
  131. function gzgetss(resource $zp,
  132. int $length = 0,
  133. string $allowable_tags = ''): mixed;
  134. /**
  135. * Inflate a deflated string
  136. *
  137. * @param string $data - The data compressed by gzdeflate().
  138. * @param int $length - The maximum length of data to decode.
  139. *
  140. * @return string - The original uncompressed data or FALSE on error.
  141. * The function will return an error if the uncompressed data is more
  142. * than 32768 times the length of the compressed input data or more than
  143. * the optional parameter length.
  144. */
  145. <<__Native>>
  146. function gzinflate(string $data, int $length = 0): mixed;
  147. /**
  148. * Open gz-file
  149. *
  150. * @param string $filename - The file name.
  151. * @param string $mode - As in fopen() (rb or wb) but can also include a
  152. * compression level (wb9) or a strategy: f for filtered data as in wb6f,
  153. * h for Huffman only compression as in wb1h. (See the description of
  154. * deflateInit2 in zlib.h for more information about the strategy
  155. * parameter.)
  156. * @param int $use_include_path - You can set this optional parameter to
  157. * 1, if you want to search for the file in the include_path too.
  158. *
  159. * @return resource - Returns a file pointer to the file opened, after
  160. * that, everything you read from this file descriptor will be
  161. * transparently decompressed and what you write gets compressed. If
  162. * the open fails, the function returns FALSE.
  163. */
  164. <<__Native>>
  165. function gzopen(string $filename,
  166. string $mode,
  167. int $use_include_path = 0): mixed;
  168. /**
  169. * Output all remaining data on a gz-file pointer
  170. *
  171. *
  172. * @param resource $zp - The gz-file pointer. It must be valid, and must
  173. * point to a file successfully opened by gzopen().
  174. *
  175. * @return int - The number of uncompressed characters read from gz and
  176. * passed through to the input, or FALSE on error.
  177. */
  178. <<__Native>>
  179. function gzpassthru(resource $zp): mixed;
  180. /**
  181. * Alias of gzwrite()
  182. */
  183. function gzputs(resource $zp, string $string, int $length = 0): mixed {
  184. return gzwrite($zp, $string, $length);
  185. }
  186. /**
  187. * Binary-safe gz-file read
  188. *
  189. * @param resource $zp - The gz-file pointer. It must be valid, and must
  190. * point to a file successfully opened by gzopen().
  191. * @param int $length - The number of bytes to read.
  192. *
  193. * @return string - The data that have been read.
  194. */
  195. <<__Native>>
  196. function gzread(resource $zp,
  197. int $length = 0): mixed;
  198. /**
  199. * Rewind the position of a gz-file pointer
  200. *
  201. * @param resource $zp - The gz-file pointer. It must be valid, and must
  202. * point to a file successfully opened by gzopen().
  203. *
  204. * @return bool -
  205. */
  206. <<__Native>>
  207. function gzrewind(resource $zp): bool;
  208. /**
  209. * Seek on a gz-file pointer
  210. *
  211. * @param resource $zp - The gz-file pointer. It must be valid, and must
  212. * point to a file successfully opened by gzopen().
  213. * @param int $offset - The seeked offset.
  214. * @param int $whence - whence values are: SEEK_SET - Set position equal
  215. * to offset bytes. SEEK_CUR - Set position to current location plus
  216. * offset. If whence is not specified, it is assumed to be SEEK_SET.
  217. *
  218. * @return int - Upon success, returns 0; otherwise, returns -1. Note
  219. * that seeking past EOF is not considered an error.
  220. */
  221. <<__Native>>
  222. function gzseek(resource $zp,
  223. int $offset,
  224. int $whence = SEEK_SET): mixed;
  225. /**
  226. * Tell gz-file pointer read/write position
  227. *
  228. * @param resource $zp - The gz-file pointer. It must be valid, and must
  229. * point to a file successfully opened by gzopen().
  230. *
  231. * @return int - The position of the file pointer or FALSE if an error
  232. * occurs.
  233. */
  234. <<__Native>>
  235. function gztell(resource $zp): mixed;
  236. /**
  237. * Uncompress a compressed string
  238. *
  239. * @param string $data - The data compressed by gzcompress().
  240. * @param int $length - The maximum length of data to decode.
  241. *
  242. * @return string - The original uncompressed data or FALSE on error.
  243. * The function will return an error if the uncompressed data is more
  244. * than 32768 times the length of the compressed input data or more than
  245. * the optional parameter length.
  246. */
  247. <<__Native>>
  248. function gzuncompress(string $data, int $length = 0): mixed;
  249. /**
  250. * Binary-safe gz-file write
  251. *
  252. * @param resource $zp - The gz-file pointer. It must be valid, and must
  253. * point to a file successfully opened by gzopen().
  254. * @param string $string - The string to write.
  255. * @param int $length - The number of uncompressed bytes to write. If
  256. * supplied, writing will stop after length (uncompressed) bytes have
  257. * been written or the end of string is reached, whichever comes first.
  258. * Note that if the length argument is given, then the
  259. * magic_quotes_runtime configuration option will be ignored and no
  260. * slashes will be stripped from string.
  261. *
  262. * @return int - Returns the number of (uncompressed) bytes written to
  263. * the given gz-file stream.
  264. */
  265. <<__Native>>
  266. function gzwrite(resource $zp,
  267. string $string,
  268. int $length = 0): mixed;
  269. /**
  270. * Output a gz-file
  271. *
  272. * @param string $filename - The file name. This file will be opened from
  273. * the filesystem and its contents written to standard output.
  274. * @param int $use_include_path - You can set this optional parameter to
  275. * 1, if you want to search for the file in the include_path too.
  276. *
  277. * @return int - Returns the number of (uncompressed) bytes read from the
  278. * file. If an error occurs, FALSE is returned and unless the function
  279. * was called as @readgzfile, an error message is printed.
  280. */
  281. <<__Native>>
  282. function readgzfile(string $filename,
  283. int $use_include_path = 0): mixed;
  284. /**
  285. * This function compresses the given string using the nzlib data format, which
  286. * is primarily used for compressing and uncompressing memcache values.
  287. *
  288. * @param string $uncompressed - The uncompressed data
  289. *
  290. * @return string - The compressed data, or FALSE on error
  291. */
  292. <<__Native, __HipHopSpecific>>
  293. function nzcompress(string $uncompressed): mixed;
  294. /**
  295. * This function uncompresses the given string given that it is in the nzlib
  296. * data format, which is primarily used for compressing and uncompressing
  297. * memcache values
  298. *
  299. * @param string $compressed - The data compressed by nzcompress().
  300. *
  301. * @return string - The uncompressed data or FALSE on error
  302. */
  303. <<__Native, __HipHopSpecific>>
  304. function nzuncompress(string $compressed): mixed;
  305. /**
  306. * This function compresses the given string using the lz4lib data format, which
  307. * is primarily used for compressing and uncompressing memcache values.
  308. *
  309. * @param string $uncompressed - The uncompressed data
  310. *
  311. * @return string - The compressed data, or FALSE on error
  312. */
  313. <<__Native, __HipHopSpecific>>
  314. function lz4compress(string $uncompressed): mixed;
  315. /**
  316. * This function compresses the given string using the lz4lib data format, which
  317. * is primarily used for compressing and uncompressing memcache values.
  318. *
  319. * @param string $uncompressed - The uncompressed data
  320. *
  321. * @return string - The compressed data, or FALSE on error
  322. */
  323. <<__Native, __HipHopSpecific>>
  324. function lz4hccompress(string $uncompressed): mixed;
  325. /**
  326. * This function uncompresses the given string given that it is in the lz4lib
  327. * data format, which is primarily used for compressing and uncompressing
  328. * memcache values
  329. *
  330. * @param string $compressed - The data compressed by lz4compress().
  331. *
  332. * @return string - The uncompressed data or FALSE on error
  333. */
  334. <<__Native, __HipHopSpecific>>
  335. function lz4uncompress(string $compressed): mixed;
  336. /**
  337. * Implementation detail for zlib.inflate stream filter.
  338. *
  339. * Not a public API - ideally this would be in namespace __SystemLib, but that
  340. * isn't currently supported.
  341. */
  342. <<__NativeData("__SystemLib_ChunkedInflator")>>
  343. class __SystemLib_ChunkedInflator {
  344. <<__Native>>
  345. function eof(): bool;
  346. <<__Native>>
  347. function inflateChunk(string $chunk): string;
  348. }