Back to index

glibc  2.9
Defines | Functions | Variables
tst-mqueue.h File Reference
#include <mqueue.h>
#include <search.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/uio.h>
#include <unistd.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define PREPARE(argc, argv)   do_prepare ()
#define CLEANUP_HANDLER   do_cleanup ()

Functions

static void __attribute__ ((unused)) add_temp_mq(const char *name)
static void do_cleanup (void)
static void do_prepare (void)

Variables

static int temp_mq_fd

Define Documentation

#define CLEANUP_HANDLER   do_cleanup ()

Definition at line 84 of file tst-mqueue.h.

#define PREPARE (   argc,
  argv 
)    do_prepare ()

Definition at line 83 of file tst-mqueue.h.


Function Documentation

static void __attribute__ ( (unused)  ) const [static]

Definition at line 33 of file tst-mqueue.h.

{
  struct iovec iov[2];
  iov[0].iov_base = (char *) name;
  iov[0].iov_len = strlen (name);
  iov[1].iov_base = (char *) "\n";
  iov[1].iov_len = 1;
  if (writev (temp_mq_fd, iov, 2) != iov[0].iov_len + 1)
    printf ("Could not record temp mq filename %s\n", name);
}

Here is the call graph for this function:

static void do_cleanup ( void  ) [static]

Definition at line 47 of file tst-mqueue.h.

{
  if (lseek (temp_mq_fd, 0, SEEK_SET) != 0)
    return;

  FILE *f = fdopen (temp_mq_fd, "r");
  if (f == NULL)
    return;

  char *line = NULL;
  size_t n = 0;
  ssize_t rets;
  while ((rets = getline (&line, &n, f)) > 0)
    {
      if (line[rets - 1] != '\n')
        continue;

      line[rets - 1] = '\0';
      mq_unlink (line);
    }
  fclose (f);
}

Here is the call graph for this function:

static void do_prepare ( void  ) [static]

Definition at line 71 of file tst-mqueue.h.

{
  char name [] = "/tmp/tst-mqueueN.XXXXXX";
  temp_mq_fd = mkstemp (name);
  if (temp_mq_fd == -1)
    {
      printf ("Could not create temporary file %s: %m\n", name);
      exit (1);
    }
  unlink (name);
}

Here is the call graph for this function:


Variable Documentation

int temp_mq_fd [static]

Definition at line 29 of file tst-mqueue.h.