9 #define THE_COOKIE ((void *) 0xdeadbeeful)
14 static int cookieread_called
;
16 cookieread (void *cookie
, char *buf
, size_t count
)
18 printf ("`%s' called with cookie %#lx\n", __FUNCTION__
,
19 (unsigned long int) cookie
);
20 if (cookie
!= THE_COOKIE
)
22 cookieread_called
= 1;
27 static int cookiewrite_called
;
29 cookiewrite (void *cookie
, const char *buf
, size_t count
)
31 printf ("`%s' called with cookie %#lx\n", __FUNCTION__
,
32 (unsigned long int) cookie
);
33 if (cookie
!= THE_COOKIE
)
35 cookiewrite_called
= 1;
40 static int cookieseek_called
;
42 cookieseek (void *cookie
, off64_t
*offset
, int whence
)
44 printf ("`%s' called with cookie %#lx\n", __FUNCTION__
,
45 (unsigned long int) cookie
);
46 if (cookie
!= THE_COOKIE
)
48 cookieseek_called
= 1;
53 static int cookieclose_called
;
55 cookieclose (void *cookie
)
57 printf ("`%s' called with cookie %#lx\n", __FUNCTION__
,
58 (unsigned long int) cookie
);
59 if (cookie
!= THE_COOKIE
)
61 cookieclose_called
= 1;
69 cookie_io_functions_t fcts
;
73 fcts
.read
= cookieread
;
74 fcts
.seek
= cookieseek
;
75 fcts
.close
= cookieclose
;
76 fcts
.write
= cookiewrite
;
78 f
= fopencookie (THE_COOKIE
, "r+", fcts
);
81 fwrite (buf
, 1, 1, f
);
82 fseek (f
, 0, SEEK_CUR
);
85 if (cookieread_called
== 0
86 || cookiewrite_called
== 0
87 || cookieseek_called
== 0
88 || cookieclose_called
== 0)
94 #define TEST_FUNCTION do_test ()
95 #include "../test-skeleton.c"