2000-03-05 13:57:01 +00:00
|
|
|
/* sane - Scanner Access Now Easy.
|
2001-08-11 09:46:55 +00:00
|
|
|
Copyright (C) 1998-2001 Yuri Dario
|
2000-03-05 13:57:01 +00:00
|
|
|
This file is part of the SANE package.
|
|
|
|
|
|
|
|
SANE is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
|
|
|
Software Foundation; either version 2 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
SANE is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with sane; see the file COPYING. If not, write to the Free
|
|
|
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2002-01-19 22:32:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file sanei_thread.h
|
|
|
|
* Header file to make porting fork, wait, and waitpid easier.
|
|
|
|
*
|
|
|
|
* This file contains helper functions for the OS/2 port (using threads
|
|
|
|
* instead of forked processes). <b>Do not use these functions in the backends
|
|
|
|
* directly</b>, they are used automatically by macros. Just include this file
|
|
|
|
* in an \#ifdef HAVE_OS2_H statement if you use fork. If your reader process
|
|
|
|
* has more than one argument, you also need to implement a
|
|
|
|
* os2_reader_process() in your backend. The implementation should call your
|
|
|
|
* own reader process. See mustek.c for an example.
|
|
|
|
*
|
|
|
|
* The preprocessor is used for routing process-related function to OS/2
|
|
|
|
* threaded code: in this way, Unix backends requires only minimal code
|
|
|
|
* changes.
|
1994-02-15 21:37:33 +00:00
|
|
|
*
|
|
|
|
* @sa sanei.h sanei_backend.h
|
2002-01-19 22:32:05 +00:00
|
|
|
*/
|
2000-03-05 13:57:01 +00:00
|
|
|
|
2002-01-20 20:08:31 +00:00
|
|
|
|
2000-03-05 13:57:01 +00:00
|
|
|
#ifndef sanei_thread_h
|
|
|
|
#define sanei_thread_h
|
2001-08-11 09:46:55 +00:00
|
|
|
#include "../include/sane/config.h"
|
2000-03-05 13:57:01 +00:00
|
|
|
|
1994-02-15 21:37:33 +00:00
|
|
|
/** @name Internal functions
|
|
|
|
* @{
|
|
|
|
*/
|
2002-01-19 22:32:05 +00:00
|
|
|
/** <b>Do not use in backends</b>
|
|
|
|
*
|
|
|
|
* Wrapper for @c fork.
|
|
|
|
*/
|
2001-08-11 09:46:55 +00:00
|
|
|
extern int sanei_thread_begin( void (*start)(void *arg), void* arg_list);
|
2002-01-19 22:32:05 +00:00
|
|
|
|
|
|
|
/** <b>Do not use in backends</b>
|
|
|
|
*
|
|
|
|
* Wrapper for @c kill.
|
|
|
|
*/
|
2000-03-05 13:57:01 +00:00
|
|
|
extern int sanei_thread_kill( int pid, int sig);
|
2002-01-19 22:32:05 +00:00
|
|
|
|
|
|
|
/** <b>Do not use in backends</b>
|
|
|
|
*
|
|
|
|
* Wrapper for @c waitpid.
|
|
|
|
*/
|
2000-03-05 13:57:01 +00:00
|
|
|
extern int sanei_thread_waitpid( int pid, int *stat_loc, int options);
|
2002-01-19 22:32:05 +00:00
|
|
|
|
|
|
|
/** <b>Do not use in backends</b>
|
|
|
|
*
|
|
|
|
* Wrapper for @c wait.
|
|
|
|
*/
|
2000-03-05 13:57:01 +00:00
|
|
|
extern int sanei_thread_wait( int *stat_loc);
|
1994-02-15 21:37:33 +00:00
|
|
|
/* @} */
|
2000-03-05 13:57:01 +00:00
|
|
|
|
2002-01-19 22:32:05 +00:00
|
|
|
/** Reader process function.
|
|
|
|
*
|
|
|
|
* This wrapper is necessary if a backend's reader process need more than one
|
|
|
|
* argument. Add a function to you backend with this name and let it call your
|
|
|
|
* own reader process. See mustek.c for an example.
|
|
|
|
*/
|
2001-08-11 09:46:55 +00:00
|
|
|
static void os2_reader_process( void* data);
|
|
|
|
|
|
|
|
#ifdef HAVE_OS2_H
|
|
|
|
#define fork() sanei_thread_begin( os2_reader_process)
|
|
|
|
#define kill( a, b) sanei_thread_kill( a,b)
|
|
|
|
#define waitpid( a, b, c) sanei_thread_waitpid( a, b, c)
|
|
|
|
#endif
|
|
|
|
|
2000-03-05 13:57:01 +00:00
|
|
|
#endif /* sanei_thread_h */
|