static SANE_Status init (struct backend *be) { SANE_Status status; SANE_Int version; if (!be->loaded) { status = load (be); if (status != SANE_STATUS_GOOD) return status; } DBG(3, "init: initializing backend `%s'\n", be->name); status = (long) (*be->op[OP_INIT]) (&version, auth_callback); if (status != SANE_STATUS_GOOD) return status; if (SANE_VERSION_MAJOR (version) != V_MAJOR) { DBG(1, "init: backend `%s' has a wrong major version (%d instead of %d)\n", be->name, SANE_VERSION_MAJOR (version), V_MAJOR); return SANE_STATUS_INVAL; } DBG(4, "init: backend `%s' is version %d.%d.%d\n", be->name, SANE_VERSION_MAJOR(version), SANE_VERSION_MINOR(version), SANE_VERSION_BUILD(version)); be->inited = 1; return SANE_STATUS_GOOD; }
G_MODULE_EXPORT void gnome_scan_module_init (GnomeScanModule *module) { SANE_Status status; SANE_Int version; /* TODO: version checking */ status = sane_init(&version, NULL); bind_textdomain_codeset("sane-backends","UTF-8"); g_message (G_STRLOC ": SANE version is %i.%i.%i for GSANE %s", SANE_VERSION_MAJOR(version), SANE_VERSION_MINOR(version), SANE_VERSION_BUILD(version), PACKAGE_VERSION); if (SANE_VERSION_MAJOR(version) != SANE_CURRENT_MAJOR) { g_warning (G_STRLOC ": SANE major version must be %i.", SANE_CURRENT_MAJOR); return; } gsane_backend_register (G_TYPE_MODULE (module)); gsane_scanner_register (G_TYPE_MODULE (module)); /* GSane option handling */ gsane_option_manager = gsane_option_manager_new(); gsane_option_manager_add_rule_by_type(gsane_option_manager, SANE_TYPE_BOOL, GSANE_TYPE_OPTION_HANDLER_GENERIC); gsane_option_manager_add_rule_by_type(gsane_option_manager, SANE_TYPE_INT, GSANE_TYPE_OPTION_HANDLER_GENERIC); gsane_option_manager_add_rule_by_type(gsane_option_manager, SANE_TYPE_FIXED, GSANE_TYPE_OPTION_HANDLER_GENERIC); gsane_option_manager_add_rule_by_type(gsane_option_manager, SANE_TYPE_STRING, GSANE_TYPE_OPTION_HANDLER_GENERIC); gsane_option_manager_add_rules_by_name(gsane_option_manager, GSANE_TYPE_OPTION_SOURCE, "source", "doc-source", NULL); gsane_option_manager_add_rules_by_name(gsane_option_manager, GSANE_TYPE_OPTION_PRIMARY, "resolution", "mode", NULL); gsane_option_manager_add_rules_by_name(gsane_option_manager, GSANE_TYPE_OPTION_AREA, "tl-x", "tl-y", "br-x", "br-y", NULL); }
static PyObject *init (PyObject * self, PyObject * args) { SANE_Status st; SANE_Int version; if (!PyArg_ParseTuple (args, "")) raiseError("Invalid arguments."); /* XXX Authorization is not yet supported */ st = sane_init (&version, auth_callback); if (st != SANE_STATUS_GOOD) return raiseSaneError (st); return Py_BuildValue ("iiii", version, SANE_VERSION_MAJOR (version), SANE_VERSION_MINOR (version), SANE_VERSION_BUILD (version)); }