예제 #1
0
static sfsistat test_eom(SMFICTX *ctx)
{
    printf("test_eom\n");
#ifdef SMFIR_REPLBODY
    if (body_file) {
	char    buf[BUFSIZ + 2];
	FILE   *fp;
	size_t  len;
	int     count;

	if ((fp = fopen(body_file, "r")) == 0) {
	    perror(body_file);
	} else {
	    printf("replace body with content of %s\n", body_file);
	    for (count = 0; fgets(buf, BUFSIZ, fp) != 0; count++) {
		len = strcspn(buf, "\n");
		buf[len + 0] = '\r';
		buf[len + 1] = '\n';
		if (smfi_replacebody(ctx, buf, len + 2) == MI_FAILURE) {
		    fprintf(stderr, "body replace failure\n");
		    exit(1);
		}
		if (verbose)
		    printf("%.*s\n", (int) len, buf);
	    }
	    if (count == 0)
		perror("fgets");
	    (void) fclose(fp);
	}
    }
#endif
#ifdef SMFIR_CHGFROM
    if (chg_from != 0 && smfi_chgfrom(ctx, chg_from, "whatever") == MI_FAILURE)
	fprintf(stderr, "smfi_chgfrom failed\n");
#endif
#ifdef SMFIR_INSHEADER
    if (ins_hdr && smfi_insheader(ctx, ins_idx, ins_hdr, ins_val) == MI_FAILURE)
	fprintf(stderr, "smfi_insheader failed\n");
#endif
#ifdef SMFIR_CHGHEADER
    if (chg_hdr && smfi_chgheader(ctx, chg_hdr, chg_idx, chg_val) == MI_FAILURE)
	fprintf(stderr, "smfi_chgheader failed\n");
#endif
    {
	int     count;

	for (count = 0; count < rcpt_count; count++)
	    if (smfi_addrcpt(ctx, rcpt_addr[count]) == MI_FAILURE)
		fprintf(stderr, "smfi_addrcpt `%s' failed\n", rcpt_addr[count]);
    }
    return (test_reply(ctx, test_eom_reply));
}
예제 #2
0
파일: msgmod.c 프로젝트: badzong/mopher
int
msgmod_change_body(void *ctx, int argc, var_t *args[])
{
	char *body;
	int size;

	if (argc != 1)
	{
		log_error("msgmod_change_nody: bad argument count");
		return -1;
	}

	body = args[0]->v_data;
	size = strlen(body);

	if (smfi_replacebody(ctx, (void *) body, size) != MI_SUCCESS)
	{
		log_error("msgmod_change_body: smfi_replacebody failed");
		return -1;
	}

	return 0;
}