aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Belkin <abc@telekom.ru>2016-11-06 21:38:47 +0300
committerAlex Belkin <abc@telekom.ru>2016-11-06 21:42:52 +0300
commit58c1e43b83712899162030d83df3ecac151d69d3 (patch)
tree2576502b4d0ab534da6f7d71c96d422740a306de
parent610533a9a66d7232a8a0ecd360871e3a6fa67980 (diff)
Indent of xerox_mfp-tcp.c and xerox_mfp-usb.c
This is purely indent commit without any code changes, in follow-up to 83bbcfe7d546b4d0cd28269b647fb558c6a1e00a. Indent command used: astyle -A8 -U -H -k3 -W3 -o xerox_mfp-{usb,tcp}.c Proof that code is not changed: git log -w -p xerox_mfp-{usb,tcp}.c
-rw-r--r--backend/xerox_mfp-tcp.c132
-rw-r--r--backend/xerox_mfp-usb.c126
2 files changed, 129 insertions, 129 deletions
diff --git a/backend/xerox_mfp-tcp.c b/backend/xerox_mfp-tcp.c
index ab19ae6..845ab7e 100644
--- a/backend/xerox_mfp-tcp.c
+++ b/backend/xerox_mfp-tcp.c
@@ -47,9 +47,9 @@
#define RECV_TIMEOUT 1 /* seconds */
extern int sanei_debug_xerox_mfp;
-int tcp_dev_request (struct device *dev,
- SANE_Byte *cmd, size_t cmdlen,
- SANE_Byte *resp, size_t *resplen)
+int tcp_dev_request(struct device *dev,
+ SANE_Byte *cmd, size_t cmdlen,
+ SANE_Byte *resp, size_t *resplen)
{
size_t bytes_recv = 0;
ssize_t rc = 1;
@@ -58,46 +58,46 @@ int tcp_dev_request (struct device *dev,
/* Send request, if any */
if (cmd && cmdlen) {
- len = (size_t)sanei_tcp_write(dev->dn, cmd, cmdlen);
- if (len != cmdlen) {
- DBG (1, "%s: sent only %lu bytes of %lu\n",
- __func__, (u_long)len, (u_long)cmdlen);
- return SANE_STATUS_IO_ERROR;
- }
+ len = (size_t)sanei_tcp_write(dev->dn, cmd, cmdlen);
+ if (len != cmdlen) {
+ DBG(1, "%s: sent only %lu bytes of %lu\n",
+ __func__, (u_long)len, (u_long)cmdlen);
+ return SANE_STATUS_IO_ERROR;
+ }
}
/* Receive response, if expected */
if (resp && resplen) {
- DBG (3, "%s: wait for %i bytes\n", __func__, (int)*resplen);
-
- while (bytes_recv < *resplen && rc > 0) {
- rc = recv(dev->dn, resp+bytes_recv, *resplen-bytes_recv, 0);
-
- if (rc > 0) bytes_recv += rc;
- else {
- DBG(1, "%s: error %s, bytes requested: %i, bytes read: %i\n",
- __func__, strerror(errno), (int)*resplen, (int)bytes_recv);
- *resplen = bytes_recv;
-/*
- TODO:
- do something smarter than that!
-*/
- return SANE_STATUS_GOOD;
- return SANE_STATUS_IO_ERROR;
- }
- }
+ DBG(3, "%s: wait for %i bytes\n", __func__, (int)*resplen);
+
+ while (bytes_recv < *resplen && rc > 0) {
+ rc = recv(dev->dn, resp+bytes_recv, *resplen-bytes_recv, 0);
+
+ if (rc > 0) bytes_recv += rc;
+ else {
+ DBG(1, "%s: error %s, bytes requested: %i, bytes read: %i\n",
+ __func__, strerror(errno), (int)*resplen, (int)bytes_recv);
+ *resplen = bytes_recv;
+ /*
+ TODO:
+ do something smarter than that!
+ */
+ return SANE_STATUS_GOOD;
+ return SANE_STATUS_IO_ERROR;
+ }
+ }
}
*resplen = bytes_recv;
- return SANE_STATUS_GOOD;
+ return SANE_STATUS_GOOD;
}
-SANE_Status tcp_dev_open (struct device *dev)
+SANE_Status tcp_dev_open(struct device *dev)
{
SANE_Status status;
- char* strhost;
- char* strport;
+ char *strhost;
+ char *strport;
int port;
struct servent *sp;
struct timeval tv;
@@ -105,60 +105,60 @@ SANE_Status tcp_dev_open (struct device *dev)
devname = dev->sane.name;
- DBG (3, "%s: open %s\n", __func__, devname);
+ DBG(3, "%s: open %s\n", __func__, devname);
- if (strncmp (devname, "tcp", 3) != 0) return SANE_STATUS_INVAL;
+ if (strncmp(devname, "tcp", 3) != 0) return SANE_STATUS_INVAL;
devname += 3;
- devname = sanei_config_skip_whitespace (devname);
+ devname = sanei_config_skip_whitespace(devname);
if (!*devname) return SANE_STATUS_INVAL;
- devname = sanei_config_get_string (devname, &strhost);
- devname = sanei_config_skip_whitespace (devname);
+ devname = sanei_config_get_string(devname, &strhost);
+ devname = sanei_config_skip_whitespace(devname);
if (*devname)
- devname = sanei_config_get_string (devname, &strport);
+ devname = sanei_config_get_string(devname, &strport);
else
- strport = "9400";
+ strport = "9400";
if (isdigit(*strport)) {
- port = atoi(strport);
+ port = atoi(strport);
} else {
- if ((sp = getservbyname(strport, "tcp"))) {
- port = ntohs(sp->s_port);
- } else {
- DBG (1, "%s: unknown TCP service %s\n", __func__, strport);
- return SANE_STATUS_IO_ERROR;
- }
+ if ((sp = getservbyname(strport, "tcp"))) {
+ port = ntohs(sp->s_port);
+ } else {
+ DBG(1, "%s: unknown TCP service %s\n", __func__, strport);
+ return SANE_STATUS_IO_ERROR;
+ }
}
status = sanei_tcp_open(strhost, port, &dev->dn);
if (status == SANE_STATUS_GOOD) {
- tv.tv_sec = RECV_TIMEOUT;
- tv.tv_usec = 0;
- if (setsockopt (dev->dn, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv) < 0) {
- DBG(1, "%s: setsockopts %s", __func__, strerror(errno));
- }
+ tv.tv_sec = RECV_TIMEOUT;
+ tv.tv_usec = 0;
+ if (setsockopt(dev->dn, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv) < 0) {
+ DBG(1, "%s: setsockopts %s", __func__, strerror(errno));
+ }
}
return status;
}
void
-tcp_dev_close (struct device *dev)
+tcp_dev_close(struct device *dev)
{
if (!dev) return;
- DBG (3, "%s: closing dev %p\n", __func__, (void *)dev);
+ DBG(3, "%s: closing dev %p\n", __func__, (void *)dev);
/* finish all operations */
if (dev->scanning) {
- dev->cancel = 1;
- /* flush READ_IMAGE data */
- if (dev->reading) sane_read(dev, NULL, 1, NULL);
- /* send cancel if not sent before */
- if (dev->state != SANE_STATUS_CANCELLED)
- ret_cancel(dev, 0);
+ dev->cancel = 1;
+ /* flush READ_IMAGE data */
+ if (dev->reading) sane_read(dev, NULL, 1, NULL);
+ /* send cancel if not sent before */
+ if (dev->state != SANE_STATUS_CANCELLED)
+ ret_cancel(dev, 0);
}
sanei_tcp_close(dev->dn);
@@ -167,15 +167,15 @@ tcp_dev_close (struct device *dev)
SANE_Status
-tcp_configure_device (const char *devname, SANE_Status (*list_one)(SANE_String_Const devname))
+tcp_configure_device(const char *devname, SANE_Status(*list_one)(SANE_String_Const devname))
{
-/*
- TODO: LAN scanners multicast discovery.
- devname would contain "tcp auto"
-
- We find new devnames and feed them to
- `list_one_device' one by one
-*/
+ /*
+ TODO: LAN scanners multicast discovery.
+ devname would contain "tcp auto"
+
+ We find new devnames and feed them to
+ `list_one_device' one by one
+ */
return list_one(devname);
}
diff --git a/backend/xerox_mfp-usb.c b/backend/xerox_mfp-usb.c
index 0d8d765..6ef1eea 100644
--- a/backend/xerox_mfp-usb.c
+++ b/backend/xerox_mfp-usb.c
@@ -22,90 +22,90 @@
extern int sanei_debug_xerox_mfp;
int
-usb_dev_request (struct device *dev,
- SANE_Byte *cmd, size_t cmdlen,
- SANE_Byte *resp, size_t *resplen)
+usb_dev_request(struct device *dev,
+ SANE_Byte *cmd, size_t cmdlen,
+ SANE_Byte *resp, size_t *resplen)
{
- SANE_Status status;
- size_t len = cmdlen;
-
- if (cmd && cmdlen) {
- status = sanei_usb_write_bulk (dev->dn, cmd, &cmdlen);
- if (status != SANE_STATUS_GOOD) {
- DBG (1, "%s: sanei_usb_write_bulk: %s\n", __func__,
- sane_strstatus (status));
- return SANE_STATUS_IO_ERROR;
+ SANE_Status status;
+ size_t len = cmdlen;
+
+ if (cmd && cmdlen) {
+ status = sanei_usb_write_bulk(dev->dn, cmd, &cmdlen);
+ if (status != SANE_STATUS_GOOD) {
+ DBG(1, "%s: sanei_usb_write_bulk: %s\n", __func__,
+ sane_strstatus(status));
+ return SANE_STATUS_IO_ERROR;
+ }
+
+ if (cmdlen != len) {
+ DBG(1, "%s: sanei_usb_write_bulk: wanted %lu bytes, wrote %lu bytes\n",
+ __func__, (size_t)len, (size_t)cmdlen);
+ return SANE_STATUS_IO_ERROR;
+ }
}
- if (cmdlen != len) {
- DBG (1, "%s: sanei_usb_write_bulk: wanted %lu bytes, wrote %lu bytes\n",
- __func__, (size_t)len, (size_t)cmdlen);
- return SANE_STATUS_IO_ERROR;
- }
- }
-
- if (resp && resplen) {
- status = sanei_usb_read_bulk (dev->dn, resp, resplen);
- if (status != SANE_STATUS_GOOD) {
- DBG (1, "%s: sanei_usb_read_bulk: %s\n", __func__,
- sane_strstatus (status));
- return SANE_STATUS_IO_ERROR;
+ if (resp && resplen) {
+ status = sanei_usb_read_bulk(dev->dn, resp, resplen);
+ if (status != SANE_STATUS_GOOD) {
+ DBG(1, "%s: sanei_usb_read_bulk: %s\n", __func__,
+ sane_strstatus(status));
+ return SANE_STATUS_IO_ERROR;
+ }
}
- }
- return SANE_STATUS_GOOD;
+ return SANE_STATUS_GOOD;
}
SANE_Status
-usb_dev_open (struct device *dev)
+usb_dev_open(struct device *dev)
{
- SANE_Status status;
-
- DBG (3, "%s: open %p\n", __func__, (void *)dev);
- status = sanei_usb_open (dev->sane.name, &dev->dn);
- if (status != SANE_STATUS_GOOD) {
- DBG (1, "%s: sanei_usb_open(%s): %s\n", __func__,
- dev->sane.name, sane_strstatus (status));
- dev->dn = -1;
- return status;
+ SANE_Status status;
+
+ DBG(3, "%s: open %p\n", __func__, (void *)dev);
+ status = sanei_usb_open(dev->sane.name, &dev->dn);
+ if (status != SANE_STATUS_GOOD) {
+ DBG(1, "%s: sanei_usb_open(%s): %s\n", __func__,
+ dev->sane.name, sane_strstatus(status));
+ dev->dn = -1;
+ return status;
}
- sanei_usb_clear_halt (dev->dn);
- return SANE_STATUS_GOOD;
+ sanei_usb_clear_halt(dev->dn);
+ return SANE_STATUS_GOOD;
}
void
-usb_dev_close (struct device *dev)
+usb_dev_close(struct device *dev)
{
- if (!dev)
- return;
- DBG (3, "%s: closing dev %p\n", __func__, (void *)dev);
-
- /* finish all operations */
- if (dev->scanning) {
- dev->cancel = 1;
- /* flush READ_IMAGE data */
- if (dev->reading)
- sane_read(dev, NULL, 1, NULL);
- /* send cancel if not sent before */
- if (dev->state != SANE_STATUS_CANCELLED)
- ret_cancel(dev, 0);
- }
-
- sanei_usb_clear_halt (dev->dn); /* unstall for next users */
- sanei_usb_close (dev->dn);
- dev->dn = -1;
+ if (!dev)
+ return;
+ DBG(3, "%s: closing dev %p\n", __func__, (void *)dev);
+
+ /* finish all operations */
+ if (dev->scanning) {
+ dev->cancel = 1;
+ /* flush READ_IMAGE data */
+ if (dev->reading)
+ sane_read(dev, NULL, 1, NULL);
+ /* send cancel if not sent before */
+ if (dev->state != SANE_STATUS_CANCELLED)
+ ret_cancel(dev, 0);
+ }
+
+ sanei_usb_clear_halt(dev->dn); /* unstall for next users */
+ sanei_usb_close(dev->dn);
+ dev->dn = -1;
}
/* SANE API ignores return code of this callback */
SANE_Status
-usb_configure_device (const char *devname, SANE_Status (*attach) (const char *dev))
+usb_configure_device(const char *devname, SANE_Status(*attach)(const char *dev))
{
- sanei_usb_set_timeout (1000);
- sanei_usb_attach_matching_devices (devname, attach);
- sanei_usb_set_timeout (30000);
- return SANE_STATUS_GOOD;
+ sanei_usb_set_timeout(1000);
+ sanei_usb_attach_matching_devices(devname, attach);
+ sanei_usb_set_timeout(30000);
+ return SANE_STATUS_GOOD;
}