[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[mhc:02219] Re: pilot-link 0.12.1
Message-Id: <87zmcipscr.wl%ukai@xxxxxxxxxxxx>
Date: Sat, 30 Sep 2006 01:09:24 +0900
From: Fumitoshi UKAI <ukai@xxxxxxxxxxxx>
Subject: [mhc:02218] pilot-link 0.12.1
| pilot-link 0.12 でAPIがだいぶかわっていてbuildできないようなのですが
| 誰か直している人おられますか?
|
| http://bugs.debian.org/386196
pilot-link 0.12ではバッファリングが改良されたおかげで
とくに無線LANのような遅延の大きな環境でパフォーマンスがよくなるので
mhcも見た目だけの修正で直せるかと半年くらい前にfixに挑戦したのですが
動かずあきらめてしまいました。
とりあえず、できそこないのパッチを添付します。
--
KOIE Hidetaka <hide@xxxxxxxx>
Index: ruby-ext/mhc_pilib.c
===================================================================
RCS file: /cvsroot/mhc/ruby-ext/mhc_pilib.c,v
retrieving revision 1.5
diff -p -u -r1.5 mhc_pilib.c
--- ruby-ext/mhc_pilib.c 15 Nov 2004 00:40:01 -0000 1.5
+++ ruby-ext/mhc_pilib.c 29 Sep 2006 23:43:55 -0000
@@ -121,6 +121,9 @@ static VALUE rpi_sock_open(VALUE obj, VA
}
}
+#if PILOT_LINK_MAJOR >= 12
+ ret = pi_bind(sd, dev_str);
+#else
if (dev_usb) {
for (i=7; i>0; i--) {
ret = pi_bind(sd, (struct sockaddr*)&addr, sizeof(addr));
@@ -130,6 +133,7 @@ static VALUE rpi_sock_open(VALUE obj, VA
} else {
ret = pi_bind(sd, (struct sockaddr*)&addr, sizeof(addr));
}
+#endif
if (ret == -1) return Qnil;
return INT2FIX(sd);
@@ -260,6 +264,20 @@ static VALUE rdlp_CloseDB(VALUE obj, VAL
static VALUE rdlp_ReadAppBlock(VALUE obj, VALUE sd, VALUE db)
{
+#if PILOT_LINK_MAJOR >= 12
+ int len;
+ VALUE ret = Qnil;
+ pi_buffer_t *buffer = pi_buffer_new(DLP_BUF_SIZE); /* xxx need check */
+
+ len = dlp_ReadAppBlock(FIX2INT(sd), FIX2INT(db), 0, DLP_BUF_SIZE, buffer);
+
+ if (len > 0)
+ ret = str_new(buffer->data, len);
+
+ pi_buffer_free(buffer);
+
+ return ret;
+#else
int len;
unsigned char buffer[0xffff];
@@ -269,6 +287,7 @@ static VALUE rdlp_ReadAppBlock(VALUE obj
return Qnil;
else
return str_new(buffer, len);
+#endif
}
/****************************************************************/
@@ -284,18 +303,32 @@ static VALUE rdlp_ReadAppBlock(VALUE obj
static VALUE rdlp_ReadRecordByIndex(VALUE obj, VALUE sd, VALUE db, VALUE i)
{
- VALUE ary;
+ VALUE ary = Qnil;
int attr, category, len;
recordid_t id;
+#if PILOT_LINK_MAJOR >= 12
+ pi_buffer_t *buffer = pi_buffer_new(DLP_BUF_SIZE); /* xxx needed check */
+#else
unsigned char buffer[0xffff];
+#endif
- ary = ary_new();
+#if PILOT_LINK_MAJOR >= 12
+ len = dlp_ReadRecordByIndex(FIX2INT(sd), FIX2INT(db), FIX2INT(i),
+ buffer, &id, &attr, &category);
+#else
len = dlp_ReadRecordByIndex(FIX2INT(sd), FIX2INT(db), FIX2INT(i),
buffer, &id, 0, &attr, &category);
+#endif
- if (len <= 0) return Qnil;
+ if (len <= 0) goto out;
+ ary = ary_new();
+
+#if PILOT_LINK_MAJOR >= 12
+ dprintf(("id:%d atr:%d cat:%d bp:%d len:%d\n",id,attr,category,buffer->data,len));
+#else
dprintf(("id:%d atr:%d cat:%d bp:%d len:%d\n",id,attr,category,buffer,len));
+#endif
dprintf(("readrecordbyindex 0\n"));
ar_set1(ary, "i", id);
dprintf(("readrecordbyindex 1\n"));
@@ -303,32 +336,62 @@ static VALUE rdlp_ReadRecordByIndex(VALU
dprintf(("readrecordbyindex 2\n"));
ar_set1(ary, "i", category);
dprintf(("readrecordbyindex 3\n"));
+#if PILOT_LINK_MAJOR >= 12
+ ary_push(ary, str_new(buffer->data, len));
+#else
ary_push(ary, str_new(buffer, len));
+#endif
dprintf(("readrecordbyindex 4\n"));
+ out:
+#if PILOT_LINK_MAJOR >= 12
+ pi_buffer_free(buffer);
+#endif
return ary;
}
static VALUE rdlp_ReadRecordById(VALUE obj, VALUE sd, VALUE db, VALUE vid)
{
- VALUE ary;
+ VALUE ary = Qnil;
int attr, category, len;
int index;
+#if PILOT_LINK_MAJOR >= 12
+ pi_buffer_t *buffer = pi_buffer_new(DLP_BUF_SIZE);
+#else
unsigned char buffer[0xffff];
+#endif
recordid_t id = FIX2INT(vid);
- ary = ary_new();
+#if PILOT_LINK_MAJOR >= 12
+ len = dlp_ReadRecordById(FIX2INT(sd), FIX2INT(db), id,
+ buffer, &index, &attr, &category);
+#else
len = dlp_ReadRecordById(FIX2INT(sd), FIX2INT(db), id,
buffer, &index, 0, &attr, &category);
+#endif
+
+ if (len <= 0) goto out;
- if (len <= 0) return Qnil;
+ ary = ary_new();
+#if PILOT_LINK_MAJOR >= 12
+ dprintf(("id:%d atr:%d cat:%d bp:%d len:%d\n",id,attr,category,buffer->data,len));
+#else
dprintf(("id:%d atr:%d cat:%d bp:%d len:%d\n",id,attr,category,buffer,len));
+#endif
ar_set1(ary, "i", id);
ar_set1(ary, "i", attr);
ar_set1(ary, "i", category);
+#if PILOT_LINK_MAJOR >= 12
+ ary_push(ary, str_new(buffer->data, len));
+#else
ary_push(ary, str_new(buffer, len));
+#endif
+ out:
+#if PILOT_LINK_MAJOR >= 12
+ pi_buffer_free(buffer);
+#endif
return ary;
}
@@ -340,14 +403,22 @@ static VALUE rdlp_WriteRecord(VALUE obj,
{
recordid_t id, new_id;
int attr, category, ret, len;
+#if PILOT_LINK_MAJOR >= 12
+ pi_buffer_t *buf = pi_buffer_new(DLP_BUF_SIZE); /* xxx need check */
+#else
char buf[0xffff];
+#endif
char *ptr;
struct Appointment app;
int i;
VALUE a = ary_new();
+#if PILOT_LINK_MAJOR >= 12
+ memset(buf->data, 0, buf->allocated);
+#else
for (i = 0; i < 0xffff; i++)
buf[i] = '\0';
+#endif
ary_copy(a, ary);
ar_get1(a, "i", id);
@@ -359,15 +430,26 @@ static VALUE rdlp_WriteRecord(VALUE obj,
dprintf(("buf: %s\n", buf));
+#if PILOT_LINK_MAJOR >= 12
+ unpack_Appointment(&app, buf, datebook_v1);
+#else
unpack_Appointment(&app, buf, len);
+#endif
dprintf(("event: %d\n", app.event));
dprintf(("beg_year %d\n", app.begin.tm_year));
dprintf(("Subject: %s\n", app.description));
dprintf(("id: %d attr: %d cat: %d buf_len: %d\n",
id, attr, category, len));
+#if PILOT_LINK_MAJOR >= 12
+ ret = dlp_WriteRecord(FIX2INT(sd), FIX2INT(db), attr,
+ id, category, buf->data, len, &new_id);
+
+ pi_buffer_free(buf);
+#else
ret = dlp_WriteRecord(FIX2INT(sd), FIX2INT(db), attr,
id, category, buf, len, &new_id);
+#endif
if (ret < 0){
dprintf(("%s\n", dlp_strerror(ret)));
@@ -425,7 +507,12 @@ static VALUE rdlp_ResetSyncFlags(VALUE o
static VALUE rpack_Appointment(VALUE x, VALUE ary1)
{
struct Appointment app;
+#if PILOT_LINK_MAJOR >= 12
+ pi_buffer_t *buf = pi_buffer_new(DLP_BUF_SIZE); /* xxx need check */
+ VALUE ret;
+#else
char buf[0xffff];
+#endif
int len, i = 0;
VALUE ary = ary_new();
ary_copy(ary, ary1);
@@ -449,10 +536,20 @@ static VALUE rpack_Appointment(VALUE x,
ar_get1(ary, "s", app.description);
ar_get1(ary, "s", app.note);
+#if PILOT_LINK_MAJOR >= 12
+ len = pack_Appointment(&app, buf, datebook_v1);
+#else
len = pack_Appointment(&app, buf, sizeof(buf));
+#endif
dprintf(("pack_Appointment: length: %d\n", len));
free(app.exception);
+#if PILOT_LINK_MAJOR >= 12
+ ret = str_new(buf->data, len);
+ pi_buffer_free(buf);
+ return ret;
+#else
return str_new(buf, len);
+#endif
}
static VALUE runpack_Appointment(VALUE x, VALUE raw_str)
@@ -461,7 +558,15 @@ static VALUE runpack_Appointment(VALUE x
VALUE ary = ary_new();
Check_Type(raw_str, T_STRING);
+#if PILOT_LINK_MAJOR >= 12
+ pi_buffer_t *buf = pi_buffer_new(DLP_BUF_SIZE); /* xxx need check */
+ unpack_Appointment(&app, buf, datebook_v1);
+ memcpy(RSTRING(raw_str)->ptr, buf->data, buf->used);
+ RSTRING(raw_str)->len = buf->used;
+ pi_buffer_free(buf);
+#else
unpack_Appointment(&app, RSTRING(raw_str)->ptr, RSTRING(raw_str)->len);
+#endif
ar_set1(ary, "b", app.event);
dprintf(("runpack_Appointment: 0\n"));
@@ -491,6 +596,46 @@ static VALUE runpack_Appointment(VALUE x
return ary;
}
+/* XXX koie */
+static VALUE rpack_AppointmentAppInfo(VALUE o, VALUE ary1)
+{
+ struct AppointmentAppInfo ai;
+ unsigned char buf[0xffff];
+ int len;
+ VALUE ary = ary_new();
+ ary_copy(ary, ary1);
+
+ ar_get2(ary, "b", ai.category.renamed, 16);
+ ar_get2(ary, "c", ai.category.ID, 16);
+ ar_get1(ary, "c", ai.category.lastUniqueID);
+
+ ar_get1(ary, "i", ai.startOfWeek);
+
+ len = pack_AppointmentAppInfo(&ai, buf, sizeof(buf));
+ dprintf(("pack_AppointmentAppInfo: length: %d\n", len));
+ return str_new(buf, len);
+}
+
+
+/* XXX koie */
+static VALUE runpack_AppointmentAppInfo(VALUE o, VALUE raw_str)
+{
+ struct AppointmentAppInfo ai;
+ VALUE ary = ary_new();
+
+ Check_Type(raw_str, T_STRING);
+ unpack_AppointmentAppInfo(&ai, RSTRING(raw_str)->ptr, RSTRING(raw_str)->len);
+
+ ar_set2(ary, "b", ai.category.renamed, 16);
+ ar_set2(ary, "s16", ai.category.name, 16);
+ ar_set2(ary, "c", ai.category.ID, 16);
+ ar_set1(ary, "c", ai.category.lastUniqueID);
+
+ ar_set1(ary, "i", ai.startOfWeek);
+
+ return ary;
+}
+
/****************************************************************/
/********* For Address Records **********************************/
/****************************************************************/
@@ -498,7 +643,12 @@ static VALUE runpack_Appointment(VALUE x
static VALUE rpack_Address(VALUE x, VALUE ary1)
{
struct Address add;
+#if PILOT_LINK_MAJOR >= 12
+ pi_buffer_t *buf = pi_buffer_new(DLP_BUF_SIZE); /* xxx need check */
+ VALUE ret;
+#else
unsigned char buf[0xffff];
+#endif
int len;
VALUE ary = ary_new();
@@ -508,8 +658,15 @@ static VALUE rpack_Address(VALUE x, VALU
ar_get1(ary, "i", add.showPhone);
ar_get2(ary, "s", add.entry, 19);
+#if PILOT_LINK_MAJOR >= 12
+ len = pack_Address(&add, buf, address_v1);
+ ret = str_new(buf->data, len);
+ pi_buffer_free(buf);
+ return ret;
+#else
len = pack_Address(&add, buf, sizeof(buf));
return str_new(buf, len);
+#endif
}
static VALUE runpack_Address(VALUE x, VALUE raw_str)
@@ -518,7 +675,15 @@ static VALUE runpack_Address(VALUE x, VA
VALUE ary = ary_new();
Check_Type(raw_str, T_STRING);
+#if PILOT_LINK_MAJOR >= 12
+ pi_buffer_t *buf = pi_buffer_new(DLP_BUF_SIZE); /* xxx need check */
+ unpack_Address(&add, buf, address_v1);
+ memcpy(RSTRING(raw_str)->ptr, buf->data, buf->used);
+ RSTRING(raw_str)->len = buf->used;
+ pi_buffer_free(buf);
+#else
unpack_Address(&add, RSTRING(raw_str)->ptr, RSTRING(raw_str)->len);
+#endif
ar_set2(ary, "i", add.phoneLabel, 5);
ar_set1(ary, "i", add.showPhone);
@@ -541,6 +706,7 @@ static VALUE rpack_AddressAppInfo(VALUE
ar_get1(ary, "c", ai.category.lastUniqueID);
ar_get2(ary, "s16", ai.labels, 22);
+ /* XXX koie ar_get2(ary, "b", ai.labelRenamed, 22) */
ar_get2(ary, "s16", ai.phoneLabels, 8);
ar_get1(ary, "i", ai.country);
ar_get1(ary, "b", ai.sortByCompany);
@@ -599,14 +765,18 @@ static VALUE rpi_file_open(int argc, VAL
static VALUE rpi_file_get_app_info(VALUE obj)
{
struct pi_file *pf;
- int len;
+ size_t len;
char *ptr;
Data_Get_Struct(obj, struct pi_file, pf);
+#if PILOT_LINK_MAJOR >= 12
+ pi_file_get_app_info(pf, (void*)&ptr, &len);
+#else
if (pi_file_get_app_info(pf, (void*)&ptr, &len) < 0){
Fail("pi_file_get_app_info");
}
+#endif
return str_new(ptr, len);
}
@@ -614,7 +784,11 @@ static VALUE rpi_file_read_record(VALUE
{
struct pi_file *pf;
int len, attr, category;
+#if PILOT_LINK_MAJOR >= 12
+ recordid_t id;
+#else
pi_uid_t id;
+#endif
void *ptr;
VALUE ary = ary_new();
@@ -684,6 +858,9 @@ void Init_mhc_pilib()
/* for datebook */
mfunc(mPiLib, "pack_Appointment", rpack_Appointment, 1);
mfunc(mPiLib, "unpack_Appointment", runpack_Appointment, 1);
+ /* XXX koie */
+ mfunc(mPiLib, "pack_AppointmentAppInfo", rpack_AppointmentAppInfo, 1);
+ mfunc(mPiLib, "unpack_AppointmentAppInfo", runpack_AppointmentAppInfo, 1);
/* for address */
mfunc(mPiLib, "pack_Address", rpack_Address, 1);