S
Sean Bartholomew
im trying to parse my email file located in my system library on my
mac osx.
i have a form online that, when filled and submitted, is sent to my
email address.
i need to parse the fields that were filled out ignoring all the ip
and complicated stuff around it.
for eg. im trying to at least get the first block of text that ONLY
includes the fields and their values.
char *tempBuf;
ofstream testText ("/Volumes/iBook Docs/Documents/testText.txt");
char *start = strstr(buffer, "First Name=");
if (start != NULL)
{
strcpy(tempBuf, start);
char *stop = strstr(buffer, "Submit=");
if (stop != NULL)
{
tempBuf[stop - start] = '\0';
testText << tempBuf;
testText.close();
}
}
it DOES NOT WORK.
also, "stop - start" works out to a negative value, what gives???
"testText << start"...."testText << stop"....WORKS (prints a file
beginning from those exact positions) only if i comment out the
---"tempBuf[stop - start] = '\0';"---"
EVEN if i turn it around to... "start-stop"... so that the value is
positive.
once i do ANYTHING with "start" or "stop", cast them and copy them to
integers, or other char variables, ANYTHING, ..."testText <<
start"...PRINTS OUT AN EMPTY FILE.
but i need to find out the length between start and stop so that i
could insert a null character for the 1st record. once thats done i
could use strtok to parse the fields, which happen to be RETURN
delimited, but thats fine. i could deal with that. another thing
is...strstr DOESNT work with "\r".
and ANOTHER thing is, if i insert ...
testText << buffer;....
just before the ...testText << tempBuf;...it prints out a file
beginning with the start address... ie. from "First Name=", NOT FROM
THE BEGINNING OF THE EMAIL. so it means that buffer is being messed
with EVEN though i copied it to tempBuf and didnt touch it afterward.
please someone, tell me whats going on, my hair is long and its going
to be very short, VERY soon.
mac osx.
i have a form online that, when filled and submitted, is sent to my
email address.
i need to parse the fields that were filled out ignoring all the ip
and complicated stuff around it.
for eg. im trying to at least get the first block of text that ONLY
includes the fields and their values.
char *tempBuf;
ofstream testText ("/Volumes/iBook Docs/Documents/testText.txt");
char *start = strstr(buffer, "First Name=");
if (start != NULL)
{
strcpy(tempBuf, start);
char *stop = strstr(buffer, "Submit=");
if (stop != NULL)
{
tempBuf[stop - start] = '\0';
testText << tempBuf;
testText.close();
}
}
it DOES NOT WORK.
also, "stop - start" works out to a negative value, what gives???
"testText << start"...."testText << stop"....WORKS (prints a file
beginning from those exact positions) only if i comment out the
---"tempBuf[stop - start] = '\0';"---"
EVEN if i turn it around to... "start-stop"... so that the value is
positive.
once i do ANYTHING with "start" or "stop", cast them and copy them to
integers, or other char variables, ANYTHING, ..."testText <<
start"...PRINTS OUT AN EMPTY FILE.
but i need to find out the length between start and stop so that i
could insert a null character for the 1st record. once thats done i
could use strtok to parse the fields, which happen to be RETURN
delimited, but thats fine. i could deal with that. another thing
is...strstr DOESNT work with "\r".
and ANOTHER thing is, if i insert ...
testText << buffer;....
just before the ...testText << tempBuf;...it prints out a file
beginning with the start address... ie. from "First Name=", NOT FROM
THE BEGINNING OF THE EMAIL. so it means that buffer is being messed
with EVEN though i copied it to tempBuf and didnt touch it afterward.
please someone, tell me whats going on, my hair is long and its going
to be very short, VERY soon.