From: Alex Blekhman on 9 Feb 2010 04:35 "Rayne" wrote: > Thank you for all the suggestions. > > I'm trying to use the A2T macro for my pcap_loop callback > function "got_packet". > > So I have > > void got_packet(u_char *cuser, const struct pcap_pkthdr *header, > const > u_char *cpacket) > { > _TUCHAR *user, *packet; > user = A2T(cuser); > packet = A2T(cpacket); > ... > } Well, it seems you've ignored my other post even though it describes your case. I looked up the `pcap_loop' function and it seems that you don't need any conversions at all. The type `u_char' is used as a substitute for a byte, i.e. actual data is binary. Alex
From: Rayne on 10 Feb 2010 05:22 On Feb 9, 5:35 pm, "Alex Blekhman" <tkfx.REM...(a)yahoo.com> wrote: > "Rayne" wrote: > > Thank you for all the suggestions. > > > I'm trying to use the A2T macro for my pcap_loop callback > > function "got_packet". > > > So I have > > > void got_packet(u_char *cuser, const struct pcap_pkthdr *header, > > const > > u_char *cpacket) > > { > > _TUCHAR *user, *packet; > > user = A2T(cuser); > > packet = A2T(cpacket); > > ... > > } > > Well, it seems you've ignored my other post even though it > describes your case. I looked up the `pcap_loop' function and it > seems that you don't need any conversions at all. The type > `u_char' is used as a substitute for a byte, i.e. actual data is > binary. > > Alex Sorry, I must have missed your post. So after reading all the suggestions, I think that my initial approach is wrong, in that I simply tried to convert all char and char * to TCHAR. So under what circumstances would I need the conversion, besides when using string functions like strlen and strcat, APIs that have the A/W versions and filenames longer than MAX_PATH characters? Thank you. Regards, Rayne
From: Alex Blekhman on 10 Feb 2010 06:05 "Rayne" wrote: > So under what circumstances would I need the conversion, besides > when using string functions like strlen and strcat, APIs that > have the A/W versions and filenames longer than MAX_PATH > characters? You need the conversion for textual data only which you're going to interpret and process as a text. For example, your program accepts both Unicode and ANSI textual files as an input. But you don't want to duplicate processing code to deal separately with Unicode and ANSI files. So, naturally you convert all input to Unicode first (if necessary), then you process the text as Unicode all the way along. However, in C language for ages people use `char' as a synonym to byte to store binary data. So, not every buffer of char's requires conversion. You need to know your data. Alex
First
|
Prev
|
Pages: 1 2 3 4 Prev: filename string manipulation Next: Making userdefined messages like WM_PAINT or WM_QUIT |