Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Functions | Variables
libiberty.h File Reference
#include "ansidecl.h"
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  pex_time

Defines

#define basename   basename_cannot_be_used_without_a_prototype
#define ACONCAT(ACONCAT_PARAMS)
#define XNEW(T)   ((T *) xmalloc (sizeof (T)))
#define XCNEW(T)   ((T *) xcalloc (1, sizeof (T)))
#define XDELETE(P)   free ((void*) (P))
#define XNEWVEC(T, N)   ((T *) xmalloc (sizeof (T) * (N)))
#define XCNEWVEC(T, N)   ((T *) xcalloc ((N), sizeof (T)))
#define XRESIZEVEC(T, P, N)   ((T *) xrealloc ((void *) (P), sizeof (T) * (N)))
#define XDELETEVEC(P)   free ((void*) (P))
#define XNEWVAR(T, S)   ((T *) xmalloc ((S)))
#define XCNEWVAR(T, S)   ((T *) xcalloc (1, (S)))
#define XRESIZEVAR(T, P, S)   ((T *) xrealloc ((P), (S)))
#define XOBNEW(O, T)   ((T *) obstack_alloc ((O), sizeof (T)))
#define XOBFINISH(O, T)   ((T) obstack_finish ((O)))
#define _hex_array_size   256
#define _hex_bad   99
#define hex_p(c)   (hex_value (c) != _hex_bad)
#define hex_value(c)   ((unsigned int) _hex_value[(unsigned char) (c)])
#define PEX_RECORD_TIMES   0x1
#define PEX_USE_PIPES   0x2
#define PEX_SAVE_TEMPS   0x4
#define PEX_LAST   0x1
#define PEX_SEARCH   0x2
#define PEX_SUFFIX   0x4
#define PEX_STDERR_TO_STDOUT   0x8
#define PEX_BINARY_INPUT   0x10
#define PEX_BINARY_OUTPUT   0x20
#define PEX_STDERR_TO_PIPE   0x40
#define PEX_BINARY_ERROR   0x80
#define PEXECUTE_FIRST   1
#define PEXECUTE_LAST   2
#define PEXECUTE_ONE   (PEXECUTE_FIRST + PEXECUTE_LAST)
#define PEXECUTE_SEARCH   4
#define PEXECUTE_VERBOSE   8
#define ARRAY_SIZE(a)   (sizeof (a) / sizeof ((a)[0]))
#define alloca(x)   C_alloca(x)
#define USE_C_ALLOCA   1
#define C_ALLOCA   1
#define ASTRDUP(X)

Functions

void unlock_stream (FILE *)
void unlock_std_streams (void)
FILE * fopen_unlocked (const char *, const char *)
FILE * fdopen_unlocked (int, const char *)
FILE * freopen_unlocked (const char *, const char *, FILE *)
char ** buildargv (const char *) ATTRIBUTE_MALLOC
void freeargv (char **)
char ** dupargv (char **) ATTRIBUTE_MALLOC
void expandargv PARAMS ((int *, char ***))
const char * lbasename (const char *)
char * lrealpath (const char *)
char * concat (const char *,...) ATTRIBUTE_MALLOC ATTRIBUTE_SENTINEL
char * reconcat (char *, const char *,...) ATTRIBUTE_MALLOC ATTRIBUTE_SENTINEL
unsigned long concat_length (const char *,...) ATTRIBUTE_SENTINEL
char * concat_copy (char *, const char *,...) ATTRIBUTE_SENTINEL
char * concat_copy2 (const char *,...) ATTRIBUTE_SENTINEL
int fdmatch (int fd1, int fd2)
char * getpwd (void)
long get_run_time (void)
char * make_relative_prefix (const char *, const char *, const char *) ATTRIBUTE_MALLOC
char * make_relative_prefix_ignore_links (const char *, const char *, const char *) ATTRIBUTE_MALLOC
char * choose_temp_base (void) ATTRIBUTE_MALLOC
char * make_temp_file (const char *) ATTRIBUTE_MALLOC
int unlink_if_ordinary (const char *)
const char * spaces (int count)
int errno_max (void)
const char * strerrno (int)
int strtoerrno (const char *)
char * xstrerror (int)
int signo_max (void)
const char * strsigno (int)
int strtosigno (const char *)
int xatexit (void(*fn)(void))
void xexit (int status) ATTRIBUTE_NORETURN
void xmalloc_set_program_name (const char *)
void xmalloc_failed (size_t) ATTRIBUTE_NORETURN
void * xmalloc (size_t) ATTRIBUTE_MALLOC
void * xrealloc (void *, size_t)
void * xcalloc (size_t, size_t) ATTRIBUTE_MALLOC
char * xstrdup (const char *) ATTRIBUTE_MALLOC
char * xstrndup (const char *, size_t) ATTRIBUTE_MALLOC
void * xmemdup (const void *, size_t, size_t) ATTRIBUTE_MALLOC
double physmem_total (void)
double physmem_available (void)
void hex_init (void)
struct pex_objpex_init (int flags, const char *pname, const char *tempbase)
const char * pex_run (struct pex_obj *obj, int flags, const char *executable, char *const *argv, const char *outname, const char *errname, int *err)
const char * pex_run_in_environment (struct pex_obj *obj, int flags, const char *executable, char *const *argv, char *const *env, const char *outname, const char *errname, int *err)
FILE * pex_input_file (struct pex_obj *obj, int flags, const char *in_name)
FILE * pex_input_pipe (struct pex_obj *obj, int binary)
FILE * pex_read_output (struct pex_obj *, int binary)
FILE * pex_read_err (struct pex_obj *, int binary)
int pex_get_status (struct pex_obj *, int count, int *vector)
int pex_get_times (struct pex_obj *, int count, struct pex_time *vector)
void pex_free (struct pex_obj *)
const char * pex_one (int flags, const char *executable, char *const *argv, const char *pname, const char *outname, const char *errname, int *status, int *err)
int pexecute (const char *, char *const *, const char *, const char *, char **, char **, int)
int pwait (int, int *, int)
int asprintf (char **, const char *,...) ATTRIBUTE_PRINTF_2
int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2
void * C_alloca (size_t) ATTRIBUTE_MALLOC

Variables

char * libiberty_concat_ptr
const unsigned char _hex_value [_hex_array_size]
const char * libiberty_optr
char * libiberty_nptr
unsigned long libiberty_len

Class Documentation

struct pex_time

Definition at line 529 of file libiberty.h.

Class Members
unsigned long system_microseconds
unsigned long system_seconds
unsigned long user_microseconds
unsigned long user_seconds

Define Documentation

#define _hex_array_size   256

Definition at line 343 of file libiberty.h.

#define _hex_bad   99

Definition at line 344 of file libiberty.h.

#define ACONCAT (   ACONCAT_PARAMS)
Value:
(libiberty_concat_ptr = (char *) alloca (concat_length ACONCAT_PARAMS + 1), \
   concat_copy2 ACONCAT_PARAMS)

Definition at line 161 of file libiberty.h.

#define alloca (   x)    C_alloca(x)

Definition at line 629 of file libiberty.h.

#define ARRAY_SIZE (   a)    (sizeof (a) / sizeof ((a)[0]))

Definition at line 610 of file libiberty.h.

#define ASTRDUP (   X)
Value:

Definition at line 637 of file libiberty.h.

#define basename   basename_cannot_be_used_without_a_prototype

Definition at line 106 of file libiberty.h.

#define C_ALLOCA   1

Definition at line 633 of file libiberty.h.

#define hex_p (   c)    (hex_value (c) != _hex_bad)

Definition at line 347 of file libiberty.h.

#define hex_value (   c)    ((unsigned int) _hex_value[(unsigned char) (c)])

Definition at line 350 of file libiberty.h.

#define PEX_BINARY_ERROR   0x80

Definition at line 413 of file libiberty.h.

#define PEX_BINARY_INPUT   0x10

Definition at line 394 of file libiberty.h.

#define PEX_BINARY_OUTPUT   0x20

Definition at line 401 of file libiberty.h.

#define PEX_LAST   0x1

Definition at line 381 of file libiberty.h.

#define PEX_RECORD_TIMES   0x1

Definition at line 355 of file libiberty.h.

#define PEX_SAVE_TEMPS   0x4

Definition at line 361 of file libiberty.h.

#define PEX_SEARCH   0x2

Definition at line 384 of file libiberty.h.

#define PEX_STDERR_TO_PIPE   0x40

Definition at line 409 of file libiberty.h.

#define PEX_STDERR_TO_STDOUT   0x8

Definition at line 390 of file libiberty.h.

#define PEX_SUFFIX   0x4

Definition at line 387 of file libiberty.h.

#define PEX_USE_PIPES   0x2

Definition at line 358 of file libiberty.h.

#define PEXECUTE_FIRST   1

Definition at line 566 of file libiberty.h.

#define PEXECUTE_LAST   2

Definition at line 567 of file libiberty.h.

Definition at line 568 of file libiberty.h.

#define PEXECUTE_SEARCH   4

Definition at line 569 of file libiberty.h.

#define PEXECUTE_VERBOSE   8

Definition at line 570 of file libiberty.h.

#define USE_C_ALLOCA   1

Definition at line 631 of file libiberty.h.

#define XCNEW (   T)    ((T *) xcalloc (1, sizeof (T)))

Definition at line 320 of file libiberty.h.

#define XCNEWVAR (   T,
  S 
)    ((T *) xcalloc (1, (S)))

Definition at line 333 of file libiberty.h.

#define XCNEWVEC (   T,
  N 
)    ((T *) xcalloc ((N), sizeof (T)))

Definition at line 326 of file libiberty.h.

#define XDELETE (   P)    free ((void*) (P))

Definition at line 321 of file libiberty.h.

#define XDELETEVEC (   P)    free ((void*) (P))

Definition at line 328 of file libiberty.h.

#define XNEW (   T)    ((T *) xmalloc (sizeof (T)))

Definition at line 319 of file libiberty.h.

#define XNEWVAR (   T,
  S 
)    ((T *) xmalloc ((S)))

Definition at line 332 of file libiberty.h.

#define XNEWVEC (   T,
  N 
)    ((T *) xmalloc (sizeof (T) * (N)))

Definition at line 325 of file libiberty.h.

#define XOBFINISH (   O,
 
)    ((T) obstack_finish ((O)))

Definition at line 339 of file libiberty.h.

#define XOBNEW (   O,
 
)    ((T *) obstack_alloc ((O), sizeof (T)))

Definition at line 338 of file libiberty.h.

#define XRESIZEVAR (   T,
  P,
  S 
)    ((T *) xrealloc ((P), (S)))

Definition at line 334 of file libiberty.h.

#define XRESIZEVEC (   T,
  P,
  N 
)    ((T *) xrealloc ((void *) (P), sizeof (T) * (N)))

Definition at line 327 of file libiberty.h.


Function Documentation

int asprintf ( char **  ,
const char *  ,
  ... 
)

Definition at line 47 of file asprintf.c.

{
  int status;
  VA_OPEN (ap, fmt);
  VA_FIXEDARG (ap, char **, buf);
  VA_FIXEDARG (ap, const char *, fmt);
  status = vasprintf (buf, fmt, ap);
  VA_CLOSE (ap);
  return status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char** buildargv ( const char *  )

Definition at line 162 of file argv.c.

{
  char *arg;
  char *copybuf;
  int squote = 0;
  int dquote = 0;
  int bsquote = 0;
  int argc = 0;
  int maxargc = 0;
  char **argv = NULL;
  char **nargv;

  if (input != NULL)
    {
      copybuf = (char *) alloca (strlen (input) + 1);
      /* Is a do{}while to always execute the loop once.  Always return an
        argv, even for null strings.  See NOTES above, test case below. */
      do
       {
         /* Pick off argv[argc] */
         while (ISBLANK (*input))
           {
             input++;
           }
         if ((maxargc == 0) || (argc >= (maxargc - 1)))
           {
             /* argv needs initialization, or expansion */
             if (argv == NULL)
              {
                maxargc = INITIAL_MAXARGC;
                nargv = (char **) malloc (maxargc * sizeof (char *));
              }
             else
              {
                maxargc *= 2;
                nargv = (char **) realloc (argv, maxargc * sizeof (char *));
              }
             if (nargv == NULL)
              {
                if (argv != NULL)
                  {
                    freeargv (argv);
                    argv = NULL;
                  }
                break;
              }
             argv = nargv;
             argv[argc] = NULL;
           }
         /* Begin scanning arg */
         arg = copybuf;
         while (*input != EOS)
           {
             if (ISSPACE (*input) && !squote && !dquote && !bsquote)
              {
                break;
              }
             else
              {
                if (bsquote)
                  {
                    bsquote = 0;
                    *arg++ = *input;
                  }
                else if (*input == '\\')
                  {
                    bsquote = 1;
                  }
                else if (squote)
                  {
                    if (*input == '\'')
                     {
                       squote = 0;
                     }
                    else
                     {
                       *arg++ = *input;
                     }
                  }
                else if (dquote)
                  {
                    if (*input == '"')
                     {
                       dquote = 0;
                     }
                    else
                     {
                       *arg++ = *input;
                     }
                  }
                else
                  {
                    if (*input == '\'')
                     {
                       squote = 1;
                     }
                    else if (*input == '"')
                     {
                       dquote = 1;
                     }
                    else
                     {
                       *arg++ = *input;
                     }
                  }
                input++;
              }
           }
         *arg = EOS;
         argv[argc] = strdup (copybuf);
         if (argv[argc] == NULL)
           {
             freeargv (argv);
             argv = NULL;
             break;
           }
         argc++;
         argv[argc] = NULL;

         while (ISSPACE (*input))
           {
             input++;
           }
       }
      while (*input != EOS);
    }
  return (argv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* C_alloca ( size_t  )

Definition at line 162 of file alloca.c.

{
  auto char probe;          /* Probes stack depth: */
  register char *depth = ADDRESS_FUNCTION (probe);

#if STACK_DIRECTION == 0
  if (STACK_DIR == 0)              /* Unknown growth direction.  */
    find_stack_direction ();
#endif

  /* Reclaim garbage, defined as all alloca'd storage that
     was allocated from deeper in the stack than currently.  */

  {
    register header *hp;    /* Traverses linked list.  */

    for (hp = last_alloca_header; hp != NULL;)
      if ((STACK_DIR > 0 && hp->h.deep > depth)
         || (STACK_DIR < 0 && hp->h.deep < depth))
       {
         register header *np = hp->h.next;

         free ((PTR) hp);   /* Collect garbage.  */

         hp = np;           /* -> next header.  */
       }
      else
       break;               /* Rest are not deeper.  */

    last_alloca_header = hp;       /* -> last valid storage.  */
  }

  if (size == 0)
    return NULL;            /* No allocation required.  */

  /* Allocate combined header + user data storage.  */

  {
    register void *new_storage = XNEWVEC (char, sizeof (header) + size);
    /* Address of header.  */

    if (new_storage == 0)
      abort();

    ((header *) new_storage)->h.next = last_alloca_header;
    ((header *) new_storage)->h.deep = depth;

    last_alloca_header = (header *) new_storage;

    /* User storage begins just after header.  */

    return (PTR) ((char *) new_storage + sizeof (header));
  }
}

Here is the call graph for this function:

char* choose_temp_base ( void  )

Definition at line 57 of file choose-temp.c.

{
  const char *base = choose_tmpdir ();
  char *temp_filename;
  int len;

  len = strlen (base);
  temp_filename = XNEWVEC (char, len + TEMP_FILE_LEN + 1);
  strcpy (temp_filename, base);
  strcpy (temp_filename + len, TEMP_FILE);

  if (mktemp (temp_filename) == 0)
    abort ();
  return temp_filename;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* concat ( const char *  ,
  ... 
)

Definition at line 152 of file concat.c.

{
  char *newstr;

  /* First compute the size of the result and get sufficient memory.  */
  VA_OPEN (args, first);
  VA_FIXEDARG (args, const char *, first);
  newstr = XNEWVEC (char, vconcat_length (first, args) + 1);
  VA_CLOSE (args);

  /* Now copy the individual pieces to the result string. */
  VA_OPEN (args, first);
  VA_FIXEDARG (args, const char *, first);
  vconcat_copy (newstr, first, args);
  VA_CLOSE (args);

  return newstr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* concat_copy ( char *  ,
const char *  ,
  ... 
)

Definition at line 116 of file concat.c.

{
  char *save_dst;

  VA_OPEN (args, first);
  VA_FIXEDARG (args, char *, dst);
  VA_FIXEDARG (args, const char *, first);
  vconcat_copy (dst, first, args);
  save_dst = dst; /* With K&R C, dst goes out of scope here.  */
  VA_CLOSE (args);

  return save_dst;
}

Here is the call graph for this function:

char* concat_copy2 ( const char *  ,
  ... 
)

Definition at line 141 of file concat.c.

{
  VA_OPEN (args, first);
  VA_FIXEDARG (args, const char *, first);
  vconcat_copy (libiberty_concat_ptr, first, args);
  VA_CLOSE (args);

  return libiberty_concat_ptr;
}

Here is the call graph for this function:

unsigned long concat_length ( const char *  ,
  ... 
)

Definition at line 101 of file concat.c.

{
  unsigned long length;

  VA_OPEN (args, first);
  VA_FIXEDARG (args, const char *, first);
  length = vconcat_length (first, args);
  VA_CLOSE (args);

  return length;
}

Here is the call graph for this function:

char** dupargv ( char **  )

Definition at line 65 of file argv.c.

{
  int argc;
  char **copy;
  
  if (argv == NULL)
    return NULL;
  
  /* the vector */
  for (argc = 0; argv[argc] != NULL; argc++);
  copy = (char **) malloc ((argc + 1) * sizeof (char *));
  if (copy == NULL)
    return NULL;
  
  /* the strings */
  for (argc = 0; argv[argc] != NULL; argc++)
    {
      int len = strlen (argv[argc]);
      copy[argc] = (char *) malloc (len + 1);
      if (copy[argc] == NULL)
       {
         freeargv (copy);
         return NULL;
       }
      strcpy (copy[argc], argv[argc]);
    }
  copy[argc] = NULL;
  return copy;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int errno_max ( void  )

Definition at line 587 of file strerror.c.

{
  int maxsize;

  if (error_names == NULL)
    {
      init_error_tables ();
    }
  maxsize = MAX (sys_nerr, num_error_names);
  return (maxsize - 1);
}

Here is the call graph for this function:

int fdmatch ( int  fd1,
int  fd2 
)

Definition at line 52 of file fdmatch.c.

{
  struct stat sbuf1;
  struct stat sbuf2;

  if ((fstat (fd1, &sbuf1) == 0) &&
      (fstat (fd2, &sbuf2) == 0) &&
      (sbuf1.st_dev == sbuf2.st_dev) &&
      (sbuf1.st_ino == sbuf2.st_ino))
    {
      return (1);
    }
  else
    {
      return (0);
    }
}
FILE* fdopen_unlocked ( int  ,
const char *   
)

Definition at line 113 of file fopen_unlocked.c.

{
  FILE *const fp = fdopen (fildes, mode);
  unlock_1 (fp);
  return fp;
}

Here is the call graph for this function:

FILE* fopen_unlocked ( const char *  ,
const char *   
)

Definition at line 105 of file fopen_unlocked.c.

{
  FILE *const fp = fopen (path, mode);
  unlock_1 (fp);
  return fp;
}

Here is the call graph for this function:

void freeargv ( char **  )

Definition at line 108 of file argv.c.

{
  register char **scan;

  if (vector != NULL)
    {
      for (scan = vector; *scan != NULL; scan++)
       {
         free (*scan);
       }
      free (vector);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* freopen_unlocked ( const char *  ,
const char *  ,
FILE *   
)

Definition at line 121 of file fopen_unlocked.c.

{
  FILE *const fp = freopen (path, mode, stream);
  unlock_1 (fp);
  return fp;
}

Here is the call graph for this function:

long get_run_time ( void  )

Definition at line 93 of file getruntime.c.

{
#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
  struct rusage rusage;

  getrusage (0, &rusage);
  return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
         + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
#else /* ! HAVE_GETRUSAGE */
#ifdef HAVE_TIMES
  struct tms tms;

  times (&tms);
  return (tms.tms_utime + tms.tms_stime) * (1000000 / GNU_HZ);
#else /* ! HAVE_TIMES */
  /* Fall back on clock and hope it's correctly implemented. */
  const long clocks_per_sec = CLOCKS_PER_SEC;
  if (clocks_per_sec <= 1000000)
    return clock () * (1000000 / clocks_per_sec);
  else
    return clock () / clocks_per_sec;
#endif  /* HAVE_TIMES */
#endif  /* HAVE_GETRUSAGE */
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* getpwd ( void  )

Definition at line 68 of file getpwd.c.

{
  static char *pwd;
  static int failure_errno;

  char *p = pwd;
  size_t s;
  struct stat dotstat, pwdstat;

  if (!p && !(errno = failure_errno))
    {
      if (! ((p = getenv ("PWD")) != 0
            && *p == '/'
            && stat (p, &pwdstat) == 0
            && stat (".", &dotstat) == 0
            && dotstat.st_ino == pwdstat.st_ino
            && dotstat.st_dev == pwdstat.st_dev))

       /* The shortcut didn't work.  Try the slow, ``sure'' way.  */
       for (s = GUESSPATHLEN;  !getcwd (p = XNEWVEC (char, s), s);  s *= 2)
         {
           int e = errno;
           free (p);
#ifdef ERANGE
           if (e != ERANGE)
#endif
             {
              errno = failure_errno = e;
              p = 0;
              break;
             }
         }

      /* Cache the result.  This assumes that the program does
        not invoke chdir between calls to getpwd.  */
      pwd = p;
    }
  return p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hex_init ( void  )

Definition at line 159 of file hex.c.

{
#ifndef HEX_TABLE_INITIALIZED
  int i;

  for (i=0; i<_hex_array_size; i++)
    {
      switch (i)
       {
       case '0': _hex_value[i] = 0; break;
       case '1': _hex_value[i] = 1; break;
       case '2': _hex_value[i] = 2; break;
       case '3': _hex_value[i] = 3; break;
       case '4': _hex_value[i] = 4; break;
       case '5': _hex_value[i] = 5; break;
       case '6': _hex_value[i] = 6; break;
       case '7': _hex_value[i] = 7; break;
       case '8': _hex_value[i] = 8; break;
       case '9': _hex_value[i] = 9; break;

       case 'a': case 'A': _hex_value[i] = 10; break;
       case 'b': case 'B': _hex_value[i] = 11; break;
       case 'c': case 'C': _hex_value[i] = 12; break;
       case 'd': case 'D': _hex_value[i] = 13; break;
       case 'e': case 'E': _hex_value[i] = 14; break;
       case 'f': case 'F': _hex_value[i] = 15; break;

       default:
         _hex_value[i] = _hex_bad;
         break;
       }
    }
#endif
}

Here is the caller graph for this function:

const char* lbasename ( const char *  )

Definition at line 49 of file lbasename.c.

{
  const char *base;

#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
  /* Skip over a possible disk name.  */
  if (ISALPHA (name[0]) && name[1] == ':') 
    name += 2;
#endif

  for (base = name; *name; name++)
    if (IS_DIR_SEPARATOR (*name))
      base = name + 1;

  return base;
}

Here is the caller graph for this function:

char* lrealpath ( const char *  )

Definition at line 76 of file lrealpath.c.

{
  /* Method 1: The system has a compile time upper bound on a filename
     path.  Use that and realpath() to canonicalize the name.  This is
     the most common case.  Note that, if there isn't a compile time
     upper bound, you want to avoid realpath() at all costs.  */
#if defined(REALPATH_LIMIT)
  {
    char buf[REALPATH_LIMIT];
    const char *rp = realpath (filename, buf);
    if (rp == NULL)
      rp = filename;
    return strdup (rp);
  }
#endif /* REALPATH_LIMIT */

  /* Method 2: The host system (i.e., GNU) has the function
     canonicalize_file_name() which malloc's a chunk of memory and
     returns that, use that.  */
#if defined(HAVE_CANONICALIZE_FILE_NAME)
  {
    char *rp = canonicalize_file_name (filename);
    if (rp == NULL)
      return strdup (filename);
    else
      return rp;
  }
#endif

  /* Method 3: Now we're getting desperate!  The system doesn't have a
     compile time buffer size and no alternative function.  Query the
     OS, using pathconf(), for the buffer limit.  Care is needed
     though, some systems do not limit PATH_MAX (return -1 for
     pathconf()) making it impossible to pass a correctly sized buffer
     to realpath() (it could always overflow).  On those systems, we
     skip this.  */
#if defined (HAVE_REALPATH) && defined (HAVE_UNISTD_H)
  {
    /* Find out the max path size.  */
    long path_max = pathconf ("/", _PC_PATH_MAX);
    if (path_max > 0)
      {
       /* PATH_MAX is bounded.  */
       char *buf, *rp, *ret;
       buf = (char *) malloc (path_max);
       if (buf == NULL)
         return NULL;
       rp = realpath (filename, buf);
       ret = strdup (rp ? rp : filename);
       free (buf);
       return ret;
      }
  }
#endif

  /* The MS Windows method.  If we don't have realpath, we assume we
     don't have symlinks and just canonicalize to a Windows absolute
     path.  GetFullPath converts ../ and ./ in relative paths to
     absolute paths, filling in current drive if one is not given
     or using the current directory of a specified drive (eg, "E:foo").
     It also converts all forward slashes to back slashes.  */
#if defined (_WIN32)
  {
    char buf[MAX_PATH];
    char* basename;
    DWORD len = GetFullPathName (filename, MAX_PATH, buf, &basename);
    if (len == 0 || len > MAX_PATH - 1)
      return strdup (filename);
    else
      {
       /* The file system is case-preserving but case-insensitive,
          Canonicalize to lowercase, using the codepage associated
          with the process locale.  */
        CharLowerBuff (buf, len);
        return strdup (buf);
      }
  }
#endif

  /* This system is a lost cause, just duplicate the filename.  */
  return strdup (filename);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* make_relative_prefix ( const char *  ,
const char *  ,
const char *   
)

Here is the caller graph for this function:

char* make_relative_prefix_ignore_links ( const char *  ,
const char *  ,
const char *   
)
char* make_temp_file ( const char *  )

Definition at line 148 of file make-temp-file.c.

{
  const char *base = choose_tmpdir ();
  char *temp_filename;
  int base_len, suffix_len;
  int fd;

  if (suffix == 0)
    suffix = "";

  base_len = strlen (base);
  suffix_len = strlen (suffix);

  temp_filename = XNEWVEC (char, base_len
                        + TEMP_FILE_LEN
                        + suffix_len + 1);
  strcpy (temp_filename, base);
  strcpy (temp_filename + base_len, TEMP_FILE);
  strcpy (temp_filename + base_len + TEMP_FILE_LEN, suffix);

  fd = mkstemps (temp_filename, suffix_len);
  /* If mkstemps failed, then something bad is happening.  Maybe we should
     issue a message about a possible security attack in progress?  */
  if (fd == -1)
    abort ();
  /* Similarly if we can not close the file.  */
  if (close (fd))
    abort ();
  return temp_filename;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void expandargv PARAMS ( (int *, char ***)  )
void pex_free ( struct pex_obj )

Definition at line 598 of file pex-common.c.

{
  if (obj->next_input >= 0 && obj->next_input != STDIN_FILE_NO)
    obj->funcs->close (obj, obj->next_input);

  /* If the caller forgot to wait for the children, we do it here, to
     avoid zombies.  */
  if (obj->status == NULL)
    {
      const char *errmsg;
      int err;

      obj->flags &= ~ PEX_RECORD_TIMES;
      pex_get_status_and_time (obj, 1, &errmsg, &err);
    }

  if (obj->next_input_name_allocated)
    free (obj->next_input_name);
  if (obj->children != NULL)
    free (obj->children);
  if (obj->status != NULL)
    free (obj->status);
  if (obj->time != NULL)
    free (obj->time);
  if (obj->read_output != NULL)
    fclose (obj->read_output);
  if (obj->read_err != NULL)
    fclose (obj->read_err);

  if (obj->remove_count > 0)
    {
      int i;

      for (i = 0; i < obj->remove_count; ++i)
       {
         remove (obj->remove[i]);
         free (obj->remove[i]);
       }
      free (obj->remove);
    }

  if (obj->funcs->cleanup != NULL)
    obj->funcs->cleanup (obj);

  free (obj);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pex_get_status ( struct pex_obj ,
int  count,
int vector 
)

Definition at line 544 of file pex-common.c.

{
  if (obj->status == NULL)
    {
      const char *errmsg;
      int err;

      if (!pex_get_status_and_time (obj, 0, &errmsg, &err))
       return 0;
    }

  if (count > obj->count)
    {
      memset (vector + obj->count, 0, (count - obj->count) * sizeof (int));
      count = obj->count;
    }

  memcpy (vector, obj->status, count * sizeof (int));

  return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pex_get_times ( struct pex_obj ,
int  count,
struct pex_time vector 
)

Definition at line 569 of file pex-common.c.

{
  if (obj->status == NULL)
    {
      const char *errmsg;
      int err;

      if (!pex_get_status_and_time (obj, 0, &errmsg, &err))
       return 0;
    }

  if (obj->time == NULL)
    return 0;

  if (count > obj->count)
    {
      memset (vector + obj->count, 0,
             (count - obj->count) * sizeof (struct pex_time));
      count = obj->count;
    }

  memcpy (vector, obj->time, count * sizeof (struct pex_time));

  return 1;
}

Here is the call graph for this function:

struct pex_obj* pex_init ( int  flags,
const char *  pname,
const char *  tempbase 
) [read]

Definition at line 73 of file pex-djgpp.c.

{
  /* DJGPP does not support pipes.  */
  flags &= ~ PEX_USE_PIPES;
  return pex_init_common (flags, pname, tempbase, &funcs);
}

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* pex_input_file ( struct pex_obj obj,
int  flags,
const char *  in_name 
)

Definition at line 379 of file pex-common.c.

{
  char *name = (char *) in_name;
  FILE *f;

  /* This must be called before the first pipeline stage is run, and
     there must not have been any other input selected.  */
  if (obj->count != 0
      || (obj->next_input >= 0 && obj->next_input != STDIN_FILE_NO)
      || obj->next_input_name)
    {
      errno = EINVAL;
      return NULL;
    }

  name = temp_file (obj, flags, name);
  if (! name)
    return NULL;

  f = fopen (name, (flags & PEX_BINARY_OUTPUT) ? "wb" : "w");
  if (! f)
    {
      free (name);
      return NULL;
    }

  obj->input_file = f;
  obj->next_input_name = name;
  obj->next_input_name_allocated = (name != in_name);

  return f;
}

Here is the call graph for this function:

FILE* pex_input_pipe ( struct pex_obj obj,
int  binary 
)

Definition at line 415 of file pex-common.c.

{
  int p[2];
  FILE *f;

  /* You must call pex_input_pipe before the first pex_run or pex_one.  */
  if (obj->count > 0)
    goto usage_error;

  /* You must be using pipes.  Implementations that don't support
     pipes clear this flag before calling pex_init_common.  */
  if (! (obj->flags & PEX_USE_PIPES))
    goto usage_error;

  /* If we have somehow already selected other input, that's a
     mistake.  */
  if ((obj->next_input >= 0 && obj->next_input != STDIN_FILE_NO)
      || obj->next_input_name)
    goto usage_error;

  if (obj->funcs->pipe (obj, p, binary != 0) < 0)
    return NULL;

  f = obj->funcs->fdopenw (obj, p[WRITE_PORT], binary != 0);
  if (! f)
    {
      int saved_errno = errno;
      obj->funcs->close (obj, p[READ_PORT]);
      obj->funcs->close (obj, p[WRITE_PORT]);
      errno = saved_errno;
      return NULL;
    }

  obj->next_input = p[READ_PORT];

  return f;

 usage_error:
  errno = EINVAL;
  return NULL;
}

Here is the call graph for this function:

const char* pex_one ( int  flags,
const char *  executable,
char *const argv,
const char *  pname,
const char *  outname,
const char *  errname,
int status,
int err 
)

Definition at line 24 of file pex-one.c.

{
  struct pex_obj *obj;
  const char *errmsg;

  obj = pex_init (0, pname, NULL);
  errmsg = pex_run (obj, flags, executable, argv, outname, errname, err);
  if (errmsg == NULL)
    {
      if (!pex_get_status (obj, 1, status))
       {
         *err = 0;
         errmsg = "pex_get_status failed";
       }
    }
  pex_free (obj);
  return errmsg;  
}

Here is the call graph for this function:

FILE* pex_read_err ( struct pex_obj ,
int  binary 
)

Definition at line 500 of file pex-common.c.

{
  int o;
  
  o = obj->stderr_pipe;
  if (o < 0 || o == STDIN_FILE_NO)
    return NULL;
  obj->read_err = obj->funcs->fdopenr (obj, o, binary);
  return obj->read_err;    
}
FILE* pex_read_output ( struct pex_obj ,
int  binary 
)

Definition at line 461 of file pex-common.c.

{
  if (obj->next_input_name != NULL)
    {
      const char *errmsg;
      int err;

      /* We have to make sure that the process has completed before we
        try to read the file.  */
      if (!pex_get_status_and_time (obj, 0, &errmsg, &err))
       {
         errno = err;
         return NULL;
       }

      obj->read_output = fopen (obj->next_input_name, binary ? "rb" : "r");

      if (obj->next_input_name_allocated)
       {
         free (obj->next_input_name);
         obj->next_input_name_allocated = 0;
       }
      obj->next_input_name = NULL;
    }
  else
    {
      int o;

      o = obj->next_input;
      if (o < 0 || o == STDIN_FILE_NO)
       return NULL;
      obj->read_output = obj->funcs->fdopenr (obj, o, binary);
      obj->next_input = -1;
    }

  return obj->read_output;
}

Here is the call graph for this function:

const char* pex_run ( struct pex_obj obj,
int  flags,
const char *  executable,
char *const argv,
const char *  outname,
const char *  errname,
int err 
)

Definition at line 368 of file pex-common.c.

{
  return pex_run_in_environment (obj, flags, executable, argv, NULL,
                             orig_outname, errname, err);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* pex_run_in_environment ( struct pex_obj obj,
int  flags,
const char *  executable,
char *const argv,
char *const env,
const char *  outname,
const char *  errname,
int err 
)

Definition at line 152 of file pex-common.c.

{
  const char *errmsg;
  int in, out, errdes;
  char *outname;
  int outname_allocated;
  int p[2];
  int toclose;
  long pid;

  in = -1;
  out = -1;
  errdes = -1;
  outname = (char *) orig_outname;
  outname_allocated = 0;

  /* If the user called pex_input_file, close the file now.  */
  if (obj->input_file)
    {
      if (fclose (obj->input_file) == EOF)
        {
          errmsg = "closing pipeline input file";
          goto error_exit;
        }
      obj->input_file = NULL;
    }

  /* Set IN.  */

  if (obj->next_input_name != NULL)
    {
      /* We have to make sure that the previous process has completed
        before we try to read the file.  */
      if (!pex_get_status_and_time (obj, 0, &errmsg, err))
       goto error_exit;

      in = obj->funcs->open_read (obj, obj->next_input_name,
                              (flags & PEX_BINARY_INPUT) != 0);
      if (in < 0)
       {
         *err = errno;
         errmsg = "open temporary file";
         goto error_exit;
       }
      if (obj->next_input_name_allocated)
       {
         free (obj->next_input_name);
         obj->next_input_name_allocated = 0;
       }
      obj->next_input_name = NULL;
    }
  else
    {
      in = obj->next_input;
      if (in < 0)
       {
         *err = 0;
         errmsg = "pipeline already complete";
         goto error_exit;
       }
    }

  /* Set OUT and OBJ->NEXT_INPUT/OBJ->NEXT_INPUT_NAME.  */

  if ((flags & PEX_LAST) != 0)
    {
      if (outname == NULL)
       out = STDOUT_FILE_NO;
      else if ((flags & PEX_SUFFIX) != 0)
       {
         outname = concat (obj->tempbase, outname, NULL);
         outname_allocated = 1;
       }
      obj->next_input = -1;
    }
  else if ((obj->flags & PEX_USE_PIPES) == 0)
    {
      outname = temp_file (obj, flags, outname);
      if (! outname)
        {
          *err = 0;
          errmsg = "could not create temporary file";
          goto error_exit;
        }

      if (outname != orig_outname)
        outname_allocated = 1;

      if ((obj->flags & PEX_SAVE_TEMPS) == 0)
       {
         pex_add_remove (obj, outname, outname_allocated);
         outname_allocated = 0;
       }

      /* Hand off ownership of outname to the next stage.  */
      obj->next_input_name = outname;
      obj->next_input_name_allocated = outname_allocated;
      outname_allocated = 0;
    }
  else
    {
      if (obj->funcs->pipe (obj, p, (flags & PEX_BINARY_OUTPUT) != 0) < 0)
       {
         *err = errno;
         errmsg = "pipe";
         goto error_exit;
       }

      out = p[WRITE_PORT];
      obj->next_input = p[READ_PORT];
    }

  if (out < 0)
    {
      out = obj->funcs->open_write (obj, outname,
                                (flags & PEX_BINARY_OUTPUT) != 0);
      if (out < 0)
       {
         *err = errno;
         errmsg = "open temporary output file";
         goto error_exit;
       }
    }

  if (outname_allocated)
    {
      free (outname);
      outname_allocated = 0;
    }

  /* Set ERRDES.  */

  if (errname != NULL && (flags & PEX_STDERR_TO_PIPE) != 0)
    {
      *err = 0;
      errmsg = "both ERRNAME and PEX_STDERR_TO_PIPE specified.";
      goto error_exit;
    }

  if (obj->stderr_pipe != -1)
    {
      *err = 0;
      errmsg = "PEX_STDERR_TO_PIPE used in the middle of pipeline";
      goto error_exit;
    }

  if (errname == NULL)
    {
      if (flags & PEX_STDERR_TO_PIPE)
       {
         if (obj->funcs->pipe (obj, p, (flags & PEX_BINARY_ERROR) != 0) < 0)
           {
             *err = errno;
             errmsg = "pipe";
             goto error_exit;
           }
         
         errdes = p[WRITE_PORT];
         obj->stderr_pipe = p[READ_PORT];   
       }
      else
       {
         errdes = STDERR_FILE_NO;
       }
    }
  else
    {
      errdes = obj->funcs->open_write (obj, errname, 
                                   (flags & PEX_BINARY_ERROR) != 0);
      if (errdes < 0)
       {
         *err = errno;
         errmsg = "open error file";
         goto error_exit;
       }
    }

  /* If we are using pipes, the child process has to close the next
     input pipe.  */

  if ((obj->flags & PEX_USE_PIPES) == 0)
    toclose = -1;
  else
    toclose = obj->next_input;

  /* Run the program.  */

  pid = obj->funcs->exec_child (obj, flags, executable, argv, env,
                            in, out, errdes, toclose, &errmsg, err);
  if (pid < 0)
    goto error_exit;

  ++obj->count;
  obj->children = XRESIZEVEC (long, obj->children, obj->count);
  obj->children[obj->count - 1] = pid;

  return NULL;

 error_exit:
  if (in >= 0 && in != STDIN_FILE_NO)
    obj->funcs->close (obj, in);
  if (out >= 0 && out != STDOUT_FILE_NO)
    obj->funcs->close (obj, out);
  if (errdes >= 0 && errdes != STDERR_FILE_NO)
    obj->funcs->close (obj, errdes);
  if (outname_allocated)
    free (outname);
  return errmsg;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pexecute ( const char *  ,
char *const ,
const char *  ,
const char *  ,
char **  ,
char **  ,
int   
)

Definition at line 39 of file pexecute.c.

{
  const char *errmsg;
  int err;

  if ((flags & PEXECUTE_FIRST) != 0)
    {
      if (pex != NULL)
       {
         *errmsg_fmt = (char *) "pexecute already in progress";
         *errmsg_arg = NULL;
         return -1;
       }
      pex = pex_init (PEX_USE_PIPES, pname, temp_base);
      idx = 0;
    }
  else
    {
      if (pex == NULL)
       {
         *errmsg_fmt = (char *) "pexecute not in progress";
         *errmsg_arg = NULL;
         return -1;
       }
    }

  errmsg = pex_run (pex,
                  (((flags & PEXECUTE_LAST) != 0 ? PEX_LAST : 0)
                   | ((flags & PEXECUTE_SEARCH) != 0 ? PEX_SEARCH : 0)),
                  program, argv, NULL, NULL, &err);
  if (errmsg != NULL)
    {
      *errmsg_fmt = (char *) errmsg;
      *errmsg_arg = NULL;
      return -1;
    }

  /* Instead of a PID, we just return a one-based index into the
     status values.  We avoid zero just because the old pexecute would
     never return it.  */
  return ++idx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 187 of file physmem.c.

{
#if defined _SC_AVPHYS_PAGES && defined _SC_PAGESIZE
  { /* This works on linux-gnu, solaris2 and cygwin.  */
    double pages = sysconf (_SC_AVPHYS_PAGES);
    double pagesize = sysconf (_SC_PAGESIZE);
    if (0 <= pages && 0 <= pagesize)
      return pages * pagesize;
  }
#endif

#if HAVE_PSTAT_GETSTATIC && HAVE_PSTAT_GETDYNAMIC
  { /* This works on hpux11.  */
    struct pst_static pss;
    struct pst_dynamic psd;
    if (0 <= pstat_getstatic (&pss, sizeof pss, 1, 0)
       && 0 <= pstat_getdynamic (&psd, sizeof psd, 1, 0))
      {
       double pages = psd.psd_free;
       double pagesize = pss.page_size;
       if (0 <= pages && 0 <= pagesize)
         return pages * pagesize;
      }
  }
#endif

#if HAVE_SYSMP && defined MP_SAGET && defined MPSA_RMINFO && defined _SC_PAGESIZE
  { /* This works on irix6. */
    struct rminfo realmem;
    if (sysmp (MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0)
      {
       double pagesize = sysconf (_SC_PAGESIZE);
       double pages = realmem.availrmem;
       if (0 <= pages && 0 <= pagesize)
         return pages * pagesize;
      }
  }
#endif

#if HAVE_TABLE && defined TBL_VMSTATS
  { /* This works on Tru64 UNIX V4/5.  */
    struct tbl_vmstats vmstats;

    if (table (TBL_VMSTATS, 0, &vmstats, 1, sizeof (vmstats)) == 1)
      {
       double pages = vmstats.free_count;
       double pagesize = vmstats.pagesize;

       if (0 <= pages && 0 <= pagesize)
         return pages * pagesize;
      }
  }
#endif

#if HAVE_SYSCTL && defined HW_USERMEM
  { /* This works on *bsd and darwin.  */
    unsigned int usermem;
    size_t len = sizeof usermem;
    static int mib[2] = { CTL_HW, HW_USERMEM };

    if (sysctl (mib, ARRAY_SIZE (mib), &usermem, &len, NULL, 0) == 0
       && len == sizeof (usermem))
      return (double) usermem;
  }
#endif

#if defined _WIN32
  { /* this works on windows */
    PFN_MS_EX pfnex;
    HMODULE h = GetModuleHandle ("kernel32.dll");

    if (!h)
      return 0.0;

    /*  Use GlobalMemoryStatusEx if available.  */
    if ((pfnex = (PFN_MS_EX) GetProcAddress (h, "GlobalMemoryStatusEx")))
      {
       lMEMORYSTATUSEX lms_ex;
       lms_ex.dwLength = sizeof lms_ex;
       if (!pfnex (&lms_ex))
         return 0.0;
       return (double) lms_ex.ullAvailPhys;
      }

    /*  Fall back to GlobalMemoryStatus which is always available.
        but returns wrong results for physical memory > 4GB  */
    else
      {
       MEMORYSTATUS ms;
       GlobalMemoryStatus (&ms);
       return (double) ms.dwAvailPhys;
      }
  }
#endif

  /* Guess 25% of physical memory.  */
  return physmem_total () / 4;
}

Here is the call graph for this function:

double physmem_total ( void  )

Definition at line 83 of file physmem.c.

{
#if defined _SC_PHYS_PAGES && defined _SC_PAGESIZE
  { /* This works on linux-gnu, solaris2 and cygwin.  */
    double pages = sysconf (_SC_PHYS_PAGES);
    double pagesize = sysconf (_SC_PAGESIZE);
    if (0 <= pages && 0 <= pagesize)
      return pages * pagesize;
  }
#endif

#if HAVE_PSTAT_GETSTATIC
  { /* This works on hpux11.  */
    struct pst_static pss;
    if (0 <= pstat_getstatic (&pss, sizeof pss, 1, 0))
      {
       double pages = pss.physical_memory;
       double pagesize = pss.page_size;
       if (0 <= pages && 0 <= pagesize)
         return pages * pagesize;
      }
  }
#endif

#if HAVE_SYSMP && defined MP_SAGET && defined MPSA_RMINFO && defined _SC_PAGESIZE
  { /* This works on irix6. */
    struct rminfo realmem;
    if (sysmp (MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0)
      {
       double pagesize = sysconf (_SC_PAGESIZE);
       double pages = realmem.physmem;
       if (0 <= pages && 0 <= pagesize)
         return pages * pagesize;
      }
  }
#endif

#if HAVE_GETSYSINFO && defined GSI_PHYSMEM
  { /* This works on Tru64 UNIX V4/5.  */
    int physmem;

    if (getsysinfo (GSI_PHYSMEM, (caddr_t) &physmem, sizeof (physmem),
                  NULL, NULL, NULL) == 1)
      {
       double kbytes = physmem;

       if (0 <= kbytes)
         return kbytes * 1024.0;
      }
  }
#endif

#if HAVE_SYSCTL && defined HW_PHYSMEM
  { /* This works on *bsd and darwin.  */
    unsigned int physmem;
    size_t len = sizeof physmem;
    static int mib[2] = { CTL_HW, HW_PHYSMEM };

    if (sysctl (mib, ARRAY_SIZE (mib), &physmem, &len, NULL, 0) == 0
       && len == sizeof (physmem))
      return (double) physmem;
  }
#endif

#if HAVE__SYSTEM_CONFIGURATION
  /* This works on AIX 4.3.3+.  */
  return _system_configuration.physmem;
#endif

#if defined _WIN32
  { /* this works on windows */
    PFN_MS_EX pfnex;
    HMODULE h = GetModuleHandle ("kernel32.dll");

    if (!h)
      return 0.0;

    /*  Use GlobalMemoryStatusEx if available.  */
    if ((pfnex = (PFN_MS_EX) GetProcAddress (h, "GlobalMemoryStatusEx")))
      {
       lMEMORYSTATUSEX lms_ex;
       lms_ex.dwLength = sizeof lms_ex;
       if (!pfnex (&lms_ex))
         return 0.0;
       return (double) lms_ex.ullTotalPhys;
      }

    /*  Fall back to GlobalMemoryStatus which is always available.
        but returns wrong results for physical memory > 4GB.  */
    else
      {
       MEMORYSTATUS ms;
       GlobalMemoryStatus (&ms);
       return (double) ms.dwTotalPhys;
      }
  }
#endif

  /* Return 0 if we can't determine the value.  */
  return 0;
}

Here is the caller graph for this function:

int pwait ( int  ,
int ,
int   
)

Here is the caller graph for this function:

char* reconcat ( char *  ,
const char *  ,
  ... 
)

Definition at line 189 of file concat.c.

{
  char *newstr;

  /* First compute the size of the result and get sufficient memory.  */
  VA_OPEN (args, first);
  VA_FIXEDARG (args, char *, optr);
  VA_FIXEDARG (args, const char *, first);
  newstr = XNEWVEC (char, vconcat_length (first, args) + 1);
  VA_CLOSE (args);

  /* Now copy the individual pieces to the result string. */
  VA_OPEN (args, first);
  VA_FIXEDARG (args, char *, optr);
  VA_FIXEDARG (args, const char *, first);
  vconcat_copy (newstr, first, args);
  if (optr) /* Done before VA_CLOSE so optr stays in scope for K&R C.  */
    free (optr);
  VA_CLOSE (args);

  return newstr;
}

Here is the call graph for this function:

int signo_max ( void  )

Definition at line 368 of file strsignal.c.

{
  int maxsize;

  if (signal_names == NULL)
    {
      init_signal_tables ();
    }
  maxsize = MAX (sys_nsig, num_signal_names);
  return (maxsize - 1);
}

Here is the call graph for this function:

const char* spaces ( int  count)

Definition at line 48 of file spaces.c.

{
  register char *t;
  static char *buf;
  static int maxsize;

  if (count > maxsize)
    {
      if (buf)
       {
         free (buf);
       }
      buf = (char *) malloc (count + 1);
      if (buf == (char *) 0)
       return 0;
      for (t = buf + count ; t != buf ; )
       {
         *--t = ' ';
       }
      maxsize = count;
      buf[count] = '\0';
    }
  return (const char *) (buf + maxsize - count);
}

Here is the call graph for this function:

const char* strerrno ( int  )

Definition at line 692 of file strerror.c.

{
  const char *name;
  static char buf[32];

  if (error_names == NULL)
    {
      init_error_tables ();
    }

  if ((errnoval < 0) || (errnoval >= num_error_names))
    {
#ifdef EVMSERR
      if (errnoval == evmserr.value)
       name = evmserr.name;
      else
#endif
      /* Out of range, just return NULL */
      name = NULL;
    }
  else if ((error_names == NULL) || (error_names[errnoval] == NULL))
    {
      /* In range, but no error_names or no entry at this index. */
      sprintf (buf, "Error %d", errnoval);
      name = (const char *) buf;
    }
  else
    {
      /* In range, and a valid name.  Just return the name. */
      name = error_names[errnoval];
    }

  return (name);
}

Here is the call graph for this function:

const char* strsigno ( int  )

Definition at line 467 of file strsignal.c.

{
  const char *name;
  static char buf[32];

  if (signal_names == NULL)
    {
      init_signal_tables ();
    }

  if ((signo < 0) || (signo >= num_signal_names))
    {
      /* Out of range, just return NULL */
      name = NULL;
    }
  else if ((signal_names == NULL) || (signal_names[signo] == NULL))
    {
      /* In range, but no signal_names or no entry at this index. */
      sprintf (buf, "Signal %d", signo);
      name = (const char *) buf;
    }
  else
    {
      /* In range, and a valid name.  Just return the name. */
      name = signal_names[signo];
    }

  return (name);
}

Here is the call graph for this function:

int strtoerrno ( const char *  )

Definition at line 739 of file strerror.c.

{
  int errnoval = 0;

  if (name != NULL)
    {
      if (error_names == NULL)
       {
         init_error_tables ();
       }
      for (errnoval = 0; errnoval < num_error_names; errnoval++)
       {
         if ((error_names[errnoval] != NULL) &&
             (strcmp (name, error_names[errnoval]) == 0))
           {
             break;
           }
       }
      if (errnoval == num_error_names)
       {
#ifdef EVMSERR
         if (strcmp (name, evmserr.name) == 0)
           errnoval = evmserr.value;
         else
#endif
         errnoval = 0;
       }
    }
  return (errnoval);
}

Here is the call graph for this function:

int strtosigno ( const char *  )

Definition at line 510 of file strsignal.c.

{
  int signo = 0;

  if (name != NULL)
    {
      if (signal_names == NULL)
       {
         init_signal_tables ();
       }
      for (signo = 0; signo < num_signal_names; signo++)
       {
         if ((signal_names[signo] != NULL) &&
             (strcmp (name, signal_names[signo]) == 0))
           {
             break;
           }
       }
      if (signo == num_signal_names)
       {
         signo = 0;
       }
    }
  return (signo);
}

Here is the call graph for this function:

Definition at line 63 of file unlink-if-ordinary.c.

{
  struct stat st;

  if (lstat (name, &st) == 0
      && (S_ISREG (st.st_mode) || S_ISLNK (st.st_mode)))
    return unlink (name);

  return 1;
}

Here is the caller graph for this function:

void unlock_std_streams ( void  )

Definition at line 97 of file fopen_unlocked.c.

{
  unlock_1 (stdin);
  unlock_1 (stdout);
  unlock_1 (stderr);
}

Here is the call graph for this function:

void unlock_stream ( FILE *  )

Definition at line 91 of file fopen_unlocked.c.

{
  unlock_1 (fp);
}

Here is the call graph for this function:

int vasprintf ( char **  ,
const char *  ,
va_list   
)

Here is the caller graph for this function:

int xatexit ( void(*)(void)  fn)

Definition at line 67 of file xatexit.c.

{
  register struct xatexit *p;

  /* Tell xexit to call xatexit_cleanup.  */
  if (!_xexit_cleanup)
    _xexit_cleanup = xatexit_cleanup;

  p = xatexit_head;
  if (p->ind >= XATEXIT_SIZE)
    {
      if ((p = (struct xatexit *) malloc (sizeof *p)) == NULL)
       return -1;
      p->ind = 0;
      p->next = xatexit_head;
      xatexit_head = p;
    }
  p->fns[p->ind++] = fn;
  return 0;
}

Here is the call graph for this function:

void* xcalloc ( size_t  ,
size_t   
)

Definition at line 155 of file xmalloc.c.

{
  PTR newmem;

  if (nelem == 0 || elsize == 0)
    nelem = elsize = 1;

  newmem = calloc (nelem, elsize);
  if (!newmem)
    xmalloc_failed (nelem * elsize);

  return (newmem);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void xexit ( int  status)

Definition at line 47 of file xexit.c.

{
  if (_xexit_cleanup != NULL)
    (*_xexit_cleanup) ();
  exit (code);
}

Here is the caller graph for this function:

void* xmalloc ( size_t  )

Definition at line 141 of file xmalloc.c.

{
  PTR newmem;

  if (size == 0)
    size = 1;
  newmem = malloc (size);
  if (!newmem)
    xmalloc_failed (size);

  return (newmem);
}
void xmalloc_failed ( size_t  )

Definition at line 117 of file xmalloc.c.

{
#ifdef HAVE_SBRK
  extern char **environ;
  size_t allocated;

  if (first_break != NULL)
    allocated = (char *) sbrk (0) - first_break;
  else
    allocated = (char *) sbrk (0) - (char *) &environ;
  fprintf (stderr,
          "\n%s%sout of memory allocating %lu bytes after a total of %lu bytes\n",
          name, *name ? ": " : "",
          (unsigned long) size, (unsigned long) allocated);
#else /* HAVE_SBRK */
  fprintf (stderr,
          "\n%s%sout of memory allocating %lu bytes\n",
          name, *name ? ": " : "",
          (unsigned long) size);
#endif /* HAVE_SBRK */
  xexit (1);
}  

Here is the call graph for this function:

Here is the caller graph for this function:

void xmalloc_set_program_name ( const char *  )

Definition at line 106 of file xmalloc.c.

{
  name = s;
#ifdef HAVE_SBRK
  /* Win32 ports other than cygwin32 don't have brk() */
  if (first_break == NULL)
    first_break = (char *) sbrk (0);
#endif /* HAVE_SBRK */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* xmemdup ( const void *  ,
size_t  ,
size_t   
)
void* xrealloc ( void *  ,
size_t   
)
char* xstrdup ( const char *  )

Definition at line 31 of file xstrdup.c.

{
  register size_t len = strlen (s) + 1;
  register char *ret = XNEWVEC (char, len);
  return (char *) memcpy (ret, s, len);
}

Here is the call graph for this function:

char* xstrerror ( int  )

Definition at line 54 of file xstrerror.c.

{
  char *errstr;
#ifdef VMS
  char *(*vmslib_strerror) (int,...);

  /* Override any possibly-conflicting declaration from system header.  */
  vmslib_strerror = (char *(*) (int,...)) strerror;
  /* Second argument matters iff first is EVMSERR, but it's simpler to
     pass it unconditionally.  `vaxc$errno' is declared in <errno.h>
     and maintained by the run-time library in parallel to `errno'.
     We assume that `errnum' corresponds to the last value assigned to
     errno by the run-time library, hence vaxc$errno will be relevant.  */
  errstr = (*vmslib_strerror) (errnum, vaxc$errno);
#else
  errstr = strerror (errnum);
#endif

  /* If `errnum' is out of range, result might be NULL.  We'll fix that.  */
  if (!errstr)
    {
      sprintf (xstrerror_buf, ERRSTR_FMT, errnum);
      errstr = xstrerror_buf;
    }
  return errstr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* xstrndup ( const char *  ,
size_t   
)

Definition at line 48 of file xstrndup.c.

{
  char *result;
  size_t len = strlen (s);

  if (n < len)
    len = n;

  result = XNEWVEC (char, len + 1);

  result[len] = '\0';
  return (char *) memcpy (result, s, len);
}

Here is the call graph for this function:


Variable Documentation

Definition at line 75 of file hex.c.

Definition at line 133 of file concat.c.

Definition at line 65 of file alloca.c.

Definition at line 64 of file alloca.c.

Definition at line 63 of file alloca.c.