]> granicus.if.org Git - postgresql/blobdiff - src/include/utils/cash.h
Update copyright for 2014
[postgresql] / src / include / utils / cash.h
index 2cfb29313a302937bc6371cd8507f9915d476ca2..3a491f9231a8cf2678c7385635f6465b027249b7 100644 (file)
@@ -1,35 +1,73 @@
 /*
+ * src/include/utils/cash.h
+ *
+ *
  * cash.h
  * Written by D'Arcy J.M. Cain
  *
  * Functions to allow input and output of money normally but store
- *  and handle it as long integers.
+ *     and handle it as 64 bit integer.
  */
 
 #ifndef CASH_H
 #define CASH_H
 
-typedef long int Cash;
+#include "fmgr.h"
+
+typedef int64 Cash;
+
+/* Cash is pass-by-reference if and only if int64 is */
+#define DatumGetCash(X)                ((Cash) DatumGetInt64(X))
+#define CashGetDatum(X)                Int64GetDatum(X)
+#define PG_GETARG_CASH(n)      DatumGetCash(PG_GETARG_DATUM(n))
+#define PG_RETURN_CASH(x)      return CashGetDatum(x)
+
+extern Datum cash_in(PG_FUNCTION_ARGS);
+extern Datum cash_out(PG_FUNCTION_ARGS);
+extern Datum cash_recv(PG_FUNCTION_ARGS);
+extern Datum cash_send(PG_FUNCTION_ARGS);
+
+extern Datum cash_eq(PG_FUNCTION_ARGS);
+extern Datum cash_ne(PG_FUNCTION_ARGS);
+extern Datum cash_lt(PG_FUNCTION_ARGS);
+extern Datum cash_le(PG_FUNCTION_ARGS);
+extern Datum cash_gt(PG_FUNCTION_ARGS);
+extern Datum cash_ge(PG_FUNCTION_ARGS);
+extern Datum cash_cmp(PG_FUNCTION_ARGS);
+
+extern Datum cash_pl(PG_FUNCTION_ARGS);
+extern Datum cash_mi(PG_FUNCTION_ARGS);
+extern Datum cash_div_cash(PG_FUNCTION_ARGS);
+
+extern Datum cash_mul_flt8(PG_FUNCTION_ARGS);
+extern Datum flt8_mul_cash(PG_FUNCTION_ARGS);
+extern Datum cash_div_flt8(PG_FUNCTION_ARGS);
+
+extern Datum cash_mul_flt4(PG_FUNCTION_ARGS);
+extern Datum flt4_mul_cash(PG_FUNCTION_ARGS);
+extern Datum cash_div_flt4(PG_FUNCTION_ARGS);
+
+extern Datum cash_mul_int8(PG_FUNCTION_ARGS);
+extern Datum int8_mul_cash(PG_FUNCTION_ARGS);
+extern Datum cash_div_int8(PG_FUNCTION_ARGS);
+
+extern Datum cash_mul_int4(PG_FUNCTION_ARGS);
+extern Datum int4_mul_cash(PG_FUNCTION_ARGS);
+extern Datum cash_div_int4(PG_FUNCTION_ARGS);
 
-const char *cash_out(Cash *value);
-Cash *cash_in(const char *str);
+extern Datum cash_mul_int2(PG_FUNCTION_ARGS);
+extern Datum int2_mul_cash(PG_FUNCTION_ARGS);
+extern Datum cash_div_int2(PG_FUNCTION_ARGS);
 
-bool cash_eq(Cash *c1, Cash *c2);
-bool cash_ne(Cash *c1, Cash *c2);
-bool cash_lt(Cash *c1, Cash *c2);
-bool cash_le(Cash *c1, Cash *c2);
-bool cash_gt(Cash *c1, Cash *c2);
-bool cash_ge(Cash *c1, Cash *c2);
+extern Datum cashlarger(PG_FUNCTION_ARGS);
+extern Datum cashsmaller(PG_FUNCTION_ARGS);
 
-Cash *cash_pl(Cash *c1, Cash *c2);
-Cash *cash_mi(Cash *c1, Cash *c2);
-Cash *cash_mul(Cash *c, float8 *f);
-Cash *cash_div(Cash *c, float8 *f);
+extern Datum cash_words(PG_FUNCTION_ARGS);
 
-Cash *cashlarger(Cash *c1, Cash *c2);
-Cash *cashsmaller(Cash *c1, Cash *c2);
+extern Datum cash_numeric(PG_FUNCTION_ARGS);
+extern Datum numeric_cash(PG_FUNCTION_ARGS);
 
-const char *cash_words_out(Cash *value);
-static const char *num_word(Cash value);
+extern Datum int4_cash(PG_FUNCTION_ARGS);
+extern Datum int8_cash(PG_FUNCTION_ARGS);
 
-#endif /* CASH_H */
+#endif   /* CASH_H */