send.c (da52b4caaf187775f6b56a72c6b16e94ad728f7b) | send.c (6d8484b0d0191b66f9bfd0dfa89c06a29647f02a) |
---|---|
1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 38 unchanged lines hidden (view full) --- 47/* 48 * Send message described by the passed pointer to the 49 * passed output buffer. Return -1 on error. 50 * Adjust the status: field if need be. 51 * If doign is given, suppress ignored header fields. 52 * prefix is a string to prepend to each output line. 53 */ 54int | 1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 38 unchanged lines hidden (view full) --- 47/* 48 * Send message described by the passed pointer to the 49 * passed output buffer. Return -1 on error. 50 * Adjust the status: field if need be. 51 * If doign is given, suppress ignored header fields. 52 * prefix is a string to prepend to each output line. 53 */ 54int |
55sendmessage(mp, obuf, doign, prefix) 56 struct message *mp; 57 FILE *obuf; 58 struct ignoretab *doign; 59 char *prefix; | 55sendmessage(struct message *mp, FILE *obuf, struct ignoretab *doign, 56 char *prefix) |
60{ 61 long count; 62 FILE *ibuf; 63 char *cp, *cp2, line[LINESIZE]; 64 int ishead, infld, ignoring, dostat, firstline; 65 int c, length, prefixlen; 66 67 /* --- 154 unchanged lines hidden (view full) --- 222 return (-1); 223 return (0); 224} 225 226/* 227 * Output a reasonable looking status field. 228 */ 229void | 57{ 58 long count; 59 FILE *ibuf; 60 char *cp, *cp2, line[LINESIZE]; 61 int ishead, infld, ignoring, dostat, firstline; 62 int c, length, prefixlen; 63 64 /* --- 154 unchanged lines hidden (view full) --- 219 return (-1); 220 return (0); 221} 222 223/* 224 * Output a reasonable looking status field. 225 */ 226void |
230statusput(mp, obuf, prefix) 231 struct message *mp; 232 FILE *obuf; 233 char *prefix; | 227statusput(struct message *mp, FILE *obuf, char *prefix) |
234{ 235 char statout[3]; 236 char *cp = statout; 237 238 if (mp->m_flag & MREAD) 239 *cp++ = 'R'; 240 if ((mp->m_flag & MNEW) == 0) 241 *cp++ = 'O'; 242 *cp = '\0'; 243 if (statout[0] != '\0') 244 fprintf(obuf, "%sStatus: %s\n", 245 prefix == NULL ? "" : prefix, statout); 246} 247 248/* 249 * Interface between the argument list and the mail1 routine 250 * which does all the dirty work. 251 */ 252int | 228{ 229 char statout[3]; 230 char *cp = statout; 231 232 if (mp->m_flag & MREAD) 233 *cp++ = 'R'; 234 if ((mp->m_flag & MNEW) == 0) 235 *cp++ = 'O'; 236 *cp = '\0'; 237 if (statout[0] != '\0') 238 fprintf(obuf, "%sStatus: %s\n", 239 prefix == NULL ? "" : prefix, statout); 240} 241 242/* 243 * Interface between the argument list and the mail1 routine 244 * which does all the dirty work. 245 */ 246int |
253mail(to, cc, bcc, smopts, subject, replyto) 254 struct name *to, *cc, *bcc, *smopts; 255 char *subject, *replyto; | 247mail(struct name *to, struct name *cc, struct name *bcc, struct name *smopts, 248 char *subject, char *replyto) |
256{ 257 struct header head; 258 259 head.h_to = to; 260 head.h_subject = subject; 261 head.h_cc = cc; 262 head.h_bcc = bcc; 263 head.h_smopts = smopts; --- 4 unchanged lines hidden (view full) --- 268} 269 270 271/* 272 * Send mail to a bunch of user names. The interface is through 273 * the mail routine below. 274 */ 275int | 249{ 250 struct header head; 251 252 head.h_to = to; 253 head.h_subject = subject; 254 head.h_cc = cc; 255 head.h_bcc = bcc; 256 head.h_smopts = smopts; --- 4 unchanged lines hidden (view full) --- 261} 262 263 264/* 265 * Send mail to a bunch of user names. The interface is through 266 * the mail routine below. 267 */ 268int |
276sendmail(str) 277 char *str; | 269sendmail(char *str) |
278{ 279 struct header head; 280 281 head.h_to = extract(str, GTO); 282 head.h_subject = NULL; 283 head.h_cc = NULL; 284 head.h_bcc = NULL; 285 head.h_smopts = NULL; 286 head.h_replyto = value("REPLYTO"); 287 head.h_inreplyto = NULL; 288 mail1(&head, 0); 289 return (0); 290} 291 292/* 293 * Mail a message on standard input to the people indicated 294 * in the passed header. (Internal interface). 295 */ 296void | 270{ 271 struct header head; 272 273 head.h_to = extract(str, GTO); 274 head.h_subject = NULL; 275 head.h_cc = NULL; 276 head.h_bcc = NULL; 277 head.h_smopts = NULL; 278 head.h_replyto = value("REPLYTO"); 279 head.h_inreplyto = NULL; 280 mail1(&head, 0); 281 return (0); 282} 283 284/* 285 * Mail a message on standard input to the people indicated 286 * in the passed header. (Internal interface). 287 */ 288void |
297mail1(hp, printheaders) 298 struct header *hp; 299 int printheaders; | 289mail1(struct header *hp, int printheaders) |
300{ 301 char *cp; 302 char *nbuf; 303 int pid; 304 char **namelist; 305 struct name *to, *nsto; 306 FILE *mtf; 307 --- 120 unchanged lines hidden (view full) --- 428 (void)Fclose(mtf); 429} 430 431/* 432 * Fix the header by glopping all of the expanded names from 433 * the distribution list into the appropriate fields. 434 */ 435void | 290{ 291 char *cp; 292 char *nbuf; 293 int pid; 294 char **namelist; 295 struct name *to, *nsto; 296 FILE *mtf; 297 --- 120 unchanged lines hidden (view full) --- 418 (void)Fclose(mtf); 419} 420 421/* 422 * Fix the header by glopping all of the expanded names from 423 * the distribution list into the appropriate fields. 424 */ 425void |
436fixhead(hp, tolist) 437 struct header *hp; 438 struct name *tolist; | 426fixhead(struct header *hp, struct name *tolist) |
439{ 440 struct name *np; 441 442 hp->h_to = NULL; 443 hp->h_cc = NULL; 444 hp->h_bcc = NULL; 445 for (np = tolist; np != NULL; np = np->n_flink) { 446 /* Don't copy deleted addresses to the header */ --- 11 unchanged lines hidden (view full) --- 458 } 459} 460 461/* 462 * Prepend a header in front of the collected stuff 463 * and return the new file. 464 */ 465FILE * | 427{ 428 struct name *np; 429 430 hp->h_to = NULL; 431 hp->h_cc = NULL; 432 hp->h_bcc = NULL; 433 for (np = tolist; np != NULL; np = np->n_flink) { 434 /* Don't copy deleted addresses to the header */ --- 11 unchanged lines hidden (view full) --- 446 } 447} 448 449/* 450 * Prepend a header in front of the collected stuff 451 * and return the new file. 452 */ 453FILE * |
466infix(hp, fi) 467 struct header *hp; 468 FILE *fi; | 454infix(struct header *hp, FILE *fi) |
469{ 470 FILE *nfo, *nfi; 471 int c, fd; 472 char tempname[PATHSIZE]; 473 474 (void)snprintf(tempname, sizeof(tempname), 475 "%s/mail.RsXXXXXXXXXX", tmpdir); 476 if ((fd = mkstemp(tempname)) == -1 || --- 34 unchanged lines hidden (view full) --- 511 return (nfi); 512} 513 514/* 515 * Dump the to, subject, cc header on the 516 * passed file buffer. 517 */ 518int | 455{ 456 FILE *nfo, *nfi; 457 int c, fd; 458 char tempname[PATHSIZE]; 459 460 (void)snprintf(tempname, sizeof(tempname), 461 "%s/mail.RsXXXXXXXXXX", tmpdir); 462 if ((fd = mkstemp(tempname)) == -1 || --- 34 unchanged lines hidden (view full) --- 497 return (nfi); 498} 499 500/* 501 * Dump the to, subject, cc header on the 502 * passed file buffer. 503 */ 504int |
519puthead(hp, fo, w) 520 struct header *hp; 521 FILE *fo; 522 int w; | 505puthead(struct header *hp, FILE *fo, int w) |
523{ 524 int gotcha; 525 526 gotcha = 0; 527 if (hp->h_to != NULL && w & GTO) 528 fmt("To:", hp->h_to, fo, w&GCOMMA), gotcha++; 529 if (hp->h_subject != NULL && w & GSUBJECT) 530 fprintf(fo, "Subject: %s\n", hp->h_subject), gotcha++; --- 9 unchanged lines hidden (view full) --- 540 (void)putc('\n', fo); 541 return (0); 542} 543 544/* 545 * Format the given header line to not exceed 72 characters. 546 */ 547void | 506{ 507 int gotcha; 508 509 gotcha = 0; 510 if (hp->h_to != NULL && w & GTO) 511 fmt("To:", hp->h_to, fo, w&GCOMMA), gotcha++; 512 if (hp->h_subject != NULL && w & GSUBJECT) 513 fprintf(fo, "Subject: %s\n", hp->h_subject), gotcha++; --- 9 unchanged lines hidden (view full) --- 523 (void)putc('\n', fo); 524 return (0); 525} 526 527/* 528 * Format the given header line to not exceed 72 characters. 529 */ 530void |
548fmt(str, np, fo, comma) 549 const char *str; 550 struct name *np; 551 FILE *fo; 552 int comma; | 531fmt(const char *str, struct name *np, FILE *fo, int comma) |
553{ 554 int col, len; 555 556 comma = comma ? 1 : 0; 557 col = strlen(str); 558 if (col) 559 fputs(str, fo); 560 for (; np != NULL; np = np->n_flink) { --- 15 unchanged lines hidden (view full) --- 576} 577 578/* 579 * Save the outgoing mail on the passed file. 580 */ 581 582/*ARGSUSED*/ 583int | 532{ 533 int col, len; 534 535 comma = comma ? 1 : 0; 536 col = strlen(str); 537 if (col) 538 fputs(str, fo); 539 for (; np != NULL; np = np->n_flink) { --- 15 unchanged lines hidden (view full) --- 555} 556 557/* 558 * Save the outgoing mail on the passed file. 559 */ 560 561/*ARGSUSED*/ 562int |
584savemail(name, fi) 585 char name[]; 586 FILE *fi; | 563savemail(char name[], FILE *fi) |
587{ 588 FILE *fo; 589 char buf[BUFSIZ]; 590 int i; 591 time_t now; 592 593 if ((fo = Fopen(name, "a")) == NULL) { 594 warn("%s", name); --- 14 unchanged lines hidden --- | 564{ 565 FILE *fo; 566 char buf[BUFSIZ]; 567 int i; 568 time_t now; 569 570 if ((fo = Fopen(name, "a")) == NULL) { 571 warn("%s", name); --- 14 unchanged lines hidden --- |