Lines Matching refs:this

16    along with this program.  If not, see <https://www.gnu.org/licenses/>.
19 additional uses of the libraries contained in this release of SANE.
22 to produce an executable, this does not by itself cause the
33 those changes may be distributed with this exception intact.
36 whether to permit this exception to apply to your modifications.
37 If you do not wish that, delete this exception notice.
91 hp_handle_isScanning (HpHandle this)
93 return this->reader_pid != 0;
102 struct hp_handle_s *this = (struct hp_handle_s *) data;
108 (long) this->scsi, this->pipe_write_fd);
114 status = sanei_hp_scsi_pipeout (this->scsi, this->pipe_write_fd,
115 &(this->procdata));
118 close (this->pipe_write_fd);
119 this->pipe_write_fd = -1;
120 sanei_hp_scsi_destroy (this->scsi, 0);
130 struct hp_handle_s *this = (struct hp_handle_s *) data;
136 close (this->pipe_read_fd);
137 this->pipe_read_fd = -1;
142 sigdelset(&(this->sig_set), SIGTERM);
143 sigprocmask(SIG_SETMASK, &(this->sig_set), 0);
146 status = sanei_hp_scsi_pipeout (this->scsi, this->pipe_write_fd,
147 &(this->procdata));
148 close (this->pipe_write_fd);
149 this->pipe_write_fd = -1;
155 hp_handle_startReader (HpHandle this, HpScsi scsi)
160 assert(this->reader_pid == 0);
161 this->cancelled = 0;
162 this->pipe_write_fd = this->pipe_read_fd = -1;
167 sigfillset(&(this->sig_set));
168 sigprocmask(SIG_BLOCK, &(this->sig_set), &old_set);
170 this->scsi = scsi;
171 this->pipe_write_fd = fds[1];
172 this->pipe_read_fd = fds[0];
175 this->child_forked = sanei_thread_is_forked ();
179 this->reader_pid = sanei_thread_begin (this->child_forked ? reader_process :
180 reader_thread, (void *) this);
181 if (this->reader_pid != 0)
186 if ( this->child_forked )
189 close (this->pipe_write_fd);
190 this->pipe_write_fd = -1;
193 if (!sanei_thread_is_valid (this->reader_pid))
195 if ( !this->child_forked )
197 close (this->pipe_write_fd);
198 this->pipe_write_fd = -1;
200 close (this->pipe_read_fd);
201 this->pipe_read_fd = -1;
208 DBG(1, "start_reader: reader process %ld started\n", (long) this->reader_pid);
217 hp_handle_stopScan (HpHandle this)
221 this->cancelled = 0;
222 this->bytes_left = 0;
224 if (this->reader_pid)
227 DBG(3, "hp_handle_stopScan: killing child (%ld)\n", (long) this->reader_pid);
228 sanei_thread_kill (this->reader_pid);
229 sanei_thread_waitpid(this->reader_pid, &info);
234 close(this->pipe_read_fd);
235 this->reader_pid = 0;
237 if ( !FAILED( sanei_hp_scsi_new(&scsi, this->dev->sanedev.name)) )
258 hp_handle_uploadParameters (HpHandle this, HpScsi scsi, int *scan_depth,
261 SANE_Parameters * p = &this->scan_params;
281 switch (sanei_hp_optset_scanmode(this->dev->options, this->data)) {
304 *out8 = sanei_hp_optset_output_8bit (this->dev->options, this->data);
321 *out8 = sanei_hp_optset_output_8bit (this->dev->options, this->data);
365 sanei_hp_handle_destroy (HpHandle this)
371 hp_handle_stopScan(this);
373 if (sanei_hp_scsi_new(&scsi,this->dev->sanedev.name)==SANE_STATUS_GOOD &&
378 sanei_hp_data_destroy(this->data);
379 sanei_hp_free(this);
383 sanei_hp_handle_saneoption (HpHandle this, SANE_Int optnum)
385 if (this->cancelled)
388 hp_handle_stopScan(this);
390 return sanei_hp_optset_saneoption(this->dev->options, this->data, optnum);
394 sanei_hp_handle_control(HpHandle this, SANE_Int optnum,
401 if (this->cancelled)
404 RETURN_IF_FAIL( hp_handle_stopScan(this) );
407 if (hp_handle_isScanning(this))
410 RETURN_IF_FAIL( sanei_hp_scsi_new(&scsi, this->dev->sanedev.name) );
412 immediate = sanei_hp_optset_isImmediate(this->dev->options, optnum);
414 status = sanei_hp_optset_control(this->dev->options, this->data,
423 sanei_hp_handle_getParameters (HpHandle this, SANE_Parameters *params)
430 if (this->cancelled)
433 RETURN_IF_FAIL( hp_handle_stopScan(this) );
436 if (hp_handle_isScanning(this))
438 *params = this->scan_params;
442 status = sanei_hp_optset_guessParameters(this->dev->options,
443 this->data, params);
445 /* Photosmart: this gives the correct number of lines when doing
447 if (!strcmp("C5100A", this->dev->sanedev.model)) {
449 SANE_Parameters * p = &this->scan_params;
451 if (!FAILED( sanei_hp_scsi_new(&scsi, this->dev->sanedev.name) )) {
455 *params = this->scan_params;
463 sanei_hp_handle_startScan (HpHandle this)
468 HpProcessData *procdata = &(this->procdata);
473 if (hp_handle_isScanning(this))
476 RETURN_IF_FAIL( hp_handle_stopScan(this) );
479 RETURN_IF_FAIL( sanei_hp_scsi_new(&scsi, this->dev->sanedev.name) );
481 status = sanei_hp_optset_download(this->dev->options, this->data, scsi);
484 status = hp_handle_uploadParameters(this, scsi,
496 sanei_hp_optset_mirror_vert (this->dev->options, this->data, scsi);
500 scl = sanei_hp_optset_scan_type (this->dev->options, this->data);
523 if ( (sanei_hp_device_support_get (this->dev->sanedev.name,
526 && (sanei_hp_device_support_get (this->dev->sanedev.name,
539 else if ( sanei_hp_device_support_get (this->dev->sanedev.name,
612 this->bytes_left = ( this->scan_params.bytes_per_line
613 * this->scan_params.lines );
616 this->scan_params.pixels_per_line, this->scan_params.bytes_per_line,
617 this->scan_params.lines);
618 procdata->bytes_per_line = (int)this->scan_params.bytes_per_line;
625 procdata->lines = this->scan_params.lines;
628 status = sanei_hp_optset_start_wait(this->dev->options, this->data);
643 status = hp_handle_startReader(this, scsi);
647 if (this->child_forked)
655 sanei_hp_handle_read (HpHandle this, void * buf, size_t *lengthp)
663 if (!hp_handle_isScanning(this))
669 if (this->cancelled)
672 RETURN_IF_FAIL( hp_handle_stopScan(this) );
679 if (*lengthp > this->bytes_left)
680 *lengthp = this->bytes_left;
682 if ((nread = read(this->pipe_read_fd, buf, *lengthp)) < 0)
689 hp_handle_stopScan(this);
693 this->bytes_left -= (*lengthp = nread);
702 status = this->bytes_left ? SANE_STATUS_IO_ERROR : SANE_STATUS_EOF;
703 RETURN_IF_FAIL( hp_handle_stopScan(this) );
711 if ( sanei_hp_scsi_new(&scsi, this->dev->sanedev.name) == SANE_STATUS_GOOD )
713 hpinfo = sanei_hp_device_info_get ( this->dev->sanedev.name );
728 sanei_hp_handle_cancel (HpHandle this)
730 this->cancelled = 1;
734 (int)this->dev->compat);
735 if ( (this->reader_pid)
736 && (this->dev->compat & HP_COMPAT_OJ_1150C) )
739 (long) this->reader_pid);
740 sanei_thread_kill(this->reader_pid);
745 sanei_hp_handle_setNonblocking (HpHandle this, hp_bool_t non_blocking)
747 if (!hp_handle_isScanning(this))
750 if (this->cancelled)
753 RETURN_IF_FAIL( hp_handle_stopScan(this) );
757 if (fcntl(this->pipe_read_fd, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0)
764 sanei_hp_handle_getPipefd (HpHandle this, SANE_Int *fd)
766 if (! hp_handle_isScanning(this))
769 if (this->cancelled)
772 RETURN_IF_FAIL( hp_handle_stopScan(this) );
776 *fd = this->pipe_read_fd;