pike.git / src / modules / SANE / sane.c

version» Context lines:

pike.git/src/modules/SANE/sane.c:12:      #include "global.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "threads.h"   #include "array.h" - #include "error.h" + #include "pike_error.h"   #include "mapping.h"   #include "multiset.h"   #include "backend.h"   #include "operators.h"   #include "module_support.h"   #include "builtin_functions.h"      #include "../Image/image.h"      /* must be included last */   #include "module_magic.h"    - RCSID("$Id: sane.c,v 1.7 2000/08/10 09:51:54 per Exp $"); + RCSID("$Id: sane.c,v 1.8 2000/12/01 08:10:23 hubbe Exp $");      /*   **! module SANE   **!   **! This module enables access to the SANE (Scanner Access Now Easy)   **! library from pike   **!   **! note - **! $Id: sane.c,v 1.7 2000/08/10 09:51:54 per Exp $ + **! $Id: sane.c,v 1.8 2000/12/01 08:10:23 hubbe Exp $   */      static int sane_is_inited;      struct scanner   {    SANE_Handle h;   };      static void init_sane()   {    if( sane_init( NULL, NULL ) ) -  error( "Sane init failed.\n" ); +  Pike_error( "Sane init failed.\n" );    sane_is_inited = 1;   }      static void push_device( SANE_Device *d )   {    push_text( "name" ); push_text( d->name );    push_text( "vendor" ); push_text( d->vendor );    push_text( "model" ); push_text( d->model );    push_text( "type" ); push_text( d->type );    f_aggregate_mapping( 8 );
pike.git/src/modules/SANE/sane.c:100:    int i = 0;       if( !sane_is_inited ) init_sane();    switch( sane_get_devices( (void *)&devices, 0 ) )    {    case 0:    while( devices[i] ) push_device( devices[i++] );    f_aggregate( i );    break;    default: -  error("Failed to get device list\n"); +  Pike_error("Failed to get device list\n");    }   }      #define THIS ((struct scanner *)Pike_fp->current_storage)      static void push_option_descriptor( const SANE_Option_Descriptor *o )   {    int i;    struct svalue *osp = sp;    push_text( "name" );
pike.git/src/modules/SANE/sane.c:210:   **! class Scanner   **! Scanner s = Scanner( scanner name )   */   static void f_scanner_create( INT32 args )   {    char *name;    if(!sane_is_inited) init_sane();    get_all_args( "create", args, "%s", &name );       if( sane_open( name, &THIS->h ) ) -  error("Failed to open scanner \"%s\"\n", name ); +  Pike_error("Failed to open scanner \"%s\"\n", name );   }      /*   **! function array(mapping) list_options( )   */   static void f_scanner_list_options( INT32 args )   {    int i, n;    const SANE_Option_Descriptor *d;    pop_n_elems( args );
pike.git/src/modules/SANE/sane.c:237:   static int find_option( char *name, const SANE_Option_Descriptor **p )   {    int i;    const SANE_Option_Descriptor *d;    for( i = 1; (d = sane_get_option_descriptor( THIS->h, i ) ); i++ )    if(d->name && !strcmp( d->name, name ) )    {    *p = d;    return i;    } -  error("No such option: %s\n", name ); +  Pike_error("No such option: %s\n", name );   }         /*   **! function void set_option( string name, mixed new_value )   **! function void set_option( string name )   **! If no value is specified, the option is set to it's default value   */   static void f_scanner_set_option( INT32 args )   {
pike.git/src/modules/SANE/sane.c:410:   static void assert_image_program()   {    if( !image_program )    {    push_text( "Image.Image" );    APPLY_MASTER( "resolv", 1 );    image_program = program_from_svalue( sp - 1 );    sp--;/* Do not free image program.. */    }    if( !image_program ) -  error("No Image.Image?!\n"); +  Pike_error("No Image.Image?!\n");   }      /*   **! function Image.Image simple_scan( )   */   static void f_scanner_simple_scan( INT32 args )   {    SANE_Parameters p;    SANE_Handle h = THIS->h;    struct object *o;    rgb_group *r;          assert_image_program();       pop_n_elems( args ); -  if( sane_start( THIS->h ) ) error("Start failed\n"); -  if( sane_get_parameters( THIS->h, &p ) ) error("Get parameters failed\n"); +  if( sane_start( THIS->h ) ) Pike_error("Start failed\n"); +  if( sane_get_parameters( THIS->h, &p ) ) Pike_error("Get parameters failed\n");       if( p.depth != 8 ) -  error("Sorry, only depth 8 supported right now.\n"); +  Pike_error("Sorry, only depth 8 supported right now.\n");       push_int( p.pixels_per_line );    push_int( p.lines );    o = clone_object( image_program, 2 );    r = ((struct image *)o->storage)->img;       THREADS_ALLOW();    do    {    switch( p.format )
pike.git/src/modules/SANE/sane.c:480:   */   static void f_scanner_row_scan( INT32 args )   {    SANE_Parameters p;    SANE_Handle h = THIS->h;    struct svalue *s;    struct object *o;    rgb_group *r, or;    int i, nr;    -  if( sane_start( THIS->h ) ) error("Start failed\n"); -  if( sane_get_parameters( THIS->h, &p ) ) error("Get parameters failed\n"); -  if( p.depth != 8 ) error("Sorry, only depth 8 supported right now.\n"); +  if( sane_start( THIS->h ) ) Pike_error("Start failed\n"); +  if( sane_get_parameters( THIS->h, &p ) ) Pike_error("Get parameters failed\n"); +  if( p.depth != 8 ) Pike_error("Sorry, only depth 8 supported right now.\n");       assert_image_program();    switch( p.format )    {    case SANE_FRAME_GRAY:    case SANE_FRAME_RGB:    break;    case SANE_FRAME_RED:    case SANE_FRAME_GREEN:    case SANE_FRAME_BLUE: -  error("Composite frame mode not supported for row_scan\n"); +  Pike_error("Composite frame mode not supported for row_scan\n");    break;    }    push_int( p.pixels_per_line );    push_int( 1 );    o = clone_object( image_program, 2 );    r = ((struct image *)o->storage)->img;       nr = p.lines;    p.lines=1;   
pike.git/src/modules/SANE/sane.c:624:   **! function void nonblocking_row_scan(function(Image.Image,int,Scanner,int:void) callback)   */   static void f_scanner_nonblocking_row_scan( INT32 args )   {    SANE_Parameters p;    SANE_Handle h = THIS->h;    struct svalue *s;    int fd;    struct row_scan_struct *rsp;    -  if( sane_start( THIS->h ) ) error("Start failed\n"); -  if( sane_get_parameters( THIS->h, &p ) ) error("Get parameters failed\n"); -  if( p.depth != 8 ) error("Sorry, only depth 8 supported right now.\n"); +  if( sane_start( THIS->h ) ) Pike_error("Start failed\n"); +  if( sane_get_parameters( THIS->h, &p ) ) Pike_error("Get parameters failed\n"); +  if( p.depth != 8 ) Pike_error("Sorry, only depth 8 supported right now.\n");       switch( p.format )    {    case SANE_FRAME_GRAY:    case SANE_FRAME_RGB:    break;    case SANE_FRAME_RED:    case SANE_FRAME_GREEN:    case SANE_FRAME_BLUE: -  error("Composite frame mode not supported for row_scan\n"); +  Pike_error("Composite frame mode not supported for row_scan\n");    break;    }       assert_image_program();       rsp = malloc( sizeof(struct row_scan_struct) );    push_int( p.pixels_per_line );    push_int( 1 );    rsp->o = clone_object( image_program, 2 );    rsp->t = Pike_fp->current_object;
pike.git/src/modules/SANE/sane.c:664:    rsp->callback = sp[-1];    rsp->nonblocking = !sane_set_io_mode( THIS->h, 1 );    sp--;       if( sane_get_select_fd( THIS->h, &fd ) )    {    free_object( rsp->o );    free_object( rsp->t );    free( rsp->buffer );    free( rsp ); -  error("Failed to get select fd for scanning device!\n"); +  Pike_error("Failed to get select fd for scanning device!\n");    }    set_read_callback( fd, nonblocking_row_scan_callback, (void*)rsp );    push_int( 0 );   }      static void f_scanner_cancel_scan( INT32 args )   {    sane_cancel( THIS->h );   }