Fix heap use after free in CPDFSDK_Annot::GetPDFAnnot.
[pdfium.git] / fpdfsdk / src / fpdfview_c_api_test.c
1 // Copyright 2015 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This "C" (not "C++") file ensures that the public headers compile
6 // and link for "C" (and not just "C++").
7
8 #include <stdio.h>
9
10 #include "fpdfview_c_api_test.h"
11
12 #include "../../public/fpdf_dataavail.h"
13 #include "../../public/fpdf_doc.h"
14 #include "../../public/fpdf_edit.h"
15 #include "../../public/fpdf_ext.h"
16 #include "../../public/fpdf_flatten.h"
17 #include "../../public/fpdf_formfill.h"
18 #include "../../public/fpdf_fwlevent.h"
19 #include "../../public/fpdf_ppo.h"
20 #include "../../public/fpdf_progressive.h"
21 #include "../../public/fpdf_save.h"
22 #include "../../public/fpdf_searchex.h"
23 #include "../../public/fpdf_sysfontinfo.h"
24 #include "../../public/fpdf_text.h"
25 #include "../../public/fpdf_transformpage.h"
26 #include "../../public/fpdfview.h"
27
28 // Scheme for avoiding LTO out of existence, warnings, etc.
29 typedef void (*fnptr)(void);  // Legal generic function type for casts.
30 fnptr g_c_api_test_fnptr = NULL;  // Extern, so can't know it doesn't change.
31 #define CHK(x) if ((fnptr)(x) == g_c_api_test_fnptr) return 0
32
33 // Function to call from gtest harness to ensure linker resolution.
34 int CheckPDFiumCApi() {
35     // fpdf_dataavail.h
36     CHK(FPDFAvail_Create);
37     CHK(FPDFAvail_Destroy);
38     CHK(FPDFAvail_IsDocAvail);
39     CHK(FPDFAvail_GetDocument);
40     CHK(FPDFAvail_GetFirstPageNum);
41     CHK(FPDFAvail_IsPageAvail);
42     CHK(FPDFAvail_IsFormAvail);
43     CHK(FPDFAvail_IsLinearized);
44
45     // fpdf_doc.h
46     CHK(FPDFBookmark_GetFirstChild);
47     CHK(FPDFBookmark_GetNextSibling);
48     CHK(FPDFBookmark_GetTitle);
49     CHK(FPDFBookmark_Find);
50     CHK(FPDFBookmark_GetDest);
51     CHK(FPDFBookmark_GetAction);
52     CHK(FPDFAction_GetType);
53     CHK(FPDFAction_GetDest);
54     CHK(FPDFAction_GetURIPath);
55     CHK(FPDFDest_GetPageIndex);
56     CHK(FPDFLink_GetLinkAtPoint);
57     CHK(FPDFLink_GetLinkZOrderAtPoint);
58     CHK(FPDFLink_GetDest);
59     CHK(FPDFLink_GetAction);
60     CHK(FPDFLink_Enumerate);
61     CHK(FPDFLink_GetAnnotRect);
62     CHK(FPDFLink_CountQuadPoints);
63     CHK(FPDFLink_GetQuadPoints);
64     CHK(FPDF_GetMetaText);
65
66     // fpdf_edit.h
67     CHK(FPDF_CreateNewDocument);
68     CHK(FPDFPage_New);
69     CHK(FPDFPage_Delete);
70     CHK(FPDFPage_GetRotation);
71     CHK(FPDFPage_SetRotation);
72     CHK(FPDFPage_InsertObject);
73     CHK(FPDFPage_CountObject);
74     CHK(FPDFPage_GetObject);
75     CHK(FPDFPage_HasTransparency);
76     CHK(FPDFPage_GenerateContent);
77     CHK(FPDFPageObj_HasTransparency);
78     CHK(FPDFPageObj_Transform);
79     CHK(FPDFPage_TransformAnnots);
80     CHK(FPDFPageObj_NewImgeObj);
81     CHK(FPDFImageObj_LoadJpegFile);
82     CHK(FPDFImageObj_SetMatrix);
83     CHK(FPDFImageObj_SetBitmap);
84
85     // fpdf_ext.h
86     CHK(FSDK_SetUnSpObjProcessHandler);
87     CHK(FPDFDoc_GetPageMode);
88
89     // fpdf_flatten.h
90     CHK(FPDFPage_Flatten);
91
92     // fpdf_fwlevent.h - no exports.
93
94     // fpdf_formfill.h
95     CHK(FPDFDOC_InitFormFillEnvironment);
96     CHK(FPDFDOC_ExitFormFillEnvironment);
97     CHK(FORM_OnAfterLoadPage);
98     CHK(FORM_OnBeforeClosePage);
99     CHK(FORM_DoDocumentJSAction);
100     CHK(FORM_DoDocumentOpenAction);
101     CHK(FORM_DoDocumentAAction);
102     CHK(FORM_DoPageAAction);
103     CHK(FORM_OnMouseMove);
104     CHK(FORM_OnLButtonDown);
105     CHK(FORM_OnLButtonUp);
106     CHK(FORM_OnKeyDown);
107     CHK(FORM_OnKeyUp);
108     CHK(FORM_OnChar);
109     CHK(FORM_ForceToKillFocus);
110     CHK(FPDFPage_HasFormFieldAtPoint);
111     CHK(FPDPage_HasFormFieldAtPoint);  // DEPRECATED. Remove in the future.
112     CHK(FPDFPage_FormFieldZOrderAtPoint);
113     CHK(FPDF_SetFormFieldHighlightColor);
114     CHK(FPDF_SetFormFieldHighlightAlpha);
115     CHK(FPDF_RemoveFormFieldHighlight);
116     CHK(FPDF_FFLDraw);
117
118     // fpdf_ppo.h
119     CHK(FPDF_ImportPages);
120     CHK(FPDF_CopyViewerPreferences);
121
122     // fpdf_progressive.h
123     CHK(FPDF_RenderPageBitmap_Start);
124     CHK(FPDF_RenderPage_Continue);
125     CHK(FPDF_RenderPage_Close);
126
127     // fpdf_save.h
128     CHK(FPDF_SaveAsCopy);
129     CHK(FPDF_SaveWithVersion);
130
131     // fpdf_searchex.h
132     CHK(FPDFText_GetCharIndexFromTextIndex);
133
134     // fpdf_sysfontinfo.h
135     CHK(FPDF_GetDefaultTTFMap);
136     CHK(FPDF_AddInstalledFont);
137     CHK(FPDF_SetSystemFontInfo);
138     CHK(FPDF_GetDefaultSystemFontInfo);
139
140     // fpdf_text.h
141     CHK(FPDFText_LoadPage);
142     CHK(FPDFText_ClosePage);
143     CHK(FPDFText_CountChars);
144     CHK(FPDFText_GetUnicode);
145     CHK(FPDFText_GetFontSize);
146     CHK(FPDFText_GetCharBox);
147     CHK(FPDFText_GetCharIndexAtPos);
148     CHK(FPDFText_GetText);
149     CHK(FPDFText_CountRects);
150     CHK(FPDFText_GetRect);
151     CHK(FPDFText_GetBoundedText);
152     CHK(FPDFText_FindStart);
153     CHK(FPDFText_FindNext);
154     CHK(FPDFText_FindPrev);
155     CHK(FPDFText_GetSchResultIndex);
156     CHK(FPDFText_GetSchCount);
157     CHK(FPDFText_FindClose);
158     CHK(FPDFLink_LoadWebLinks);
159     CHK(FPDFLink_CountWebLinks);
160     CHK(FPDFLink_GetURL);
161     CHK(FPDFLink_CountRects);
162     CHK(FPDFLink_GetRect);
163     CHK(FPDFLink_CloseWebLinks);
164
165     // fpdf_transformpage.h
166     CHK(FPDFPage_SetMediaBox);
167     CHK(FPDFPage_SetCropBox);
168     CHK(FPDFPage_GetMediaBox);
169     CHK(FPDFPage_GetCropBox);
170     CHK(FPDFPage_TransFormWithClip);
171     CHK(FPDFPageObj_TransformClipPath);
172     CHK(FPDF_CreateClipPath);
173     CHK(FPDF_DestroyClipPath);
174     CHK(FPDFPage_InsertClipPath);
175
176     // fpdfview.h
177     CHK(FPDF_InitLibrary);
178     CHK(FPDF_InitLibraryWithConfig);
179     CHK(FPDF_DestroyLibrary);
180     CHK(FPDF_SetSandBoxPolicy);
181     CHK(FPDF_LoadDocument);
182     CHK(FPDF_LoadMemDocument);
183     CHK(FPDF_LoadCustomDocument);
184     CHK(FPDF_GetFileVersion);
185     CHK(FPDF_GetLastError);
186     CHK(FPDF_GetDocPermissions);
187     CHK(FPDF_GetSecurityHandlerRevision);
188     CHK(FPDF_GetPageCount);
189     CHK(FPDF_LoadPage);
190     CHK(FPDF_GetPageWidth);
191     CHK(FPDF_GetPageHeight);
192     CHK(FPDF_GetPageSizeByIndex);
193     CHK(FPDF_RenderPageBitmap);
194     CHK(FPDF_ClosePage);
195     CHK(FPDF_CloseDocument);
196     CHK(FPDF_DeviceToPage);
197     CHK(FPDF_PageToDevice);
198     CHK(FPDFBitmap_Create);
199     CHK(FPDFBitmap_CreateEx);
200     CHK(FPDFBitmap_FillRect);
201     CHK(FPDFBitmap_GetBuffer);
202     CHK(FPDFBitmap_GetWidth);
203     CHK(FPDFBitmap_GetHeight);
204     CHK(FPDFBitmap_GetStride);
205     CHK(FPDFBitmap_Destroy);
206     CHK(FPDF_VIEWERREF_GetPrintScaling);
207     CHK(FPDF_VIEWERREF_GetNumCopies);
208     CHK(FPDF_VIEWERREF_GetPrintPageRange);
209     CHK(FPDF_VIEWERREF_GetDuplex);
210     CHK(FPDF_CountNamedDests);
211     CHK(FPDF_GetNamedDestByName);
212     CHK(FPDF_GetNamedDest);
213
214     return 1;
215 }
216
217 #undef CHK