@@ -133,21 +133,6 @@ import core.vararg : va_list;
133
133
extern (C ):
134
134
nothrow :
135
135
136
- // #ifndef OPENSSL_NO_ERR
137
- // #define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e)
138
- // #else
139
- // #define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0)
140
- // #endif
141
- version (OPENSSL_NO_ERR) {
142
- void ERR_PUT_error ()(int a, int b,int c,const (char )* d,int e) {
143
- ERR_put_error(a,b,c,null ,0 );
144
- }
145
- } else {
146
- alias ERR_put_error ERR_PUT_error;
147
- }
148
-
149
- // #include <errno.h>
150
-
151
136
enum ERR_TXT_MALLOCED = 0x01 ;
152
137
enum ERR_TXT_STRING = 0x02 ;
153
138
@@ -327,7 +312,51 @@ struct ERR_string_data_st {
327
312
}
328
313
alias ERR_string_data_st ERR_STRING_DATA ;
329
314
330
- void ERR_put_error (int lib, int func,int reason,const (char )* file,int line);
315
+ static if (OPENSSL_VERSION_BEFORE (3 , 0 , 0 ))
316
+ {
317
+ void ERR_put_error (int lib, int func,int reason,const (char )* file,int line);
318
+ alias ERR_PUT_error = ERR_put_error;
319
+ }
320
+ else
321
+ {
322
+ // New Error API
323
+
324
+ // 12 lines and some on an 80 column terminal
325
+ enum ERR_MAX_DATA_SIZE = 1024 ;
326
+
327
+ /* Building blocks */
328
+ void ERR_new ();
329
+ void ERR_set_debug (const (char )* file, int line, const (char )* func);
330
+ void ERR_set_error (int lib, int reason, const (char )* fmt, ... );
331
+ void ERR_vset_error (int lib, int reason, const (char )* fmt, va_list args);
332
+
333
+ // Due to the API of those macro, we are forced to use CT arguments for FILE/LINE/FUNC
334
+ // This is not ideal as it creates lots of template instantiations
335
+ // Prefer using individual functions.
336
+ auto ERR_raise (string file = __FILE__ , int line = __LINE__ , string func = __FUNCTION__ )
337
+ (int lib, int reason)
338
+ {
339
+ return ERR_raise_data! (file, line, func)(lib, reason, null );
340
+ }
341
+
342
+ auto ERR_raise_data (string file = __FILE__ , int line = __LINE__ , string func = __FUNCTION__ )
343
+ (int lib, int reason, const (char )* fmt, ... )
344
+ {
345
+ ERR_new();
346
+ ERR_set_debug(file.ptr, line, func.ptr);
347
+ ERR_set_error(lib, reason, fmt);
348
+ }
349
+
350
+ // Deprecated in v3.0.0 and re-implemented as macro
351
+ auto ERR_put_error () (int lib, int func, int reason, const (char )* file, int line)
352
+ {
353
+ ERR_new();
354
+ ERR_set_debug(file, line, null );
355
+ ERR_set_error(lib, reason, null );
356
+ }
357
+ alias ERR_PUT_error = ERR_put_error;
358
+ }
359
+
331
360
void ERR_set_error_data (char * data,int flags);
332
361
333
362
c_ulong ERR_get_error ();
@@ -358,6 +387,11 @@ void ERR_print_errors(BIO* bp);
358
387
}
359
388
void ERR_add_error_data (int num, ... );
360
389
void ERR_add_error_vdata (int num, va_list args);
390
+ static if (OPENSSL_VERSION_AT_LEAST (3 , 0 , 0 ))
391
+ {
392
+ void ERR_add_error_txt (const (char )* sepr, const (char )* txt);
393
+ void ERR_add_error_mem_bio (const (char )* sep, BIO * bio);
394
+ }
361
395
void ERR_load_strings (int lib,ERR_STRING_DATA [] str);
362
396
void ERR_unload_strings (int lib,ERR_STRING_DATA [] str);
363
397
void ERR_load_ERR_strings ();
0 commit comments