|
7 | 7 | * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group |
8 | 8 | * |
9 | 9 | * IDENTIFICATION |
10 | | - * $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.5 2007/01/0522:19:18 momjian Exp $ |
| 10 | + * $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.6 2007/06/0521:31:03 tgl Exp $ |
11 | 11 | * |
12 | 12 | *------------------------------------------------------------------------- |
13 | 13 | */ |
@@ -39,10 +39,6 @@ static const char *isn_names[] = {"EAN13/UPC/ISxN", "EAN13/UPC/ISxN", "EAN13", " |
39 | 39 | staticboolg_weak= false; |
40 | 40 | staticboolg_initialized= false; |
41 | 41 |
|
42 | | -/* Macros for converting TEXT to and from c-string */ |
43 | | -#defineGET_TEXT(cstrp) DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(cstrp))) |
44 | | -#defineGET_STR(textp) DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp))) |
45 | | - |
46 | 42 |
|
47 | 43 | /*********************************************************************** |
48 | 44 | ** |
@@ -1042,30 +1038,6 @@ upc_in(PG_FUNCTION_ARGS) |
1042 | 1038 |
|
1043 | 1039 | /* casting functions |
1044 | 1040 | */ |
1045 | | -PG_FUNCTION_INFO_V1(ean13_cast_to_text); |
1046 | | -Datum |
1047 | | -ean13_cast_to_text(PG_FUNCTION_ARGS) |
1048 | | -{ |
1049 | | -ean13val=PG_GETARG_EAN13(0); |
1050 | | -charbuf[MAXEAN13LEN+1]; |
1051 | | - |
1052 | | -(void)ean2string(val, false,buf, false); |
1053 | | - |
1054 | | -PG_RETURN_TEXT_P(GET_TEXT(buf)); |
1055 | | -} |
1056 | | - |
1057 | | -PG_FUNCTION_INFO_V1(isn_cast_to_text); |
1058 | | -Datum |
1059 | | -isn_cast_to_text(PG_FUNCTION_ARGS) |
1060 | | -{ |
1061 | | -ean13val=PG_GETARG_EAN13(0); |
1062 | | -charbuf[MAXEAN13LEN+1]; |
1063 | | - |
1064 | | -(void)ean2string(val, false,buf, true); |
1065 | | - |
1066 | | -PG_RETURN_TEXT_P(GET_TEXT(buf)); |
1067 | | -} |
1068 | | - |
1069 | 1041 | PG_FUNCTION_INFO_V1(isbn_cast_from_ean13); |
1070 | 1042 | Datum |
1071 | 1043 | isbn_cast_from_ean13(PG_FUNCTION_ARGS) |
@@ -1115,61 +1087,6 @@ upc_cast_from_ean13(PG_FUNCTION_ARGS) |
1115 | 1087 | } |
1116 | 1088 |
|
1117 | 1089 |
|
1118 | | -PG_FUNCTION_INFO_V1(ean13_cast_from_text); |
1119 | | -Datum |
1120 | | -ean13_cast_from_text(PG_FUNCTION_ARGS) |
1121 | | -{ |
1122 | | -constchar*str=GET_STR(PG_GETARG_TEXT_P(0)); |
1123 | | -ean13result; |
1124 | | - |
1125 | | -(void)string2ean(str, false,&result,EAN13); |
1126 | | -PG_RETURN_EAN13(result); |
1127 | | -} |
1128 | | - |
1129 | | -PG_FUNCTION_INFO_V1(isbn_cast_from_text); |
1130 | | -Datum |
1131 | | -isbn_cast_from_text(PG_FUNCTION_ARGS) |
1132 | | -{ |
1133 | | -constchar*str=GET_STR(PG_GETARG_TEXT_P(0)); |
1134 | | -ean13result; |
1135 | | - |
1136 | | -(void)string2ean(str, false,&result,ISBN); |
1137 | | -PG_RETURN_EAN13(result); |
1138 | | -} |
1139 | | - |
1140 | | -PG_FUNCTION_INFO_V1(ismn_cast_from_text); |
1141 | | -Datum |
1142 | | -ismn_cast_from_text(PG_FUNCTION_ARGS) |
1143 | | -{ |
1144 | | -constchar*str=GET_STR(PG_GETARG_TEXT_P(0)); |
1145 | | -ean13result; |
1146 | | - |
1147 | | -(void)string2ean(str, false,&result,ISMN); |
1148 | | -PG_RETURN_EAN13(result); |
1149 | | -} |
1150 | | - |
1151 | | -PG_FUNCTION_INFO_V1(issn_cast_from_text); |
1152 | | -Datum |
1153 | | -issn_cast_from_text(PG_FUNCTION_ARGS) |
1154 | | -{ |
1155 | | -constchar*str=GET_STR(PG_GETARG_TEXT_P(0)); |
1156 | | -ean13result; |
1157 | | - |
1158 | | -(void)string2ean(str, false,&result,ISSN); |
1159 | | -PG_RETURN_EAN13(result); |
1160 | | -} |
1161 | | - |
1162 | | -PG_FUNCTION_INFO_V1(upc_cast_from_text); |
1163 | | -Datum |
1164 | | -upc_cast_from_text(PG_FUNCTION_ARGS) |
1165 | | -{ |
1166 | | -constchar*str=GET_STR(PG_GETARG_TEXT_P(0)); |
1167 | | -ean13result; |
1168 | | - |
1169 | | -(void)string2ean(str, false,&result,UPC); |
1170 | | -PG_RETURN_EAN13(result); |
1171 | | -} |
1172 | | - |
1173 | 1090 | /* is_valid - returns false if the "invalid-check-digit-on-input" is set |
1174 | 1091 | */ |
1175 | 1092 | PG_FUNCTION_INFO_V1(is_valid); |
|