source: project/release/3/z3/z3fdtest.c @ 18200

Last change on this file since 18200 was 108, checked in by felix winkelmann, 14 years ago

z3, removed chicken-config uses

File size: 788 bytes
Line 
1
2#include <unistd.h>
3#include <stdio.h>
4#include <string.h>
5
6// #define D(x) x
7
8#ifndef D
9#define D(x)
10#endif
11
12#include "z3blib.c"
13#include "z3dlib.c"
14#include "z3flib.c"
15
16int main(void)
17{
18  struct z3fd_handle zh;
19  __u8 code[4096];
20  int r, i, w;
21  r = z3f_decode_init(STDIN_FILENO, &zh);
22  if (r < 0) {
23    fprintf(stderr, "z3f_decode_init failed: %s\n", strerror(-r));
24    return 1;
25  }
26  do {
27    r = z3f_decode_read(&zh, &code[0], sizeof(code));
28    if ((r < 0) && (r != -EAGAIN)) {
29      fprintf(stderr, "z3f_decode_read failed: %s\n", strerror(-r));
30      return 1;
31    }
32    i = 0;
33    while (i < r) {
34      w = write(STDOUT_FILENO, &code[i], r-i);
35      if (w < 0) {
36        perror("write failed");
37        return 1;
38      }
39      i += w;
40    }
41  } while (r != 0);
42  return 0;
43}
Note: See TracBrowser for help on using the repository browser.