extern SANE_Status sane_hpaio_open(SANE_String_Const devicename, SANE_Handle * pHandle) { struct hpmud_model_attributes ma; char devname[256]; /* Get device attributes and determine what backend to call. */ snprintf(devname, sizeof(devname)-1, "hp:%s", devicename); /* prepend "hp:" */ hpmud_query_model(devname, &ma); DBG(8, "sane_hpaio_open(%s): %s %d scan_type=%d scansrc=%d\n", devicename, __FILE__, __LINE__, ma.scantype, ma.scansrc); if ((ma.scantype == HPMUD_SCANTYPE_MARVELL) || (ma.scantype == HPMUD_SCANTYPE_MARVELL2)) return marvell_open(devicename, pHandle); if (ma.scantype == HPMUD_SCANTYPE_SOAP) return soap_open(devicename, pHandle); if (ma.scantype == HPMUD_SCANTYPE_SOAPHT) return soapht_open(devicename, pHandle); if (ma.scantype == HPMUD_SCANTYPE_LEDM) return ledm_open(devicename, pHandle); if ((ma.scantype == HPMUD_SCANTYPE_SCL) || (ma.scantype == HPMUD_SCANTYPE_SCL_DUPLEX) ||(ma.scantype == HPMUD_SCANTYPE_PML)) return sclpml_open(devicename, pHandle); if (ma.scantype == HPMUD_SCANTYPE_ESCL) return escl_open(devicename, pHandle); if (ma.scantype == HPMUD_SCANTYPE_ORBLITE) return orblite_open(devicename, pHandle); else return SANE_STATUS_UNSUPPORTED; } /* sane_hpaio_open() */
static int AddDevice(char *uri) { struct hpmud_model_attributes ma; char model[HPMUD_LINE_SIZE]; char new_uri[256]; int len = 0, i = 0, j = 0; int scan_type; int device_added = 0; hpmud_query_model(uri, &ma); if (ma.scantype > 0) { hpmud_get_uri_model(uri, model, sizeof(model)); AddDeviceList(uri, model, &DeviceList); device_added = 1; } else { // This is added to make the uri hp:/net/hp_model_name?ip-xxx.xxx.xxx.xxx&queue=false // For some of the devices the scan MDL recevied would be model_name instead of hp_model_name len = strlen(uri); strncpy(new_uri, uri, 9); new_uri[8] = 'h'; new_uri[9] = 'p'; new_uri[10] = '_'; for (i = 11,j = 8; j<=len; ++i, ++j) new_uri[i] = uri[j]; hpmud_query_model(new_uri, &ma); DBG(6,"scantype=%d %s\n", ma.scantype, new_uri); if(ma.scantype>0) { hpmud_get_uri_model(new_uri, model, sizeof(model)); AddDeviceList(new_uri, model, &DeviceList); device_added = 1; } else { DBG(6,"unsupported scantype=%d %s\n", ma.scantype, new_uri); } } return device_added; }
SANE_Status soapht_open(SANE_String_Const device, SANE_Handle *handle) { struct hpmud_model_attributes ma; int i, stat = SANE_STATUS_IO_ERROR; DBG8("sane_hpaio_open(%s)\n", device); if (session) { BUG("session in use\n"); return SANE_STATUS_DEVICE_BUSY; } if ((session = create_session()) == NULL) return SANE_STATUS_NO_MEM; /* Set session to specified device. */ snprintf(session->uri, sizeof(session->uri)-1, "hp:%s", device); /* prepend "hp:" */ /* Get actual model attributes from models.dat. */ hpmud_query_model(session->uri, &ma); session->scan_type = ma.scantype; if (hpmud_open_device(session->uri, ma.mfp_mode, &session->dd) != HPMUD_R_OK) { BUG("unable to open device %s\n", session->uri); goto bugout; free(session); session = NULL; return SANE_STATUS_IO_ERROR; } if (bb_load(session, SCAN_PLUGIN_SOAPHT)) { stat = SANE_STATUS_IO_ERROR; goto bugout; } /* Init sane option descriptors. */ init_options(session); if (session->bb_open(session)) { stat = SANE_STATUS_IO_ERROR; goto bugout; } /* Set supported Scan Modes as determined by bb_open. */ soapht_control_option(session, SOAP_OPTION_SCAN_MODE, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Set scan input sources as determined by bb_open. */ soapht_control_option(session, SOAP_OPTION_INPUT_SOURCE, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Set supported resolutions. */ soapht_control_option(session, SOAP_OPTION_SCAN_RESOLUTION, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Set supported brightness. */ soapht_control_option(session, SOAP_OPTION_BRIGHTNESS, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Set supported contrast. */ soapht_control_option(session, SOAP_OPTION_CONTRAST, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Set supported compression. (Note, cm1017 may say it supports MMR, but it doesn't) */ soapht_control_option(session, SOAP_OPTION_COMPRESSION, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Determine supported jpeg quality factor as determined by bb_open. */ soapht_control_option(session, SOAP_OPTION_JPEG_QUALITY, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Set x,y extents. See bb_open */ soapht_control_option(session, SOAP_OPTION_TL_X, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ soapht_control_option(session, SOAP_OPTION_TL_Y, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ soapht_control_option(session, SOAP_OPTION_BR_X, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ soapht_control_option(session, SOAP_OPTION_BR_Y, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ *handle = (SANE_Handle *)session; stat = SANE_STATUS_GOOD; bugout: if (stat != SANE_STATUS_GOOD) { if (session) { bb_unload(session); if (session->dd > 0) hpmud_close_device(session->dd); free(session); session = NULL; } } return stat; } /* saneht_open */
SANE_Status __attribute__ ((visibility ("hidden"))) ledm_open(SANE_String_Const device, SANE_Handle *handle) { struct hpmud_model_attributes ma; int stat = SANE_STATUS_IO_ERROR; if(session) { return SANE_STATUS_DEVICE_BUSY; } if((session = create_session()) == NULL) return SANE_STATUS_NO_MEM; /* Set session to specified device. */ snprintf(session->uri, sizeof(session->uri)-1, "hp:%s", device); /* prepend "hp:" */ /* Get actual model attributes from models.dat. */ hpmud_query_model(session->uri, &ma); session->scan_type = ma.scantype; if (hpmud_open_device(session->uri, ma.mfp_mode, &session->dd) != HPMUD_R_OK) { stat = SANE_STATUS_IO_ERROR; goto bugout; } init_options(session); if (bb_open(session)) { stat = SANE_STATUS_IO_ERROR; goto bugout; } /* Set supported Scan Modes as determined by bb_open. */ ledm_control_option(session, LEDM_OPTION_SCAN_MODE, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Set scan input sources as determined by bb_open. */ ledm_control_option(session, LEDM_OPTION_INPUT_SOURCE, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Set supported resolutions. */ ledm_control_option(session, LEDM_OPTION_SCAN_RESOLUTION, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Set supported contrast. */ ledm_control_option(session, LEDM_OPTION_CONTRAST, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Set supported compression. (Note, cm1017 may say it supports MMR, but it doesn't) */ ledm_control_option(session, LEDM_OPTION_COMPRESSION, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Determine supported jpeg quality factor as determined by bb_open. */ ledm_control_option(session, LEDM_OPTION_JPEG_QUALITY, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ /* Set x,y extents. See bb_open */ ledm_control_option(session, LEDM_OPTION_TL_X, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ ledm_control_option(session, LEDM_OPTION_TL_Y, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ ledm_control_option(session, LEDM_OPTION_BR_X, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ ledm_control_option(session, LEDM_OPTION_BR_Y, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */ *handle = (SANE_Handle *)session; stat = SANE_STATUS_GOOD; bugout: if (stat != SANE_STATUS_GOOD) { if (session) { bb_close(session); if (session->cd > 0) hpmud_close_channel(session->dd, session->cd); if (session->dd > 0) hpmud_close_device(session->dd); free(session); session = NULL; } } return stat; }