├── .gitattributes
├── .gitignore
├── LICENSE
├── LICENSE.md
├── Makefile
├── README.md
├── include
├── curl
│ ├── curl.h
│ ├── curlver.h
│ ├── easy.h
│ ├── header.h
│ ├── mprintf.h
│ ├── multi.h
│ ├── options.h
│ ├── stdcheaders.h
│ ├── system.h
│ ├── typecheck-gcc.h
│ ├── urlapi.h
│ └── websockets.h
├── json.hpp
└── sdk
│ ├── amx
│ └── amx.h
│ └── plugin.h
├── lib
├── libcrypto.a
├── libcurl.a
├── libcurl.lib
├── libcurl_debug.lib
├── libssl.a
└── sdk
│ └── src
│ ├── plugin.cpp
│ └── plugin.h
├── resource.h
├── samp-chatbot.def
├── samp-chatbot.inc
├── samp-chatbot.make
├── samp-chatbot.rc
├── samp-chatbot.sln
├── samp-chatbot.vcxproj
├── samp-chatbot.vcxproj.filters
└── src
├── ChatBotHelper.cpp
├── ChatBotHelper.h
├── EncodingHelper.hpp
├── SampHelper.h
└── main.cpp
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | .vscode/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # DNX
46 | project.lock.json
47 | artifacts/
48 |
49 | *_i.c
50 | *_p.c
51 | *_i.h
52 | *.ilk
53 | *.meta
54 | *.obj
55 | *.pch
56 | *.pdb
57 | *.pgc
58 | *.pgd
59 | *.rsp
60 | *.sbr
61 | *.tlb
62 | *.tli
63 | *.tlh
64 | *.tmp
65 | *.tmp_proj
66 | *.log
67 | *.vspscc
68 | *.vssscc
69 | .builds
70 | *.pidb
71 | *.svclog
72 | *.scc
73 |
74 | # Chutzpah Test files
75 | _Chutzpah*
76 |
77 | # Visual C++ cache files
78 | ipch/
79 | *.aps
80 | *.ncb
81 | *.opendb
82 | *.opensdf
83 | *.sdf
84 | *.cachefile
85 |
86 | # Visual Studio profiler
87 | *.psess
88 | *.vsp
89 | *.vspx
90 | *.sap
91 |
92 | # TFS 2012 Local Workspace
93 | $tf/
94 |
95 | # Guidance Automation Toolkit
96 | *.gpState
97 |
98 | # ReSharper is a .NET coding add-in
99 | _ReSharper*/
100 | *.[Rr]e[Ss]harper
101 | *.DotSettings.user
102 |
103 | # JustCode is a .NET coding add-in
104 | .JustCode
105 |
106 | # TeamCity is a build add-in
107 | _TeamCity*
108 |
109 | # DotCover is a Code Coverage Tool
110 | *.dotCover
111 |
112 | # NCrunch
113 | _NCrunch_*
114 | .*crunch*.local.xml
115 | nCrunchTemp_*
116 |
117 | # MightyMoose
118 | *.mm.*
119 | AutoTest.Net/
120 |
121 | # Web workbench (sass)
122 | .sass-cache/
123 |
124 | # Installshield output folder
125 | [Ee]xpress/
126 |
127 | # DocProject is a documentation generator add-in
128 | DocProject/buildhelp/
129 | DocProject/Help/*.HxT
130 | DocProject/Help/*.HxC
131 | DocProject/Help/*.hhc
132 | DocProject/Help/*.hhk
133 | DocProject/Help/*.hhp
134 | DocProject/Help/Html2
135 | DocProject/Help/html
136 |
137 | # Click-Once directory
138 | publish/
139 |
140 | # Publish Web Output
141 | *.[Pp]ublish.xml
142 | *.azurePubxml
143 | # TODO: Comment the next line if you want to checkin your web deploy settings
144 | # but database connection strings (with potential passwords) will be unencrypted
145 | *.pubxml
146 | *.publishproj
147 |
148 | # NuGet Packages
149 | *.nupkg
150 | # The packages folder can be ignored because of Package Restore
151 | **/packages/*
152 | # except build/, which is used as an MSBuild target.
153 | !**/packages/build/
154 | # Uncomment if necessary however generally it will be regenerated when needed
155 | #!**/packages/repositories.config
156 | # NuGet v3's project.json files produces more ignoreable files
157 | *.nuget.props
158 | *.nuget.targets
159 |
160 | # Microsoft Azure Build Output
161 | csx/
162 | *.build.csdef
163 |
164 | # Microsoft Azure Emulator
165 | ecf/
166 | rcf/
167 |
168 | # Microsoft Azure ApplicationInsights config file
169 | ApplicationInsights.config
170 |
171 | # Windows Store app package directory
172 | AppPackages/
173 | BundleArtifacts/
174 |
175 | # Visual Studio cache files
176 | # files ending in .cache can be ignored
177 | *.[Cc]ache
178 | # but keep track of directories ending in .cache
179 | !*.[Cc]ache/
180 |
181 | # Others
182 | ClientBin/
183 | ~$*
184 | *~
185 | *.dbmdl
186 | *.dbproj.schemaview
187 | *.pfx
188 | *.publishsettings
189 | node_modules/
190 | orleans.codegen.cs
191 |
192 | # RIA/Silverlight projects
193 | Generated_Code/
194 |
195 | # Backup & report files from converting an old project file
196 | # to a newer Visual Studio version. Backup files are not needed,
197 | # because we have git ;-)
198 | _UpgradeReport_Files/
199 | Backup*/
200 | UpgradeLog*.XML
201 | UpgradeLog*.htm
202 |
203 | # SQL Server files
204 | *.mdf
205 | *.ldf
206 |
207 | # Business Intelligence projects
208 | *.rdl.data
209 | *.bim.layout
210 | *.bim_*.settings
211 |
212 | # Microsoft Fakes
213 | FakesAssemblies/
214 |
215 | # GhostDoc plugin setting file
216 | *.GhostDoc.xml
217 |
218 | # Node.js Tools for Visual Studio
219 | .ntvs_analysis.dat
220 |
221 | # Visual Studio 6 build log
222 | *.plg
223 |
224 | # Visual Studio 6 workspace options file
225 | *.opt
226 |
227 | # Visual Studio LightSwitch build output
228 | **/*.HTMLClient/GeneratedArtifacts
229 | **/*.DesktopClient/GeneratedArtifacts
230 | **/*.DesktopClient/ModelManifest.xml
231 | **/*.Server/GeneratedArtifacts
232 | **/*.Server/ModelManifest.xml
233 | _Pvt_Extensions
234 |
235 | # Paket dependency manager
236 | .paket/paket.exe
237 |
238 | # FAKE - F# Make
239 | .fake/
240 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | GTA SAMP plugin for IPC Shared Memory functionality.
635 | Copyright (C) 2022 SimoSbara
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | samp-shared-memory Copyright (C) 2022 SimoSbara
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # GNU Make solution makefile autogenerated by Premake
2 | # Type "make help" for usage help
3 |
4 | ifndef config
5 | config=release
6 | endif
7 | export config
8 |
9 | PROJECTS := samp-chatbot
10 |
11 | .PHONY: all clean help $(PROJECTS)
12 |
13 | all: $(PROJECTS)
14 |
15 | samp-chatbot:
16 | @echo "==== Building samp-chatbot ($(config)) ===="
17 | @${MAKE} --no-print-directory -C . -f samp-chatbot.make
18 |
19 | clean:
20 | @${MAKE} --no-print-directory -C . -f samp-chatbot.make clean
21 |
22 | help:
23 | @echo "Usage: make [config=name] [target]"
24 | @echo ""
25 | @echo "CONFIGURATIONS:"
26 | @echo " debug"
27 | @echo " release"
28 | @echo ""
29 | @echo "TARGETS:"
30 | @echo " all (default)"
31 | @echo " clean"
32 | @echo " samp-chatbot"
33 | @echo ""
34 | @echo "For more information, see http://industriousone.com/premake/quick-start"
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # samp-chatbot
2 |
3 |
4 | ## Description
5 |
6 | A GTA SAMP plugin for Chat Bot communication.
7 |
8 | It works for both [SA-MP](https://www.sa-mp.mp/) and [open.mp](https://www.open.mp/).
9 |
10 | The following Chat Bots API are implemented:
11 | * [Chat GPT](https://platform.openai.com/docs/quickstart)
12 | * [Gemini AI](https://ai.google.dev/)
13 | * [LLAMA](https://groq.com/)
14 | * [Doubao](https://www.doubao.com/)
15 | * [DeepSeek](https://www.deepseek.com/)
16 |
17 | This plugin can permit arbitrary model and system instruction choise using natives in runtime.
18 |
19 | Refer to this [wiki](https://github.com/SimoSbara/samp-chatbot/wiki) for pawn implementation.
20 |
21 | ### Side Note
22 | Before choosing a Chat Bot API remember:
23 | * GPT is not free to use, check [pricing](https://openai.com/api/pricing/);
24 | * Gemini is free to use in [certain countries](https://ai.google.dev/gemini-api/docs/available-regions?hl=it);
25 | * LLAMA is free on [groq.com](https://groq.com/) everywhere and has some premium features (LLAMA hasn't any official API);
26 | * Doubao performs better in Chinese;
27 | * DeepSeek is not free to use, check [pricing](https://api-docs.deepseek.com/quick_start/pricing).
28 |
29 |
30 | ## Example of use
31 | ```
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 |
39 | #define COLOR_RED 0xFF0000FF
40 | #define COLOR_MAGENTA 0xFF00FFFF
41 |
42 | #define CHATBOT_DIALOG 10
43 | #define API_KEY "MY_API_KEY"
44 | #define GLOBAL_REQUEST -1
45 |
46 | #pragma tabsize 0
47 |
48 | new lastResponses[MAX_PLAYERS][1024];
49 | new lastGlobalResponse[1024];
50 |
51 | main()
52 | {
53 | SetChatBotEncoding(W1252);
54 | SelectChatBot(LLAMA);
55 | SetModel("llama3-70b-8192");
56 | SetAPIKey(API_KEY);
57 | SetSystemPrompt("You are an assistant inside GTA SAMP");
58 | }
59 |
60 | CMD:clearmemory(playerid, params[])
61 | {
62 | new id;
63 |
64 | if(sscanf(params, "d", id))
65 | return SendClientMessage(playerid, COLOR_RED, "/clearmemory ");
66 |
67 | ClearMemory(id);
68 |
69 | return 1;
70 | }
71 |
72 | CMD:disablesysprompt(playerid, params[])
73 | {
74 | SetSystemPrompt("");
75 |
76 | return 1;
77 | }
78 |
79 | CMD:sysprompt(playerid, params[])
80 | {
81 | new sysPrompt[512];
82 |
83 | if(sscanf(params, "s[512]", sysPrompt))
84 | return SendClientMessage(playerid, COLOR_RED, "/sysprompt ");
85 |
86 | SetSystemPrompt(sysPrompt);
87 |
88 | return 1;
89 | }
90 |
91 | CMD:bot(playerid, params[])
92 | {
93 | new prompt[512];
94 |
95 | if(sscanf(params, "s[512]", prompt))
96 | return SendClientMessage(playerid, COLOR_RED, "/bot ");
97 |
98 | RequestToChatBot(prompt, playerid);
99 |
100 | return 1;
101 | }
102 |
103 | CMD:botglobal(playerid, params[])
104 | {
105 | new prompt[512];
106 |
107 | if(sscanf(params, "s[512]", prompt))
108 | return SendClientMessage(playerid, COLOR_RED, "/botglobal ");
109 |
110 | RequestToChatBot(prompt, GLOBAL_REQUEST);
111 |
112 | return 1;
113 | }
114 |
115 | CMD:lastresponse(playerid, params[])
116 | {
117 | ShowPlayerDialog(playerid, CHATBOT_DIALOG, DIALOG_STYLE_MSGBOX, "Chat Bot Answer", lastResponses[playerid], "Ok", "");
118 | return 1;
119 | }
120 |
121 | public OnChatBotResponse(prompt[], response[], id)
122 | {
123 | //from a player
124 | if(id >= 0 && id < MAX_PLAYERS)
125 | {
126 | format(lastResponses[id], 1024, "%s", response);
127 |
128 | SendClientMessage(id, COLOR_MAGENTA, "Chat Bot Responded! Check it with /lastresponse.");
129 | }
130 | else if(id == GLOBAL_REQUEST) //global
131 | {
132 | format(lastGlobalResponse, 2048, "%s", response);
133 |
134 | SendClientMessageToAll(COLOR_MAGENTA, "Chat Bot Responded Globally! Check it with /lastglobalresponse.");
135 | }
136 | }
137 | ```
138 | ## Installation
139 | * Download the last [Release](https://github.com/SimoSbara/samp-chatbot/releases).
140 | * Put ```samp-chatbot.inc``` inside ```pawno/include``` folder.
141 |
142 | ### Only Windows
143 | * Put ```samp-chatbot.dll``` inside ```plugins``` folder;
144 | * Put ```libcurl.dll libcrypto-3.dll libss-3.dll``` inside the root server folder.
145 |
146 | ### Only Linux
147 | * Put ```samp-chatbot.so``` inside ```plugins``` folder.
148 |
149 | ## Development
150 |
151 | ### Compilation
152 |
153 | #### Windows
154 | Compiling on Windows is pretty simple, it requires Visual Studio 2022 with the latest C++ Windows SDK, libcurl is already provided.
155 |
156 | #### Linux
157 | In Linux (I only tried on Debian based systems) you need to do ```make clean``` and ```make``` inside the main folder, ```libcurl libssl libcrypto``` are already provided.
158 |
159 | If you want to compile curl and openssl yourself you will need to cross-compile them in 32 bit on 64 bit machine.
160 |
161 | Steps:
162 | * remove libcurl and OpenSSL if it's already install and update with ```ldconfig``` otherwise it will create conflicts!
163 | * install cross-platform multilib: ```sudo apt install gcc-multilib g++-multilib```
164 | * download [OpenSSL 3.3.1](https://github.com/openssl/openssl/releases/tag/openssl-3.3.1) and extract it
165 | * go inside OpenSSL folder and configure on x86: ```setarch i386 ./config -m32```
166 | * compile and install OpenSSL ```make``` and ```sudo make install```
167 | * download [libcurl 8.8.0](https://github.com/curl/curl) and extract it
168 | * configure libcurl by doing: ```./configure --host=i686-pc-linux-gnu --with-openssl CFLAGS=-m32 CC=/usr/bin/gcc```
169 | * compile libcurl ```make``` and install it ```cd lib/``` and ```sudo make install```
170 | * find and copy ```libcurl.a libcrypto.a libssl.a``` inside ```samp-chatbot-root-folder/lib```
171 | * now you should have everything ready for compilation!
172 |
173 | For compiling the samp-chatbot do ```make clean``` and ```make``` inside the main folder, binaries are inside bin/linux/Release.
174 |
175 | ## License
176 | This project is licensed under the GNU General Public License v3.0 - see the LICENSE.md file for details
177 |
178 | ## Acknowledgments
179 | Project structure inspired from:
180 | * [samp-dns-plugin by samp-incognito](https://github.com/samp-incognito/samp-dns-plugin)
181 |
--------------------------------------------------------------------------------
/include/curl/curlver.h:
--------------------------------------------------------------------------------
1 | #ifndef CURLINC_CURLVER_H
2 | #define CURLINC_CURLVER_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at https://curl.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * SPDX-License-Identifier: curl
24 | *
25 | ***************************************************************************/
26 |
27 | /* This header file contains nothing but libcurl version info, generated by
28 | a script at release-time. This was made its own header file in 7.11.2 */
29 |
30 | /* This is the global package copyright */
31 | #define LIBCURL_COPYRIGHT "Daniel Stenberg, ."
32 |
33 | /* This is the version number of the libcurl package from which this header
34 | file origins: */
35 | #define LIBCURL_VERSION "8.8.0"
36 |
37 | /* The numeric version number is also available "in parts" by using these
38 | defines: */
39 | #define LIBCURL_VERSION_MAJOR 8
40 | #define LIBCURL_VERSION_MINOR 8
41 | #define LIBCURL_VERSION_PATCH 0
42 |
43 | /* This is the numeric version of the libcurl version number, meant for easier
44 | parsing and comparisons by programs. The LIBCURL_VERSION_NUM define will
45 | always follow this syntax:
46 |
47 | 0xXXYYZZ
48 |
49 | Where XX, YY and ZZ are the main version, release and patch numbers in
50 | hexadecimal (using 8 bits each). All three numbers are always represented
51 | using two digits. 1.2 would appear as "0x010200" while version 9.11.7
52 | appears as "0x090b07".
53 |
54 | This 6-digit (24 bits) hexadecimal number does not show pre-release number,
55 | and it is always a greater number in a more recent release. It makes
56 | comparisons with greater than and less than work.
57 |
58 | Note: This define is the full hex number and _does not_ use the
59 | CURL_VERSION_BITS() macro since curl's own configure script greps for it
60 | and needs it to contain the full number.
61 | */
62 | #define LIBCURL_VERSION_NUM 0x080800
63 |
64 | /*
65 | * This is the date and time when the full source package was created. The
66 | * timestamp is not stored in git, as the timestamp is properly set in the
67 | * tarballs by the maketgz script.
68 | *
69 | * The format of the date follows this template:
70 | *
71 | * "2007-11-23"
72 | */
73 | #define LIBCURL_TIMESTAMP "2024-05-22"
74 |
75 | #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
76 | #define CURL_AT_LEAST_VERSION(x,y,z) \
77 | (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
78 |
79 | #endif /* CURLINC_CURLVER_H */
80 |
--------------------------------------------------------------------------------
/include/curl/easy.h:
--------------------------------------------------------------------------------
1 | #ifndef CURLINC_EASY_H
2 | #define CURLINC_EASY_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at https://curl.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * SPDX-License-Identifier: curl
24 | *
25 | ***************************************************************************/
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Flag bits in the curl_blob struct: */
31 | #define CURL_BLOB_COPY 1 /* tell libcurl to copy the data */
32 | #define CURL_BLOB_NOCOPY 0 /* tell libcurl to NOT copy the data */
33 |
34 | struct curl_blob {
35 | void *data;
36 | size_t len;
37 | unsigned int flags; /* bit 0 is defined, the rest are reserved and should be
38 | left zeroes */
39 | };
40 |
41 | CURL_EXTERN CURL *curl_easy_init(void);
42 | CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
43 | CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
44 | CURL_EXTERN void curl_easy_cleanup(CURL *curl);
45 |
46 | /*
47 | * NAME curl_easy_getinfo()
48 | *
49 | * DESCRIPTION
50 | *
51 | * Request internal information from the curl session with this function.
52 | * The third argument MUST be pointing to the specific type of the used option
53 | * which is documented in each man page of the option. The data pointed to
54 | * will be filled in accordingly and can be relied upon only if the function
55 | * returns CURLE_OK. This function is intended to get used *AFTER* a performed
56 | * transfer, all results from this function are undefined until the transfer
57 | * is completed.
58 | */
59 | CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
60 |
61 |
62 | /*
63 | * NAME curl_easy_duphandle()
64 | *
65 | * DESCRIPTION
66 | *
67 | * Creates a new curl session handle with the same options set for the handle
68 | * passed in. Duplicating a handle could only be a matter of cloning data and
69 | * options, internal state info and things like persistent connections cannot
70 | * be transferred. It is useful in multithreaded applications when you can run
71 | * curl_easy_duphandle() for each new thread to avoid a series of identical
72 | * curl_easy_setopt() invokes in every thread.
73 | */
74 | CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl);
75 |
76 | /*
77 | * NAME curl_easy_reset()
78 | *
79 | * DESCRIPTION
80 | *
81 | * Re-initializes a CURL handle to the default values. This puts back the
82 | * handle to the same state as it was in when it was just created.
83 | *
84 | * It does keep: live connections, the Session ID cache, the DNS cache and the
85 | * cookies.
86 | */
87 | CURL_EXTERN void curl_easy_reset(CURL *curl);
88 |
89 | /*
90 | * NAME curl_easy_recv()
91 | *
92 | * DESCRIPTION
93 | *
94 | * Receives data from the connected socket. Use after successful
95 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
96 | */
97 | CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
98 | size_t *n);
99 |
100 | /*
101 | * NAME curl_easy_send()
102 | *
103 | * DESCRIPTION
104 | *
105 | * Sends data over the connected socket. Use after successful
106 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
107 | */
108 | CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
109 | size_t buflen, size_t *n);
110 |
111 |
112 | /*
113 | * NAME curl_easy_upkeep()
114 | *
115 | * DESCRIPTION
116 | *
117 | * Performs connection upkeep for the given session handle.
118 | */
119 | CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl);
120 |
121 | #ifdef __cplusplus
122 | } /* end of extern "C" */
123 | #endif
124 |
125 | #endif
126 |
--------------------------------------------------------------------------------
/include/curl/header.h:
--------------------------------------------------------------------------------
1 | #ifndef CURLINC_HEADER_H
2 | #define CURLINC_HEADER_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at https://curl.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * SPDX-License-Identifier: curl
24 | *
25 | ***************************************************************************/
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | struct curl_header {
32 | char *name; /* this might not use the same case */
33 | char *value;
34 | size_t amount; /* number of headers using this name */
35 | size_t index; /* ... of this instance, 0 or higher */
36 | unsigned int origin; /* see bits below */
37 | void *anchor; /* handle privately used by libcurl */
38 | };
39 |
40 | /* 'origin' bits */
41 | #define CURLH_HEADER (1<<0) /* plain server header */
42 | #define CURLH_TRAILER (1<<1) /* trailers */
43 | #define CURLH_CONNECT (1<<2) /* CONNECT headers */
44 | #define CURLH_1XX (1<<3) /* 1xx headers */
45 | #define CURLH_PSEUDO (1<<4) /* pseudo headers */
46 |
47 | typedef enum {
48 | CURLHE_OK,
49 | CURLHE_BADINDEX, /* header exists but not with this index */
50 | CURLHE_MISSING, /* no such header exists */
51 | CURLHE_NOHEADERS, /* no headers at all exist (yet) */
52 | CURLHE_NOREQUEST, /* no request with this number was used */
53 | CURLHE_OUT_OF_MEMORY, /* out of memory while processing */
54 | CURLHE_BAD_ARGUMENT, /* a function argument was not okay */
55 | CURLHE_NOT_BUILT_IN /* if API was disabled in the build */
56 | } CURLHcode;
57 |
58 | CURL_EXTERN CURLHcode curl_easy_header(CURL *easy,
59 | const char *name,
60 | size_t index,
61 | unsigned int origin,
62 | int request,
63 | struct curl_header **hout);
64 |
65 | CURL_EXTERN struct curl_header *curl_easy_nextheader(CURL *easy,
66 | unsigned int origin,
67 | int request,
68 | struct curl_header *prev);
69 |
70 | #ifdef __cplusplus
71 | } /* end of extern "C" */
72 | #endif
73 |
74 | #endif /* CURLINC_HEADER_H */
75 |
--------------------------------------------------------------------------------
/include/curl/mprintf.h:
--------------------------------------------------------------------------------
1 | #ifndef CURLINC_MPRINTF_H
2 | #define CURLINC_MPRINTF_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at https://curl.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * SPDX-License-Identifier: curl
24 | *
25 | ***************************************************************************/
26 |
27 | #include
28 | #include /* needed for FILE */
29 | #include "curl.h" /* for CURL_EXTERN */
30 |
31 | #ifdef __cplusplus
32 | extern "C" {
33 | #endif
34 |
35 | #if (defined(__GNUC__) || defined(__clang__)) && \
36 | defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
37 | !defined(CURL_NO_FMT_CHECKS)
38 | #if defined(__MINGW32__) && !defined(__clang__)
39 | #define CURL_TEMP_PRINTF(fmt, arg) \
40 | __attribute__((format(gnu_printf, fmt, arg)))
41 | #else
42 | #define CURL_TEMP_PRINTF(fmt, arg) \
43 | __attribute__((format(printf, fmt, arg)))
44 | #endif
45 | #else
46 | #define CURL_TEMP_PRINTF(fmt, arg)
47 | #endif
48 |
49 | CURL_EXTERN int curl_mprintf(const char *format, ...)
50 | CURL_TEMP_PRINTF(1, 2);
51 | CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...)
52 | CURL_TEMP_PRINTF(2, 3);
53 | CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...)
54 | CURL_TEMP_PRINTF(2, 3);
55 | CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength,
56 | const char *format, ...)
57 | CURL_TEMP_PRINTF(3, 4);
58 | CURL_EXTERN int curl_mvprintf(const char *format, va_list args)
59 | CURL_TEMP_PRINTF(1, 0);
60 | CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args)
61 | CURL_TEMP_PRINTF(2, 0);
62 | CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args)
63 | CURL_TEMP_PRINTF(2, 0);
64 | CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
65 | const char *format, va_list args)
66 | CURL_TEMP_PRINTF(3, 0);
67 | CURL_EXTERN char *curl_maprintf(const char *format, ...)
68 | CURL_TEMP_PRINTF(1, 2);
69 | CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args)
70 | CURL_TEMP_PRINTF(1, 0);
71 |
72 | #undef CURL_TEMP_PRINTF
73 |
74 | #ifdef __cplusplus
75 | } /* end of extern "C" */
76 | #endif
77 |
78 | #endif /* CURLINC_MPRINTF_H */
79 |
--------------------------------------------------------------------------------
/include/curl/multi.h:
--------------------------------------------------------------------------------
1 | #ifndef CURLINC_MULTI_H
2 | #define CURLINC_MULTI_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at https://curl.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * SPDX-License-Identifier: curl
24 | *
25 | ***************************************************************************/
26 | /*
27 | This is an "external" header file. Don't give away any internals here!
28 |
29 | GOALS
30 |
31 | o Enable a "pull" interface. The application that uses libcurl decides where
32 | and when to ask libcurl to get/send data.
33 |
34 | o Enable multiple simultaneous transfers in the same thread without making it
35 | complicated for the application.
36 |
37 | o Enable the application to select() on its own file descriptors and curl's
38 | file descriptors simultaneous easily.
39 |
40 | */
41 |
42 | /*
43 | * This header file should not really need to include "curl.h" since curl.h
44 | * itself includes this file and we expect user applications to do #include
45 | * without the need for especially including multi.h.
46 | *
47 | * For some reason we added this include here at one point, and rather than to
48 | * break existing (wrongly written) libcurl applications, we leave it as-is
49 | * but with this warning attached.
50 | */
51 | #include "curl.h"
52 |
53 | #ifdef __cplusplus
54 | extern "C" {
55 | #endif
56 |
57 | #if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
58 | typedef struct Curl_multi CURLM;
59 | #else
60 | typedef void CURLM;
61 | #endif
62 |
63 | typedef enum {
64 | CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
65 | curl_multi_socket*() soon */
66 | CURLM_OK,
67 | CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
68 | CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
69 | CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
70 | CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
71 | CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
72 | CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
73 | CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
74 | attempted to get added - again */
75 | CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
76 | callback */
77 | CURLM_WAKEUP_FAILURE, /* wakeup is unavailable or failed */
78 | CURLM_BAD_FUNCTION_ARGUMENT, /* function called with a bad parameter */
79 | CURLM_ABORTED_BY_CALLBACK,
80 | CURLM_UNRECOVERABLE_POLL,
81 | CURLM_LAST
82 | } CURLMcode;
83 |
84 | /* just to make code nicer when using curl_multi_socket() you can now check
85 | for CURLM_CALL_MULTI_SOCKET too in the same style it works for
86 | curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
87 | #define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
88 |
89 | /* bitmask bits for CURLMOPT_PIPELINING */
90 | #define CURLPIPE_NOTHING 0L
91 | #define CURLPIPE_HTTP1 1L
92 | #define CURLPIPE_MULTIPLEX 2L
93 |
94 | typedef enum {
95 | CURLMSG_NONE, /* first, not used */
96 | CURLMSG_DONE, /* This easy handle has completed. 'result' contains
97 | the CURLcode of the transfer */
98 | CURLMSG_LAST /* last, not used */
99 | } CURLMSG;
100 |
101 | struct CURLMsg {
102 | CURLMSG msg; /* what this message means */
103 | CURL *easy_handle; /* the handle it concerns */
104 | union {
105 | void *whatever; /* message-specific data */
106 | CURLcode result; /* return code for transfer */
107 | } data;
108 | };
109 | typedef struct CURLMsg CURLMsg;
110 |
111 | /* Based on poll(2) structure and values.
112 | * We don't use pollfd and POLL* constants explicitly
113 | * to cover platforms without poll(). */
114 | #define CURL_WAIT_POLLIN 0x0001
115 | #define CURL_WAIT_POLLPRI 0x0002
116 | #define CURL_WAIT_POLLOUT 0x0004
117 |
118 | struct curl_waitfd {
119 | curl_socket_t fd;
120 | short events;
121 | short revents;
122 | };
123 |
124 | /*
125 | * Name: curl_multi_init()
126 | *
127 | * Desc: initialize multi-style curl usage
128 | *
129 | * Returns: a new CURLM handle to use in all 'curl_multi' functions.
130 | */
131 | CURL_EXTERN CURLM *curl_multi_init(void);
132 |
133 | /*
134 | * Name: curl_multi_add_handle()
135 | *
136 | * Desc: add a standard curl handle to the multi stack
137 | *
138 | * Returns: CURLMcode type, general multi error code.
139 | */
140 | CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
141 | CURL *curl_handle);
142 |
143 | /*
144 | * Name: curl_multi_remove_handle()
145 | *
146 | * Desc: removes a curl handle from the multi stack again
147 | *
148 | * Returns: CURLMcode type, general multi error code.
149 | */
150 | CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
151 | CURL *curl_handle);
152 |
153 | /*
154 | * Name: curl_multi_fdset()
155 | *
156 | * Desc: Ask curl for its fd_set sets. The app can use these to select() or
157 | * poll() on. We want curl_multi_perform() called as soon as one of
158 | * them are ready.
159 | *
160 | * Returns: CURLMcode type, general multi error code.
161 | */
162 | CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
163 | fd_set *read_fd_set,
164 | fd_set *write_fd_set,
165 | fd_set *exc_fd_set,
166 | int *max_fd);
167 |
168 | /*
169 | * Name: curl_multi_wait()
170 | *
171 | * Desc: Poll on all fds within a CURLM set as well as any
172 | * additional fds passed to the function.
173 | *
174 | * Returns: CURLMcode type, general multi error code.
175 | */
176 | CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
177 | struct curl_waitfd extra_fds[],
178 | unsigned int extra_nfds,
179 | int timeout_ms,
180 | int *ret);
181 |
182 | /*
183 | * Name: curl_multi_poll()
184 | *
185 | * Desc: Poll on all fds within a CURLM set as well as any
186 | * additional fds passed to the function.
187 | *
188 | * Returns: CURLMcode type, general multi error code.
189 | */
190 | CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle,
191 | struct curl_waitfd extra_fds[],
192 | unsigned int extra_nfds,
193 | int timeout_ms,
194 | int *ret);
195 |
196 | /*
197 | * Name: curl_multi_wakeup()
198 | *
199 | * Desc: wakes up a sleeping curl_multi_poll call.
200 | *
201 | * Returns: CURLMcode type, general multi error code.
202 | */
203 | CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle);
204 |
205 | /*
206 | * Name: curl_multi_perform()
207 | *
208 | * Desc: When the app thinks there's data available for curl it calls this
209 | * function to read/write whatever there is right now. This returns
210 | * as soon as the reads and writes are done. This function does not
211 | * require that there actually is data available for reading or that
212 | * data can be written, it can be called just in case. It returns
213 | * the number of handles that still transfer data in the second
214 | * argument's integer-pointer.
215 | *
216 | * Returns: CURLMcode type, general multi error code. *NOTE* that this only
217 | * returns errors etc regarding the whole multi stack. There might
218 | * still have occurred problems on individual transfers even when
219 | * this returns OK.
220 | */
221 | CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
222 | int *running_handles);
223 |
224 | /*
225 | * Name: curl_multi_cleanup()
226 | *
227 | * Desc: Cleans up and removes a whole multi stack. It does not free or
228 | * touch any individual easy handles in any way. We need to define
229 | * in what state those handles will be if this function is called
230 | * in the middle of a transfer.
231 | *
232 | * Returns: CURLMcode type, general multi error code.
233 | */
234 | CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
235 |
236 | /*
237 | * Name: curl_multi_info_read()
238 | *
239 | * Desc: Ask the multi handle if there's any messages/informationals from
240 | * the individual transfers. Messages include informationals such as
241 | * error code from the transfer or just the fact that a transfer is
242 | * completed. More details on these should be written down as well.
243 | *
244 | * Repeated calls to this function will return a new struct each
245 | * time, until a special "end of msgs" struct is returned as a signal
246 | * that there is no more to get at this point.
247 | *
248 | * The data the returned pointer points to will not survive calling
249 | * curl_multi_cleanup().
250 | *
251 | * The 'CURLMsg' struct is meant to be very simple and only contain
252 | * very basic information. If more involved information is wanted,
253 | * we will provide the particular "transfer handle" in that struct
254 | * and that should/could/would be used in subsequent
255 | * curl_easy_getinfo() calls (or similar). The point being that we
256 | * must never expose complex structs to applications, as then we'll
257 | * undoubtably get backwards compatibility problems in the future.
258 | *
259 | * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
260 | * of structs. It also writes the number of messages left in the
261 | * queue (after this read) in the integer the second argument points
262 | * to.
263 | */
264 | CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
265 | int *msgs_in_queue);
266 |
267 | /*
268 | * Name: curl_multi_strerror()
269 | *
270 | * Desc: The curl_multi_strerror function may be used to turn a CURLMcode
271 | * value into the equivalent human readable error string. This is
272 | * useful for printing meaningful error messages.
273 | *
274 | * Returns: A pointer to a null-terminated error message.
275 | */
276 | CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
277 |
278 | /*
279 | * Name: curl_multi_socket() and
280 | * curl_multi_socket_all()
281 | *
282 | * Desc: An alternative version of curl_multi_perform() that allows the
283 | * application to pass in one of the file descriptors that have been
284 | * detected to have "action" on them and let libcurl perform.
285 | * See man page for details.
286 | */
287 | #define CURL_POLL_NONE 0
288 | #define CURL_POLL_IN 1
289 | #define CURL_POLL_OUT 2
290 | #define CURL_POLL_INOUT 3
291 | #define CURL_POLL_REMOVE 4
292 |
293 | #define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD
294 |
295 | #define CURL_CSELECT_IN 0x01
296 | #define CURL_CSELECT_OUT 0x02
297 | #define CURL_CSELECT_ERR 0x04
298 |
299 | typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */
300 | curl_socket_t s, /* socket */
301 | int what, /* see above */
302 | void *userp, /* private callback
303 | pointer */
304 | void *socketp); /* private socket
305 | pointer */
306 | /*
307 | * Name: curl_multi_timer_callback
308 | *
309 | * Desc: Called by libcurl whenever the library detects a change in the
310 | * maximum number of milliseconds the app is allowed to wait before
311 | * curl_multi_socket() or curl_multi_perform() must be called
312 | * (to allow libcurl's timed events to take place).
313 | *
314 | * Returns: The callback should return zero.
315 | */
316 | typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
317 | long timeout_ms, /* see above */
318 | void *userp); /* private callback
319 | pointer */
320 |
321 | CURL_EXTERN CURLMcode CURL_DEPRECATED(7.19.5, "Use curl_multi_socket_action()")
322 | curl_multi_socket(CURLM *multi_handle, curl_socket_t s, int *running_handles);
323 |
324 | CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
325 | curl_socket_t s,
326 | int ev_bitmask,
327 | int *running_handles);
328 |
329 | CURL_EXTERN CURLMcode CURL_DEPRECATED(7.19.5, "Use curl_multi_socket_action()")
330 | curl_multi_socket_all(CURLM *multi_handle, int *running_handles);
331 |
332 | #ifndef CURL_ALLOW_OLD_MULTI_SOCKET
333 | /* This macro below was added in 7.16.3 to push users who recompile to use
334 | the new curl_multi_socket_action() instead of the old curl_multi_socket()
335 | */
336 | #define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)
337 | #endif
338 |
339 | /*
340 | * Name: curl_multi_timeout()
341 | *
342 | * Desc: Returns the maximum number of milliseconds the app is allowed to
343 | * wait before curl_multi_socket() or curl_multi_perform() must be
344 | * called (to allow libcurl's timed events to take place).
345 | *
346 | * Returns: CURLM error code.
347 | */
348 | CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
349 | long *milliseconds);
350 |
351 | typedef enum {
352 | /* This is the socket callback function pointer */
353 | CURLOPT(CURLMOPT_SOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 1),
354 |
355 | /* This is the argument passed to the socket callback */
356 | CURLOPT(CURLMOPT_SOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 2),
357 |
358 | /* set to 1 to enable pipelining for this multi handle */
359 | CURLOPT(CURLMOPT_PIPELINING, CURLOPTTYPE_LONG, 3),
360 |
361 | /* This is the timer callback function pointer */
362 | CURLOPT(CURLMOPT_TIMERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 4),
363 |
364 | /* This is the argument passed to the timer callback */
365 | CURLOPT(CURLMOPT_TIMERDATA, CURLOPTTYPE_OBJECTPOINT, 5),
366 |
367 | /* maximum number of entries in the connection cache */
368 | CURLOPT(CURLMOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 6),
369 |
370 | /* maximum number of (pipelining) connections to one host */
371 | CURLOPT(CURLMOPT_MAX_HOST_CONNECTIONS, CURLOPTTYPE_LONG, 7),
372 |
373 | /* maximum number of requests in a pipeline */
374 | CURLOPT(CURLMOPT_MAX_PIPELINE_LENGTH, CURLOPTTYPE_LONG, 8),
375 |
376 | /* a connection with a content-length longer than this
377 | will not be considered for pipelining */
378 | CURLOPT(CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 9),
379 |
380 | /* a connection with a chunk length longer than this
381 | will not be considered for pipelining */
382 | CURLOPT(CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 10),
383 |
384 | /* a list of site names(+port) that are blocked from pipelining */
385 | CURLOPT(CURLMOPT_PIPELINING_SITE_BL, CURLOPTTYPE_OBJECTPOINT, 11),
386 |
387 | /* a list of server types that are blocked from pipelining */
388 | CURLOPT(CURLMOPT_PIPELINING_SERVER_BL, CURLOPTTYPE_OBJECTPOINT, 12),
389 |
390 | /* maximum number of open connections in total */
391 | CURLOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, CURLOPTTYPE_LONG, 13),
392 |
393 | /* This is the server push callback function pointer */
394 | CURLOPT(CURLMOPT_PUSHFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 14),
395 |
396 | /* This is the argument passed to the server push callback */
397 | CURLOPT(CURLMOPT_PUSHDATA, CURLOPTTYPE_OBJECTPOINT, 15),
398 |
399 | /* maximum number of concurrent streams to support on a connection */
400 | CURLOPT(CURLMOPT_MAX_CONCURRENT_STREAMS, CURLOPTTYPE_LONG, 16),
401 |
402 | CURLMOPT_LASTENTRY /* the last unused */
403 | } CURLMoption;
404 |
405 |
406 | /*
407 | * Name: curl_multi_setopt()
408 | *
409 | * Desc: Sets options for the multi handle.
410 | *
411 | * Returns: CURLM error code.
412 | */
413 | CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
414 | CURLMoption option, ...);
415 |
416 |
417 | /*
418 | * Name: curl_multi_assign()
419 | *
420 | * Desc: This function sets an association in the multi handle between the
421 | * given socket and a private pointer of the application. This is
422 | * (only) useful for curl_multi_socket uses.
423 | *
424 | * Returns: CURLM error code.
425 | */
426 | CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
427 | curl_socket_t sockfd, void *sockp);
428 |
429 | /*
430 | * Name: curl_multi_get_handles()
431 | *
432 | * Desc: Returns an allocated array holding all handles currently added to
433 | * the multi handle. Marks the final entry with a NULL pointer. If
434 | * there is no easy handle added to the multi handle, this function
435 | * returns an array with the first entry as a NULL pointer.
436 | *
437 | * Returns: NULL on failure, otherwise a CURL **array pointer
438 | */
439 | CURL_EXTERN CURL **curl_multi_get_handles(CURLM *multi_handle);
440 |
441 | /*
442 | * Name: curl_push_callback
443 | *
444 | * Desc: This callback gets called when a new stream is being pushed by the
445 | * server. It approves or denies the new stream. It can also decide
446 | * to completely fail the connection.
447 | *
448 | * Returns: CURL_PUSH_OK, CURL_PUSH_DENY or CURL_PUSH_ERROROUT
449 | */
450 | #define CURL_PUSH_OK 0
451 | #define CURL_PUSH_DENY 1
452 | #define CURL_PUSH_ERROROUT 2 /* added in 7.72.0 */
453 |
454 | struct curl_pushheaders; /* forward declaration only */
455 |
456 | CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
457 | size_t num);
458 | CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
459 | const char *name);
460 |
461 | typedef int (*curl_push_callback)(CURL *parent,
462 | CURL *easy,
463 | size_t num_headers,
464 | struct curl_pushheaders *headers,
465 | void *userp);
466 |
467 | /*
468 | * Name: curl_multi_waitfds()
469 | *
470 | * Desc: Ask curl for fds for polling. The app can use these to poll on.
471 | * We want curl_multi_perform() called as soon as one of them are
472 | * ready. Passing zero size allows to get just a number of fds.
473 | *
474 | * Returns: CURLMcode type, general multi error code.
475 | */
476 | CURL_EXTERN CURLMcode curl_multi_waitfds(CURLM *multi,
477 | struct curl_waitfd *ufds,
478 | unsigned int size,
479 | unsigned int *fd_count);
480 |
481 | #ifdef __cplusplus
482 | } /* end of extern "C" */
483 | #endif
484 |
485 | #endif
486 |
--------------------------------------------------------------------------------
/include/curl/options.h:
--------------------------------------------------------------------------------
1 | #ifndef CURLINC_OPTIONS_H
2 | #define CURLINC_OPTIONS_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at https://curl.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * SPDX-License-Identifier: curl
24 | *
25 | ***************************************************************************/
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | typedef enum {
32 | CURLOT_LONG, /* long (a range of values) */
33 | CURLOT_VALUES, /* (a defined set or bitmask) */
34 | CURLOT_OFF_T, /* curl_off_t (a range of values) */
35 | CURLOT_OBJECT, /* pointer (void *) */
36 | CURLOT_STRING, /* (char * to null-terminated buffer) */
37 | CURLOT_SLIST, /* (struct curl_slist *) */
38 | CURLOT_CBPTR, /* (void * passed as-is to a callback) */
39 | CURLOT_BLOB, /* blob (struct curl_blob *) */
40 | CURLOT_FUNCTION /* function pointer */
41 | } curl_easytype;
42 |
43 | /* Flag bits */
44 |
45 | /* "alias" means it is provided for old programs to remain functional,
46 | we prefer another name */
47 | #define CURLOT_FLAG_ALIAS (1<<0)
48 |
49 | /* The CURLOPTTYPE_* id ranges can still be used to figure out what type/size
50 | to use for curl_easy_setopt() for the given id */
51 | struct curl_easyoption {
52 | const char *name;
53 | CURLoption id;
54 | curl_easytype type;
55 | unsigned int flags;
56 | };
57 |
58 | CURL_EXTERN const struct curl_easyoption *
59 | curl_easy_option_by_name(const char *name);
60 |
61 | CURL_EXTERN const struct curl_easyoption *
62 | curl_easy_option_by_id(CURLoption id);
63 |
64 | CURL_EXTERN const struct curl_easyoption *
65 | curl_easy_option_next(const struct curl_easyoption *prev);
66 |
67 | #ifdef __cplusplus
68 | } /* end of extern "C" */
69 | #endif
70 | #endif /* CURLINC_OPTIONS_H */
71 |
--------------------------------------------------------------------------------
/include/curl/stdcheaders.h:
--------------------------------------------------------------------------------
1 | #ifndef CURLINC_STDCHEADERS_H
2 | #define CURLINC_STDCHEADERS_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at https://curl.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * SPDX-License-Identifier: curl
24 | *
25 | ***************************************************************************/
26 |
27 | #include
28 |
29 | size_t fread(void *, size_t, size_t, FILE *);
30 | size_t fwrite(const void *, size_t, size_t, FILE *);
31 |
32 | int strcasecmp(const char *, const char *);
33 | int strncasecmp(const char *, const char *, size_t);
34 |
35 | #endif /* CURLINC_STDCHEADERS_H */
36 |
--------------------------------------------------------------------------------
/include/curl/system.h:
--------------------------------------------------------------------------------
1 | #ifndef CURLINC_SYSTEM_H
2 | #define CURLINC_SYSTEM_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at https://curl.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * SPDX-License-Identifier: curl
24 | *
25 | ***************************************************************************/
26 |
27 | /*
28 | * Try to keep one section per platform, compiler and architecture, otherwise,
29 | * if an existing section is reused for a different one and later on the
30 | * original is adjusted, probably the piggybacking one can be adversely
31 | * changed.
32 | *
33 | * In order to differentiate between platforms/compilers/architectures use
34 | * only compiler built in predefined preprocessor symbols.
35 | *
36 | * curl_off_t
37 | * ----------
38 | *
39 | * For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
40 | * wide signed integral data type. The width of this data type must remain
41 | * constant and independent of any possible large file support settings.
42 | *
43 | * As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit
44 | * wide signed integral data type if there is no 64-bit type.
45 | *
46 | * As a general rule, curl_off_t shall not be mapped to off_t. This rule shall
47 | * only be violated if off_t is the only 64-bit data type available and the
48 | * size of off_t is independent of large file support settings. Keep your
49 | * build on the safe side avoiding an off_t gating. If you have a 64-bit
50 | * off_t then take for sure that another 64-bit data type exists, dig deeper
51 | * and you will find it.
52 | *
53 | */
54 |
55 | #if defined(__DJGPP__) || defined(__GO32__)
56 | # if defined(__DJGPP__) && (__DJGPP__ > 1)
57 | # define CURL_TYPEOF_CURL_OFF_T long long
58 | # define CURL_FORMAT_CURL_OFF_T "lld"
59 | # define CURL_FORMAT_CURL_OFF_TU "llu"
60 | # define CURL_SUFFIX_CURL_OFF_T LL
61 | # define CURL_SUFFIX_CURL_OFF_TU ULL
62 | # else
63 | # define CURL_TYPEOF_CURL_OFF_T long
64 | # define CURL_FORMAT_CURL_OFF_T "ld"
65 | # define CURL_FORMAT_CURL_OFF_TU "lu"
66 | # define CURL_SUFFIX_CURL_OFF_T L
67 | # define CURL_SUFFIX_CURL_OFF_TU UL
68 | # endif
69 | # define CURL_TYPEOF_CURL_SOCKLEN_T int
70 |
71 | #elif defined(__SALFORDC__)
72 | # define CURL_TYPEOF_CURL_OFF_T long
73 | # define CURL_FORMAT_CURL_OFF_T "ld"
74 | # define CURL_FORMAT_CURL_OFF_TU "lu"
75 | # define CURL_SUFFIX_CURL_OFF_T L
76 | # define CURL_SUFFIX_CURL_OFF_TU UL
77 | # define CURL_TYPEOF_CURL_SOCKLEN_T int
78 |
79 | #elif defined(__BORLANDC__)
80 | # if (__BORLANDC__ < 0x520)
81 | # define CURL_TYPEOF_CURL_OFF_T long
82 | # define CURL_FORMAT_CURL_OFF_T "ld"
83 | # define CURL_FORMAT_CURL_OFF_TU "lu"
84 | # define CURL_SUFFIX_CURL_OFF_T L
85 | # define CURL_SUFFIX_CURL_OFF_TU UL
86 | # else
87 | # define CURL_TYPEOF_CURL_OFF_T __int64
88 | # define CURL_FORMAT_CURL_OFF_T "I64d"
89 | # define CURL_FORMAT_CURL_OFF_TU "I64u"
90 | # define CURL_SUFFIX_CURL_OFF_T i64
91 | # define CURL_SUFFIX_CURL_OFF_TU ui64
92 | # endif
93 | # define CURL_TYPEOF_CURL_SOCKLEN_T int
94 |
95 | #elif defined(__TURBOC__)
96 | # define CURL_TYPEOF_CURL_OFF_T long
97 | # define CURL_FORMAT_CURL_OFF_T "ld"
98 | # define CURL_FORMAT_CURL_OFF_TU "lu"
99 | # define CURL_SUFFIX_CURL_OFF_T L
100 | # define CURL_SUFFIX_CURL_OFF_TU UL
101 | # define CURL_TYPEOF_CURL_SOCKLEN_T int
102 |
103 | #elif defined(__POCC__)
104 | # if (__POCC__ < 280)
105 | # define CURL_TYPEOF_CURL_OFF_T long
106 | # define CURL_FORMAT_CURL_OFF_T "ld"
107 | # define CURL_FORMAT_CURL_OFF_TU "lu"
108 | # define CURL_SUFFIX_CURL_OFF_T L
109 | # define CURL_SUFFIX_CURL_OFF_TU UL
110 | # elif defined(_MSC_VER)
111 | # define CURL_TYPEOF_CURL_OFF_T __int64
112 | # define CURL_FORMAT_CURL_OFF_T "I64d"
113 | # define CURL_FORMAT_CURL_OFF_TU "I64u"
114 | # define CURL_SUFFIX_CURL_OFF_T i64
115 | # define CURL_SUFFIX_CURL_OFF_TU ui64
116 | # else
117 | # define CURL_TYPEOF_CURL_OFF_T long long
118 | # define CURL_FORMAT_CURL_OFF_T "lld"
119 | # define CURL_FORMAT_CURL_OFF_TU "llu"
120 | # define CURL_SUFFIX_CURL_OFF_T LL
121 | # define CURL_SUFFIX_CURL_OFF_TU ULL
122 | # endif
123 | # define CURL_TYPEOF_CURL_SOCKLEN_T int
124 |
125 | #elif defined(__LCC__)
126 | # if defined(__MCST__) /* MCST eLbrus Compiler Collection */
127 | # define CURL_TYPEOF_CURL_OFF_T long
128 | # define CURL_FORMAT_CURL_OFF_T "ld"
129 | # define CURL_FORMAT_CURL_OFF_TU "lu"
130 | # define CURL_SUFFIX_CURL_OFF_T L
131 | # define CURL_SUFFIX_CURL_OFF_TU UL
132 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
133 | # define CURL_PULL_SYS_TYPES_H 1
134 | # define CURL_PULL_SYS_SOCKET_H 1
135 | # else /* Local (or Little) C Compiler */
136 | # define CURL_TYPEOF_CURL_OFF_T long
137 | # define CURL_FORMAT_CURL_OFF_T "ld"
138 | # define CURL_FORMAT_CURL_OFF_TU "lu"
139 | # define CURL_SUFFIX_CURL_OFF_T L
140 | # define CURL_SUFFIX_CURL_OFF_TU UL
141 | # define CURL_TYPEOF_CURL_SOCKLEN_T int
142 | # endif
143 |
144 | #elif defined(macintosh)
145 | # include
146 | # if TYPE_LONGLONG
147 | # define CURL_TYPEOF_CURL_OFF_T long long
148 | # define CURL_FORMAT_CURL_OFF_T "lld"
149 | # define CURL_FORMAT_CURL_OFF_TU "llu"
150 | # define CURL_SUFFIX_CURL_OFF_T LL
151 | # define CURL_SUFFIX_CURL_OFF_TU ULL
152 | # else
153 | # define CURL_TYPEOF_CURL_OFF_T long
154 | # define CURL_FORMAT_CURL_OFF_T "ld"
155 | # define CURL_FORMAT_CURL_OFF_TU "lu"
156 | # define CURL_SUFFIX_CURL_OFF_T L
157 | # define CURL_SUFFIX_CURL_OFF_TU UL
158 | # endif
159 | # define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
160 |
161 | #elif defined(__TANDEM)
162 | # if ! defined(__LP64)
163 | /* Required for 32-bit NonStop builds only. */
164 | # define CURL_TYPEOF_CURL_OFF_T long long
165 | # define CURL_FORMAT_CURL_OFF_T "lld"
166 | # define CURL_FORMAT_CURL_OFF_TU "llu"
167 | # define CURL_SUFFIX_CURL_OFF_T LL
168 | # define CURL_SUFFIX_CURL_OFF_TU ULL
169 | # define CURL_TYPEOF_CURL_SOCKLEN_T int
170 | # endif
171 |
172 | #elif defined(_WIN32_WCE)
173 | # define CURL_TYPEOF_CURL_OFF_T __int64
174 | # define CURL_FORMAT_CURL_OFF_T "I64d"
175 | # define CURL_FORMAT_CURL_OFF_TU "I64u"
176 | # define CURL_SUFFIX_CURL_OFF_T i64
177 | # define CURL_SUFFIX_CURL_OFF_TU ui64
178 | # define CURL_TYPEOF_CURL_SOCKLEN_T int
179 |
180 | #elif defined(__MINGW32__)
181 | # include
182 | # define CURL_TYPEOF_CURL_OFF_T long long
183 | # define CURL_FORMAT_CURL_OFF_T PRId64
184 | # define CURL_FORMAT_CURL_OFF_TU PRIu64
185 | # define CURL_SUFFIX_CURL_OFF_T LL
186 | # define CURL_SUFFIX_CURL_OFF_TU ULL
187 | # define CURL_TYPEOF_CURL_SOCKLEN_T int
188 | # define CURL_PULL_SYS_TYPES_H 1
189 |
190 | #elif defined(__VMS)
191 | # if defined(__VAX)
192 | # define CURL_TYPEOF_CURL_OFF_T long
193 | # define CURL_FORMAT_CURL_OFF_T "ld"
194 | # define CURL_FORMAT_CURL_OFF_TU "lu"
195 | # define CURL_SUFFIX_CURL_OFF_T L
196 | # define CURL_SUFFIX_CURL_OFF_TU UL
197 | # else
198 | # define CURL_TYPEOF_CURL_OFF_T long long
199 | # define CURL_FORMAT_CURL_OFF_T "lld"
200 | # define CURL_FORMAT_CURL_OFF_TU "llu"
201 | # define CURL_SUFFIX_CURL_OFF_T LL
202 | # define CURL_SUFFIX_CURL_OFF_TU ULL
203 | # endif
204 | # define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
205 |
206 | #elif defined(__OS400__)
207 | # define CURL_TYPEOF_CURL_OFF_T long long
208 | # define CURL_FORMAT_CURL_OFF_T "lld"
209 | # define CURL_FORMAT_CURL_OFF_TU "llu"
210 | # define CURL_SUFFIX_CURL_OFF_T LL
211 | # define CURL_SUFFIX_CURL_OFF_TU ULL
212 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
213 | # define CURL_PULL_SYS_TYPES_H 1
214 | # define CURL_PULL_SYS_SOCKET_H 1
215 |
216 | #elif defined(__MVS__)
217 | # if defined(_LONG_LONG)
218 | # define CURL_TYPEOF_CURL_OFF_T long long
219 | # define CURL_FORMAT_CURL_OFF_T "lld"
220 | # define CURL_FORMAT_CURL_OFF_TU "llu"
221 | # define CURL_SUFFIX_CURL_OFF_T LL
222 | # define CURL_SUFFIX_CURL_OFF_TU ULL
223 | # elif defined(_LP64)
224 | # define CURL_TYPEOF_CURL_OFF_T long
225 | # define CURL_FORMAT_CURL_OFF_T "ld"
226 | # define CURL_FORMAT_CURL_OFF_TU "lu"
227 | # define CURL_SUFFIX_CURL_OFF_T L
228 | # define CURL_SUFFIX_CURL_OFF_TU UL
229 | # else
230 | # define CURL_TYPEOF_CURL_OFF_T long
231 | # define CURL_FORMAT_CURL_OFF_T "ld"
232 | # define CURL_FORMAT_CURL_OFF_TU "lu"
233 | # define CURL_SUFFIX_CURL_OFF_T L
234 | # define CURL_SUFFIX_CURL_OFF_TU UL
235 | # endif
236 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
237 | # define CURL_PULL_SYS_TYPES_H 1
238 | # define CURL_PULL_SYS_SOCKET_H 1
239 |
240 | #elif defined(__370__)
241 | # if defined(__IBMC__) || defined(__IBMCPP__)
242 | # if defined(_ILP32)
243 | # elif defined(_LP64)
244 | # endif
245 | # if defined(_LONG_LONG)
246 | # define CURL_TYPEOF_CURL_OFF_T long long
247 | # define CURL_FORMAT_CURL_OFF_T "lld"
248 | # define CURL_FORMAT_CURL_OFF_TU "llu"
249 | # define CURL_SUFFIX_CURL_OFF_T LL
250 | # define CURL_SUFFIX_CURL_OFF_TU ULL
251 | # elif defined(_LP64)
252 | # define CURL_TYPEOF_CURL_OFF_T long
253 | # define CURL_FORMAT_CURL_OFF_T "ld"
254 | # define CURL_FORMAT_CURL_OFF_TU "lu"
255 | # define CURL_SUFFIX_CURL_OFF_T L
256 | # define CURL_SUFFIX_CURL_OFF_TU UL
257 | # else
258 | # define CURL_TYPEOF_CURL_OFF_T long
259 | # define CURL_FORMAT_CURL_OFF_T "ld"
260 | # define CURL_FORMAT_CURL_OFF_TU "lu"
261 | # define CURL_SUFFIX_CURL_OFF_T L
262 | # define CURL_SUFFIX_CURL_OFF_TU UL
263 | # endif
264 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
265 | # define CURL_PULL_SYS_TYPES_H 1
266 | # define CURL_PULL_SYS_SOCKET_H 1
267 | # endif
268 |
269 | #elif defined(TPF)
270 | # define CURL_TYPEOF_CURL_OFF_T long
271 | # define CURL_FORMAT_CURL_OFF_T "ld"
272 | # define CURL_FORMAT_CURL_OFF_TU "lu"
273 | # define CURL_SUFFIX_CURL_OFF_T L
274 | # define CURL_SUFFIX_CURL_OFF_TU UL
275 | # define CURL_TYPEOF_CURL_SOCKLEN_T int
276 |
277 | #elif defined(__TINYC__) /* also known as tcc */
278 | # define CURL_TYPEOF_CURL_OFF_T long long
279 | # define CURL_FORMAT_CURL_OFF_T "lld"
280 | # define CURL_FORMAT_CURL_OFF_TU "llu"
281 | # define CURL_SUFFIX_CURL_OFF_T LL
282 | # define CURL_SUFFIX_CURL_OFF_TU ULL
283 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
284 | # define CURL_PULL_SYS_TYPES_H 1
285 | # define CURL_PULL_SYS_SOCKET_H 1
286 |
287 | #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */
288 | # if !defined(__LP64) && (defined(__ILP32) || \
289 | defined(__i386) || \
290 | defined(__sparcv8) || \
291 | defined(__sparcv8plus))
292 | # define CURL_TYPEOF_CURL_OFF_T long long
293 | # define CURL_FORMAT_CURL_OFF_T "lld"
294 | # define CURL_FORMAT_CURL_OFF_TU "llu"
295 | # define CURL_SUFFIX_CURL_OFF_T LL
296 | # define CURL_SUFFIX_CURL_OFF_TU ULL
297 | # elif defined(__LP64) || \
298 | defined(__amd64) || defined(__sparcv9)
299 | # define CURL_TYPEOF_CURL_OFF_T long
300 | # define CURL_FORMAT_CURL_OFF_T "ld"
301 | # define CURL_FORMAT_CURL_OFF_TU "lu"
302 | # define CURL_SUFFIX_CURL_OFF_T L
303 | # define CURL_SUFFIX_CURL_OFF_TU UL
304 | # endif
305 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
306 | # define CURL_PULL_SYS_TYPES_H 1
307 | # define CURL_PULL_SYS_SOCKET_H 1
308 |
309 | #elif defined(__xlc__) /* IBM xlc compiler */
310 | # if !defined(_LP64)
311 | # define CURL_TYPEOF_CURL_OFF_T long long
312 | # define CURL_FORMAT_CURL_OFF_T "lld"
313 | # define CURL_FORMAT_CURL_OFF_TU "llu"
314 | # define CURL_SUFFIX_CURL_OFF_T LL
315 | # define CURL_SUFFIX_CURL_OFF_TU ULL
316 | # else
317 | # define CURL_TYPEOF_CURL_OFF_T long
318 | # define CURL_FORMAT_CURL_OFF_T "ld"
319 | # define CURL_FORMAT_CURL_OFF_TU "lu"
320 | # define CURL_SUFFIX_CURL_OFF_T L
321 | # define CURL_SUFFIX_CURL_OFF_TU UL
322 | # endif
323 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
324 | # define CURL_PULL_SYS_TYPES_H 1
325 | # define CURL_PULL_SYS_SOCKET_H 1
326 |
327 | #elif defined(__hpux) /* HP aCC compiler */
328 | # if !defined(_LP64)
329 | # define CURL_TYPEOF_CURL_OFF_T long long
330 | # define CURL_FORMAT_CURL_OFF_T "lld"
331 | # define CURL_FORMAT_CURL_OFF_TU "llu"
332 | # define CURL_SUFFIX_CURL_OFF_T LL
333 | # define CURL_SUFFIX_CURL_OFF_TU ULL
334 | # else
335 | # define CURL_TYPEOF_CURL_OFF_T long
336 | # define CURL_FORMAT_CURL_OFF_T "ld"
337 | # define CURL_FORMAT_CURL_OFF_TU "lu"
338 | # define CURL_SUFFIX_CURL_OFF_T L
339 | # define CURL_SUFFIX_CURL_OFF_TU UL
340 | # endif
341 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
342 | # define CURL_PULL_SYS_TYPES_H 1
343 | # define CURL_PULL_SYS_SOCKET_H 1
344 |
345 | /* ===================================== */
346 | /* KEEP MSVC THE PENULTIMATE ENTRY */
347 | /* ===================================== */
348 |
349 | #elif defined(_MSC_VER)
350 | # if (_MSC_VER >= 1800)
351 | # include
352 | # define CURL_TYPEOF_CURL_OFF_T __int64
353 | # define CURL_FORMAT_CURL_OFF_T PRId64
354 | # define CURL_FORMAT_CURL_OFF_TU PRIu64
355 | # define CURL_SUFFIX_CURL_OFF_T i64
356 | # define CURL_SUFFIX_CURL_OFF_TU ui64
357 | # elif (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
358 | # define CURL_TYPEOF_CURL_OFF_T __int64
359 | # define CURL_FORMAT_CURL_OFF_T "I64d"
360 | # define CURL_FORMAT_CURL_OFF_TU "I64u"
361 | # define CURL_SUFFIX_CURL_OFF_T i64
362 | # define CURL_SUFFIX_CURL_OFF_TU ui64
363 | # else
364 | # define CURL_TYPEOF_CURL_OFF_T long
365 | # define CURL_FORMAT_CURL_OFF_T "ld"
366 | # define CURL_FORMAT_CURL_OFF_TU "lu"
367 | # define CURL_SUFFIX_CURL_OFF_T L
368 | # define CURL_SUFFIX_CURL_OFF_TU UL
369 | # endif
370 | # define CURL_TYPEOF_CURL_SOCKLEN_T int
371 |
372 | /* ===================================== */
373 | /* KEEP GENERIC GCC THE LAST ENTRY */
374 | /* ===================================== */
375 |
376 | #elif defined(__GNUC__) && !defined(_SCO_DS)
377 | # if !defined(__LP64__) && \
378 | (defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
379 | defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
380 | defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
381 | defined(__XTENSA__) || \
382 | (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
383 | (defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L))
384 | # define CURL_TYPEOF_CURL_OFF_T long long
385 | # define CURL_FORMAT_CURL_OFF_T "lld"
386 | # define CURL_FORMAT_CURL_OFF_TU "llu"
387 | # define CURL_SUFFIX_CURL_OFF_T LL
388 | # define CURL_SUFFIX_CURL_OFF_TU ULL
389 | # elif defined(__LP64__) || \
390 | defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
391 | defined(__e2k__) || \
392 | (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
393 | (defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
394 | # define CURL_TYPEOF_CURL_OFF_T long
395 | # define CURL_FORMAT_CURL_OFF_T "ld"
396 | # define CURL_FORMAT_CURL_OFF_TU "lu"
397 | # define CURL_SUFFIX_CURL_OFF_T L
398 | # define CURL_SUFFIX_CURL_OFF_TU UL
399 | # endif
400 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
401 | # define CURL_PULL_SYS_TYPES_H 1
402 | # define CURL_PULL_SYS_SOCKET_H 1
403 |
404 | #else
405 | /* generic "safe guess" on old 32 bit style */
406 | # define CURL_TYPEOF_CURL_OFF_T long
407 | # define CURL_FORMAT_CURL_OFF_T "ld"
408 | # define CURL_FORMAT_CURL_OFF_TU "lu"
409 | # define CURL_SUFFIX_CURL_OFF_T L
410 | # define CURL_SUFFIX_CURL_OFF_TU UL
411 | # define CURL_TYPEOF_CURL_SOCKLEN_T int
412 | #endif
413 |
414 | #ifdef _AIX
415 | /* AIX needs */
416 | #define CURL_PULL_SYS_POLL_H
417 | #endif
418 |
419 | /* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
420 | /* sys/types.h is required here to properly make type definitions below. */
421 | #ifdef CURL_PULL_SYS_TYPES_H
422 | # include
423 | #endif
424 |
425 | /* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
426 | /* sys/socket.h is required here to properly make type definitions below. */
427 | #ifdef CURL_PULL_SYS_SOCKET_H
428 | # include
429 | #endif
430 |
431 | /* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
432 | /* sys/poll.h is required here to properly make type definitions below. */
433 | #ifdef CURL_PULL_SYS_POLL_H
434 | # include
435 | #endif
436 |
437 | /* Data type definition of curl_socklen_t. */
438 | #ifdef CURL_TYPEOF_CURL_SOCKLEN_T
439 | typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
440 | #endif
441 |
442 | /* Data type definition of curl_off_t. */
443 |
444 | #ifdef CURL_TYPEOF_CURL_OFF_T
445 | typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
446 | #endif
447 |
448 | /*
449 | * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
450 | * these to be visible and exported by the external libcurl interface API,
451 | * while also making them visible to the library internals, simply including
452 | * curl_setup.h, without actually needing to include curl.h internally.
453 | * If some day this section would grow big enough, all this should be moved
454 | * to its own header file.
455 | */
456 |
457 | /*
458 | * Figure out if we can use the ## preprocessor operator, which is supported
459 | * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
460 | * or __cplusplus so we need to carefully check for them too.
461 | */
462 |
463 | #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
464 | defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
465 | defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
466 | defined(__ILEC400__)
467 | /* This compiler is believed to have an ISO compatible preprocessor */
468 | #define CURL_ISOCPP
469 | #else
470 | /* This compiler is believed NOT to have an ISO compatible preprocessor */
471 | #undef CURL_ISOCPP
472 | #endif
473 |
474 | /*
475 | * Macros for minimum-width signed and unsigned curl_off_t integer constants.
476 | */
477 |
478 | #if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
479 | # define CURLINC_OFF_T_C_HLPR2(x) x
480 | # define CURLINC_OFF_T_C_HLPR1(x) CURLINC_OFF_T_C_HLPR2(x)
481 | # define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
482 | CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
483 | # define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
484 | CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
485 | #else
486 | # ifdef CURL_ISOCPP
487 | # define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
488 | # else
489 | # define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
490 | # endif
491 | # define CURLINC_OFF_T_C_HLPR1(Val,Suffix) CURLINC_OFF_T_C_HLPR2(Val,Suffix)
492 | # define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
493 | # define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
494 | #endif
495 |
496 | #endif /* CURLINC_SYSTEM_H */
497 |
--------------------------------------------------------------------------------
/include/curl/urlapi.h:
--------------------------------------------------------------------------------
1 | #ifndef CURLINC_URLAPI_H
2 | #define CURLINC_URLAPI_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at https://curl.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * SPDX-License-Identifier: curl
24 | *
25 | ***************************************************************************/
26 |
27 | #include "curl.h"
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | /* the error codes for the URL API */
34 | typedef enum {
35 | CURLUE_OK,
36 | CURLUE_BAD_HANDLE, /* 1 */
37 | CURLUE_BAD_PARTPOINTER, /* 2 */
38 | CURLUE_MALFORMED_INPUT, /* 3 */
39 | CURLUE_BAD_PORT_NUMBER, /* 4 */
40 | CURLUE_UNSUPPORTED_SCHEME, /* 5 */
41 | CURLUE_URLDECODE, /* 6 */
42 | CURLUE_OUT_OF_MEMORY, /* 7 */
43 | CURLUE_USER_NOT_ALLOWED, /* 8 */
44 | CURLUE_UNKNOWN_PART, /* 9 */
45 | CURLUE_NO_SCHEME, /* 10 */
46 | CURLUE_NO_USER, /* 11 */
47 | CURLUE_NO_PASSWORD, /* 12 */
48 | CURLUE_NO_OPTIONS, /* 13 */
49 | CURLUE_NO_HOST, /* 14 */
50 | CURLUE_NO_PORT, /* 15 */
51 | CURLUE_NO_QUERY, /* 16 */
52 | CURLUE_NO_FRAGMENT, /* 17 */
53 | CURLUE_NO_ZONEID, /* 18 */
54 | CURLUE_BAD_FILE_URL, /* 19 */
55 | CURLUE_BAD_FRAGMENT, /* 20 */
56 | CURLUE_BAD_HOSTNAME, /* 21 */
57 | CURLUE_BAD_IPV6, /* 22 */
58 | CURLUE_BAD_LOGIN, /* 23 */
59 | CURLUE_BAD_PASSWORD, /* 24 */
60 | CURLUE_BAD_PATH, /* 25 */
61 | CURLUE_BAD_QUERY, /* 26 */
62 | CURLUE_BAD_SCHEME, /* 27 */
63 | CURLUE_BAD_SLASHES, /* 28 */
64 | CURLUE_BAD_USER, /* 29 */
65 | CURLUE_LACKS_IDN, /* 30 */
66 | CURLUE_TOO_LARGE, /* 31 */
67 | CURLUE_LAST
68 | } CURLUcode;
69 |
70 | typedef enum {
71 | CURLUPART_URL,
72 | CURLUPART_SCHEME,
73 | CURLUPART_USER,
74 | CURLUPART_PASSWORD,
75 | CURLUPART_OPTIONS,
76 | CURLUPART_HOST,
77 | CURLUPART_PORT,
78 | CURLUPART_PATH,
79 | CURLUPART_QUERY,
80 | CURLUPART_FRAGMENT,
81 | CURLUPART_ZONEID /* added in 7.65.0 */
82 | } CURLUPart;
83 |
84 | #define CURLU_DEFAULT_PORT (1<<0) /* return default port number */
85 | #define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,
86 | if the port number matches the
87 | default for the scheme */
88 | #define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if
89 | missing */
90 | #define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */
91 | #define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */
92 | #define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */
93 | #define CURLU_URLDECODE (1<<6) /* URL decode on get */
94 | #define CURLU_URLENCODE (1<<7) /* URL encode on set */
95 | #define CURLU_APPENDQUERY (1<<8) /* append a form style part */
96 | #define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
97 | #define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the
98 | scheme is unknown. */
99 | #define CURLU_ALLOW_SPACE (1<<11) /* Allow spaces in the URL */
100 | #define CURLU_PUNYCODE (1<<12) /* get the host name in punycode */
101 | #define CURLU_PUNY2IDN (1<<13) /* punycode => IDN conversion */
102 | #define CURLU_GET_EMPTY (1<<14) /* allow empty queries and fragments
103 | when extracting the URL or the
104 | components */
105 |
106 | typedef struct Curl_URL CURLU;
107 |
108 | /*
109 | * curl_url() creates a new CURLU handle and returns a pointer to it.
110 | * Must be freed with curl_url_cleanup().
111 | */
112 | CURL_EXTERN CURLU *curl_url(void);
113 |
114 | /*
115 | * curl_url_cleanup() frees the CURLU handle and related resources used for
116 | * the URL parsing. It will not free strings previously returned with the URL
117 | * API.
118 | */
119 | CURL_EXTERN void curl_url_cleanup(CURLU *handle);
120 |
121 | /*
122 | * curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
123 | * handle must also be freed with curl_url_cleanup().
124 | */
125 | CURL_EXTERN CURLU *curl_url_dup(const CURLU *in);
126 |
127 | /*
128 | * curl_url_get() extracts a specific part of the URL from a CURLU
129 | * handle. Returns error code. The returned pointer MUST be freed with
130 | * curl_free() afterwards.
131 | */
132 | CURL_EXTERN CURLUcode curl_url_get(const CURLU *handle, CURLUPart what,
133 | char **part, unsigned int flags);
134 |
135 | /*
136 | * curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
137 | * error code. The passed in string will be copied. Passing a NULL instead of
138 | * a part string, clears that part.
139 | */
140 | CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
141 | const char *part, unsigned int flags);
142 |
143 | /*
144 | * curl_url_strerror() turns a CURLUcode value into the equivalent human
145 | * readable error string. This is useful for printing meaningful error
146 | * messages.
147 | */
148 | CURL_EXTERN const char *curl_url_strerror(CURLUcode);
149 |
150 | #ifdef __cplusplus
151 | } /* end of extern "C" */
152 | #endif
153 |
154 | #endif /* CURLINC_URLAPI_H */
155 |
--------------------------------------------------------------------------------
/include/curl/websockets.h:
--------------------------------------------------------------------------------
1 | #ifndef CURLINC_WEBSOCKETS_H
2 | #define CURLINC_WEBSOCKETS_H
3 | /***************************************************************************
4 | * _ _ ____ _
5 | * Project ___| | | | _ \| |
6 | * / __| | | | |_) | |
7 | * | (__| |_| | _ <| |___
8 | * \___|\___/|_| \_\_____|
9 | *
10 | * Copyright (C) Daniel Stenberg, , et al.
11 | *
12 | * This software is licensed as described in the file COPYING, which
13 | * you should have received as part of this distribution. The terms
14 | * are also available at https://curl.se/docs/copyright.html.
15 | *
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 | * copies of the Software, and permit persons to whom the Software is
18 | * furnished to do so, under the terms of the COPYING file.
19 | *
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 | * KIND, either express or implied.
22 | *
23 | * SPDX-License-Identifier: curl
24 | *
25 | ***************************************************************************/
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | struct curl_ws_frame {
32 | int age; /* zero */
33 | int flags; /* See the CURLWS_* defines */
34 | curl_off_t offset; /* the offset of this data into the frame */
35 | curl_off_t bytesleft; /* number of pending bytes left of the payload */
36 | size_t len; /* size of the current data chunk */
37 | };
38 |
39 | /* flag bits */
40 | #define CURLWS_TEXT (1<<0)
41 | #define CURLWS_BINARY (1<<1)
42 | #define CURLWS_CONT (1<<2)
43 | #define CURLWS_CLOSE (1<<3)
44 | #define CURLWS_PING (1<<4)
45 | #define CURLWS_OFFSET (1<<5)
46 |
47 | /*
48 | * NAME curl_ws_recv()
49 | *
50 | * DESCRIPTION
51 | *
52 | * Receives data from the websocket connection. Use after successful
53 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
54 | */
55 | CURL_EXTERN CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen,
56 | size_t *recv,
57 | const struct curl_ws_frame **metap);
58 |
59 | /* flags for curl_ws_send() */
60 | #define CURLWS_PONG (1<<6)
61 |
62 | /*
63 | * NAME curl_ws_send()
64 | *
65 | * DESCRIPTION
66 | *
67 | * Sends data over the websocket connection. Use after successful
68 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
69 | */
70 | CURL_EXTERN CURLcode curl_ws_send(CURL *curl, const void *buffer,
71 | size_t buflen, size_t *sent,
72 | curl_off_t fragsize,
73 | unsigned int flags);
74 |
75 | /* bits for the CURLOPT_WS_OPTIONS bitmask: */
76 | #define CURLWS_RAW_MODE (1<<0)
77 |
78 | CURL_EXTERN const struct curl_ws_frame *curl_ws_meta(CURL *curl);
79 |
80 | #ifdef __cplusplus
81 | }
82 | #endif
83 |
84 | #endif /* CURLINC_WEBSOCKETS_H */
85 |
--------------------------------------------------------------------------------
/include/sdk/amx/amx.h:
--------------------------------------------------------------------------------
1 | /* Pawn Abstract Machine (for the Pawn language)
2 | *
3 | * Copyright (c) ITB CompuPhase, 1997-2005
4 | *
5 | * This software is provided "as-is", without any express or implied warranty.
6 | * In no event will the authors be held liable for any damages arising from
7 | * the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software in
15 | * a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | *
21 | * Version: $Id: amx.h 3363 2005-07-23 09:03:29Z thiadmer $
22 | */
23 |
24 | #ifndef AMX_H_INCLUDED
25 | #define AMX_H_INCLUDED
26 |
27 | #include /* for size_t */
28 | #include
29 |
30 | #if defined __linux || defined __linux__
31 | #define __LINUX__
32 | #endif
33 |
34 | #if defined FREEBSD && !defined __FreeBSD__
35 | #define __FreeBSD__
36 | #endif
37 |
38 | #if !defined HAVE_STDINT_H
39 | #if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) \
40 | || (defined _MSC_VER && _MSC_VER >= 1600) \
41 | || defined __GNUC__ || defined __LCC__ || defined __DMC__ \
42 | || (defined __WATCOMC__ && __WATCOMC__ >= 1200)
43 | #define HAVE_STDINT_H 1
44 | #endif
45 | #endif
46 |
47 | #if !defined HAVE_INTTYPES_H
48 | #if defined __FreeBSD__
49 | #define HAVE_INTTYPES_H 1
50 | #endif
51 | #endif
52 |
53 | #if defined HAVE_STDINT_H
54 | #include
55 | #elif defined HAVE_INTTYPES_H
56 | #include
57 | #else
58 | #if defined __MACH__
59 | #include
60 | #endif
61 | typedef short int int16_t;
62 | typedef unsigned short int uint16_t;
63 | #if defined SN_TARGET_PS2
64 | typedef int int32_t;
65 | typedef unsigned int uint32_t;
66 | #else
67 | typedef long int int32_t;
68 | typedef unsigned long int uint32_t;
69 | #endif
70 | #if defined __WIN32__ || defined _WIN32 || defined WIN32
71 | typedef __int64 int64_t;
72 | typedef unsigned __int64 uint64_t;
73 | #define HAVE_I64
74 | #endif
75 | #if !defined _INTPTR_T_DEFINED
76 | #if defined _LP64 || defined WIN64 || defined _WIN64
77 | typedef __int64 intptr_t;
78 | #else
79 | typedef int32_t intptr_t;
80 | #endif
81 | #endif
82 | #endif
83 |
84 | #if defined _LP64 || defined WIN64 || defined _WIN64
85 | #if !defined __64BIT__
86 | #define __64BIT__
87 | #endif
88 | #endif
89 |
90 | #if !defined HAVE_ALLOCA_H
91 | #if defined __GNUC__ || defined __LCC__ || defined __DMC__ || defined __ARMCC_VERSION
92 | #define HAVE_ALLOCA_H 1
93 | #elif (defined __WATCOMC__ && __WATCOMC__ >= 1200)
94 | #define HAVE_ALLOCA_H 1
95 | #endif
96 | #endif
97 |
98 | #if defined HAVE_ALLOCA_H && HAVE_ALLOCA_H
99 | #include
100 | #elif defined __BORLANDC__
101 | #include
102 | #endif
103 |
104 | #if defined __WIN32__ || defined _WIN32 || defined WIN32
105 | #if !defined alloca
106 | #define alloca _alloca
107 | #endif
108 | #endif
109 |
110 | #if !defined assert_static
111 | /* see "Compile-Time Assertions" by Greg Miller,
112 | * (with modifications to port it to C)
113 | */
114 | #define _ASSERT_STATIC_SYMBOL_INNER(line) __ASSERT_STATIC_ ## line
115 | #define _ASSERT_STATIC_SYMBOL(line) _ASSERT_STATIC_SYMBOL_INNER(line)
116 | #define assert_static(test) \
117 | do { \
118 | typedef char _ASSERT_STATIC_SYMBOL(__LINE__)[((test) ? 1 : -1)]; \
119 | } while (0)
120 | #endif
121 |
122 | #ifdef __cplusplus
123 | extern "C" {
124 | #endif
125 |
126 | #if defined PAWN_DLL
127 | #if !defined AMX_NATIVE_CALL
128 | #define AMX_NATIVE_CALL __stdcall
129 | #endif
130 | #if !defined AMXAPI
131 | #define AMXAPI __stdcall
132 | #endif
133 | #endif
134 |
135 | /* calling convention for native functions */
136 | #if !defined AMX_NATIVE_CALL
137 | #define AMX_NATIVE_CALL
138 | #endif
139 |
140 | /* calling convention for all interface functions and callback functions */
141 | #if !defined AMXAPI
142 | #if defined STDECL
143 | #define AMXAPI __stdcall
144 | #elif defined CDECL
145 | #define AMXAPI __cdecl
146 | #elif defined GCC_HASCLASSVISIBILITY
147 | #define AMXAPI __attribute__((visibility("default")))
148 | #else
149 | #define AMXAPI
150 | #endif
151 | #endif
152 |
153 | #if !defined AMXEXPORT
154 | #define AMXEXPORT
155 | #endif
156 |
157 | /* File format version (in CUR_FILE_VERSION)
158 | * 0 original version
159 | * 1 opcodes JUMP.pri, SWITCH and CASETBL
160 | * 2 compressed files
161 | * 3 public variables
162 | * 4 opcodes SWAP.pri/alt and PUSHADDR
163 | * 5 tagnames table
164 | * 6 reformatted header
165 | * 7 name table, opcodes SYMTAG & SYSREQ.D
166 | * 8 opcode BREAK, renewed debug interface
167 | * 9 macro opcodes
168 | * 10 position-independent code, overlays, packed instructions
169 | * 11 relocating instructions for the native interface, reorganized instruction set
170 | * MIN_FILE_VERSION is the lowest file version number that the current AMX
171 | * implementation supports. If the AMX file header gets new fields, this number
172 | * often needs to be incremented. MIN_AMX_VERSION is the lowest AMX version that
173 | * is needed to support the current file version. When there are new opcodes,
174 | * this number needs to be incremented.
175 | */
176 | #define CUR_FILE_VERSION 8 /* current file version; also the current AMX version */
177 | #define MIN_FILE_VERSION 6 /* lowest supported file format version for the current AMX version */
178 | #define MIN_AMX_VERSION 8 /* minimum AMX version needed to support the current file format */
179 |
180 | #if !defined PAWN_CELL_SIZE
181 | #define PAWN_CELL_SIZE 32 /* by default, use 32-bit cells */
182 | #endif
183 |
184 | #if PAWN_CELL_SIZE == 16
185 | typedef uint16_t ucell;
186 | typedef int16_t cell;
187 | #elif PAWN_CELL_SIZE == 32
188 | typedef uint32_t ucell;
189 | typedef int32_t cell;
190 | #elif PAWN_CELL_SIZE == 64
191 | typedef uint64_t ucell;
192 | typedef int64_t cell;
193 | #else
194 | #error Unsupported cell size (PAWN_CELL_SIZE)
195 | #endif
196 |
197 | #define UNPACKEDMAX ((1L << (sizeof(cell) - 1) * 8) - 1)
198 | #define UNLIMITED (~1u >> 1)
199 |
200 | struct tagAMX;
201 |
202 | typedef cell (AMX_NATIVE_CALL *AMX_NATIVE)(struct tagAMX *amx, cell *params);
203 | typedef int (AMXAPI *AMX_CALLBACK)(struct tagAMX *amx, cell index, cell *result, cell *params);
204 | typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx);
205 |
206 | #if !defined _FAR
207 | #define _FAR
208 | #endif
209 |
210 | #if defined _MSC_VER
211 | #pragma warning(disable:4103) /* used #pragma pack to change alignment */
212 | #pragma warning(disable:4100) /* unreferenced formal parameter */
213 | #endif
214 |
215 | /* Some compilers do not support the #pragma align, which should be fine. Some
216 | * compilers give a warning on unknown #pragmas, which is not so fine...
217 | */
218 | #if (defined SN_TARGET_PS2 || defined __GNUC__) && !defined AMX_NO_ALIGN
219 | #define AMX_NO_ALIGN
220 | #endif
221 |
222 | #if defined __GNUC__
223 | #define PACKED __attribute__((packed))
224 | #else
225 | #define PACKED
226 | #endif
227 |
228 | #if !defined AMX_NO_ALIGN
229 | #if defined __LINUX__ || defined __FreeBSD__
230 | #pragma pack(1) /* structures must be packed (byte-aligned) */
231 | #elif defined MACOS && defined __MWERKS__
232 | #pragma options align=mac68k
233 | #else
234 | #pragma pack(push)
235 | #pragma pack(1) /* structures must be packed (byte-aligned) */
236 | #if defined __TURBOC__
237 | #pragma option -a- /* "pack" pragma for older Borland compilers */
238 | #endif
239 | #endif
240 | #endif
241 |
242 | typedef struct tagAMX_NATIVE_INFO {
243 | const char _FAR *name;
244 | AMX_NATIVE func;
245 | } PACKED AMX_NATIVE_INFO;
246 |
247 | #if !defined AMX_USERNUM
248 | #define AMX_USERNUM 4
249 | #endif
250 | #define sEXPMAX 19 /* maximum name length for file version <= 6 */
251 | #define sNAMEMAX 31 /* maximum name length of symbol name */
252 |
253 | typedef struct tagFUNCSTUB {
254 | uint32_t address;
255 | char name[sEXPMAX + 1];
256 | } PACKED AMX_FUNCSTUB;
257 |
258 | typedef struct tagFUNCSTUBNT {
259 | uint32_t address;
260 | uint32_t nameofs;
261 | } PACKED AMX_FUNCSTUBNT;
262 |
263 | /* The AMX structure is the internal structure for many functions. Not all
264 | * fields are valid at all times; many fields are cached in local variables.
265 | */
266 | typedef struct tagAMX {
267 | unsigned char _FAR *base; /* points to the AMX header, perhaps followed by P-code and data */
268 | unsigned char _FAR *data; /* points to separate data+stack+heap, may be NULL */
269 | AMX_CALLBACK callback; /* native function callback */
270 | AMX_DEBUG debug; /* debug callback */
271 | /* for external functions a few registers must be accessible from the outside */
272 | cell cip; /* instruction pointer: relative to base + amxhdr->cod */
273 | cell frm; /* stack frame base: relative to base + amxhdr->dat */
274 | cell hea; /* top of the heap: relative to base + amxhdr->dat */
275 | cell hlw; /* bottom of the heap: relative to base + amxhdr->dat */
276 | cell stk; /* stack pointer: relative to base + amxhdr->dat */
277 | cell stp; /* top of the stack: relative to base + amxhdr->dat */
278 | int flags; /* current status, see amx_Flags() */
279 | /* user data */
280 | #if AMX_USERNUM > 0
281 | long usertags[AMX_USERNUM];
282 | void _FAR *userdata[AMX_USERNUM];
283 | #endif
284 | /* native functions can raise an error */
285 | int error;
286 | /* passing parameters requires a "count" field */
287 | int paramcount;
288 | /* the sleep opcode needs to store the full AMX status */
289 | cell pri;
290 | cell alt;
291 | cell reset_stk;
292 | cell reset_hea;
293 | cell sysreq_d; /* relocated address/value for the SYSREQ.D opcode */
294 | #if defined JIT
295 | /* support variables for the JIT */
296 | int reloc_size; /* required temporary buffer for relocations */
297 | long code_size; /* estimated memory footprint of the native code */
298 | #endif
299 | } PACKED AMX;
300 |
301 | /* The AMX_HEADER structure is both the memory format as the file format. The
302 | * structure is used internally.
303 | */
304 | typedef struct tagAMX_HEADER {
305 | int32_t size; /* size of the "file" */
306 | uint16_t magic; /* signature */
307 | char file_version; /* file format version */
308 | char amx_version; /* required version of the AMX */
309 | int16_t flags;
310 | int16_t defsize; /* size of a definition record */
311 | int32_t cod; /* initial value of COD - code block */
312 | int32_t dat; /* initial value of DAT - data block */
313 | int32_t hea; /* initial value of HEA - start of the heap */
314 | int32_t stp; /* initial value of STP - stack top */
315 | int32_t cip; /* initial value of CIP - the instruction pointer */
316 | int32_t publics; /* offset to the "public functions" table */
317 | int32_t natives; /* offset to the "native functions" table */
318 | int32_t libraries; /* offset to the table of libraries */
319 | int32_t pubvars; /* offset to the "public variables" table */
320 | int32_t tags; /* offset to the "public tagnames" table */
321 | int32_t nametable; /* offset to the name table */
322 | } PACKED AMX_HEADER;
323 |
324 | #define AMX_MAGIC_16 0xf1e2
325 | #define AMX_MAGIC_32 0xf1e0
326 | #define AMX_MAGIC_64 0xf1e1
327 | #if PAWN_CELL_SIZE == 16
328 | #define AMX_MAGIC AMX_MAGIC_16
329 | #elif PAWN_CELL_SIZE == 32
330 | #define AMX_MAGIC AMX_MAGIC_32
331 | #elif PAWN_CELL_SIZE == 64
332 | #define AMX_MAGIC AMX_MAGIC_64
333 | #endif
334 |
335 | enum {
336 | AMX_ERR_NONE,
337 | /* reserve the first 15 error codes for exit codes of the abstract machine */
338 | AMX_ERR_EXIT, /* forced exit */
339 | AMX_ERR_ASSERT, /* assertion failed */
340 | AMX_ERR_STACKERR, /* stack/heap collision */
341 | AMX_ERR_BOUNDS, /* index out of bounds */
342 | AMX_ERR_MEMACCESS, /* invalid memory access */
343 | AMX_ERR_INVINSTR, /* invalid instruction */
344 | AMX_ERR_STACKLOW, /* stack underflow */
345 | AMX_ERR_HEAPLOW, /* heap underflow */
346 | AMX_ERR_CALLBACK, /* no callback, or invalid callback */
347 | AMX_ERR_NATIVE, /* native function failed */
348 | AMX_ERR_DIVIDE, /* divide by zero */
349 | AMX_ERR_SLEEP, /* go into sleepmode - code can be restarted */
350 | AMX_ERR_INVSTATE, /* invalid state for this access */
351 |
352 | AMX_ERR_MEMORY = 16, /* out of memory */
353 | AMX_ERR_FORMAT, /* invalid file format */
354 | AMX_ERR_VERSION, /* file is for a newer version of the AMX */
355 | AMX_ERR_NOTFOUND, /* function not found */
356 | AMX_ERR_INDEX, /* invalid index parameter (bad entry point) */
357 | AMX_ERR_DEBUG, /* debugger cannot run */
358 | AMX_ERR_INIT, /* AMX not initialized (or doubly initialized) */
359 | AMX_ERR_USERDATA, /* unable to set user data field (table full) */
360 | AMX_ERR_INIT_JIT, /* cannot initialize the JIT */
361 | AMX_ERR_PARAMS, /* parameter error */
362 | AMX_ERR_DOMAIN, /* domain error, expression result does not fit in range */
363 | AMX_ERR_GENERAL, /* general error (unknown or unspecific error) */
364 | };
365 |
366 | #define AMX_FLAG_DEBUG 0x02 /* symbolic info. available */
367 | #define AMX_FLAG_COMPACT 0x04 /* compact encoding */
368 | #define AMX_FLAG_BYTEOPC 0x08 /* opcode is a byte (not a cell) */
369 | #define AMX_FLAG_NOCHECKS 0x10 /* no array bounds checking; no STMT opcode */
370 | #define AMX_FLAG_NTVREG 0x1000 /* all native functions are registered */
371 | #define AMX_FLAG_JITC 0x2000 /* abstract machine is JIT compiled */
372 | #define AMX_FLAG_BROWSE 0x4000 /* busy browsing */
373 | #define AMX_FLAG_RELOC 0x8000 /* jump/call addresses relocated */
374 |
375 | #define AMX_EXEC_MAIN (-1) /* start at program entry point */
376 | #define AMX_EXEC_CONT (-2) /* continue from last address */
377 |
378 | #define AMX_USERTAG(a, b, c, d) ((a) | ((b) << 8) | ((long)(c) << 16) | ((long)(d) << 24))
379 |
380 | /* for native functions that use floating point parameters, the following
381 | * two macros are convenient for casting a "cell" into a "float" type _without_
382 | * changing the bit pattern
383 | */
384 | #if PAWN_CELL_SIZE == 32
385 | #define amx_ftoc(f) (*((cell*)&f)) /* float to cell */
386 | #define amx_ctof(c) (*((float*)&c)) /* cell to float */
387 | #elif PAWN_CELL_SIZE == 64
388 | #define amx_ftoc(f) (*((cell*)&f)) /* float to cell */
389 | #define amx_ctof(c) (*((double*)&c)) /* cell to float */
390 | #else
391 | // amx_ftoc() and amx_ctof() cannot be used
392 | #endif
393 |
394 | #define amx_StrParam(amx,param,result) \
395 | do { \
396 | cell *amx_cstr_; int amx_length_; \
397 | amx_GetAddr((amx), (param), &amx_cstr_); \
398 | amx_StrLen(amx_cstr_, &amx_length_); \
399 | if (amx_length_ > 0 && \
400 | ((result) = (char*)alloca((amx_length_ + 1) * sizeof(*(result)))) != NULL) \
401 | amx_GetString((char*)(result), amx_cstr_, sizeof(*(result)) > 1, amx_length_ + 1); \
402 | else (result) = NULL; \
403 | } while (0)
404 |
405 | uint16_t *AMXAPI amx_Align16(uint16_t *v);
406 | uint32_t *AMXAPI amx_Align32(uint32_t *v);
407 | #if defined _I64_MAX || defined INT64_MAX || defined HAVE_I64
408 | uint64_t *AMXAPI amx_Align64(uint64_t *v);
409 | #endif
410 | int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr);
411 | int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params);
412 | int AMXAPI amx_Cleanup(AMX *amx);
413 | int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data);
414 | int AMXAPI amx_Exec(AMX *amx, cell *retval, int index);
415 | int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index);
416 | int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index);
417 | int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr);
418 | int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname);
419 | int AMXAPI amx_Flags(AMX *amx,uint16_t *flags);
420 | int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr);
421 | int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname);
422 | int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname);
423 | int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr);
424 | int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size);
425 | int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id);
426 | int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr);
427 | int AMXAPI amx_Init(AMX *amx, void *program);
428 | int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code);
429 | int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap);
430 | int AMXAPI amx_NameLength(AMX *amx, int *length);
431 | AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func);
432 | int AMXAPI amx_NumNatives(AMX *amx, int *number);
433 | int AMXAPI amx_NumPublics(AMX *amx, int *number);
434 | int AMXAPI amx_NumPubVars(AMX *amx, int *number);
435 | int AMXAPI amx_NumTags(AMX *amx, int *number);
436 | int AMXAPI amx_Push(AMX *amx, cell value);
437 | int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells);
438 | int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar);
439 | int AMXAPI amx_RaiseError(AMX *amx, int error);
440 | int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number);
441 | int AMXAPI amx_Release(AMX *amx, cell amx_addr);
442 | int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback);
443 | int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug);
444 | int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size);
445 | int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr);
446 | int AMXAPI amx_StrLen(const cell *cstring, int *length);
447 | int AMXAPI amx_UTF8Check(const char *string, int *length);
448 | int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value);
449 | int AMXAPI amx_UTF8Len(const cell *cstr, int *length);
450 | int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value);
451 |
452 | #if PAWN_CELL_SIZE == 16
453 | #define amx_AlignCell(v) amx_Align16(v)
454 | #elif PAWN_CELL_SIZE == 32
455 | #define amx_AlignCell(v) amx_Align32(v)
456 | #elif PAWN_CELL_SIZE == 64 && (defined _I64_MAX || defined INT64_MAX || defined HAVE_I64)
457 | #define amx_AlignCell(v) amx_Align64(v)
458 | #else
459 | #error Unsupported cell size
460 | #endif
461 |
462 | #define amx_RegisterFunc(amx, name, func) \
463 | amx_Register((amx), amx_NativeInfo((name),(func)), 1);
464 |
465 | #if !defined AMX_NO_ALIGN
466 | #if defined __LINUX__ || defined __FreeBSD__
467 | #pragma pack() /* reset default packing */
468 | #elif defined MACOS && defined __MWERKS__
469 | #pragma options align=reset
470 | #else
471 | #pragma pack(pop) /* reset previous packing */
472 | #endif
473 | #endif
474 |
475 | #ifdef __cplusplus
476 | }
477 | #endif
478 |
479 | #endif /* AMX_H_INCLUDED */
480 |
--------------------------------------------------------------------------------
/include/sdk/plugin.h:
--------------------------------------------------------------------------------
1 | //----------------------------------------------------------
2 | //
3 | // SA:MP Multiplayer Modification For GTA:SA
4 | // Copyright 2004-2007 SA:MP Team
5 | //
6 | //----------------------------------------------------------
7 |
8 | #ifndef PLUGIN_H_INCLUDED
9 | #define PLUGIN_H_INCLUDED
10 |
11 | #include "amx/amx.h"
12 |
13 | //----------------------------------------------------------
14 |
15 | #define SAMP_PLUGIN_VERSION 0x0200
16 |
17 | //----------------------------------------------------------
18 |
19 | #ifdef __cplusplus
20 | #define PLUGIN_EXTERN_C extern "C"
21 | #else
22 | #define PLUGIN_EXTERN_C
23 | #endif
24 |
25 | #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__
26 | #ifndef __GNUC__
27 | #pragma message "Warning: Not using a GNU compiler."
28 | #endif
29 | #define PLUGIN_CALL
30 | #ifndef SAMPSVR
31 | // Compile code with -fvisibility=hidden to hide non-exported functions.
32 | #define PLUGIN_EXPORT PLUGIN_EXTERN_C __attribute__((visibility("default")))
33 | #else
34 | #define PLUGIN_EXPORT PLUGIN_EXTERN_C
35 | #endif
36 | #elif defined __WIN32__ || defined _WIN32 || defined WIN32
37 | #ifndef _MSC_VER
38 | #pragma message "Warning: Not using a VC++ compiler."
39 | #endif
40 | #define PLUGIN_CALL __stdcall
41 | #define PLUGIN_EXPORT PLUGIN_EXTERN_C
42 | #else
43 | #error "You must define one of WIN32, LINUX, or FREEBSD."
44 | #endif
45 |
46 | //----------------------------------------------------------
47 |
48 | enum SUPPORTS_FLAGS
49 | {
50 | SUPPORTS_VERSION = SAMP_PLUGIN_VERSION,
51 | SUPPORTS_VERSION_MASK = 0xffff,
52 | SUPPORTS_AMX_NATIVES = 0x10000,
53 | SUPPORTS_PROCESS_TICK = 0x20000,
54 | };
55 |
56 | //----------------------------------------------------------
57 |
58 | enum PLUGIN_DATA_TYPE
59 | {
60 | // For some debugging
61 | PLUGIN_DATA_LOGPRINTF = 0x00, // void (*logprintf_t)(const char*, ...)
62 |
63 | // AMX
64 | PLUGIN_DATA_AMX_EXPORTS = 0x10, // void *AmxFunctionTable[] (see PLUGIN_AMX_EXPORT)
65 | PLUGIN_DATA_CALLPUBLIC_FS = 0x11, // int (*AmxCallPublicFilterScript)(char *szFunctionName)
66 | PLUGIN_DATA_CALLPUBLIC_GM = 0x12, // int (*AmxCallPublicGameMode)(char *szFunctionName)
67 | };
68 |
69 | //----------------------------------------------------------
70 |
71 | enum PLUGIN_AMX_EXPORT
72 | {
73 | PLUGIN_AMX_EXPORT_Align16 = 0,
74 | PLUGIN_AMX_EXPORT_Align32 = 1,
75 | PLUGIN_AMX_EXPORT_Align64 = 2,
76 | PLUGIN_AMX_EXPORT_Allot = 3,
77 | PLUGIN_AMX_EXPORT_Callback = 4,
78 | PLUGIN_AMX_EXPORT_Cleanup = 5,
79 | PLUGIN_AMX_EXPORT_Clone = 6,
80 | PLUGIN_AMX_EXPORT_Exec = 7,
81 | PLUGIN_AMX_EXPORT_FindNative = 8,
82 | PLUGIN_AMX_EXPORT_FindPublic = 9,
83 | PLUGIN_AMX_EXPORT_FindPubVar = 10,
84 | PLUGIN_AMX_EXPORT_FindTagId = 11,
85 | PLUGIN_AMX_EXPORT_Flags = 12,
86 | PLUGIN_AMX_EXPORT_GetAddr = 13,
87 | PLUGIN_AMX_EXPORT_GetNative = 14,
88 | PLUGIN_AMX_EXPORT_GetPublic = 15,
89 | PLUGIN_AMX_EXPORT_GetPubVar = 16,
90 | PLUGIN_AMX_EXPORT_GetString = 17,
91 | PLUGIN_AMX_EXPORT_GetTag = 18,
92 | PLUGIN_AMX_EXPORT_GetUserData = 19,
93 | PLUGIN_AMX_EXPORT_Init = 20,
94 | PLUGIN_AMX_EXPORT_InitJIT = 21,
95 | PLUGIN_AMX_EXPORT_MemInfo = 22,
96 | PLUGIN_AMX_EXPORT_NameLength = 23,
97 | PLUGIN_AMX_EXPORT_NativeInfo = 24,
98 | PLUGIN_AMX_EXPORT_NumNatives = 25,
99 | PLUGIN_AMX_EXPORT_NumPublics = 26,
100 | PLUGIN_AMX_EXPORT_NumPubVars = 27,
101 | PLUGIN_AMX_EXPORT_NumTags = 28,
102 | PLUGIN_AMX_EXPORT_Push = 29,
103 | PLUGIN_AMX_EXPORT_PushArray = 30,
104 | PLUGIN_AMX_EXPORT_PushString = 31,
105 | PLUGIN_AMX_EXPORT_RaiseError = 32,
106 | PLUGIN_AMX_EXPORT_Register = 33,
107 | PLUGIN_AMX_EXPORT_Release = 34,
108 | PLUGIN_AMX_EXPORT_SetCallback = 35,
109 | PLUGIN_AMX_EXPORT_SetDebugHook = 36,
110 | PLUGIN_AMX_EXPORT_SetString = 37,
111 | PLUGIN_AMX_EXPORT_SetUserData = 38,
112 | PLUGIN_AMX_EXPORT_StrLen = 39,
113 | PLUGIN_AMX_EXPORT_UTF8Check = 40,
114 | PLUGIN_AMX_EXPORT_UTF8Get = 41,
115 | PLUGIN_AMX_EXPORT_UTF8Len = 42,
116 | PLUGIN_AMX_EXPORT_UTF8Put = 43,
117 | };
118 |
119 | //----------------------------------------------------------
120 |
121 | #endif // PLUGIN_H_INCLUDED
122 |
123 | //----------------------------------------------------------
124 | // EOF
125 |
--------------------------------------------------------------------------------
/lib/libcrypto.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimoSbara/samp-chatbot/49b3efb0bcc694901e90e277eb874b0bd7614b7b/lib/libcrypto.a
--------------------------------------------------------------------------------
/lib/libcurl.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimoSbara/samp-chatbot/49b3efb0bcc694901e90e277eb874b0bd7614b7b/lib/libcurl.a
--------------------------------------------------------------------------------
/lib/libcurl.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimoSbara/samp-chatbot/49b3efb0bcc694901e90e277eb874b0bd7614b7b/lib/libcurl.lib
--------------------------------------------------------------------------------
/lib/libcurl_debug.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimoSbara/samp-chatbot/49b3efb0bcc694901e90e277eb874b0bd7614b7b/lib/libcurl_debug.lib
--------------------------------------------------------------------------------
/lib/libssl.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimoSbara/samp-chatbot/49b3efb0bcc694901e90e277eb874b0bd7614b7b/lib/libssl.a
--------------------------------------------------------------------------------
/lib/sdk/src/plugin.cpp:
--------------------------------------------------------------------------------
1 | //----------------------------------------------------------
2 | //
3 | // SA:MP Multiplayer Modification For GTA:SA
4 | // Copyright 2004-2007 SA:MP Team
5 | //
6 | //----------------------------------------------------------
7 |
8 | #include "plugin.h"
9 |
10 | //----------------------------------------------------------
11 |
12 | void *pAMXFunctions;
13 |
14 | //----------------------------------------------------------
15 |
16 | #if (defined __WIN32__ || defined _WIN32 || defined WIN32) && defined _MSC_VER
17 |
18 | // Optimized Inline Assembly Thunks for MS VC++
19 |
20 | #define NUDE _declspec(naked)
21 |
22 | NUDE uint16_t *AMXAPI amx_Align16(uint16_t *v)
23 | {
24 | _asm mov eax, pAMXFunctions;
25 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Align16 * 4];
26 | }
27 |
28 | NUDE uint32_t *AMXAPI amx_Align32(uint32_t *v)
29 | {
30 | _asm mov eax, pAMXFunctions;
31 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Align32 * 4];
32 | }
33 |
34 | #if defined _I64_MAX || defined HAVE_I64
35 | NUDE uint64_t *AMXAPI amx_Align64(uint64_t *v)
36 | {
37 | _asm mov eax, pAMXFunctions;
38 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Align64 * 4];
39 | }
40 |
41 | #endif
42 | NUDE int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr)
43 | {
44 | _asm mov eax, pAMXFunctions;
45 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Allot * 4];
46 | }
47 |
48 | NUDE int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
49 | {
50 | _asm mov eax, pAMXFunctions;
51 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Callback * 4];
52 | }
53 |
54 | NUDE int AMXAPI amx_Cleanup(AMX *amx)
55 | {
56 | _asm mov eax, pAMXFunctions;
57 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Cleanup * 4];
58 | }
59 |
60 | NUDE int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data)
61 | {
62 | _asm mov eax, pAMXFunctions;
63 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Clone * 4];
64 | }
65 |
66 | NUDE int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
67 | {
68 | _asm mov eax, pAMXFunctions;
69 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Exec * 4];
70 | }
71 |
72 | NUDE int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index)
73 | {
74 | _asm mov eax, pAMXFunctions;
75 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_FindNative * 4];
76 | }
77 |
78 | NUDE int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index)
79 | {
80 | _asm mov eax, pAMXFunctions;
81 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_FindPublic * 4];
82 | }
83 |
84 | NUDE int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr)
85 | {
86 | _asm mov eax, pAMXFunctions;
87 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_FindPubVar * 4];
88 | }
89 |
90 | NUDE int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname)
91 | {
92 | _asm mov eax, pAMXFunctions;
93 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_FindTagId * 4];
94 | }
95 |
96 | NUDE int AMXAPI amx_Flags(AMX *amx,uint16_t *flags)
97 | {
98 | _asm mov eax, pAMXFunctions;
99 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Flags * 4];
100 | }
101 |
102 | NUDE int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr)
103 | {
104 | _asm mov eax, pAMXFunctions;
105 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_GetAddr * 4];
106 | }
107 |
108 | NUDE int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname)
109 | {
110 | _asm mov eax, pAMXFunctions;
111 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_GetNative * 4];
112 | }
113 |
114 | NUDE int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname)
115 | {
116 | _asm mov eax, pAMXFunctions;
117 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_GetPublic * 4];
118 | }
119 |
120 | NUDE int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr)
121 | {
122 | _asm mov eax, pAMXFunctions;
123 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_GetPubVar * 4];
124 | }
125 |
126 | NUDE int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size)
127 | {
128 | _asm mov eax, pAMXFunctions;
129 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_GetString * 4];
130 | }
131 |
132 | NUDE int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id)
133 | {
134 | _asm mov eax, pAMXFunctions;
135 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_GetTag * 4];
136 | }
137 |
138 | NUDE int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr)
139 | {
140 | _asm mov eax, pAMXFunctions;
141 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_GetUserData * 4];
142 | }
143 |
144 | NUDE int AMXAPI amx_Init(AMX *amx, void *program)
145 | {
146 | _asm mov eax, pAMXFunctions;
147 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Init * 4];
148 | }
149 |
150 | NUDE int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code)
151 | {
152 | _asm mov eax, pAMXFunctions;
153 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_InitJIT * 4];
154 | }
155 |
156 | NUDE int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap)
157 | {
158 | _asm mov eax, pAMXFunctions;
159 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_MemInfo * 4];
160 | }
161 |
162 | NUDE int AMXAPI amx_NameLength(AMX *amx, int *length)
163 | {
164 | _asm mov eax, pAMXFunctions;
165 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_NameLength * 4];
166 | }
167 |
168 | NUDE AMX_NATIVE_INFO *AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func)
169 | {
170 | _asm mov eax, pAMXFunctions;
171 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_NativeInfo * 4];
172 | }
173 |
174 | NUDE int AMXAPI amx_NumNatives(AMX *amx, int *number)
175 | {
176 | _asm mov eax, pAMXFunctions;
177 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_NumNatives * 4];
178 | }
179 |
180 | NUDE int AMXAPI amx_NumPublics(AMX *amx, int *number)
181 | {
182 | _asm mov eax, pAMXFunctions;
183 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_NumPublics * 4];
184 | }
185 |
186 | NUDE int AMXAPI amx_NumPubVars(AMX *amx, int *number)
187 | {
188 | _asm mov eax, pAMXFunctions;
189 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_NumPubVars * 4];
190 | }
191 |
192 | NUDE int AMXAPI amx_NumTags(AMX *amx, int *number)
193 | {
194 | _asm mov eax, pAMXFunctions;
195 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_NumTags * 4];
196 | }
197 |
198 | NUDE int AMXAPI amx_Push(AMX *amx, cell value)
199 | {
200 | _asm mov eax, pAMXFunctions;
201 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Push * 4];
202 | }
203 |
204 | NUDE int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells)
205 | {
206 | _asm mov eax, pAMXFunctions;
207 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_PushArray * 4];
208 | }
209 |
210 | NUDE int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar)
211 | {
212 | _asm mov eax, pAMXFunctions;
213 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_PushString * 4];
214 | }
215 |
216 | NUDE int AMXAPI amx_RaiseError(AMX *amx, int error)
217 | {
218 | _asm mov eax, pAMXFunctions;
219 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_RaiseError * 4];
220 | }
221 |
222 | NUDE int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number)
223 | {
224 | _asm mov eax, pAMXFunctions;
225 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Register * 4];
226 | }
227 |
228 | NUDE int AMXAPI amx_Release(AMX *amx, cell amx_addr)
229 | {
230 | _asm mov eax, pAMXFunctions;
231 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_Release * 4];
232 | }
233 |
234 | NUDE int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback)
235 | {
236 | _asm mov eax, pAMXFunctions;
237 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_SetCallback * 4];
238 | }
239 |
240 | NUDE int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug)
241 | {
242 | _asm mov eax, pAMXFunctions;
243 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_SetDebugHook * 4];
244 | }
245 |
246 | NUDE int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size)
247 | {
248 | _asm mov eax, pAMXFunctions;
249 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_SetString * 4];
250 | }
251 |
252 | NUDE int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr)
253 | {
254 | _asm mov eax, pAMXFunctions;
255 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_SetUserData * 4];
256 | }
257 |
258 | NUDE int AMXAPI amx_StrLen(const cell *cstring, int *length)
259 | {
260 | _asm mov eax, pAMXFunctions;
261 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_StrLen * 4];
262 | }
263 |
264 | NUDE int AMXAPI amx_UTF8Check(const char *string, int *length)
265 | {
266 | _asm mov eax, pAMXFunctions;
267 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_UTF8Check * 4];
268 | }
269 |
270 | NUDE int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value)
271 | {
272 | _asm mov eax, pAMXFunctions;
273 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_UTF8Get * 4];
274 | }
275 |
276 | NUDE int AMXAPI amx_UTF8Len(const cell *cstr, int *length)
277 | {
278 | _asm mov eax, pAMXFunctions;
279 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_UTF8Len * 4];
280 | }
281 |
282 | NUDE int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value)
283 | {
284 | _asm mov eax, pAMXFunctions;
285 | _asm jmp dword ptr[eax + PLUGIN_AMX_EXPORT_UTF8Put * 4];
286 | }
287 |
288 | #else
289 |
290 | // Unoptimized Thunks (Linux/BSD/non MSVC++)
291 |
292 | typedef uint16_t * AMXAPI (*amx_Align16_t)(uint16_t *v);
293 | uint16_t *AMXAPI amx_Align16(uint16_t *v)
294 | {
295 | amx_Align16_t fn = ((amx_Align16_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Align16];
296 | return fn(v);
297 | }
298 |
299 | typedef uint32_t * AMXAPI (*amx_Align32_t)(uint32_t *v);
300 | uint32_t *AMXAPI amx_Align32(uint32_t *v)
301 | {
302 | amx_Align32_t fn = ((amx_Align32_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Align32];
303 | return fn(v);
304 | }
305 |
306 | #if defined _I64_MAX || defined HAVE_I64
307 | typedef uint64_t * AMXAPI (*amx_Align64_t)(uint64_t *v);
308 | uint64_t *AMXAPI amx_Align64(uint64_t *v)
309 | {
310 | amx_Align64_t fn = ((amx_Align64_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Align64];
311 | return fn(v);
312 | }
313 |
314 | #endif
315 | typedef int AMXAPI (*amx_Allot_t)(AMX *amx, int cells, cell *amx_addr, cell **phys_addr);
316 | int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr)
317 | {
318 | amx_Allot_t fn = ((amx_Allot_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Allot];
319 | return fn(amx, cells, amx_addr, phys_addr);
320 | }
321 |
322 | typedef int AMXAPI (*amx_Callback_t)(AMX *amx, cell index, cell *result, cell *params);
323 | int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
324 | {
325 | amx_Callback_t fn = ((amx_Callback_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Callback];
326 | return fn(amx, index, result, params);
327 | }
328 |
329 | typedef int AMXAPI (*amx_Cleanup_t)(AMX *amx);
330 | int AMXAPI amx_Cleanup(AMX *amx)
331 | {
332 | amx_Cleanup_t fn = ((amx_Cleanup_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Cleanup];
333 | return fn(amx);
334 | }
335 |
336 | typedef int AMXAPI (*amx_Clone_t)(AMX *amxClone, AMX *amxSource, void *data);
337 | int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data)
338 | {
339 | amx_Clone_t fn = ((amx_Clone_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Clone];
340 | return fn(amxClone, amxSource, data);
341 | }
342 |
343 | typedef int AMXAPI (*amx_Exec_t)(AMX *amx, cell *retval, int index);
344 | int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
345 | {
346 | amx_Exec_t fn = ((amx_Exec_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Exec];
347 | return fn(amx, retval, index);
348 | }
349 |
350 | typedef int AMXAPI (*amx_FindNative_t)(AMX *amx, const char *name, int *index);
351 | int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index)
352 | {
353 | amx_FindNative_t fn = ((amx_FindNative_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindNative];
354 | return fn(amx, name, index);
355 | }
356 |
357 | typedef int AMXAPI (*amx_FindPublic_t)(AMX *amx, const char *funcname, int *index);
358 | int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index)
359 | {
360 | amx_FindPublic_t fn = ((amx_FindPublic_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindPublic];
361 | return fn(amx, funcname, index);
362 | }
363 |
364 | typedef int AMXAPI (*amx_FindPubVar_t)(AMX *amx, const char *varname, cell *amx_addr);
365 | int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr)
366 | {
367 | amx_FindPubVar_t fn = ((amx_FindPubVar_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindPubVar];
368 | return fn(amx, varname, amx_addr);
369 | }
370 |
371 | typedef int AMXAPI (*amx_FindTagId_t)(AMX *amx, cell tag_id, char *tagname);
372 | int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname)
373 | {
374 | amx_FindTagId_t fn = ((amx_FindTagId_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindTagId];
375 | return fn(amx, tag_id, tagname);
376 | }
377 |
378 | typedef int AMXAPI (*amx_Flags_t)(AMX *amx,uint16_t *flags);
379 | int AMXAPI amx_Flags(AMX *amx,uint16_t *flags)
380 | {
381 | amx_Flags_t fn = ((amx_Flags_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Flags];
382 | return fn(amx,flags);
383 | }
384 |
385 | typedef int AMXAPI (*amx_GetAddr_t)(AMX *amx,cell amx_addr,cell **phys_addr);
386 | int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr)
387 | {
388 | amx_GetAddr_t fn = ((amx_GetAddr_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetAddr];
389 | return fn(amx,amx_addr,phys_addr);
390 | }
391 |
392 | typedef int AMXAPI (*amx_GetNative_t)(AMX *amx, int index, char *funcname);
393 | int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname)
394 | {
395 | amx_GetNative_t fn = ((amx_GetNative_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetNative];
396 | return fn(amx, index, funcname);
397 | }
398 |
399 | typedef int AMXAPI (*amx_GetPublic_t)(AMX *amx, int index, char *funcname);
400 | int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname)
401 | {
402 | amx_GetPublic_t fn = ((amx_GetPublic_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetPublic];
403 | return fn(amx, index, funcname);
404 | }
405 |
406 | typedef int AMXAPI (*amx_GetPubVar_t)(AMX *amx, int index, char *varname, cell *amx_addr);
407 | int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr)
408 | {
409 | amx_GetPubVar_t fn = ((amx_GetPubVar_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetPubVar];
410 | return fn(amx, index, varname, amx_addr);
411 | }
412 |
413 | typedef int AMXAPI (*amx_GetString_t)(char *dest,const cell *source, int use_wchar, size_t size);
414 | int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size)
415 | {
416 | amx_GetString_t fn = ((amx_GetString_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetString];
417 | return fn(dest,source, use_wchar, size);
418 | }
419 |
420 | typedef int AMXAPI (*amx_GetTag_t)(AMX *amx, int index, char *tagname, cell *tag_id);
421 | int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id)
422 | {
423 | amx_GetTag_t fn = ((amx_GetTag_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetTag];
424 | return fn(amx, index, tagname, tag_id);
425 | }
426 |
427 | typedef int AMXAPI (*amx_GetUserData_t)(AMX *amx, long tag, void **ptr);
428 | int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr)
429 | {
430 | amx_GetUserData_t fn = ((amx_GetUserData_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetUserData];
431 | return fn(amx, tag, ptr);
432 | }
433 |
434 | typedef int AMXAPI (*amx_Init_t)(AMX *amx, void *program);
435 | int AMXAPI amx_Init(AMX *amx, void *program)
436 | {
437 | amx_Init_t fn = ((amx_Init_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Init];
438 | return fn(amx, program);
439 | }
440 |
441 | typedef int AMXAPI (*amx_InitJIT_t)(AMX *amx, void *reloc_table, void *native_code);
442 | int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code)
443 | {
444 | amx_InitJIT_t fn = ((amx_InitJIT_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_InitJIT];
445 | return fn(amx, reloc_table, native_code);
446 | }
447 |
448 | typedef int AMXAPI (*amx_MemInfo_t)(AMX *amx, long *codesize, long *datasize, long *stackheap);
449 | int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap)
450 | {
451 | amx_MemInfo_t fn = ((amx_MemInfo_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_MemInfo];
452 | return fn(amx, codesize, datasize, stackheap);
453 | }
454 |
455 | typedef int AMXAPI (*amx_NameLength_t)(AMX *amx, int *length);
456 | int AMXAPI amx_NameLength(AMX *amx, int *length)
457 | {
458 | amx_NameLength_t fn = ((amx_NameLength_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NameLength];
459 | return fn(amx, length);
460 | }
461 |
462 | typedef AMX_NATIVE_INFO * AMXAPI (*amx_NativeInfo_t)(const char *name, AMX_NATIVE func);
463 | AMX_NATIVE_INFO *AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func)
464 | {
465 | amx_NativeInfo_t fn = ((amx_NativeInfo_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NativeInfo];
466 | return fn(name, func);
467 | }
468 |
469 | typedef int AMXAPI (*amx_NumNatives_t)(AMX *amx, int *number);
470 | int AMXAPI amx_NumNatives(AMX *amx, int *number)
471 | {
472 | amx_NumNatives_t fn = ((amx_NumNatives_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumNatives];
473 | return fn(amx, number);
474 | }
475 |
476 | typedef int AMXAPI (*amx_NumPublics_t)(AMX *amx, int *number);
477 | int AMXAPI amx_NumPublics(AMX *amx, int *number)
478 | {
479 | amx_NumPublics_t fn = ((amx_NumPublics_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumPublics];
480 | return fn(amx, number);
481 | }
482 |
483 | typedef int AMXAPI (*amx_NumPubVars_t)(AMX *amx, int *number);
484 | int AMXAPI amx_NumPubVars(AMX *amx, int *number)
485 | {
486 | amx_NumPubVars_t fn = ((amx_NumPubVars_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumPubVars];
487 | return fn(amx, number);
488 | }
489 |
490 | typedef int AMXAPI (*amx_NumTags_t)(AMX *amx, int *number);
491 | int AMXAPI amx_NumTags(AMX *amx, int *number)
492 | {
493 | amx_NumTags_t fn = ((amx_NumTags_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumTags];
494 | return fn(amx, number);
495 | }
496 |
497 | typedef int AMXAPI (*amx_Push_t)(AMX *amx, cell value);
498 | int AMXAPI amx_Push(AMX *amx, cell value)
499 | {
500 | amx_Push_t fn = ((amx_Push_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Push];
501 | return fn(amx, value);
502 | }
503 |
504 | typedef int AMXAPI (*amx_PushArray_t)(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells);
505 | int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells)
506 | {
507 | amx_PushArray_t fn = ((amx_PushArray_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_PushArray];
508 | return fn(amx, amx_addr, phys_addr, array, numcells);
509 | }
510 |
511 | typedef int AMXAPI (*amx_PushString_t)(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar);
512 | int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar)
513 | {
514 | amx_PushString_t fn = ((amx_PushString_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_PushString];
515 | return fn(amx, amx_addr, phys_addr, string, pack, use_wchar);
516 | }
517 |
518 | typedef int AMXAPI (*amx_RaiseError_t)(AMX *amx, int error);
519 | int AMXAPI amx_RaiseError(AMX *amx, int error)
520 | {
521 | amx_RaiseError_t fn = ((amx_RaiseError_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_RaiseError];
522 | return fn(amx, error);
523 | }
524 |
525 | typedef int AMXAPI (*amx_Register_t)(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number);
526 | int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number)
527 | {
528 | amx_Register_t fn = ((amx_Register_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Register];
529 | return fn(amx, nativelist, number);
530 | }
531 |
532 | typedef int AMXAPI (*amx_Release_t)(AMX *amx, cell amx_addr);
533 | int AMXAPI amx_Release(AMX *amx, cell amx_addr)
534 | {
535 | amx_Release_t fn = ((amx_Release_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Release];
536 | return fn(amx, amx_addr);
537 | }
538 |
539 | typedef int AMXAPI (*amx_SetCallback_t)(AMX *amx, AMX_CALLBACK callback);
540 | int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback)
541 | {
542 | amx_SetCallback_t fn = ((amx_SetCallback_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetCallback];
543 | return fn(amx, callback);
544 | }
545 |
546 | typedef int AMXAPI (*amx_SetDebugHook_t)(AMX *amx, AMX_DEBUG debug);
547 | int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug)
548 | {
549 | amx_SetDebugHook_t fn = ((amx_SetDebugHook_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetDebugHook];
550 | return fn(amx, debug);
551 | }
552 |
553 | typedef int AMXAPI (*amx_SetString_t)(cell *dest, const char *source, int pack, int use_wchar, size_t size);
554 | int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size)
555 | {
556 | amx_SetString_t fn = ((amx_SetString_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetString];
557 | return fn(dest, source, pack, use_wchar, size);
558 | }
559 |
560 | typedef int AMXAPI (*amx_SetUserData_t)(AMX *amx, long tag, void *ptr);
561 | int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr)
562 | {
563 | amx_SetUserData_t fn = ((amx_SetUserData_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetUserData];
564 | return fn(amx, tag, ptr);
565 | }
566 |
567 | typedef int AMXAPI (*amx_StrLen_t)(const cell *cstring, int *length);
568 | int AMXAPI amx_StrLen(const cell *cstring, int *length)
569 | {
570 | amx_StrLen_t fn = ((amx_StrLen_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_StrLen];
571 | return fn(cstring, length);
572 | }
573 |
574 | typedef int AMXAPI (*amx_UTF8Check_t)(const char *string, int *length);
575 | int AMXAPI amx_UTF8Check(const char *string, int *length)
576 | {
577 | amx_UTF8Check_t fn = ((amx_UTF8Check_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Check];
578 | return fn(string, length);
579 | }
580 |
581 | typedef int AMXAPI (*amx_UTF8Get_t)(const char *string, const char **endptr, cell *value);
582 | int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value)
583 | {
584 | amx_UTF8Get_t fn = ((amx_UTF8Get_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Get];
585 | return fn(string, endptr, value);
586 | }
587 |
588 | typedef int AMXAPI (*amx_UTF8Len_t)(const cell *cstr, int *length);
589 | int AMXAPI amx_UTF8Len(const cell *cstr, int *length)
590 | {
591 | amx_UTF8Len_t fn = ((amx_UTF8Len_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Len];
592 | return fn(cstr, length);
593 | }
594 |
595 | typedef int AMXAPI (*amx_UTF8Put_t)(char *string, char **endptr, int maxchars, cell value);
596 | int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value)
597 | {
598 | amx_UTF8Put_t fn = ((amx_UTF8Put_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Put];
599 | return fn(string, endptr, maxchars, value);
600 | }
601 |
602 | #endif
603 |
604 | //----------------------------------------------------------
605 | // EOF
606 |
--------------------------------------------------------------------------------
/lib/sdk/src/plugin.h:
--------------------------------------------------------------------------------
1 | #include
2 |
--------------------------------------------------------------------------------
/samp-chatbot.def:
--------------------------------------------------------------------------------
1 | LIBRARY "samp-gpt"
2 |
3 | EXPORTS
4 | Supports
5 | Load
6 | Unload
7 | AmxLoad
8 | AmxUnload
9 | ProcessTick
10 |
--------------------------------------------------------------------------------
/samp-chatbot.inc:
--------------------------------------------------------------------------------
1 | // Defines
2 |
3 | #define CHAT_GPT 0
4 | #define GEMINI_AI 1
5 | #define LLAMA 2
6 | #define DOUBAO 3
7 | #define DEEPSEEK 4
8 |
9 | #define W1252 0
10 | #define GB2312 1
11 | #define W1251 2
12 |
13 | // Natives
14 |
15 | native SetChatBotEncoding(encoding);
16 | native ClearMemory(id);
17 | native RequestToChatBot(const prompt[], id);
18 | native SelectChatBot(type);
19 | native SetAPIKey(const apiKey[]);
20 | native SetSystemPrompt(const systemPrompt[]);
21 | native SetModel(const model[]);
22 |
23 | // Callbacks
24 |
25 | forward OnChatBotResponse(prompt[], response[], id);
26 |
--------------------------------------------------------------------------------
/samp-chatbot.make:
--------------------------------------------------------------------------------
1 | # GNU Make project makefile autogenerated by Premake
2 | ifndef config
3 | config=release
4 | endif
5 |
6 | ifndef verbose
7 | SILENT = @
8 | endif
9 |
10 | ifndef CC
11 | CC = gcc
12 | endif
13 |
14 | ifndef CXX
15 | CXX = g++
16 | endif
17 |
18 | ifndef AR
19 | AR = ar
20 | endif
21 |
22 | ifndef RESCOMP
23 | ifdef WINDRES
24 | RESCOMP = $(WINDRES)
25 | else
26 | RESCOMP = windres
27 | endif
28 | endif
29 |
30 | ifeq ($(config),debug)
31 | OBJDIR = obj/linux/Debug
32 | TARGETDIR = bin/linux/Debug
33 | TARGET = $(TARGETDIR)/samp-chatbot.so
34 | DEFINES +=
35 | INCLUDES += -Iinclude
36 | CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES)
37 | CFLAGS += $(CPPFLAGS) $(ARCH) -m32 -g -O0 -Wall
38 | CXXFLAGS += $(CFLAGS)
39 | LDFLAGS += -rdynamic -shared -m32 -L./lib/ -l:libcurl.a -l:libssl.a -l:libcrypto.a
40 | LIBS +=
41 | RESFLAGS += $(DEFINES) $(INCLUDES)
42 | LDDEPS +=
43 | LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)
44 | define PREBUILDCMDS
45 | endef
46 | define PRELINKCMDS
47 | endef
48 | define POSTBUILDCMDS
49 | endef
50 | endif
51 |
52 | ifeq ($(config),release)
53 | OBJDIR = obj/linux/Release
54 | TARGETDIR = bin/linux/Release
55 | TARGET = $(TARGETDIR)/samp-chatbot.so
56 | DEFINES += -DNDEBUG
57 | INCLUDES += -Iinclude
58 | CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES)
59 | CFLAGS += $(CPPFLAGS) $(ARCH) -m32 -ffast-math -fmerge-all-constants -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Wall
60 | CXXFLAGS += $(CFLAGS)
61 | LDFLAGS += -s -shared -m32 -L./lib/ -l:libcurl.a -l:libssl.a -l:libcrypto.a
62 | LIBS +=
63 | RESFLAGS += $(DEFINES) $(INCLUDES)
64 | LDDEPS +=
65 | LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)
66 | define PREBUILDCMDS
67 | endef
68 | define PRELINKCMDS
69 | endef
70 | define POSTBUILDCMDS
71 | endef
72 | endif
73 |
74 | OBJECTS := \
75 | $(OBJDIR)/ChatBotHelper.o \
76 | $(OBJDIR)/plugin.o \
77 | $(OBJDIR)/main.o \
78 |
79 | RESOURCES := \
80 |
81 | SHELLTYPE := msdos
82 | ifeq (,$(ComSpec)$(COMSPEC))
83 | SHELLTYPE := posix
84 | endif
85 | ifeq (/bin,$(findstring /bin,$(SHELL)))
86 | SHELLTYPE := posix
87 | endif
88 |
89 | .PHONY: clean prebuild prelink
90 |
91 | all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET)
92 | @:
93 |
94 | $(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES)
95 | @echo Linking samp-chatbot
96 | $(SILENT) $(LINKCMD)
97 | $(POSTBUILDCMDS)
98 |
99 | $(TARGETDIR):
100 | @echo Creating $(TARGETDIR)
101 | ifeq (posix,$(SHELLTYPE))
102 | $(SILENT) mkdir -p $(TARGETDIR)
103 | else
104 | $(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
105 | endif
106 |
107 | $(OBJDIR):
108 | @echo Creating $(OBJDIR)
109 | ifeq (posix,$(SHELLTYPE))
110 | $(SILENT) mkdir -p $(OBJDIR)
111 | else
112 | $(SILENT) mkdir $(subst /,\\,$(OBJDIR))
113 | endif
114 |
115 | clean:
116 | @echo Cleaning samp-chatbot
117 | ifeq (posix,$(SHELLTYPE))
118 | $(SILENT) rm -f $(TARGET)
119 | $(SILENT) rm -rf $(OBJDIR)
120 | else
121 | $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
122 | $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
123 | endif
124 |
125 | prebuild:
126 | $(PREBUILDCMDS)
127 |
128 | prelink:
129 | $(PRELINKCMDS)
130 |
131 | ifneq (,$(PCH))
132 | $(GCH): $(PCH)
133 | @echo $(notdir $<)
134 | ifeq (posix,$(SHELLTYPE))
135 | -$(SILENT) cp $< $(OBJDIR)
136 | else
137 | $(SILENT) xcopy /D /Y /Q "$(subst /,\,$<)" "$(subst /,\,$(OBJDIR))" 1>nul
138 | endif
139 | $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -MF $(@:%.o=%.d) -c "$<"
140 | endif
141 |
142 | $(OBJDIR)/ChatBotHelper.o: src/ChatBotHelper.cpp
143 | @echo $(notdir $<)
144 | $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -MF $(@:%.o=%.d) -c "$<"
145 | $(OBJDIR)/plugin.o: lib/sdk/src/plugin.cpp
146 | @echo $(notdir $<)
147 | $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -MF $(@:%.o=%.d) -c "$<"
148 | $(OBJDIR)/main.o: src/main.cpp
149 | @echo $(notdir $<)
150 | $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -MF $(@:%.o=%.d) -c "$<"
151 |
152 | -include $(OBJECTS:%.o=%.d)
153 |
--------------------------------------------------------------------------------
/samp-chatbot.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SimoSbara/samp-chatbot/49b3efb0bcc694901e90e277eb874b0bd7614b7b/samp-chatbot.rc
--------------------------------------------------------------------------------
/samp-chatbot.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.6.33723.286
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "samp-chatbot", "samp-chatbot.vcxproj", "{98891499-D683-4622-9BCF-DCCEAD0A6674}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x86 = Debug|x86
11 | Release|x86 = Release|x86
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {98891499-D683-4622-9BCF-DCCEAD0A6674}.Debug|x86.ActiveCfg = Debug|Win32
15 | {98891499-D683-4622-9BCF-DCCEAD0A6674}.Debug|x86.Build.0 = Debug|Win32
16 | {98891499-D683-4622-9BCF-DCCEAD0A6674}.Release|x86.ActiveCfg = Release|Win32
17 | {98891499-D683-4622-9BCF-DCCEAD0A6674}.Release|x86.Build.0 = Release|Win32
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {C03F789A-DF46-4A67-9333-C5C7E29FE216}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/samp-chatbot.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {98891499-D683-4622-9BCF-DCCEAD0A6674}
15 | samp-chatbot
16 | Win32Proj
17 | 10.0.20348.0
18 | samp-chatbot
19 |
20 |
21 |
22 | DynamicLibrary
23 | true
24 | false
25 | v143
26 |
27 |
28 | DynamicLibrary
29 | false
30 | true
31 | v143
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | bin\windows\$(Configuration)\
42 | obj\windows\$(Configuration)\
43 | true
44 |
45 |
46 | bin\windows\$(Configuration)\
47 | obj\windows\$(Configuration)\
48 | false
49 |
50 |
51 |
52 | Disabled
53 | include;include\windows
54 | _DEBUG
55 | Level3
56 | true
57 | $(IntDir)\%(RelativeDir)\
58 |
59 |
60 | samp-chatbot.def
61 | true
62 |
63 |
64 | lib/
65 |
66 |
67 |
68 |
69 | MaxSpeed
70 | include;include\windows
71 | NDEBUG
72 | MultiThreadedDLL
73 | false
74 | true
75 | Fast
76 | Level3
77 | true
78 | $(IntDir)\%(RelativeDir)\
79 |
80 |
81 | samp-chatbot.def
82 | true
83 | true
84 | false
85 |
86 |
87 | lib/
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/samp-chatbot.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | lib\sdk\src
6 |
7 |
8 | src
9 |
10 |
11 | src
12 |
13 |
14 |
15 |
16 | lib\sdk\src
17 |
18 |
19 |
20 | src
21 |
22 |
23 | src
24 |
25 |
26 | src
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | {b2b397a5-15c5-4ea4-8c0e-a67582bf7f5e}
35 |
36 |
37 | {5548903e-4fa2-4f6a-aa3a-c301ce9fa775}
38 |
39 |
40 | {6234074f-39c9-474e-b0af-ab35565cd874}
41 |
42 |
43 | {34cf8eef-2043-4f30-aaa2-e4a79fa95e1e}
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/ChatBotHelper.cpp:
--------------------------------------------------------------------------------
1 | #include "ChatBotHelper.h"
2 | #include "EncodingHelper.hpp"
3 | #include "SampHelper.h"
4 |
5 | #ifdef WIN32
6 |
7 | #ifdef _DEBUG
8 | #pragma comment(lib, "libcurl_debug.lib")
9 | #else
10 | #pragma comment(lib, "libcurl.lib")
11 | #endif
12 |
13 | #endif
14 |
15 | static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* response)
16 | {
17 | size_t totalSize = size * nmemb;
18 | response->append((char*)contents, totalSize);
19 | return totalSize;
20 | }
21 |
22 | curl_slist* ChatBotHelper::GetHeader(const ChatBotParams& params)
23 | {
24 | curl_slist* headers = NULL;
25 |
26 | switch (params.botType)
27 | {
28 | case DEEPSEEK:
29 | case DOUBAO:
30 | case GPT:
31 | case LLAMA:
32 | headers = curl_slist_append(headers, "Content-Type: application/json");
33 | headers = curl_slist_append(headers, ("Authorization: Bearer " + params.apikey).c_str());
34 | break;
35 | case GEMINI:
36 | headers = curl_slist_append(headers, "Content-Type: application/json");
37 | break;
38 | }
39 |
40 | return headers;
41 | }
42 |
43 | std::string ChatBotHelper::GetURL(const ChatBotParams& params)
44 | {
45 | switch (params.botType)
46 | {
47 | case GPT:
48 | return "https://api.openai.com/v1/chat/completions";
49 | case GEMINI:
50 | return "https://generativelanguage.googleapis.com/v1beta/models/" + params.model + ":generateContent?key=" + params.apikey;
51 | case LLAMA:
52 | return "https://api.groq.com/openai/v1/chat/completions";
53 | case DOUBAO:
54 | return "https://ark.cn-beijing.volces.com/api/v3/chat/completions";
55 | case DEEPSEEK:
56 | return "https://api.deepseek.com/chat/completions";
57 | }
58 |
59 | return "";
60 | }
61 |
62 | json ChatBotHelper::CreateRequestDocument(const std::string request, const ChatBotParams& params, const ChatMemory& memory)
63 | {
64 | json requestDoc;
65 | int index = 0;
66 |
67 | switch (params.botType)
68 | {
69 | case DEEPSEEK:
70 | case DOUBAO:
71 | case LLAMA:
72 | case GPT:
73 | {
74 | requestDoc["model"] = params.model;
75 |
76 | if (!params.systemPrompt.empty())
77 | {
78 | requestDoc["messages"][index]["role"] = "system";
79 | requestDoc["messages"][index]["content"] = params.systemPrompt;
80 | index++;
81 | }
82 |
83 | //aggiungo memoria
84 | for (int i = 0; i < memory.GetSize(); i++)
85 | {
86 | Message message = memory.GetMessageFromIndex(i);
87 |
88 | requestDoc["messages"][index]["role"] = (message.isBot) ? "assistant" : "user";
89 | requestDoc["messages"][index]["content"] = message.msg;
90 |
91 | index++;
92 | }
93 |
94 | //ultima richiesta
95 | requestDoc["messages"][index]["role"] = "user";
96 | requestDoc["messages"][index]["content"] = request;
97 | requestDoc["temperature"] = 0;
98 | }
99 | break;
100 | case GEMINI:
101 | {
102 | if (!params.systemPrompt.empty())
103 | requestDoc["system_instruction"]["parts"]["text"] = params.systemPrompt;
104 |
105 | //aggiungo memoria
106 | for (int i = 0; i < memory.GetSize(); i++)
107 | {
108 | Message message = memory.GetMessageFromIndex(i);
109 |
110 | requestDoc["contents"][index]["role"] = (message.isBot) ? "model" : "user";
111 | requestDoc["contents"][index]["parts"][0]["text"] = message.msg;
112 |
113 | index++;
114 | }
115 |
116 | requestDoc["contents"][index]["role"] = "user";
117 | requestDoc["contents"][index]["parts"][0]["text"] = request;
118 | }
119 | break;
120 | }
121 |
122 | return requestDoc;
123 | }
124 |
125 | bool ChatBotHelper::DoRequest(std::string& response, const std::string request, const ChatBotParams& params, ChatMemory& memory)
126 | {
127 | CURL* curl = curl_easy_init();
128 |
129 | if (curl)
130 | {
131 | std::string curlResponse;
132 |
133 | curl_slist* headers = GetHeader(params);
134 | std::string url = GetURL(params);
135 |
136 | json requestDataDoc = CreateRequestDocument(request, params, memory);
137 |
138 | std::string requestDataStr = requestDataDoc.dump();
139 |
140 | curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
141 | curl_easy_setopt(curl, CURLOPT_POSTFIELDS, requestDataStr.c_str());
142 | curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, requestDataStr.length());
143 | curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
144 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
145 | curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
146 | curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
147 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, &curlResponse);
148 |
149 | CURLcode res = curl_easy_perform(curl);
150 |
151 | if (res == CURLE_OK)
152 | {
153 | nlohmann::json jresponse = nlohmann::json::parse(curlResponse);
154 | response = GetBotAnswer(params, jresponse);
155 |
156 | //aggiungo nella memoria
157 | memory.AddUserMessage(request);
158 | memory.AddBotMessage(response);
159 | }
160 | else
161 | logprintf("\n\nChat Bot Request Failed! Error: %s\n", curl_easy_strerror(res));
162 |
163 | curl_easy_cleanup(curl);
164 | curl_slist_free_all(headers);
165 |
166 | return res == CURLE_OK;
167 | }
168 |
169 | curl_easy_cleanup(curl);
170 |
171 | return false;
172 | }
173 |
174 | std::string ChatBotHelper::GetBotAnswer(const ChatBotParams& params, nlohmann::json response)
175 | {
176 | if (!response.empty())
177 | {
178 | try
179 | {
180 | std::string answer;
181 |
182 | try
183 | {
184 | nlohmann::json error = response.at("error");
185 |
186 | if (!error.empty())
187 | return response.dump(4).c_str();
188 | }
189 | catch (...)
190 | {
191 | //errore non trovato
192 | }
193 |
194 | switch (params.botType)
195 | {
196 | case DEEPSEEK:
197 | case DOUBAO:
198 | case LLAMA:
199 | case GPT:
200 | answer = response.at("choices").at(0).at("message").at("content");
201 | break;
202 | case GEMINI:
203 | answer = response.at("candidates").at(0).at("content").at("parts").at(0).at("text");
204 | break;
205 | }
206 |
207 | return answer;
208 | }
209 | catch (std::exception &exc)
210 | {
211 | logprintf("ChatBot Plugin Exception GetBotAnswer(): %s\n", exc.what());
212 | logprintf("Chatbot Plugin Exception Response:\n%s", response.dump(4).c_str());
213 |
214 | return response.dump(4).c_str();
215 | }
216 | }
217 |
218 | return "";
219 | }
220 |
--------------------------------------------------------------------------------
/src/ChatBotHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 |
6 | #include "curl/curl.h"
7 |
8 | using json = nlohmann::json;
9 |
10 | enum ChatBots
11 | {
12 | GPT = 0,
13 | GEMINI,
14 | LLAMA,
15 | DOUBAO,
16 | DEEPSEEK,
17 | NUM_CHAT_BOTS
18 | };
19 |
20 | class AIRequest
21 | {
22 | public:
23 | AIRequest()
24 | {
25 | this->id = -1;
26 | }
27 |
28 | AIRequest(int id, std::string prompt)
29 | {
30 | this->id = id;
31 | this->prompt = prompt;
32 | }
33 |
34 | void Clear()
35 | {
36 | this->id = -1;
37 | this->prompt.clear();
38 | }
39 |
40 | std::string GetPrompt()
41 | {
42 | return this->prompt;
43 | }
44 |
45 | int GetID()
46 | {
47 | return this->id;
48 | }
49 |
50 | private:
51 | std::string prompt;
52 | int id; //generic ID
53 | };
54 |
55 | class AIResponse
56 | {
57 | public:
58 | AIResponse(int id, std::string prompt, std::string response)
59 | {
60 | this->id = id;
61 | this->prompt = prompt;
62 | this->response = response;
63 | }
64 |
65 | std::string GetPrompt()
66 | {
67 | return this->prompt;
68 | }
69 |
70 | std::string GetResponse()
71 | {
72 | return this->response;
73 | }
74 |
75 | int GetID()
76 | {
77 | return this->id;
78 | }
79 |
80 | private:
81 | std::string prompt; //prompt from the player
82 | std::string response; //response of gpt
83 | int id; //ID of the original request
84 | };
85 |
86 | struct Message
87 | {
88 | std::string msg;
89 | bool isBot;
90 | };
91 |
92 | struct ChatMemory
93 | {
94 | std::vector messages;
95 |
96 | inline void Clear()
97 | {
98 | messages.clear();
99 | }
100 |
101 | inline bool IsEmpty() const
102 | {
103 | return messages.size() == 0;
104 | }
105 |
106 | inline int GetSize() const
107 | {
108 | return messages.size();
109 | }
110 |
111 | Message GetMessageFromIndex(int index) const
112 | {
113 | if (index < 0 || index >= GetSize())
114 | return Message();
115 |
116 | return messages[index];
117 | }
118 |
119 | void AddBotMessage(std::string msg)
120 | {
121 | Message m;
122 | m.msg = msg;
123 | m.isBot = true;
124 |
125 | messages.push_back(m);
126 | }
127 |
128 | void AddUserMessage(std::string msg)
129 | {
130 | Message m;
131 | m.msg = msg;
132 | m.isBot = false;
133 |
134 | messages.push_back(m);
135 | }
136 | };
137 |
138 | struct ChatBotParams
139 | {
140 | std::string apikey;
141 | std::string systemPrompt;
142 | std::string model;
143 | int botType; //enum ChatBots
144 | int encoding; //enum Encodings
145 | };
146 |
147 | class ChatBotHelper
148 | {
149 | public:
150 | static bool DoRequest(std::string& response, const std::string request, const ChatBotParams& params, ChatMemory& memory);
151 |
152 | private:
153 | static std::string GetBotAnswer(const ChatBotParams& params, nlohmann::json response);
154 |
155 | static nlohmann::json CreateRequestDocument(const std::string request, const ChatBotParams& params, const ChatMemory& memory);
156 |
157 | static curl_slist* GetHeader(const ChatBotParams& params);
158 | static std::string GetURL(const ChatBotParams& params);
159 | };
--------------------------------------------------------------------------------
/src/EncodingHelper.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include "SampHelper.h"
10 |
11 | #ifdef _WIN32
12 | #include
13 | #else
14 | #include
15 | #include
16 | #endif
17 |
18 | enum Encodings
19 | {
20 | W1252 = 0, //windows 1252 for latin
21 | GB2312, //GB2312 for simplified chinese
22 | W1251, //windows 1251 for cyrilic
23 | NUM_ENCODINGS
24 | };
25 |
26 | //IT: artigianale...
27 | //EN: homemade
28 | class EncodingHelper
29 | {
30 | public:
31 | //maledette lingue diverse!!! (da encoding scelto a utf8)
32 | static std::string ConvertToUTF8(std::string input, uint8_t inputEncoding)
33 | {
34 | #ifdef _WIN32
35 | int inputCodePage;
36 |
37 | switch (inputEncoding)
38 | {
39 | default:
40 | case W1252:
41 | {
42 | inputCodePage = 1252;
43 | break;
44 | }
45 | case GB2312: inputCodePage = 936; break;
46 | case W1251: inputCodePage = 1251; break;
47 | }
48 |
49 | //verifico se va bene
50 | int wideLen = MultiByteToWideChar(inputCodePage, 0, input.c_str(), input.size(), nullptr, 0);
51 |
52 | if (wideLen == 0)
53 | {
54 | logprintf("\n\nChatBot UTF8 conversion error: wideLen = 0\n");
55 | return "";
56 | }
57 |
58 | std::vector utf16Str(wideLen);
59 | MultiByteToWideChar(inputCodePage, 0, input.c_str(), input.size(), utf16Str.data(), wideLen);
60 |
61 | //verifico se va bene da utf16 a utf8
62 | int utf8Len = WideCharToMultiByte(CP_UTF8, 0, utf16Str.data(), wideLen, nullptr, 0, nullptr, nullptr);
63 |
64 | if (utf8Len == 0)
65 | {
66 | logprintf("\n\nChatBot UTF8 conversion error: utf8Len = 0\n");
67 | return "";
68 | }
69 |
70 | std::vector utf8Str(utf8Len);
71 | WideCharToMultiByte(CP_UTF8, 0, utf16Str.data(), wideLen, utf8Str.data(), utf8Len, nullptr, nullptr);
72 |
73 | return std::string(utf8Str.begin(), utf8Str.end());
74 | #else
75 | std::string inputCodePage;
76 |
77 | switch (inputEncoding)
78 | {
79 | default:
80 | case W1252:
81 | {
82 | inputCodePage = "WINDOWS-1252";
83 | break;
84 | }
85 | case GB2312: inputCodePage = "GB2312"; break;
86 | case W1251: inputCodePage = "WINDOWS-1251"; break;
87 | }
88 |
89 | iconv_t handle = iconv_open("UTF8", inputCodePage.c_str());
90 |
91 | if (handle == (iconv_t)-1)
92 | {
93 | logprintf("\n\nChatBot UTF8 conversion error: iconv_open failed\n");
94 | return "";
95 | }
96 |
97 | size_t outputLen = input.size() * 4; //per stare sereni
98 | char* output = new char[outputLen];
99 |
100 | if (!output)
101 | {
102 | iconv_close(handle);
103 | logprintf("\n\nChatBot UTF8 conversion error: output malloc failed\n");
104 | return "";
105 | }
106 |
107 | memset(output, 0, outputLen);
108 |
109 | char* inBuf = (char*)input.c_str();
110 | char* outBuf = output;
111 | size_t inBytesLeft = input.size();
112 | size_t outBytesLeft = outputLen;
113 |
114 | if (iconv(handle, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft) == (size_t)-1)
115 | {
116 | std::string err;
117 |
118 | if(errno == E2BIG)
119 | err = "There is not sufficient room at *outbuf.";
120 | else if(errno == EILSEQ)
121 | err = "An invalid multibyte sequence has been encountered in the input.";
122 | else if(errno == EINVAL)
123 | err = "An incomplete multibyte sequence has been encountered in the input.";
124 | else
125 | err = "Generic Error";
126 |
127 | logprintf("\n\nChatBot UTF8 conversion iconv failed: %s\n", err.c_str());
128 | delete[] output;
129 | iconv_close(handle);
130 | return "";
131 | }
132 |
133 | iconv_close(handle);
134 |
135 | std::string result(output, strlen(output));
136 | delete[] output;
137 |
138 | return result;
139 | #endif
140 | }
141 |
142 | //gli accenti sono micidiali!!!! (da utf8 a l'encoding scelto)
143 | static std::string ConvertToWideByte(std::string input, uint8_t outputEncoding)
144 | {
145 | #ifdef _WIN32
146 | int outputCodePage;
147 |
148 | switch (outputEncoding)
149 | {
150 | default:
151 | case W1252:
152 | {
153 | outputCodePage = 1252;
154 | break;
155 | }
156 | case GB2312: outputCodePage = 936; break;
157 | case W1251: outputCodePage = 1251; break;
158 | }
159 |
160 | //verifico se va bene
161 | int wideLen = MultiByteToWideChar(CP_UTF8, 0, input.c_str(), input.size(), nullptr, 0);
162 |
163 | if (wideLen == 0)
164 | {
165 | logprintf("\n\nChatBot WideByte conversion error: wideLen = 0\n");
166 | return "";
167 | }
168 |
169 | std::vector utf16Str(wideLen);
170 | MultiByteToWideChar(CP_UTF8, 0, input.c_str(), input.size(), utf16Str.data(), wideLen);
171 |
172 | //verifico se va bene da utf16 a encoding scelto
173 | int encLen = WideCharToMultiByte(outputCodePage, 0, utf16Str.data(), wideLen, nullptr, 0, nullptr, nullptr);
174 |
175 | if (encLen == 0)
176 | {
177 | logprintf("\n\nChatBot WideByte conversion error: encLen = 0\n");
178 | return "";
179 | }
180 |
181 | std::vector encStr(encLen);
182 | WideCharToMultiByte(outputCodePage, 0, utf16Str.data(), wideLen, encStr.data(), encLen, nullptr, nullptr);
183 |
184 | return std::string(encStr.begin(), encStr.end());
185 | #else
186 | std::string outputCodePage;
187 |
188 | switch (outputEncoding)
189 | {
190 | default:
191 | case W1252:
192 | {
193 | outputCodePage = "WINDOWS-1252";
194 | break;
195 | }
196 | case GB2312: outputCodePage = "GB2312"; break;
197 | case W1251: outputCodePage = "WINDOWS-1251"; break;
198 | }
199 |
200 | iconv_t handle = iconv_open(outputCodePage.c_str(), "UTF8");
201 |
202 | if (handle == (iconv_t)-1)
203 | {
204 | logprintf("\n\nChatBot WideByte conversion error: iconv_open failed\n");
205 | return "";
206 | }
207 |
208 | size_t outputLen = input.size() * 4; //per stare sereni
209 | char* output = new char[outputLen];
210 |
211 | if (!output)
212 | {
213 | iconv_close(handle);
214 | logprintf("\n\nChatBot WideByte conversion error: output malloc failed\n");
215 | return "";
216 | }
217 |
218 | memset(output, 0, outputLen);
219 |
220 | char* inBuf = (char*)input.c_str();
221 | char* outBuf = output;
222 | size_t inBytesLeft = input.size();
223 | size_t outBytesLeft = outputLen;
224 |
225 | if (iconv(handle, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft) == (size_t)-1)
226 | {
227 | std::string err;
228 |
229 | if(errno == E2BIG)
230 | err = "There is not sufficient room at *outbuf.";
231 | else if(errno == EILSEQ)
232 | err = "An invalid multibyte sequence has been encountered in the input.";
233 | else if(errno == EINVAL)
234 | err = "An incomplete multibyte sequence has been encountered in the input.";
235 | else
236 | err = "Generic Error";
237 |
238 | logprintf("\n\nChatBot WideByte conversion iconv failed: %s\n", err.c_str());
239 |
240 | delete[] output;
241 | iconv_close(handle);
242 | return "";
243 | }
244 |
245 | iconv_close(handle);
246 |
247 | std::string result(output, strlen(output));
248 | delete[] output;
249 |
250 | return result;
251 | #endif
252 | }
253 | };
254 |
--------------------------------------------------------------------------------
/src/SampHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #define PLUGIN_VERSION "v1.7.5"
4 |
5 | #include
6 | #include
7 |
8 | #ifdef _WIN32
9 | #include
10 | #endif
11 |
12 | typedef void (*logprintf_t)(const char*, ...);
13 |
14 | #define CHECK_PARAMS(m, n) \
15 | if (params[0] != (m * 4)) \
16 | { \
17 | logprintf("*** %s: Expecting %d parameter(s), but found %d", n, m, params[0] / 4); \
18 | return 0; \
19 | }
20 |
21 | static logprintf_t logprintf;
22 |
23 | extern void* pAMXFunctions;
24 | static std::set interfaces;
--------------------------------------------------------------------------------
/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include "EncodingHelper.hpp"
10 | #include "SampHelper.h"
11 | #include "ChatBotHelper.h"
12 |
13 | static std::queue requestes;
14 | static std::queue responses;
15 |
16 | static std::map chatMemories;
17 | static ChatBotParams botParams;
18 |
19 | static std::mutex requestLock;
20 | static std::mutex responseLock;
21 | static std::mutex paramsLock;
22 | static std::mutex memoryLock;
23 |
24 | static std::thread requestsThread;
25 | static std::atomic running;
26 |
27 | static void DoRequest(std::string prompt, int id)
28 | {
29 | std::string answer;
30 |
31 | paramsLock.lock();
32 | ChatBotParams curParams = botParams;
33 | paramsLock.unlock();
34 |
35 | ChatMemory memory;
36 |
37 | //lo trovo?
38 | memoryLock.lock();
39 | if (chatMemories.find(id) != chatMemories.end())
40 | memory = chatMemories[id];
41 | memoryLock.unlock();
42 |
43 | if (ChatBotHelper::DoRequest(answer, prompt, curParams, memory))
44 | {
45 | AIResponse response(id, prompt, answer);
46 |
47 | responseLock.lock();
48 | responses.push(response);
49 | responseLock.unlock();
50 |
51 | //aggiorno la memoria
52 | memoryLock.lock();
53 | chatMemories[id] = memory;
54 | memoryLock.unlock();
55 | }
56 | }
57 |
58 | static void RequestsThread()
59 | {
60 | using namespace std::chrono_literals;
61 | AIRequest curRequest;
62 |
63 | while (running)
64 | {
65 | requestLock.lock();
66 |
67 | if (!requestes.empty())
68 | {
69 | curRequest = requestes.front();
70 | requestes.pop();
71 | }
72 |
73 | requestLock.unlock();
74 |
75 | std::string prompt = curRequest.GetPrompt();
76 | int id = curRequest.GetID();
77 |
78 | if (!prompt.empty())
79 | {
80 | #ifdef _DEBUG
81 | paramsLock.lock();
82 | ChatBotParams curParams = botParams;
83 | paramsLock.unlock();
84 |
85 | std::string encPrompt = EncodingHelper::ConvertToWideByte(prompt, curParams.encoding);
86 | logprintf("\nnew request: %s\n", encPrompt.c_str());
87 | #endif
88 | DoRequest(prompt, id);
89 | curRequest.Clear();
90 | }
91 | else
92 | std::this_thread::sleep_for(10ms);
93 |
94 | curRequest.Clear();
95 | }
96 | }
97 |
98 | void InitParams()
99 | {
100 | botParams.model = "gpt-3.5-turbo"; //GPT!!! goooo
101 | botParams.botType = GPT; //0 - GPT, 1 - Gemini, 2 - LLAMA (https://groq.com/), 3 - DOUBAO
102 | botParams.encoding = W1252; //windows 1252
103 | }
104 |
105 | PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
106 | {
107 | return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES | SUPPORTS_PROCESS_TICK;
108 | }
109 |
110 | PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
111 | {
112 | pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
113 | logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];
114 | logprintf("\n\nChatBot API Plugin %s by SimoSbara loaded\n", PLUGIN_VERSION);
115 |
116 | InitParams();
117 |
118 | running = true;
119 | requestsThread = std::thread(RequestsThread);
120 | requestsThread.detach();
121 |
122 | return true;
123 | }
124 |
125 | PLUGIN_EXPORT void PLUGIN_CALL Unload()
126 | {
127 | running = false;
128 |
129 | logprintf("\n\nChatBot API Plugin %s by SimoSbara unloaded\n", PLUGIN_VERSION);
130 | }
131 |
132 | static cell AMX_NATIVE_CALL n_SetChatBotEncoding(AMX* amx, cell* params)
133 | {
134 | CHECK_PARAMS(1, "SetChatBotEncoding"); //encoding int
135 |
136 | int newEncoding = static_cast(params[1]);
137 |
138 | if (newEncoding >= W1252 && newEncoding < NUM_ENCODINGS)
139 | {
140 | paramsLock.lock();
141 | botParams.encoding = newEncoding;
142 | paramsLock.unlock();
143 |
144 | return 1;
145 | }
146 |
147 | return 0;
148 | }
149 |
150 | static cell AMX_NATIVE_CALL n_ClearMemory(AMX* amx, cell* params)
151 | {
152 | CHECK_PARAMS(1, "ClearMemory"); //id int
153 |
154 | int id = static_cast(params[1]);
155 |
156 | memoryLock.lock();
157 | if (chatMemories.find(id) != chatMemories.end())
158 | {
159 | chatMemories[id].Clear();
160 | memoryLock.unlock();
161 |
162 | return 1;
163 | }
164 |
165 | memoryLock.unlock();
166 |
167 | return 0;
168 | }
169 |
170 | static cell AMX_NATIVE_CALL n_RequestToChatBot(AMX* amx, cell* params)
171 | {
172 | char* pRequest = NULL;
173 |
174 | CHECK_PARAMS(2, "RequestToChatBot"); //id int, request string
175 |
176 | amx_StrParam(amx, params[1], pRequest);
177 |
178 | int id = static_cast(params[2]);
179 |
180 | if (pRequest)
181 | {
182 | paramsLock.lock();
183 | int encoding = botParams.encoding;
184 | paramsLock.unlock();
185 |
186 | std::string requestStr = EncodingHelper::ConvertToUTF8(pRequest, encoding);
187 |
188 | AIRequest newRequest(id, requestStr);
189 |
190 | requestLock.lock();
191 | requestes.push(newRequest);
192 | requestLock.unlock();
193 |
194 | return 1;
195 | }
196 |
197 | return 0;
198 | }
199 |
200 | static cell AMX_NATIVE_CALL n_SelectChatBot(AMX* amx, cell* params)
201 | {
202 | CHECK_PARAMS(1, "SelectChatBot"); //api key string
203 |
204 | int type = static_cast(params[1]);
205 |
206 | if (type >= GPT && type < NUM_CHAT_BOTS)
207 | {
208 | paramsLock.lock();
209 | botParams.botType = type;
210 | paramsLock.unlock();
211 |
212 | return 1;
213 | }
214 |
215 | return 0;
216 | }
217 |
218 | static cell AMX_NATIVE_CALL n_SetAPIKey(AMX* amx, cell* params)
219 | {
220 | char* pKey = NULL;
221 |
222 | CHECK_PARAMS(1, "SetAPIKey"); //api key string
223 | amx_StrParam(amx, params[1], pKey);
224 |
225 | if (pKey)
226 | {
227 | paramsLock.lock();
228 | botParams.apikey = std::string(pKey);
229 | paramsLock.unlock();
230 |
231 | return 1;
232 | }
233 |
234 | return 0;
235 | }
236 |
237 | static cell AMX_NATIVE_CALL n_SetSystemPrompt(AMX* amx, cell* params)
238 | {
239 | char* pPrompt = NULL;
240 |
241 | CHECK_PARAMS(1, "SetSystemPrompt"); //system prompt string
242 | amx_StrParam(amx, params[1], pPrompt);
243 |
244 | paramsLock.lock();
245 |
246 | if (pPrompt)
247 | botParams.systemPrompt = EncodingHelper::ConvertToUTF8(pPrompt, botParams.encoding);
248 | else
249 | botParams.systemPrompt.clear();
250 |
251 | paramsLock.unlock();
252 |
253 | return 1;
254 | }
255 |
256 | static cell AMX_NATIVE_CALL n_SetModel(AMX* amx, cell* params)
257 | {
258 | char* pModel = NULL;
259 |
260 | CHECK_PARAMS(1, "SetModel"); //chatbot model string
261 | amx_StrParam(amx, params[1], pModel);
262 |
263 | if (pModel)
264 | {
265 | paramsLock.lock();
266 | botParams.model = std::string(pModel);
267 | paramsLock.unlock();
268 |
269 | return 1;
270 | }
271 |
272 | return 0;
273 | }
274 |
275 | AMX_NATIVE_INFO natives[] =
276 | {
277 | { "SetChatBotEncoding", n_SetChatBotEncoding },
278 | { "ClearMemory", n_ClearMemory },
279 | { "RequestToChatBot", n_RequestToChatBot },
280 | { "SelectChatBot", n_SelectChatBot },
281 | { "SetAPIKey", n_SetAPIKey },
282 | { "SetSystemPrompt", n_SetSystemPrompt },
283 | { "SetModel", n_SetModel },
284 | { 0, 0 }
285 | };
286 |
287 | PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx)
288 | {
289 | interfaces.insert(amx);
290 | return amx_Register(amx, natives, -1);
291 | }
292 |
293 | PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx)
294 | {
295 | interfaces.erase(amx);
296 | return AMX_ERR_NONE;
297 | }
298 |
299 | PLUGIN_EXPORT void PLUGIN_CALL ProcessTick()
300 | {
301 | if (!responses.empty())
302 | {
303 | responseLock.lock();
304 | AIResponse response = responses.front();
305 | responses.pop();
306 | responseLock.unlock();
307 |
308 | paramsLock.lock();
309 | int encoding = botParams.encoding;
310 | paramsLock.unlock();
311 |
312 | //conversione a encoding originale
313 | std::string resp = EncodingHelper::ConvertToWideByte(response.GetResponse(), encoding);
314 | std::string prompt = EncodingHelper::ConvertToWideByte(response.GetPrompt(), encoding);
315 |
316 | #ifdef _DEBUG
317 | logprintf("\nnew response: %s\n", resp.c_str());
318 | #endif
319 |
320 | for (std::set::iterator a = interfaces.begin(); a != interfaces.end(); a++)
321 | {
322 | cell amxAddresses[2] = { 0 };
323 | int amxIndex = 0;
324 |
325 | if (!amx_FindPublic(*a, "OnChatBotResponse", &amxIndex))
326 | {
327 | //parametri al contrario
328 | amx_Push(*a, response.GetID());
329 | amx_PushString(*a, &amxAddresses[0], NULL, resp.c_str(), 0, 0);
330 | amx_PushString(*a, &amxAddresses[1], NULL, prompt.c_str(), 0, 0);
331 | amx_Exec(*a, NULL, amxIndex);
332 | amx_Release(*a, amxAddresses[0]);
333 | amx_Release(*a, amxAddresses[1]);
334 | }
335 | }
336 | }
337 | }
338 |
--------------------------------------------------------------------------------