Browse Source

Add input field in fmail_ctx structure

tags/v0.1.0
Damien Goutte-Gattat 9 years ago
parent
commit
81fe97ae6f
1 changed files with 9 additions and 5 deletions
  1. +9
    -5
      src/fmail.c

+ 9
- 5
src/fmail.c View File

@@ -107,6 +107,7 @@ typedef struct fmail_ctx
const char *footer;
magic_t magic_ctx;
gpgme_ctx_t signing_ctx;
FILE *input;
} fmail_ctx_t;

static char *
@@ -242,7 +243,7 @@ read_headers(FILE *in, string_buffer_t *headers)
static void process_attachment(const char *, magic_t, FILE *);

static void
process_text_body(fmail_ctx_t *ctx, FILE *in, FILE *out)
process_text_body(fmail_ctx_t *ctx, FILE *out)
{
char boundary[32];
int i;
@@ -259,7 +260,7 @@ process_text_body(fmail_ctx_t *ctx, FILE *in, FILE *out)
fprintf(out, "Content-Type: text/plain; charset=\"utf-8\"\r\n"
"Content-Transfer-Encoding: quoted-printable\r\n"
"Content-Disposition: inline\r\n\r\n");
qp_encode_stream(in, out);
qp_encode_stream(ctx->input, out);
fprintf(out, "\r\n");

if ( ctx->footer ) {
@@ -434,6 +435,7 @@ main(int argc, char *argv[])
ctx.attachments = NULL;
ctx.att_count = 0;
ctx.footer = NULL;
ctx.input = stdin;

while ( (c = getopt_long(argc, argv, "hvsa:f:H:F:T:C:S:",
options, NULL)) != -1 ) {
@@ -491,7 +493,7 @@ main(int argc, char *argv[])
sb_addf(headers, "User-Agent: fmail %s\r\n", VERSION);

/* Read user-provided headers. */
read_headers(stdin, headers);
read_headers(ctx.input, headers);

/* Write all headers. */
fprintf(stdout, "%s", sb_get(headers));
@@ -499,7 +501,7 @@ main(int argc, char *argv[])
if ( ctx.signing_ctx ) {
FILE *tmp = tmpfile();

process_text_body(&ctx, stdin, tmp);
process_text_body(&ctx, tmp);
fseek(tmp, 0, SEEK_SET);
sign_stream(ctx.signing_ctx, tmp, stdout);

@@ -507,7 +509,9 @@ main(int argc, char *argv[])
gpgme_release(ctx.signing_ctx);
}
else
process_text_body(&ctx, stdin, stdout);
process_text_body(&ctx, stdout);

fclose(ctx.input);

if ( ctx.attachments )
free(ctx.attachments);


Loading…
Cancel
Save