int msgmod_insert_header(void *ctx, int argc, var_t *args[]) { char *headerf; char *headerv; long index = 0; if (argc < 2 || argc > 3) { log_error("msgmod_insert_header: bad argument count"); return -1; } headerf = args[0]->v_data; headerv = args[1]->v_data; if (argc == 3) { index = atol(args[2]->v_data); } if (smfi_insheader(ctx, index, headerf, headerv) != MI_SUCCESS) { log_error("msgmod_insert_header: smfi_insheader failed"); return -1; } log_debug("msgmod_insert_header: %s: %s (%d)", headerf, headerv, index); return 0; }
static void add_x_header(SMFICTX *ctx, char *st, unsigned int scanned, unsigned int status) { if(addxvirus == 1) { /* Replace/Yes */ while(scanned) if(smfi_chgheader(ctx, (char *)"X-Virus-Scanned", scanned--, NULL) != MI_SUCCESS) logg("^Failed to remove existing X-Virus-Scanned header\n"); while(status) if(smfi_chgheader(ctx, (char *)"X-Virus-Status", status--, NULL) != MI_SUCCESS) logg("^Failed to remove existing X-Virus-Status header\n"); if(smfi_addheader(ctx, (char *)"X-Virus-Scanned", xvirushdr) != MI_SUCCESS) logg("^Failed to add X-Virus-Scanned header\n"); if(smfi_addheader(ctx, (char *)"X-Virus-Status", st) != MI_SUCCESS) logg("^Failed to add X-Virus-Status header\n"); } else { /* Add */ if(smfi_insheader(ctx, 1, (char *)"X-Virus-Scanned", xvirushdr) != MI_SUCCESS) logg("^Failed to insert X-Virus-Scanned header\n"); if(smfi_insheader(ctx, 1, (char *)"X-Virus-Status", st) != MI_SUCCESS) logg("^Failed to insert X-Virus-Status header\n"); } }
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)); }