Header And Logo

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

Defines | Typedefs | Functions

isn.h File Reference

#include "fmgr.h"
Include dependency graph for isn.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ISN_WEAK_MODE
#define EAN13_FORMAT   UINT64_FORMAT
#define PG_GETARG_EAN13(n)   PG_GETARG_INT64(n)
#define PG_RETURN_EAN13(x)   PG_RETURN_INT64(x)

Typedefs

typedef uint64 ean13

Functions

Datum isn_out (PG_FUNCTION_ARGS)
Datum ean13_out (PG_FUNCTION_ARGS)
Datum ean13_in (PG_FUNCTION_ARGS)
Datum isbn_in (PG_FUNCTION_ARGS)
Datum ismn_in (PG_FUNCTION_ARGS)
Datum issn_in (PG_FUNCTION_ARGS)
Datum upc_in (PG_FUNCTION_ARGS)
Datum isbn_cast_from_ean13 (PG_FUNCTION_ARGS)
Datum ismn_cast_from_ean13 (PG_FUNCTION_ARGS)
Datum issn_cast_from_ean13 (PG_FUNCTION_ARGS)
Datum upc_cast_from_ean13 (PG_FUNCTION_ARGS)
Datum is_valid (PG_FUNCTION_ARGS)
Datum make_valid (PG_FUNCTION_ARGS)
Datum accept_weak_input (PG_FUNCTION_ARGS)
Datum weak_input_status (PG_FUNCTION_ARGS)
void initialize (void)

Define Documentation

#define EAN13_FORMAT   UINT64_FORMAT

Definition at line 28 of file isn.h.

Referenced by ean2isn(), and ean2string().

#define ISN_WEAK_MODE

Definition at line 21 of file isn.h.

#define PG_GETARG_EAN13 (   n  )     PG_GETARG_INT64(n)
#define PG_RETURN_EAN13 (   x  )     PG_RETURN_INT64(x)

Typedef Documentation

typedef uint64 ean13

Definition at line 26 of file isn.h.


Function Documentation

Datum accept_weak_input ( PG_FUNCTION_ARGS   ) 

Definition at line 1113 of file isn.c.

References g_weak, PG_GETARG_BOOL, and PG_RETURN_BOOL.

{
#ifdef ISN_WEAK_MODE
    g_weak = PG_GETARG_BOOL(0);
#else
    /* function has no effect */
#endif   /* ISN_WEAK_MODE */
    PG_RETURN_BOOL(g_weak);
}

Datum ean13_in ( PG_FUNCTION_ARGS   ) 

Definition at line 972 of file isn.c.

References EAN13, PG_GETARG_CSTRING, PG_RETURN_EAN13, and string2ean().

{
    const char *str = PG_GETARG_CSTRING(0);
    ean13       result;

    (void) string2ean(str, false, &result, EAN13);
    PG_RETURN_EAN13(result);
}

Datum ean13_out ( PG_FUNCTION_ARGS   ) 

Definition at line 956 of file isn.c.

References buf, ean2string(), MAXEAN13LEN, PG_GETARG_EAN13, PG_RETURN_CSTRING, pstrdup(), and val.

{
    ean13       val = PG_GETARG_EAN13(0);
    char       *result;
    char        buf[MAXEAN13LEN + 1];

    (void) ean2string(val, false, buf, false);

    result = pstrdup(buf);
    PG_RETURN_CSTRING(result);
}

void initialize ( void   ) 

Definition at line 919 of file isn.c.

References EAN13, EAN13_index, elog, g_initialized, ISBN, ISBN_index, ISMN, ISMN_index, ISSN, ISSN_index, LOG, UPC, and UPC_index.

Referenced by longest(), and shortest().

{
#ifdef ISN_DEBUG
    if (!check_table(EAN13, EAN13_index))
        elog(LOG, "EAN13 failed check");
    if (!check_table(ISBN, ISBN_index))
        elog(LOG, "ISBN failed check");
    if (!check_table(ISMN, ISMN_index))
        elog(LOG, "ISMN failed check");
    if (!check_table(ISSN, ISSN_index))
        elog(LOG, "ISSN failed check");
    if (!check_table(UPC, UPC_index))
        elog(LOG, "UPC failed check");
#endif
    g_initialized = true;
}

Datum is_valid ( PG_FUNCTION_ARGS   ) 

Definition at line 1088 of file isn.c.

References PG_GETARG_EAN13, PG_RETURN_BOOL, and val.

{
    ean13       val = PG_GETARG_EAN13(0);

    PG_RETURN_BOOL((val & 1) == 0);
}

Datum isbn_cast_from_ean13 ( PG_FUNCTION_ARGS   ) 

Definition at line 1037 of file isn.c.

References ean2isn(), ISBN, PG_GETARG_EAN13, PG_RETURN_EAN13, and val.

{
    ean13       val = PG_GETARG_EAN13(0);
    ean13       result;

    (void) ean2isn(val, false, &result, ISBN);

    PG_RETURN_EAN13(result);
}

Datum isbn_in ( PG_FUNCTION_ARGS   ) 

Definition at line 985 of file isn.c.

References ISBN, PG_GETARG_CSTRING, PG_RETURN_EAN13, and string2ean().

{
    const char *str = PG_GETARG_CSTRING(0);
    ean13       result;

    (void) string2ean(str, false, &result, ISBN);
    PG_RETURN_EAN13(result);
}

Datum ismn_cast_from_ean13 ( PG_FUNCTION_ARGS   ) 

Definition at line 1049 of file isn.c.

References ean2isn(), ISMN, PG_GETARG_EAN13, PG_RETURN_EAN13, and val.

{
    ean13       val = PG_GETARG_EAN13(0);
    ean13       result;

    (void) ean2isn(val, false, &result, ISMN);

    PG_RETURN_EAN13(result);
}

Datum ismn_in ( PG_FUNCTION_ARGS   ) 

Definition at line 998 of file isn.c.

References ISMN, PG_GETARG_CSTRING, PG_RETURN_EAN13, and string2ean().

{
    const char *str = PG_GETARG_CSTRING(0);
    ean13       result;

    (void) string2ean(str, false, &result, ISMN);
    PG_RETURN_EAN13(result);
}

Datum isn_out ( PG_FUNCTION_ARGS   ) 

Definition at line 940 of file isn.c.

References buf, ean2string(), MAXEAN13LEN, PG_GETARG_EAN13, PG_RETURN_CSTRING, pstrdup(), and val.

{
    ean13       val = PG_GETARG_EAN13(0);
    char       *result;
    char        buf[MAXEAN13LEN + 1];

    (void) ean2string(val, false, buf, true);

    result = pstrdup(buf);
    PG_RETURN_CSTRING(result);
}

Datum issn_cast_from_ean13 ( PG_FUNCTION_ARGS   ) 

Definition at line 1061 of file isn.c.

References ean2isn(), ISSN, PG_GETARG_EAN13, PG_RETURN_EAN13, and val.

{
    ean13       val = PG_GETARG_EAN13(0);
    ean13       result;

    (void) ean2isn(val, false, &result, ISSN);

    PG_RETURN_EAN13(result);
}

Datum issn_in ( PG_FUNCTION_ARGS   ) 

Definition at line 1011 of file isn.c.

References ISSN, PG_GETARG_CSTRING, PG_RETURN_EAN13, and string2ean().

{
    const char *str = PG_GETARG_CSTRING(0);
    ean13       result;

    (void) string2ean(str, false, &result, ISSN);
    PG_RETURN_EAN13(result);
}

Datum make_valid ( PG_FUNCTION_ARGS   ) 

Definition at line 1099 of file isn.c.

References PG_GETARG_EAN13, PG_RETURN_EAN13, and val.

{
    ean13       val = PG_GETARG_EAN13(0);

    val &= ~((ean13) 1);
    PG_RETURN_EAN13(val);
}

Datum upc_cast_from_ean13 ( PG_FUNCTION_ARGS   ) 

Definition at line 1073 of file isn.c.

References ean2isn(), PG_GETARG_EAN13, PG_RETURN_EAN13, UPC, and val.

{
    ean13       val = PG_GETARG_EAN13(0);
    ean13       result;

    (void) ean2isn(val, false, &result, UPC);

    PG_RETURN_EAN13(result);
}

Datum upc_in ( PG_FUNCTION_ARGS   ) 

Definition at line 1024 of file isn.c.

References PG_GETARG_CSTRING, PG_RETURN_EAN13, string2ean(), and UPC.

{
    const char *str = PG_GETARG_CSTRING(0);
    ean13       result;

    (void) string2ean(str, false, &result, UPC);
    PG_RETURN_EAN13(result);
}

Datum weak_input_status ( PG_FUNCTION_ARGS   ) 

Definition at line 1125 of file isn.c.

References g_weak, and PG_RETURN_BOOL.