Header And Logo

PostgreSQL
| The world's most advanced open source database.

Defines | Functions

private.h File Reference

#include <limits.h>
#include <sys/wait.h>
#include <unistd.h>
#include "pgtime.h"
Include dependency graph for private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define GRANDPARENTED   "Local time zone must be set--see zic manual page"
#define WIFEXITED(status)   (((status) & 0xff) == 0)
#define WEXITSTATUS(status)   (((status) >> 8) & 0xff)
#define is_digit(c)   ((unsigned)(c) - '0' <= 9)
#define remove   unlink
#define TRUE   1
#define FALSE   0
#define TYPE_BIT(type)   (sizeof (type) * CHAR_BIT)
#define TYPE_SIGNED(type)   (((type) -1) < 0)
#define TYPE_INTEGRAL(type)   (((type) 0.5) != 0.5)
#define INT_STRLEN_MAXIMUM(type)   ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
#define _(msgid)   (msgid)
#define YEARSPERREPEAT   400
#define AVGSECSPERYEAR   31556952L
#define SECSPERREPEAT   ((int64) YEARSPERREPEAT * (int64) AVGSECSPERYEAR)
#define SECSPERREPEAT_BITS   34

Functions

int unlink (const char *filename)
char * icalloc (int nelem, int elsize)
char * icatalloc (char *old, const char *new)
char * icpyalloc (const char *string)
char * imalloc (int n)
void * irealloc (void *pointer, int size)
void icfree (char *pointer)
void ifree (char *pointer)
const char * scheck (const char *string, const char *format)

Define Documentation

#define _ (   msgid  )     (msgid)

Definition at line 102 of file private.h.

#define AVGSECSPERYEAR   31556952L

Definition at line 113 of file private.h.

#define FALSE   0

Definition at line 70 of file private.h.

#define GRANDPARENTED   "Local time zone must be set--see zic manual page"

Definition at line 26 of file private.h.

Referenced by newabbr(), and writezone().

#define INT_STRLEN_MAXIMUM (   type  )     ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))

Definition at line 97 of file private.h.

Referenced by _conv().

#define is_digit (   c  )     ((unsigned)(c) - '0' <= 9)

Definition at line 36 of file private.h.

Referenced by getnum(), getrule(), getzname(), and scheck().

#define remove   unlink

Definition at line 45 of file private.h.

#define SECSPERREPEAT   ((int64) YEARSPERREPEAT * (int64) AVGSECSPERYEAR)

Definition at line 117 of file private.h.

#define SECSPERREPEAT_BITS   34

Definition at line 121 of file private.h.

Referenced by differ_by_repeat().

#define TRUE   1

Definition at line 66 of file private.h.

#define TYPE_BIT (   type  )     (sizeof (type) * CHAR_BIT)

Definition at line 74 of file private.h.

Referenced by differ_by_repeat(), and main().

#define TYPE_INTEGRAL (   type  )     (((type) 0.5) != 0.5)

Definition at line 87 of file private.h.

Referenced by differ_by_repeat(), and tzload().

#define TYPE_SIGNED (   type  )     (((type) -1) < 0)

Definition at line 78 of file private.h.

Referenced by differ_by_repeat(), and tzload().

#define WEXITSTATUS (   status  )     (((status) >> 8) & 0xff)

Definition at line 32 of file private.h.

#define WIFEXITED (   status  )     (((status) & 0xff) == 0)

Definition at line 29 of file private.h.

#define YEARSPERREPEAT   400

Definition at line 105 of file private.h.

Referenced by localsub(), outzone(), and pg_next_dst_boundary().


Function Documentation

char* icalloc ( int  nelem,
int  elsize 
)

Definition at line 23 of file ialloc.c.

References calloc.

{
    if (nelem == 0 || elsize == 0)
        nelem = elsize = 1;
    return calloc((size_t) nelem, (size_t) elsize);
}

char* icatalloc ( char *  old,
const char *  new 
)

Definition at line 39 of file ialloc.c.

References irealloc(), and NULL.

Referenced by icpyalloc().

{
    char       *result;
    int         oldsize,
                newsize;

    newsize = (new == NULL) ? 0 : strlen(new);
    if (old == NULL)
        oldsize = 0;
    else if (newsize == 0)
        return old;
    else
        oldsize = strlen(old);
    if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
        if (new != NULL)
            (void) strcpy(result + oldsize, new);
    return result;
}

void icfree ( char *  pointer  ) 

Definition at line 72 of file ialloc.c.

References free, and NULL.

{
    if (p != NULL)
        (void) free(p);
}

char* icpyalloc ( const char *  string  ) 

Definition at line 59 of file ialloc.c.

References icatalloc(), and NULL.

{
    return icatalloc((char *) NULL, string);
}

void ifree ( char *  pointer  ) 

Definition at line 65 of file ialloc.c.

References free, and NULL.

Referenced by dolink(), infile(), itsdir(), mkdirs(), newabbr(), outzone(), rulesub(), scheck(), and warning().

{
    if (p != NULL)
        (void) free(p);
}

char* imalloc ( int  n  ) 

Definition at line 17 of file ialloc.c.

References malloc, and nonzero.

Referenced by irealloc(), and scheck().

{
    return malloc((size_t) nonzero(n));
}

void* irealloc ( void *  pointer,
int  size 
)

Definition at line 31 of file ialloc.c.

References imalloc(), nonzero, NULL, and realloc.

Referenced by icatalloc().

{
    if (pointer == NULL)
        return imalloc(size);
    return realloc((void *) pointer, (size_t) nonzero(size));
}

const char* scheck ( const char *  string,
const char *  format 
)

Definition at line 15 of file scheck.c.

References ifree(), imalloc(), is_digit, and NULL.

Referenced by gethms(), inleap(), and rulesub().

{
    char       *fbuf;
    const char *fp;
    char       *tp;
    int         c;
    const char *result;
    char        dummy;

    result = "";
    if (string == NULL || format == NULL)
        return result;
    fbuf = imalloc((int) (2 * strlen(format) + 4));
    if (fbuf == NULL)
        return result;
    fp = format;
    tp = fbuf;
    while ((*tp++ = c = *fp++) != '\0')
    {
        if (c != '%')
            continue;
        if (*fp == '%')
        {
            *tp++ = *fp++;
            continue;
        }
        *tp++ = '*';
        if (*fp == '*')
            ++fp;
        while (is_digit(*fp))
            *tp++ = *fp++;
        if (*fp == 'l' || *fp == 'h')
            *tp++ = *fp++;
        else if (*fp == '[')
            do
                *tp++ = *fp++;
            while (*fp != '\0' && *fp != ']');
        if ((*tp++ = *fp++) == '\0')
            break;
    }
    *(tp - 1) = '%';
    *tp++ = 'c';
    *tp = '\0';
    if (sscanf(string, fbuf, &dummy) != 1)
        result = (char *) format;
    ifree(fbuf);
    return result;
}

int unlink ( const char *  filename  )