1 /*
2  * src/include/utils/cash.h
3  *
4  *
5  * cash.h
6  * Written by D'Arcy J.M. Cain
7  *
8  * Functions to allow input and output of money normally but store
9  *	and handle it as 64 bit integer.
10  */
11 
12 #ifndef CASH_H
13 #define CASH_H
14 
15 #include "fmgr.h"
16 
17 typedef int64 Cash;
18 
19 /* Cash is pass-by-reference if and only if int64 is */
20 #define DatumGetCash(X)		((Cash) DatumGetInt64(X))
21 #define CashGetDatum(X)		Int64GetDatum(X)
22 #define PG_GETARG_CASH(n)	DatumGetCash(PG_GETARG_DATUM(n))
23 #define PG_RETURN_CASH(x)	return CashGetDatum(x)
24 
25 extern Datum cash_in(PG_FUNCTION_ARGS);
26 extern Datum cash_out(PG_FUNCTION_ARGS);
27 extern Datum cash_recv(PG_FUNCTION_ARGS);
28 extern Datum cash_send(PG_FUNCTION_ARGS);
29 
30 extern Datum cash_eq(PG_FUNCTION_ARGS);
31 extern Datum cash_ne(PG_FUNCTION_ARGS);
32 extern Datum cash_lt(PG_FUNCTION_ARGS);
33 extern Datum cash_le(PG_FUNCTION_ARGS);
34 extern Datum cash_gt(PG_FUNCTION_ARGS);
35 extern Datum cash_ge(PG_FUNCTION_ARGS);
36 extern Datum cash_cmp(PG_FUNCTION_ARGS);
37 
38 extern Datum cash_pl(PG_FUNCTION_ARGS);
39 extern Datum cash_mi(PG_FUNCTION_ARGS);
40 extern Datum cash_div_cash(PG_FUNCTION_ARGS);
41 
42 extern Datum cash_mul_flt8(PG_FUNCTION_ARGS);
43 extern Datum flt8_mul_cash(PG_FUNCTION_ARGS);
44 extern Datum cash_div_flt8(PG_FUNCTION_ARGS);
45 
46 extern Datum cash_mul_flt4(PG_FUNCTION_ARGS);
47 extern Datum flt4_mul_cash(PG_FUNCTION_ARGS);
48 extern Datum cash_div_flt4(PG_FUNCTION_ARGS);
49 
50 extern Datum cash_mul_int8(PG_FUNCTION_ARGS);
51 extern Datum int8_mul_cash(PG_FUNCTION_ARGS);
52 extern Datum cash_div_int8(PG_FUNCTION_ARGS);
53 
54 extern Datum cash_mul_int4(PG_FUNCTION_ARGS);
55 extern Datum int4_mul_cash(PG_FUNCTION_ARGS);
56 extern Datum cash_div_int4(PG_FUNCTION_ARGS);
57 
58 extern Datum cash_mul_int2(PG_FUNCTION_ARGS);
59 extern Datum int2_mul_cash(PG_FUNCTION_ARGS);
60 extern Datum cash_div_int2(PG_FUNCTION_ARGS);
61 
62 extern Datum cashlarger(PG_FUNCTION_ARGS);
63 extern Datum cashsmaller(PG_FUNCTION_ARGS);
64 
65 extern Datum cash_words(PG_FUNCTION_ARGS);
66 
67 extern Datum cash_numeric(PG_FUNCTION_ARGS);
68 extern Datum numeric_cash(PG_FUNCTION_ARGS);
69 
70 extern Datum int4_cash(PG_FUNCTION_ARGS);
71 extern Datum int8_cash(PG_FUNCTION_ARGS);
72 
73 #endif   /* CASH_H */
74