1 /* io.h 2 * Copyright (C) 2001-2015, Parrot Foundation. 3 * Overview: 4 * Parrot IO subsystem 5 * References: 6 * Perl6 RFCs (14,30,47,60,186,239,321,345,350) 7 * Some ideas and goals from Perl5.7 and Nick Ing-Simmons' work 8 * Some ideas from AT&T SFIO 9 */ 10 11 #ifndef PARROT_IO_H_GUARD 12 #define PARROT_IO_H_GUARD 13 14 #include <stdio.h> 15 16 /* &gen_from_def(stdio.pasm) */ 17 18 #define PIO_STDIN_FILENO 0 19 #define PIO_STDOUT_FILENO 1 20 #define PIO_STDERR_FILENO 2 21 22 /* &end_gen */ 23 24 /* Read whatever is available */ 25 #define PIO_READ_SIZE_ANY ((size_t)-1) 26 27 /* Block Size. Returned from Parrot_io_internal_getblksize */ 28 #ifdef BLKSIZE 29 # define PIO_BLKSIZE BLKSIZE 30 #else 31 # define PIO_BLKSIZE 8192 32 #endif 33 34 /* Buffer flags */ 35 #define PIO_BF_MALLOC 0x0001 /* Buffer malloced */ 36 #define PIO_BF_MMAP 0x0002 /* Buffer mmap()ed */ 37 #define PIO_BF_LINEBUF 0x0004 /* Flushes on newline */ 38 #define PIO_BF_BLKBUF 0x0008 /* Raw block-based buffering */ 39 40 /* Number of pre-allocated standard IO streams, only 3 are needed */ 41 #define PIO_NR_OPEN 3 /* Nr of internal IO handles */ 42 43 /* Handle flags */ 44 #define PIO_F_READ 00000001 /* File is opened for reading */ 45 #define PIO_F_WRITE 00000002 /* File is opened for writing */ 46 #define PIO_F_APPEND 00000004 /* File is opened for append */ 47 #define PIO_F_TRUNC 00000010 48 #define PIO_F_EOF 00000020 /* File is at EOF */ 49 #define PIO_F_PIPE 00000040 /* FileHandle is in pipe mode */ 50 #define PIO_F_CONSOLE 00001000 /* A terminal */ 51 #define PIO_F_READLINE 00002000 /* user interactive readline */ 52 #define PIO_F_SOFT_SP 00040000 /* Python softspace */ 53 #define PIO_F_SHARED 00100000 /* Stream shares a file handle */ 54 #define PIO_F_ASYNC 01000000 /* Handle is asynchronous */ 55 #define PIO_F_BINARY 02000000 /* Open in binary mode */ 56 57 /* IO VTABLE Flags */ 58 #define PIO_VF_DEFAULT_READ_BUF 0x0001 /* This type uses read buffers by default */ 59 #define PIO_VF_DEFAULT_WRITE_BUF 0x0002 /* This type uses write buffers by default */ 60 #define PIO_VF_FLUSH_ON_CLOSE 0x0004 /* Flush before closing */ 61 #define PIO_VF_PATH_NOT_REQUIRED 0x0008 /* This handle does not require a path 62 for .open() */ 63 #define PIO_VF_AWAYS_READABLE 0x0010 /* Handle can always be read */ 64 #define PIO_VF_MULTI_READABLE 0x0020 /* Can perform multiple low-level read 65 operations to satisfy a large request */ 66 #define PIO_VF_SYNC_IO 0x0040 /* This type needs synchronization 67 before r/w operations due to buffering */ 68 69 /* 70 * pioctl argument constants. These don't have to 71 * be unique across io commands. 72 */ 73 #define PIOCTL_NONBUF 0 74 #define PIOCTL_LINEBUF 1 75 #define PIOCTL_BLKBUF 2 76 77 /* 78 * Enum definition of constants for Socket.socket. 79 * Note that these are the *parrot* values for these defines; the system 80 * values vary from one platform to the next. See the lookup tables in 81 * socket_unix.c and socket_win32.c for the mappings. 82 */ 83 84 /* &gen_from_enum(socket.pasm) */ 85 typedef enum { 86 PIO_PF_LOCAL = 0, 87 PIO_PF_UNIX = 1, 88 PIO_PF_INET = 2, 89 PIO_PF_INET6 = 3, 90 PIO_PF_MAX = 4 /* last elem */ 91 } Socket_Protocol_Family; 92 93 typedef enum { 94 PIO_SOCK_PACKET = 0, 95 PIO_SOCK_STREAM = 1, 96 PIO_SOCK_DGRAM = 2, 97 PIO_SOCK_RAW = 3, 98 PIO_SOCK_RDM = 4, 99 PIO_SOCK_SEQPACKET = 5, 100 PIO_SOCK_MAX = 6 /* last element */ 101 } Socket_Socket_Type; 102 103 typedef enum { 104 PIO_PROTO_TCP = 6, 105 PIO_PROTO_UDP = 17 /* last element */ 106 } Socket_Protocol; 107 /* &end_gen */ 108 109 extern PIOOFF_T piooffsetzero; 110 111 typedef struct _ParrotIOData ParrotIOData; 112 113 /* BUFFERING */ 114 typedef struct _io_buffer { 115 INTVAL flags; /* Flags on this buffer */ 116 size_t raw_reads; /* Number of raw reads */ 117 size_t buffer_size; /* Current allocated size */ 118 const STR_VTABLE *encoding; /* Encoding used by this buffer */ 119 char *buffer_ptr; /* ptr to the buffer mem block */ 120 char *buffer_start; /* ptr to the start of the data */ 121 char *buffer_end; /* ptr to the end of the data */ 122 } IO_BUFFER; 123 124 /* For examples of mmap-like behavior on windows, see: 125 http://msdn.microsoft.com/en-us/library/windows/desktop/aa366551(v=vs.85).aspx 126 */ 127 128 /* IO VTABLEs */ 129 /* Legend: 130 _s: This function operates on a Parrot STRING* 131 _b: This function operates on a raw char* buffer (Possibly from ByteBuffer) 132 */ 133 134 typedef INTVAL (*io_vtable_read_b) (PARROT_INTERP, PMC *handle, 135 ARGOUT(char * buffer), 136 const size_t byte_length); 137 typedef INTVAL (*io_vtable_write_b) (PARROT_INTERP, PMC *handle, 138 ARGIN(const char * buffer), 139 const size_t byte_length); 140 typedef INTVAL (*io_vtable_flush) (PARROT_INTERP, PMC *handle); 141 typedef INTVAL (*io_vtable_is_eof) (PARROT_INTERP, const PMC *handle); 142 typedef void (*io_vtable_set_eof) (PARROT_INTERP, PMC *handle, 143 INTVAL is_set); 144 typedef PIOOFF_T (*io_vtable_tell) (PARROT_INTERP, const PMC *handle); 145 typedef PIOOFF_T (*io_vtable_seek) (PARROT_INTERP, PMC *handle, 146 const PIOOFF_T offset, const INTVAL whence); 147 typedef void (*io_vtable_adv_position) (PARROT_INTERP, PMC *handle, 148 const size_t len); 149 typedef void (*io_vtable_set_position) (PARROT_INTERP, PMC *handle, 150 const PIOOFF_T pos); 151 typedef PIOOFF_T (*io_vtable_get_position) (PARROT_INTERP, const PMC *handle); 152 typedef INTVAL (*io_vtable_open) (PARROT_INTERP, PMC *handle, 153 ARGIN(const STRING *path), 154 const INTVAL flags, 155 ARGIN(const STRING *mode)); 156 typedef INTVAL (*io_vtable_is_open) (PARROT_INTERP, const PMC *handle); 157 typedef INTVAL (*io_vtable_close) (PARROT_INTERP, PMC *handle); 158 typedef void (*io_vtable_set_flags) (PARROT_INTERP, PMC *handle, 159 const INTVAL flags); 160 typedef INTVAL (*io_vtable_get_flags) (PARROT_INTERP, const PMC *handle); 161 typedef size_t (*io_vtable_total_size) (PARROT_INTERP, const PMC *handle); 162 typedef PIOHANDLE (*io_vtable_get_piohandle)(PARROT_INTERP, const PMC *handle); 163 typedef const STR_VTABLE *(*io_vtable_get_encoding) (PARROT_INTERP, const PMC *handle); 164 165 typedef struct _io_vtable { 166 const char * name; /* Name of this vtable type */ 167 INTVAL number; /* Index number of this vtable */ 168 INTVAL flags; /* Flags for this type */ 169 io_vtable_read_b read_b; /* Read bytes from the handle */ 170 io_vtable_write_b write_b; /* Write bytes to the handle */ 171 io_vtable_flush flush; /* Flush the handle */ 172 io_vtable_is_eof is_eof; /* Determine if at end-of-file */ 173 io_vtable_set_eof set_eof; /* Set or clear the passed-EOF flag */ 174 io_vtable_open open; /* Open the handle */ 175 io_vtable_is_open is_open; /* Determine if the handle is open */ 176 io_vtable_close close; /* Close the handle */ 177 io_vtable_tell tell; /* Get on-disk file position */ 178 io_vtable_seek seek; /* Seek to new position */ 179 io_vtable_adv_position adv_position; /* Advance handle (in-mem) position */ 180 io_vtable_set_position set_position; /* Set handle (in-mem) position */ 181 io_vtable_get_position get_position; /* Get handle (in-mem) position */ 182 io_vtable_get_flags get_flags; /* Get the flags */ 183 io_vtable_set_flags set_flags; /* Set the flags */ 184 io_vtable_get_encoding get_encoding; /* Get the handle encoding */ 185 io_vtable_total_size total_size; /* Get the total size, if possible */ 186 io_vtable_get_piohandle get_piohandle; /* Get the raw file PIOHANDLE */ 187 } IO_VTABLE; 188 189 /* Indices to common IO vtables */ 190 #define IO_VTABLE_FILEHANDLE 0 191 #define IO_VTABLE_PIPE 1 192 #define IO_VTABLE_SOCKET 2 193 #define IO_VTABLE_STRINGHANDLE 3 194 #define IO_VTABLE_USER 4 195 196 /* get_pointer values for common io-related pointer values. 197 ALL IO handle types MUST implement get_pointer and MUST respond to these 198 values. */ 199 #define IO_PTR_IDX_VTABLE 0 200 #define IO_PTR_IDX_READ_BUFFER 1 201 #define IO_PTR_IDX_WRITE_BUFFER 2 202 203 /* Specify that the buffer may be any size */ 204 #define BUFFER_SIZE_ANY (size_t)-1 205 #define BUFFER_FLAGS_ANY (INTVAL)0 206 207 /* Helpful wrappers to get common pointers from IO handle PMCs */ 208 #define IO_GET_VTABLE(i, p) \ 209 ((const IO_VTABLE *)VTABLE_get_pointer_keyed_int((i), (p), IO_PTR_IDX_VTABLE)) 210 #define IO_GET_READ_BUFFER(i, p) \ 211 ((IO_BUFFER *)VTABLE_get_pointer_keyed_int((i), (p), IO_PTR_IDX_READ_BUFFER)) 212 #define IO_GET_WRITE_BUFFER(i, p) \ 213 ((IO_BUFFER *)VTABLE_get_pointer_keyed_int((i), (p), IO_PTR_IDX_WRITE_BUFFER)) 214 215 /* io/api.c - Public API functions */ 216 /* HEADERIZER BEGIN: src/io/api.c */ 217 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 218 219 PARROT_EXPORT 220 INTVAL Parrot_io_close(PARROT_INTERP, ARGMOD(PMC *handle), INTVAL autoflush) 221 __attribute__nonnull__(1) 222 __attribute__nonnull__(2) 223 FUNC_MODIFIES(*handle); 224 225 PARROT_EXPORT 226 PARROT_DEPRECATED 227 INTVAL Parrot_io_close_handle(PARROT_INTERP, ARGMOD(PMC *pmc)) 228 __attribute__nonnull__(1) 229 __attribute__nonnull__(2) 230 FUNC_MODIFIES(*pmc); 231 232 PARROT_EXPORT 233 PARROT_WARN_UNUSED_RESULT 234 INTVAL Parrot_io_eof(PARROT_INTERP, ARGIN(const PMC * const handle)) 235 __attribute__nonnull__(1) 236 __attribute__nonnull__(2); 237 238 PARROT_EXPORT 239 PARROT_IGNORABLE_RESULT 240 INTVAL /*@alt void@*/ 241 Parrot_io_eprintf( 242 NULLOK(PARROT_INTERP), 243 ARGIN(const char *s), 244 ...) 245 __attribute__nonnull__(2); 246 247 PARROT_EXPORT 248 PARROT_WARN_UNUSED_RESULT 249 PARROT_CANNOT_RETURN_NULL 250 PMC * Parrot_io_fdopen(PARROT_INTERP, 251 ARGIN(PMC *pmc), 252 PIOHANDLE fd, 253 ARGIN(STRING *sflags)) 254 __attribute__nonnull__(1) 255 __attribute__nonnull__(2) 256 __attribute__nonnull__(4); 257 258 PARROT_EXPORT 259 PARROT_WARN_UNUSED_RESULT 260 PARROT_CANNOT_RETURN_NULL 261 PMC * Parrot_io_fdopen_flags(PARROT_INTERP, 262 ARGMOD(PMC *filehandle), 263 PIOHANDLE fd, 264 INTVAL flags) 265 __attribute__nonnull__(1) 266 __attribute__nonnull__(2) 267 FUNC_MODIFIES(*filehandle); 268 269 PARROT_EXPORT 270 void Parrot_io_finish(PARROT_INTERP) 271 __attribute__nonnull__(1); 272 273 PARROT_EXPORT 274 size_t Parrot_io_flush(PARROT_INTERP, ARGMOD(PMC *handle)) 275 __attribute__nonnull__(1) 276 __attribute__nonnull__(2) 277 FUNC_MODIFIES(*handle); 278 279 PARROT_EXPORT 280 PARROT_DEPRECATED 281 void Parrot_io_flush_handle(PARROT_INTERP, ARGMOD(PMC *pmc)) 282 __attribute__nonnull__(1) 283 __attribute__nonnull__(2) 284 FUNC_MODIFIES(*pmc); 285 286 PARROT_EXPORT 287 PARROT_IGNORABLE_RESULT 288 INTVAL /*@alt void@*/ 289 Parrot_io_fprintf(PARROT_INTERP, 290 ARGIN(const PMC * const pmc), 291 ARGIN_FORMAT(const char *s), 292 ...) 293 __attribute__nonnull__(1) 294 __attribute__nonnull__(2) 295 __attribute__format__(3, 4) 296 __attribute__nonnull__(3); 297 298 PARROT_EXPORT 299 PARROT_WARN_UNUSED_RESULT 300 PARROT_CAN_RETURN_NULL 301 const IO_VTABLE * Parrot_io_get_vtable(PARROT_INTERP, 302 INTVAL idx, 303 ARGIN_NULLOK(const char * name)) 304 __attribute__nonnull__(1); 305 306 PARROT_EXPORT 307 PARROT_WARN_UNUSED_RESULT 308 PARROT_DEPRECATED 309 PIOHANDLE Parrot_io_getfd(PARROT_INTERP, ARGIN(PMC *pmc)) 310 __attribute__nonnull__(1) 311 __attribute__nonnull__(2); 312 313 PARROT_EXPORT 314 PARROT_WARN_UNUSED_RESULT 315 INTVAL Parrot_io_getprotobyname(PARROT_INTERP, ARGIN(STRING * name)) 316 __attribute__nonnull__(1) 317 __attribute__nonnull__(2); 318 319 PARROT_EXPORT 320 void Parrot_io_init(PARROT_INTERP) 321 __attribute__nonnull__(1); 322 323 PARROT_EXPORT 324 PARROT_WARN_UNUSED_RESULT 325 INTVAL Parrot_io_is_async(PARROT_INTERP, ARGMOD(PMC *pmc)) 326 __attribute__nonnull__(1) 327 __attribute__nonnull__(2) 328 FUNC_MODIFIES(*pmc); 329 330 PARROT_EXPORT 331 PARROT_WARN_UNUSED_RESULT 332 INTVAL Parrot_io_is_closed(PARROT_INTERP, ARGIN(PMC *pmc)) 333 __attribute__nonnull__(1) 334 __attribute__nonnull__(2); 335 336 PARROT_EXPORT 337 PARROT_WARN_UNUSED_RESULT 338 INTVAL Parrot_io_is_tty_handle(PARROT_INTERP, ARGIN(PMC *pmc)) 339 __attribute__nonnull__(1) 340 __attribute__nonnull__(2); 341 342 PARROT_EXPORT 343 PARROT_WARN_UNUSED_RESULT 344 PIOOFF_T Parrot_io_make_offset(INTVAL offset); 345 346 PARROT_EXPORT 347 PARROT_WARN_UNUSED_RESULT 348 PIOOFF_T Parrot_io_make_offset32(INTVAL hi, INTVAL lo); 349 350 PARROT_EXPORT 351 PARROT_WARN_UNUSED_RESULT 352 PARROT_CANNOT_RETURN_NULL 353 PMC * Parrot_io_open(PARROT_INTERP, 354 ARGIN(PMC *pmc), 355 ARGIN(STRING *path), 356 ARGIN(STRING *mode)) 357 __attribute__nonnull__(1) 358 __attribute__nonnull__(2) 359 __attribute__nonnull__(3) 360 __attribute__nonnull__(4); 361 362 PARROT_EXPORT 363 PARROT_WARN_UNUSED_RESULT 364 PARROT_CANNOT_RETURN_NULL 365 PARROT_DEPRECATED 366 PMC * Parrot_io_open_handle(PARROT_INTERP, 367 ARGIN(PMC *pmc), 368 ARGIN(STRING *path), 369 ARGIN(STRING *mode)) 370 __attribute__nonnull__(1) 371 __attribute__nonnull__(2) 372 __attribute__nonnull__(3) 373 __attribute__nonnull__(4); 374 375 PARROT_EXPORT 376 PARROT_WARN_UNUSED_RESULT 377 PARROT_CANNOT_RETURN_NULL 378 STRING * Parrot_io_peek(PARROT_INTERP, ARGMOD(PMC *handle)) 379 __attribute__nonnull__(1) 380 __attribute__nonnull__(2) 381 FUNC_MODIFIES(*handle); 382 383 PARROT_EXPORT 384 INTVAL Parrot_io_poll(PARROT_INTERP, 385 ARGMOD(PMC *pmc), 386 INTVAL which, 387 INTVAL sec, 388 INTVAL usec) 389 __attribute__nonnull__(1) 390 __attribute__nonnull__(2) 391 FUNC_MODIFIES(*pmc); 392 393 PARROT_EXPORT 394 PARROT_IGNORABLE_RESULT 395 INTVAL /*@alt void@*/ 396 Parrot_io_pprintf(PARROT_INTERP, 397 const PIOHANDLE os_handle, 398 ARGIN_FORMAT(const char *s), 399 ...) 400 __attribute__nonnull__(1) 401 __attribute__format__(3, 4) 402 __attribute__nonnull__(3); 403 404 PARROT_EXPORT 405 PARROT_IGNORABLE_RESULT 406 INTVAL /*@alt void@*/ 407 Parrot_io_printf(PARROT_INTERP, 408 ARGIN_FORMAT(const char *s), 409 ...) 410 __attribute__nonnull__(1) 411 __attribute__format__(2, 3) 412 __attribute__nonnull__(2); 413 414 PARROT_EXPORT 415 PARROT_DEPRECATED 416 INTVAL Parrot_io_putps(PARROT_INTERP, 417 ARGIN(const PMC * const pmc), 418 ARGIN(const STRING * const s)) 419 __attribute__nonnull__(1) 420 __attribute__nonnull__(2) 421 __attribute__nonnull__(3); 422 423 PARROT_EXPORT 424 PARROT_DEPRECATED 425 INTVAL Parrot_io_puts(PARROT_INTERP, 426 ARGIN(const PMC * const pmc), 427 ARGIN(const char *s)) 428 __attribute__nonnull__(1) 429 __attribute__nonnull__(2) 430 __attribute__nonnull__(3); 431 432 PARROT_EXPORT 433 PARROT_CANNOT_RETURN_NULL 434 PMC * Parrot_io_read_byte_buffer_pmc(PARROT_INTERP, 435 ARGMOD(PMC *handle), 436 ARGMOD_NULLOK(PMC *buffer), 437 size_t byte_length) 438 __attribute__nonnull__(1) 439 __attribute__nonnull__(2) 440 FUNC_MODIFIES(*handle) 441 FUNC_MODIFIES(*buffer); 442 443 PARROT_EXPORT 444 PARROT_WARN_UNUSED_RESULT 445 PARROT_CANNOT_RETURN_NULL 446 STRING * Parrot_io_read_s(PARROT_INTERP, ARGMOD(PMC *handle), size_t length) 447 __attribute__nonnull__(1) 448 __attribute__nonnull__(2) 449 FUNC_MODIFIES(*handle); 450 451 PARROT_EXPORT 452 PARROT_WARN_UNUSED_RESULT 453 PARROT_CANNOT_RETURN_NULL 454 STRING * Parrot_io_readall_s(PARROT_INTERP, ARGMOD(PMC *handle)) 455 __attribute__nonnull__(1) 456 __attribute__nonnull__(2) 457 FUNC_MODIFIES(*handle); 458 459 PARROT_EXPORT 460 PARROT_WARN_UNUSED_RESULT 461 PARROT_CANNOT_RETURN_NULL 462 PARROT_DEPRECATED 463 STRING * Parrot_io_readline(PARROT_INTERP, ARGMOD(PMC *handle)) 464 __attribute__nonnull__(1) 465 __attribute__nonnull__(2) 466 FUNC_MODIFIES(*handle); 467 468 PARROT_EXPORT 469 PARROT_WARN_UNUSED_RESULT 470 PARROT_CANNOT_RETURN_NULL 471 STRING * Parrot_io_readline_s(PARROT_INTERP, 472 ARGMOD(PMC *handle), 473 ARGIN(STRING * terminator)) 474 __attribute__nonnull__(1) 475 __attribute__nonnull__(2) 476 __attribute__nonnull__(3) 477 FUNC_MODIFIES(*handle); 478 479 PARROT_EXPORT 480 PARROT_WARN_UNUSED_RESULT 481 PARROT_CANNOT_RETURN_NULL 482 PARROT_DEPRECATED 483 STRING * Parrot_io_reads(PARROT_INTERP, ARGMOD(PMC *pmc), size_t length) 484 __attribute__nonnull__(1) 485 __attribute__nonnull__(2) 486 FUNC_MODIFIES(*pmc); 487 488 PARROT_EXPORT 489 PARROT_CANNOT_RETURN_NULL 490 PARROT_DEPRECATED 491 STRING * Parrot_io_recv_handle(PARROT_INTERP, ARGMOD(PMC *pmc), size_t len) 492 __attribute__nonnull__(1) 493 __attribute__nonnull__(2) 494 FUNC_MODIFIES(*pmc); 495 496 PARROT_EXPORT 497 PARROT_WARN_UNUSED_RESULT 498 PIOOFF_T Parrot_io_seek(PARROT_INTERP, 499 ARGMOD(PMC *handle), 500 PIOOFF_T offset, 501 INTVAL w) 502 __attribute__nonnull__(1) 503 __attribute__nonnull__(2) 504 FUNC_MODIFIES(*handle); 505 506 PARROT_EXPORT 507 PARROT_WARN_UNUSED_RESULT 508 PIOOFF_T Parrot_io_seek_handle(PARROT_INTERP, 509 ARGMOD(PMC *handle), 510 PIOOFF_T offset, 511 INTVAL w) 512 __attribute__nonnull__(1) 513 __attribute__nonnull__(2) 514 FUNC_MODIFIES(*handle); 515 516 PARROT_EXPORT 517 PARROT_WARN_UNUSED_RESULT 518 PARROT_CANNOT_RETURN_NULL 519 PMC * Parrot_io_socket(PARROT_INTERP, 520 ARGMOD_NULLOK(PMC *socket), 521 INTVAL fam, 522 INTVAL type, 523 INTVAL proto) 524 __attribute__nonnull__(1) 525 FUNC_MODIFIES(*socket); 526 527 PARROT_EXPORT 528 PARROT_WARN_UNUSED_RESULT 529 PARROT_CANNOT_RETURN_NULL 530 PMC * Parrot_io_socket_accept(PARROT_INTERP, ARGMOD(PMC *pmc)) 531 __attribute__nonnull__(1) 532 __attribute__nonnull__(2) 533 FUNC_MODIFIES(*pmc); 534 535 PARROT_EXPORT 536 void Parrot_io_socket_bind(PARROT_INTERP, 537 ARGMOD(PMC *pmc), 538 ARGMOD(PMC *address)) 539 __attribute__nonnull__(1) 540 __attribute__nonnull__(2) 541 __attribute__nonnull__(3) 542 FUNC_MODIFIES(*pmc) 543 FUNC_MODIFIES(*address); 544 545 PARROT_EXPORT 546 void Parrot_io_socket_connect(PARROT_INTERP, 547 ARGMOD(PMC *pmc), 548 ARGMOD(PMC *address)) 549 __attribute__nonnull__(1) 550 __attribute__nonnull__(2) 551 __attribute__nonnull__(3) 552 FUNC_MODIFIES(*pmc) 553 FUNC_MODIFIES(*address); 554 555 PARROT_EXPORT 556 PARROT_WARN_UNUSED_RESULT 557 PARROT_DEPRECATED 558 INTVAL Parrot_io_socket_handle(PARROT_INTERP, 559 ARGMOD_NULLOK(PMC *socket), 560 INTVAL fam, 561 INTVAL type, 562 INTVAL proto) 563 __attribute__nonnull__(1) 564 FUNC_MODIFIES(*socket); 565 566 PARROT_EXPORT 567 void Parrot_io_socket_initialize(PARROT_INTERP, ARGMOD(PMC *socket)) 568 __attribute__nonnull__(2) 569 FUNC_MODIFIES(*socket); 570 571 PARROT_EXPORT 572 void Parrot_io_socket_listen(PARROT_INTERP, 573 ARGMOD(PMC *pmc), 574 INTVAL backlog) 575 __attribute__nonnull__(1) 576 __attribute__nonnull__(2) 577 FUNC_MODIFIES(*pmc); 578 579 PARROT_EXPORT 580 PARROT_WARN_UNUSED_RESULT 581 PARROT_CANNOT_RETURN_NULL 582 PMC * Parrot_io_socket_new(PARROT_INTERP, INTVAL flags) 583 __attribute__nonnull__(1); 584 585 PARROT_EXPORT 586 PARROT_WARN_UNUSED_RESULT 587 PARROT_CANNOT_RETURN_NULL 588 PMC * Parrot_io_STDERR(PARROT_INTERP) 589 __attribute__nonnull__(1); 590 591 PARROT_EXPORT 592 PARROT_WARN_UNUSED_RESULT 593 PARROT_CAN_RETURN_NULL 594 PMC * Parrot_io_stdhandle(PARROT_INTERP, 595 INTVAL fileno, 596 ARGIN_NULLOK(PMC *newhandle)) 597 __attribute__nonnull__(1); 598 599 PARROT_EXPORT 600 PARROT_WARN_UNUSED_RESULT 601 PARROT_CANNOT_RETURN_NULL 602 PMC * Parrot_io_STDIN(PARROT_INTERP) 603 __attribute__nonnull__(1); 604 605 PARROT_EXPORT 606 PARROT_WARN_UNUSED_RESULT 607 PARROT_CANNOT_RETURN_NULL 608 PMC * Parrot_io_STDOUT(PARROT_INTERP) 609 __attribute__nonnull__(1); 610 611 PARROT_EXPORT 612 PARROT_WARN_UNUSED_RESULT 613 PIOOFF_T Parrot_io_tell(PARROT_INTERP, ARGMOD(PMC *handle)) 614 __attribute__nonnull__(1) 615 __attribute__nonnull__(2) 616 FUNC_MODIFIES(*handle); 617 618 PARROT_EXPORT 619 PARROT_WARN_UNUSED_RESULT 620 PIOOFF_T Parrot_io_tell_handle(PARROT_INTERP, ARGMOD(PMC *handle)) 621 __attribute__nonnull__(1) 622 __attribute__nonnull__(2) 623 FUNC_MODIFIES(*handle); 624 625 PARROT_EXPORT 626 size_t Parrot_io_write_b(PARROT_INTERP, 627 ARGMOD(PMC *handle), 628 ARGIN(const void *buffer), 629 size_t byte_length) 630 __attribute__nonnull__(1) 631 __attribute__nonnull__(2) 632 __attribute__nonnull__(3) 633 FUNC_MODIFIES(*handle); 634 635 PARROT_EXPORT 636 INTVAL Parrot_io_write_s(PARROT_INTERP, 637 ARGMOD(PMC *handle), 638 ARGIN(const STRING * const s)) 639 __attribute__nonnull__(1) 640 __attribute__nonnull__(2) 641 __attribute__nonnull__(3) 642 FUNC_MODIFIES(*handle); 643 644 void io_setup_vtables(PARROT_INTERP) 645 __attribute__nonnull__(1); 646 647 PARROT_CANNOT_RETURN_NULL 648 PARROT_WARN_UNUSED_RESULT 649 PARROT_MALLOC 650 const IO_VTABLE * Parrot_io_allocate_new_vtable(PARROT_INTERP, 651 ARGIN(const char *name)) 652 __attribute__nonnull__(1) 653 __attribute__nonnull__(2); 654 655 PARROT_WARN_UNUSED_RESULT 656 INTVAL Parrot_io_buffer_size(PARROT_INTERP, 657 ARGMOD(PMC *handle), 658 INTVAL size, 659 INTVAL has_size) 660 __attribute__nonnull__(1) 661 __attribute__nonnull__(2) 662 FUNC_MODIFIES(*handle); 663 664 PARROT_CANNOT_RETURN_NULL 665 PARROT_WARN_UNUSED_RESULT 666 STRING * Parrot_io_get_buffer_mode(PARROT_INTERP, ARGMOD(PMC *handle)) 667 __attribute__nonnull__(1) 668 __attribute__nonnull__(2) 669 FUNC_MODIFIES(*handle); 670 671 PARROT_WARN_UNUSED_RESULT 672 INTVAL Parrot_io_get_flags(PARROT_INTERP, ARGIN(PMC *handle)) 673 __attribute__nonnull__(1) 674 __attribute__nonnull__(2); 675 676 PARROT_WARN_UNUSED_RESULT 677 PIOHANDLE Parrot_io_get_os_handle(PARROT_INTERP, ARGIN(PMC *handle)) 678 __attribute__nonnull__(1) 679 __attribute__nonnull__(2); 680 681 PARROT_WARN_UNUSED_RESULT 682 PIOHANDLE Parrot_io_get_standard_piohandle(PARROT_INTERP, INTVAL idx) 683 __attribute__nonnull__(1); 684 685 PARROT_WARN_UNUSED_RESULT 686 PIOOFF_T Parrot_io_make_offset_pmc(PARROT_INTERP, ARGMOD(PMC *pmc)) 687 __attribute__nonnull__(1) 688 __attribute__nonnull__(2) 689 FUNC_MODIFIES(*pmc); 690 691 void Parrot_io_mark(PARROT_INTERP, ARGIN(ParrotIOData *piodata)) 692 __attribute__nonnull__(1) 693 __attribute__nonnull__(2); 694 695 PARROT_CANNOT_RETURN_NULL 696 PARROT_WARN_UNUSED_RESULT 697 STRING * Parrot_io_reencode_string_for_handle(PARROT_INTERP, 698 ARGIN(PMC *handle), 699 ARGIN_NULLOK(STRING *str)) 700 __attribute__nonnull__(1) 701 __attribute__nonnull__(2); 702 703 void Parrot_io_set_buffer_mode(PARROT_INTERP, 704 ARGMOD(PMC *handle), 705 ARGIN(STRING *mode)) 706 __attribute__nonnull__(1) 707 __attribute__nonnull__(2) 708 __attribute__nonnull__(3) 709 FUNC_MODIFIES(*handle); 710 711 void Parrot_io_set_flags(PARROT_INTERP, ARGIN(PMC *handle), INTVAL flags) 712 __attribute__nonnull__(1) 713 __attribute__nonnull__(2); 714 715 INTVAL Parrot_io_write_byte_buffer_pmc(PARROT_INTERP, 716 ARGMOD(PMC * handle), 717 ARGMOD(PMC *buffer), 718 size_t byte_length) 719 __attribute__nonnull__(1) 720 __attribute__nonnull__(2) 721 __attribute__nonnull__(3) 722 FUNC_MODIFIES(* handle) 723 FUNC_MODIFIES(*buffer); 724 725 #define ASSERT_ARGS_Parrot_io_close __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 726 PARROT_ASSERT_ARG(interp) \ 727 , PARROT_ASSERT_ARG(handle)) 728 #define ASSERT_ARGS_Parrot_io_close_handle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 729 PARROT_ASSERT_ARG(interp) \ 730 , PARROT_ASSERT_ARG(pmc)) 731 #define ASSERT_ARGS_Parrot_io_eof __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 732 PARROT_ASSERT_ARG(interp) \ 733 , PARROT_ASSERT_ARG(handle)) 734 #define ASSERT_ARGS_Parrot_io_eprintf __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 735 PARROT_ASSERT_ARG(s)) 736 #define ASSERT_ARGS_Parrot_io_fdopen __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 737 PARROT_ASSERT_ARG(interp) \ 738 , PARROT_ASSERT_ARG(pmc) \ 739 , PARROT_ASSERT_ARG(sflags)) 740 #define ASSERT_ARGS_Parrot_io_fdopen_flags __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 741 PARROT_ASSERT_ARG(interp) \ 742 , PARROT_ASSERT_ARG(filehandle)) 743 #define ASSERT_ARGS_Parrot_io_finish __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 744 PARROT_ASSERT_ARG(interp)) 745 #define ASSERT_ARGS_Parrot_io_flush __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 746 PARROT_ASSERT_ARG(interp) \ 747 , PARROT_ASSERT_ARG(handle)) 748 #define ASSERT_ARGS_Parrot_io_flush_handle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 749 PARROT_ASSERT_ARG(interp) \ 750 , PARROT_ASSERT_ARG(pmc)) 751 #define ASSERT_ARGS_Parrot_io_fprintf __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 752 PARROT_ASSERT_ARG(interp) \ 753 , PARROT_ASSERT_ARG(pmc) \ 754 , PARROT_ASSERT_ARG(s)) 755 #define ASSERT_ARGS_Parrot_io_get_vtable __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 756 PARROT_ASSERT_ARG(interp)) 757 #define ASSERT_ARGS_Parrot_io_getfd __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 758 PARROT_ASSERT_ARG(interp) \ 759 , PARROT_ASSERT_ARG(pmc)) 760 #define ASSERT_ARGS_Parrot_io_getprotobyname __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 761 PARROT_ASSERT_ARG(interp) \ 762 , PARROT_ASSERT_ARG(name)) 763 #define ASSERT_ARGS_Parrot_io_init __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 764 PARROT_ASSERT_ARG(interp)) 765 #define ASSERT_ARGS_Parrot_io_is_async __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 766 PARROT_ASSERT_ARG(interp) \ 767 , PARROT_ASSERT_ARG(pmc)) 768 #define ASSERT_ARGS_Parrot_io_is_closed __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 769 PARROT_ASSERT_ARG(interp) \ 770 , PARROT_ASSERT_ARG(pmc)) 771 #define ASSERT_ARGS_Parrot_io_is_tty_handle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 772 PARROT_ASSERT_ARG(interp) \ 773 , PARROT_ASSERT_ARG(pmc)) 774 #define ASSERT_ARGS_Parrot_io_make_offset __attribute__unused__ int _ASSERT_ARGS_CHECK = (0) 775 #define ASSERT_ARGS_Parrot_io_make_offset32 __attribute__unused__ int _ASSERT_ARGS_CHECK = (0) 776 #define ASSERT_ARGS_Parrot_io_open __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 777 PARROT_ASSERT_ARG(interp) \ 778 , PARROT_ASSERT_ARG(pmc) \ 779 , PARROT_ASSERT_ARG(path) \ 780 , PARROT_ASSERT_ARG(mode)) 781 #define ASSERT_ARGS_Parrot_io_open_handle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 782 PARROT_ASSERT_ARG(interp) \ 783 , PARROT_ASSERT_ARG(pmc) \ 784 , PARROT_ASSERT_ARG(path) \ 785 , PARROT_ASSERT_ARG(mode)) 786 #define ASSERT_ARGS_Parrot_io_peek __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 787 PARROT_ASSERT_ARG(interp) \ 788 , PARROT_ASSERT_ARG(handle)) 789 #define ASSERT_ARGS_Parrot_io_poll __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 790 PARROT_ASSERT_ARG(interp) \ 791 , PARROT_ASSERT_ARG(pmc)) 792 #define ASSERT_ARGS_Parrot_io_pprintf __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 793 PARROT_ASSERT_ARG(interp) \ 794 , PARROT_ASSERT_ARG(s)) 795 #define ASSERT_ARGS_Parrot_io_printf __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 796 PARROT_ASSERT_ARG(interp) \ 797 , PARROT_ASSERT_ARG(s)) 798 #define ASSERT_ARGS_Parrot_io_putps __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 799 PARROT_ASSERT_ARG(interp) \ 800 , PARROT_ASSERT_ARG(pmc) \ 801 , PARROT_ASSERT_ARG(s)) 802 #define ASSERT_ARGS_Parrot_io_puts __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 803 PARROT_ASSERT_ARG(interp) \ 804 , PARROT_ASSERT_ARG(pmc) \ 805 , PARROT_ASSERT_ARG(s)) 806 #define ASSERT_ARGS_Parrot_io_read_byte_buffer_pmc \ 807 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 808 PARROT_ASSERT_ARG(interp) \ 809 , PARROT_ASSERT_ARG(handle)) 810 #define ASSERT_ARGS_Parrot_io_read_s __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 811 PARROT_ASSERT_ARG(interp) \ 812 , PARROT_ASSERT_ARG(handle)) 813 #define ASSERT_ARGS_Parrot_io_readall_s __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 814 PARROT_ASSERT_ARG(interp) \ 815 , PARROT_ASSERT_ARG(handle)) 816 #define ASSERT_ARGS_Parrot_io_readline __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 817 PARROT_ASSERT_ARG(interp) \ 818 , PARROT_ASSERT_ARG(handle)) 819 #define ASSERT_ARGS_Parrot_io_readline_s __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 820 PARROT_ASSERT_ARG(interp) \ 821 , PARROT_ASSERT_ARG(handle) \ 822 , PARROT_ASSERT_ARG(terminator)) 823 #define ASSERT_ARGS_Parrot_io_reads __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 824 PARROT_ASSERT_ARG(interp) \ 825 , PARROT_ASSERT_ARG(pmc)) 826 #define ASSERT_ARGS_Parrot_io_recv_handle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 827 PARROT_ASSERT_ARG(interp) \ 828 , PARROT_ASSERT_ARG(pmc)) 829 #define ASSERT_ARGS_Parrot_io_seek __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 830 PARROT_ASSERT_ARG(interp) \ 831 , PARROT_ASSERT_ARG(handle)) 832 #define ASSERT_ARGS_Parrot_io_seek_handle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 833 PARROT_ASSERT_ARG(interp) \ 834 , PARROT_ASSERT_ARG(handle)) 835 #define ASSERT_ARGS_Parrot_io_socket __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 836 PARROT_ASSERT_ARG(interp)) 837 #define ASSERT_ARGS_Parrot_io_socket_accept __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 838 PARROT_ASSERT_ARG(interp) \ 839 , PARROT_ASSERT_ARG(pmc)) 840 #define ASSERT_ARGS_Parrot_io_socket_bind __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 841 PARROT_ASSERT_ARG(interp) \ 842 , PARROT_ASSERT_ARG(pmc) \ 843 , PARROT_ASSERT_ARG(address)) 844 #define ASSERT_ARGS_Parrot_io_socket_connect __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 845 PARROT_ASSERT_ARG(interp) \ 846 , PARROT_ASSERT_ARG(pmc) \ 847 , PARROT_ASSERT_ARG(address)) 848 #define ASSERT_ARGS_Parrot_io_socket_handle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 849 PARROT_ASSERT_ARG(interp)) 850 #define ASSERT_ARGS_Parrot_io_socket_initialize __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 851 PARROT_ASSERT_ARG(socket)) 852 #define ASSERT_ARGS_Parrot_io_socket_listen __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 853 PARROT_ASSERT_ARG(interp) \ 854 , PARROT_ASSERT_ARG(pmc)) 855 #define ASSERT_ARGS_Parrot_io_socket_new __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 856 PARROT_ASSERT_ARG(interp)) 857 #define ASSERT_ARGS_Parrot_io_STDERR __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 858 PARROT_ASSERT_ARG(interp)) 859 #define ASSERT_ARGS_Parrot_io_stdhandle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 860 PARROT_ASSERT_ARG(interp)) 861 #define ASSERT_ARGS_Parrot_io_STDIN __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 862 PARROT_ASSERT_ARG(interp)) 863 #define ASSERT_ARGS_Parrot_io_STDOUT __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 864 PARROT_ASSERT_ARG(interp)) 865 #define ASSERT_ARGS_Parrot_io_tell __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 866 PARROT_ASSERT_ARG(interp) \ 867 , PARROT_ASSERT_ARG(handle)) 868 #define ASSERT_ARGS_Parrot_io_tell_handle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 869 PARROT_ASSERT_ARG(interp) \ 870 , PARROT_ASSERT_ARG(handle)) 871 #define ASSERT_ARGS_Parrot_io_write_b __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 872 PARROT_ASSERT_ARG(interp) \ 873 , PARROT_ASSERT_ARG(handle) \ 874 , PARROT_ASSERT_ARG(buffer)) 875 #define ASSERT_ARGS_Parrot_io_write_s __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 876 PARROT_ASSERT_ARG(interp) \ 877 , PARROT_ASSERT_ARG(handle) \ 878 , PARROT_ASSERT_ARG(s)) 879 #define ASSERT_ARGS_io_setup_vtables __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 880 PARROT_ASSERT_ARG(interp)) 881 #define ASSERT_ARGS_Parrot_io_allocate_new_vtable __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 882 PARROT_ASSERT_ARG(interp) \ 883 , PARROT_ASSERT_ARG(name)) 884 #define ASSERT_ARGS_Parrot_io_buffer_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 885 PARROT_ASSERT_ARG(interp) \ 886 , PARROT_ASSERT_ARG(handle)) 887 #define ASSERT_ARGS_Parrot_io_get_buffer_mode __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 888 PARROT_ASSERT_ARG(interp) \ 889 , PARROT_ASSERT_ARG(handle)) 890 #define ASSERT_ARGS_Parrot_io_get_flags __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 891 PARROT_ASSERT_ARG(interp) \ 892 , PARROT_ASSERT_ARG(handle)) 893 #define ASSERT_ARGS_Parrot_io_get_os_handle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 894 PARROT_ASSERT_ARG(interp) \ 895 , PARROT_ASSERT_ARG(handle)) 896 #define ASSERT_ARGS_Parrot_io_get_standard_piohandle \ 897 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 898 PARROT_ASSERT_ARG(interp)) 899 #define ASSERT_ARGS_Parrot_io_make_offset_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 900 PARROT_ASSERT_ARG(interp) \ 901 , PARROT_ASSERT_ARG(pmc)) 902 #define ASSERT_ARGS_Parrot_io_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 903 PARROT_ASSERT_ARG(interp) \ 904 , PARROT_ASSERT_ARG(piodata)) 905 #define ASSERT_ARGS_Parrot_io_reencode_string_for_handle \ 906 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 907 PARROT_ASSERT_ARG(interp) \ 908 , PARROT_ASSERT_ARG(handle)) 909 #define ASSERT_ARGS_Parrot_io_set_buffer_mode __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 910 PARROT_ASSERT_ARG(interp) \ 911 , PARROT_ASSERT_ARG(handle) \ 912 , PARROT_ASSERT_ARG(mode)) 913 #define ASSERT_ARGS_Parrot_io_set_flags __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 914 PARROT_ASSERT_ARG(interp) \ 915 , PARROT_ASSERT_ARG(handle)) 916 #define ASSERT_ARGS_Parrot_io_write_byte_buffer_pmc \ 917 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 918 PARROT_ASSERT_ARG(interp) \ 919 , PARROT_ASSERT_ARG(handle) \ 920 , PARROT_ASSERT_ARG(buffer)) 921 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 922 /* HEADERIZER END: src/io/api.c */ 923 924 /* io/buffer.c - Buffering functions */ 925 /* HEADERIZER BEGIN: src/io/buffer.c */ 926 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 927 928 PARROT_WARN_UNUSED_RESULT 929 size_t io_buffer_find_num_characters(PARROT_INTERP, 930 ARGMOD(IO_BUFFER *buffer), 931 ARGMOD(PMC *handle), 932 ARGIN(const IO_VTABLE *vtable), 933 ARGIN(const STR_VTABLE *encoding), 934 ARGMOD(Parrot_String_Bounds *bounds), 935 size_t num_chars) 936 __attribute__nonnull__(1) 937 __attribute__nonnull__(2) 938 __attribute__nonnull__(3) 939 __attribute__nonnull__(4) 940 __attribute__nonnull__(5) 941 __attribute__nonnull__(6) 942 FUNC_MODIFIES(*buffer) 943 FUNC_MODIFIES(*handle) 944 FUNC_MODIFIES(*bounds); 945 946 PARROT_WARN_UNUSED_RESULT 947 size_t io_buffer_find_string_marker(PARROT_INTERP, 948 ARGMOD(IO_BUFFER *buffer), 949 ARGMOD(PMC *handle), 950 ARGIN(const IO_VTABLE *vtable), 951 ARGIN(const STR_VTABLE *encoding), 952 ARGMOD(Parrot_String_Bounds *bounds), 953 ARGIN(STRING * delim), 954 ARGOUT(INTVAL *have_delim)) 955 __attribute__nonnull__(1) 956 __attribute__nonnull__(2) 957 __attribute__nonnull__(3) 958 __attribute__nonnull__(4) 959 __attribute__nonnull__(5) 960 __attribute__nonnull__(6) 961 __attribute__nonnull__(7) 962 __attribute__nonnull__(8) 963 FUNC_MODIFIES(*buffer) 964 FUNC_MODIFIES(*handle) 965 FUNC_MODIFIES(*bounds) 966 FUNC_MODIFIES(*have_delim); 967 968 void Parrot_io_buffer_add_to_handle(PARROT_INTERP, 969 ARGMOD(PMC *handle), 970 const INTVAL idx, 971 const size_t length, 972 const INTVAL flags) 973 __attribute__nonnull__(1) 974 __attribute__nonnull__(2) 975 FUNC_MODIFIES(*handle); 976 977 void Parrot_io_buffer_advance_position(PARROT_INTERP, 978 ARGMOD_NULLOK(IO_BUFFER *buffer), 979 size_t len) 980 __attribute__nonnull__(1) 981 FUNC_MODIFIES(*buffer); 982 983 PARROT_CANNOT_RETURN_NULL 984 PARROT_WARN_UNUSED_RESULT 985 IO_BUFFER * Parrot_io_buffer_allocate(PARROT_INTERP, 986 ARGMOD(PMC *owner), 987 INTVAL flags, 988 ARGIN_NULLOK(const STR_VTABLE *encoding), 989 size_t init_size) 990 __attribute__nonnull__(1) 991 __attribute__nonnull__(2) 992 FUNC_MODIFIES(*owner); 993 994 void Parrot_io_buffer_clear(PARROT_INTERP, ARGMOD_NULLOK(IO_BUFFER *buffer)) 995 FUNC_MODIFIES(*buffer); 996 997 PARROT_WARN_UNUSED_RESULT 998 size_t Parrot_io_buffer_content_size(PARROT_INTERP, 999 ARGIN(IO_BUFFER *buffer)) 1000 __attribute__nonnull__(2); 1001 1002 size_t Parrot_io_buffer_fill(PARROT_INTERP, 1003 ARGMOD_NULLOK(IO_BUFFER *buffer), 1004 ARGMOD(PMC * handle), 1005 ARGIN(const IO_VTABLE *vtable)) 1006 __attribute__nonnull__(1) 1007 __attribute__nonnull__(3) 1008 __attribute__nonnull__(4) 1009 FUNC_MODIFIES(*buffer) 1010 FUNC_MODIFIES(* handle); 1011 1012 size_t Parrot_io_buffer_flush(PARROT_INTERP, 1013 ARGMOD_NULLOK(IO_BUFFER *buffer), 1014 ARGMOD(PMC * handle), 1015 ARGIN(const IO_VTABLE *vtable)) 1016 __attribute__nonnull__(1) 1017 __attribute__nonnull__(3) 1018 __attribute__nonnull__(4) 1019 FUNC_MODIFIES(*buffer) 1020 FUNC_MODIFIES(* handle); 1021 1022 void Parrot_io_buffer_free(PARROT_INTERP, ARGFREE(IO_BUFFER *buffer)) 1023 __attribute__nonnull__(1); 1024 1025 void Parrot_io_buffer_mark(PARROT_INTERP, ARGMOD_NULLOK(IO_BUFFER *buffer)) 1026 FUNC_MODIFIES(*buffer); 1027 1028 UINTVAL Parrot_io_buffer_peek(PARROT_INTERP, 1029 ARGMOD(IO_BUFFER *buffer), 1030 ARGMOD(PMC * handle), 1031 ARGIN(const IO_VTABLE *vtable)) 1032 __attribute__nonnull__(1) 1033 __attribute__nonnull__(2) 1034 __attribute__nonnull__(3) 1035 __attribute__nonnull__(4) 1036 FUNC_MODIFIES(*buffer) 1037 FUNC_MODIFIES(* handle); 1038 1039 size_t Parrot_io_buffer_read_b(PARROT_INTERP, 1040 ARGMOD_NULLOK(IO_BUFFER *buffer), 1041 ARGIN(PMC *handle), 1042 ARGIN(const IO_VTABLE *vtable), 1043 ARGOUT(char *s), 1044 size_t length) 1045 __attribute__nonnull__(1) 1046 __attribute__nonnull__(3) 1047 __attribute__nonnull__(4) 1048 __attribute__nonnull__(5) 1049 FUNC_MODIFIES(*buffer) 1050 FUNC_MODIFIES(*s); 1051 1052 void Parrot_io_buffer_remove_from_handle(PARROT_INTERP, 1053 ARGMOD(PMC *handle), 1054 const INTVAL idx) 1055 __attribute__nonnull__(1) 1056 __attribute__nonnull__(2) 1057 FUNC_MODIFIES(*handle); 1058 1059 size_t Parrot_io_buffer_resize(PARROT_INTERP, 1060 ARGMOD(IO_BUFFER *buffer), 1061 size_t new_size) 1062 __attribute__nonnull__(2) 1063 FUNC_MODIFIES(*buffer); 1064 1065 PIOOFF_T Parrot_io_buffer_seek(PARROT_INTERP, 1066 ARGMOD(IO_BUFFER *buffer), 1067 ARGMOD(PMC *handle), 1068 ARGIN(const IO_VTABLE *vtable), 1069 PIOOFF_T offset, 1070 INTVAL w) 1071 __attribute__nonnull__(1) 1072 __attribute__nonnull__(2) 1073 __attribute__nonnull__(3) 1074 __attribute__nonnull__(4) 1075 FUNC_MODIFIES(*buffer) 1076 FUNC_MODIFIES(*handle); 1077 1078 PARROT_WARN_UNUSED_RESULT 1079 PIOOFF_T Parrot_io_buffer_tell(PARROT_INTERP, 1080 ARGIN_NULLOK(IO_BUFFER *buffer), 1081 ARGMOD(PMC *handle), 1082 ARGIN(const IO_VTABLE * vtable)) 1083 __attribute__nonnull__(1) 1084 __attribute__nonnull__(3) 1085 __attribute__nonnull__(4) 1086 FUNC_MODIFIES(*handle); 1087 1088 size_t Parrot_io_buffer_write_b(PARROT_INTERP, 1089 ARGMOD_NULLOK(IO_BUFFER *buffer), 1090 ARGMOD(PMC * handle), 1091 ARGIN(const IO_VTABLE *vtable), 1092 ARGIN(const char *s), 1093 const size_t length) 1094 __attribute__nonnull__(1) 1095 __attribute__nonnull__(3) 1096 __attribute__nonnull__(4) 1097 __attribute__nonnull__(5) 1098 FUNC_MODIFIES(*buffer) 1099 FUNC_MODIFIES(* handle); 1100 1101 #define ASSERT_ARGS_io_buffer_find_num_characters __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1102 PARROT_ASSERT_ARG(interp) \ 1103 , PARROT_ASSERT_ARG(buffer) \ 1104 , PARROT_ASSERT_ARG(handle) \ 1105 , PARROT_ASSERT_ARG(vtable) \ 1106 , PARROT_ASSERT_ARG(encoding) \ 1107 , PARROT_ASSERT_ARG(bounds)) 1108 #define ASSERT_ARGS_io_buffer_find_string_marker __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1109 PARROT_ASSERT_ARG(interp) \ 1110 , PARROT_ASSERT_ARG(buffer) \ 1111 , PARROT_ASSERT_ARG(handle) \ 1112 , PARROT_ASSERT_ARG(vtable) \ 1113 , PARROT_ASSERT_ARG(encoding) \ 1114 , PARROT_ASSERT_ARG(bounds) \ 1115 , PARROT_ASSERT_ARG(delim) \ 1116 , PARROT_ASSERT_ARG(have_delim)) 1117 #define ASSERT_ARGS_Parrot_io_buffer_add_to_handle \ 1118 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1119 PARROT_ASSERT_ARG(interp) \ 1120 , PARROT_ASSERT_ARG(handle)) 1121 #define ASSERT_ARGS_Parrot_io_buffer_advance_position \ 1122 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1123 PARROT_ASSERT_ARG(interp)) 1124 #define ASSERT_ARGS_Parrot_io_buffer_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1125 PARROT_ASSERT_ARG(interp) \ 1126 , PARROT_ASSERT_ARG(owner)) 1127 #define ASSERT_ARGS_Parrot_io_buffer_clear __attribute__unused__ int _ASSERT_ARGS_CHECK = (0) 1128 #define ASSERT_ARGS_Parrot_io_buffer_content_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1129 PARROT_ASSERT_ARG(buffer)) 1130 #define ASSERT_ARGS_Parrot_io_buffer_fill __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1131 PARROT_ASSERT_ARG(interp) \ 1132 , PARROT_ASSERT_ARG(handle) \ 1133 , PARROT_ASSERT_ARG(vtable)) 1134 #define ASSERT_ARGS_Parrot_io_buffer_flush __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1135 PARROT_ASSERT_ARG(interp) \ 1136 , PARROT_ASSERT_ARG(handle) \ 1137 , PARROT_ASSERT_ARG(vtable)) 1138 #define ASSERT_ARGS_Parrot_io_buffer_free __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1139 PARROT_ASSERT_ARG(interp)) 1140 #define ASSERT_ARGS_Parrot_io_buffer_mark __attribute__unused__ int _ASSERT_ARGS_CHECK = (0) 1141 #define ASSERT_ARGS_Parrot_io_buffer_peek __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1142 PARROT_ASSERT_ARG(interp) \ 1143 , PARROT_ASSERT_ARG(buffer) \ 1144 , PARROT_ASSERT_ARG(handle) \ 1145 , PARROT_ASSERT_ARG(vtable)) 1146 #define ASSERT_ARGS_Parrot_io_buffer_read_b __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1147 PARROT_ASSERT_ARG(interp) \ 1148 , PARROT_ASSERT_ARG(handle) \ 1149 , PARROT_ASSERT_ARG(vtable) \ 1150 , PARROT_ASSERT_ARG(s)) 1151 #define ASSERT_ARGS_Parrot_io_buffer_remove_from_handle \ 1152 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1153 PARROT_ASSERT_ARG(interp) \ 1154 , PARROT_ASSERT_ARG(handle)) 1155 #define ASSERT_ARGS_Parrot_io_buffer_resize __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1156 PARROT_ASSERT_ARG(buffer)) 1157 #define ASSERT_ARGS_Parrot_io_buffer_seek __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1158 PARROT_ASSERT_ARG(interp) \ 1159 , PARROT_ASSERT_ARG(buffer) \ 1160 , PARROT_ASSERT_ARG(handle) \ 1161 , PARROT_ASSERT_ARG(vtable)) 1162 #define ASSERT_ARGS_Parrot_io_buffer_tell __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1163 PARROT_ASSERT_ARG(interp) \ 1164 , PARROT_ASSERT_ARG(handle) \ 1165 , PARROT_ASSERT_ARG(vtable)) 1166 #define ASSERT_ARGS_Parrot_io_buffer_write_b __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 1167 PARROT_ASSERT_ARG(interp) \ 1168 , PARROT_ASSERT_ARG(handle) \ 1169 , PARROT_ASSERT_ARG(vtable) \ 1170 , PARROT_ASSERT_ARG(s)) 1171 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 1172 /* HEADERIZER END: src/io/buffer.c */ 1173 1174 #endif /* PARROT_IO_H_GUARD */ 1175 1176 /* 1177 * Local variables: 1178 * c-file-style: "parrot" 1179 * End: 1180 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' : 1181 */ 1182