A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/ncbi__sendmail_8c_source.html below:

NCBI C++ ToolKit: src/connect/ncbi_sendmail.c Source File

42 #define NCBI_USE_ERRCODE_X Connect_SMTP 46 # define SENDMAIL_LOCALTIME_MT_SAFE 1 49 #define MX_SENDMAIL_MAGIC 0xBA8ADEDA 50 #define MX_CRLF "\r\n" 52 #define SMTP_READERR -1 53 #define SMTP_READTMO -2 54 #define SMTP_RESPERR -3 55 #define SMTP_NOCODE -4 56 #define SMTP_BADCODE -5 57 #define SMTP_BADRESP -6 74  assert

(response && max_response_len);

82  if

(m == 3 && status == eIO_Closed)

99  if

(errno ||

code

<= 0 || e !=

buf

+ 3)

103  if

(

n

> max_response_len)

104  n

= max_response_len;

105

memcpy(response,

buf

,

n

);

106  if

(

n

< max_response_len)

107

response[

n

++] =

' '

;

109

}

else if

(

code

!= atoi(

buf

))

117  if

(status == eIO_Closed) {

118  if

(

n

< max_response_len)

119

response[

n

++] =

'\n'

;

125  if

(*

buf

!=

'\r'

&&

n

< max_response_len)

126

response[

n

++] = *

buf

;

128

}

while

(*

buf

!=

'\n'

);

133

response[

n

- 1] =

'\0'

;

134  else if

(

n

< max_response_len)

135

response[

n

] =

' '

;

148  char

*

buf

,

size_t

buf_size,

153  const char

* message = 0;

156

message =

"Read error"

;

159

message =

"Read timed out"

;

162

message =

"Cannot read response prefix"

;

165

message =

"No response code detected"

;

168

message =

"Response code mismatch"

;

171

message =

"Malformed response"

;

174

message =

"Unknown error"

;

180

}

else if

(!

code

|| c ==

code

|| (alt_code && c == alt_code))

208  if

(!(at = strchr(from,

'@'

))) {

217  len

= (size_t)(at - from);

219  size_t tmp

=

len

+ strlen(at);

231  if

((

len

= strlen(at)) <

sizeof

(x_buf)) {

232

memcpy(x_buf, at,

len

+ 1);

260  if

((!(host = getenv(

"HOSTNAME"

)) && !(host = getenv(

"HOST"

)))

261

|| (

len

= strlen(host)) >=

size

) {

269

}

else if

(1 < (

len

= strlen(at)) &&

len

<

size

)

270

memcpy(

buf

, at,

len

+ 1);

294

|| !(port = (

unsigned int

) atoi(

buf

)) || port > 65535) {

299 #if defined(NCBI_OS_UNIX) && !defined(NCBI_OS_CYGWIN) 300

strcpy(

buf

,

"localhost"

);

302

strcpy(

buf

,

"mailgw"

);

323  info

->body_size = 0;

327  info

->mx_options = 0;

346 #define SENDMAIL_RETURN(subcode, reason) \ 352  CORE_LOGF_X(subcode, eLOG_Error, ("[SendMail] %s"

, reason)); \

354

if (info->mx_options & fSendMail_ExtendedErrInfo) { \

355

char* retval = strdup(reason); \

356

return retval ? retval : ""; \

363 #define SENDMAIL_RETURN2(subcode, reason, explanation) \ 369  CORE_LOGF_X(subcode, eLOG_Error, \ 370  ("[SendMail] %s: %s"

, reason, explanation)); \

372

if (info->mx_options & fSendMail_ExtendedErrInfo) { \

373

size_t lenr = strlen(reason); \

374

size_t lene = strlen(explanation) + 1; \

375

char* retval = (char*) malloc(lene + 2 + lenr); \

378

memcpy(retval, reason, lenr); \

379

retval[lenr++] = ':'; \

380

retval[lenr++] = ' '; \

381

memcpy(retval + lenr, explanation, lene); \

391  char buf

[],

size_t

buf_size,

393  const char

write_error[],

394  const char

proto_error[],

398  while

((c = *to++) !=

'\0'

) {

401  if

(

isspace

((

unsigned char

) c))

403  while

(k < buf_size) {

407

}

else if

(c ==

'"'

|| c ==

'<'

) {

408

quote = c ==

'<'

?

'>'

: c;

409

}

else if

(c ==

','

)

411  buf

[k++] = c ==

'\t'

?

' '

: c;

414  if

(

isspace

((

unsigned char

) c)) {

415  while

(

isspace

((

unsigned char

)(*to)))

424

(

"[SendMail] Unbalanced delimiters in" 425  " recipient %s for %s: \"%c\" expected"

,

446  const char

* at, *dot;

447  size_t len

= *

info

->from ? strlen(

info

->from) : 0;

451  if

(!(at = (

const char

*) memchr(

info

->from,

'@'

,

len

))

452

|| at ==

info

->from +

len

- 1) {

455  if

(!(dot = (

const char

*) memchr(at + 1,

'.'

,

456  len

- (

size_t

)(at -

info

->from) - 1))

457

|| dot == at + 1 || dot ==

info

->from +

len

- 1) {

458  return

(

size_t

)(at -

info

->from);

464 #define SENDMAIL_SENDRCPT(what, list, buffer) \ 465  s_SendRcpt(sock, list, buffer, sizeof(buffer), what, \ 466  "Write error in RCPT ("

what ") command", \

467

"Protocol error in RCPT (" what ") command", \

470 #define SENDMAIL_READ_RESPONSE(code, buffer) \ 471  s_SockReadResponse(sock, code, 0, buffer, sizeof(buffer), \ 472  info->mx_options & fSendMail_ExtendedErrInfo) 480  static const STimeout

zero = {0, 0};

490  SENDMAIL_RETURN

(6,

"SSendMailInfo inited improperly: Invalid magic"

);

495  SENDMAIL_RETURN

(7,

"At least one message recipient must be specified"

);

501

&

info

->mx_timeout, &sock,

503

sprintf(

buffer

,

"%.512s:%hu (%s)"

,

info

->mx_host,

info

->mx_port,

564  static const char

* kMonth[] = {

"Jan"

,

"Feb"

,

"Mar"

,

"Apr"

,

565  "May"

,

"Jun"

,

"Jul"

,

"Aug"

,

566  "Sep"

,

"Oct"

,

"Nov"

,

"Dec"

};

568  static const char

kDateFmt[] =

"%d %%s %Y %H:%M:%S %z" MX_CRLF

;

569

time_t now = time(0);

572 #if defined(NCBI_OS_SOLARIS) 574  tmp

= localtime(&now);

578 # ifdef HAVE_LOCALTIME_R 579

localtime_r(&now,

tmp

);

581 # ifndef SENDMAIL_LOCALTIME_MT_SAFE 584

tm = *localtime(&now);

585 # ifndef SENDMAIL_LOCALTIME_MT_SAFE 590  if

(strftime(datefmt,

sizeof

(datefmt), kDateFmt,

tmp

)) {

591

sprintf(

buffer

, datefmt, kMonth[

tmp

->tm_mon]);

628  "[SendMail] Subject ignored in as-is messages"

);

631  if

(!

s_SockWrite

(sock,

"X-Mailer: CORE_SendMail (NCBI " 644  if

(

info

->header && *

info

->header) {

645  size_t n

= 0, m = strlen(

info

->header);

652  if

(

info

->header[

n

] ==

'\n'

) {

657  if

(

info

->header[

n

] !=

'\r'

||

info

->header[

n

+1] !=

'\n'

)

669  const char

*

error

=

"Custom header write error"

;

674  error

=

"Spurious response while writing custom header"

;

683  size_t n

= 0, m =

info

->body_size ?

info

->body_size : strlen(body);

694  if

(body[

n

] ==

'\n'

) {

699  if

(body[

n

] !=

'\r'

|| (

n

+1 < m && body[

n

+1] !=

'\n'

)){

700  if

(body[

n

] ==

'.'

&& (newline || !

n

)) {

716  const char

*

error

=

"Message body write error"

;

721  error

=

"Spurious response while writing message body"

;

745 #undef SENDMAIL_READ_RESPONSE 746 #undef SENDMAIL_SENDRCPT 747 #undef SENDMAIL_RETURN2 748 #undef SENDMAIL_RETURN

const char * CORE_SendMailEx(const char *to, const char *subject, const char *body, const SSendMailInfo *uinfo)

Send a message as in CORE_SendMail() but by explicitly specifying all additional parameters of the me...

SSendMailInfo * SendMailInfo_InitEx(SSendMailInfo *info, const char *from, ECORE_Username user)

Initialize SSendMailInfo structure, setting: 'cc', 'bcc', 'header' to NULL (means no recipients/addit...

#define SendMailInfo_Init(i)

const char * CORE_SendMail(const char *to, const char *subject, const char *body)

Send a simple message to recipient(s) defined in 'to', and having: 'subject', which may be empty (bot...

@ fSendMail_NoMxHeader

Don't add standard mail header, just use what user provided.

@ fSendMail_ExtendedErrInfo

Return extended error info that must be free()'d by caller.

@ fSendMail_LogOn

see: fSOCK_LogOn

@ fSendMail_StripNonFQDNHost

Strip host part off the "from" field if it does not look like an FQDN (i.e.

@ fSendMail_Old822Headers

Form "Date:" and "From:" hdrs (usually they are defaulted)

EIO_Status SOCK_SetTimeout(SOCK sock, EIO_Event event, const STimeout *timeout)

Specify timeout for the connection I/O (see SOCK_[Read|Write|Close]()).

void SOCK_DisableOSSendDelay(SOCK sock, int on_off)

Control OS-defined send strategy by disabling/enabling the TCP Nagle algorithm (which is on by defaul...

EIO_Status SOCK_Close(SOCK sock)

Close the SOCK handle, and destroy all relevant internal data.

const char * SOCK_gethostbyaddr(unsigned int addr, char *buf, size_t buflen)

Same as SOCK_gethostbyaddrEx(,,<current API data logging>)

EIO_Status SOCK_Read(SOCK sock, void *buf, size_t size, size_t *n_read, EIO_ReadMethod how)

Read/peek up to "size" bytes from "sock" to a buffer pointed to by "buf".

int SOCK_gethostname(char *name, size_t namelen)

Same as SOCK_gethostnameEx(,,<current API data logging>)

void SOCK_SetCork(SOCK sock, int on_off)

Control OS-defined send strategy by disabling/enabling the TCP layer to send incomplete network frame...

EIO_Status SOCK_Wait(SOCK sock, EIO_Event event, const STimeout *timeout)

Block on the socket until either the specified "event" is available or "timeout" expires (if "timeout...

EIO_Status SOCK_CreateEx(const char *host, unsigned short port, const STimeout *timeout, SOCK *sock, const void *data, size_t size, TSOCK_Flags flags)

[CLIENT-side] Connect client to another(server-side, listening) socket (socket() + connect() [+ selec...

EIO_Status SOCK_Write(SOCK sock, const void *data, size_t size, size_t *n_written, EIO_WriteMethod how)

Write "size" bytes of "data" to "sock".

unsigned int TSOCK_Flags

bitwise "OR" of ESOCK_Flags

ECORE_Username

Select which username is the most preferable to obtain from the system.

unsigned int usec

microseconds (modulo 1,000,000)

const char * IO_StatusStr(EIO_Status status)

Get the text form of an enum status value.

const char * CORE_GetUsernameEx(char *buf, size_t bufsize, ECORE_Username username)

Obtain and store in the buffer provided, the best (as possible) user name that matches the requested ...

@ eIO_Timeout

timeout expired before any I/O succeeded

@ eIO_Success

everything is fine, no error occurred

@ eIO_ReadPlain

read readily available data only, wait if none

@ eIO_ReadPersist

read exactly as much as requested, w/waits

@ eIO_WritePersist

write exactly as much as specified, w/waits

@ eIO_ReadWrite

eIO_Read | eIO_Write (also, eCONN_OnFlush)

@ eIO_Close

also serves as an error indicator in SOCK_Poll

unsigned int

A callback function used to compare two keys in a database.

const struct ncbi::grid::netcache::search::fields::SIZE size

double NCBI_simple_atof(const char *s, char **t)

Locale-independent ASCII-to-double conversion of string "s".

char * strncpy0(char *s1, const char *s2, size_t n)

Copy not more than "n" characters from string "s2" into "s1", and return the result,...

const char * ConnNetInfo_GetValueInternal(const char *service, const char *param, char *value, size_t value_size, const char *def_value)

#define CORE_LOGF_X(subcode, level, fmt_args)

#define CORE_LOG_X(subcode, level, message)

static char s_MxHost[CONN_HOST_LEN+1]

static void x_Sendmail_InitEnv(void)

static int s_SockReadResponse(SOCK sock, int code, int alt_code, char *buf, size_t buf_size, int savecode)

static int s_SockRead(SOCK sock, char *response, size_t max_response_len, int savecode)

#define SENDMAIL_READ_RESPONSE(code, buffer)

#define SENDMAIL_RETURN2(subcode, reason, explanation)

static size_t s_FromSize(const SSendMailInfo *info)

static int s_SockWrite(SOCK sock, const char *buf, size_t len)

#define MX_SENDMAIL_MAGIC

static const char * s_SendRcpt(SOCK sock, const char *to, char buf[], size_t buf_size, const char what[], const char write_error[], const char proto_error[], const SSendMailInfo *info)

static void s_MakeFrom(char *buf, size_t size, const char *from, ECORE_Username user)

#define SENDMAIL_RETURN(subcode, reason)

static STimeout s_MxTimeout

#define SENDMAIL_SENDRCPT(what, list, buffer)

static unsigned short s_MxPort

Define optional parameters for communication with sendmail.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4