summaryrefslogtreecommitdiff
path: root/gettext-po.scm
blob: 590d77c2944119a34f6b6d100df6eaf6848bdb20 (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
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
;; generated with `guild compile-ffi gettext-po.ffi'

(define-module (gettext-po)
  #:use-module (system ffi-help-rt)
  #:use-module ((system foreign) #:prefix ffi:)
  #:use-module (bytestructures guile)
  )
(define link-lib (dynamic-link "libgettextpo"))

;; extern int libgettextpo_version;
(define libgettextpo_version
  (let* ((addr #f)
         (memoize-addr
           (lambda ()
             (unless
               addr
               (set! addr
                 (make-bytestructure
                   (ffi:pointer->bytevector
                     (dynamic-pointer
                       "libgettextpo_version"
                       (dynamic-link))
                     (ffi:sizeof '*))
                   0
                   (bs:pointer int)))))))
    (case-lambda
      (() (memoize-addr) (bytestructure-ref addr '*)))))
(export libgettextpo_version)

;; typedef struct po_file *po_file_t;
(define-public po_file_t-desc (bs:pointer 'void))
(define-fh-pointer-type po_file_t po_file_t-desc po_file_t? make-po_file_t)
(export po_file_t po_file_t? make-po_file_t)

;; typedef struct po_message_iterator *po_message_iterator_t;
(define-public po_message_iterator_t-desc (bs:pointer 'void))
(define-fh-pointer-type po_message_iterator_t po_message_iterator_t-desc 
 po_message_iterator_t? make-po_message_iterator_t)
(export po_message_iterator_t po_message_iterator_t? 
 make-po_message_iterator_t)

;; typedef struct po_message *po_message_t;
(define-public po_message_t-desc (bs:pointer 'void))
(define-fh-pointer-type po_message_t po_message_t-desc po_message_t? 
 make-po_message_t)
(export po_message_t po_message_t? make-po_message_t)

;; typedef struct po_filepos *po_filepos_t;
(define-public po_filepos_t-desc (bs:pointer 'void))
(define-fh-pointer-type po_filepos_t po_filepos_t-desc po_filepos_t? 
 make-po_filepos_t)
(export po_filepos_t po_filepos_t? make-po_filepos_t)

;; struct po_error_handler {
;;   /* Signal an error.  The error message is built from FORMAT and the following
;;       
;;      arguments.  ERRNUM, if nonzero, is an errno value.
;;      Must increment the error_message_count variable declared in error.h.
;;      Must not return if STATUS is nonzero.  */
;;   void (*error)(int status, int errnum, const char *format, ...);
;;   /* Signal an error.  The error message is built from FORMAT and the following
;;       
;;      arguments.  The error location is at FILENAME line LINENO. ERRNUM, if
;;      nonzero, is an errno value.
;;      Must increment the error_message_count variable declared in error.h.
;;      Must not return if STATUS is nonzero.  */
;;   void (*error_at_line)(int status, int errnum, const char *filename, 
;;       unsigned int lineno, const char *format, ...);
;;   /* Signal a multiline warning.  The PREFIX applies to all lines of the
;;      MESSAGE.  Free the PREFIX and MESSAGE when done.  */
;;   void (*multiline_warning)(char *prefix, char *message);
;;   /* Signal a multiline error.  The PREFIX applies to all lines of the
;;      MESSAGE.  Free the PREFIX and MESSAGE when done.
;;      Must increment the error_message_count variable declared in error.h if
;;      PREFIX is non-NULL.  */
;;   void (*multiline_error)(char *prefix, char *message);
;; };
(define-public struct-po_error_handler-desc
  (bs:struct
    (list `(error ,(bs:pointer 'void))
          `(error_at_line ,(bs:pointer 'void))
          `(multiline_warning ,(bs:pointer 'void))
          `(multiline_error ,(bs:pointer 'void)))))
(define-fh-compound-type struct-po_error_handler struct-po_error_handler-desc 
 struct-po_error_handler? make-struct-po_error_handler)
(export struct-po_error_handler struct-po_error_handler? 
 make-struct-po_error_handler)
(define-public struct-po_error_handler*-desc
  (bs:pointer struct-po_error_handler-desc))
(define-fh-pointer-type struct-po_error_handler* struct-po_error_handler*-desc
 struct-po_error_handler*? make-struct-po_error_handler*)
(export struct-po_error_handler* struct-po_error_handler*? 
 make-struct-po_error_handler*)
(ref<->deref!
  struct-po_error_handler*
  make-struct-po_error_handler*
  struct-po_error_handler
  make-struct-po_error_handler)

;; typedef const struct po_error_handler *po_error_handler_t;
(define-public po_error_handler_t&-desc 'void)
(define-public po_error_handler_t-desc (bs:pointer (delay po_error_handler_t&-desc)))
(define-fh-pointer-type po_error_handler_t po_error_handler_t-desc 
 po_error_handler_t? make-po_error_handler_t)
(export po_error_handler_t po_error_handler_t? make-po_error_handler_t)

;; struct po_xerror_handler {
;;   /* Signal a problem of the given severity.
;;      MESSAGE and/or FILENAME + LINENO indicate where the problem occurred.
;;      If FILENAME is NULL, FILENAME and LINENO and COLUMN should be ignored.
;;      If LINENO is (size_t)(-1), LINENO and COLUMN should be ignored.
;;      If COLUMN is (size_t)(-1), it should be ignored.
;;      MESSAGE_TEXT is the problem description (if MULTILINE_P is true,
;;      multiple lines of text, each terminated with a newline, otherwise
;;      usually a single line).
;;      Must not return if SEVERITY is PO_SEVERITY_FATAL_ERROR.  */
;;   void (*xerror)(int severity, po_message_t message, const char *filename, 
;;       size_t lineno, size_t column, int multiline_p, const char *
;;       message_text);
;;   /* Signal a problem that refers to two messages.
;;      Similar to two calls to xerror.
;;      If possible, a "..." can be appended to MESSAGE_TEXT1 and prepended to
;;      MESSAGE_TEXT2.  */
;;   void (*xerror2)(int severity, po_message_t message1, const char *filename1
;;       , size_t lineno1, size_t column1, int multiline_p1, const char *
;;       message_text1, po_message_t message2, const char *filename2, size_t 
;;       lineno2, size_t column2, int multiline_p2, const char *message_text2)
;;       ;
;; };
(define-public struct-po_xerror_handler-desc
  (bs:struct
    (list `(xerror ,(bs:pointer 'void))
          `(xerror2 ,(bs:pointer 'void)))))
(define-fh-compound-type struct-po_xerror_handler 
 struct-po_xerror_handler-desc struct-po_xerror_handler? 
 make-struct-po_xerror_handler)
(export struct-po_xerror_handler struct-po_xerror_handler? 
 make-struct-po_xerror_handler)
(define-public struct-po_xerror_handler*-desc
  (bs:pointer struct-po_xerror_handler-desc))
(define-fh-pointer-type struct-po_xerror_handler* 
 struct-po_xerror_handler*-desc struct-po_xerror_handler*? 
 make-struct-po_xerror_handler*)
(export struct-po_xerror_handler* struct-po_xerror_handler*? 
 make-struct-po_xerror_handler*)
(ref<->deref!
  struct-po_xerror_handler*
  make-struct-po_xerror_handler*
  struct-po_xerror_handler
  make-struct-po_xerror_handler)

;; typedef const struct po_xerror_handler *po_xerror_handler_t;
(define-public po_xerror_handler_t&-desc 'void)
(define-public po_xerror_handler_t-desc (bs:pointer (delay po_xerror_handler_t&-desc)))
(define-fh-pointer-type po_xerror_handler_t po_xerror_handler_t-desc 
 po_xerror_handler_t? make-po_xerror_handler_t)
(export po_xerror_handler_t po_xerror_handler_t? make-po_xerror_handler_t)

;; extern po_file_t po_file_create(void);
(define ~po_file_create
  (delay (fh-link-proc
           ffi-void*
           "po_file_create"
           (list)
           link-lib)))
(define (po_file_create)
  (let ()
    ((fht-wrap po_file_t) ((force ~po_file_create)))))
(export po_file_create)

;; extern po_file_t po_file_read_v3(const char *filename, po_xerror_handler_t 
;;     handler);
(define ~po_file_read_v3
  (delay (fh-link-proc
           ffi-void*
           "po_file_read_v3"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_file_read_v3 filename handler)
  (let ((~filename (unwrap~pointer filename))
        (~handler
          ((fht-unwrap po_xerror_handler_t) handler)))
    ((fht-wrap po_file_t)
     ((force ~po_file_read_v3) ~filename ~handler))))
(export po_file_read_v3)

;; extern po_file_t po_file_write_v2(po_file_t file, const char *filename, 
;;     po_xerror_handler_t handler);
(define ~po_file_write_v2
  (delay (fh-link-proc
           ffi-void*
           "po_file_write_v2"
           (list ffi-void* ffi-void* ffi-void*)
           link-lib)))
(define (po_file_write_v2 file filename handler)
  (let ((~file ((fht-unwrap po_file_t) file))
        (~filename (unwrap~pointer filename))
        (~handler
          ((fht-unwrap po_xerror_handler_t) handler)))
    ((fht-wrap po_file_t)
     ((force ~po_file_write_v2)
      ~file
      ~filename
      ~handler))))
(export po_file_write_v2)

;; extern void po_file_free(po_file_t file);
(define ~po_file_free
  (delay (fh-link-proc
           ffi:void
           "po_file_free"
           (list ffi-void*)
           link-lib)))
(define (po_file_free file)
  (let ((~file ((fht-unwrap po_file_t) file)))
    ((force ~po_file_free) ~file)))
(export po_file_free)

;; extern const char *const*po_file_domains(po_file_t file);
(define ~po_file_domains
  (delay (fh-link-proc
           ffi-void*
           "po_file_domains"
           (list ffi-void*)
           link-lib)))
(define (po_file_domains file)
  (let ((~file ((fht-unwrap po_file_t) file)))
    ((force ~po_file_domains) ~file)))
(export po_file_domains)

;; extern const char *po_file_domain_header(po_file_t file, const char *domain)
;;     ;
(define ~po_file_domain_header
  (delay (fh-link-proc
           ffi-void*
           "po_file_domain_header"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_file_domain_header file domain)
  (let ((~file ((fht-unwrap po_file_t) file))
        (~domain (unwrap~pointer domain)))
    ((force ~po_file_domain_header) ~file ~domain)))
(export po_file_domain_header)

;; extern char *po_header_field(const char *header, const char *field);
(define ~po_header_field
  (delay (fh-link-proc
           ffi-void*
           "po_header_field"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_header_field header field)
  (let ((~header (unwrap~pointer header))
        (~field (unwrap~pointer field)))
    ((force ~po_header_field) ~header ~field)))
(export po_header_field)

;; extern char *po_header_set_field(const char *header, const char *field, 
;;     const char *value);
(define ~po_header_set_field
  (delay (fh-link-proc
           ffi-void*
           "po_header_set_field"
           (list ffi-void* ffi-void* ffi-void*)
           link-lib)))
(define (po_header_set_field header field value)
  (let ((~header (unwrap~pointer header))
        (~field (unwrap~pointer field))
        (~value (unwrap~pointer value)))
    ((force ~po_header_set_field)
     ~header
     ~field
     ~value)))
(export po_header_set_field)

;; extern po_message_iterator_t po_message_iterator(po_file_t file, const char 
;;     *domain);
(define ~po_message_iterator
  (delay (fh-link-proc
           ffi-void*
           "po_message_iterator"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_iterator file domain)
  (let ((~file ((fht-unwrap po_file_t) file))
        (~domain (unwrap~pointer domain)))
    ((fht-wrap po_message_iterator_t)
     ((force ~po_message_iterator) ~file ~domain))))
(export po_message_iterator)

;; extern void po_message_iterator_free(po_message_iterator_t iterator);
(define ~po_message_iterator_free
  (delay (fh-link-proc
           ffi:void
           "po_message_iterator_free"
           (list ffi-void*)
           link-lib)))
(define (po_message_iterator_free iterator)
  (let ((~iterator
          ((fht-unwrap po_message_iterator_t) iterator)))
    ((force ~po_message_iterator_free) ~iterator)))
(export po_message_iterator_free)

;; extern po_message_t po_next_message(po_message_iterator_t iterator);
(define ~po_next_message
  (delay (fh-link-proc
           ffi-void*
           "po_next_message"
           (list ffi-void*)
           link-lib)))
(define (po_next_message iterator)
  (let ((~iterator
          ((fht-unwrap po_message_iterator_t) iterator)))
    ((fht-wrap po_message_t)
     ((force ~po_next_message) ~iterator))))
(export po_next_message)

;; extern void po_message_insert(po_message_iterator_t iterator, po_message_t 
;;     message);
(define ~po_message_insert
  (delay (fh-link-proc
           ffi:void
           "po_message_insert"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_insert iterator message)
  (let ((~iterator
          ((fht-unwrap po_message_iterator_t) iterator))
        (~message ((fht-unwrap po_message_t) message)))
    ((force ~po_message_insert) ~iterator ~message)))
(export po_message_insert)

;; extern po_message_t po_message_create(void);
(define ~po_message_create
  (delay (fh-link-proc
           ffi-void*
           "po_message_create"
           (list)
           link-lib)))
(define (po_message_create)
  (let ()
    ((fht-wrap po_message_t)
     ((force ~po_message_create)))))
(export po_message_create)

;; extern const char *po_message_msgctxt(po_message_t message);
(define ~po_message_msgctxt
  (delay (fh-link-proc
           ffi-void*
           "po_message_msgctxt"
           (list ffi-void*)
           link-lib)))
(define (po_message_msgctxt message)
  (let ((~message ((fht-unwrap po_message_t) message)))
    ((force ~po_message_msgctxt) ~message)))
(export po_message_msgctxt)

;; extern void po_message_set_msgctxt(po_message_t message, const char *msgctxt
;;     );
(define ~po_message_set_msgctxt
  (delay (fh-link-proc
           ffi:void
           "po_message_set_msgctxt"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_set_msgctxt message msgctxt)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~msgctxt (unwrap~pointer msgctxt)))
    ((force ~po_message_set_msgctxt)
     ~message
     ~msgctxt)))
(export po_message_set_msgctxt)

;; extern const char *po_message_msgid(po_message_t message);
(define ~po_message_msgid
  (delay (fh-link-proc
           ffi-void*
           "po_message_msgid"
           (list ffi-void*)
           link-lib)))
(define (po_message_msgid message)
  (let ((~message ((fht-unwrap po_message_t) message)))
    ((force ~po_message_msgid) ~message)))
(export po_message_msgid)

;; extern void po_message_set_msgid(po_message_t message, const char *msgid);
(define ~po_message_set_msgid
  (delay (fh-link-proc
           ffi:void
           "po_message_set_msgid"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_set_msgid message msgid)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~msgid (unwrap~pointer msgid)))
    ((force ~po_message_set_msgid) ~message ~msgid)))
(export po_message_set_msgid)

;; extern const char *po_message_msgid_plural(po_message_t message);
(define ~po_message_msgid_plural
  (delay (fh-link-proc
           ffi-void*
           "po_message_msgid_plural"
           (list ffi-void*)
           link-lib)))
(define (po_message_msgid_plural message)
  (let ((~message ((fht-unwrap po_message_t) message)))
    ((force ~po_message_msgid_plural) ~message)))
(export po_message_msgid_plural)

;; extern void po_message_set_msgid_plural(po_message_t message, const char *
;;     msgid_plural);
(define ~po_message_set_msgid_plural
  (delay (fh-link-proc
           ffi:void
           "po_message_set_msgid_plural"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_set_msgid_plural
         message
         msgid_plural)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~msgid_plural (unwrap~pointer msgid_plural)))
    ((force ~po_message_set_msgid_plural)
     ~message
     ~msgid_plural)))
(export po_message_set_msgid_plural)

;; extern const char *po_message_msgstr(po_message_t message);
(define ~po_message_msgstr
  (delay (fh-link-proc
           ffi-void*
           "po_message_msgstr"
           (list ffi-void*)
           link-lib)))
(define (po_message_msgstr message)
  (let ((~message ((fht-unwrap po_message_t) message)))
    ((force ~po_message_msgstr) ~message)))
(export po_message_msgstr)

;; extern void po_message_set_msgstr(po_message_t message, const char *msgstr)
;;     ;
(define ~po_message_set_msgstr
  (delay (fh-link-proc
           ffi:void
           "po_message_set_msgstr"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_set_msgstr message msgstr)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~msgstr (unwrap~pointer msgstr)))
    ((force ~po_message_set_msgstr) ~message ~msgstr)))
(export po_message_set_msgstr)

;; extern const char *po_message_msgstr_plural(po_message_t message, int index)
;;     ;
(define ~po_message_msgstr_plural
  (delay (fh-link-proc
           ffi-void*
           "po_message_msgstr_plural"
           (list ffi-void* ffi:int)
           link-lib)))
(define (po_message_msgstr_plural message index)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~index (unwrap~fixed index)))
    ((force ~po_message_msgstr_plural)
     ~message
     ~index)))
(export po_message_msgstr_plural)

;; extern void po_message_set_msgstr_plural(po_message_t message, int index, 
;;     const char *msgstr);
(define ~po_message_set_msgstr_plural
  (delay (fh-link-proc
           ffi:void
           "po_message_set_msgstr_plural"
           (list ffi-void* ffi:int ffi-void*)
           link-lib)))
(define (po_message_set_msgstr_plural
         message
         index
         msgstr)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~index (unwrap~fixed index))
        (~msgstr (unwrap~pointer msgstr)))
    ((force ~po_message_set_msgstr_plural)
     ~message
     ~index
     ~msgstr)))
(export po_message_set_msgstr_plural)

;; extern const char *po_message_comments(po_message_t message);
(define ~po_message_comments
  (delay (fh-link-proc
           ffi-void*
           "po_message_comments"
           (list ffi-void*)
           link-lib)))
(define (po_message_comments message)
  (let ((~message ((fht-unwrap po_message_t) message)))
    ((force ~po_message_comments) ~message)))
(export po_message_comments)

;; extern void po_message_set_comments(po_message_t message, const char *
;;     comments);
(define ~po_message_set_comments
  (delay (fh-link-proc
           ffi:void
           "po_message_set_comments"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_set_comments message comments)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~comments (unwrap~pointer comments)))
    ((force ~po_message_set_comments)
     ~message
     ~comments)))
(export po_message_set_comments)

;; extern const char *po_message_extracted_comments(po_message_t message);
(define ~po_message_extracted_comments
  (delay (fh-link-proc
           ffi-void*
           "po_message_extracted_comments"
           (list ffi-void*)
           link-lib)))
(define (po_message_extracted_comments message)
  (let ((~message ((fht-unwrap po_message_t) message)))
    ((force ~po_message_extracted_comments) ~message)))
(export po_message_extracted_comments)

;; extern void po_message_set_extracted_comments(po_message_t message, const 
;;     char *comments);
(define ~po_message_set_extracted_comments
  (delay (fh-link-proc
           ffi:void
           "po_message_set_extracted_comments"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_set_extracted_comments
         message
         comments)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~comments (unwrap~pointer comments)))
    ((force ~po_message_set_extracted_comments)
     ~message
     ~comments)))
(export po_message_set_extracted_comments)

;; extern po_filepos_t po_message_filepos(po_message_t message, int i);
(define ~po_message_filepos
  (delay (fh-link-proc
           ffi-void*
           "po_message_filepos"
           (list ffi-void* ffi:int)
           link-lib)))
(define (po_message_filepos message i)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~i (unwrap~fixed i)))
    ((fht-wrap po_filepos_t)
     ((force ~po_message_filepos) ~message ~i))))
(export po_message_filepos)

;; extern void po_message_remove_filepos(po_message_t message, int i);
(define ~po_message_remove_filepos
  (delay (fh-link-proc
           ffi:void
           "po_message_remove_filepos"
           (list ffi-void* ffi:int)
           link-lib)))
(define (po_message_remove_filepos message i)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~i (unwrap~fixed i)))
    ((force ~po_message_remove_filepos) ~message ~i)))
(export po_message_remove_filepos)

;; extern void po_message_add_filepos(po_message_t message, const char *file, 
;;     size_t start_line);
(define ~po_message_add_filepos
  (delay (fh-link-proc
           ffi:void
           "po_message_add_filepos"
           (list ffi-void* ffi-void* ffi:size_t)
           link-lib)))
(define (po_message_add_filepos message file start_line)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~file (unwrap~pointer file))
        (~start_line (unwrap~fixed start_line)))
    ((force ~po_message_add_filepos)
     ~message
     ~file
     ~start_line)))
(export po_message_add_filepos)

;; extern const char *po_message_prev_msgctxt(po_message_t message);
(define ~po_message_prev_msgctxt
  (delay (fh-link-proc
           ffi-void*
           "po_message_prev_msgctxt"
           (list ffi-void*)
           link-lib)))
(define (po_message_prev_msgctxt message)
  (let ((~message ((fht-unwrap po_message_t) message)))
    ((force ~po_message_prev_msgctxt) ~message)))
(export po_message_prev_msgctxt)

;; extern void po_message_set_prev_msgctxt(po_message_t message, const char *
;;     prev_msgctxt);
(define ~po_message_set_prev_msgctxt
  (delay (fh-link-proc
           ffi:void
           "po_message_set_prev_msgctxt"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_set_prev_msgctxt
         message
         prev_msgctxt)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~prev_msgctxt (unwrap~pointer prev_msgctxt)))
    ((force ~po_message_set_prev_msgctxt)
     ~message
     ~prev_msgctxt)))
(export po_message_set_prev_msgctxt)

;; extern const char *po_message_prev_msgid(po_message_t message);
(define ~po_message_prev_msgid
  (delay (fh-link-proc
           ffi-void*
           "po_message_prev_msgid"
           (list ffi-void*)
           link-lib)))
(define (po_message_prev_msgid message)
  (let ((~message ((fht-unwrap po_message_t) message)))
    ((force ~po_message_prev_msgid) ~message)))
(export po_message_prev_msgid)

;; extern void po_message_set_prev_msgid(po_message_t message, const char *
;;     prev_msgid);
(define ~po_message_set_prev_msgid
  (delay (fh-link-proc
           ffi:void
           "po_message_set_prev_msgid"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_set_prev_msgid message prev_msgid)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~prev_msgid (unwrap~pointer prev_msgid)))
    ((force ~po_message_set_prev_msgid)
     ~message
     ~prev_msgid)))
(export po_message_set_prev_msgid)

;; extern const char *po_message_prev_msgid_plural(po_message_t message);
(define ~po_message_prev_msgid_plural
  (delay (fh-link-proc
           ffi-void*
           "po_message_prev_msgid_plural"
           (list ffi-void*)
           link-lib)))
(define (po_message_prev_msgid_plural message)
  (let ((~message ((fht-unwrap po_message_t) message)))
    ((force ~po_message_prev_msgid_plural) ~message)))
(export po_message_prev_msgid_plural)

;; extern void po_message_set_prev_msgid_plural(po_message_t message, const 
;;     char *prev_msgid_plural);
(define ~po_message_set_prev_msgid_plural
  (delay (fh-link-proc
           ffi:void
           "po_message_set_prev_msgid_plural"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_set_prev_msgid_plural
         message
         prev_msgid_plural)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~prev_msgid_plural
          (unwrap~pointer prev_msgid_plural)))
    ((force ~po_message_set_prev_msgid_plural)
     ~message
     ~prev_msgid_plural)))
(export po_message_set_prev_msgid_plural)

;; extern int po_message_is_obsolete(po_message_t message);
(define ~po_message_is_obsolete
  (delay (fh-link-proc
           ffi:int
           "po_message_is_obsolete"
           (list ffi-void*)
           link-lib)))
(define (po_message_is_obsolete message)
  (let ((~message ((fht-unwrap po_message_t) message)))
    ((force ~po_message_is_obsolete) ~message)))
(export po_message_is_obsolete)

;; extern void po_message_set_obsolete(po_message_t message, int obsolete);
(define ~po_message_set_obsolete
  (delay (fh-link-proc
           ffi:void
           "po_message_set_obsolete"
           (list ffi-void* ffi:int)
           link-lib)))
(define (po_message_set_obsolete message obsolete)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~obsolete (unwrap~fixed obsolete)))
    ((force ~po_message_set_obsolete)
     ~message
     ~obsolete)))
(export po_message_set_obsolete)

;; extern int po_message_is_fuzzy(po_message_t message);
(define ~po_message_is_fuzzy
  (delay (fh-link-proc
           ffi:int
           "po_message_is_fuzzy"
           (list ffi-void*)
           link-lib)))
(define (po_message_is_fuzzy message)
  (let ((~message ((fht-unwrap po_message_t) message)))
    ((force ~po_message_is_fuzzy) ~message)))
(export po_message_is_fuzzy)

;; extern void po_message_set_fuzzy(po_message_t message, int fuzzy);
(define ~po_message_set_fuzzy
  (delay (fh-link-proc
           ffi:void
           "po_message_set_fuzzy"
           (list ffi-void* ffi:int)
           link-lib)))
(define (po_message_set_fuzzy message fuzzy)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~fuzzy (unwrap~fixed fuzzy)))
    ((force ~po_message_set_fuzzy) ~message ~fuzzy)))
(export po_message_set_fuzzy)

;; extern int po_message_is_format(po_message_t message, const char *
;;     format_type);
(define ~po_message_is_format
  (delay (fh-link-proc
           ffi:int
           "po_message_is_format"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_is_format message format_type)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~format_type (unwrap~pointer format_type)))
    ((force ~po_message_is_format)
     ~message
     ~format_type)))
(export po_message_is_format)

;; extern void po_message_set_format(po_message_t message, const char *
;;     format_type, int value);
(define ~po_message_set_format
  (delay (fh-link-proc
           ffi:void
           "po_message_set_format"
           (list ffi-void* ffi-void* ffi:int)
           link-lib)))
(define (po_message_set_format message format_type value)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~format_type (unwrap~pointer format_type))
        (~value (unwrap~fixed value)))
    ((force ~po_message_set_format)
     ~message
     ~format_type
     ~value)))
(export po_message_set_format)

;; extern int po_message_is_range(po_message_t message, int *minp, int *maxp);
(define ~po_message_is_range
  (delay (fh-link-proc
           ffi:int
           "po_message_is_range"
           (list ffi-void* ffi-void* ffi-void*)
           link-lib)))
(define (po_message_is_range message minp maxp)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~minp (unwrap~pointer minp))
        (~maxp (unwrap~pointer maxp)))
    ((force ~po_message_is_range)
     ~message
     ~minp
     ~maxp)))
(export po_message_is_range)

;; extern void po_message_set_range(po_message_t message, int min, int max);
(define ~po_message_set_range
  (delay (fh-link-proc
           ffi:void
           "po_message_set_range"
           (list ffi-void* ffi:int ffi:int)
           link-lib)))
(define (po_message_set_range message min max)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~min (unwrap~fixed min))
        (~max (unwrap~fixed max)))
    ((force ~po_message_set_range)
     ~message
     ~min
     ~max)))
(export po_message_set_range)

;; extern const char *po_filepos_file(po_filepos_t filepos);
(define ~po_filepos_file
  (delay (fh-link-proc
           ffi-void*
           "po_filepos_file"
           (list ffi-void*)
           link-lib)))
(define (po_filepos_file filepos)
  (let ((~filepos ((fht-unwrap po_filepos_t) filepos)))
    ((force ~po_filepos_file) ~filepos)))
(export po_filepos_file)

;; extern size_t po_filepos_start_line(po_filepos_t filepos);
(define ~po_filepos_start_line
  (delay (fh-link-proc
           ffi:size_t
           "po_filepos_start_line"
           (list ffi-void*)
           link-lib)))
(define (po_filepos_start_line filepos)
  (let ((~filepos ((fht-unwrap po_filepos_t) filepos)))
    ((force ~po_filepos_start_line) ~filepos)))
(export po_filepos_start_line)

;; extern const char *const*po_format_list(void);
(define ~po_format_list
  (delay (fh-link-proc
           ffi-void*
           "po_format_list"
           (list)
           link-lib)))
(define (po_format_list)
  (let () ((force ~po_format_list))))
(export po_format_list)

;; extern const char *po_format_pretty_name(const char *format_type);
(define ~po_format_pretty_name
  (delay (fh-link-proc
           ffi-void*
           "po_format_pretty_name"
           (list ffi-void*)
           link-lib)))
(define (po_format_pretty_name format_type)
  (let ((~format_type (unwrap~pointer format_type)))
    ((force ~po_format_pretty_name) ~format_type)))
(export po_format_pretty_name)

;; extern void po_file_check_all(po_file_t file, po_xerror_handler_t handler);
(define ~po_file_check_all
  (delay (fh-link-proc
           ffi:void
           "po_file_check_all"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_file_check_all file handler)
  (let ((~file ((fht-unwrap po_file_t) file))
        (~handler
          ((fht-unwrap po_xerror_handler_t) handler)))
    ((force ~po_file_check_all) ~file ~handler)))
(export po_file_check_all)

;; extern void po_message_check_all(po_message_t message, po_message_iterator_t
;;      iterator, po_xerror_handler_t handler);
(define ~po_message_check_all
  (delay (fh-link-proc
           ffi:void
           "po_message_check_all"
           (list ffi-void* ffi-void* ffi-void*)
           link-lib)))
(define (po_message_check_all message iterator handler)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~iterator
          ((fht-unwrap po_message_iterator_t) iterator))
        (~handler
          ((fht-unwrap po_xerror_handler_t) handler)))
    ((force ~po_message_check_all)
     ~message
     ~iterator
     ~handler)))
(export po_message_check_all)

;; extern void po_message_check_format_v2(po_message_t message, 
;;     po_xerror_handler_t handler);
(define ~po_message_check_format_v2
  (delay (fh-link-proc
           ffi:void
           "po_message_check_format_v2"
           (list ffi-void* ffi-void*)
           link-lib)))
(define (po_message_check_format_v2 message handler)
  (let ((~message ((fht-unwrap po_message_t) message))
        (~handler
          ((fht-unwrap po_xerror_handler_t) handler)))
    ((force ~po_message_check_format_v2)
     ~message
     ~handler)))
(export po_message_check_format_v2)

;; access to enum symbols and #define'd constants:
(define gettext-po-symbol-val
  (let ((sym-tab
          '((_GETTEXT_PO_H . 1)
            (LIBGETTEXTPO_VERSION . 4872)
            (PO_SEVERITY_WARNING . 0)
            (PO_SEVERITY_ERROR . 1)
            (PO_SEVERITY_FATAL_ERROR . 2))))
    (lambda (k) (or (assq-ref sym-tab k)))))
(export gettext-po-symbol-val)

(define (unwrap-enum obj)
  (cond ((number? obj) obj)
        ((symbol? obj) (gettext-po-symbol-val obj))
        ((fh-object? obj) (struct-ref obj 0))
        (else (error "type mismatch"))))

(define gettext-po-types
  '("po_file_t" "po_message_iterator_t" "po_message_t" "po_filepos_t" (struct 
    . "po_error_handler") "po_error_handler_t" (struct . "po_xerror_handler") 
    "po_xerror_handler_t"))
(export gettext-po-types)

;; TODO: add renamer

;; --- last line ---