From 30b517b433fcf91f4fd632320da159ce669f2e49 Mon Sep 17 00:00:00 2001 From: Henning Geinitz Date: Fri, 13 Apr 2001 17:04:51 +0000 Subject: [PATCH] 2001-04-13 Henning Meier-Geinitz * PROJECTS TODO: Added entry about E3 USB chipset. * backend/dll.c backend/dll.desc: New version is 1.0.5. Version and PACKAGE_VERSION is printed with debug level set to 1 or higher. The version numbers of all backends that are loaded are printed at debug level 3 or higher. Print error if backend with wrong major version number is loaded. Some standardization changes concerning the DBG messages. * backend/net.c backend/net.desc: New version is 1.0.5. Version and PACKAGE_VERSION is printed with debug level set to 1 or higher. Some standardization changes concerning the DBG messages. * backend/pnm.c: Return SANE_INFO_RELOAD_PARAMS even if the pnm file doesn't exist or can't be loaded (from mh ). * doc/backend-writing.txt: Added AUTHORS to the list of things that should be updated when including a new backend. Added points about avoiding printf and exit in backends. * doc/releases.txt: New file. This text summarizes some points to pay attention to when a new release of sane-backends is made. Additions and corrections are appreciated. * doc/scanimage.man: Add some more information about the -V option. * frontend/scanimage.c: The option -V now also prints the version of the backend (ususally dll). --- PROJECTS | 4 +++ backend/dll.c | 57 +++++++++++++++++++++++++---------------- backend/dll.desc | 2 +- backend/net.c | 41 ++++++++++++++++------------- backend/net.desc | 2 +- backend/pnm.c | 3 +-- doc/backend-writing.txt | 14 +++++++--- doc/realeases.txt | 31 ++++++++++++++++++++++ doc/scanimage.man | 9 ++++--- frontend/scanimage.c | 8 ++++-- 10 files changed, 119 insertions(+), 52 deletions(-) create mode 100644 doc/realeases.txt diff --git a/PROJECTS b/PROJECTS index 2a564e4ec..74248d1f1 100644 --- a/PROJECTS +++ b/PROJECTS @@ -22,6 +22,10 @@ David Mosberger Canon 1220U USB scanner (wip) http://sourceforge.net/projects/canonscanner/ +E3 USB chipset support (e.g. Genius Vivid Pro USB, Colorado USB 19200, +Visioneer OneTouch 7600, IBM IdeaScan 2000 USB) (wip) +http://homepages.paradise.net.nz/stevenel/scanner/ + ePhoto (wip?) Matthew K. Gray diff --git a/backend/dll.c b/backend/dll.c index 284a08dd8..9d236e4d7 100644 --- a/backend/dll.c +++ b/backend/dll.c @@ -42,6 +42,8 @@ allows managing an arbitrary number of SANE backends by using dynamic linking to load backends on demand. */ +#define BUILD 5 + #ifdef _AIX # include "lalloca.h" /* MUST come first for AIX! */ #endif @@ -198,7 +200,7 @@ static const char *op_name[] = static void * op_unsupported (void) { - DBG(1, "call to unsupported backend operation\n"); + DBG(1, "op_unsupported: call to unsupported backend operation\n"); return (void *) (long) SANE_STATUS_UNSUPPORTED; } @@ -208,18 +210,18 @@ add_backend (const char *name, struct backend **bep) { struct backend *be, *prev; - DBG(1, "adding backend %s\n", name); + DBG(1, "add_backend: adding backend %s\n", name); if (strcmp(name,"dll") == 0) { - DBG( 0, "remove the dll-backend from your dll.conf !!!\n"); + DBG( 0, "add_backend: remove the dll-backend from your dll.conf!!!\n"); return SANE_STATUS_GOOD; } for (prev = 0, be = first_backend; be; prev = be, be = be->next) if (strcmp (be->name, name) == 0) { - DBG(1, "...already there\n"); + DBG(1, "add_backend: %s is already there\n", name); /* move to front so we preserve order that we'd get with dynamic loading: */ if (prev) @@ -269,7 +271,7 @@ load (struct backend *be) # error "Tried to compile unsupported DLL." #endif /* HAVE_DLOPEN */ - DBG(1, "loading backend %s\n", be->name); + DBG(1, "load: loading backend %s\n", be->name); /* initialize all ops to "unsupported" so we can "use" the backend even if the stuff later in this function fails */ @@ -312,7 +314,7 @@ load (struct backend *be) libname, strerror (errno)); return SANE_STATUS_INVAL; } - DBG(2, "dlopen()ing `%s'\n", libname); + DBG(2, "load: dlopen()ing `%s'\n", libname); #ifdef HAVE_DLOPEN be->handle = dlopen (libname, mode); @@ -324,9 +326,9 @@ load (struct backend *be) if (!be->handle) { #ifdef HAVE_DLOPEN - DBG(2, "dlopen() failed (%s)\n", dlerror()); + DBG(2, "load: dlopen() failed (%s)\n", dlerror()); #else - DBG(2, "dlopen() failed (%s)\n", strerror (errno)); + DBG(2, "load: dlopen() failed (%s)\n", strerror (errno)); #endif return SANE_STATUS_INVAL; } @@ -363,7 +365,7 @@ load (struct backend *be) be->op[i] = op; } if (NULL == op) - DBG(2, "unable to find %s\n", funcname); + DBG(2, "load: unable to find %s\n", funcname); } return SANE_STATUS_GOOD; @@ -397,7 +399,14 @@ init (struct backend *be) return status; if (SANE_VERSION_MAJOR (version) != V_MAJOR) - return SANE_STATUS_INVAL; + { + DBG(1, "init: backend `%sī has a wrong major version (%d instead of %d)\n", + be->name, SANE_VERSION_MAJOR (version), V_MAJOR); + return SANE_STATUS_INVAL; + } + DBG(3, "init: backend `%s' is version %d.%d.%d\n", be->name, + SANE_VERSION_MAJOR(version), SANE_VERSION_MINOR(version), + SANE_VERSION_BUILD(version)); be->inited = 1; @@ -497,6 +506,10 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) auth_callback = authorize; + DBG(1, "sane_init: SANE dll backend version %d.%d.%d from %s\n", V_MAJOR, + V_MINOR, BUILD, PACKAGE_VERSION); + + /* chain preloaded backends together: */ for (i = 0; i < NELEMS(preloaded_backends); ++i) { @@ -507,7 +520,7 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) } if (version_code) - *version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR, 0); + *version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR, BUILD); fp = sanei_config_open (DLL_CONFIG_FILE); if (!fp) @@ -553,14 +566,14 @@ sane_exit (void) struct backend *be, *next; struct alias *alias; - DBG(1, "exiting\n"); + DBG(1, "sane_exit: exiting\n"); for (be = first_backend; be; be = next) { next = be->next; if (be->loaded) { - DBG(2, "calling backend `%s's exit function\n", be->name); + DBG(2, "sane_exit: calling backend `%s's exit function\n", be->name); (*be->op[OP_EXIT]) (); #ifdef HAVE_DLL @@ -803,7 +816,7 @@ sane_close (SANE_Handle handle) { struct meta_scanner *s = handle; - DBG(3, "close(handle=%p)\n", handle); + DBG(3, "sane_close(handle=%p)\n", handle); (*s->be->op[OP_CLOSE]) (s->handle); free (s); } @@ -813,7 +826,7 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { struct meta_scanner *s = handle; - DBG(3, "get_option_descriptor(handle=%p,option=%d)\n", handle, option); + DBG(3, "sane_get_option_descriptor(handle=%p,option=%d)\n", handle, option); return (*s->be->op[OP_GET_OPTION_DESC]) (s->handle, option); } @@ -823,7 +836,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, { struct meta_scanner *s = handle; - DBG(3, "control_option(handle=%p,option=%d,action=%d,value=%p,info=%p)\n", + DBG(3, "sane_control_option(handle=%p,option=%d,action=%d,value=%p,info=%p)\n", handle, option, action, value, info); return (long) (*s->be->op[OP_CTL_OPTION]) (s->handle, option, action, value, info); @@ -834,7 +847,7 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { struct meta_scanner *s = handle; - DBG(3, "get_parameters(handle=%p,params=%p)\n", handle, params); + DBG(3, "sane_get_parameters(handle=%p,params=%p)\n", handle, params); return (long) (*s->be->op[OP_GET_PARAMS]) (s->handle, params); } @@ -843,7 +856,7 @@ sane_start (SANE_Handle handle) { struct meta_scanner *s = handle; - DBG(3, "start(handle=%p)\n", handle); + DBG(3, "sane_start(handle=%p)\n", handle); return (long) (*s->be->op[OP_START]) (s->handle); } @@ -853,7 +866,7 @@ sane_read (SANE_Handle handle, SANE_Byte * data, SANE_Int max_length, { struct meta_scanner *s = handle; - DBG(3, "read(handle=%p,data=%p,maxlen=%d,lenp=%p)\n", + DBG(3, "sane_read(handle=%p,data=%p,maxlen=%d,lenp=%p)\n", handle, data, max_length, length); return (long) (*s->be->op[OP_READ]) (s->handle, data, max_length, length); } @@ -863,7 +876,7 @@ sane_cancel (SANE_Handle handle) { struct meta_scanner *s = handle; - DBG(3, "cancel(handle=%p)\n", handle); + DBG(3, "sane_cancel(handle=%p)\n", handle); (*s->be->op[OP_CANCEL]) (s->handle); } @@ -872,7 +885,7 @@ sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { struct meta_scanner *s = handle; - DBG(3, "set_io_mode(handle=%p,nonblocking=%d)\n", handle, non_blocking); + DBG(3, "sane_set_io_mode(handle=%p,nonblocking=%d)\n", handle, non_blocking); return (long) (*s->be->op[OP_SET_IO_MODE]) (s->handle, non_blocking); } @@ -881,6 +894,6 @@ sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { struct meta_scanner *s = handle; - DBG(3, "get_select_fd(handle=%p,fdp=%p)\n", handle, fd); + DBG(3, "sane_get_select_fd(handle=%p,fdp=%p)\n", handle, fd); return (long) (*s->be->op[OP_GET_SELECT_FD]) (s->handle, fd); } diff --git a/backend/dll.desc b/backend/dll.desc index dab29b5da..0fa410c7d 100644 --- a/backend/dll.desc +++ b/backend/dll.desc @@ -1,5 +1,5 @@ :backend "dll" ; name of backend -:version "0.73" +:version "1.0.5" :status :beta :manpage "sane-dll" diff --git a/backend/net.c b/backend/net.c index 5beed3c1e..8eb57a7cf 100644 --- a/backend/net.c +++ b/backend/net.c @@ -40,6 +40,8 @@ This file implements a SANE network-based meta backend. */ +#define BUILD 5 + #ifdef _AIX # include "lalloca.h" /* MUST come first for AIX! */ #endif @@ -90,18 +92,18 @@ add_device (const char *name, Net_Device ** ndp) struct hostent *he; Net_Device *nd; - DBG (1, "adding backend %s\n", name); + DBG (1, "add_device: adding backend %s\n", name); he = gethostbyname (name); if (!he) { - DBG (1, "can't get address of host %s\n", name); + DBG (1, "add_device: can't get address of host %s\n", name); return SANE_STATUS_IO_ERROR; } if (he->h_addrtype != AF_INET) { - DBG (1, "don't know how to deal with addr family %d\n", he->h_addrtype); + DBG (1, "add_device: don't know how to deal with addr family %d\n", he->h_addrtype); return SANE_STATUS_INVAL; } @@ -328,7 +330,10 @@ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) auth_callback = authorize; if (version_code) - *version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR, 0); + *version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR, BUILD); + + DBG(1, "sane_init: SANE net backend version %d.%d.%d from %s\n", V_MAJOR, + V_MINOR, BUILD, PACKAGE_VERSION); serv = getservbyname ("sane", "tcp"); if (serv) @@ -337,7 +342,7 @@ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { saned_port = htons (6566); DBG (1, - "init: could not find `sane' service (%s); using default port %d\n", + "sane_init: could not find `sane' service (%s); using default port %d\n", strerror (errno), htons (saned_port)); } @@ -380,7 +385,7 @@ sane_exit (void) Net_Scanner *handle, *next_handle; Net_Device *dev, *next_device; - DBG (1, "exiting\n"); + DBG (1, "sane_exit: exiting\n"); /* first, close all handles: */ for (handle = first_handle; handle; handle = next_handle) @@ -395,7 +400,7 @@ sane_exit (void) { next_device = dev->next; - DBG (2, "closing dev %p, ctl=%d\n", dev, dev->ctl); + DBG (2, "sane_exit: closing dev %p, ctl=%d\n", dev, dev->ctl); if (dev->ctl >= 0) { @@ -458,7 +463,7 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) status = connect_dev (dev); if (status != SANE_STATUS_GOOD) { - DBG (1, "get_devices: ignoring failure to connect to %s\n", + DBG (1, "sane_get_devices: ignoring failure to connect to %s\n", dev->name); continue; } @@ -469,7 +474,7 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) (WireCodecFunc) sanei_w_get_devices_reply, &reply); if (reply.status != SANE_STATUS_GOOD) { - DBG (1, "get_devices: ignoring rpc-returned status %s\n", + DBG (1, "sane_get_devices: ignoring rpc-returned status %s\n", sane_strstatus (reply.status)); sanei_w_free (&dev->wire, (WireCodecFunc) sanei_w_get_devices_reply, &reply); @@ -531,7 +536,7 @@ SANE_Status sane_open (SANE_String_Const full_name, SANE_Handle * meta_handle) Net_Scanner *s; int need_auth; - DBG (3, "open(\"%s\")\n", full_name); + DBG (3, "sane_open(\"%s\")\n", full_name); dev_name = strchr (full_name, ':'); if (dev_name) @@ -589,7 +594,7 @@ SANE_Status sane_open (SANE_String_Const full_name, SANE_Handle * meta_handle) { if (dev->wire.status != 0) { - DBG (1, "open rpc call failed (%s)\n", strerror (dev->wire.status)); + DBG (1, "sane_open: open rpc call failed (%s)\n", strerror (dev->wire.status)); return SANE_STATUS_IO_ERROR; } @@ -618,7 +623,7 @@ SANE_Status sane_open (SANE_String_Const full_name, SANE_Handle * meta_handle) if (status != SANE_STATUS_GOOD) { - DBG (1, "remote open failed\n"); + DBG (1, "sane_open: remote open failed\n"); return reply.status; } } @@ -654,7 +659,7 @@ sane_close (SANE_Handle handle) } if (!s) { - DBG (1, "close: invalid handle %p\n", handle); + DBG (1, "sane_close: invalid handle %p\n", handle); return; /* oops, not a handle we know about */ } if (prev) @@ -764,7 +769,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, if ((SANE_Word) value_size == reply.value_size) memcpy (value, reply.value, reply.value_size); else - DBG (1, "control_option: size changed from %d to %d\n", + DBG (1, "sane_control_option: size changed from %d to %d\n", s->opt.desc[option]->size, reply.value_size); } @@ -819,14 +824,14 @@ SANE_Status sane_start (SANE_Handle handle) len = sizeof (sin); if (getpeername (s->hw->ctl, (struct sockaddr *) &sin, &len) < 0) { - DBG (1, "start: getpeername() failed (%s)\n", strerror (errno)); + DBG (1, "sane_start: getpeername() failed (%s)\n", strerror (errno)); return SANE_STATUS_IO_ERROR; } fd = socket (s->hw->addr.sa_family, SOCK_STREAM, 0); if (fd < 0) { - DBG (1, "start: socket() failed (%s)\n", strerror (errno)); + DBG (1, "sane_start: socket() failed (%s)\n", strerror (errno)); return SANE_STATUS_IO_ERROR; } @@ -869,7 +874,7 @@ SANE_Status sane_start (SANE_Handle handle) if (connect (fd, (struct sockaddr *) &sin, len) < 0) { - DBG (1, "start: connect() failed (%s)\n", strerror (errno)); + DBG (1, "sane_start: connect() failed (%s)\n", strerror (errno)); close (fd); return SANE_STATUS_IO_ERROR; } @@ -920,7 +925,7 @@ sane_read (SANE_Handle handle, SANE_Byte * data, SANE_Int max_length, | ((u_long) s->reclen_buf[1] << 16) | ((u_long) s->reclen_buf[2] << 8) | ((u_long) s->reclen_buf[3] << 0)); - DBG (3, "read: next record length=%ld bytes\n", + DBG (3, "sane_read: next record length=%ld bytes\n", (long) s->bytes_remaining); if (s->bytes_remaining == (size_t) - 1) { diff --git a/backend/net.desc b/backend/net.desc index 8fb9d1107..62ae830c4 100644 --- a/backend/net.desc +++ b/backend/net.desc @@ -1,5 +1,5 @@ :backend "net" ; name of backend -:version "0.73" +:version "1.0.5" :status :beta :manpage "sane-net" diff --git a/backend/pnm.c b/backend/pnm.c index eeaea682a..add4802a6 100644 --- a/backend/pnm.c +++ b/backend/pnm.c @@ -335,8 +335,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, if ((strlen (value) + 1) > sizeof (filename)) return SANE_STATUS_NO_MEM; strcpy (filename, value); - if (access (filename, R_OK) == 0) - myinfo |= SANE_INFO_RELOAD_PARAMS; + myinfo |= SANE_INFO_RELOAD_PARAMS; break; case 4: bright = *(SANE_Word *) value; diff --git a/doc/backend-writing.txt b/doc/backend-writing.txt index 5f3030ab4..8a1a6a1fd 100644 --- a/doc/backend-writing.txt +++ b/doc/backend-writing.txt @@ -1,4 +1,4 @@ -2000-12-23 +2001-04-13 Here are a few rules that should help writing a SANE-conformant backend: @@ -117,5 +117,13 @@ backend: look at "sane-desc.el" in the tools/ directory. * When your backend is included in the SANE distribution, add an entry - to README and sane-backends.lsm. The README entry should point to your - documentation (man-page, website, readme). + to README, AUTHORS and sane-backends.lsm. The README entry should point to + your documentation (man-page, website, readme). + +* Don't use printf, fprintf or perror to output debug or error messages. + Use the DBG macro instead. If your backend can't detect a scanner for + whatever reason it shouldn't output anything as long as + SANE_DEBUG_BACKENDNAME isn't set. + +* Don't use exit() in your backend. You will exit the whole program, not only your + backend. diff --git a/doc/realeases.txt b/doc/realeases.txt new file mode 100644 index 000000000..f26d1699b --- /dev/null +++ b/doc/realeases.txt @@ -0,0 +1,31 @@ +2001-04-13 + +This text summarizes some points to pay attention to when a new realease +of sane-backends should be made. + +Before the release: + +* configure.in: increase version number +* configure.in: set --disable-warnings as default +* configure: recreate +* net.c net.desc dll.c dll.desc: update version numbers +* NEWS: update and enter date of release +* sane-backends.lsm: update +* ChangeLog: set release marker +* final compilation test +* make distclean + +Making the release: + +* remove all CVS files from directories (CVS, .cvsignore etc.) +* make tar.gz and sane-backends-x.y.z.lsm +* upload both to mostang.com +* write announcements on mostang.com and sane-devel, maybe others + (e.g. freshmeat) +* upload to mirrors that don't get the files automatically (sunsite + and tsx11) + +After the release: + +* configure.in: set --enable-warnings as default +* configure: regenerate diff --git a/doc/scanimage.man b/doc/scanimage.man index 7f7541487..3e8e4f2c0 100644 --- a/doc/scanimage.man +++ b/doc/scanimage.man @@ -1,4 +1,4 @@ -.TH scanimage 1 "24 November 2000" +.TH scanimage 1 "13 April 2001" .IX scanimage .SH NAME scanimage - scan an image @@ -115,8 +115,11 @@ or .B --version option requests that .B scanimage -print the program and package name, as well as the version number of -the SANE distribution that it came with. +prints the program and package name, the version number of +the SANE distribution that it came with and the version of the backend +that it loads. Usually that's the dll backend. If more information about +the version numbers of the backends are necessary, the DEBUG variable for +the dll backend can be used. Example: SANE_DEBUG_DLL=3 scanimage -L. As you might imagine, much of the power of .B scanimage diff --git a/frontend/scanimage.c b/frontend/scanimage.c index 0372de6e3..0031ab66e 100644 --- a/frontend/scanimage.c +++ b/frontend/scanimage.c @@ -1348,6 +1348,7 @@ main (int argc, char **argv) int batch = 0; SANE_Status status; char *full_optstring; + SANE_Int version_code; atexit (sane_exit); @@ -1359,7 +1360,7 @@ main (int argc, char **argv) defdevname = getenv ("SANE_DEFAULT_DEVICE"); - sane_init (0, auth_callback); + sane_init (&version_code, auth_callback); /* make a first pass through the options with error printing and argument permutation disabled: */ @@ -1429,7 +1430,10 @@ main (int argc, char **argv) } case 'V': - printf ("scanimage (%s) %s\n", PACKAGE, VERSION); + printf ("scanimage (%s) %s; backend version %d.%d.%d\n", PACKAGE, + VERSION, SANE_VERSION_MAJOR(version_code), + SANE_VERSION_MINOR(version_code), + SANE_VERSION_BUILD(version_code)); exit (0); default: