File: async.h

package info (click to toggle)
foot 1.26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,692 kB
  • sloc: ansic: 41,627; python: 499; sh: 181; makefile: 18
file content (24 lines) | stat: -rw-r--r-- 771 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once

#include <stddef.h>

enum async_write_status {ASYNC_WRITE_DONE, ASYNC_WRITE_REMAIN, ASYNC_WRITE_ERR};

/*
 * Primitive that writes data to a NONBLOCK:ing FD.
 *
 * _data: points to the beginning of the buffer
 * len: total size of the data buffer
 * idx: pointer to byte offset into data buffer - writing starts here.
 *
 * Thus, the total amount of data to write is (len - *idx). *idx is
 * updated such that it points to the next unwritten byte in the data
 * buffer.
 *
 * I.e. if the return value is:
 *  - ASYNC_WRITE_DONE, then the *idx == len.
 *  - ASYNC_WRITE_REMAIN, then *idx < len
 *  - ASYNC_WRITE_ERR, there was an error, and no data was written
 */
enum async_write_status async_write(
    int fd, const void *data, size_t len, size_t *idx);