1 /*
2  * Copyright (C) 2021  Brodie Gaslam
3  *
4  * This file is part of "fansi - ANSI Control Sequence Aware String Functions"
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * Go to <https://www.r-project.org/Licenses/GPL-2> for a copy of the license.
17  */
18 
19 #include "fansi.h"
20 #include <R_ext/Rdynload.h>
21 
22 static const
23 R_CallMethodDef callMethods[] = {
24   {"has_csi", (DL_FUNC) &FANSI_has, 3},
25   {"strip_csi", (DL_FUNC) &FANSI_strip, 3},
26   {"strwrap_csi", (DL_FUNC) &FANSI_strwrap_ext, 15},
27   {"state_at_pos_ext", (DL_FUNC) &FANSI_state_at_pos_ext, 8},
28   {"process", (DL_FUNC) &FANSI_process_ext, 1},
29   {"check_assumptions", (DL_FUNC) &FANSI_check_assumptions, 0},
30   {"digits_in_int", (DL_FUNC) &FANSI_digits_in_int_ext, 1},
31   {"tabs_as_spaces", (DL_FUNC) &FANSI_tabs_as_spaces_ext, 5},
32   {"color_to_html", (DL_FUNC) &FANSI_color_to_html_ext, 1},
33   {"esc_to_html", (DL_FUNC) &FANSI_esc_to_html, 4},
34   {"unhandled_esc", (DL_FUNC) &FANSI_unhandled_esc, 2},
35   {"unique_chr", (DL_FUNC) &FANSI_unique_chr, 1},
36   {"nzchar_esc", (DL_FUNC) &FANSI_nzchar, 5},
37   {"add_int", (DL_FUNC) &FANSI_add_int_ext, 2},
38   {"strsplit", (DL_FUNC) &FANSI_strsplit, 3},
39   {"cleave", (DL_FUNC) &FANSI_cleave, 1},
40   {"order", (DL_FUNC) &FANSI_order, 1},
41   {"sort_int", (DL_FUNC) &FANSI_sort_int, 1},
42   {"sort_chr", (DL_FUNC) &FANSI_sort_chr, 1},
43   {"set_int_max", (DL_FUNC) &FANSI_set_int_max, 1},
44   {"get_int_max", (DL_FUNC) &FANSI_get_int_max, 0},
45   {"check_enc", (DL_FUNC) &FANSI_check_enc_ext, 2},
46   {"ctl_as_int", (DL_FUNC) &FANSI_ctl_as_int_ext, 1},
47   {"esc_html", (DL_FUNC) &FANSI_esc_html, 1},
48   {NULL, NULL, 0}
49 };
50 
51 SEXP FANSI_warn_sym;
52 
R_init_fansi(DllInfo * info)53 void R_init_fansi(DllInfo *info)
54 {
55  /* Register the .C and .Call routines.
56     No .Fortran() or .External() routines,
57     so pass those arrays as NULL.
58   */
59   R_registerRoutines(info, NULL, callMethods, NULL, NULL);
60   R_useDynamicSymbols(info, FALSE);
61   R_forceSymbols(info, FALSE);
62 
63   FANSI_warn_sym = install("warn");
64 }
65 
66