Re: Polaroid SprintScan 35 LE

From: Henning Meier-Geinitz (henning@meier-geinitz.de)
Date: Mon May 21 2001 - 12:43:53 PDT

  • Next message: Jonathan Buzzard: "Re: Linux-compliant USB scanner"

    Hi,

    On Mon, May 21, 2001 at 02:22:14PM -0400, Matto Marjanovic wrote:
    > * Use DBG(...) instead of fprintf(stderr, ...) or printf
    > - microtek
    >
    > --> this is not so simple.
    > There are a lot of places where I used 'fprintf(stderr, ...)'
    > in order to produce readable output; usually, such code is
    > conditioned off of DBG_LEVEL like so (per an early discussion
    > with David Mosberger-Tang on the right way to do this):
    >
    > if (DBG_LEVEL >= 192) {
    > int i;
    > fprintf(stderr, "MSL: ");
    > for (i=0;i<6+comm[4];i++) fprintf(stderr, "%2x ", comm[i]);
    > fprintf(stderr, "\n");
    > }
    >
    > There is no way to produce readable output using DBG(...) in a
    > situation like this, because of all the stuff that DBG() prepends
    > and appends to its arguments.
    >
    > Any suggestions?
    > Perhaps an additional, raw form of DBG(...) ?

    I'm using strings together with sprintf and strcat and after creation
    of the output string I print it with DBG(level, "%s", string). It's
    one or two more lines of code but I think it's worth it because we
    don't get problems with saned this way. So in your example:

    int i;
    char *dbg_buffer[enough_mem];
    char *tmp_buffer[not_so_much_mem];
    sprintf(tmp_buffer, "MSL: ");
    strcat(dbg_buffer, tmp_buffer);
    for (i=0;i<6+comm[4];i++)
      {
         sprintf(tmp_buffer, "%2x ", comm[i]);
         strcat(dbg_buffer, tmp_buffer);
      }

    (untested and ugly but you may get the idea).

    Bye,
      Henning

    --
    Source code, list archive, and docs: http://www.mostang.com/sane/
    To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com
    



    This archive was generated by hypermail 2b29 : Mon May 21 2001 - 12:44:33 PDT