#include <R.h>
#include <Rinternals.h>
#include <R_ext/Rdynload.h>

SEXP C_jgd(SEXP s_width, SEXP s_height, SEXP s_dpi, SEXP s_socket);
SEXP C_jgd_poll_resize(void);
SEXP C_jgd_server_info(SEXP s_path);
SEXP C_jgd_set_ext(SEXP s_json);
SEXP C_jgd_set_frame_ext(SEXP s_json);
SEXP C_jgd_begin_group(SEXP s_ext);
SEXP C_jgd_end_group(void);
SEXP C_jgd_update_snapshot(void);
SEXP C_jgd_discover(SEXP s_path);

static const R_CallMethodDef CallEntries[] = {
    {"C_jgd",               (DL_FUNC) &C_jgd,               4},
    {"C_jgd_poll_resize",   (DL_FUNC) &C_jgd_poll_resize,   0},
    {"C_jgd_server_info",   (DL_FUNC) &C_jgd_server_info,   1},
    {"C_jgd_set_ext",       (DL_FUNC) &C_jgd_set_ext,       1},
    {"C_jgd_set_frame_ext", (DL_FUNC) &C_jgd_set_frame_ext, 1},
    {"C_jgd_begin_group",   (DL_FUNC) &C_jgd_begin_group,   1},
    {"C_jgd_end_group",     (DL_FUNC) &C_jgd_end_group,     0},
    {"C_jgd_update_snapshot", (DL_FUNC) &C_jgd_update_snapshot, 0},
    {"C_jgd_discover",      (DL_FUNC) &C_jgd_discover,      1},
    {NULL, NULL, 0}
};

void R_init_jgd(DllInfo *dll) {
    R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
    R_useDynamicSymbols(dll, FALSE);
    R_forceSymbols(dll, TRUE);
}
