Re: Parsing a Section of Binary String Data!
- From: Pedro Graca <hexkid@xxxxxxxxxxx>
- Date: 22 Mar 2006 11:17:02 GMT
zoltan wrote:
Hi,
The scenario is like this :
struct ns_rr {
const u_char* rdata;
};
What is u_char?
I'll assume it's a struct with (possibly among others) these members:
The rdata field contains some fields such as :
char * flags;
char * services;
char * regexp;
char * replacement;
I want to parse the rdata section and obtain the individual string
fields as shown above. Can anyone suggest an efficient method? Are
these strings terminiated by '\0' within the rdata section?
I have absolutely no idea. If they are, you can use standard string
handling functions to mess with them; if they are not you should take
extra care when dealing with those members.
Here's a short program that tries to put together the information you
provided and uses the individual members of `rdata`.
#include <stdio.h>
struct u_char { /* bad choice of name */
char * flags;
char * services;
char * regexp;
char * replacement;
};
struct ns_rr {
const struct u_char * rdata;
};
int main(void) {
struct u_char dummy = {"flags", "services", "regexp", "replacement"};
struct ns_rr x;
x.rdata = &dummy;
printf("x.rdata->flags is '%s'.\n", x.rdata->flags);
printf("x.rdata->services is '%s'.\n", x.rdata->services);
printf("x.rdata->regexp is '%s'.\n", x.rdata->regexp);
printf("x.rdata->replacement is '%s'.\n", x.rdata->replacement);
return 0;
}
--
If you're posting through Google read <http://cfaj.freeshell.org/google>
.
- Follow-Ups:
- Re: Parsing a Section of Binary String Data!
- From: zoltan
- Re: Parsing a Section of Binary String Data!
- References:
- Parsing a Section of Binary String Data!
- From: zoltan
- Parsing a Section of Binary String Data!
- Prev by Date: Re: ip address
- Next by Date: Re: array subscript type cannot be `char`?
- Previous by thread: Re: Parsing a Section of Binary String Data!
- Next by thread: Re: Parsing a Section of Binary String Data!
- Index(es):
Relevant Pages
|
|