aboutsummaryrefslogtreecommitdiff
path: root/devel/libpasori
diff options
context:
space:
mode:
authorNorikatsu Shigemura <nork@FreeBSD.org>2007-01-21 13:39:26 +0000
committerNorikatsu Shigemura <nork@FreeBSD.org>2007-01-21 13:39:26 +0000
commita9905cdafd258cf886b75e96dce0581c987a21af (patch)
tree2167bfa7639261dc6df667f3f99a88015a0f19de /devel/libpasori
parent81a5022f951ae480e596e79decae775d7f11030b (diff)
downloadports-a9905cdafd258cf886b75e96dce0581c987a21af.tar.gz
ports-a9905cdafd258cf886b75e96dce0581c987a21af.zip
Notes
Diffstat (limited to 'devel/libpasori')
-rw-r--r--devel/libpasori/Makefile30
-rw-r--r--devel/libpasori/distinfo3
-rw-r--r--devel/libpasori/files/Makefile5
-rw-r--r--devel/libpasori/files/Makefile.lib18
-rw-r--r--devel/libpasori/files/Makefile.lpdump14
-rw-r--r--devel/libpasori/files/Makefile.lptest14
-rw-r--r--devel/libpasori/files/patch-libpasori_com_bsdugen.c147
-rw-r--r--devel/libpasori/files/patch-libpasori_command.c44
-rw-r--r--devel/libpasori/files/patch-libpasori_command.h13
-rw-r--r--devel/libpasori/files/patch-libpasori_polling.c11
-rw-r--r--devel/libpasori/files/patch-lpdump.c51
-rw-r--r--devel/libpasori/files/patch-lptest.c44
-rw-r--r--devel/libpasori/pkg-descr4
-rw-r--r--devel/libpasori/pkg-message3
-rw-r--r--devel/libpasori/pkg-plist8
15 files changed, 409 insertions, 0 deletions
diff --git a/devel/libpasori/Makefile b/devel/libpasori/Makefile
new file mode 100644
index 000000000000..c01c48f00929
--- /dev/null
+++ b/devel/libpasori/Makefile
@@ -0,0 +1,30 @@
+# New ports collection makefile for: libpasori
+# Date created: 18 January 2007
+# Whom: Yoshihiko Sarumaru <mistral@imasy.or.jp>
+#
+# $FreeBSD$
+
+PORTNAME= libpasori
+PORTVERSION= 02
+CATEGORIES= devel
+MASTER_SITES= ${MASTER_SITE_SOURCEFORGE_JP}
+MASTER_SITE_SUBDIR= ${PORTNAME}/20457
+DISTNAME= ${PORTNAME}${PORTVERSION}
+
+MAINTAINER= mistral@imasy.or.jp
+COMMENT= FeliCa read/write library for Sony RC-S320 USB FeliCa R/W(PaSoRi)
+
+USE_BZIP2= yes
+WRKSRC= ${WRKDIR}/${PORTNAME}
+
+post-extract:
+ @${MKDIR} ${WRKSRC}/lib ${WRKSRC}/lpdump ${WRKSRC}/lptest
+ @${CP} ${FILESDIR}/Makefile ${WRKSRC}/Makefile
+ @${CP} ${FILESDIR}/Makefile.lib ${WRKSRC}/lib/Makefile
+ @${CP} ${FILESDIR}/Makefile.lpdump ${WRKSRC}/lptest/Makefile
+ @${CP} ${FILESDIR}/Makefile.lptest ${WRKSRC}/lpdump/Makefile
+
+post-install:
+ @${CAT} ${PKGMESSAGE}
+
+.include <bsd.port.mk>
diff --git a/devel/libpasori/distinfo b/devel/libpasori/distinfo
new file mode 100644
index 000000000000..cae632f483fc
--- /dev/null
+++ b/devel/libpasori/distinfo
@@ -0,0 +1,3 @@
+MD5 (libpasori02.tar.bz2) = c23f2a3ae3d699bcd7a269dbd64120fb
+SHA256 (libpasori02.tar.bz2) = 753dedbb8deb1f30d6d227f6e352714b5045badc6c86e77c651497e0b2a9bb15
+SIZE (libpasori02.tar.bz2) = 6352
diff --git a/devel/libpasori/files/Makefile b/devel/libpasori/files/Makefile
new file mode 100644
index 000000000000..4b1c5811dcde
--- /dev/null
+++ b/devel/libpasori/files/Makefile
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+SUBDIR= lib lpdump lptest
+
+.include <bsd.subdir.mk>
diff --git a/devel/libpasori/files/Makefile.lib b/devel/libpasori/files/Makefile.lib
new file mode 100644
index 000000000000..faf16f93e3f3
--- /dev/null
+++ b/devel/libpasori/files/Makefile.lib
@@ -0,0 +1,18 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../src
+
+LIB= pasori
+SRCS= libpasori_command.c libpasori_com_bsdugen.c \
+ libpasori_polling.c
+INCS= libpasori.h libpasori_com.h libpasori_command.h \
+ libpasori_config.h libpasori_liblocal.h
+
+LIBDIR= ${LOCALBASE}/lib
+INCLUDEDIR= ${LOCALBASE}/include
+NO_PROFILE=
+
+CFLAGS+= -D__LIBPASORI_WITH_BSDUGEN
+CFLAGS+= -Wall -W
+
+.include <bsd.lib.mk>
diff --git a/devel/libpasori/files/Makefile.lpdump b/devel/libpasori/files/Makefile.lpdump
new file mode 100644
index 000000000000..c2a08b99c3e2
--- /dev/null
+++ b/devel/libpasori/files/Makefile.lpdump
@@ -0,0 +1,14 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../src
+
+PROG= lpdump
+DPADD= libpasori.a
+LDADD= -L../lib -lpasori
+
+BINDIR= ${LOCALBASE}/bin
+NO_MAN=
+
+CFLAGS+= -Wall -W
+
+.include <bsd.prog.mk>
diff --git a/devel/libpasori/files/Makefile.lptest b/devel/libpasori/files/Makefile.lptest
new file mode 100644
index 000000000000..4b045140f968
--- /dev/null
+++ b/devel/libpasori/files/Makefile.lptest
@@ -0,0 +1,14 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../src
+
+PROG= lptest
+DPADD= libpasori.a
+LDADD= -L../lib -lpasori
+
+BINDIR= ${LOCALBASE}/bin
+NO_MAN=
+
+CFLAGS+= -Wall -W
+
+.include <bsd.prog.mk>
diff --git a/devel/libpasori/files/patch-libpasori_com_bsdugen.c b/devel/libpasori/files/patch-libpasori_com_bsdugen.c
new file mode 100644
index 000000000000..8b699002fdb2
--- /dev/null
+++ b/devel/libpasori/files/patch-libpasori_com_bsdugen.c
@@ -0,0 +1,147 @@
+--- src/libpasori_com_bsdugen.c.orig Mon Mar 20 09:12:58 2006
++++ src/libpasori_com_bsdugen.c Sat Jan 20 23:13:12 2007
+@@ -6,7 +6,16 @@
+ #include <sys/ioctl.h>
+ #include <errno.h>
+
++#include <sys/param.h>
++#include <string.h>
++#include <unistd.h>
++#include <err.h>
++
+ #include "libpasori_liblocal.h"
++#include "libpasori.h"
++
++#define VENDOR_SONY 0x054c
++#define PRODUCT_RC_S320 0x01bb
+
+ void dbg_dump(uint8* d,int size){
+ int i;
+@@ -16,25 +25,86 @@
+ Log("\n");
+ }
+
+-pasori* pasori_open(char* c){ /* FIXME:unused arg. */
++void search_pasori(char* devname, int devnamelen){
++ int pathnum;
++ char buspath[16];
++ int busfd;
++
++ memset(devname, 0, devnamelen);
++ for (pathnum = 0; pathnum < 10; pathnum++) {
++ snprintf(buspath, sizeof(buspath), "/dev/usb%d", pathnum);
++ if ((busfd = open(buspath, O_RDONLY)) >= 0) {
++ int devnum;
++ for (devnum = 1; devnum < USB_MAX_DEVICES; devnum++) {
++ struct usb_device_info di;
++ di.udi_addr = devnum;
++ if (ioctl(busfd, USB_DEVICEINFO, &di) != -1) {
++ if ((di.udi_vendorNo == VENDOR_SONY) &&
++ (di.udi_productNo == PRODUCT_RC_S320)) {
++ int i;
++ for (i=0; i<USB_MAX_DEVNAMES; i++) {
++ if (strncmp(di.udi_devnames[i], "ugen", 4) == 0) {
++ snprintf(devname, devnamelen,
++ "/dev/%s", di.udi_devnames[i]);
++ devname[devnamelen -1] = '\0';
++ break;
++ }
++ }
++ }
++ }
++ if (devname[0] != '\0') break;
++ }
++ close(busfd);
++ if (devname[0] != '\0') break;
++ } else {
++ continue;
++ }
++ }
++}
++
++pasori* pasori_open(char* c){
+ int config;
+ pasori *pp;
+- char* pasori_devname;
+- char* pasori_intr;
++ char pasori_devname[USB_MAX_DEVNAMELEN +1];
++ char pasori_ctrl[PATH_MAX];
++ char pasori_intr[PATH_MAX];
+ int i;
+- int t;
+- const int timeout = 400;
+- const int size = 0;
+ pp = (pasori *)malloc(sizeof(pasori));
+
+- pasori_devname = "/dev/ugen0.00"; /* FIXME:hardcoded device path */
+- pasori_intr = "/dev/ugen0.01";
+-
+- pp->fd_cntl = open(pasori_devname,O_RDWR);
++ if (c != NULL) {
++ snprintf(pasori_devname, sizeof(pasori_devname),
++ "%s", c);
++ pasori_devname[sizeof(pasori_devname) -1] = '\0';
++ } else {
++ search_pasori(pasori_devname, sizeof(pasori_devname));
++ if (strlen(pasori_devname) == 0) {
++ warnx("No PaSoRi was found.");
++ return NULL;
++ }
++ }
++#if defined(__NetBSD__) || defined(__OpenBSD__)
++ snprintf(pasori_ctrl, sizeof(pasori_ctrl),
++ "%s.00", pasori_devname);
++#else
++ snprintf(pasori_ctrl, sizeof(pasori_ctrl),
++ "%s", pasori_devname);
++#endif
++ pasori_ctrl[sizeof(pasori_ctrl) -1] = '\0';
++ snprintf(pasori_intr, sizeof(pasori_intr),
++ "%s.1", pasori_devname);
++ pasori_intr[sizeof(pasori_intr) -1] = '\0';
++
++ pp->fd_cntl = open(pasori_ctrl,O_RDWR);
++ if (pp->fd_cntl == -1) {
++ warn("%s", pasori_ctrl);
++ }
+
+ config = 1;
+ i = ioctl(pp->fd_cntl,USB_SET_CONFIG,&config);
+ pp->fd_intr = open(pasori_intr,O_RDONLY | O_NONBLOCK);
++ if (pp->fd_intr == -1) {
++ warn("%s", pasori_intr);
++ }
+ if( (pp->fd_cntl < 0) || (pp->fd_intr < 0) ){
+ Log("error opening pasori.%d %d",pp->fd_cntl,pp->fd_intr);
+ close(pp->fd_cntl);
+@@ -47,7 +117,6 @@
+
+ int pasori_send(pasori* pp,uint8 *cmd,uint8 size,int timeout){
+ struct usb_ctl_request req;
+- uint8 msg[128]; /* FIXME:max message bytes? */
+ uint8 resp[256];
+ signed int i;
+ int t;
+@@ -90,11 +159,12 @@
+ int pasori_recv(pasori* pp,uint8* buf,uint8 bufsize,int timeout){
+ signed int i;
+ int state;
+- int size;
++ int size=0;
+ int ptr;
+- int one = 1;
+ fd_set fds;
+ struct timeval tv;
++
++ (void)bufsize; /* FIXME: buffer size is not checked */
+
+ uint8 resp;
+ state = STATE_UNKNOWN;
+@@ -156,5 +226,7 @@
+ void pasori_close(pasori* p){
+ close(p->fd_intr);
+ close(p->fd_cntl);
++ free(p);
++ p = NULL;
+ }
+
diff --git a/devel/libpasori/files/patch-libpasori_command.c b/devel/libpasori/files/patch-libpasori_command.c
new file mode 100644
index 000000000000..5170cfa07270
--- /dev/null
+++ b/devel/libpasori/files/patch-libpasori_command.c
@@ -0,0 +1,44 @@
+--- src/libpasori_command.c.orig Mon Mar 20 09:12:58 2006
++++ src/libpasori_command.c Fri Jan 19 01:54:43 2007
+@@ -1,6 +1,7 @@
+ /* pasori commands */
+ #include "libpasori_liblocal.h"
+ #include <stdlib.h>
++#include <string.h>
+
+ /* FIXME: UNKNOWN CONSTANTS */
+ const uint8 PASORI_INIT0[] = {0x62,0x01,0x82};
+@@ -24,7 +25,6 @@
+ void /* FIXME: return errorcode */
+ pasori_packet_write(pasori* p,uint8* data,int size){ /* RAW Packet SEND */
+ uint8 cmd[256];
+- uint8 recv[256];
+ uint8 sum;
+ int i;
+ sum = 0;
+@@ -81,6 +81,7 @@
+ s = recv[3];
+ /* FIXME:calc checksum */
+ /* FIXME:check buffer size */
++ (void)size;
+ /* FIXME:check msgid */
+ s--;
+ memcpy(data,&recv[7],s);
+@@ -95,6 +96,9 @@
+ uint8 resp[256];
+ uint8 blklist[2];
+ int i;
++
++ (void)mode; /* FIXME: what is this argument? */
++
+ blklist[0] = 0;
+ blklist[1] = addr;
+ blklist[0] |= 0x80; /* element size == 2 */
+@@ -124,7 +128,6 @@
+ /* INIT */
+ int
+ pasori_init(pasori *p){
+- uint8 recv[256];
+ pasori_test(p,PASORI_INIT0,sizeof(PASORI_INIT0));
+ pasori_test(p,PASORI_INIT1,sizeof(PASORI_INIT1));
+ pasori_test(p,PASORI_INIT2,sizeof(PASORI_INIT2));
diff --git a/devel/libpasori/files/patch-libpasori_command.h b/devel/libpasori/files/patch-libpasori_command.h
new file mode 100644
index 000000000000..c429f9fe01f4
--- /dev/null
+++ b/devel/libpasori/files/patch-libpasori_command.h
@@ -0,0 +1,13 @@
+--- src/libpasori_command.h.orig Mon Mar 20 09:12:58 2006
++++ src/libpasori_command.h Fri Jan 19 00:38:48 2007
+@@ -2,8 +2,8 @@
+ #define __LIBPASORI_COMMAND_H
+
+ int pasori_init(pasori*);
+-int pasori_write(pasori*,uint8,uint8);
+-int pasori_read(pasori*,uint8,uint8);
++int pasori_write(pasori*,uint8*,uint8);
++int pasori_read(pasori*,uint8*,uint8);
+
+ felica* felica_polling(pasori*,uint16,uint8,uint8);
+ int felica_read_without_encryption02(felica* f,int servicecode,int mode,uint8 addr,uint8* b);
diff --git a/devel/libpasori/files/patch-libpasori_polling.c b/devel/libpasori/files/patch-libpasori_polling.c
new file mode 100644
index 000000000000..1f7208407440
--- /dev/null
+++ b/devel/libpasori/files/patch-libpasori_polling.c
@@ -0,0 +1,11 @@
+--- src/libpasori_polling.c.orig Tue May 16 01:45:01 2006
++++ src/libpasori_polling.c Fri Jan 19 01:09:56 2007
+@@ -1,6 +1,8 @@
+ /* libpasori polling func. */
+ #include <stdlib.h>
++#include <string.h>
+ #include "libpasori_liblocal.h"
++#include "libpasori_command.h"
+
+
+ felica *
diff --git a/devel/libpasori/files/patch-lpdump.c b/devel/libpasori/files/patch-lpdump.c
new file mode 100644
index 000000000000..09f243000814
--- /dev/null
+++ b/devel/libpasori/files/patch-lpdump.c
@@ -0,0 +1,51 @@
+--- src/lpdump.c.orig Tue May 16 02:55:42 2006
++++ src/lpdump.c Sat Jan 20 23:04:08 2007
+@@ -1,8 +1,10 @@
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <string.h>
+ #include <time.h>
+
+ #include "libpasori.h"
++#include "libpasori_command.h"
+
+ void
+ mydump(uint8 *p,int size){
+@@ -96,7 +98,6 @@
+ uint16 area_end[60];
+ uint16 area_count;
+ uint16 servicecode[128];
+- int servicecode_area[128];
+ uint16 servicecode_count;
+ uint16 t;
+ uint16 idx;
+@@ -166,7 +167,7 @@
+ uint8 resp[256];
+ uint16 sc[4];
+ int sc_count;
+- int i,j;
++ int i;
+
+ cmd[0] = 0x0c;
+ memcpy(&cmd[1],f->IDm,8);
+@@ -188,14 +189,15 @@
+ }
+
+ int
+-main(void){
++main(int argc, char **argv){
+ pasori* p;
+ felica* f;
+- int i;
+- int m;
+- uint8 b[16];
+
+- p = pasori_open(NULL);
++ char* devpath = NULL;
++ if (argc == 2) {
++ devpath = argv[1];
++ }
++ p = pasori_open(devpath);
+ if(!p){
+ printf("error\n");
+ exit(-1);
diff --git a/devel/libpasori/files/patch-lptest.c b/devel/libpasori/files/patch-lptest.c
new file mode 100644
index 000000000000..0d94c5ee2a8e
--- /dev/null
+++ b/devel/libpasori/files/patch-lptest.c
@@ -0,0 +1,44 @@
+--- src/lptest.c.orig Mon Mar 20 09:12:58 2006
++++ src/lptest.c Sun Jan 21 00:36:43 2007
+@@ -2,24 +2,29 @@
+ #include <stdlib.h>
+
+ #include "libpasori.h"
++#include "libpasori_command.h"
+
+
+ int
+-main(void){
++main(int argc, char **argv){
+ pasori* p;
+ felica* f;
+ int i;
+- int m;
+ uint8 b[16];
+
+ printf("lptest : start\n");
+- p = pasori_open(NULL);
++ char* devpath = NULL;
++ if (argc == 2) {
++ devpath = argv[1];
++ }
++ p = pasori_open(devpath);
+ if(!p){
+ printf("error\n");
+ exit(-1);
+ }
+ pasori_init(p);
+ f = felica_polling(p,POLLING_ANY,0,0);
++ if (f) {
+ printf("read test\n");
+ for(i=0;i!=32;i++){
+ if(!felica_read_without_encryption02(f,0x090f,0,i,b)){
+@@ -38,6 +43,8 @@
+
+
+ }
++ }
++ free(f);
+ }
+
+ pasori_close(p);
diff --git a/devel/libpasori/pkg-descr b/devel/libpasori/pkg-descr
new file mode 100644
index 000000000000..ba90a516419c
--- /dev/null
+++ b/devel/libpasori/pkg-descr
@@ -0,0 +1,4 @@
+FeliCa read/write library for Sony RC-S320 USB FeliCa R/W(PaSoRi).
+This library is independent from the SDK for FeliCa.
+
+WWW: http://libpasori.sourceforge.jp/
diff --git a/devel/libpasori/pkg-message b/devel/libpasori/pkg-message
new file mode 100644
index 000000000000..14de2c8bebd7
--- /dev/null
+++ b/devel/libpasori/pkg-message
@@ -0,0 +1,3 @@
+******************************************************************************
+Place your FeliCa card on PaSoRi before executing commands.
+******************************************************************************
diff --git a/devel/libpasori/pkg-plist b/devel/libpasori/pkg-plist
new file mode 100644
index 000000000000..43ae94c4a986
--- /dev/null
+++ b/devel/libpasori/pkg-plist
@@ -0,0 +1,8 @@
+bin/lpdump
+bin/lptest
+include/libpasori.h
+include/libpasori_command.h
+include/libpasori_liblocal.h
+include/libpasori_com.h
+include/libpasori_config.h
+lib/libpasori.a