List Info

Thread: sanei_tcp




sanei_tcp
user name
2006-02-23 19:35:26

 Hi,

  this patch adds support for sanei_tcp, a TCP
 based interface. 

 include/sane/sanei_tcp.h |   33 ++++++++++++++++++++
 sanei/Makefile.in        |    7 ++--
 sanei/sanei_tcp.c        |   74
+++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+), 3 deletions(-)

--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ sane-backends/include/sane/sanei_tcp.h	2006-02-23
20:32:41.000000000 +0100
 -0,0
+1,33 
+/* sane - Scanner Access Now Easy.
+   Copyright (c) 2006 Tower Technologies
+   This file is part of the SANE package.
+
+   This file is in the public domain.  You may use and
modify it as
+   you see fit, as long as this copyright message is
included and
+   that there is an indication as to what modifications
have been
+   made (if any).
+
+   SANE is distributed in the hope that it will be useful,
but WITHOUT
+   ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.
+
+   This file declares SANE application interface.  See the
SANE
+   standard for a detailed explanation of the interface.
+*/
+
+#ifndef sanei_tcp_h
+#define sanei_tcp_h
+
+#include <sane/sane.h>
+#include <sane/sanei_wire.h>
+
+#include <netinet/in.h>
+#include <netdb.h>
+
+extern SANE_Status sanei_tcp_open(const char *host, int
port, int *fdp);
+extern void sanei_tcp_close(int fd);
+extern ssize_t sanei_tcp_write(int fd, const u_char *buf,
int count);
+extern ssize_t sanei_tcp_read(int fd, u_char *buf, int
count);
+
+
+#endif /* sanei_tcp_h */
--- sane-backends.orig/sanei/Makefile.in	2006-02-23
20:22:58.000000000 +0100
+++ sane-backends/sanei/Makefile.in	2006-02-23
20:23:13.000000000 +0100
 -51,13
+51,14  LIBSANEI_OBJS = sanei_ab306.o sanei_cons
 	sanei_net.o sanei_wire.o sanei_codec_ascii.o
sanei_codec_bin.o \
 	sanei_scsi.o sanei_config.o sanei_config2.o sanei_pio.o
sanei_pa4s2.o \
 	sanei_auth.o sanei_usb.o sanei_thread.o sanei_pv8630.o
sanei_pp.o \
-	sanei_lm983x.o sanei_access.o SANEI_JPEG
+	sanei_lm983x.o sanei_access.o sanei_tcp.o SANEI_JPEG
 
 LIBSANEI_LTOBJS = sanei_ab306.lo sanei_constrain_value.lo
sanei_init_debug.lo \
 	sanei_net.lo sanei_wire.lo sanei_codec_ascii.lo
sanei_codec_bin.lo \
 	sanei_scsi.lo sanei_config.lo sanei_config2.lo
sanei_pio.lo \
 	sanei_pa4s2.lo sanei_auth.lo sanei_usb.lo sanei_thread.lo
\
-	sanei_pv8630.lo sanei_lm983x.lo sanei_pp.lo
sanei_access.lo SANEI_JPEG_LO
+	sanei_pv8630.lo sanei_lm983x.lo sanei_pp.lo
sanei_access.lo SANEI_JPEG_LO \
+	sanei_tcp.lo
 
 TARGETS = libsanei.a $(LIBSANEI_LTOBJS)
 TESTPROGRAMS = test_wire
 -68,7
+69,7  DISTFILES = Makefile.in linux_sg3_err.h 
   sanei_constrain_value.c sanei_init_debug.c sanei_jpeg.c
\
   sanei_net.c sanei_pa4s2.c sanei_pio.c sanei_pv8630.c
sanei_lm983x.c \
   sanei_scsi.c sanei_thread.c sanei_usb.c sanei_pp.c \
-  sanei_wire.c test_wire.c sanei_access.c
+  sanei_wire.c test_wire.c sanei_access.c sanei_tcp.c
 
 .PHONY: all check clean depend dist distclean install
uninstall
 
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ sane-backends/sanei/sanei_tcp.c	2006-02-23
20:23:27.000000000 +0100
 -0,0
+1,74 
+/* sane - Scanner Access Now Easy.
+   Copyright (c) 2006 Tower Technologies
+   Author: Alessandro Zummo <a.zummotowertech.it>
+   This file is part of the SANE package.
+
+   This program is free software; you can redistribute it
and/or
+   modify it under the terms of the GNU General Public
License,
+   version 2, published by the Free Software Foundation.
+*/
+
+#include "../include/sane/config.h"
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define BACKEND_NAME sanei_tcp
+
+#include "../include/sane/sane.h"
+#include "../include/sane/sanei_debug.h"
+#include "../include/sane/sanei_tcp.h"
+
+SANE_Status
+sanei_tcp_open(const char *host, int port, int *fdp)
+{
+	int fd, err;
+	struct sockaddr_in saddr;
+	struct hostent *h;
+
+	DBG_INIT();
+	DBG(1, "%s: host = %s, port = %d\n",
__FUNCTION__, host, port);
+
+	h = gethostbyname(host);
+
+	if (h == NULL || h->h_addr_list[0] == NULL ||
h->h_addrtype != AF_INET)
+		return SANE_STATUS_INVAL;
+
+	if ((fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) <
0)
+		return SANE_STATUS_INVAL;
+
+	memset(&saddr, 0x00, sizeof(struct sockaddr_in));
+
+	saddr.sin_family = AF_INET;
+	saddr.sin_port = htons(port);
+	memcpy(&saddr.sin_addr, h->h_addr_list[0],
h->h_length);
+
+	if ((err = connect(fd, (struct sockaddr *) &saddr,
sizeof(struct sockaddr_in))) != 0) {
+		close(fd);
+		return SANE_STATUS_INVAL;
+	}
+
+	*fdp = fd;
+
+	return SANE_STATUS_GOOD;
+}
+
+void
+sanei_tcp_close(int fd)
+{
+	close(fd);
+}
+
+ssize_t
+sanei_tcp_write(int fd, const u_char *buf, int count)
+{
+	return send(fd, buf, count, 0);
+}
+
+ssize_t
+sanei_tcp_read(int fd, u_char *buf, int count)
+{
+	return recv(fd, buf, count, 0);
+}


-- 

 Best regards,

 Alessandro Zummo,
  Tower Technologies - Turin, Italy

  http://www.towertech.it


-- 
sane-devel mailing list: sane-devellists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/sane-d
evel
Unsubscribe: Send mail with subject "unsubscribe
your_password"
             to sane-devel-requestlists.alioth.debian.org
sanei_tcp
user name
2006-02-26 12:24:14
Hi,

On 2006-02-23 20:35, Alessandro Zummo wrote:
>   this patch adds support for sanei_tcp, a TCP
>  based interface. 

Thanks. I haven't looked at the actual code yet, just some
formal
things:

> +++ sane-backends/include/sane/sanei_tcp.h	2006-02-23
20:32:41.000000000 +0100
>  -0,0 +1,33 

[...]

> +   This file declares SANE application interface.  See
the SANE
> +   standard for a detailed explanation of the
interface.

No, sanei files aren't part of the SANE API.
SANE uses the public domain license for sane.h only, the
other header
files use GPL+SANE exception. But this is up to you.

> +++ sane-backends/sanei/sanei_tcp.c	2006-02-23
20:23:27.000000000 +0100
> +/* sane - Scanner Access Now Easy.
> +   Copyright (c) 2006 Tower Technologies
> +   Author: Alessandro Zummo <a.zummotowertech.it>
> +   This file is part of the SANE package.
> +
> +   This program is free software; you can redistribute
it and/or
> +   modify it under the terms of the GNU General Public
License,
> +   version 2, published by the Free Software
Foundation.
> +*/

This should be GPL+SANE exception. Otherwise the SANE
exception for
all backends may be void. At least for all backends that
link to this
code. See the other sanei_*.c files for examples.

Bye,
  Henning

-- 
sane-devel mailing list: sane-devellists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/sane-d
evel
Unsubscribe: Send mail with subject "unsubscribe
your_password"
             to sane-devel-requestlists.alioth.debian.org
sanei_tcp
user name
2006-02-27 12:26:04
On Sun, 26 Feb 2006 13:24:14 +0100
Henning Meier-Geinitz <henningmeier-geinitz.de> wrote:

> Thanks. I haven't looked at the actual code yet, just
some formal
> things:


 [..]

 ok, I will modify the license. please drop me a note when
you'll have
 reviewed the code so I can send the new version just once.

 thanks.
-- 

 Best regards,

 Alessandro Zummo,
  Tower Technologies - Turin, Italy

  http://www.towertech.it


-- 
sane-devel mailing list: sane-devellists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/sane-d
evel
Unsubscribe: Send mail with subject "unsubscribe
your_password"
             to sane-devel-requestlists.alioth.debian.org
sanei_tcp
user name
2006-05-21 16:24:37
Hi,

On 2006-02-27 13:26, Alessandro Zummo wrote:
> > Thanks. I haven't looked at the actual code yet,
just some formal
> > things:
> 
> 
>  [..]
> 
>  ok, I will modify the license. please drop me a note
when you'll have
>  reviewed the code so I can send the new version just
once.

Sorry for the long delay. I have no comments on the actual
code, but
somebody with more betwork knowledge shoulc look at it
anyway.

What's the status of your AcuLaser CX11NF via network
backend?

Bye,
  Henning

-- 
sane-devel mailing list: sane-devellists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/sane-d
evel
Unsubscribe: Send mail with subject "unsubscribe
your_password"
             to sane-devel-requestlists.alioth.debian.org
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )