Hi,
I've never had this trouble before with this but in this situation ??
it's twilight zone time --
so this code gets SMTP response
rfp is static FILE *rfp; that's the read end of an AF_INET socket
it's a local connection to avmailgate on port 25 that relays to exim on port 825 or something
(can't imagine how that makes a difference)
Code:
int mySMTP::get_response()
{
char buf[BUFSIZ];
char nCode[3]={0};
while (fgets(buf, sizeof(buf), rfp)) {
buf[strlen(buf)-1] = 0;
printf("%s --> %s\n", host, buf);
if (!isdigit(buf[0]) || buf[0] > '3') {
return 1;
}
if (buf[4] != '-')
break;
}
strncpy(nCode, buf, 3);
return (atoi(nCode));
}
ok with this server buf is
220 lisa.sourcery.net AvMailGate-2.0.2-2
the entire line from the printf is
0x42ce2904localhost --> 220 lisa.sourcery.net AvMailGate-2.0.2-2
somehow above code is returning
2201
last digit is not an "L" (i copy and paste here to make sure)
i haven't tested this alot becaus it always works
i have no idea where the 1 is comming from ?????????
need c gurus help cause i'm not good with c char arrays