/[mailutils]/mailutils/mail/reply.c
ViewVC logotype

Diff of /mailutils/mail/reply.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by gray, Thu Aug 15 12:55:57 2002 UTC revision 1.12 by gray, Thu Sep 26 14:19:44 2002 UTC
# Line 25  Line 25 
25   */   */
26    
27  int  int
28  mail_reply(int argc, char **argv)  mail_reply (int argc, char **argv)
29  {  {
30    if (argc > 1)    if (argc > 1)
31      return util_msglist_command(mail_reply, argc, argv, 1);      return util_msglist_command (mail_reply, argc, argv, 1);
32    else    else
33      {      {
34        message_t msg;        message_t msg;
35        header_t hdr;        header_t hdr;
36        struct send_environ env;        compose_env_t env;
37        int status;        int status;
38        char *str;        char *str;
39    
40        env.to = env.cc = env.bcc = env.subj = NULL;        compose_init (&env);
       env.outfiles = NULL; env.nfiles = 0;  
41    
42        if (mailbox_get_message(mbox, cursor, &msg))        if (mailbox_get_message (mbox, cursor, &msg))
43          {          {
44            util_error("%d: can't get message", cursor);            util_error ("%d: can't get message", cursor);
45            return 1;            return 1;
46          }          }
47    
48        message_get_header(msg, &hdr);        message_get_header (msg, &hdr);
49    
50        env.to = util_get_sender(cursor, 0);        compose_header_set (&env, MU_HEADER_TO, util_get_sender (cursor, 0),
51        if (islower(argv[0][0]))                            COMPOSE_SINGLE_LINE);
52    
53          if (islower (argv[0][0]))
54          {          {
55            /* Add all recepients of the originate letter */            /* Add all recepients of the originate letter */
56    
# Line 57  mail_reply(int argc, char **argv) Line 58  mail_reply(int argc, char **argv)
58            size_t i, count = 0;            size_t i, count = 0;
59            char buf[512];            char buf[512];
60    
61            if (header_aget_value(hdr, MU_HEADER_TO, &str) == 0)            if (header_aget_value (hdr, MU_HEADER_TO, &str) == 0)
62              {              {
63                address_create(&addr, str);                address_create (&addr, str);
64                free(str);                free (str);
65                address_get_count(addr, &count);                address_get_count (addr, &count);
66              }              }
67    
68            /* Make sure we do not include our alternate names */            /* Make sure we do not include our alternate names */
69            for (i = 1; i <= count; i++)            for (i = 1; i <= count; i++)
70              {              {
71                address_get_email(addr, i, buf, sizeof(buf), NULL);                address_get_email (addr, i, buf, sizeof (buf), NULL);
72                if (!mail_is_my_name(buf))                if (!mail_is_my_name (buf))
73                  {                  compose_header_set (&env, MU_HEADER_TO,
74                    util_strcat(&env.to, " ");                                      buf,
75                    util_strcat(&env.to, buf);                                      COMPOSE_SINGLE_LINE);
                 }  
76              }              }
77    
78            /* Finally, add any Ccs */            /* Finally, add any Ccs */
79            header_aget_value(hdr, MU_HEADER_CC, &env.cc);            header_aget_value (hdr, MU_HEADER_CC, &str);
80              compose_header_set (&env, MU_HEADER_TO, str, COMPOSE_SINGLE_LINE);
81          }          }
82    
83        if (header_aget_value(hdr, MU_HEADER_SUBJECT, &str) == 0)        if (header_aget_value (hdr, MU_HEADER_SUBJECT, &str) == 0)
84          {          {
85              char *p = NULL;
86    
87            if (strncasecmp (str, "Re:", 3))            if (strncasecmp (str, "Re:", 3))
88              util_strcat (&env.subj, "Re: ");              util_strcat (&p, "Re: ");
89            util_strcat (&env.subj, str);            util_strcat (&p, str);
90            free (str);            free (str);
91              compose_header_set (&env, MU_HEADER_SUBJECT, p, COMPOSE_REPLACE);
92              free (p);
93          }          }
94        else        else
95          util_strcat (&env.subj, "");          compose_header_set (&env, MU_HEADER_SUBJECT, "", COMPOSE_REPLACE);
96        fprintf(ofile, "To: %s\n", env.to);  
97        if (env.cc)        fprintf (ofile, "To: %s\n",
98          fprintf(ofile, "Cc: %s\n", env.cc);                 compose_header_get (&env, MU_HEADER_TO, ""));
99        fprintf(ofile, "Subject: %s\n\n", env.subj);        str = compose_header_get (&env, MU_HEADER_CC, NULL);
100          if (str)
101            fprintf (ofile, "Cc: %s\n", str);
102          fprintf (ofile, "Subject: %s\n\n",
103                   compose_header_get (&env, MU_HEADER_SUBJECT, ""));
104    
105        status = mail_send0(&env, 0);        status = mail_send0 (&env, 0);
106        free_env_headers (&env);        compose_destroy (&env);
107        return status;        return status;
108      }      }
109    return 1;    return 1;

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26