Back to index

glibc  2.9
Defines | Functions | Variables
tst-cookie.c File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>

Go to the source code of this file.

Defines

#define THE_COOKIE   ((void *) 0xdeadbeeful)

Functions

static ssize_t cookieread (void *cookie, char *buf, size_t count)
static ssize_t cookiewrite (void *cookie, const char *buf, size_t count)
static int cookieseek (void *cookie, off64_t *offset, int whence)
static int cookieclose (void *cookie)
int main (void)

Variables

static int errors
static int cookieread_called
static int cookiewrite_called
static int cookieseek_called
static int cookieclose_called

Define Documentation

#define THE_COOKIE   ((void *) 0xdeadbeeful)

Definition at line 9 of file tst-cookie.c.


Function Documentation

static int cookieclose ( void *  cookie) [static]

Definition at line 55 of file tst-cookie.c.

{
  printf ("`%s' called with cookie %#lx\n", __FUNCTION__,
         (unsigned long int) cookie);
  if (cookie != THE_COOKIE)
    ++errors;
  cookieclose_called = 1;
  return 45;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static ssize_t cookieread ( void *  cookie,
char *  buf,
size_t  count 
) [static]

Definition at line 16 of file tst-cookie.c.

{
  printf ("`%s' called with cookie %#lx\n", __FUNCTION__,
         (unsigned long int) cookie);
  if (cookie != THE_COOKIE)
    ++errors;
  cookieread_called = 1;
  return 42;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int cookieseek ( void *  cookie,
off64_t *  offset,
int  whence 
) [static]

Definition at line 42 of file tst-cookie.c.

{
  printf ("`%s' called with cookie %#lx\n", __FUNCTION__,
         (unsigned long int) cookie);
  if (cookie != THE_COOKIE)
    ++errors;
  cookieseek_called = 1;
  return 44;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static ssize_t cookiewrite ( void *  cookie,
const char *  buf,
size_t  count 
) [static]

Definition at line 29 of file tst-cookie.c.

{
  printf ("`%s' called with cookie %#lx\n", __FUNCTION__,
         (unsigned long int) cookie);
  if (cookie != THE_COOKIE)
    ++errors;
  cookiewrite_called = 1;
  return 43;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( void  )

Definition at line 67 of file tst-cookie.c.

{
  cookie_io_functions_t fcts;
  char buf[1];
  FILE *f;

  fcts.read = cookieread;
  fcts.seek = cookieseek;
  fcts.close = cookieclose;
  fcts.write = cookiewrite;

  f = fopencookie (THE_COOKIE, "r+", fcts);

  fread (buf, 1, 1, f);
  fwrite (buf, 1, 1, f);
  fseek (f, 0, SEEK_CUR);
  fclose (f);

  if (cookieread_called == 0
      || cookiewrite_called == 0
      || cookieseek_called == 0
      || cookieclose_called == 0)
    ++errors;

  return errors != 0;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 53 of file tst-cookie.c.

Definition at line 14 of file tst-cookie.c.

Definition at line 40 of file tst-cookie.c.

Definition at line 27 of file tst-cookie.c.

int errors [static]

Definition at line 11 of file tst-cookie.c.