示例#1
0
文件: msgmod.c 项目: badzong/mopher
int
msgmod_add_rcpt(void *ctx, int argc, var_t *args[])
{
	char *rcpt;
	char *esmtp_args = NULL;
	int r;

	if (argc < 1 || argc > 2)
	{
		log_error("msgmod_add_rcpt: bad argument count");
		return -1;
	}

	rcpt = args[0]->v_data;

	if (argc == 2)
	{
		esmtp_args = args[1]->v_data;
		r = smfi_addrcpt_par(ctx, rcpt, esmtp_args);
	}
	else
	{
		r = smfi_addrcpt(ctx, rcpt);
	}

	if (r != MI_SUCCESS)
	{
		log_error("msgmod_add_rcpt: smfi_addrcpt failed");
		return -1;
	}

	log_debug("msgmod_add_rcpt: %s %s", rcpt,
		esmtp_args? esmtp_args: "");

	return 0;
}
示例#2
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;
	char   *args;

	for (count = 0; count < add_rcpt_count; count++) {
	    if ((args = strchr(add_rcpt[count], ' ')) != 0) {
		*args++ = 0;
		if (smfi_addrcpt_par(ctx, add_rcpt[count], args) == MI_FAILURE)
		    fprintf(stderr, "smfi_addrcpt_par `%s' `%s' failed\n",
			    add_rcpt[count], args);
	    } else {
		if (smfi_addrcpt(ctx, add_rcpt[count]) == MI_FAILURE)
		    fprintf(stderr, "smfi_addrcpt `%s' failed\n",
			    add_rcpt[count]);
	    }
	}

	for (count = 0; count < del_rcpt_count; count++)
	    if (smfi_delrcpt(ctx, del_rcpt[count]) == MI_FAILURE)
		fprintf(stderr, "smfi_delrcpt `%s' failed\n", del_rcpt[count]);
    }
    return (test_reply(ctx, test_eom_reply));
}