forked from SWI-Prolog/swipl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSWI-Prolog.h
1490 lines (1241 loc) · 55.6 KB
/
SWI-Prolog.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: [email protected]
WWW: http://www.swi-prolog.org
Copyright (c) 2008-2024, University of Amsterdam
VU University Amsterdam
SWI-Prolog Solutions b.v.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SWI_PROLOG_H
#define _SWI_PROLOG_H
#ifndef __SWI_PROLOG__ /* use this to switch on Prolog dialect */
#define __SWI_PROLOG__ /* normally defined by the swipl-ld compiler driver */
#endif
#ifndef __WINDOWS__
#if defined(_MSC_VER) || defined(__MINGW32__)
#define __WINDOWS__ 1
#endif
#endif
#include <stdarg.h>
#include <stdlib.h> /* get size_t */
#include <stddef.h>
#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/* PLVERSION: 10000 * <Major> + 100 * <Minor> + <Patch> */
/* PLVERSION_TAG: a string, normally "", but for example "rc1" */
#ifndef PLVERSION
#define PLVERSION 90209
#endif
#ifndef PLVERSION_TAG
#define PLVERSION_TAG ""
#endif
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This number is incremented when the SWI-Prolog PL_*() functions or one
of the data types is modified such that old binary extensions cannot run
reliably with the current version. This version is introduced in
SWI-Prolog 8.1.30. The most recent violation of compatibility was
between versions 8.1.21 and 8.1.22 with the introduction of rational
numbers are atomic type.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define PL_FLI_VERSION 2 /* PL_*() functions */
#define PL_REC_VERSION 3 /* PL_record_external(), fastrw */
#define PL_QLF_LOADVERSION 68 /* load all versions later >= X */
#define PL_QLF_VERSION 69 /* save version number */
/*******************************
* EXPORT *
*******************************/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Traditional and ELF-based Unix systems don't need all this, but COFF
based systems need to import and export symbols explicitely from
executables and shared objects (DLL). On some systems (e.g. AIX) this is
achieved using import/export files, on Windows this is achieved using
special declarations on exported symbols. So, a symbol is local
(static), shared between the objects building an executable or DLL (no
special declaration) or exported from the executable or DLL.
Both using native Microsoft MSVC as well as recent Cygwin (tested 1.1)
compilers support __declspec(...) for exporting symbols.
As SWI-Stream.h can be included separately or together with this file we
duplicated this stuff.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef _PL_EXPORT_DONE
#define _PL_EXPORT_DONE
#if defined(_MSC_VER) || defined(__MINGW32__)
#define HAVE_DECLSPEC 1
#else
#if !defined(HAVE_VISIBILITY_ATTRIBUTE) && (__GNUC__ >= 4 || defined(__clang__))
#define HAVE_VISIBILITY_ATTRIBUTE 1
#endif
#endif
#ifdef HAVE_DECLSPEC
# ifdef PL_KERNEL
#define PL_EXPORT(type) __declspec(dllexport) extern type
#define PL_EXPORT_DATA(type) __declspec(dllexport) extern type
# else
# ifdef __BORLANDC__
#define PL_EXPORT(type) type _stdcall
#define PL_EXPORT_DATA(type) extern type
# else
# ifdef __MINGW32__
#define PL_EXPORT(type) extern type
#define PL_EXPORT_DATA(type) extern type
# else
#define PL_EXPORT(type) extern type
#define PL_EXPORT_DATA(type) __declspec(dllimport) type
# endif
# endif
#define install_t __declspec(dllexport) void
# endif
#else /*!HAVE_DECLSPEC*/
# ifdef PL_SO_EXPORT
#define PL_EXPORT(type) extern PL_SO_EXPORT type
#define PL_EXPORT_DATA(type) extern PL_SO_EXPORT type
# else
#define PL_EXPORT(type) extern type
#define PL_EXPORT_DATA(type) extern type
# endif
#ifdef HAVE_VISIBILITY_ATTRIBUTE
#define install_t __attribute__((visibility("default"))) void
#else
#define install_t void
#endif
#endif /*HAVE_DECLSPEC*/
#endif /*_PL_EXPORT_DONE*/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The following two macros are used to define types that are internal to the
SWI-Prolog library but appear in public API signatures. None of these
types should be used by derived code; the mangling done by PL_OPAQUE is
intended solely to avoid clutter in global type namespaces and should not
be relied upon to remain unchanged across versions.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef PL_OPAQUE
#define PL_OPAQUE(type) __PL_ ## type
#define _DEFINED_PL_OPAQUE
#endif
#ifndef PL_STRUCT
#define PL_STRUCT(name) struct PL_OPAQUE(name)
#define _DEFINED_PL_STRUCT
#endif
/* Shorthand defines, for brevity in this file. They get undefined
* at the bottom, so don't use them in #define definitions (which
* use lazy evaluation) or in derived code.
*/
#define _PLQ PL_OPAQUE
#define _PLS PL_STRUCT
/*******************************
* GCC ATTRIBUTES *
*******************************/
#if __GNUC__ >= 4
#define WUNUSED __attribute__((warn_unused_result))
#define WDEPRECATED __attribute__((deprecated))
#else
#define WUNUSED
#define WDEPRECATED
#endif
/*******************************
* TYPES *
*******************************/
typedef uintptr_t _PLQ(word); /* Anonymous ptr-sized object*/
#ifndef PL_HAVE_ATOM_T
#define PL_HAVE_ATOM_T
typedef uintptr_t atom_t; /* Prolog atom */
#endif
typedef _PLQ(word) functor_t; /* Name/arity pair */
typedef uintptr_t _PLQ(code); /* Prolog bytecode type */
typedef _PLS(module) * module_t; /* Prolog module */
typedef _PLS(procedure) *predicate_t; /* Prolog procedure */
typedef _PLS(record) * record_t; /* Prolog recorded term */
#ifndef PL_HAVE_TERM_T
#define PL_HAVE_TERM_T
typedef uintptr_t term_t; /* opaque term handle */
#endif
typedef _PLS(queryRef) *qid_t; /* opaque query handle */
typedef uintptr_t PL_fid_t; /* opaque foreign context handle */
typedef _PLS(foreign_context) *control_t; /* non-deterministic control arg */
typedef _PLS(PL_local_data) *PL_engine_t; /* opaque engine handle */
typedef uintptr_t PL_atomic_t; /* same a word */
typedef uintptr_t foreign_t; /* return type of foreign functions */
typedef wchar_t pl_wchar_t; /* Prolog wide character */
#if defined(__cplusplus) || __STDC_VERSION__ > 201710L
typedef void * pl_function_t; /* pass function as void* */
#else
typedef foreign_t (*pl_function_t)(); /* foreign language functions */
#endif
typedef uintptr_t buf_mark_t; /* buffer mark handle */
#define fid_t PL_fid_t /* avoid AIX name-clash */
typedef struct io_stream IOSTREAM; /* fully defined in SWI-Stream.h */
/* values for PL_get_term_value() */
typedef union
{ int64_t i; /* PL_INTEGER */
double f; /* PL_FLOAT */
char * s; /* PL_STRING */
atom_t a; /* PL_ATOM */
struct /* PL_TERM */
{ atom_t name;
size_t arity;
} t;
} term_value_t;
#ifndef TRUE
#define TRUE (1)
#define FALSE (0)
#endif
/*******************************
* TERM-TYPE CONSTANTS *
*******************************/
/* PL_unify_term() arguments */
#define PL_VARIABLE (1) /* nothing */
#define PL_ATOM (2) /* const char * */
#define PL_INTEGER (3) /* int */
#define PL_RATIONAL (4) /* rational number */
#define PL_FLOAT (5) /* double */
#define PL_STRING (6) /* const char * */
#define PL_TERM (7)
#define PL_NIL (8) /* The constant [] */
#define PL_BLOB (9) /* non-atom blob */
#define PL_LIST_PAIR (10) /* [_|_] term */
/* PL_unify_term() */
#define PL_FUNCTOR (11) /* functor_t, arg ... */
#define PL_LIST (12) /* length, arg ... */
#define PL_CHARS (13) /* const char * */
#define PL_POINTER (14) /* void * */
/* PlArg::PlArg(text, type) */
#define PL_CODE_LIST (15) /* [ascii...] */
#define PL_CHAR_LIST (16) /* [h,e,l,l,o] */
#define PL_BOOL (17) /* PL_set_prolog_flag() */
#define PL_FUNCTOR_CHARS (18) /* PL_unify_term() */
#define _PL_PREDICATE_INDICATOR (19) /* predicate_t (Procedure) */
#define PL_SHORT (20) /* short */
#define PL_INT (21) /* int */
#define PL_LONG (22) /* long */
#define PL_DOUBLE (23) /* double */
#define PL_NCHARS (24) /* size_t, const char * */
#define PL_UTF8_CHARS (25) /* const char * */
#define PL_UTF8_STRING (26) /* const char * */
#define PL_INT64 (27) /* int64_t */
#define PL_NUTF8_CHARS (28) /* size_t, const char * */
#define PL_NUTF8_CODES (29) /* size_t, const char * */
#define PL_NUTF8_STRING (30) /* size_t, const char * */
#define PL_NWCHARS (31) /* size_t, const wchar_t * */
#define PL_NWCODES (32) /* size_t, const wchar_t * */
#define PL_NWSTRING (33) /* size_t, const wchar_t * */
#define PL_MBCHARS (34) /* const char * */
#define PL_MBCODES (35) /* const char * */
#define PL_MBSTRING (36) /* const char * */
#define PL_INTPTR (37) /* intptr_t */
#define PL_CHAR (38) /* int */
#define PL_CODE (39) /* int */
#define PL_BYTE (40) /* int */
/* PL_skip_list() */
#define PL_PARTIAL_LIST (41) /* a partial list */
#define PL_CYCLIC_TERM (42) /* a cyclic list/term */
#define PL_NOT_A_LIST (43) /* Object is not a list */
/* dicts */
#define PL_DICT (44)
/* Or'ed flags for PL_set_prolog_flag() */
/* MUST fit in a short int! */
#define FF_READONLY 0x1000 /* Read-only prolog flag */
#define FF_KEEP 0x2000 /* keep prolog flag if already set */
#define FF_NOCREATE 0x4000 /* Fail if flag is non-existent */
#define FF_FORCE 0x8000 /* Force setting, overwrite READONLY */
#define FF_MASK 0xf000
/********************************
* DETERMINISTIC CALL/RETURN *
*********************************/
/* PL_succeed and PL_fail are deprecated */
#define PL_succeed return TRUE /* succeed deterministically */
#define PL_fail return FALSE /* fail */
/********************************
* NON-DETERMINISTIC CALL/RETURN *
*********************************/
/* Note 1: Non-deterministic foreign functions may also use the deterministic
return methods PL_succeed and PL_fail.
Note 2: The argument to PL_retry is a sizeof(ptr)-2 bits signed
integer (use type intptr_t).
*/
#define PL_FIRST_CALL (0)
#define PL_CUTTED (1) /* deprecated */
#define PL_PRUNED (1)
#define PL_REDO (2)
#define PL_RESUME (3)
#define PL_retry(n) return _PL_retry(n)
#define PL_retry_address(a) return _PL_retry_address(a)
#define PL_yield_address(a) return _PL_yield_address(a)
PL_EXPORT(foreign_t) _PL_retry(intptr_t);
PL_EXPORT(foreign_t) _PL_retry_address(void *);
PL_EXPORT(foreign_t) _PL_yield_address(void *);
PL_EXPORT(int) PL_foreign_control(control_t);
PL_EXPORT(intptr_t) PL_foreign_context(control_t);
PL_EXPORT(void *) PL_foreign_context_address(control_t);
PL_EXPORT(predicate_t) PL_foreign_context_predicate(control_t);
/********************************
* REGISTERING FOREIGNS *
*********************************/
typedef struct PL_extension
{ const char *predicate_name; /* Name of the predicate */
short arity; /* Arity of the predicate */
pl_function_t function; /* Implementing functions */
short flags; /* Or of PL_FA_... */
} PL_extension;
#define PL_FA_NOTRACE (0x01) /* foreign cannot be traced */
#define PL_FA_TRANSPARENT (0x02) /* foreign is module transparent (deprecated) */
#define PL_FA_NONDETERMINISTIC (0x04) /* foreign is non-deterministic */
#define PL_FA_VARARGS (0x08) /* call using t0, ac, ctx */
#define PL_FA_CREF (0x10) /* Internal: has clause-reference */
#define PL_FA_ISO (0x20) /* Internal: ISO core predicate */
#define PL_FA_META (0x40) /* Additional meta-argument spec */
#define PL_FA_SIG_ATOMIC (0x80) /* Internal: do not dispatch signals */
extern PL_extension PL_extensions[]; /* not Win32! */
PL_EXPORT(void) PL_register_extensions(const PL_extension *e);
PL_EXPORT(void) PL_register_extensions_in_module(const char *module, const PL_extension *e);
PL_EXPORT(int) PL_register_foreign(const char *name, int arity,
pl_function_t func,
int flags, ...);
PL_EXPORT(int) PL_register_foreign_in_module(const char *module,
const char *name, int arity,
pl_function_t func,
int flags, ...);
PL_EXPORT(void) PL_load_extensions(const PL_extension *e); /* WDEPRECATED */
/*******************************
* LICENSE *
*******************************/
PL_EXPORT(void) PL_license(const char *license, const char *module);
/********************************
* MODULES *
*********************************/
PL_EXPORT(module_t) PL_context(void);
PL_EXPORT(atom_t) PL_module_name(module_t module);
PL_EXPORT(module_t) PL_new_module(atom_t name);
PL_EXPORT(int) PL_strip_module(term_t in, module_t *m, term_t out) WUNUSED;
/*******************************
* CONSTANTS *
*******************************/
PL_EXPORT(const atom_t) *_PL_atoms(void); /* base of reserved (meta-)atoms */
#ifndef PL_KERNEL
#define ATOM_nil (_PL_atoms()[0]) /* `[]` */
#define ATOM_dot (_PL_atoms()[1]) /* `.` */
#endif /*PL_KERNEL*/
/*******************************
* CALL-BACK *
*******************************/
#ifdef PL_KERNEL
#define PL_Q_DEBUG 0x0001 /* = TRUE for backward compatibility */
#endif
#define PL_Q_NORMAL 0x0002 /* normal usage */
#define PL_Q_NODEBUG 0x0004 /* use this one */
#define PL_Q_CATCH_EXCEPTION 0x0008 /* handle exceptions in C */
#define PL_Q_PASS_EXCEPTION 0x0010 /* pass to parent environment */
#define PL_Q_ALLOW_YIELD 0x0020 /* Support I_YIELD */
#define PL_Q_EXT_STATUS 0x0040 /* Return extended status */
#ifdef PL_KERNEL
#define PL_Q_DETERMINISTIC 0x0100 /* call was deterministic */
#endif
/* PL_Q_EXT_STATUS return codes */
#define PL_S_NOT_INNER -2 /* Query is not inner query */
#define PL_S_EXCEPTION -1 /* Query raised exception */
#define PL_S_FALSE 0 /* Query failed */
#define PL_S_TRUE 1 /* Query succeeded with choicepoint */
#define PL_S_LAST 2 /* Query succeeded without CP */
#define PL_S_YIELD 255 /* Foreign yield */
/* Foreign context frames */
PL_EXPORT(fid_t) PL_open_foreign_frame(void);
PL_EXPORT(void) PL_rewind_foreign_frame(fid_t cid);
PL_EXPORT(void) PL_close_foreign_frame(fid_t cid);
PL_EXPORT(void) PL_discard_foreign_frame(fid_t cid);
/* Finding predicates */
PL_EXPORT(predicate_t) PL_pred(functor_t f, module_t m);
PL_EXPORT(predicate_t) PL_predicate(const char *name, int arity,
const char* module);
PL_EXPORT(int) PL_predicate_info(predicate_t pred,
atom_t *name, size_t *arity,
module_t *module);
/* Call-back */
PL_EXPORT(qid_t) PL_open_query(module_t m, int flags,
predicate_t pred, term_t t0);
PL_EXPORT(int) PL_next_solution(qid_t qid) WUNUSED;
PL_EXPORT(int) PL_close_query(qid_t qid);
PL_EXPORT(int) PL_cut_query(qid_t qid);
PL_EXPORT(qid_t) PL_current_query(void);
PL_EXPORT(PL_engine_t) PL_query_engine(qid_t qid);
PL_EXPORT(int) PL_can_yield(void);
/* Simplified (but less flexible) call-back */
PL_EXPORT(int) PL_call(term_t t, module_t m) WUNUSED;
PL_EXPORT(int) PL_call_predicate(module_t m, int flags,
predicate_t pred, term_t t0); /* TODO: WUNUSED */
/* Handling exceptions */
PL_EXPORT(term_t) PL_exception(qid_t qid);
PL_EXPORT(int) PL_raise_exception(term_t exception);
PL_EXPORT(int) PL_throw(term_t exception); /* WDEPRECATED */
PL_EXPORT(void) PL_clear_exception(void);
/* Engine-based coroutining */
PL_EXPORT(term_t) PL_yielded(qid_t qid);
/*******************************
* ASSERT *
*******************************/
#define PL_ASSERTZ 0x0000
#define PL_ASSERTA 0x0001
#define PL_CREATE_THREAD_LOCAL 0x0010
#define PL_CREATE_INCREMENTAL 0x0020
PL_EXPORT(int) PL_assert(term_t term, module_t m, int flags);
/*******************************
* TERM-REFERENCES *
*******************************/
/* Creating and destroying term-refs */
PL_EXPORT(term_t) PL_new_term_refs(size_t n);
PL_EXPORT(term_t) PL_new_term_ref(void);
PL_EXPORT(term_t) PL_copy_term_ref(term_t from);
PL_EXPORT(void) PL_free_term_ref(term_t t);
PL_EXPORT(void) PL_reset_term_refs(term_t r);
/* Constants */
PL_EXPORT(atom_t) PL_new_atom(const char *s);
PL_EXPORT(atom_t) PL_new_atom_nchars(size_t len, const char *s);
PL_EXPORT(atom_t) PL_new_atom_wchars(size_t len, const pl_wchar_t *s);
PL_EXPORT(atom_t) PL_new_atom_mbchars(int rep, size_t len, const char *s);
PL_EXPORT(const char *) PL_atom_chars(atom_t a); /* WDEPRECATED */
PL_EXPORT(const char *) PL_atom_nchars(atom_t a, size_t *len);
PL_EXPORT(int) PL_atom_mbchars(atom_t a, size_t *len, char **s,
unsigned int flags);
PL_EXPORT(const wchar_t *) PL_atom_wchars(atom_t a, size_t *len);
PL_EXPORT(void) PL_register_atom(atom_t a);
PL_EXPORT(void) PL_unregister_atom(atom_t a);
#ifdef O_DEBUG_ATOMGC
#define PL_register_atom(a) \
_PL_debug_register_atom(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define PL_unregister_atom(a) \
_PL_debug_unregister_atom(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
PL_EXPORT(void) _PL_debug_register_atom(atom_t a,
const char *file, int line,
const char *func);
PL_EXPORT(void) _PL_debug_unregister_atom(atom_t a,
const char *file, int line,
const char *func);
#endif
PL_EXPORT(functor_t) PL_new_functor_sz(atom_t f, size_t a);
PL_EXPORT(functor_t) PL_new_functor(atom_t f, int a);
PL_EXPORT(atom_t) PL_functor_name(functor_t f);
PL_EXPORT(int) PL_functor_arity(functor_t f);
PL_EXPORT(size_t) PL_functor_arity_sz(functor_t f);
/* Get C-values from Prolog terms */
PL_EXPORT(int) PL_get_atom(term_t t, atom_t *a) WUNUSED;
PL_EXPORT(int) PL_get_bool(term_t t, int *value) WUNUSED;
PL_EXPORT(int) PL_get_atom_chars(term_t t, char **a) WUNUSED;
#define PL_get_string_chars(t, s, l) PL_get_string(t,s,l)
PL_EXPORT(int) PL_get_string(term_t t, char **s, size_t *len) WUNUSED; /* WDEPRECATED */
PL_EXPORT(int) PL_get_chars(term_t t, char **s, unsigned int flags) WUNUSED;
PL_EXPORT(int) PL_get_list_chars(term_t l, char **s,
unsigned int flags) WUNUSED;
PL_EXPORT(int) PL_get_atom_nchars(term_t t, size_t *len, char **a) WUNUSED;
PL_EXPORT(int) PL_get_list_nchars(term_t l,
size_t *len, char **s,
unsigned int flags) WUNUSED;
PL_EXPORT(int) PL_get_nchars(term_t t,
size_t *len, char **s,
unsigned int flags) WUNUSED;
PL_EXPORT(int) PL_get_integer(term_t t, int *i) WUNUSED;
PL_EXPORT(int) PL_get_long(term_t t, long *i) WUNUSED;
PL_EXPORT(int) PL_get_intptr(term_t t, intptr_t *i) WUNUSED;
PL_EXPORT(int) PL_get_pointer(term_t t, void **ptr) WUNUSED;
PL_EXPORT(int) PL_get_float(term_t t, double *f) WUNUSED;
PL_EXPORT(int) PL_get_functor(term_t t, functor_t *f) WUNUSED;
PL_EXPORT(int) PL_get_name_arity_sz(term_t t, atom_t *name,
size_t *arity) WUNUSED;
PL_EXPORT(int) PL_get_compound_name_arity_sz(term_t t, atom_t *name,
size_t *arity) WUNUSED;
PL_EXPORT(int) PL_get_name_arity(term_t t, atom_t *name,
int *arity) WUNUSED;
PL_EXPORT(int) PL_get_compound_name_arity(term_t t, atom_t *name,
int *arity) WUNUSED;
PL_EXPORT(int) PL_get_module(term_t t, module_t *module) WUNUSED;
PL_EXPORT(int) PL_get_arg_sz(size_t index, term_t t, term_t a) WUNUSED;
PL_EXPORT(int) PL_get_arg(int index, term_t t, term_t a) WUNUSED;
PL_EXPORT(int) PL_get_dict_key(atom_t key, term_t dict, term_t value);
PL_EXPORT(int) PL_get_list(term_t l, term_t h, term_t t) WUNUSED;
PL_EXPORT(int) PL_get_head(term_t l, term_t h) WUNUSED;
PL_EXPORT(int) PL_get_tail(term_t l, term_t t) WUNUSED;
PL_EXPORT(int) PL_get_nil(term_t l) WUNUSED;
PL_EXPORT(int) PL_get_term_value(term_t t, term_value_t *v) WUNUSED;
PL_EXPORT(char *) PL_quote(int chr, const char *data);
#define PL_FOR_DICT_SORTED 0x1
PL_EXPORT(int) PL_for_dict(term_t dict,
int (*func)(term_t key, term_t value, void *closure),
void *closure,
int flags);
/* Verify types */
PL_EXPORT(int) PL_term_type(term_t t);
PL_EXPORT(int) PL_is_variable(term_t t);
PL_EXPORT(int) PL_is_ground(term_t t);
PL_EXPORT(int) PL_is_atom(term_t t);
PL_EXPORT(int) PL_is_integer(term_t t);
PL_EXPORT(int) PL_is_string(term_t t);
PL_EXPORT(int) PL_is_float(term_t t);
PL_EXPORT(int) PL_is_rational(term_t t);
PL_EXPORT(int) PL_is_compound(term_t t);
PL_EXPORT(int) PL_is_callable(term_t t);
PL_EXPORT(int) PL_is_functor(term_t t, functor_t f);
PL_EXPORT(int) PL_is_list(term_t t);
PL_EXPORT(int) PL_is_dict(term_t t);
PL_EXPORT(int) PL_is_pair(term_t t);
PL_EXPORT(int) PL_is_atomic(term_t t);
PL_EXPORT(int) PL_is_number(term_t t);
PL_EXPORT(int) PL_is_acyclic(term_t t);
/* Assign to term-references */
PL_EXPORT(int) PL_put_variable(term_t t);
PL_EXPORT(int) PL_put_atom(term_t t, atom_t a);
PL_EXPORT(int) PL_put_bool(term_t t, int val);
PL_EXPORT(int) PL_put_atom_chars(term_t t, const char *chars);
PL_EXPORT(int) PL_put_string_chars(term_t t, const char *chars) WUNUSED;
PL_EXPORT(int) PL_put_chars(term_t t, int flags,
size_t len, const char *chars) WUNUSED;
PL_EXPORT(int) PL_put_list_chars(term_t t, const char *chars) WUNUSED;
PL_EXPORT(int) PL_put_list_codes(term_t t, const char *chars) WUNUSED;
PL_EXPORT(int) PL_put_atom_nchars(term_t t, size_t l, const char *chars);
PL_EXPORT(int) PL_put_string_nchars(term_t t, size_t len, const char *chars) WUNUSED;
PL_EXPORT(int) PL_put_list_nchars(term_t t, size_t l, const char *chars) WUNUSED;
PL_EXPORT(int) PL_put_list_ncodes(term_t t, size_t l, const char *chars) WUNUSED;
PL_EXPORT(int) PL_put_integer(term_t t, long i) WUNUSED;
PL_EXPORT(int) PL_put_pointer(term_t t, void *ptr) WUNUSED;
PL_EXPORT(int) PL_put_float(term_t t, double f) WUNUSED;
PL_EXPORT(int) PL_put_functor(term_t t, functor_t functor) WUNUSED;
PL_EXPORT(int) PL_put_list(term_t l) WUNUSED;
PL_EXPORT(int) PL_put_nil(term_t l);
PL_EXPORT(int) PL_put_term(term_t t1, term_t t2) WUNUSED;
PL_EXPORT(int) PL_put_dict(term_t t, atom_t tag, size_t len,
const atom_t *keys, term_t values) WUNUSED;
PL_EXPORT(atom_t) _PL_cons_small_int(int64_t v);
PL_EXPORT(void) _PL_unregister_keys(size_t len, atom_t *keys);
/* construct a functor or list-cell */
PL_EXPORT(int) PL_cons_functor(term_t h, functor_t f, ...) WUNUSED;
PL_EXPORT(int) PL_cons_functor_v(term_t h, functor_t fd, term_t a0) WUNUSED;
PL_EXPORT(int) PL_cons_list(term_t l, term_t h, term_t t) WUNUSED;
/* Unify term-references */
PL_EXPORT(int) PL_unify(term_t t1, term_t t2) WUNUSED;
PL_EXPORT(int) PL_unify_atom(term_t t, atom_t a) WUNUSED;
PL_EXPORT(int) PL_unify_atom_chars(term_t t, const char *chars) WUNUSED;
PL_EXPORT(int) PL_unify_list_chars(term_t t, const char *chars) WUNUSED;
PL_EXPORT(int) PL_unify_list_codes(term_t t, const char *chars) WUNUSED;
PL_EXPORT(int) PL_unify_string_chars(term_t t, const char *chars) WUNUSED;
PL_EXPORT(int) PL_unify_atom_nchars(term_t t, size_t l, const char *s) WUNUSED;
PL_EXPORT(int) PL_unify_list_ncodes(term_t t, size_t l, const char *s) WUNUSED;
PL_EXPORT(int) PL_unify_list_nchars(term_t t, size_t l, const char *s) WUNUSED;
PL_EXPORT(int) PL_unify_string_nchars(term_t t,
size_t len,
const char *chars) WUNUSED;
PL_EXPORT(int) PL_unify_bool(term_t t, int n) WUNUSED;
PL_EXPORT(int) PL_unify_integer(term_t t, intptr_t n) WUNUSED;
PL_EXPORT(int) PL_unify_float(term_t t, double f) WUNUSED;
PL_EXPORT(int) PL_unify_pointer(term_t t, void *ptr) WUNUSED;
PL_EXPORT(int) PL_unify_functor(term_t t, functor_t f) WUNUSED;
PL_EXPORT(int) PL_unify_compound(term_t t, functor_t f) WUNUSED;
PL_EXPORT(int) PL_unify_list(term_t l, term_t h, term_t t) WUNUSED;
PL_EXPORT(int) PL_unify_nil(term_t l) WUNUSED;
PL_EXPORT(int) PL_unify_arg_sz(size_t index, term_t t, term_t a) WUNUSED;
PL_EXPORT(int) PL_unify_arg(int index, term_t t, term_t a) WUNUSED;
PL_EXPORT(int) PL_unify_term(term_t t, ...) WUNUSED;
PL_EXPORT(int) PL_unify_chars(term_t t, int flags,
size_t len, const char *s) WUNUSED;
/*******************************
* LISTS *
*******************************/
PL_EXPORT(int) PL_skip_list(term_t list, term_t tail, size_t *len);
/*******************************
* WIDE CHARACTER VERSIONS *
*******************************/
PL_EXPORT(int) PL_put_wchars(term_t t, int type,
size_t len, const pl_wchar_t *s) WUNUSED;
PL_EXPORT(int) PL_unify_wchars(term_t t, int type,
size_t len, const pl_wchar_t *s) WUNUSED;
PL_EXPORT(int) PL_unify_wchars_diff(term_t t, term_t tail, int type,
size_t len, const pl_wchar_t *s) WUNUSED;
PL_EXPORT(int) PL_get_wchars(term_t l,
size_t *length, pl_wchar_t **s,
unsigned flags) WUNUSED;
PL_EXPORT(size_t) PL_utf8_strlen(const char *s, size_t len) WUNUSED;
/*******************************
* WIDE INTEGERS *
*******************************/
PL_EXPORT(int) PL_get_int64(term_t t, int64_t *i) WUNUSED;
PL_EXPORT(int) PL_get_uint64(term_t t, uint64_t *i) WUNUSED;
PL_EXPORT(int) PL_unify_int64(term_t t, int64_t value) WUNUSED;
PL_EXPORT(int) PL_unify_uint64(term_t t, uint64_t value) WUNUSED;
PL_EXPORT(int) PL_put_int64(term_t t, int64_t i) WUNUSED;
PL_EXPORT(int) PL_put_uint64(term_t t, uint64_t i) WUNUSED;
/*******************************
* ATTRIBUTED VARIABLES *
*******************************/
PL_EXPORT(int) PL_is_attvar(term_t t);
PL_EXPORT(int) PL_get_attr(term_t v, term_t a);
/*******************************
* TABLING *
*******************************/
PL_EXPORT(int) PL_get_delay_list(term_t l);
/*******************************
* ERRORS *
*******************************/
PL_EXPORT(int) PL_get_atom_ex(term_t t, atom_t *a);
PL_EXPORT(int) PL_get_integer_ex(term_t t, int *i);
PL_EXPORT(int) PL_get_long_ex(term_t t, long *i);
PL_EXPORT(int) PL_get_int64_ex(term_t t, int64_t *i);
PL_EXPORT(int) PL_get_uint64_ex(term_t t, uint64_t *i);
PL_EXPORT(int) PL_get_intptr_ex(term_t t, intptr_t *i);
PL_EXPORT(int) PL_get_size_ex(term_t t, size_t *i);
PL_EXPORT(int) PL_get_bool_ex(term_t t, int *i);
PL_EXPORT(int) PL_get_float_ex(term_t t, double *f);
PL_EXPORT(int) PL_get_char_ex(term_t t, int *p, int eof);
PL_EXPORT(int) PL_unify_bool_ex(term_t t, int val);
PL_EXPORT(int) PL_get_pointer_ex(term_t t, void **addrp);
PL_EXPORT(int) PL_unify_list_ex(term_t l, term_t h, term_t t);
PL_EXPORT(int) PL_unify_nil_ex(term_t l);
PL_EXPORT(int) PL_get_list_ex(term_t l, term_t h, term_t t);
PL_EXPORT(int) PL_get_nil_ex(term_t l);
PL_EXPORT(int) PL_instantiation_error(term_t culprit);
PL_EXPORT(int) PL_uninstantiation_error(term_t culprit);
PL_EXPORT(int) PL_representation_error(const char *resource);
PL_EXPORT(int) PL_type_error(const char *expected, term_t culprit);
PL_EXPORT(int) PL_domain_error(const char *expected, term_t culprit);
PL_EXPORT(int) PL_existence_error(const char *type, term_t culprit);
PL_EXPORT(int) PL_permission_error(const char *operation,
const char *type, term_t culprit);
PL_EXPORT(int) PL_resource_error(const char *resource);
PL_EXPORT(int) PL_syntax_error(const char *msg, IOSTREAM *in);
/*******************************
* BLOBS *
*******************************/
#define PL_BLOB_MAGIC_B 0x75293a00 /* Magic to validate a blob-type */
#define PL_BLOB_VERSION 1 /* Current version */
#define PL_BLOB_MAGIC (PL_BLOB_MAGIC_B|PL_BLOB_VERSION)
#define PL_BLOB_UNIQUE 0x01 /* Blob content is unique */
#define PL_BLOB_TEXT 0x02 /* blob contains text */
#define PL_BLOB_NOCOPY 0x04 /* do not copy the data */
#define PL_BLOB_WCHAR 0x08 /* wide character string */
typedef struct PL_blob_t
{ uintptr_t magic; /* PL_BLOB_MAGIC */
uintptr_t flags; /* PL_BLOB_* */
const char * name; /* name of the type */
int (*release)(atom_t a);
int (*compare)(atom_t a, atom_t b);
int (*write)(IOSTREAM *s, atom_t a, int flags);
void (*acquire)(atom_t a);
int (*save)(atom_t a, IOSTREAM *s);
atom_t (*load)(IOSTREAM *s);
size_t padding; /* Required 0-padding */
/* private */
void * reserved[9]; /* for future extension */
int registered; /* Already registered? */
int rank; /* Rank for ordering atoms */
struct PL_blob_t * next; /* next in registered type-chain */
atom_t atom_name; /* Name as atom */
} PL_blob_t;
PL_EXPORT(int) PL_is_blob(term_t t, PL_blob_t **type);
PL_EXPORT(int) PL_unify_blob(term_t t, void *blob, size_t len,
PL_blob_t *type);
PL_EXPORT(atom_t) PL_new_blob(void *blob, size_t len, PL_blob_t *type);
PL_EXPORT(int) PL_put_blob(term_t t, void *blob, size_t len,
PL_blob_t *type);
PL_EXPORT(int) PL_get_blob(term_t t, void **blob, size_t *len,
PL_blob_t **type);
PL_EXPORT(void*) PL_blob_data(atom_t a,
size_t *len,
struct PL_blob_t **type);
PL_EXPORT(int) PL_free_blob(atom_t blob);
PL_EXPORT(void) PL_register_blob_type(PL_blob_t *type);
PL_EXPORT(PL_blob_t*) PL_find_blob_type(const char* name);
PL_EXPORT(int) PL_unregister_blob_type(PL_blob_t *type);
#ifdef __GNU_MP__
/*******************************
* GMP *
*******************************/
PL_EXPORT(int) PL_get_mpz(term_t t, mpz_t mpz) WUNUSED;
PL_EXPORT(int) PL_get_mpq(term_t t, mpq_t mpq) WUNUSED;
PL_EXPORT(int) PL_unify_mpz(term_t t, mpz_t mpz) WUNUSED;
PL_EXPORT(int) PL_unify_mpq(term_t t, mpq_t mpq) WUNUSED;
#endif /*__GNU_MP__*/
/*******************************
* FILENAME SUPPORT *
*******************************/
#define PL_FILE_ABSOLUTE 0x01 /* return absolute path */
#define PL_FILE_OSPATH 0x02 /* return path in OS notation */
#define PL_FILE_SEARCH 0x04 /* use file_search_path */
#define PL_FILE_EXIST 0x08 /* demand file to exist */
#define PL_FILE_READ 0x10 /* demand read-access */
#define PL_FILE_WRITE 0x20 /* demand write-access */
#define PL_FILE_EXECUTE 0x40 /* demand execute-access */
#define PL_FILE_NOERRORS 0x80 /* do not raise exceptions */
PL_EXPORT(int) PL_get_file_name(term_t n, char **name, int flags);
PL_EXPORT(int) PL_get_file_nameW(term_t n, wchar_t **name, int flags);
PL_EXPORT(void) PL_changed_cwd(void); /* foreign code changed CWD */
PL_EXPORT(char *) PL_cwd(char *buf, size_t buflen);
/*******************************
* QUINTUS/SICSTUS WRAPPER *
*******************************/
PL_EXPORT(int) PL_cvt_i_bool(term_t p, int *c); /* Note "int" because C has no "bool" */
PL_EXPORT(int) PL_cvt_i_char(term_t p, char *c);
PL_EXPORT(int) PL_cvt_i_schar(term_t p, signed char *c);
PL_EXPORT(int) PL_cvt_i_uchar(term_t p, unsigned char *c);
PL_EXPORT(int) PL_cvt_i_short(term_t p, short *s);
PL_EXPORT(int) PL_cvt_i_ushort(term_t p, unsigned short *s);
PL_EXPORT(int) PL_cvt_i_int(term_t p, int *c);
PL_EXPORT(int) PL_cvt_i_uint(term_t p, unsigned int *c);
PL_EXPORT(int) PL_cvt_i_long(term_t p, long *c);
PL_EXPORT(int) PL_cvt_i_ulong(term_t p, unsigned long *c);
PL_EXPORT(int) PL_cvt_i_llong(term_t p, long long *c);
PL_EXPORT(int) PL_cvt_i_ullong(term_t p, unsigned long long *c);
PL_EXPORT(int) PL_cvt_i_int32(term_t p, int32_t *c);
PL_EXPORT(int) PL_cvt_i_uint32(term_t p, uint32_t *c);
PL_EXPORT(int) PL_cvt_i_int64(term_t p, int64_t *c);
PL_EXPORT(int) PL_cvt_i_uint64(term_t p, uint64_t *c);
PL_EXPORT(int) PL_cvt_i_size_t(term_t p, size_t *c);
PL_EXPORT(int) PL_cvt_i_float(term_t p, double *c);
PL_EXPORT(int) PL_cvt_i_single(term_t p, float *c);
PL_EXPORT(int) PL_cvt_i_string(term_t p, char **c);
PL_EXPORT(int) PL_cvt_i_codes(term_t p, char **c);
PL_EXPORT(int) PL_cvt_i_atom(term_t p, atom_t *c);
PL_EXPORT(int) PL_cvt_i_address(term_t p, void *c);
PL_EXPORT(int) PL_cvt_o_int64(int64_t c, term_t p);
PL_EXPORT(int) PL_cvt_o_float(double c, term_t p);
PL_EXPORT(int) PL_cvt_o_single(float c, term_t p);
PL_EXPORT(int) PL_cvt_o_string(const char *c, term_t p);
PL_EXPORT(int) PL_cvt_o_codes(const char *c, term_t p);
PL_EXPORT(int) PL_cvt_o_atom(atom_t c, term_t p);
PL_EXPORT(int) PL_cvt_o_address(void *address, term_t p);
PL_EXPORT(term_t) PL_new_nil_ref(void);
/* set/get encoding for PL_cvt_*_string() functions. The default
is UTF-8 (REP_UTF8)
*/
PL_EXPORT(int) PL_cvt_encoding(void);
PL_EXPORT(int) PL_cvt_set_encoding(int enc);
PL_EXPORT(void) SP_set_state(int state);
PL_EXPORT(int) SP_get_state(void);
/*******************************
* COMPARE *
*******************************/
PL_EXPORT(int) PL_compare(term_t t1, term_t t2);
PL_EXPORT(int) PL_same_compound(term_t t1, term_t t2);
/*******************************
* MESSAGES *
*******************************/
#if !defined(WPRINTF12)
/* these macros are duplicated in SWI-Streams.h */
#if defined(CHECK_FORMAT)
#define WPRINTF12 __attribute__ ((format (printf, 1, 2)))
#define WPRINTF23 __attribute__ ((format (printf, 2, 3)))
#define WPRINTF34 __attribute__ ((format (printf, 3, 4)))
#else
#define WPRINTF12
#define WPRINTF23
#define WPRINTF34
#endif
#endif
PL_EXPORT(int) PL_warning(const char *fmt, ...) WPRINTF12;
PL_EXPORT(int) PL_warningX(const char *fmt, ...);
PL_EXPORT(void) PL_fatal_error(const char *fmt, ...) WPRINTF12;
PL_EXPORT(void) PL_api_error(const char *fmt, ...) WPRINTF12;
PL_EXPORT(void) PL_system_error(const char *fmt, ...) WPRINTF12;
PL_EXPORT(int) PL_print_message(atom_t severity, ...) WUNUSED;
/*******************************
* RECORDED DATABASE *
*******************************/
PL_EXPORT(record_t) PL_record(term_t term);
PL_EXPORT(int) PL_recorded(record_t record, term_t term);
PL_EXPORT(void) PL_erase(record_t record);
PL_EXPORT(record_t) PL_duplicate_record(record_t r);
PL_EXPORT(char *) PL_record_external(term_t t, size_t *size);
PL_EXPORT(int) PL_recorded_external(const char *rec, term_t term);
PL_EXPORT(int) PL_erase_external(char *rec);
/*******************************
* PROLOG FLAGS *
*******************************/
#define PL_set_feature PL_set_prolog_flag /* compatibility */
PL_EXPORT(int) PL_set_prolog_flag(const char *name, int type, ...);
/*******************************
* INTERNAL FUNCTIONS *
*******************************/
PL_EXPORT(PL_atomic_t) _PL_get_atomic(term_t t);
PL_EXPORT(void) _PL_put_atomic(term_t t, PL_atomic_t a);
PL_EXPORT(int) _PL_unify_atomic(term_t t, PL_atomic_t a);
PL_EXPORT(int) _PL_get_arg_sz(size_t index, term_t t, term_t a);
PL_EXPORT(int) _PL_get_arg(int index, term_t t, term_t a);
/*******************************
* CHAR BUFFERS *
*******************************/
#define CVT_ATOM 0x00000001
#define CVT_STRING 0x00000002
#define CVT_LIST 0x00000004
#define CVT_INTEGER 0x00000008
#define CVT_RATIONAL 0x00000010
#define CVT_FLOAT 0x00000020
#define CVT_VARIABLE 0x00000040
#define CVT_NUMBER (CVT_RATIONAL|CVT_FLOAT)
#define CVT_ATOMIC (CVT_NUMBER|CVT_ATOM|CVT_STRING)
#define CVT_WRITE 0x00000080
#define CVT_WRITE_CANONICAL 0x00000100
#define CVT_WRITEQ 0x00000200
#define CVT_ALL (CVT_ATOMIC|CVT_LIST)
#define CVT_XINTEGER (0x00000400|CVT_INTEGER)
#define CVT_MASK 0x00000fff
#define CVT_EXCEPTION 0x00001000 /* throw exception on error */
#define CVT_VARNOFAIL 0x00002000 /* return 2 if argument is unbound */
#define BUF_DISCARDABLE 0x00000000 /* Store in single thread-local buffer */
#define BUF_STACK 0x00010000 /* Store in stack of buffers */
#define BUF_MALLOC 0x00020000 /* Store using PL_malloc() */
#define BUF_ALLOW_STACK 0x00040000 /* Allow pointer into (global) stack */
#define BUF_RING BUF_STACK /* legacy ring buffer */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Output representation for PL_get_chars() and friends. The
prepresentation type REP_FN is for PL_get_file_name() and friends. On
Windows we use UTF-8 which is translated by the `XOS' layer to Windows
UNICODE file functions.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define REP_ISO_LATIN_1 0x00000000 /* output representation */
#define REP_UTF8 0x00100000
#define REP_MB 0x00200000
#ifdef __WINDOWS__
#define REP_FN REP_UTF8
#else
#define REP_FN REP_MB
#endif
#define PL_DIFF_LIST 0x01000000 /* PL_unify_chars() */
/*******************************
* STRING BUFFERS *
*******************************/
#define PL_STRINGS_MARK() \
{ buf_mark_t __PL_mark; \
PL_mark_string_buffers(&__PL_mark);
#define PL_STRINGS_RELEASE() \
PL_release_string_buffers_from_mark(__PL_mark); \
}
PL_EXPORT(void) PL_mark_string_buffers(buf_mark_t *mark);
PL_EXPORT(void) PL_release_string_buffers_from_mark(buf_mark_t mark);
/*******************************
* STREAM SUPPORT *
*******************************/
/* Make IOSTREAM known to Prolog */
#define PL_open_stream PL_unify_stream /* compatibility */
PL_EXPORT(int) PL_unify_stream(term_t t, IOSTREAM *s);
PL_EXPORT(int) PL_get_stream_handle(term_t t, IOSTREAM **s);
PL_EXPORT(int) PL_get_stream(term_t t, IOSTREAM **s, int flags);
PL_EXPORT(int) PL_get_stream_from_blob(atom_t a, IOSTREAM**s, int flags);
PL_EXPORT(IOSTREAM*) PL_acquire_stream(IOSTREAM *s);
PL_EXPORT(int) PL_release_stream(IOSTREAM *s);
PL_EXPORT(int) PL_release_stream_noerror(IOSTREAM *s);
PL_EXPORT(IOSTREAM *) PL_open_resource(module_t m,
const char *name,
const char *rc_class,
const char *mode);
PL_EXPORT(IOSTREAM *)*_PL_streams(void); /* base of streams */
#ifndef PL_KERNEL
#define Suser_input (_PL_streams()[0])