library/src/network/email/BP-EmailSMTP.cc
// creates a new message structure.  All pointer arrays must be null ptr terminated.  Suffer under
// peril if you omit this warning.
creates a new message structure.  All pointer arrays must be null ptr terminated.  Suffer under
peril if you omit this warning.
creates a new message structure . All pointer arrays must be null ptr terminated . Suffer under peril if you omit this warning .
P_BP_EMAIL_SMTP_MESSAGE BP_CreateSMTPMessage(char **recipients, char *mail_from, char **headers, char **message_body)
{
	P_BP_EMAIL_SMTP_MESSAGE message = (P_BP_EMAIL_SMTP_MESSAGE) bpcalloc(sizeof(BP_EMAIL_SMTP_MESSAGE), 1);
	size_t n = 0;
	if(mail_from)
	{
		snprintf(message->mail_from, 1000, "%s", mail_from);
	}
	if(recipients)
	if(recipients[0])
	{
		for(n=0; recipients[n]; n++)
		{
			message->recipients = (char **) bprealloc(message->recipients, sizeof(char *) * (n+2));
			message->recipients[n]   = bpstrndup(recipients[n], 512);
			message->recipients[n+1] = NULL;
		}
		message->recipient_cnt = n;
	}
	if(headers)
	if(headers[0])
	{
		for(n=0; headers[n]; n++)
		{
			message->headers = (char **) bprealloc(message->headers, sizeof(char *) * (n+2));
			message->headers[n]   = bpstrndup(headers[n], 512);
			message->headers[n+1] = NULL;
		}
		message->header_cnt = n;
	}
	if(message_body)
	if(message_body[0])
	{
		for(n=0; message_body[n]; n++)
		{
			message->message_body = (char **) bprealloc(message->message_body, sizeof(char *) * (n+2));
			message->message_body[n]   = bpstrndup(message_body[n], 512);
			message->message_body[n+1] = NULL;
		}
		message->message_line_cnt = n;
	}
	return message;
}
P_BP_EMAIL_SMTP_MESSAGE BP_CreateSMTPMessage ( char * * recipients , char * mail_from , char * * headers , char * * message_body ) { P_BP_EMAIL_SMTP_MESSAGE message = ( P_BP_EMAIL_SMTP_MESSAGE ) bpcalloc ( sizeof ( BP_EMAIL_SMTP_MESSAGE ) , 1 ) ; size_t n = 0 ; if ( mail_from ) { snprintf ( message -> mail_from , 1000 , " " , mail_from ) ; } if ( recipients ) if ( recipients [ 0 ] ) { for ( n = 0 ; recipients [ n ] ; n ++ ) { message -> recipients = ( char * * ) bprealloc ( message -> recipients , sizeof ( char * ) * ( n + 2 ) ) ; message -> recipients [ n ] = bpstrndup ( recipients [ n ] , 512 ) ; message -> recipients [ n + 1 ] = NULL ; } message -> recipient_cnt = n ; } if ( headers ) if ( headers [ 0 ] ) { for ( n = 0 ; headers [ n ] ; n ++ ) { message -> headers = ( char * * ) bprealloc ( message -> headers , sizeof ( char * ) * ( n + 2 ) ) ; message -> headers [ n ] = bpstrndup ( headers [ n ] , 512 ) ; message -> headers [ n + 1 ] = NULL ; } message -> header_cnt = n ; } if ( message_body ) if ( message_body [ 0 ] ) { for ( n = 0 ; message_body [ n ] ; n ++ ) { message -> message_body = ( char * * ) bprealloc ( message -> message_body , sizeof ( char * ) * ( n + 2 ) ) ; message -> message_body [ n ] = bpstrndup ( message_body [ n ] , 512 ) ; message -> message_body [ n + 1 ] = NULL ; } message -> message_line_cnt = n ; } return message ; }
creates a new message structure.
creates a new message structure .
// create new message // loop iterator for counting arrays // set mail from if its there // set recipients if we have any // count the elements // bpreallocate space on loop // set recipients (duplicate string) // set the count // -- now set headers --- // set recipients if we have any // count the elements // bpreallocate space on loop // set headers (duplicate string) // set the count // -- message body --- // set recipients if we have any // count the elements // bpreallocate space on loop // set headers (duplicate string) // set the count // return the new message