[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Newbie question
From: |
Christian Rishoej |
Subject: |
Newbie question |
Date: |
16 May 2002 14:13:49 +0200 |
Hi,
Here's a quick question for you C gurus : )
I am using libgnokii in an application of mine.
When I call
error = SM_Functions(GOP_ReadPhonebook, &data, state);
...i get a segfault. GDB blames the call
dest[i] = DecodeWithUnicodeAlphabet(wc);
...in DecodeWithUnicodeAlphabet in common/gsm-encoding.c:
Connecting
Serial device: opening device /dev/ttyS1
Nokia 8310 ece50000
Getting model...
Message sent: 0x1b / 0x0006
00 01 00 07 01 00 |
Message received: 0x1b / 0x002e
01 2b 00 08 00 01 58 29 00 22 56 20 30 35 2e 30 | + X) "V 05.0
36 0a 30 37 2d 30 33 2d 30 32 0a 4e 48 4d 2d 37 | 6 07-03-02 NHM-7
0a 28 63 29 20 4e 4d 50 2e 0a 41 00 00 00 | (c) NMP. A
Received message type 1b
Received model NHM-7
Identifying...
Message sent: 0x1b / 0x0005
00 01 00 00 41 | A
Message sent: 0x1b / 0x0006
00 01 00 07 01 00 |
Message received: 0x1b / 0x001a
01 2b 00 01 00 01 41 14 00 10 33 35 30 36 30 34 | + A 350604
33 30 32 38 35 37 38 35 34 00 | 302857854
Received message type 1b
Received imei 350604302857854
Message received: 0x1b / 0x002e
01 2b 00 08 00 01 58 29 00 22 56 20 30 35 2e 30 | + X) "V 05.0
36 0a 30 37 2d 30 33 2d 30 32 0a 4e 48 4d 2d 37 | 6 07-03-02 NHM-7
0a 28 63 29 20 4e 4d 50 2e 0a 41 00 00 00 | (c) NMP. A
Received message type 1b
Received model NHM-7
Received revision V 05.06
["Nokia", "NHM-7", "V 05.06", "350604302857854"]
Reading phonebook location (6)
Message sent: 0x03 / 0x0014
00 01 00 07 04 01 00 01 02 05 00 00 00 00 00 06 |
00 00 25 40 | %@
Message received: 0x03 / 0x0126
01 45 00 08 00 01 01 00 00 10 00 05 00 07 00 00 | E
00 00 00 00 00 06 07 00 00 28 01 22 00 43 00 68 | ( " C h
00 72 00 69 00 73 00 74 00 69 00 61 00 6e 00 20 | r i s t i a n
00 52 00 69 00 73 00 68 00 f8 00 6a 00 00 0b 00 | R i s h j
00 24 02 03 00 00 00 18 00 2b 00 34 00 35 00 32 | $ + 4 5 2
00 36 00 32 00 33 00 35 00 33 00 34 00 36 00 00 | 6 2 3 5 3 4 6
00 00 0b 00 00 24 03 01 00 00 00 18 00 2b 00 36 | $ + 6
00 36 00 39 00 37 00 37 00 38 00 37 00 33 00 37 | 6 9 7 7 8 7 3 7
00 36 00 00 00 00 08 00 00 24 04 1e 00 63 00 68 | 6 $ c h
00 72 00 72 00 69 00 73 00 40 00 6d 00 61 00 69 | r r i s @ m a i
00 6c 00 2e 00 64 00 6b 00 00 09 00 00 58 05 50 | l . d k X P
00 50 00 61 00 72 00 61 00 73 00 6f 00 6c 00 68 | P a r a s o l h
00 61 00 74 00 74 00 65 00 6e 00 20 00 35 00 0a | a t t e n 5
00 44 00 4b 00 2d 00 39 00 32 00 36 00 30 00 20 | D K - 9 2 6 0
00 47 00 69 00 73 00 74 00 72 00 75 00 70 00 0a | G i s t r u p
00 44 00 65 00 6e 00 6d 00 61 00 72 00 6b 00 00 | D e n m a r k
00 00 0a 00 00 24 06 1c 00 47 00 50 00 47 00 3a | $ G P G :
00 20 00 64 00 31 00 65 00 65 00 64 00 32 00 64 | d 1 e e d 2 d
00 66 00 00 00 00 | f
Received message type 03
Received phonebook info
Blockstart: 7
(no debugging symbols found)...(no debugging symbols found)...(no
debugging symbols found)...
Program received signal SIGSEGV, Segmentation fault.
0x4028f563 in DecodeUnicode (
dest=0x40054f58
"\213F\004\205Àu\002\213\006\203Äøÿv\024Pè3ýÿÿ\211ø\215eè[^_ÉÃ\220U\211å\203ì\fWVSè",
src=0x402d38b4 "", len=17) at gsm-encoding.c:262
262 dest[i] = DecodeWithUnicodeAlphabet(wc);
(gdb)
DecodeWithUnicodeAlphabet is:
static unsigned char DecodeWithUnicodeAlphabet(wchar_t value)
{
unsigned char retval;
if (wctomb(&retval, value) == -1) return '?';
else return retval;
}
Now, I'm not sure this is where it fails, but it seems to me that
retval should have room for at least MB_CUR_MAX bytes, not just a
single, according to man 3 wctomb:
If s is not NULL, the wctomb function converts the wide
character wc to its multibyte representation and stores it
at the beginning of the character array pointed to by s.
It updates the shift state, which is stored in a static
anonymous variable only known to the wctomb function, and
returns the length of said multibyte representation, i.e.
the number of bytes written at s.
Or maybe it's just me screwing up somewhere?
Christian
- Newbie question,
Christian Rishoej <=