Logo Search packages:      
Sourcecode: nbsmtp version File versions  Download package

int smtp_read ( servinfo_t serverinfo,
char *  response 
)

Gets a line from a socket an returns its first digit ( borrowed from sSMTP ).

Parameters:
[in] serverinfo A pointer to a servinfo_t struct with the socket information
[out] response A pointer where we will store the line read
Returns:
The first digit of the line we read
See also:
fd_gets()

Definition at line 80 of file smtp.c.

References fd_gets(), log_msg(), and smtp_stored_message.

Referenced by nbsmtp_auth(), nbsmtp_data(), and smtp_okay().

{
      char *p;

      do
      {
            if (fd_gets(response,BUF_SIZE,serverinfo)==NULL)
            {
                  return 0;
            }

            log_msg(LOG_DEBUG,"[<-] %s",response);
      } while (response[3]=='-');


      /* Free last message if neccesary */
      if (smtp_stored_message!=NULL)
      {
            free(smtp_stored_message);
      }


      /* Find the first space (numbers finish there) */
      p = strchr(response,' ');

      /* Avoid possible missbehavior */
      if (p != NULL)
      {
            p++;

            smtp_stored_message = (char *)strdup(p);
      }
      else
      {
            smtp_stored_message = (char *)strdup("");
      }

      return(atoi(response)/100); /* response[0] ? */
}


Generated by  Doxygen 1.6.0   Back to index