kopia lustrzana https://gitlab.com/sane-project/backends
Fail if there are arguments without a preceding option on the command line.
Fixed indenting. Henning Meier-Geinitz <henning@meier-geinitz.de>DEVEL_2_0_BRANCH-1
rodzic
3c506cae68
commit
e96e066c2f
|
@ -170,8 +170,7 @@ auth_callback (SANE_String_Const resource,
|
||||||
if (strchr (strchr (tmp, ':') + 1, ':') != NULL)
|
if (strchr (strchr (tmp, ':') + 1, ':') != NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (
|
if ((strncmp
|
||||||
(strncmp
|
|
||||||
(strchr (strchr (tmp, ':') + 1, ':') + 1,
|
(strchr (strchr (tmp, ':') + 1, ':') + 1,
|
||||||
resource, len) == 0)
|
resource, len) == 0)
|
||||||
&&
|
&&
|
||||||
|
@ -184,8 +183,7 @@ auth_callback (SANE_String_Const resource,
|
||||||
SANE_MAX_USERNAME_LEN)
|
SANE_MAX_USERNAME_LEN)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (
|
if ((strchr (strchr (tmp, ':') + 1, ':') -
|
||||||
(strchr (strchr (tmp, ':') + 1, ':') -
|
|
||||||
(strchr (tmp, ':') + 1)) <
|
(strchr (tmp, ':') + 1)) <
|
||||||
SANE_MAX_PASSWORD_LEN)
|
SANE_MAX_PASSWORD_LEN)
|
||||||
{
|
{
|
||||||
|
@ -291,8 +289,7 @@ sighandler (int signum)
|
||||||
|
|
||||||
if (device)
|
if (device)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: received signal %d\n", prog_name,
|
fprintf (stderr, "%s: received signal %d\n", prog_name, signum);
|
||||||
signum);
|
|
||||||
if (first_time)
|
if (first_time)
|
||||||
{
|
{
|
||||||
first_time = SANE_FALSE;
|
first_time = SANE_FALSE;
|
||||||
|
@ -302,7 +299,7 @@ sighandler (int signum)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: aborting\n", prog_name);
|
fprintf (stderr, "%s: aborting\n", prog_name);
|
||||||
_exit(0);
|
_exit (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1217,13 +1214,13 @@ scan_it (void)
|
||||||
{
|
{
|
||||||
unsigned char LSB;
|
unsigned char LSB;
|
||||||
LSB = buffer[i];
|
LSB = buffer[i];
|
||||||
buffer[i] = buffer[i+1];
|
buffer[i] = buffer[i + 1];
|
||||||
buffer[i+1] = LSB;
|
buffer[i + 1] = LSB;
|
||||||
}
|
}
|
||||||
/* check if we have an odd number of bytes */
|
/* check if we have an odd number of bytes */
|
||||||
if (((len - start) % 2) != 0)
|
if (((len - start) % 2) != 0)
|
||||||
{
|
{
|
||||||
hang_over = buffer [len - 1];
|
hang_over = buffer[len - 1];
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1263,8 +1260,8 @@ scan_it (void)
|
||||||
{
|
{
|
||||||
unsigned char LSB;
|
unsigned char LSB;
|
||||||
LSB = image.data[i];
|
LSB = image.data[i];
|
||||||
image.data[i] = image.data[i+1];
|
image.data[i] = image.data[i + 1];
|
||||||
image.data[i+1] = LSB;
|
image.data[i + 1] = LSB;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
fwrite (image.data, image.Bpp, image.height * image.width, stdout);
|
fwrite (image.data, image.Bpp, image.height * image.width, stdout);
|
||||||
|
@ -1278,7 +1275,8 @@ cleanup:
|
||||||
|
|
||||||
|
|
||||||
expected_bytes = parm.bytes_per_line * parm.lines *
|
expected_bytes = parm.bytes_per_line * parm.lines *
|
||||||
((parm.format == SANE_FRAME_RGB || parm.format == SANE_FRAME_GRAY)?1:3);
|
((parm.format == SANE_FRAME_RGB
|
||||||
|
|| parm.format == SANE_FRAME_GRAY) ? 1 : 3);
|
||||||
if (parm.lines < 0)
|
if (parm.lines < 0)
|
||||||
expected_bytes = 0;
|
expected_bytes = 0;
|
||||||
if (total_bytes > expected_bytes && expected_bytes != 0)
|
if (total_bytes > expected_bytes && expected_bytes != 0)
|
||||||
|
@ -1486,7 +1484,6 @@ main (int argc, char **argv)
|
||||||
case ':':
|
case ':':
|
||||||
case '?':
|
case '?':
|
||||||
break; /* may be an option that we'll parse later on */
|
break; /* may be an option that we'll parse later on */
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
devname = optarg;
|
devname = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -1505,16 +1502,16 @@ main (int argc, char **argv)
|
||||||
test = 1;
|
test = 1;
|
||||||
break;
|
break;
|
||||||
case OPTION_BATCH_INCREMENT:
|
case OPTION_BATCH_INCREMENT:
|
||||||
batch_increment = atoi(optarg);
|
batch_increment = atoi (optarg);
|
||||||
break;
|
break;
|
||||||
case OPTION_BATCH_START_AT:
|
case OPTION_BATCH_START_AT:
|
||||||
batch_start_at = atoi(optarg);
|
batch_start_at = atoi (optarg);
|
||||||
break;
|
break;
|
||||||
case OPTION_BATCH_DOUBLE:
|
case OPTION_BATCH_DOUBLE:
|
||||||
batch_increment = 2;
|
batch_increment = 2;
|
||||||
break;
|
break;
|
||||||
case OPTION_BATCH_COUNT:
|
case OPTION_BATCH_COUNT:
|
||||||
batch_count = atoi(optarg);
|
batch_count = atoi (optarg);
|
||||||
batch = 1;
|
batch = 1;
|
||||||
break;
|
break;
|
||||||
case OPTION_FORMAT:
|
case OPTION_FORMAT:
|
||||||
|
@ -1555,18 +1552,18 @@ main (int argc, char **argv)
|
||||||
const char *text_arg = 0;
|
const char *text_arg = 0;
|
||||||
char cc, ftype;
|
char cc, ftype;
|
||||||
|
|
||||||
fmt = malloc(strlen(optarg)+1);
|
fmt = malloc (strlen (optarg) + 1);
|
||||||
if (fmt == 0)
|
if (fmt == 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: not enough memory\n", prog_name);
|
fprintf (stderr, "%s: not enough memory\n", prog_name);
|
||||||
exit(1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; device_list[i]; ++i)
|
for (i = 0; device_list[i]; ++i)
|
||||||
{
|
{
|
||||||
strcpy(fmt, optarg);
|
strcpy (fmt, optarg);
|
||||||
start = fmt;
|
start = fmt;
|
||||||
while(*start && (percent = strchr(start, '%')) )
|
while (*start && (percent = strchr (start, '%')))
|
||||||
{
|
{
|
||||||
percent++;
|
percent++;
|
||||||
if (*percent)
|
if (*percent)
|
||||||
|
@ -1597,7 +1594,8 @@ main (int argc, char **argv)
|
||||||
ftype = 0;
|
ftype = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: unknown format specifier %%%c\n",
|
fprintf (stderr,
|
||||||
|
"%s: unknown format specifier %%%c\n",
|
||||||
prog_name, *percent);
|
prog_name, *percent);
|
||||||
*percent = '%';
|
*percent = '%';
|
||||||
ftype = 0;
|
ftype = 0;
|
||||||
|
@ -1608,13 +1606,13 @@ main (int argc, char **argv)
|
||||||
switch (ftype)
|
switch (ftype)
|
||||||
{
|
{
|
||||||
case 's':
|
case 's':
|
||||||
printf(start, text_arg);
|
printf (start, text_arg);
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
printf(start, int_arg);
|
printf (start, int_arg);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
printf(start);
|
printf (start);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*percent = cc;
|
*percent = cc;
|
||||||
|
@ -1628,7 +1626,7 @@ main (int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*start)
|
if (*start)
|
||||||
printf(start);
|
printf (start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == 0 && ch != 'f')
|
if (i == 0 && ch != 'f')
|
||||||
|
@ -1645,9 +1643,9 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
printf ("scanimage (%s) %s; backend version %d.%d.%d\n", PACKAGE,
|
printf ("scanimage (%s) %s; backend version %d.%d.%d\n", PACKAGE,
|
||||||
VERSION, SANE_VERSION_MAJOR(version_code),
|
VERSION, SANE_VERSION_MAJOR (version_code),
|
||||||
SANE_VERSION_MINOR(version_code),
|
SANE_VERSION_MINOR (version_code),
|
||||||
SANE_VERSION_BUILD(version_code));
|
SANE_VERSION_BUILD (version_code));
|
||||||
exit (0);
|
exit (0);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1678,8 +1676,7 @@ standard output.\n\
|
||||||
-T, --test test backend thoroughly\n\
|
-T, --test test backend thoroughly\n\
|
||||||
-v, --verbose give even more status messages\n\
|
-v, --verbose give even more status messages\n\
|
||||||
-V, --version print version information\n\
|
-V, --version print version information\n\
|
||||||
--accept-md5-only only accept authorization requests using md5\n",
|
--accept-md5-only only accept authorization requests using md5\n", prog_name);
|
||||||
prog_name);
|
|
||||||
|
|
||||||
if (!devname)
|
if (!devname)
|
||||||
{
|
{
|
||||||
|
@ -1826,6 +1823,13 @@ standard output.\n\
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (optind < argc)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: argument without option: `%s'; ", prog_name,
|
||||||
|
argv[argc - 1]);
|
||||||
|
fprintf (stderr, "try %s --help\n", prog_name);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
free (full_optstring);
|
free (full_optstring);
|
||||||
for (index = 0; index < 2; ++index)
|
for (index = 0; index < 2; ++index)
|
||||||
|
@ -1923,10 +1927,10 @@ List of available devices:", prog_name);
|
||||||
format = "out%d.pnm";
|
format = "out%d.pnm";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(batch) {
|
if (batch)
|
||||||
fprintf(stderr, "Scanning %d pages, incrementing by %d, numbering from %d\n",
|
fprintf (stderr,
|
||||||
|
"Scanning %d pages, incrementing by %d, numbering from %d\n",
|
||||||
batch_count, batch_increment, batch_start_at);
|
batch_count, batch_increment, batch_start_at);
|
||||||
}
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -1940,11 +1944,13 @@ List of available devices:", prog_name);
|
||||||
return SANE_STATUS_ACCESS_DENIED;
|
return SANE_STATUS_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (batch) {
|
if (batch)
|
||||||
fprintf(stderr, "Scanning page %d\n", n);
|
{
|
||||||
|
fprintf (stderr, "Scanning page %d\n", n);
|
||||||
}
|
}
|
||||||
status = scan_it ();
|
status = scan_it ();
|
||||||
if (batch) {
|
if (batch)
|
||||||
|
{
|
||||||
fprintf (stderr, "Scanned page %d.", n);
|
fprintf (stderr, "Scanned page %d.", n);
|
||||||
fprintf (stderr, " (scanner status = %d)\n", status);
|
fprintf (stderr, " (scanner status = %d)\n", status);
|
||||||
}
|
}
|
||||||
|
@ -1966,7 +1972,8 @@ List of available devices:", prog_name);
|
||||||
} /* switch */
|
} /* switch */
|
||||||
n += batch_increment;
|
n += batch_increment;
|
||||||
}
|
}
|
||||||
while ((batch && (batch_count==BATCH_COUNT_UNLIMITED || --batch_count))
|
while ((batch
|
||||||
|
&& (batch_count == BATCH_COUNT_UNLIMITED || --batch_count))
|
||||||
&& SANE_STATUS_GOOD == status);
|
&& SANE_STATUS_GOOD == status);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Ładowanie…
Reference in New Issue