-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrpdllutil.pas
811 lines (748 loc) · 19.2 KB
/
rpdllutil.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
{*******************************************************}
{ }
{ Report Manager }
{ }
{ rpdllutil }
{ Exported functions for the Standarc C Library }
{ }
{ Copyright (c) 1994-2019 Toni Martir }
{ }
{ This file is under the MPL license }
{ If you enhace this file you must provide }
{ source code }
{ }
{ }
{*******************************************************}
unit rpdllutil;
{$I rpconf.inc}
interface
uses SysUtils,Classes,rpreport,rpmdconsts,rppdfdriver,
{$IFDEF USEVARIANTS}
Variants,
{$ENDIF}
rptypes,rpeval,rptypeval,rpdatainfo,rppdfreport,
rpparams,rpcsvdriver,rptextdriver,
{$IFDEF MSWINDOWS}
rpexceldriver,Comobj,
rpgdidriver,
Graphics,
Printers,rpvgraphutils,
{$ENDIF}
rphtmldriver,
rpsvgdriver;
var
lreports:TStringList;
lasthandle:integer;
rplasterror:String;
function rp_new:integer;stdcall;
function rp_open(filename:PAnsiChar):integer;stdcall;
function rp_openw(filename:PWideChar):integer;stdcall;
function rp_execute(hreport:integer;outputfilename:PAnsiChar;metafile,
compressed:integer):integer;stdcall;
function rp_executeW(hreport:integer;outputfilename:PWideChar;metafile,
compressed:integer):integer;stdcall;
function rp_executeremote(hostname:PAnsiChar;port:integer;user,password,aliasname,reportname:PAnsiChar;outputfilename:PAnsiChar;metafile,
compressed:integer):integer;stdcall;
function rp_executeremotew(hostname:PWideChar;port:integer;user,password,aliasname,reportname:PWideChar;outputfilename:PWideChar;metafile,
compressed:integer):integer;stdcall;
function rp_executeremote_report(hreport:integer;hostname:PAnsiChar;port:integer;user,password,aliasname,reportname:PAnsiChar;outputfilename:PAnsiChar;metafile,
compressed:integer):integer;stdcall;
function rp_executeremote_reportW(hreport:integer;hostname:PWideChar;port:integer;user,password,aliasname,reportname:PWideChar;outputfilename:PWideChar;metafile,
compressed:integer):integer;stdcall;
function rp_getremoteparams(hreport:integer;hostname:PAnsiChar;port:integer;user,password,aliasname,reportname:PAnsiChar):integer;stdcall;
function rp_getremoteparamsw(hreport:integer;hostname:PWideChar;port:integer;user,password,aliasname,reportname:PWideChar):integer;stdcall;
function rp_close(hreport:integer):integer;stdcall;
function rp_lasterror:PAnsiChar;stdcall;
function rp_lasterrorw:PWideChar;stdcall;
function rp_setparamvalue(hreport:integer;paramname:pansichar;paramtype:integer;
paramvalue:Pointer):integer;stdcall;
function rp_setparamvaluew(hreport:integer;paramname:pWidechar;paramtype:integer;
paramvalue:Pointer):integer;stdcall;
function rp_getparamcount(hreport:integer;var paramcount:Integer):integer;stdcall;
function rp_getparamname(hreport:integer;index:integer;
abuffer:PAnsiChar):integer;stdcall;
function rp_getparamnameW(hreport:integer;index:integer;
abuffer:PWideChar):integer;stdcall;
{$IFDEF MSWINDOWS}
function rp_setparamvaluevar(hreport:integer;paramname:pAnsichar;
paramvalue:OleVariant):integer;stdcall;
function rp_setparamvaluevarw(hreport:integer;paramname:pWidechar;
paramvalue:OleVariant):integer;stdcall;
function rp_setadoconnectionstring(hreport:integer;conname:pAnsichar;
constring:PAnsiChar):integer;stdcall;
function rp_setadoconnectionstringw(hreport:integer;conname:pWidechar;
constring:PWideChar):integer;stdcall;
function rp_getdefaultprinter:pAnsichar;stdcall;
function rp_getdefaultprinterw:pWidechar;stdcall;
function rp_getprinters:pAnsichar;stdcall;
function rp_getprintersw:pWidechar;stdcall;
function rp_setdefaultprinter(device:pAnsichar):integer;stdcall;
function rp_setdefaultprinterw(device:pWidechar):integer;stdcall;
{$ENDIF}
function FindReportIndex(hreport:integer):integer;
function FindReport(hreport:integer):TRpReport;
procedure rplibdoinit;
{$IFDEF LINUX}
procedure DLLHandler(Reason: Integer);
{$ENDIF}
implementation
procedure rplibdoinit;
var
found:boolean;
aclass:TPersistentClass;
begin
if Assigned(lreports) then
exit;
lreports:=TStringList.Create;
lreports.sorted:=True;
lasthandle:=1;
rplasterror:='';
aclass:=GetClass('TRpReport');
found:=true;
if aclass=nil then
found:=false;
if found then
begin
rpreport.RegisterRpReportClasses;
rptypeval.DefaultDecimals:=2;
end;
end;
function FindReportIndex(hreport:integer):integer;
var
index:integer;
begin
rplibdoinit;
index:=lreports.IndexOf(IntToStr(hreport));
if index<0 then
Raise Exception.Create(SRpSInvReportHandle+' - '+IntTostr(hreport));
Result:=index;
end;
function FindReport(hreport:integer):TRpReport;
var
index:integer;
begin
rplibdoinit;
index:=FindReportIndex(hreport);
Result:=TRpReport(lreports.Objects[index]);
end;
function rp_open(filename:PAnsiChar):integer;
begin
Result:=rp_openw(PWideChar(WideString(filename)));
end;
function rp_openw(filename:PWideChar):integer;
var
report:TRpReport;
begin
rplibdoinit;
rplasterror:='';
try
report:=TRpReport.Create(nil);
try
report.LoadFromFile(filename);
inc(lasthandle);
Result:=lasthandle;
lreports.AddObject(IntToStr(lasthandle),report);
except
on E:Exception do
begin
report.free;
raise;
end;
end;
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
function rp_new:integer;
var
report:TRpReport;
begin
rplibdoinit;
rplasterror:='';
try
report:=TRpReport.Create(nil);
try
inc(lasthandle);
Result:=lasthandle;
lreports.AddObject(IntToStr(lasthandle),report);
except
on E:Exception do
begin
report.free;
raise;
end;
end;
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
function rp_execute(hreport:integer;outputfilename:PAnsiChar;metafile,compressed:integer):integer;
begin
Result:=rp_executew(hreport,PWideChar(WideString(outputfilename)),metafile,compressed);
end;
function rp_executew(hreport:integer;outputfilename:PWideChar;metafile,compressed:integer):integer;
var
report:TRpReport;
acompressed:boolean;
adriver:TRpPdfDriver;
{$IFDEF MSWINDOWS}
mono:boolean;
horzres,vertres:integer;
abitmap:TBitmap;
{$ENDIF}
begin
rplibdoinit;
rplasterror:='';
Result:=1;
try
if compressed=0 then
acompressed:=false
else
acompressed:=true;
report:=FindReport(hreport);
case metafile of
0:
begin
rppdfdriver.PrintReportPDF(report,'',false,true,1,99999,1,
StrPas(outputfilename),acompressed,false);
end;
1:
begin
rppdfdriver.PrintReportToMetafile(report,'',false,true,1,99999,1,
StrPas(outputfilename),false);
end;
2:
begin
report.TwoPass:=true;
adriver:=TRpPdfDriver.Create;
try
report.PrintAll(adriver);
ExportMetafileToCSV(report.metafile,StrPas(outputfilename),true,true,
1,9999,',');
finally
adriver.free;
end;
end;
3,10:
begin
report.TwoPass:=true;
adriver:=TRpPdfDriver.Create;
try
if (metafile=10) then
begin
ExportReportToHtmlSingle(report,StrPas(outputfilename));
end
else
begin
report.PrintAll(adriver);
ExportMetafileToHtml(report.Metafile,'',StrPas(outputfilename),
true,true,1,9999);
end
finally
adriver.free;
end;
end;
4:
begin
report.TwoPass:=true;
adriver:=TRpPdfDriver.Create;
try
report.PrintAll(adriver);
ExportMetafileToSVG(report.Metafile,'',StrPas(outputfilename),
true,true,1,9999);
finally
adriver.free;
end;
end;
5:
begin
{$IFDEF MSWINDOWS}
report.TwoPass:=true;
adriver:=TRpPdfDriver.Create;
try
report.PrintAll(adriver);
horzres:=100;
vertres:=100;
mono:=true;
if AskBitmapProps(horzres,vertres,mono) then
begin
abitmap:=MetafileToBitmap(report.Metafile,true,mono,horzres,vertres);
try
if assigned(abitmap) then
abitmap.SaveToFile(StrPas(outputfilename));
finally
abitmap.free;
end;
end;
finally
adriver.free;
end;
{$ENDIF}
{$IFDEF LINUX}
raise Exception.Create(SRpError+'-'+SRpParameter+':'+'metafile'+
' function:rp_execute, bitmap output not supported, use rp_bitmap instead ');
{$ENDIF}
end;
6:
begin
report.TwoPass:=true;
adriver:=TRpPdfDriver.Create;
try
report.PrintAll(adriver);
SaveMetafileToTextFile(report.Metafile,StrPas(outputfilename));
finally
adriver.free;
end;
end;
7:
begin
report.TwoPass:=true;
adriver:=TRpPdfDriver.Create;
try
report.PrintAll(adriver);
ExportMetafileToTextPro(report.metafile,StrPas(outputfilename),true,true,
1,9999);
finally
adriver.free;
end;
end;
8,9:
begin
{$IFDEF MSWINDOWS}
report.TwoPass:=true;
adriver:=TRpPdfDriver.Create;
try
report.PrintAll(adriver);
ExportMetafileToExcel(report.Metafile,StrPas(outputfilename),
true,false,true,1,9999,metafile=9);
finally
adriver.free;
end;
{$ENDIF}
{$IFDEF LINUX}
raise Exception.Create(SRpError+'-'+SRpParameter+':'+'metafile'+
' function:rp_execute, excel output not supported ');
{$ENDIF}
end;
else
raise Exception.Create(SRpError+'-'+SRpParameter+':'+'metafile'+
' function:rp_execute ');
end;
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
function rp_getremoteparams(hreport:integer;hostname:PAnsiChar;port:integer;user,password,aliasname,reportname:PAnsiChar):integer;stdcall;
begin
Result:=rp_getremoteparamsw(hreport,PWideChar(WideString(hostname)),port,PWideChar(WideString(user)),pWidechar(WideString(password)),pWidechar(WideString(aliasname)),pWidechar(WideString(reportname)));
end;
function rp_getremoteparamsw(hreport:integer;hostname:PWideChar;port:integer;user,password,aliasname,reportname:PWideChar):integer;stdcall;
var
pdfreport:TPDFReport;
report:TRpReport;
begin
rplibdoinit;
rplasterror:='';
Result:=1;
try
report:=FindReport(hreport);
pdfreport:=TPDFReport.Create(nil);
try
pdfreport.GetRemoteParams(hostname,port,user,password,aliasname,reportname);
report.params.Assign(pdfreport.Report.Params);
finally
pdfreport.free;
end;
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
function rp_executeremote_report(hreport:integer;hostname:PAnsiChar;port:integer;user,password,aliasname,reportname:PAnsiChar;outputfilename:PAnsiChar;metafile,
compressed:integer):integer;
begin
rp_executeremote_reportw(hreport,PWideChar(WideString(hostname)),port,PWideChar(WideString(user)),PWidechar(WideString(password)),PWidechar(WideString(aliasname)),PWidechar(WideString(reportname)),
PWideChar(WideString(outputfilename)),metafile,compressed);
end;
function rp_executeremote_reportw(hreport:integer;hostname:PWideChar;port:integer;user,password,aliasname,reportname:PWideChar;outputfilename:PWideChar;metafile,
compressed:integer):integer;
var
pdfreport:TPDFReport;
report:TRpReport;
memstream:TMemoryStream;
begin
rplibdoinit;
rplasterror:='';
Result:=1;
try
report:=FindReport(hreport);
pdfreport:=TPDFReport.Create(nil);
try
memstream:=TMemoryStream.Create;
try
report.SaveToStream(memstream);
memstream.Seek(0,soFromBeginning);
pdfreport.LoadFromStream(memstream);
finally
memstream.free;
end;
pdfreport.PDFFilename:=outputfilename;
pdfreport.Compressed:=(compressed<>0);
pdfreport.AsMetafile:=(metafile<>0);
pdfreport.ExecuteRemote(hostname,port,user,password,aliasname,reportname);
finally
pdfreport.free;
end;
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
function rp_executeremote(hostname:PAnsiChar;port:integer;user,password,aliasname,reportname:PAnsiChar;outputfilename:PAnsiChar;metafile,
compressed:integer):integer;
begin
Result:= rp_executeremotew(PWidechar(WideString(hostname)),port,PWidechar(WideString(user)),PWidechar(WideString(password)),pWidechar(WideString(aliasname)),PWidechar(WideString(reportname)),
pWidechar(WideString(outputfilename)),metafile,compressed);
end;
function rp_executeremotew(hostname:PWideChar;port:integer;user,password,aliasname,reportname:PWideChar;outputfilename:PWideChar;metafile,
compressed:integer):integer;
var
pdfreport:TPDFReport;
begin
rplibdoinit;
rplasterror:='';
Result:=1;
try
pdfreport:=TPDFReport.Create(nil);
try
pdfreport.PDFFilename:=outputfilename;
pdfreport.Compressed:=(compressed<>0);
pdfreport.AsMetafile:=(metafile<>0);
pdfreport.ExecuteRemote(hostname,port,user,password,aliasname,reportname);
finally
pdfreport.free;
end;
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
function rp_close(hreport:integer):integer;
var
index:integer;
begin
rplibdoinit;
rplasterror:='';
Result:=1;
try
index:=FindReportIndex(hreport);
TRpReport(lreports.Objects[index]).free;
lreports.delete(index);
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
{$IFDEF MSWINDOWS}
function rp_setdefaultprinter(device:pAnsichar):integer;
begin
Result:=rp_setdefaultprinterw(PWideChar(WideString(device)));
end;
function rp_setdefaultprinterw(device:pWidechar):integer;
var
adevice:string;
i:integer;
itemindex:integer;
printerlist:string;
begin
rplibdoinit;
rplasterror:='';
Result:=1;
try
adevice:=UpperCase(device);
itemindex:=-1;
printerlist:='';
for i:=0 to printer.printers.count-1 do
begin
if UpperCase(printer.printers.strings[i])=adevice then
begin
itemindex:=i;
break;
end;
printerlist:=printerlist+printer.printers.strings[i]+#10;
end;
if itemindex<0 then
Raise Exception.Create(SRpErrorOpenImp+':'+device+#10+printerlist);
SwitchToPrinterIndex(itemindex);
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
function rp_getprinters:pAnsichar;
begin
Result:=PAnsiChar(AnsiString(rp_getprintersw));
end;
function rp_getprintersw:pWidechar;
var
i:integer;
aresult:String;
begin
rplibdoinit;
rplasterror:='';
try
aresult:='';
for i:=0 to printer.printers.count-1 do
begin
if i>0 then
aResult:=aResult+#10;
aResult:=aResult+printer.printers[i];
end;
Result:=PWidechar(aresult);
except
on E:Exception do
begin
Result:=PWideChar(E.Message);
end;
end;
end;
function rp_getdefaultprinter:pAnsichar;
begin
Result:=PAnsiChar(AnsiString(rp_getdefaultprinterw));
end;
function rp_getdefaultprinterw:pWidechar;
var
aresult:String;
begin
rplibdoinit;
rplasterror:='';
try
aResult:='';
if printer.printerindex>0 then
aResult:=printer.printers[printer.printerindex];
Result:=PWidechar(aresult);
except
on E:Exception do
begin
Result:=PWideChar(E.Message);
end;
end;
end;
{$ENDIF}
function rp_setparamvalue(hreport:integer;paramname:pAnsichar;paramtype:integer;
paramvalue:Pointer):integer;
begin
Result:=rp_setparamvaluew(hreport,PWidechar(WideString(paramname)),paramtype,paramvalue);
end;
function rp_setparamvaluew(hreport:integer;paramname:pWidechar;paramtype:integer;
paramvalue:Pointer):integer;
var
report:TRpReport;
aparam:TRpParam;
begin
rplibdoinit;
rplasterror:='';
Result:=1;
try
report:=FindReport(hreport);
aparam:=report.params.ParamByName(Strpas(paramname));
case paramtype of
1:
aparam.Value:=Null;
3:
aparam.Value:=integer(paramvalue^);
5:
aparam.Value:=double(paramvalue^);
6:
aparam.Value:=Currency(paramvalue^);
7:
aparam.Value:=TDateTime(paramvalue^);
8:
aparam.Value:=WideCharToString(PWideChar(paramvalue));
11:
aparam.Value:=Boolean(paramvalue^);
14:
{$IFDEF USEVARIANTS}
aparam.Value:=Int64(paramvalue^);
{$ENDIF}
{$IFNDEF USEVARIANTS}
aparam.Value:=Integer(paramvalue^);
{$ENDIF}
256:
aparam.Value:=StrPas(PChar(paramvalue));
else
Raise Exception.Create(SRpEvalType+' - '+IntToStr(paramtype));
end;
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
function rp_getparamname(hreport:integer;index:integer;abuffer:PAnsiChar):integer;
begin
Result:=rp_getparamnamew(hreport,index,PWidechar(WideString(abuffer)));
end;
function rp_getparamnamew(hreport:integer;index:integer;abuffer:PWideChar):integer;
var
report:TRpReport;
aparam:TRpParam;
begin
rplibdoinit;
rplasterror:='';
Result:=1;
try
report:=FindReport(hreport);
aparam:=report.params.items[index];
StrPCopy(abuffer,aparam.Name);
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
function rp_getparamcount(hreport:integer;var paramcount:Integer):integer;
var
report:TRpReport;
begin
rplibdoinit;
rplasterror:='';
Result:=1;
try
report:=FindReport(hreport);
paramcount:=report.Params.Count;
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
{$IFDEF MSWINDOWS}
function rp_setparamvaluevar(hreport:integer;paramname:pAnsichar;
paramvalue:OleVariant):integer;
begin
Result:=rp_setparamvaluevarw(hreport,PWideChar(WideString(paramname)),paramvalue);
end;
function rp_setparamvaluevarw(hreport:integer;paramname:pWidechar;
paramvalue:OleVariant):integer;
var
report:TRpReport;
aparam:TRpParam;
begin
rplibdoinit;
rplasterror:='';
Result:=1;
try
report:=FindReport(hreport);
aparam:=report.params.ParamByName(Strpas(paramname));
aparam.Value:=paramvalue;
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
function rp_setadoconnectionstring(hreport:integer;conname:pAnsichar;
constring:PAnsiChar):integer;
begin
Result:=rp_setadoconnectionstringw(hreport,PWideChar(WideString(conname)),PWideChar(WideString(constring)));
end;
function rp_setadoconnectionstringw(hreport:integer;conname:pWidechar;
constring:PWideChar):integer;
var
report:TRpReport;
dbinfo:TRpDatabaseInfoItem;
index:Integer;
begin
rplibdoinit;
rplasterror:='';
Result:=1;
try
report:=FindReport(hreport);
index:=report.DatabaseInfo.IndexOf(StrPas(conname));
if index<0 then
Raise Exception.Create(SRPDabaseAliasNotFound+' - '+StrPas(conname));
dbinfo:=report.DatabaseInfo.Items[index];
dbinfo.ADOConnectionString:=StrPas(constring);
except
on E:Exception do
begin
rplasterror:=E.Message;
Result:=0;
end;
end;
end;
{$ENDIF}
function rp_lasterror:PAnsiChar;
begin
rplibdoinit;
Result:=PAnsiChar(AnsiString(rplasterror));
end;
function rp_lasterrorw:PWideChar;
begin
rplibdoinit;
Result:=PWideChar(rplasterror);
end;
procedure FreeAllReports;
var
i:integer;
begin
for i:=0 to lreports.count-1 do
begin
TRpReport(lreports.Objects[i]).free;
end;
lreports.clear;
end;
{$IFDEF LINUX}
procedure DLLHandler(Reason: Integer);
begin
// 0 means unloading, 1 means loading.
if Reason = 0 then
// Now we want to remove our signal handler.
UnhookSignal(RTL_SIGDEFAULT);
end;
{$ENDIF}
initialization
lreports:=nil;
rplibdoinit;
finalization
FreeAllReports;
lreports.free;
lreports:=nil;
end.