[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-27
From: |
Daniele Forsi |
Subject: |
[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-271-gdba2bd2 |
Date: |
Sun, 10 Jul 2011 12:08:34 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "libgnokii and core programs".
The branch, master has been updated
via dba2bd21c5bde1578cc713f759bb20271ca2fa4f (commit)
from dbe94675e873fa142938970f8caac4662308c04f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=dba2bd21c5bde1578cc713f759bb20271ca2fa4f
commit dba2bd21c5bde1578cc713f759bb20271ca2fa4f
Author: Daniele Forsi <address@hidden>
Date: Fri Jul 8 23:00:53 2011 +0200
Fix reading empty fields from vCards
sscanf() would stop when an empty field is encountered, like in the
case of addresses when the PO Box part is not present:
ADR;TYPE=HOME,PREF:;Ext Add;Street;Town;State;ZIP;Country
diff --git a/ChangeLog b/ChangeLog
index 734811e..66e3432 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,8 @@
o fix gn_sms_send() so the message could be resent (PaweÅ Kot)
o make the vcard reader handle also BDAY, TITLE, NICKNAME, ORG,
X-SIP;POC and X-WV-ID (Daniele Forsi)
+ o make the vcard reader handle also empty fields in N and in
+ ADR (like in addresses without a PO Box) (Daniele Forsi)
* nk6510 driver updates
o fix calendar handling issues (few off-by-ones) (PaweÅ Kot)
o implement deletecalendarnote for series40 3rd+ Ed (PaweÅ Kot)
diff --git a/common/vcard.c b/common/vcard.c
index 3192bb5..76c4246 100644
--- a/common/vcard.c
+++ b/common/vcard.c
@@ -43,6 +43,42 @@ typedef struct {
unsigned int len;
} vcard_string;
+/*
+ Copies at most @maxcount strings, each of @maxsize length to the given
+ pointers from a vCard property, such as
+ ADR;TYPE=HOME,PREF:PO Box;Ext Add;Street;Town;State;ZIP;Country
+
+ Returns: the number of strings copied
+ */
+int copy_fields(const char *str, int maxcount, size_t maxsize, ...)
+{
+ va_list ap;
+ int count;
+ size_t size;
+ char *dest;
+
+ va_start(ap, maxsize);
+
+ for (count = maxcount; count && *str; count--) {
+ dest = va_arg(ap, char *);
+
+ size = maxsize;
+ while (size && *str) {
+ if (*str == ';') {
+ str++;
+ break;
+ }
+ *dest++ = *str++;
+ size--;
+ }
+ *dest = '\0';
+ }
+
+ va_end(ap);
+
+ return maxcount - count;
+}
+
/* Write a string to a file doing folding when needed (see RFC 2425) */
static void vcard_append_printf(vcard_string *str, const char *fmt, ...)
{
@@ -372,9 +408,7 @@ GNOKII_API int gn_vcardstr2phonebook(const char *vcard,
gn_phonebook_entry *entr
buf[--line_len] = '\0';
if (BEGINS("N:")) {
- /* 64 is the value of GN_PHONEBOOK_PERSON_MAX_LENGTH */
- /* FIXME sscanf() doesn't accept empty fields */
- if (0 < sscanf(buf +2 ,
"%64[^;];%64[^;];%64[^;];%64[^;];%64[^;]\n",
+ if (0 < copy_fields(buf +2 , 5,
GN_PHONEBOOK_PERSON_MAX_LENGTH,
entry->person.family_name,
entry->person.given_name,
entry->person.additional_names,
@@ -401,9 +435,7 @@ GNOKII_API int gn_vcardstr2phonebook(const char *vcard,
gn_phonebook_entry *entr
STORE("TEL;TYPE=PREF:", entry->number);
if (BEGINS("ADR;TYPE=HOME,PREF:")) {
- /* 64 is the value of GN_PHONEBOOK_ADDRESS_MAX_LENGTH */
- /* FIXME sscanf() doesn't accept empty fields */
- if (0 < sscanf(buf + 19,
"%64[^;];%64[^;];%64[^;];%64[^;];%64[^;];%64[^;];%64[^;]\n",
+ if (0 < copy_fields(buf + 19, 7,
GN_PHONEBOOK_ADDRESS_MAX_LENGTH,
entry->address.post_office_box,
entry->address.extended_address,
entry->address.street,
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 2 ++
common/vcard.c | 44 ++++++++++++++++++++++++++++++++++++++------
2 files changed, 40 insertions(+), 6 deletions(-)
hooks/post-receive
--
libgnokii and core programs
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-271-gdba2bd2,
Daniele Forsi <=