-
Notifications
You must be signed in to change notification settings - Fork 51
/
sscanf.h
126 lines (106 loc) · 4.01 KB
/
sscanf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
* sscanf 2.15.1
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the sscanf 2.0 SA:MP plugin.
*
* The Initial Developer of the Original Code is Alex "Y_Less" Cole.
* Portions created by the Initial Developer are Copyright (c) 2022
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Cheaterman
* DEntisT
* Emmet_
* karimcambridge
* kalacsparty
* Kirima
* leHeix
* maddinat0r
* Southclaws
* Y_Less
* ziggi
*
* Special Thanks to:
*
* SA:MP Team past, present, and future.
* maddinat0r, for hosting the repo for a very long time.
* Emmet_, for his efforts in maintaining it for almost a year.
*/
#pragma once
#define SSCANF_VERSION_MAJOR 2
#define SSCANF_VERSION_MINOR 15
#define SSCANF_VERSION_BUILD 1
#include <stdint.h>
typedef
void (* logprintf_t)(char const *, ...);
typedef
char * (* GetServer_t)();
#define SSCANF_FAIL_RETURN (-1)
#define SSCANF_CONT_RETURN (((unsigned int)-1) >> 1)
#define SSCANF_TRUE_RETURN (0)
// Capped for memory reasons. I chose 32 because it's a reasonable length for
// many uses and frankly if they get warnings and don't fix them it's their
// own fault if they have problems with strings!
#define SSCANF_MAX_LENGTH (32)
// 32 bit special float values.
#define FLOAT_INFINITY ((cell)0x7F800000)
#define FLOAT_NEG_INFINITY ((cell)0xFF800000)
#define FLOAT_NAN ((cell)0xFFFFFFFF)
#define FLOAT_NAN_E ((cell)0x7FFFFFFF)
#define FLOAT_NEGATIVE_INFINITY ((cell)FLOAT_NEG_INFINITY)
#define SscanfWarning(code,str,...) \
do \
{ \
if (SscanfErrLine()) logprintf("sscanf warning (%s:%d): " #str, gCallFile, gCallLine, ##__VA_ARGS__); \
else logprintf("%s warning (`%s`): " #str, gCallFile, gFormat, ##__VA_ARGS__); \
SetErrorCode(code); \
} \
while (0)
#define SscanfError(code,str,...) \
do \
{ \
if (SscanfErrLine()) logprintf("sscanf error (%s:%d): " #str, gCallFile, gCallLine, ##__VA_ARGS__); \
else logprintf("%s error (`%s`): " #str, gCallFile, gFormat, ##__VA_ARGS__); \
SetErrorCode(code); \
} \
while (0)
bool SscanfErrLine();
typedef int32_t cell;
extern char
* gFormat;
extern const char
* gCallFile;
extern int
gCallLine;
extern cell
* gCallResolve;
#if defined __cplusplus
#define PAWN_NATIVE_EXTERN extern "C"
#else
#define PAWN_NATIVE_EXTERN extern
#endif
#if defined _WIN32 || defined __CYGWIN__
#define PAWN_NATIVE_DLLEXPORT __declspec(dllexport)
#define PAWN_NATIVE_DLLIMPORT __declspec(dllimport)
#define PAWN_NATIVE_API __cdecl
#elif defined __linux__ || defined __APPLE__
#define PAWN_NATIVE_DLLEXPORT __attribute__((visibility("default")))
#define PAWN_NATIVE_DLLIMPORT
#define PAWN_NATIVE_API __attribute__((cdecl))
#endif
#define PAWN_NATIVE_EXPORT PAWN_NATIVE_EXTERN PAWN_NATIVE_DLLEXPORT
#define PAWN_NATIVE_IMPORT PAWN_NATIVE_EXTERN PAWN_NATIVE_DLLIMPORT
#include "error.h"