From fe611e101150f009375778499a7a304b951364c9 Mon Sep 17 00:00:00 2001 From: Thomas Soumarmon Date: Sat, 2 Oct 2004 18:39:01 +0000 Subject: [PATCH] * hp5400 : removed some compilation warnings --- ChangeLog | 7 ++++++ backend/hp5400_internal.c | 52 ++++++++++++++++++++++++++------------- backend/hp5400_internal.h | 16 +++++++++--- backend/hp5400_sane.c | 2 +- backend/hp5400_sanei.c | 16 ++++-------- backend/hp5400_sanei.h | 2 ++ 6 files changed, 62 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index c877611e2..46b4bc653 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-10-02 Thomas Soumarmon + + * backend/hp5400_internal.c backend/hp5400_internal.h + backend/hp5400_sanei.c backend/hp5400_sanei.h + backend/hp5400_sane.c: + removing some compilation warnings + 2004-10-02 Thomas Soumarmon * backend/hp5400_internal.c: hp5400 version mathing test diff --git a/backend/hp5400_internal.c b/backend/hp5400_internal.c index 7a165787d..31130a7e0 100644 --- a/backend/hp5400_internal.c +++ b/backend/hp5400_internal.c @@ -60,6 +60,8 @@ #include #include #include /* for htons */ +#include + #include "hp5400.h" #include "hp5400_xfer.h" @@ -309,6 +311,7 @@ WriteGammaCalibTable (int iHandle, const int *pabGammaR, const int *pabGammaG, return; } +#ifdef STANDALONE HP5400_SANE_STATIC void SetDefaultGamma (int iHandle) @@ -321,6 +324,7 @@ SetDefaultGamma (int iHandle) WriteGammaCalibTable (iHandle, buffer, buffer, buffer); } +#endif #define BUFFER_SIZE (6*65536) @@ -389,9 +393,9 @@ int CircBufferGetLine (int iHandle, TDataPipe * p, void *pabLine) { int i; - int maxoff = 0; - + char* buftmp = (char*) (p->buffer); + /* HP5400_DBG(DBG_MSG, "CircBufferGetLine:\n"); */ if (p->roff > maxoff) @@ -421,13 +425,13 @@ CircBufferGetLine (int iHandle, TDataPipe * p, void *pabLine) /* free old buffer */ free (tmpBuf); + buftmp = (char*)(p->buffer); } while (p->bufstart + maxoff >= p->bufend) /* Not enough data in buffer */ { int res; unsigned short cmd[4] = { 0, 0, 0, 0 }; - cmd[2] = p->blksize; assert ((p->bufend + p->blksize) <= p->buffersize); @@ -437,14 +441,19 @@ CircBufferGetLine (int iHandle, TDataPipe * p, void *pabLine) res = hp5400_bulk_read_block (iHandle, CMD_INITBULK3, cmd, sizeof (cmd), - p->buffer + p->bufend, p->blksize); + buftmp + p->bufend, p->blksize); if (res != p->blksize) { HP5400_DBG (DBG_ERR, "*** ERROR: Read returned %d. FATAL.", res); return -1; } #ifdef IMAGE_DEBUG - fwrite (p->buffer + p->bufend, p->blksize, 1, temp); + fwrite ( + buftmp + p->bufend + ,p->blksize + ,1 + ,temp + ); #endif p->bufend += p->blksize; } @@ -455,9 +464,9 @@ CircBufferGetLine (int iHandle, TDataPipe * p, void *pabLine) if (p->bpp == 1) { char *itPix = (char *) pabLine; - char *itR = (char *) (p->buffer + p->bufstart + p->roff); - char *itG = (char *) (p->buffer + p->bufstart + p->goff); - char *itB = (char *) (p->buffer + p->bufstart + p->boff); + char *itR = (char *) (buftmp + p->bufstart + p->roff); + char *itG = (char *) (buftmp + p->bufstart + p->goff); + char *itB = (char *) (buftmp + p->bufstart + p->boff); for (i = 0; i < p->pixels; i++) { /* pointer move goes a little bit faster than vector access */ @@ -471,9 +480,9 @@ CircBufferGetLine (int iHandle, TDataPipe * p, void *pabLine) else { short *itPix = (short *) pabLine; - short *itR = (short *) (p->buffer + p->bufstart + p->roff); - short *itG = (short *) (p->buffer + p->bufstart + p->goff); - short *itB = (short *) (p->buffer + p->bufstart + p->boff); + short *itR = (short *) (buftmp + p->bufstart + p->roff); + short *itG = (short *) (buftmp + p->bufstart + p->goff); + short *itB = (short *) (buftmp + p->bufstart + p->boff); for (i = 0; i < p->pixels; i++) { #if 0 @@ -501,7 +510,11 @@ CircBufferGetLine (int iHandle, TDataPipe * p, void *pabLine) /* If we've used a whole block at the beginning, move it */ if (p->bufstart > p->blksize) { - memmove (p->buffer, p->buffer + p->bufstart, p->bufend - p->bufstart); + memmove ( + buftmp + ,buftmp + p->bufstart + ,p->bufend - p->bufstart + ); p->bufend -= p->bufstart; p->bufstart = 0; @@ -524,6 +537,7 @@ CircBufferExit (TDataPipe * p) } +#ifdef STANDALONE /* bpp is BYTES per pixel */ HP5400_SANE_STATIC void @@ -582,7 +596,6 @@ DecodeImage (FILE * file, int planes, int bpp, int xsize, int ysize, free (buf); } - HP5400_SANE_STATIC int hp5400_test_scan_response (struct ScanResponse *resp, struct ScanRequest *req) @@ -597,6 +610,7 @@ hp5400_test_scan_response (struct ScanResponse *resp, struct ScanRequest *req) htons (resp->ysize)); return 1; } +#endif /* This is a very specialised scanning function. It does the scan request as * usual but instead of producing an image it returns three arrays of ints. @@ -655,6 +669,7 @@ DoAverageScan (int iHandle, struct ScanRequest *req, int code, return 0; } +#ifdef STANDALONE HP5400_SANE_STATIC int DoScan (int iHandle, struct ScanRequest *req, const char *filename, int code, @@ -704,6 +719,7 @@ DoScan (int iHandle, struct ScanRequest *req, const char *filename, int code, fclose (file); return 0; } +#endif HP5400_SANE_STATIC int @@ -839,6 +855,7 @@ Calibrate (int iHandle, int dpi) return 0; } +#ifdef STANDALONE HP5400_SANE_STATIC int hp5400_scan (int iHandle, TScanParams * params, THWParams * pHWParams, @@ -906,7 +923,6 @@ hp5400_scan (int iHandle, TScanParams * params, THWParams * pHWParams, return result; } - HP5400_SANE_STATIC int PreviewScan (int iHandle) @@ -926,6 +942,7 @@ PreviewScan (int iHandle) return hp5400_scan (iHandle, ¶ms, &pHWParams, "output.ppm"); } + static char UISetup1[] = { /* Offset 40 */ 0x50, 0x72, 0x6F, 0x63, 0x65, 0x73, 0x73, 0x69, 0x6E, 0x67, 0x14, 0x00, @@ -971,6 +988,7 @@ InitScanner (int iHandle) } return 0; } +#endif /* Warning! The caller must have configured the gamma tables at this stage */ HP5400_SANE_STATIC @@ -1232,7 +1250,7 @@ FinishScan (THWParams * pHWParams) HP5400_SANE_STATIC int -HP5400Open (THWParams * params, char *filename) +HP5400Open (THWParams * params, const char *filename) { int iHandle = hp5400_open (filename); char szVersion[32]; @@ -1311,9 +1329,9 @@ HP5400Close (THWParams * params) HP5400_SANE_STATIC int -HP5400Detect (char *filename, +HP5400Detect (const char *filename, int (*_ReportDevice) (TScannerModel * pModel, - char *pszDeviceName)) + const char *pszDeviceName)) { int iHandle = hp5400_open (filename); diff --git a/backend/hp5400_internal.h b/backend/hp5400_internal.h index 5c9485a8a..13b5e0d53 100644 --- a/backend/hp5400_internal.h +++ b/backend/hp5400_internal.h @@ -170,10 +170,11 @@ void WriteGammaCalibTable (int iHandle, const int *pabGammaR, const int *pabGammaG, const int *pabGammaB); - +#ifdef STANDALONE HP5400_SANE_STATIC void SetDefaultGamma (int iHandle); +#endif HP5400_SANE_STATIC void @@ -189,6 +190,7 @@ HP5400_SANE_STATIC void CircBufferExit (TDataPipe * p); +#ifdef STANDALONE HP5400_SANE_STATIC void DecodeImage (FILE * file, int planes, int bpp, int xsize, int ysize, @@ -198,21 +200,26 @@ HP5400_SANE_STATIC int hp5400_test_scan_response (struct ScanResponse *resp, struct ScanRequest *req); +#endif + HP5400_SANE_STATIC int DoAverageScan (int iHandle, struct ScanRequest *req, int code, unsigned int **array); +#ifdef STANDALONE HP5400_SANE_STATIC int DoScan (int iHandle, struct ScanRequest *req, const char *filename, int code, struct ScanResponse *res); +#endif HP5400_SANE_STATIC int Calibrate (int iHandle, int dpi); +#ifdef STANDALONE HP5400_SANE_STATIC int hp5400_scan (int iHandle, TScanParams * params, THWParams * pHWParams, @@ -225,6 +232,7 @@ PreviewScan (int iHandle); HP5400_SANE_STATIC int InitScanner (int iHandle); +#endif HP5400_SANE_STATIC int @@ -237,7 +245,7 @@ FinishScan (THWParams * pHWParams); HP5400_SANE_STATIC int -HP5400Open (THWParams * params, char *filename); +HP5400Open (THWParams * params, const char *filename); HP5400_SANE_STATIC void @@ -245,9 +253,9 @@ HP5400Close (THWParams * params); HP5400_SANE_STATIC int -HP5400Detect (char *filename, +HP5400Detect (const char *filename, int (*_ReportDevice) (TScannerModel * pModel, - char *pszDeviceName)); + const char *pszDeviceName)); HP5400_SANE_STATIC diff --git a/backend/hp5400_sane.c b/backend/hp5400_sane.c index 2ac657b82..8d1f6ec01 100644 --- a/backend/hp5400_sane.c +++ b/backend/hp5400_sane.c @@ -403,7 +403,7 @@ static void _InitOptions(TScanner *s) } -static int _ReportDevice(TScannerModel *pModel, char *pszDeviceName) +static int _ReportDevice(TScannerModel *pModel, const char *pszDeviceName) { TDevListEntry *pNew, *pDev; diff --git a/backend/hp5400_sanei.c b/backend/hp5400_sanei.c index 27a575361..97fada876 100644 --- a/backend/hp5400_sanei.c +++ b/backend/hp5400_sanei.c @@ -94,7 +94,6 @@ _UsbWriteControl (int fd, int iValue, int iIndex, void *pabData, int iSize) } -HP5400_SANE_STATIC void hp5400_command_write_noverify (int fd, int iValue, void *pabData, int iSize) { @@ -118,7 +117,6 @@ _UsbReadControl (int fd, int iValue, int iIndex, void *pabData, int iSize) } -HP5400_SANE_STATIC int hp5400_open (const char *filename) { @@ -159,7 +157,6 @@ hp5400_open (const char *filename) } -HP5400_SANE_STATIC void hp5400_close (int iHandle) { @@ -168,7 +165,6 @@ hp5400_close (int iHandle) /* returns value > 0 if verify ok */ -HP5400_SANE_STATIC int hp5400_command_verify (int iHandle, int iCmd) { @@ -210,7 +206,6 @@ hp5400_command_verify (int iHandle, int iCmd) /* returns > 0 if command OK */ -HP5400_SANE_STATIC int hp5400_command_read_noverify (int iHandle, int iCmd, int iLen, void *pbData) { @@ -229,7 +224,6 @@ hp5400_command_read_noverify (int iHandle, int iCmd, int iLen, void *pbData) } /* returns > 0 if command OK */ -HP5400_SANE_STATIC int hp5400_command_read (int iHandle, int iCmd, int iLen, void *pbData) { @@ -240,7 +234,6 @@ hp5400_command_read (int iHandle, int iCmd, int iLen, void *pbData) /* returns >0 if command OK */ -HP5400_SANE_STATIC int hp5400_command_write (int iHandle, int iCmd, int iLen, void *pbData) { @@ -258,8 +251,8 @@ hp5400_command_write (int iHandle, int iCmd, int iLen, void *pbData) return hp5400_command_verify (iHandle, iCmd); } +#ifdef STANDALONE /* returns >0 if command OK */ -HP5400_SANE_STATIC int hp5400_bulk_read (int iHandle, size_t len, int block, FILE * file) { @@ -299,9 +292,9 @@ hp5400_bulk_read (int iHandle, size_t len, int block, FILE * file) /* error handling? */ return 0; } +#endif /* returns >0 if command OK */ -HP5400_SANE_STATIC int hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen, void *buffer, int len) @@ -324,7 +317,6 @@ hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen, } /* returns >0 if command OK */ -HP5400_SANE_STATIC int hp5400_bulk_command_write (int iHandle, int iCmd, void *cmd, int cmdlen, int datalen, int block, char *data) @@ -365,12 +357,12 @@ hp5400_bulk_command_write (int iHandle, int iCmd, void *cmd, int cmdlen, return hp5400_command_verify (iHandle, iCmd); } +#ifdef STANDALONE /** ScannerIsOn retrieve on/off status from scanner @return 1 if is on 0 if is off -1 if is not reachable */ -HP5400_SANE_STATIC int hp5400_isOn (int iHandle) { @@ -389,3 +381,5 @@ hp5400_isOn (int iHandle) return 0; /* is off */ } +#endif + diff --git a/backend/hp5400_sanei.h b/backend/hp5400_sanei.h index dc44b23a2..3c8e33700 100644 --- a/backend/hp5400_sanei.h +++ b/backend/hp5400_sanei.h @@ -85,8 +85,10 @@ HP5400_SANE_STATIC int hp5400_command_read (int iHandle, int iCmd, int iLen, voi /* returns >0 if command OK */ HP5400_SANE_STATIC int hp5400_command_write (int iHandle, int iCmd, int iLen, void *pbData); +#ifdef STANDALONE /* returns >0 if command OK */ HP5400_SANE_STATIC int hp5400_bulk_read (int iHandle, size_t len, int block, FILE * file); +#endif /* returns >0 if command OK */ HP5400_SANE_STATIC int hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen,