summaryrefslogtreecommitdiff
path: root/Build/source/utils/xindy/rte/ordrules/ordrulei.lsp
blob: 623f4f91637675109b64d19fec8ceb3fd8aeba1e (plain)
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
;; $Id: ordrulei.lsp,v 1.5 2005/05/02 21:39:53 jschrod Exp $
;; ------------------------------------------------------------

;;;
;;; Interface definition of the ordrules module
;;;

(defpackage :ordrules
  (:use :cl :ffi)
  (:export :initialize
	   :add-keyword-sort-rule :add-keyword-merge-rule
	   :gen-keyword-sortkey :gen-keyword-mergekey))

(in-package :ordrules)

(c-lines "#include \"ordrules.h\"~%")

; clisp does not produce these include calls
(c-lines
  (concatenate 'string "#include <termios.h>~%"
    "#include <bits/ipctypes.h>~%"
    "#include <stddef.h>~%"))

; The following lines are the lines 1845 to 1858 from
; http://clisp.cvs.sourceforge.net/clisp/clisp/modules/bindings/glibc/linux.lisp?revision=1.25&view=markup

;;; ============================== <dirent.h> ================================
(c-lines "#include <dirent.h>~%")

;;; ----------------------------- <bits/dirent.h> ---------------------------
;; d_type is only in dirent64, not in dirent in <linux/dirent.h>,
;; but it appears to BE required, and does appear in <bits/dirent.h>

(c-lines "#ifndef __USE_FILE_OFFSET64
typedef __ino_t clisp_dirent_ino_t;
typedef __off_t clisp_dirent_off_t;
#else
typedef __ino64_t clisp_dirent_ino_t;
typedef __off64_t clisp_dirent_off_t;
#endif~%")

; Common OS definitions:
(def-c-type size_t uint)

(def-c-var *string-buffer*
    (:name "ordrules_string_buffer")
    (:type (c-array char 1024))
    (:alloc :NONE))

(def-c-var *string-buffer-used-bytes*
    (:name "ordrules_string_buffer_used_bytes")
    (:type int)
    (:alloc :NONE))

(def-c-var *string-buffer-used-bytes*
    (:name "ordrules_string_buffer_used_bytes")
    (:type int)
    (:alloc :NONE))

(def-c-var *message-logging*
    (:name "ordrules_msg_logging")
    (:type int)
    (:alloc :NONE))

(def-c-var *message-buffer*
    (:name "ordrules_msg_buffer")
    (:type c-string)
    (:alloc :NONE))

(def-c-var *message-buffer-ptr*
    (:name "ordrules_msg_buffer_ptr")
    (:type int)
    (:alloc :NONE))

(def-call-out initialize
    (:language :stdc)
    (:name "initialize")
    (:arguments (num-sort-tables int))
    (:return-type int))

(def-call-out add-keyword-sort-rule
    (:language :stdc)
    (:name "add_sort_rule")
    (:arguments (run int)
		(left c-string)
		(right c-string)
		(isreject int)
		(ruletype int))
    (:return-type int))

(def-call-out add-keyword-merge-rule
    (:language :stdc)
    (:name "add_merge_rule")
    (:arguments (left c-string)
		(right c-string)
		(isreject int)
		(ruletype int))
    (:return-type int))

(def-call-out gen-keyword-sortkey
    (:language :stdc)
    (:name "gen_sortkey")
    (:arguments (key c-string)
		(run int))
    (:return-type c-string :malloc-free))

(def-call-out gen-keyword-mergekey
    (:language :stdc)
    (:name "gen_mergekey")
    (:arguments (key c-string))
    (:return-type c-string :malloc-free))

#|

  $Log: ordrulei.lsp,v $
  Revision 1.5  2005/05/02 21:39:53  jschrod
      xindy run time engine 3.0; as used for CLISP 2.33.2.

  Revision 1.4  1997/10/20 11:23:12  kehr
  New version of sorting rules. Sorting of more complex indexes (i.e.
  French) is now possible.

  Revision 1.3  1997/01/17 16:43:38  kehr
  Several changes for new version 1.1.

  Revision 1.2  1996/04/30  15:56:38  kehr
  Renamed some of the functions to avoid conflicts with other functions
  in other packages (only for the sake of convenience).

  Revision 1.1  1996/03/27  20:29:07  kehr
  It works. Today I had my first success in getting the FFI running with
  the ordrules-library. The interface is defined in `ordrulei.lsp' and
  allows direct access to the functions in `ordrules.c'.

|#