175 |
|
function IsLibraryLoaded: boolean; |
176 |
|
function IsEmbeddedServer: boolean; virtual; abstract; |
177 |
|
function GetLibraryName: string; |
178 |
< |
function GetCharsetName(CharSetID: integer): AnsiString; |
179 |
< |
function CharSetID2CodePage(CharSetID: integer; var CodePage: TSystemCodePage): boolean; |
180 |
< |
function CodePage2CharSetID(CodePage: TSystemCodePage; var CharSetID: integer): boolean; |
181 |
< |
function CharSetName2CharSetID(CharSetName: AnsiString; var CharSetID: integer): boolean; |
182 |
< |
function CharSetWidth(CharSetID: integer; var Width: integer): boolean; |
183 |
< |
end; |
178 |
> |
end; |
179 |
|
|
180 |
|
var FirebirdClientAPI: TFBClientAPI = nil; |
181 |
|
|
197 |
|
{$I 'include/wloadlibrary.inc'} |
198 |
|
{$ENDIF} |
199 |
|
|
205 |
– |
type |
206 |
– |
TCharsetMap = record |
207 |
– |
CharsetID: integer; |
208 |
– |
CharSetName: AnsiString; |
209 |
– |
CharSetWidth: integer; |
210 |
– |
CodePage: TSystemCodePage; |
211 |
– |
end; |
212 |
– |
|
213 |
– |
const |
214 |
– |
CharSetMap: array [0..69] of TCharsetMap = ( |
215 |
– |
(CharsetID: 0; CharSetName: 'NONE'; CharSetWidth: 1; CodePage: CP_ACP), |
216 |
– |
(CharsetID: 1; CharSetName: 'OCTETS'; CharSetWidth: 1; CodePage: CP_NONE), |
217 |
– |
(CharsetID: 2; CharSetName: 'ASCII'; CharSetWidth: 1; CodePage: CP_ASCII), |
218 |
– |
(CharsetID: 3; CharSetName: 'UNICODE_FSS'; CharSetWidth: 3; CodePage: CP_UTF8), |
219 |
– |
(CharsetID: 4; CharSetName: 'UTF8'; CharSetWidth: 4; CodePage: CP_UTF8), |
220 |
– |
(CharsetID: 5; CharSetName: 'SJIS_0208'; CharSetWidth: 2; CodePage: 20932), |
221 |
– |
(CharsetID: 6; CharSetName: 'EUCJ_0208'; CharSetWidth: 2; CodePage: 20932), |
222 |
– |
(CharsetID: 7; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
223 |
– |
(CharsetID: 8; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
224 |
– |
(CharsetID: 9; CharSetName: 'DOS737'; CharSetWidth: 1; CodePage: 737), |
225 |
– |
(CharsetID: 10; CharSetName: 'DOS437'; CharSetWidth: 1; CodePage: 437), |
226 |
– |
(CharsetID: 11; CharSetName: 'DOS850'; CharSetWidth: 1; CodePage: 850), |
227 |
– |
(CharsetID: 12; CharSetName: 'DOS865'; CharSetWidth: 1; CodePage: 865), |
228 |
– |
(CharsetID: 13; CharSetName: 'DOS860'; CharSetWidth: 1; CodePage: 860), |
229 |
– |
(CharsetID: 14; CharSetName: 'DOS863'; CharSetWidth: 1; CodePage: 863), |
230 |
– |
(CharsetID: 15; CharSetName: 'DOS775'; CharSetWidth: 1; CodePage: 775), |
231 |
– |
(CharsetID: 16; CharSetName: 'DOS858'; CharSetWidth: 1; CodePage: 858), |
232 |
– |
(CharsetID: 17; CharSetName: 'DOS862'; CharSetWidth: 1; CodePage: 862), |
233 |
– |
(CharsetID: 18; CharSetName: 'DOS864'; CharSetWidth: 1; CodePage: 864), |
234 |
– |
(CharsetID: 19; CharSetName: 'NEXT'; CharSetWidth: 1; CodePage: CP_NONE), |
235 |
– |
(CharsetID: 20; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
236 |
– |
(CharsetID: 21; CharSetName: 'ISO8859_1'; CharSetWidth: 1; CodePage: 28591), |
237 |
– |
(CharsetID: 22; CharSetName: 'ISO8859_2'; CharSetWidth: 1; CodePage: 28592), |
238 |
– |
(CharsetID: 23; CharSetName: 'ISO8859_3'; CharSetWidth: 1; CodePage: 28593), |
239 |
– |
(CharsetID: 24; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
240 |
– |
(CharsetID: 25; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
241 |
– |
(CharsetID: 26; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
242 |
– |
(CharsetID: 27; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
243 |
– |
(CharsetID: 28; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
244 |
– |
(CharsetID: 29; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
245 |
– |
(CharsetID: 30; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
246 |
– |
(CharsetID: 31; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
247 |
– |
(CharsetID: 32; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
248 |
– |
(CharsetID: 33; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
249 |
– |
(CharsetID: 34; CharSetName: 'ISO8859_4'; CharSetWidth: 1; CodePage: 28594), |
250 |
– |
(CharsetID: 35; CharSetName: 'ISO8859_5'; CharSetWidth: 1; CodePage: 28595), |
251 |
– |
(CharsetID: 36; CharSetName: 'ISO8859_6'; CharSetWidth: 1; CodePage: 28596), |
252 |
– |
(CharsetID: 37; CharSetName: 'ISO8859_7'; CharSetWidth: 1; CodePage: 28597), |
253 |
– |
(CharsetID: 38; CharSetName: 'ISO8859_8'; CharSetWidth: 1; CodePage: 28598), |
254 |
– |
(CharsetID: 39; CharSetName: 'ISO8859_9'; CharSetWidth: 1; CodePage: 28599), |
255 |
– |
(CharsetID: 40; CharSetName: 'ISO8859_13'; CharSetWidth: 1; CodePage: 28603), |
256 |
– |
(CharsetID: 41; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
257 |
– |
(CharsetID: 42; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
258 |
– |
(CharsetID: 43; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
259 |
– |
(CharsetID: 44; CharSetName: 'KSC_5601'; CharSetWidth: 2; CodePage: 949), |
260 |
– |
(CharsetID: 45; CharSetName: 'DOS852'; CharSetWidth: 1; CodePage: 852), |
261 |
– |
(CharsetID: 46; CharSetName: 'DOS857'; CharSetWidth: 1; CodePage: 857), |
262 |
– |
(CharsetID: 47; CharSetName: 'DOS861'; CharSetWidth: 1; CodePage: 861), |
263 |
– |
(CharsetID: 48; CharSetName: 'DOS866'; CharSetWidth: 1; CodePage: 866), |
264 |
– |
(CharsetID: 49; CharSetName: 'DOS869'; CharSetWidth: 1; CodePage: 869), |
265 |
– |
(CharsetID: 50; CharSetName: 'CYRL'; CharSetWidth: 1; CodePage: 1251), |
266 |
– |
(CharsetID: 51; CharSetName: 'WIN1250'; CharSetWidth: 1; CodePage: 1250), |
267 |
– |
(CharsetID: 52; CharSetName: 'WIN1251'; CharSetWidth: 1; CodePage: 1251), |
268 |
– |
(CharsetID: 53; CharSetName: 'WIN1252'; CharSetWidth: 1; CodePage: 1252), |
269 |
– |
(CharsetID: 54; CharSetName: 'WIN1253'; CharSetWidth: 1; CodePage: 1253), |
270 |
– |
(CharsetID: 55; CharSetName: 'WIN1254'; CharSetWidth: 1; CodePage: 1254), |
271 |
– |
(CharsetID: 56; CharSetName: 'BIG_5'; CharSetWidth: 2; CodePage: 950), |
272 |
– |
(CharsetID: 57; CharSetName: 'GB_2312'; CharSetWidth: 2; CodePage: 936), |
273 |
– |
(CharsetID: 58; CharSetName: 'WIN1255'; CharSetWidth: 1; CodePage: 1255), |
274 |
– |
(CharsetID: 59; CharSetName: 'WIN1256'; CharSetWidth: 1; CodePage: 1256), |
275 |
– |
(CharsetID: 60; CharSetName: 'WIN1257'; CharSetWidth: 1; CodePage: 1257), |
276 |
– |
(CharsetID: 61; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
277 |
– |
(CharsetID: 62; CharSetName: 'Unknown'; CharSetWidth: 0; CodePage: CP_NONE), |
278 |
– |
(CharsetID: 63; CharSetName: 'KOI8R'; CharSetWidth: 1; CodePage: 20866), |
279 |
– |
(CharsetID: 64; CharSetName: 'KOI8U'; CharSetWidth: 1; CodePage: 21866), |
280 |
– |
(CharsetID: 65; CharSetName: 'WIN1258'; CharSetWidth: 1; CodePage: 1258), |
281 |
– |
(CharsetID: 66; CharSetName: 'TIS620'; CharSetWidth: 1; CodePage: 874), |
282 |
– |
(CharsetID: 67; CharSetName: 'GBK'; CharSetWidth: 2; CodePage: 936), |
283 |
– |
(CharsetID: 68; CharSetName: 'CP943C'; CharSetWidth: 2; CodePage: 943), |
284 |
– |
(CharsetID: 69; CharSetName: 'GB18030'; CharSetWidth: 4; CodePage: 54936) |
285 |
– |
); |
286 |
– |
|
200 |
|
{$IFDEF Unix} |
201 |
|
{SetEnvironmentVariable doesn't exist so we have to use C Library} |
202 |
|
function setenv(name:Pchar; value:Pchar; replace:integer):integer;cdecl;external clib name 'setenv'; |
327 |
|
Result := FFBLibraryName; |
328 |
|
end; |
329 |
|
|
417 |
– |
function TFBClientAPI.GetCharsetName(CharSetID: integer): AnsiString; |
418 |
– |
begin |
419 |
– |
Result := ''; |
420 |
– |
if (CharSetID >= Low(CharSetMap)) and (CharSetID <= High(CharSetMap)) and |
421 |
– |
(CharSetMap[CharSetID].CharSetID = CharSetID) then |
422 |
– |
begin |
423 |
– |
Result := CharSetMap[CharSetID].CharSetName; |
424 |
– |
Exit; |
425 |
– |
end; |
426 |
– |
end; |
427 |
– |
|
428 |
– |
function TFBClientAPI.CharSetID2CodePage(CharSetID: integer; |
429 |
– |
var CodePage: TSystemCodePage): boolean; |
430 |
– |
begin |
431 |
– |
Result := (CharSetID >= Low(CharSetMap)) and (CharSetID <= High(CharSetMap)) |
432 |
– |
and (CharSetMap[CharSetID].CharSetID = CharSetID); |
433 |
– |
if Result then |
434 |
– |
begin |
435 |
– |
CodePage := CharSetMap[CharSetID].CodePage; |
436 |
– |
Result := true; |
437 |
– |
Exit; |
438 |
– |
end; |
439 |
– |
end; |
440 |
– |
|
441 |
– |
function TFBClientAPI.CodePage2CharSetID(CodePage: TSystemCodePage; |
442 |
– |
var CharSetID: integer): boolean; |
443 |
– |
var i: integer; |
444 |
– |
begin |
445 |
– |
Result := false; |
446 |
– |
for i := Low(CharSetMap) to High(CharSetMap) do |
447 |
– |
if CharSetMap[i].CodePage = CodePage then |
448 |
– |
begin |
449 |
– |
CharSetID := CharSetMap[i].CharSetID; |
450 |
– |
Result := true; |
451 |
– |
Exit; |
452 |
– |
end; |
453 |
– |
end; |
454 |
– |
|
455 |
– |
function TFBClientAPI.CharSetName2CharSetID(CharSetName: AnsiString; |
456 |
– |
var CharSetID: integer): boolean; |
457 |
– |
var i: integer; |
458 |
– |
begin |
459 |
– |
Result := false; |
460 |
– |
for i := Low(CharSetMap) to High(CharSetMap) do |
461 |
– |
if AnsiCompareStr(CharSetMap[i].CharSetName, CharSetName) = 0 then |
462 |
– |
begin |
463 |
– |
CharSetID := CharSetMap[i].CharSetID; |
464 |
– |
Result := true; |
465 |
– |
Exit; |
466 |
– |
end; |
467 |
– |
end; |
468 |
– |
|
469 |
– |
function TFBClientAPI.CharSetWidth(CharSetID: integer; var Width: integer |
470 |
– |
): boolean; |
471 |
– |
begin |
472 |
– |
Result := (CharSetID >= Low(CharSetMap)) and (CharSetID <= High(CharSetMap)) |
473 |
– |
and (CharSetMap[CharSetID].CharSetID = CharSetID); |
474 |
– |
if Result then |
475 |
– |
begin |
476 |
– |
Width := CharSetMap[CharSetID].CharSetWidth; |
477 |
– |
Result := true; |
478 |
– |
Exit; |
479 |
– |
end; |
480 |
– |
end; |
481 |
– |
|
330 |
|
const |
331 |
|
IBLocalBufferLength = 512; |
332 |
|
IBBigLocalBufferLength = IBLocalBufferLength * 2; |
442 |
|
LeaveCriticalSection(TFBClientAPI.FIBCS); |
443 |
|
end; |
444 |
|
end; |
445 |
+ |
|
446 |
|
initialization |
447 |
|
TFBClientAPI.IBLibrary := NilHandle; |
448 |
|
{$IFNDEF FPC} |