int call_spamc(FILE *tmp_msg, char *user, int maxsize) {
   struct message msg;
   FILE *tmp_sa_msg;
   int tmp_msg_fd;
   int err,flags,is_spam;
   struct sockaddr addr;

   tmp_msg_fd=fileno(tmp_msg);
   flags = SPAMC_RAW_MODE | SPAMC_SAFE_FALLBACK;
   
#if WITH_DEBUG == 1
       fprintf(stderr, "SpamAssassin Check\n");
#endif

   msg.max_len=maxsize;
   msg.type=MESSAGE_NONE;
   msg.raw=(char *)malloc(msg.max_len);
   
   err=lookup_host(SPAMD_HOST, SPAMD_PORT, &addr);
   if(err!=EX_OK) {
	   fprintf(stderr, "BARF on lookup_host (%d)\n",err);
	   return;
   }
   rewind(tmp_msg);
   err=message_read(tmp_msg_fd,SPAMC_RAW_MODE, &msg);
   if(err != EX_OK) {
	fprintf(stderr, "BARF on message_read (%d)\n",err);
	return;
   }
   err=message_filter(&addr, user, flags|SPAMC_CHECK_ONLY, &msg);
   if(err != EX_OK) {
	fprintf(stderr, "BARF on message_filter (%d)\n",err);
	return;
   }
   is_spam=msg.is_spam;
   /* 
    * We currently run the message through the filter twice.  Becuase
    * libspamc doesn't fill in all the msg structures w/o CHECK_ONLY
    * Until this is fixed or a better workaround comes up this is how
    * it is handled (one 'check only' and one real check)
    */
   rewind(tmp_msg);
   err=message_filter(&addr, user, flags, &msg);
   if(err != EX_OK) {
	fprintf(stderr, "BARF on message_filter (%d)\n",err);
	return;
   }
   rewind(tmp_msg);
   if(err=message_write(tmp_msg_fd, &msg)<0) {
	fprintf(stderr, "BARF on message_write (%d)\n",err);
	return;
   }
   /* Restore from the original is_spam check */
   msg.is_spam = is_spam;
   if(msg.is_spam == EX_TOOBIG) msg.is_spam=0; /* Ignore Too Big errs */

   return msg.is_spam;
}
Beispiel #2
0
/**
 * Called by a diagnostic to report an error.
 * message is a string to be reported when announcements
 * are enabled.
 */
void
diag_post_error (char *message, U8 page)
{
	/* Increment total error count */
	diag_error_count++;

#ifdef CONFIG_DMD_OR_ALPHA
	/* If announcements are on, then write a message.
	If it is the first such error detected, then print the
	initial "TEST REPORT" message too. */
	if (diag_announce_flag)
	{
		if (diag_error_count == 1)
		{
			diag_message_start ();
			font_render_string_center (&font_mono5, 64, 6, "TEST REPORT...");
			diag_message_flash ();
		}

		message_write (message, page);
		diag_message_scroll ();
	}
#endif
}
Beispiel #3
0
int message_write_string(int fd, message_type_t type, const char * buffer) {
  message_t message;
  message_construct_string(&message,type,buffer);
  return message_write(fd,&message);
}