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

version» Context lines:

pike.git/src/modules/SANE/sane.c:82:    *! "vendor":"UMAX "    *! ]),    *! ([    *! "model":"Astra 1220S ",    *! "name":"net:lain.idonex.se:umax:/dev/scg1f",    *! "type":"flatbed scanner",    *! "vendor":"UMAX "    *! ])    *! })    */ - static void f_list_scanners( INT32 args ) + static void f_list_scanners( INT32 UNUSED(args) )   {    SANE_Device **devices;    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 );
pike.git/src/modules/SANE/sane.c:418:    push_text( "lines" ); push_int( p.lines );    push_text( "depth" ); push_int( p.depth );    push_text( "pixels_per_line" ); push_int( p.pixels_per_line );    push_text( "bytes_per_line" ); push_int( p.bytes_per_line );    f_aggregate_mapping( 12 );   }         static struct program *image_program;    - static void get_grey_frame( SANE_Handle h, SANE_Parameters *p, char *data ) + static void get_grey_frame( SANE_Handle h, SANE_Parameters *p, +  SANE_Byte *data )   { -  char buffer[8000]; +  SANE_Byte buffer[8000];    int nbytes = p->lines * p->bytes_per_line, amnt_read;    while( nbytes )    { -  char *pp = buffer; -  if( sane_read( h, (unsigned char *)buffer, MINIMUM(8000,nbytes), -  &amnt_read ) ) +  SANE_Byte *pp = buffer; +  if( sane_read( h, buffer, MINIMUM(8000,nbytes), &amnt_read ) )    return;    while( amnt_read-- && nbytes--)    {    *(data++) = *(pp);    *(data++) = *(pp);    *(data++) = *(pp++);    }    }   }    - static void get_rgb_frame( SANE_Handle h, SANE_Parameters *p, char *data ) + static void get_rgb_frame( SANE_Handle h, SANE_Parameters *p, +  SANE_Byte *data )   { -  char buffer[8000]; +  SANE_Byte buffer[8000];    int nbytes = p->lines * p->bytes_per_line, amnt_read;    while( nbytes )    { -  char *pp = buffer; -  if( sane_read( h, (unsigned char *)buffer, MINIMUM(8000,nbytes), -  &amnt_read ) ) +  SANE_Byte *pp = buffer; +  if( sane_read( h, buffer, MINIMUM(8000,nbytes), &amnt_read ) )    return;    while( amnt_read-- && nbytes--)    *(data++) = *(pp++);    }   }    - static void get_comp_frame( SANE_Handle h, SANE_Parameters *p, char *data ) + static void get_comp_frame( SANE_Handle h, SANE_Parameters *p, +  SANE_Byte *data )   { -  char buffer[8000]; +  SANE_Byte buffer[8000];    int nbytes = p->lines * p->bytes_per_line, amnt_read;    while( nbytes )    { -  char *pp = buffer; +  SANE_Byte *pp = buffer;    if( sane_read( h, buffer, MINIMUM(8000,nbytes), &amnt_read ) )    return;    while( amnt_read-- && nbytes--)    {    data[0] = *(pp++);    data += 3;    }    }   }   
pike.git/src/modules/SANE/sane.c:489:    Pike_error("No Image.Image?!\n");   }      /*! @decl 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; +  SANE_Byte *r; /* Actually an rgb_group *. */    -  +     assert_image_program();       pop_n_elems( args );    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");       push_int( p.pixels_per_line );    push_int( p.lines );    o = clone_object( image_program, 2 ); -  r = ((struct image *)o->storage)->img; +  r = (SANE_Byte *)((struct image *)o->storage)->img;       THREADS_ALLOW();    do    {    switch( p.format )    {    case SANE_FRAME_GRAY: -  get_grey_frame( h, &p, (char *)r ); +  get_grey_frame( h, &p, r );    p.last_frame = 1;    break;    case SANE_FRAME_RGB: -  get_rgb_frame( h, &p, (char *)r ); +  get_rgb_frame( h, &p, r );    p.last_frame = 1;    break;    case SANE_FRAME_RED: -  get_comp_frame( h, &p, ((char *)r) ); +  get_comp_frame( h, &p, r );    break;    case SANE_FRAME_GREEN: -  get_comp_frame( h, &p, ((char *)r)+1 ); +  get_comp_frame( h, &p, r + 1 );    break;    case SANE_FRAME_BLUE: -  get_comp_frame( h, &p, ((char *)r)+2 ); +  get_comp_frame( h, &p, r + 2 );    break;    }    }    while( !p.last_frame );       THREADS_DISALLOW();    push_object( o );   }      /*! @decl void row_scan(function(Image.Image,int,Scanner:void) callback)    */   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; +  SANE_Byte *r; /* Actually an rgb_group *. */    int i, nr;       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:
pike.git/src/modules/SANE/sane.c:566:    break;    case SANE_FRAME_RED:    case SANE_FRAME_GREEN:    case SANE_FRAME_BLUE:    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; +  r = (SANE_Byte *)((struct image *)o->storage)->img;       nr = p.lines;    p.lines=1;       for( i = 0; i<nr; i++ )    {    THREADS_ALLOW();    switch( p.format )    {    case SANE_FRAME_GRAY: -  get_grey_frame( h, &p, (char *)r ); +  get_grey_frame( h, &p, r );    break;    case SANE_FRAME_RGB: -  get_rgb_frame( h, &p, (char *)r ); +  get_rgb_frame( h, &p, r );    break;    case SANE_FRAME_RED:    case SANE_FRAME_GREEN:    case SANE_FRAME_BLUE:    break;    }    THREADS_DISALLOW();    ref_push_object( o );    push_int( i );    ref_push_object( Pike_fp->current_object );
pike.git/src/modules/SANE/sane.c:607:   }      struct row_scan_struct   {    SANE_Handle h;    SANE_Parameters p;    rgb_group *r;    struct object *o;    struct object *t;    int current_row; -  char *buffer; +  SANE_Byte *buffer;    int bufferpos, nonblocking;    struct svalue callback;   };      static void nonblocking_row_scan_callback( int fd, void *_c )   {    struct row_scan_struct *c = (struct row_scan_struct *)_c;    int done = 0;    int nbytes;   
pike.git/src/modules/SANE/sane.c:682:    free_object( c->o );    free_object( c->t );    free_svalue( &c->callback );    free( c->buffer );    free( c );    }   }      /*! @decl void nonblocking_row_scan(function(Image.Image,int,Scanner,int:void) callback)    */ - static void f_scanner_nonblocking_row_scan( INT32 args ) + static void f_scanner_nonblocking_row_scan( INT32 UNUSED(args) )   {    SANE_Parameters p;    SANE_Handle h = THIS->h;    struct svalue *s;    int fd;    struct row_scan_struct *rsp;       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");
pike.git/src/modules/SANE/sane.c:739:    free( rsp );    Pike_error("Failed to get select fd for scanning device!\n");    }    set_read_callback( fd, (file_callback)nonblocking_row_scan_callback,    (void*)rsp );    push_int( 0 );   }      /*! @decl void cancel_scan()    */ - static void f_scanner_cancel_scan( INT32 args ) + static void f_scanner_cancel_scan( INT32 UNUSED(args) )   {    sane_cancel( THIS->h );   }      /*! @endclass    */      /*! @decl constant FrameGray    *! @decl constant FrameRGB    *! @decl constant FrameRed    *! @decl constant FrameGreen    *! @decl constant FrameBlue    */      /*! @endmodule    */    - static void init_scanner_struct( struct object *p ) + static void init_scanner_struct( struct object *UNUSED(p) )   {    THIS->h = 0;   }    - static void exit_scanner_struct( struct object *p ) + static void exit_scanner_struct( struct object *UNUSED(p) )   {    if( THIS->h )    sane_close( THIS->h );   }      PIKE_MODULE_INIT   {    struct program *p;    ADD_FUNCTION( "list_scanners", f_list_scanners,    tFunc(tNone,tArr(tMapping)), 0 );