File: iob.c

package info (click to toggle)
libowfat 0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,288 kB
  • sloc: ansic: 20,181; makefile: 16
file content (30 lines) | stat: -rw-r--r-- 600 bytes parent folder | download
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
#include <assert.h>
#include "libowfat/iob.h"
#include <unistd.h>
#include <string.h>

static int64 write_cb(int64 fd,const void* buf,uint64 len) {
  if (len>2) len=2;
  return write(fd,buf,len);
}

int main() {
  int64 fd;
  io_batch* b;
  char* fnord=strdup(" fnord\n");
  assert(fnord);
  assert(io_readfile(&fd,"GNUmakefile"));
  assert((b=iob_new_autofree(10)));
  assert(iob_addbuf(b,"Huhu",4));
  assert(iob_addbuf_free(b,fnord,7));
  assert(iob_addfile(b,fd,10,10));
  iob_send(1,b);
#if 0
  int64 r;
  do {
    r=iob_write(1,b,write_cb);
  } while (r>0);
#endif
  iob_free(b);
  return 0;
}